مستخدم:FShbib/updateWDS.js
يمكن توفير توثيق لسكربت المستخدم هذا في الصفحة : مستخدم:FShbib/updateWDS. |
ملاحظة: بعد الحفظ، قد يلزمك إفراغ الكاش لرؤية التغييرات ( ).
var finalTextMG = "local p = {}\nfunction p.getMissingGender()\nreturn {";
function makeSPARQLQuery(endpointUrl, sparqlQuery, doneCallback) {
var settings = {
headers: {
Accept: 'application/sparql-results+json'
},
data: {
query: sparqlQuery
}
};
return $.ajax(endpointUrl, settings).then(doneCallback);
}
var endpointUrl = 'https://query.wikidata.org/sparql',
sparqlQuery = "SELECT ?itemLabel WHERE { \n" +
" ?item wdt:P31 wd:Q5 .\n" +
" VALUES ?country { wd:Q851\n" +
" wd:Q79\n" +
" wd:Q817\n" +
" wd:Q878\n" +
" wd:Q796\n" +
" wd:Q398\n" +
" wd:Q842\n" +
" wd:Q846\n" +
" wd:Q805\n" +
" wd:Q1016\n" +
" wd:Q1049\n" +
" wd:Q948\n" +
" wd:Q262\n" +
" wd:Q1028\n" +
" wd:Q1025\n" +
" wd:Q1045\n" +
" wd:Q977\n" +
" wd:Q970\n" +
" wd:Q810\n" +
" wd:QQ858\n" +
" wd:Q822\n" +
" wd:Q23792\n" +
" }\n" +
" ?item wdt:P27 ?country .\n" +
" FILTER(NOT EXISTS { ?item wdt:P21 ?sex .})\n" +
" FILTER EXISTS { ?war schema:about ?item . ?war schema:inLanguage \"ar\" }\n" +
" SERVICE wikibase:label { bd:serviceParam wikibase:language \"ar\"}\n" +
" }";
setTimeout(function() {
makeSPARQLQuery(endpointUrl, sparqlQuery, function(data) {
for (var i = 0; i < data.results.bindings.length; i++) {
finalTextMG = finalTextMG + "\"" + ((data.results.bindings[i].itemLabel.value)) + "\",\n";
}
finalTextMG = finalTextMG + "}\nend\nreturn p";
new mw.Api()
.edit( "وحدة:ملعب/FShbib/بدون_جنس", function ( revision ) {
return {
text: finalTextMG,
summary: "تحديث"
};
})
.then( function () {
console.log( 'Saved! ');
});
});
}, 3000);