User:AHIOH/metaclass-check.js: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
Created page with "// Revision of User:Lectrician1/metaclass-check.js // This adds a bit of warning text next to instance of statements on classes if their values are not metaclasses $( function () { mw.hook("wikibase.entityPage.entityLoaded").add(async function (e) { if ('P279' in e.claims && 'P31' in e.claims) { for (claim of Object.values(e.claims.P31)) { if (claim.mainsnak.snaktype == "value") { let query = `ASK { wd:${claim.mainsnak.datavalue.v..." |
No edit summary |
||
Line 10: | Line 10: | ||
let query = `ASK { |
let query = `ASK { |
||
wd:${claim.mainsnak.datavalue.value.id} wdt:P31/wdt:P279* wd:Q19478619; |
wd:${claim.mainsnak.datavalue.value.id} wdt:P31/wdt:P279* wd:Q19478619; |
||
wdt:P31/wdt:P279* wd:Q23958852; //variable order classes |
|||
wdt:P31/wdt:P279* wd:Q24017414; //second-order classes |
|||
wdt:P31/wdt:P279* wd:Q16889133. |
wdt:P31/wdt:P279* wd:Q16889133. |
||
}` |
}` |
Latest revision as of 22:10, 17 August 2024
// Revision of User:Lectrician1/metaclass-check.js
// This adds a bit of warning text next to instance of statements on classes if their values are not metaclasses
$( function () {
mw.hook("wikibase.entityPage.entityLoaded").add(async function (e) {
if ('P279' in e.claims && 'P31' in e.claims) {
for (claim of Object.values(e.claims.P31)) {
if (claim.mainsnak.snaktype == "value") {
let query = `ASK {
wd:${claim.mainsnak.datavalue.value.id} wdt:P31/wdt:P279* wd:Q19478619;
wdt:P31/wdt:P279* wd:Q23958852; //variable order classes
wdt:P31/wdt:P279* wd:Q24017414; //second-order classes
wdt:P31/wdt:P279* wd:Q16889133.
}`
let boolResult = await $.post("https://query.wikidata.org/sparql?format=json", {
query: query })
if (!boolResult.boolean) {
$('#' + $.escapeSelector(claim.id)).find('.wikibase-snakview-indicators').append('<span style="color: red;">This class is not a metaclass!</span>')
}
}
}
}
})
})