Wiki data - mdo91/Swe-573 GitHub Wiki
This section includes brief information regrading usage of wiki data:
Wikidata offers a wide range of general data about our universe as well as links to other databases. The data is published under the CC0 “Public domain dedication” license. It can be edited by anyone and is maintained by Wikidata’s editor community.
Changes to APIs and data formats used to access Wikidata are subject to the Stable Interface Policy. Changes to stable interfaces will be announced accordingly. Note that not all data sources mentioned on this page are considered stable interfaces.
Using Javascript The following code is implemented in Learning Journey platform example of WebAPI link:
www.wikidata.org/w/api.php?action=wbsearchentities&search=martten&language=en&format=json
Javascript Code for wikidata search query:
‘<script>` `$(“#search_wiki”).keyup(function() {`
‘if (!this.value) {`
`console.log("is empty");` `$("rowcustom").remove();`
‘}});`
`var textValue = $('#search_wiki').val();` `if (textValue == '' || textValue == null){` `$("#wiki_result").html("");` `}else{` `console.log("not empty"+textValue);` `}`
‘$(’#search_wiki’).on(‘input’,function(e){‘
`$("#wiki_result").html("");` `var textValue = $('#search_wiki').val();` `// console.log(textValue);` `if (textValue != null || textValue != "" ){` `$.ajax({` `type: 'GET',` `crossDomain: true,` `dataType: 'jsonp',` `url: 'https://www.wikidata.org/w/api.php?action=wbsearchentities&search='+textValue+'&language=en&format=json',` `success: function(jsondata){` `var textValue = $('#search_wiki').val();` `console.log(textValue);` `if (jsondata.search){` `console.log("lenght: "+jsondata.search.length);` `for(var i = 0, len = jsondata.search.length; i < len; i++){` `if (i < 5){` `console.log("i value: "+i);` `console.log(jsondata.search[i].label);` `var v = jsondata.search[i].label;` `var h = jsondata.search[i].concepturi;` `$("#wiki_result").append('<div class="rowcustom" ><input type="checkbox" id="checkbox'+i+'" name="checkbox'+i+'"/><a href='+h+'>'+v+'</a> <input type="hidden" id="textvalue'+i+'" name="textvalue'+i+'" value="'+v+'" /><input id="urlValue'+i+'" name="urlValue'+i+'" type="hidden" value="'+h+'"/></div>');` `}` `}` `}else{` `// MARK: clear the contecnt of the div` `$("#wiki_result").append('not sucess');` `$("#wiki_result").empty();` `$("#wiki_result").html('');` `console.log("Error: check the function20212");` `}` `}`
‘})`
`}else{` `// MARK: clear the contecnt of the div` `console.log("Error: check the function202");` `}`
‘});`
‘</script>`