PublishingJS:TheNewSocial: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
const origin = window.location.origin | const origin = window.location.origin | ||
const title = "TheNewSocial" | |||
document.onreadystatechange = function () { | document.onreadystatechange = function () { | ||
Line 39: | Line 40: | ||
for ( const principle of principles ) { | for ( const principle of principles ) { | ||
console.log( principle.href ) | console.log( principle.href ) | ||
principle.href = principle.href.replace( `${ origin }/html/`, '#' ) | if ( !principle.href.includes('#') ) { | ||
principle.href = principle.href.replace( `${ origin }/html/`, '#' ) | |||
} | |||
console.log( principle.href ) | console.log( principle.href ) | ||
} | } | ||
} | } |
Revision as of 10:54, 26 April 2023
const origin = window.location.origin
const title = "TheNewSocial"
document.onreadystatechange = function () {
console.log( 'Hello from PublishingJS namespace!' )
make_case_studies_collapsible()
make_principles_collapsible()
}
function $( selector ) {
return document.querySelectorAll( selector )
}
function make_case_studies_collapsible() {
const nav_links = $('#toc a');
window.onhashchange = function() {
for (let i = 0; i < nav_links.length; i++) {
if (nav_links[i].href.match(/(#.*)/)[1] == window.location.hash) {
nav_links[i].className = 'selected';
} else {
nav_links[i].className = '';
}
}
}
}
function make_principles_collapsible() {
const principles = $( '#Principles > table th a' )
for ( const principle of principles ) {
console.log( principle.href )
if ( !principle.href.includes('#') ) {
principle.href = principle.href.replace( `${ origin }/html/`, '#' )
}
console.log( principle.href )
}
}