Created
October 8, 2011 16:42
-
-
Save syranez/1272521 to your computer and use it in GitHub Desktop.
the-kenny braucht Hauptmensa sonst weint er.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var kenny = (function() { | |
/** | |
* uri | |
* | |
* has to be enhanced with this \d\d\d\d-\d\d\d\d.htm | |
* @param string | |
*/ | |
var host = "http://studentenwerk.essen-duisburg.de/speiseplaene/kl_"; | |
var date = null; | |
var showNextWeek = true; | |
function getDay () { | |
if (date === null) { | |
date = new Date(); | |
} | |
var day = date.getDate(); | |
if (day < 10) { | |
return "0" + day; | |
} | |
return day; | |
}; | |
function getMonth () { | |
if (date === null) { | |
console.log("month is leer"); | |
date = new Date(); | |
} | |
var month = date.getMonth(); | |
month += 1; | |
if (month < 10) { | |
return "0" + month; | |
} | |
return month; | |
} | |
return { | |
getUri: function () { | |
date = new Date(); | |
var day = date.getDay(); | |
if (showNextWeek) { | |
if (day === 0) { | |
date = new Date(date.getTime() + 86400000); | |
} else if (day === 6) { | |
date = new Date(date.getTime() + (86400000)*2); | |
} | |
} | |
return host + getDay() + getMonth() + "-" + getDay() + getMonth() + ".htm"; | |
} | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use it with
document.location = kenny.getUri();
as bookmarklet.