Skip to content

Commit

Permalink
Merge pull request #44
Browse files Browse the repository at this point in the history
Check mainsnak["datavalue"] exists before checking its value
  • Loading branch information
Teester authored Jul 11, 2024
2 parents 926f55f + f2c96a5 commit 9a8fd88
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
let entityID = mw.config.get( 'wbEntityId' );

$(document).ready(function(){
if (value == "true") {
$("#entityschema-checkbox").prop('checked', true);
} else {
$("#entityschema-checkbox").prop('checked', false);
}

let entityschema_conditions = ["/wiki/Q", "/wiki/P", "/wiki/L"];
if (entityschema_conditions.some(el => document.location.pathname.includes(el))) {
let entityschema_entity_html = `<div><span id="entityschema-simpleSearch">
Expand All @@ -36,6 +32,11 @@
<label for="entityschema-checkbox"><small>Automatically check schema</small></label>
<span id="entityschemaResponse"></span></div>`;
$(entityschema_entity_html).insertAfter("#siteSub");
if (value == "true") {
$("#entityschema-checkbox").prop('checked', true);
} else {
$("#entityschema-checkbox").prop('checked', false);
}
$("#entityschema-schemaSearchButton").click(function(){ entityschema_update(); });
$("#entityschema-checkbox").click(function() { entityschema_checkbox(); });
}
Expand All @@ -48,7 +49,7 @@
let statements = claims[claim];
for (let statement in statements) {
let mainsnak = statements[statement]["mainsnak"];
if (mainsnak["datatype"] == "wikibase-item") {
if (mainsnak["datavalue"] && mainsnak["datatype"] == "wikibase-item") {
if (!item_list.includes(mainsnak["datavalue"]["value"]["id"])) {
item_list.push(mainsnak["datavalue"]["value"]["id"]);
}
Expand Down

0 comments on commit 9a8fd88

Please sign in to comment.