אונטערשייד צווישן ווערסיעס פון "באַניצער:בוט צמא לדעת/coords.js"
ק (הגהה) |
אין תקציר עריכה |
||
(170 צווישנדיגע ווערסיעס פונעם זעלבן באַניצער נישט געוויזן) | |||
שורה 9: | שורה 9: | ||
"gapnamespace": "8000", | "gapnamespace": "8000", | ||
"gapfilterredir": "nonredirects", | "gapfilterredir": "nonredirects", | ||
"gapfrom": 'תלמידי', | |||
"gaplimit": " | "gaplimit": "150", | ||
"prop": "categories|langlinks", | "prop": "categories|langlinks", | ||
"clcategories": "קאַטעגאָריע:ארטיקלען מיט קאארדינאטן", | "clcategories": "קאַטעגאָריע:ארטיקלען מיט קאארדינאטן", | ||
שורה 27: | שורה 27: | ||
for (const l in list[p].langlinks) { | for (const l in list[p].langlinks) { | ||
if (list[p].langlinks[l].lang == "he") { | if (list[p].langlinks[l].lang == "he") { | ||
hebCoord(pageName, list[p].langlinks[l] | console.log(list[p].langlinks[l], list[p].langlinks[l]['*']) | ||
hebCoord(pageName, list[p].langlinks[l]['*']) | |||
} | } | ||
} | } | ||
שורה 35: | שורה 36: | ||
} | } | ||
sum++; | sum++; | ||
if (sum >= | if (sum >= 149) { | ||
console.log('last was: ', pageName); | console.log('last was: ', pageName); | ||
} | } | ||
שורה 61: | שורה 62: | ||
console.log('at last done'); | console.log('at last done'); | ||
$(function () { | $(function () { | ||
if (!("query" in data) || !("pages" in data.query)) { | |||
console.log('no query data!', page, hepage) | |||
} else { | |||
for (var p in data.query.pages) { | for (var p in data.query.pages) { | ||
console.log('about to test coordinates for: ', p) | console.log('about to test coordinates for: ', p) | ||
שורה 83: | שורה 87: | ||
} | } | ||
} | } | ||
} | |||
} | } |
יעצטיגע רעוויזיע זינט 09:09, 8 דעצעמבער 2023
mw.loader.using(['mediawiki.jqueryMsg']).done(function () {
function listPages() {
const api = new mw.Api();
api.get({
"action": "query",
"format": "json",
"generator": "allpages",
"utf8": 1,
"gapnamespace": "8000",
"gapfilterredir": "nonredirects",
"gapfrom": 'תלמידי',
"gaplimit": "150",
"prop": "categories|langlinks",
"clcategories": "קאַטעגאָריע:ארטיקלען מיט קאארדינאטן",
"cllimit": "max",
"lllimit": "max"
}).done((data) => {
//console.table(data);
const list = data.query.pages;
console.timeLog('מדידת זמן', 'a');
console.table(list);
var sum = 0;
for (const p in list) {
const pageName = list[p].title;
if (!("categories" in list[p])) {
if ("langlinks" in list[p]) {
for (const l in list[p].langlinks) {
if (list[p].langlinks[l].lang == "he") {
console.log(list[p].langlinks[l], list[p].langlinks[l]['*'])
hebCoord(pageName, list[p].langlinks[l]['*'])
}
}
} else {
wikidataCoord(pageName);
}
}
sum++;
if (sum >= 149) {
console.log('last was: ', pageName);
}
}
})
};
function hebCoord(page, hepage) {
console.log(hepage + ' : ' + page);
console.timeLog('מדידת זמן', '2');
var params = {
"action": "query",
"format": "json",
"titles": hepage,
"prop": "coordinates"
};
$.ajax({
url: '//he.wikipedia.org/w/api.php',
data: params,
dataType: 'jsonp',
cache: true
})
.done(function (data) {
console.log('at last done');
$(function () {
if (!("query" in data) || !("pages" in data.query)) {
console.log('no query data!', page, hepage)
} else {
for (var p in data.query.pages) {
console.log('about to test coordinates for: ', p)
if (("coordinates" in data.query.pages[p]) && ("primary" in data.query.pages[p].coordinates[0])) {
console.log('adding coordinates for: ', p)
var params = {
"action": "edit",
"format": "json",
"title": page,
"summary": "קאארדינאט",
"minor": 1,
"bot": 1,
"prependtext": '{{Coord|' + data.query.pages[p].coordinates[0].lat + '|' + data.query.pages[p].coordinates[0].lon + '|display=title}}',
"utf8": 1
},
api = new mw.Api();
api.postWithToken('csrf', params).done(function (data) {
console.table(data);
console.timeLog('מדידת זמן', 3);
});
}
}
}
}
)
});
}
function wikidataCoord(page) {
$.ajax({
url: '//www.wikidata.org/w/api.php',
data: {
'format': 'json',
'action': 'wbgetentities',
'sites': "yiwiki",
'titles': page.replace("רוי:", ""),//.replace('מדינת ישראל', 'ישראל'),
'props': 'sitelinks',
'languages': 'en',
'sitefilter': 'enwiki'
},
dataType: 'jsonp',
cache: true
})
.done(function (data) {
console.log(data);
if (data.success) {
//console.table(data.success);
$(function () {
for (var e in data.entities) {
if (e == -1) return;
var labels = data.entities[e].sitelinks;
if (!labels.enwiki) return console.log('ל' + page + ' אין מידע ויקינתונים.');
const interwiki = labels.enwiki.title;
//console.table(e);
console.log(interwiki + ' : ' + page);
console.timeLog('מדידת זמן', '2');
var params = {
"action": "query",
"format": "json",
"titles": interwiki,
"prop": "coordinates"
};
$.ajax({
url: '//en.wikipedia.org/w/api.php',
data: params,
dataType: 'jsonp',
cache: true
})
.done(function (data) {
console.log('at last done');
$(function () {
for (var p in data.query.pages) {
console.log('about to test coordinates for: ', p)
if (("coordinates" in data.query.pages[p]) && ("primary" in data.query.pages[p].coordinates[0])) {
console.log('adding coordinates for: ', p)
var params = {
"action": "edit",
"format": "json",
"title": page,
"summary": "קאארדינאט",
"minor": 1,
"bot": 1,
"prependtext": '{{Coord|' + data.query.pages[p].coordinates[0].lat + '|' + data.query.pages[p].coordinates[0].lon + '|display=title}}',
"utf8": 1
},
api = new mw.Api();
api.postWithToken('csrf', params).done(function (data) {
console.table(data);
console.timeLog('מדידת זמן', 3);
});
}
}
}
)
});
}
});
}
});
}
if (mw.config.get('wgUserGroups').indexOf('bot') !== -1 && (mw.config.get('wgAction') != 'edit') && confirm('להריץ?')) {
console.time('מדידת זמן');
listPages();
}
})