| Line 3: |
Line 3: |
| | console.log("'⌣'"); | | console.log("'⌣'"); |
| | | | |
| − | var relational_id_list = { | + | var mwEStruct = { |
| − | controller_id: ['instanceOfRekations', 96],
| + | wbXntity: 'config.values.wbEntity' |
| − | personal_data_id: ['subclassOfRekations', 421],
| + | }, |
| − | interface_button_id: ['instanceOfRekations', 487]
| |
| − | },
| |
| | | | |
| − | language = "en",
| + | language = "en", |
| | | | |
| − | wbEStruct = {
| + | WBEStructure = { |
| − | subclassOfRelations: 'claims.P4', // location of P4 relations in wbEntity
| + | subclassOfRelations: 'claims.P4', // location of P4 relations in wbEntity |
| − | defaultValRelation: 'claims.P108',
| + | defaultValRelation: 'claims.P108', |
| − | concernsRelation: 'claims.P110',
| + | concernsRelation: 'claims.P110', |
| − | instanceOfRelations: 'claims.P3',
| + | instanceOfRelations: 'claims.P3', |
| − | IDPropLoc: 'mainsnak.datavalue.value', // location of ID properties in related entity
| + | IDPropLoc: 'mainsnak.datavalue.value', // location of ID properties in related entity |
| − | IDName: 'numeric-id', // ID property name which checked
| + | IDName: 'numeric-id', // ID property name which checked |
| − | qIDPropName: 'id',
| + | qIDPropName: 'id', |
| − | standardValue: 'labels' + '.' + language + '.' + 'value'
| + | standardValue: 'labels' + '.' + language + '.' + 'value' |
| − | },
| + | }, |
| | | | |
| − | mwEStruct = {
| + | Relational_id_list = { |
| − | wbXntity: 'config.values.wbEntity'
| + | controller_id: [ WBEStructure['instanceOfRelations'], WBEStructure['IDPropLoc'], WBEStructure['IDName'], 96 ], |
| − | };
| + | personal_data_id: [ WBEStructure['subclassOfRelations'], WBEStructure['IDPropLoc'], WBEStructure['IDName'], 421 ], |
| | + | interface_button_id: [ WBEStructure ['instanceOfRelations'], WBEStructure['IDPropLoc'], WBEStructure['IDName'], 487 ] |
| | + | }, |
| | | | |
| − | mw.loader.using( ['ext.gadget.WbProcessor', 'ext.gadget.PersonalDataBase', 'ext.gadget.PDOOUI'] , function (){
| + | PDWikibaseProcessor, |
| − | console.log('Wbprocessor active'); | + | PDindexedDB, |
| − | console.log('Personaldatabase active'); | + | PDOOUI, |
| − | console.log('User Interface active'); | + | Current_entity; |
| | | | |
| − | wbproc = wbContainer(mw, mwEStruct[wbXntity]);
| |
| | | | |
| − | // Check whether the current page is in a relation of interest to an id of interest
| + | // JQ.'when' loads the current scripts asynchronously, continues when loading is 'done' |
| − | current_entity = wbproc.checkentity( relational_id_list, wbEStruct['IDPropLoc'], wbEStruct['IDName'] );
| + | $.when( |
| − | // This should return an object of relations and ids
| + | $.getScript( "//wiki.personaldata.io/w/index.php?title=User:Abel/WbProcessor.js&action=raw&ctype=text/javascript" ), |
| | + | $.getScript( "//wiki.personaldata.io/w/index.php?title=User:Abel/PersonalData.js&action=raw&ctype=text/javascript" ), |
| | + | $.getScript( "//wiki.personaldata.io/w/index.php?title=User:Abel/OOInterface.js&action=raw&ctype=text/javascript" ), |
| | + | $.Deferred( function( deferred ){ |
| | + | $( deferred.resolve ); |
| | + | }) |
| | + | ).done( function(){ |
| | | | |
| − | console.log(current_entity); | + | console.log('Main thread'); |
| | | | |
| − | // for each match, render the corresponding ui elements | + | // WBproc reads current mediawiki Entity upon instantiation |
| − | // current_entity.forEach(pdooui.render); | + | PDWikibaseProcessor = new WikibaseProcessorContainer(mw, mwEStruct['wbXntity']); |
| | + | |
| | + | // PDxDB takes mediawiki, reads user name from it, creates a hash, and 'checks in' the user upon instantiation |
| | + | // (i.e. read record belonging to user, if it does not exist, create it) |
| | + | PDindexedDB = new IndexedDBContainer( mw ); |
| | + | |
| | + | // Contains classes for creating UI elements, no instantiation consequences |
| | + | PDOOUI = new InterfaceMediaContainer( PDWikibaseProcessor, PDindexedDB ); |
| | + | |
| | + | // Check if the current entity belongs to any path of interest. |
| | + | // For each element in object argument, a corresponding element in the return object will contain one of the following: |
| | + | // - undefined - the path didn't exist even partly) |
| | + | // - [ value or object ] - if the path existed fully, it returns what is at the end of the path. If last element in path is a value, it will return the value if found |
| | + | |
| | + | Current_entity = PDWikibaseProcessor.checkentity( Relational_id_list ); |
| | + | |
| | + | // Business logicish part. |
| | + | // If any path of interest returned anything... |
| | + | if ( Current_entity != undefined ) { |
| | + | Object.keys(Current_entity).forEach( function ( entity_checked ){ |
| | + | //... for each path that returned something |
| | + | if ( Current_entity[entity_checked] != undefined ){ |
| | + | if ( Object.keys( Current_entity[entity_checked] ).length > 0 ) { |
| | + | PDOOUI.renderInterface( entity_checked ); |
| | + | //... call the OOUI renderer to render what belongs to this input |
| | + | } |
| | + | } |
| | + | }); |
| | + | } |
| | | | |
| | }); | | }); |