p (Tekstin korvaus – ”/w/images/” muotoon ”/images/”) |
Ei muokkausyhteenvetoa |
||
| Rivi 1: | Rivi 1: | ||
<includeonly><div id="<!--{$id|default:JwAlgalTable|escape:'html'}-->_container">Ladataan tietoja</div> | <includeonly> | ||
<div id="<!--{$id|default:JwAlgalTable|escape:'html'}-->_container"><p class="ingressi">Ladataan tietoja, odota...</p></div> | |||
<script type="text/javascript"> | <script type="text/javascript"> | ||
| Rivi 13: | Rivi 14: | ||
function <!--{$id|default:JwAlgalTable|escape:'html'}-->_func() { | function <!--{$id|default:JwAlgalTable|escape:'html'}-->_func() { | ||
var | var vuosi = "<!--{$vuosi|default:1998|escape:'html'}-->"; | ||
var | var alue = "<!--{$alue|escape:'html'}-->"; | ||
var | var ely, meri; | ||
var qtId = "<!--{$id|default: | |||
if ( alue == 'Sisävedet' ) { | |||
ely = 'ei'; | |||
meri = 0; | |||
} else if ( alue == 'Merialue' ) { | |||
ely = 'ei'; | |||
meri = 1; | |||
} else { | |||
ely = alue.replace( 'ELY', 'elinkeino-, liikenne- ja ympäristökeskus' ); | |||
meri = 2; | |||
} | |||
var kunta = "<!--{$kunta|default:ei|escape:'html'}-->"; | |||
var mk = "<!--{$maakunta|default:ei|escape:'html'}-->"; | |||
var qtId = "<!--{$id|default:algalTable|escape:'html'}-->"; | |||
var | var reqSuccess = false; | ||
var meripaikkoja = false; | |||
var numberOfRows = 0; | var numberOfRows = 0; | ||
var maxRows; | var maxRows = 0; | ||
var exportCsv = ""; | var exportCsv = ""; | ||
var dataArr = new Array(); | |||
var searchStr = "action=ask&query=" + encodeURI( | var searchStr = "action=ask&query=[[Havainto::>0]]"; | ||
searchStr += encodeURI( | searchStr += encodeURI("[[Tyyppi::Levätilanne]]"); | ||
searchStr += encodeURI("|?SiteID|?Vesistö|?Järvi|?Vesistöalue|?Kunta| | searchStr += encodeURI("[[Seuranta::Valtakunnallinen leväseuranta]]"); | ||
searchStr += "[[Vuosi::" + vuosi + "]]"; | |||
searchStr += "[[Viikko::>23]][[Viikko::<39]]"; | |||
if (ely != "ei") { searchStr += "[[ELY-keskus::" + encodeURI(ely) + "]]"; } | |||
if (kunta != "ei") { searchStr += "[[Kunta::" + encodeURI(kunta) + "]]"; } | |||
if (mk != "ei") { searchStr += "[[Maakunta::" + encodeURI(mk) + "]]"; } | |||
if (meri == "0") { searchStr += encodeURI("[[Vesistö::Järvi||Joki]]"); } | |||
else if (meri == "1") { searchStr += encodeURI("[[Vesistö::Meri]]"); } | |||
searchStr += encodeURI("|?SiteID|?SiteName|?Vesistö|?Alue|?Järvi|?Vesistöalue|?Kunta|?Viikko|?Levätilanne|limit=20000"); | |||
searchStr += '&format=json'; | searchStr += '&format=json'; | ||
jQuery.ajax({ | |||
type: 'GET', | |||
url: queryApi, | |||
data: searchStr, | |||
success: success, | |||
dataType: 'jsonp' | |||
}); | |||
function progressIndicator(d) { | function progressIndicator(d) { | ||
| Rivi 41: | Rivi 69: | ||
function success(request) { | function success(request) { | ||
console.log(request); | |||
reqSuccess = true; | |||
if ( request.query.meta.count > 0 ) { | |||
var output = ""; | |||
var lastSite = ""; | |||
var lastWeek = 0; | |||
output += '<div class="mw-content-ltr">' | |||
output += '<table width="100%" class="tablesorter sortable jquery-tablesorter wikitable smwtable Xsmalltable2 tablecompact" id="<!--{$id|default:JwAlgalTable|escape:'html'}-->" >'; | |||
output += '<thead><tr>'; | |||
output += '<th class="headerSort " style="text-align: left;"></th>'; | |||
output += '<th class="headerSort" style="text-align: left;">Vesistö</th>'; | |||
output += '<th class="headerSort" style="text-align: left;">Nimi</th>'; | |||
output += '<th class="headerSort" style="text-align: left;">Kunta</th>'; | |||
output += '<th class="headerSort headerSortSmall" style="text-align: center;">23</th>'; | |||
output += '<th class="headerSort headerSort-compact" style="text-align: center;">24</th>'; | |||
output += '<th class="headerSort headerSort-compact" style="text-align: center;">25</th>'; | |||
output += '<th class="headerSort headerSort-compact" style="text-align: center;">26</th>'; | |||
output += '<th class="headerSort headerSort-compact" style="text-align: center;">27</th>'; | |||
output += '<th class="headerSort headerSort-compact" style="text-align: center;">28</th>'; | |||
output += '<th class="headerSort headerSort-compact" style="text-align: center;">29</th>'; | |||
output += '<th class="headerSort headerSort-compact" style="text-align: center;">30</th>'; | |||
output += '<th class="headerSort headerSort-compact" style="text-align: center;">31</th>'; | |||
output += '<th class="headerSort headerSort-compact" style="text-align: center;">32</th>'; | |||
output += '<th class="headerSort headerSort-compact" style="text-align: center;">33</th>'; | |||
output += '<th class="headerSort headerSort-compact" style="text-align: center;">34</th>'; | |||
output += '<th class="headerSort headerSort-compact" style="text-align: center;">35</th>'; | |||
output += '<th class="headerSort headerSort-compact" style="text-align: center;">36</th>'; | |||
output += '<th class="headerSort headerSort-compact" style="text-align: center;">37</th>'; | |||
output += '<th class="headerSort headerSort-compact" style="text-align: center;">38</th>'; | |||
output += '<th class="headerSort headerSort-compact" style="text-align: center;">39</th>'; | |||
output += '</tr></thead><tbody>'; | |||
maxRows = request.query.results.length; | |||
var | var siteIDs = new Object(); | ||
for (var i in request.query.results) { | for (var i in request.query.results) { | ||
numberOfRows++; | |||
progressIndicator(numberOfRows); | |||
resultItem = request.query.results[i].printouts; | |||
resultPage = resultItem.SiteID[0]; | |||
if (dataArr[resultPage] == undefined) { | |||
dataArr[resultPage] = new Object(); | |||
dataArr[resultPage].url = "//www.jarviwiki.fi/wiki/index.php?curid=" + resultPage; | |||
dataArr[resultPage].SiteName = resultItem.SiteName[0].fulltext; | |||
if (resultItem.Vesistö[0] == 'Meri') { | |||
dataArr[resultPage].sea = true; | |||
} else { | |||
dataArr[resultPage].sea = false; | |||
} | |||
if (resultItem.Alue.length > 0) { | |||
dataArr[resultPage].wBody = resultItem.Alue[0].fulltext; | |||
dataArr[resultPage].wBodyUrl = resultItem.Alue[0].fullurl; | |||
} else { | |||
if (resultItem.Vesistö[0] == 'Järvi') { | |||
dataArr[resultPage].wBody = resultItem.Järvi[0].fulltext; | |||
dataArr[resultPage].wBodyUrl = resultItem.Järvi[0].fullurl; | |||
} else { | |||
dataArr[resultPage].wBody = resultItem.Vesistöalue[0].fulltext; | |||
dataArr[resultPage].wBodyUrl = resultItem.Vesistöalue[0].fullurl; | |||
} | |||
} | |||
dataArr[resultPage].mun = resultItem.Kunta[0].fulltext; | |||
dataArr[resultPage].munUrl = resultItem.Kunta[0].fullurl; | |||
dataArr[resultPage].weeks = new Array(); | |||
} | |||
resultWeek = resultItem.Viikko[0]; | |||
dataArr[resultPage].weeks[resultWeek] = resultItem.Levätilanne[0]; | |||
} | |||
function doRows() { | |||
for (var s in dataArr) { | |||
site = dataArr[s]; | |||
output += '<tr>'; | |||
if (site.sea) { | |||
meripaikkoja = true; | |||
output += '<td data-sort-value="1" valign="middle" class="smwtype_qty">'; | |||
output += '<a href="' + site.url + '" title="' + site.title + '">'; | |||
output += '<img alt="Merialue" src="//www.jarviwiki.fi/images/a/ac/Pm_hp_asiantuntija_1_27x27.png" width="27" height="27" style="vertical-align: middle" />'; | |||
output += '</a></td>'; | |||
} else { | |||
output += '<td data-sort-value="0" valign="middle" class="smwtype_qty">'; | |||
output += '< | output += '<a href="' + site.url + '" title="' + site.title + '">'; | ||
output += '<img alt="Sisävesi" src="//www.jarviwiki.fi/images/f/f3/Pm_hp_asiantuntija_2_27x27.png" width="27" height="27" style="vertical-align: middle" />'; | |||
output += '</a></td>'; | |||
} | |||
output += '<td class="smwtype_wpg"><a href="' + site.wBodyUrl + '">' + site.wBody + '</a></td>'; | |||
output += '< | nimi = site.SiteName.substr(site.SiteName.lastIndexOf('/')); //site.title.substr(site.title.lastIndexOf('/')); | ||
if (nimi.indexOf('(') != -1) { | |||
nimi = nimi.substr(nimi.indexOf('(')); | |||
nimi = nimi.substr(1); | |||
nimi = nimi.substr(0, nimi.length-1); | |||
} else { | |||
output += '< | nimi = ""; | ||
} | |||
output += '< | output += '<td class="smwtype_wpg">' + nimi + '</td>'; | ||
output += '<td class="smwtype_wpg"><a href="' + site.munUrl + '">' + site.mun + '</a></td>'; | |||
for ( | for (x = 23; x < 40; x++) { | ||
if (site.weeks[x] != undefined) { | |||
resultAlgalVal = site.weeks[x]; | |||
if (resultAlgalVal == 0) { | |||
exportCsv += ";0"; | |||
output += '<td data-sort-value="0" class="smwtype_qty" style="text-align: center; vertical-align: middle; background-color:none">0</td>'; | |||
} else if (resultAlgalVal == 1) { | |||
} else { | exportCsv += ";1"; | ||
output += '<td data-sort-value="1" class="smwtype_qty" style="text-align: center; vertical-align: middle; background-color:#6a9d38">1</td>'; | |||
} else if (resultAlgalVal == 2) { | |||
exportCsv += ";2"; | |||
output += '<td data-sort-value="2" class="smwtype_qty" style="text-align: center; vertical-align: middle; background-color:#fd9f00">2</td>'; | |||
} else { | |||
exportCsv += ";3"; | |||
output += '<td data-sort-value="3" class="smwtype_qty" style="text-align: center; vertical-align: middle; background-color:#c80000">3</td>'; | |||
} | |||
} else { | |||
output += '<td data-sort-value="-1" class="smwtype_qty" style="text-align: center; vertical-align: middle; background-color:none">-</td>'; | |||
} | } | ||
} | } | ||
output += '</ | output += '</tr>'; | ||
} | |||
output += '</tbody><tfoot></tfoot></table></div>'; | |||
if (meripaikkoja) { | |||
//output += '<div style="border: 0; float: left; margin-left: 13px;"><p class="kuvateksti"><a href="/images/a/ac/Pm_hp_asiantuntija_1_27x27.png"><img alt="Merialue" src="/images/thumb/a/ac/Pm_hp_asiantuntija_1_27x27.png/21px-Pm_hp_asiantuntija_1_27x27.png" width="21" height="21" /></a> = Merialueen havaintopaikka</p></div>'; | |||
} | } | ||
} | output += '</div>'; | ||
jQuery("#<!--{$id|default:JwAlgalTable|escape:'html'}-->_container").html(output); | |||
jQuery("#<!--{$id|default:JwAlgalTable|escape:'html'}-->").tablesorter(); | |||
} | |||
doRows(); | |||
} else { | |||
jQuery("#<!--{$id|default:JwAlgalTable|escape:'html'}-->_container").html( '<p class="ingressi">Hakuehtojen mukaisia tietoja ei löytynyt.</p>' ); | |||
} | } | ||
//alert(exportCsv); | |||
} | } | ||
function lataaTiedot() { | function lataaTiedot() { | ||
| Rivi 231: | Rivi 236: | ||
//window.open('data:text/csv;charset=utf-8,' + escape(exportCsv)); | //window.open('data:text/csv;charset=utf-8,' + escape(exportCsv)); | ||
} | } | ||
} | } | ||
</script></includeonly> | </script> | ||
</includeonly> | |||


