"
},
{
name: "home",
imgs:["home.png"],
body: [
"This is my home.",
"welcome to it.",
]
},
{
name: "about",
body: [
"I make art.",
"I became a cat many meoowns ago i am catto",
"this display has no img, as the node has no imgs property",
"The view adapts, so all the object actually needs is a name in this example (undefined link demonstrates no name exception)"
]
},
{
name: "archive",
imgs:["archivedimg1.png","archivedimg2.png"],
body: ["my archive stuff / links."]
},
{
name: "art",
imgs:["myart1.png","myart2.png","myart3.png","notextbody.png"],
},
{
body: "this page forgot to specify a name property"
},
];
const nodeexception = { name: "content not found", body:["node retrieval failed successfully ","did you forget to give a page a name?"] };
// read only
Object.freeze( mSite );
Object.freeze( nodeexception );
// .text
// .text
// .text
const getNode = (n)=>{
for( let i=0; i < mSite.length; ++i )
if( n === mSite[i].name ) return mSite[i];
return nodeexception;
};
// display node content
// display node content
const myView = ( cnode ) => {
$('#mid').empty();
// add title
let content = ''+cnode.name.toUpperCase()+'
';
// add images if any
if (cnode.hasOwnProperty('imgs'))
for( let i = 0; i < cnode.imgs.length; ++i ){
content += '
';
// line break after every 2nd img
content += ( i%2 ) ? '
':'';
}
// add text body if any
content += cnode.hasOwnProperty('body')? ('' + cnode.body.join('
') + '
') : '';
// add script if any
content += ( cnode.hasOwnProperty('script')? cnode.script:'' );
// render
$('#mid').append( content );
};
$(document).ready( ()=>{
// prepare your body
$(document.body).append( center() );
$('#leftcol').append(ulElement);
// node links
mSite.forEach( (n,i,a)=>{
$('#linx').append(''+n.name+'');
});
// bind node link presses to view
$('li').click( (e)=>{
myView(getNode(e.target.id));
});
// first view
myView( getNode("main") );
// reactive
$(window).resize( ()=>{
$('#mid').css( 'width', (window.innerWidth - ((colw+space+border+padding) *2) )+'px' );
});
});