Changes

Jump to navigation Jump to search
no edit summary
Line 17: Line 17:  
return dive( claim , 'mainsnak.datavalue.value')['numeric-id'] === DATA_CONTROLLER_ITEM_ID;
 
return dive( claim , 'mainsnak.datavalue.value')['numeric-id'] === DATA_CONTROLLER_ITEM_ID;
 
}
 
}
 +
 +
 +
mw.hook( 'wikibase.entityPage.entityLoaded' ).add( function ( entity ) {
 +
    'use strict';
 +
    console.log( entity );
 +
     
 +
    // get the ID of the current page
 +
var pageID = document.querySelector('.wikibase-title .wikibase-title-id').innerText.replace( /[()]/g, '' );
 +
    console.log(pageID);
 +
 +
    if (isDataController()) {
 +
  console.log('is dc');
 +
  generateGDPRLink(pageID);
 +
    }
 +
});
    
function isDataController() {
 
function isDataController() {
 
let foundThatThisIsAnInstanceOfDataController = false;
 
let foundThatThisIsAnInstanceOfDataController = false;
 
console.log('here1');
 
console.log('here1');
if ( typeof mw.config.values.wbEntity !=  "undefined" ) // if we are on the page of a loaded entity
+
 
 +
if ( typeof entity !=  "undefined" ) // if we are on the page of a loaded entity
 
{
 
{
    console.log('here2');
+
  console.log( "entity is defined" );
console.dir(obj);
+
  var obj = entity ;
let obj = JSON.parse ( mw.config.values.wbEntity );
+
  console.log('here2');
if ( typeof check( obj, INSTANCE_OF_PROPERTY ) != "undefined" ) // if the entity has any "instance of" claim
+
  console.dir(obj);
 +
  let obj = JSON.parse ( mw.config.values.wbEntity );
 +
  if ( typeof check( obj, INSTANCE_OF_PROPERTY ) != "undefined" ) // if the entity has any "instance of" claim
 +
  {
 +
console.log('here3');
 +
let claims = dive( obj, INSTANCE_OF_PROPERTY ); // get the claims which use the "instance of" property
 +
if (claims.some(claimUsesDataControllerAsItsObject))
 
{
 
{
console.log('here3');
+
  console.log('here4');
let claims = dive( obj, INSTANCE_OF_PROPERTY ); // get the claims which use the "instance of" property
+
  foundThatThisIsAnInstanceOfDataController = true;
if (claims.some(claimUsesDataControllerAsItsObject))
  −
{
  −
  console.log('here4');
  −
  foundThatThisIsAnInstanceOfDataController = true;
  −
}
   
}
 
}
 +
  }
 
}
 
}
 
return foundThatThisIsAnInstanceOfDataController;
 
return foundThatThisIsAnInstanceOfDataController;
}
  −
  −
// get the ID of the current page
  −
var pageID = document.querySelector('.wikibase-title .wikibase-title-id').innerText.replace( /[()]/g, '' );
  −
console.log(pageID);
  −
  −
if (isDataController()) {
  −
console.log('is dc');
  −
generateGDPRLink(pageID);
   
}
 
}
editors
3,524

edits

Navigation menu