-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (25 loc) · 1.59 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
$.get( 'https://tools.wmflabs.org/dspull/username.php', function(res) {
document.getElementById('login').innerHTML = res;
}).fail(function() {
document.getElementById('login').innerHTML = "Login";
});
var req = window.location.search.replace("?","").split('&')
for (var i = 0; i<req.length;i++){
switch (req[i].slice(0,req[i].indexOf("="))){
case "site": var site = req[i].slice(req[i].indexOf("=")+1); break;
};
};
window.onload = function(){
if(typeof(site) != "undefined" && site !== null) {
var wikidataUrl = 'https://query.wikidata.org/sparql?query=SELECT%20%3Fitem%20%3FitemLabel%20%7B%0A%20%20%3Fitem%20wdt%3AP31%20wd%3AQ63090714.%0A%20%20%5B%5D%20schema%3Aabout%20%3Fitem%3B%20schema%3AisPartOf%20%3Chttps%3A%2F%2F'+ site.slice(0,-4) + '.wikipedia.org%2F%3E.%0A%20%20%5B%5D%20schema%3Aabout%20%3Fitem%3B%20schema%3AisPartOf%20%3Chttps%3A%2F%2Fwww.mediawiki.org%2F%3E%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22ru%22%20%7D%0A%7D%0A'
$.get( wikidataUrl, {format:'json', origin:'*'}, function(res) {
for (var i = 0; i < res.results.bindings.length; i++) {
var moduleId = res.results.bindings[i].item.value.slice(res.results.bindings[i].item.value.lastIndexOf('Q'))
document.getElementById('list').innerHTML += '<li><a href="pull/?id='+moduleId+'&site='+site+'">'+res.results.bindings[i].itemLabel.value+'</a></li>' ;
}
});
}else{
document.getElementById('list').innerHTML += '<li><a href="?site=ruwiki">ruwiki</a></li>';
document.getElementById('list').innerHTML += '<li><a href="?site=enwiki">enwiki</a></li>';
};
};