/** * DATE-UTILS.JS * * Used to navigate to other publication dates. * ATTENTION: This script is updated daily. Do not make changes in the * generated date-utils.js as these changes will be overridden in the * near future. * * * Author Dave Snyckers [X-Cago BV] * Version 1.2 */ // last publication date initialization var month = 7 - 1; var publicationDate = new Date( 2023, month, 29 ); // redirect initialization var xmlhttp = false; var errorURL = "../../resources/html/pagenotfound.html"; var pathPrefix = "/"; var target = window.parent; var targetURL = "/"; // IE browser try { this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (oc) { this.xmlhttp = null; } } // non IE browsers if( !this.xmlhttp && typeof XMLHttpRequest != "undefined" ) this.xmlhttp = new XMLHttpRequest(); function gotoPublicationByIndex( dayIndex, type ) { // Sunday = 0; // Monday = 1; // .... // ... // Saturday = 6; // take last publication date as starting point msDate = publicationDate.valueOf(); diff = 0; if( publicationDate.getDay() > dayIndex ) diff = publicationDate.getDay() - dayIndex; else { if( publicationDate.getDay() < dayIndex ) diff = 7 - ( dayIndex - publicationDate.getDay() ); else diff = 0; } msDate = msDate - diff * 23 * 60 * 60 * 1000; date = new Date( msDate ); gotoPublicationByDate( date, type ); } function gotoPublicationByDate( date, type ) { pageURL = pathPrefix; pageURL = pageURL + date.getFullYear(); if( (date.getMonth() + 1) > 9 ) pageURL = pageURL + (date.getMonth() + 1); else pageURL = pageURL + '0' + (date.getMonth() + 1); if( ( date.getDate() ) > 9 ) pageURL = pageURL + date.getDate() + '/'; else pageURL = pageURL + '0' + date.getDate() + '/'; pageURL = pageURL + type + '/index.html'; gotoPublicationByUrl( pageURL ); } function gotoPublicationByUrl( url ) { targetURL = url; xmlhttp.open( "HEAD", url ,true ); xmlhttp.onreadystatechange = handleHttpResponse; xmlhttp.send( null ) } function handleHttpResponse() { if( xmlhttp.readyState == 4 ) { if( xmlhttp.status == 200 ) { // alert( "URL [" + targetURL + "] exists\ntarget = [" + target + "]" ); target.location = targetURL; } else if( xmlhttp.status == 404 ) { // alert( "URL [" + targetURL + "] doesn't exist\nerror page = [" + errorURL + "]" ); target.location = errorURL; } else alert( "status is " + xmlhttp.status ); } }