Line 1: |
Line 1: |
− | // Content previously here now moved to
| |
− | // https://wiki.personaldata.io/wiki/User:Abel/experimental.js
| |
− | // because common.js is a specific thing in MediaWiki, and has now been activated.
| |
| console.log('+'); | | console.log('+'); |
| | | |
| var controller_item_id = 96; | | var controller_item_id = 96; |
| + | var wbEStruct[] = ['claims.P3', 'mainsnak.datavalue.value', 'numeric-id']; |
| + | |
| + | function indexiterpolate(obj,i) {return obj[i]} |
| + | |
| + | function readpart(arr, read){ |
| + | return read.split('.').reduce(indexinterpolate, arr); |
| + | } |
| + | |
| | | |
| // check if we are on a page of a loaded Entity | | // check if we are on a page of a loaded Entity |
Line 14: |
Line 19: |
| // check each element in P3 relations | | // check each element in P3 relations |
| if ( typeof obj.claims.P3 != "undefined" ) { | | if ( typeof obj.claims.P3 != "undefined" ) { |
− | for( var i = 0; i < obj.claims.P3.length; i++ ) { | + | for( var i = 0; i < readpart(obj, wbEStruct[0]).length; i++ ) { |
| | | |
| // check if we have controller id | | // check if we have controller id |
− | if( obj.claims.P3[i].mainsnak.datavalue.value["numeric-id"] === controller_item_id ) { | + | if( readpart(readpart(obj, wbEStruct[0])[i] , wbEStruct[1])[wbEStruct[2]] === controller_item_id ) { |
| | | |
| // Create popup for SAR | | // Create popup for SAR |