Line 9: |
Line 9: |
| language = "en", | | language = "en", |
| | | |
− | wbEStructure = { | + | 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', |
Line 20: |
Line 20: |
| }, | | }, |
| | | |
− | relational_id_list = { | + | Relational_id_list = { |
| controller_id: [ wbEStructure['instanceOfRelations'], wbEStructure['IDPropLoc'], wbEStructure['IDName'], 96 ], | | controller_id: [ wbEStructure['instanceOfRelations'], wbEStructure['IDPropLoc'], wbEStructure['IDName'], 96 ], |
| personal_data_id: [ wbEStructure['subclassOfRelations'], wbEStructure['IDPropLoc'], wbEStructure['IDName'], 421 ], | | personal_data_id: [ wbEStructure['subclassOfRelations'], wbEStructure['IDPropLoc'], wbEStructure['IDName'], 421 ], |
| interface_button_id: [ wbEStructure ['instanceOfRelations'], wbEStructure['IDPropLoc'], wbEStructure['IDName'], 487 ] | | interface_button_id: [ wbEStructure ['instanceOfRelations'], wbEStructure['IDPropLoc'], wbEStructure['IDName'], 487 ] |
| }, | | }, |
− | wbproc,
| |
− | current_entity,
| |
− | pdxdb;
| |
| | | |
| + | PDWikibaseProcessor, |
| + | PDindexedDB, |
| + | PDOOUI, |
| + | Current_entity; |
| + | |
| + | |
| + | // JQ.'when' loads the current scripts asynchronously, continues when loading is 'done' |
| $.when( | | $.when( |
| $.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/WbProcessor.js&action=raw&ctype=text/javascript" ), |
Line 38: |
Line 42: |
| ).done( function(){ | | ).done( function(){ |
| | | |
− | console.log('Reporting in'); | + | console.log('Main thread'); |
− | | |
− | wbproc = new wbContainer(mw, mwEStruct['wbXntity']);
| |
| | | |
− | // Check whether the current page is in a relation of interest to an id of interest | + | // WBproc reads current mediawiki Entity upon instantiation |
− | current_entity = wbproc.checkentity( relational_id_list ); | + | PDWikibaseProcessor = new WikibaseProcessorContainer(mw, mwEStruct['wbXntity']); |
− | // This should return an object of relations and ids
| |
| | | |
− | pdxb = new idxdbContainer( mw ); | + | // PDxDB takes mediawiki, reads user name from it, creates a hash, and 'checks in' the user upon instantiation |
− | // pdxdb.EnqueuePDIO('update record', Date.now(), window.location.href); // simple timestamp tracking | + | // (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( mw, pdxb ); |
| | | |
− | pdui = new interfaceMediaContainer( mw, pdxb ); | + | // 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 |
| | | |
− | if ( current_entity != undefined ) { | + | Current_entity = PDWikibaseProcessor.checkentity( Relational_id_list ); |
− | Object.keys(current_entity).forEach( function ( entity_checked ){ | + | |
− | if ( current_entity[entity_checked] != undefined ){ | + | // Business logicish part. |
− | if ( Object.keys( current_entity[entity_checked] ).length > 0 ) { | + | // If any path of interest returned anything... |
− | pdui.renderInterface( entity_checked ); | + | 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 |
| } | | } |
| } | | } |
| }); | | }); |
| } | | } |
− | console.log("test: ")
| |
− | console.log(current_entity);
| |
| | | |
| }); | | }); |