Ero sivun ”Widget:Water level graph” versioiden välillä
Järvi-meriwikistä
Rivi 58: | Rivi 58: | ||
zi = -1; | zi = -1; | ||
for (var i in request.query.results) { | for (var i in request.query.results) { | ||
+ | |||
zi++; | zi++; | ||
resultItem = request.query.results[i].printouts; | resultItem = request.query.results[i].printouts; | ||
obsDate = new Date(toDateFromSecsSince1970(resultItem.Päivämäärä[0].timestamp)); | obsDate = new Date(toDateFromSecsSince1970(resultItem.Päivämäärä[0].timestamp)); | ||
− | + | ||
− | levelNum = resultItem.Vedenkorkeus[0].value; | + | if ( typeof resultItem.Vedenkorkeus[0].value != 'undefined' ) { |
− | + | ||
− | + | levelNum = resultItem.Vedenkorkeus[0].value; | |
− | + | if (resultItem.Lisätiedot[0] != undefined) { freeTxt = resultItem.Lisätiedot[0]; } | |
− | + | else { freeText = ''; } | |
− | + | if (obsDate.getFullYear() < firstYear) { firstYear = obsDate.getFullYear(); } | |
− | + | if (obsDate.getFullYear() > lastYear) { lastYear = obsDate.getFullYear(); } | |
− | + | if (obsDate.getMonth() < firstMonth) { firstMonth = obsDate.getMonth(); } | |
− | + | if (obsDate.getMonth() > lastMonth) { lastMonth = obsDate.getMonth(); } | |
+ | if (levelNum < minLevel) { minLevel = levelNum; } | ||
+ | if (levelNum > maxLevel) { maxLevel = levelNum; } | ||
− | + | // If image, get filename | |
− | + | if (resultItem.Tiedosto[0] != undefined) { | |
− | + | images++; | |
− | + | searchStr2 = "action=query&prop=imageinfo&iiprop=url&format=json&titles="; | |
− | + | searchStr2 += encodeURIComponent(resultItem.Tiedosto[0]); | |
− | + | jQuery.ajax({ | |
− | + | type: 'GET', | |
− | + | url: queryApi, | |
− | + | data: searchStr2, | |
− | + | dataType: 'jsonp', | |
− | + | index: zi, | |
− | + | success: function(request2) { | |
− | + | for (var x in request2.query.pages) { | |
− | + | imagesArr[this.index] = request2.query.pages[x].imageinfo[0].url; | |
− | + | break; | |
− | + | } | |
− | + | images--; | |
− | + | }, | |
− | + | error: function() { images--; } | |
− | + | }); | |
− | + | } | |
− | + | if (obsDate.getFullYear() < curYear) { | |
− | + | meanValuesArr.push(new Object( { days: obsDate.getDayOfYear(), level: levelNum, weight: 1 })); | |
+ | } | ||
+ | |||
} | } | ||
− | + | } | |
function imagesLoaded() { | function imagesLoaded() { |