//minimize latest news
window.document.querySelector("#ncWrapper > #nc > #action_ncMinMax").click();
//select location in weather
// $("a:contains('München')").click();
// check if variable is stored in cookie
var loc = $.cookie('loc_cookie');
if ( loc != null) {
alert('loc existiert');
var loc_exists = 1;
}
else { var loc_exists = 0; };
// only ask for location if no location is saved yet [functions inside if work]
if ( !loc_exists ) {
var loc = prompt("Wählen Sie den Ort für den Wetterbericht?");
alert('Sie haben ' + loc + ' als Ort für den Wetterbericht gewählt.');
};
$("a:contains('" + loc + "')").click();
// save to cookie
$.cookie('loc_cookie', loc);
alert('loc in Cookie gespeichert');
Can anyone help me? the var loc = $.cookie('loc_cookie'); seems not to work. I just copy/pasted it and hope you know, what I want to make the js do.
- look for cookie -> get cookie and save if it exists
- if it doesn’t exist, ask for location || if if does do nothing.
- get location.
- save location in cookie.
Remove the “var” keyword within the if/else block. By adding it you create a new local variable.
Should be
Lastly, it might be clearer to use a boolean: