Last active
May 15, 2018 14:57
-
-
Save SimonGivre/8689670 to your computer and use it in GitHub Desktop.
Swiss Holidays
This file contains hidden or 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
// to be executed on http://www.feiertagskalender.ch/ | |
var year = 2019; | |
var hidepast = 0; // hide past values or not | |
var type = 3; // 3 = Legally recognized holidays ; 4 = Legally + not recognized holidays | |
var geos = { | |
"Aargau": 1, | |
"Appenzell Innerrhodes": 266, | |
"Appenzell Ausserrhoden": 245, | |
"Bern": 369, | |
"Basel-Land": 273, | |
"Basel-Stadt": 365, | |
"Fribourg": 796, | |
"Genève": 1026, | |
"Glarus": 1072, | |
"Graubünden": 1102, | |
"Jura": 1323, | |
"Lucerne": 1410, | |
"Neuchâtel": 1523, | |
"Nidwalden": 1592, | |
"Obwalden": 1604, | |
"Saint-Gall": 1827, | |
"Schaffhausen": 1612, | |
"Solothurn": 1690, | |
"Schwyz": 1653, | |
"Thurgau": 2173, | |
"Ticino": 1932, | |
"Uri": 2262, | |
"Vaud": 2283, | |
"Valais": 2685, | |
"Zug": 2860, | |
"Zurich": 2872 | |
}; | |
var result = {}; | |
$.each( geos, function( key, value ) { | |
$.each(['fr', 'en', 'de'], function( i, val ) { | |
$.get('https://www.feiertagskalender.ch/index.php?geo='+value+'&jahr='+year+'&hl='+val+'&hidepast='+hidepast+'&klasse='+type,function(data){ | |
if (!result[val]) { | |
result[val] = {}; | |
} | |
if (!result[val][key]) { | |
result[val][key] = []; | |
} | |
var rows = $(data).find('.list-group-item'); | |
$(rows).each(function(i,row){ | |
var date = $(row).find('div:nth-child(1)').text(); | |
var text = $(row).find('div:nth-child(3)').text(); | |
//if($(row).find('td:nth-child(4)').find('span').text() != '#') | |
result[val][key].push(key+'\t'+val+'\t'+date+'\t'+text+'\t'); | |
}); | |
}); | |
}); | |
}); | |
console.log('Waiting for result. 5s'); | |
setTimeout(function () { | |
$.each(['fr', 'en', 'de'], function( index, val ) { | |
$.each( geos, function( key, value ) { | |
$.each(result[val][key], function (i) { | |
console.log(result[val][key][i]); | |
}); | |
}); | |
}); | |
}, 5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment