Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
HNBK Vertretungsplan Bookmarklet
/* +++ Bookmarklet für den Browser, um immer den aktuell relevanten Vertretungspan für das HNBK Essen zu bekommen +++
* 1. Klassen-ID anpassen (Anleitung steht an der betreffenden Stelle im Code)
* 2. Gesamten Code kopieren
* 3. in einen Bookmarklet Generator einfügen und generieren
* --> z. B. http://mrcoles.com/bookmarklet/
* 4. FERTIG
*/
function getWeekNumber(d) {
d = new Date(+d);
d.setHours(0,0,0);
d.setDate(d.getDate() + 4 - (d.getDay()||7));
var yearStart = new Date(d.getFullYear(),0,1);
var weekNo = Math.ceil(( ( (d - yearStart) / 86400000) + 1)/7);
return weekNo;
// todo: fix getWeekNumber http://techblog.procurios.nl/k/news/view/33796/14863/calculate-iso-8601-week-and-year-in-javascript.html
}
function getUrl() {
/* ==> Klassen-ID hier modifizieren!! */
var classId = 'c00082';
/*
* Du kannst die ID herausfinden, indem du den ausgewählten Vertretungsplan (iFrame)
* in einem neuen Tab öffnest und in die URl schaust.
* In den meisten Browsern reicht ein Rechtsklick und ein "Frame in neuem Fenster öffnen"
*/
var weekNum = getWeekNumber(Date.now());
var currentDayIndex = new Date(Date.now()).getDay();
if(currentDayIndex == 0 || currentDayIndex == 6) {
/* good luck with last week of the year! */
weekNum++;
}
if(weekNum < 10) { weekNum = '0' + weekNum; }
return 'http://217.78.137.198:64004/c/' + weekNum + '/' + classId + '.htm';
}
(function(){
window.location.href = getUrl();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.