Line 2: |
Line 2: |
| | | |
| var controller_item_id = 96, | | var controller_item_id = 96, |
− | personal_data_id = 421,
| + | personal_data_id = 421, |
− | interface_button_id = 487,
| + | interface_button_id = 487, |
− | wbEStruct = {
| + | wbEStruct = { |
| subclassOfRelations: 'claims.P4', // location of P4 relations in wbEntity | | subclassOfRelations: 'claims.P4', // location of P4 relations in wbEntity |
| defaultValRelation: 'claims.P108', | | defaultValRelation: 'claims.P108', |
| 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' |
Line 64: |
Line 64: |
| // get obj.'rel_0' (gets wbEntity), check if it has 'A', iterate over 'A', get 'B' and 'C' and check if any contains 'to_check'. if yes, return true | | // get obj.'rel_0' (gets wbEntity), check if it has 'A', iterate over 'A', get 'B' and 'C' and check if any contains 'to_check'. if yes, return true |
| function iterateAcheckBC( obj, rel_0, rel_A, rel_B, rel_C, to_check ) { | | function iterateAcheckBC( obj, rel_0, rel_A, rel_B, rel_C, to_check ) { |
− | var current = get_Y_from_X( interjson( get_Y_from_X( mw, rel_0 ) ), rel_A );
| + | var future = false; |
− | console.log( "parsed object" )
| + | if ( typeof check( mw, rel_0 ) != undefined ){ |
− | // check if we have rel_A relations and iterate through
| + | var edata = interjson(get_Y_from_X( mw, rel_0 )) |
− | var future = false;
| + | if ( typeof check( edata, rel_A ) != undefined ) { |
− | for( var i = 0; i < current.length; i++ ) {
| + | var current = get_Y_from_X( edata, rel_A ); |
− | console.log("dived in");
| + | console.log( "parsed object" ) |
− | // check if we have controller id constructed from wbEntity
| + | // check if we have rel_A relations and iterate through |
− | if ( check_Y_in_X( to_check, get_Y_from_X( get_Y_from_X( current[i], rel_B ), rel_C ) ) ) {
| + | for( var i = 0; i < current.length; i++ ) { |
− | future = true;
| + | console.log("dived in"); |
− | };
| + | // check if we have controller id constructed from wbEntity |
− | }
| + | if ( typeof check( current[i], rel_B ) != undefined ) { |
− | return future;
| + | if ( typeof check( dive (current[i], rel_B ), rel_C ) ) { |
− | }
| + | if ( check_Y_in_X( to_check, get_Y_from_X( get_Y_from_X( current[i], rel_B ), rel_C ) ) ) { |
| + | future = true; |
| + | }; |
| + | } |
| + | } |
| + | } |
| + | } |
| + | } |
| + | return future; |
| + | } |
| | | |
| function get_Y_from_X( obj, B ){ | | function get_Y_from_X( obj, B ){ |
− | if ( check(obj, B) != undefined ) { | + | if ( typeof check(obj, B) != undefined ) { |
| console.log( "entity is defined" ) | | console.log( "entity is defined" ) |
| return dive(obj, B); | | return dive(obj, B); |
Line 90: |
Line 99: |
| } catch (e) { | | } catch (e) { |
| // if not JSON, do silly things | | // if not JSON, do silly things |
− | };
| + | }; |
| | | |
| } | | } |
Line 133: |
Line 142: |
| var store = db.createObjectStore(PersonalDataDataBaseName, {keyPath: "id"}); | | var store = db.createObjectStore(PersonalDataDataBaseName, {keyPath: "id"}); |
| // shouldn't the index be the wiki.personaldata.io username? | | // shouldn't the index be the wiki.personaldata.io username? |
− | var index = store.createIndex("NameIndex", ["name.last", "name.first"]);
| + | var index = store.createIndex("NameIndex", ["name.last", "name.first"]); |
− | };
| + | }; |
− | pddb.onsuccess = function() {
| + | pddb.onsuccess = function() { |
− | var db = pddb.result;
| + | var db = pddb.result; |
− | var tx = db.transaction(PersonalDataDataBaseName, "readwrite");
| + | var tx = db.transaction(PersonalDataDataBaseName, "readwrite"); |
− | var store = tx.objectStore(PersonalDataDataBaseName);
| + | var store = tx.objectStore(PersonalDataDataBaseName); |
− | var index = store.index("NameIndex");
| + | var index = store.index("NameIndex"); |
| //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||[ Essential recordAdd ]|||||||||||||||||||||||||||||| | | //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||[ Essential recordAdd ]|||||||||||||||||||||||||||||| |
− | var getRecord = index.get([record.name.last, record.name.first]);
| + | var getRecord = index.get([record.name.last, record.name.first]); |
− | getRecord.onsuccess = function() {
| + | getRecord.onsuccess = function() { |
− | if (getRecord.result != undefined) {
| + | if (getRecord.result != undefined) { |
− | console.log("updating");
| + | console.log("updating"); |
− | inp_obj = getRecord.result;
| + | inp_obj = getRecord.result; |
− | } else {
| + | } else { |
− | inp_obj = record;
| + | inp_obj = record; |
− | store.put(inp_obj);
| + | store.put(inp_obj); |
− | }
| + | } |
− | var sanitycheck = index.get([inp_obj.name.last, inp_obj.name.first]);
| + | var sanitycheck = index.get([inp_obj.name.last, inp_obj.name.first]); |
− | sanitycheck.onsuccess = function() {
| + | sanitycheck.onsuccess = function() { |
− | console.log(sanitycheck);
| + | console.log(sanitycheck); |
− | }
| + | } |
− | }
| + | } |
| //||||||||||||||||||||||||||||||||||||||||||||| | | //||||||||||||||||||||||||||||||||||||||||||||| |
| tx.oncomplete = function() { | | tx.oncomplete = function() { |
Line 176: |
Line 185: |
| var index = store.index("NameIndex"); | | var index = store.index("NameIndex"); |
| //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||[ Essential recordUpdate ]|||||||||||||||||||||||||||||| | | //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||[ Essential recordUpdate ]|||||||||||||||||||||||||||||| |
− | var inp_obj;
| + | var inp_obj; |
− | var getRecord = index.get([record.name.last, record.name.first]);
| + | var getRecord = index.get([record.name.last, record.name.first]); |
− | getRecord.onsuccess = function() {
| + | getRecord.onsuccess = function() { |
− | if( getRecord.result != undefined ) {
| + | if( getRecord.result != undefined ) { |
− | console.log("updating");
| + | console.log("updating"); |
− | inp_obj = getRecord.result;
| + | inp_obj = getRecord.result; |
− | } else {
| + | } else { |
− | inp_obj = record;
| + | inp_obj = record; |
− | }
| + | } |
| | | |
| inp_obj[field] = value; // => "Bob" | | inp_obj[field] = value; // => "Bob" |
Line 200: |
Line 209: |
| }; | | }; |
| //|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| | | //|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
− | tx.oncomplete = function() {
| + | tx.oncomplete = function() { |
− | db.close();
| + | db.close(); |
− | };
| + | }; |
− | };
| + | }; |
− | };
| + | }; |
| | | |
| function recordCheck(pddbname, record){ | | function recordCheck(pddbname, record){ |
Line 219: |
Line 228: |
| var index = store.index("NameIndex"); | | var index = store.index("NameIndex"); |
| //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||[ Essential recordCheck ]|||||||||||||| | | //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||[ Essential recordCheck ]|||||||||||||| |
− | var recordcheck = index.get([record.name.last, record.name.first]);
| + | var recordcheck = index.get([record.name.last, record.name.first]); |
− | recordcheck.onsuccess = function() {
| + | recordcheck.onsuccess = function() { |
− | if ( recordcheck.result != undefined ) {
| + | if ( recordcheck.result != undefined ) { |
− | console.log(recordcheck);
| + | console.log(recordcheck); |
− | } else {
| + | } else { |
− | console.log("...else undefined");
| + | console.log("...else undefined"); |
− | }
| + | } |
| //|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| | | //|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| |
− | }
| + | } |
− | tx.oncomplete = function() {
| + | tx.oncomplete = function() { |
− | db.close();
| + | db.close(); |
− | };
| + | }; |
− | };
| + | }; |
| }; | | }; |