diff --git a/README.md b/README.md index 18f0f591..2bbc0d7e 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,9 @@ api.query( query ).done( function(){ } ); ``` See examples/sparql.html +[JSFiddle.net](https://jsfiddle.net/jonaskress/qpuynfz8/) + + ## Result Views Views that allow rendering SPARQL results [see documentation](https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/Wikidata_Query_Help/Result_Views). @@ -90,6 +93,7 @@ api.query( query ).done(function() { } ); ``` See examples/result.html +[JSFiddle.net](https://jsfiddle.net/jonaskress/9dhv0yLp/) ## Release Notes and npm package diff --git a/dist/js/wdqs.min.js b/dist/js/wdqs.min.js index bf27bcc7..910d1943 100644 --- a/dist/js/wdqs.min.js +++ b/dist/js/wdqs.min.js @@ -1,4 +1,4 @@ -var wikibase=wikibase||{};wikibase.queryService=wikibase.queryService||{},wikibase.queryService.ui=wikibase.queryService.ui||{},wikibase.queryService.ui.App=function(a,b,c,d,e,f){"use strict";function g(a,b,c,d,e){this._$element=a,this._editor=b,this._visualEditor=c,this._sparqlApi=d,this._querySamplesApi=e,this._init()}var h="//tinyurl.com/api-create.php?url=",i="wikibase.queryService.ui.app.";return g.prototype._$element=null,g.prototype._sparqlApi=null,g.prototype._querySamplesApi=null,g.prototype._editor=null,g.prototype._visualEditor=null,g.prototype._isHistoryDisabled=!1,g.prototype._selectedResultBrowser=null,g.prototype._actionBar=null,g.prototype._trackingApi=null,g.prototype._hasRunFirstQuery=!1,g.prototype._resultBrowsers={Table:{icon:"glyphicon-th-list",label:"Table","class":"TableResultBrowser",object:null,$element:null},ImageGrid:{icon:"glyphicon-picture",label:"Image Grid","class":"ImageResultBrowser",object:null,$element:null},Polestar:{icon:"fa-certificate",label:"Graph builder","class":"PolestarResultBrowser",object:null,$element:null},Map:{icon:"glyphicon-map-marker",label:"Map","class":"CoordinateResultBrowser",object:null,$element:null},LineChart:{icon:"fa-line-chart",label:"Line Chart","class":"LineChartResultBrowser",object:null,$element:null},BarChart:{icon:"fa-bar-chart",label:"Bar Chart","class":"BarChartResultBrowser",object:null,$element:null},ScatterChart:{icon:"fa-braille",label:"Scatter Chart","class":"ScatterChartResultBrowser",object:null,$element:null},AreaChart:{icon:"fa-area-chart",label:"Area Chart","class":"AreaChartResultBrowser",object:null,$element:null},BubbleChart:{icon:"glyphicon-tint",label:"Bubble Chart","class":"BubbleChartResultBrowser",object:null,$element:null},TreeMap:{icon:"glyphicon-th",label:"Tree Map","class":"TreeMapResultBrowser",object:null,$element:null},Timeline:{icon:"glyphicon-calendar",label:"Timeline","class":"TimelineResultBrowser",object:null,$element:null},Dimensions:{icon:"glyphicon-random",label:"Dimensions","class":"MultiDimensionResultBrowser",object:null,$element:null},Graph:{icon:"glyphicon-retweet",label:"Graph","class":"GraphResultBrowser",object:null,$element:null}},g.prototype._init=function(){this._sparqlApi||(this._sparqlApi=new wikibase.queryService.api.Sparql),this._querySamplesApi||(this._querySamplesApi=new wikibase.queryService.api.QuerySamples),this._trackingApi||(this._trackingApi=new wikibase.queryService.api.Tracking),this._editor||(this._editor=new wikibase.queryService.ui.editor.Editor),this._track("init"),this._initApp(),this._initEditor(),this._initVisualEditor(),this._initExamples(),this._initDataUpdated(),this._initQuery(),this._initRdfNamespaces(),this._initHandlers(),this._initResultBrowserMenu()},g.prototype._initApp=function(){a(c).keydown(function(b){b.ctrlKey&&13===b.keyCode&&a("#execute-button").click()}),this._actionBar=new wikibase.queryService.ui.toolbar.Actionbar(a(".action-bar"))},g.prototype._initEditor=function(){this._editor.fromTextArea(this._$element.find(".queryEditor")[0])},g.prototype._initVisualEditor=function(){var b=this,c="visual-editor-hide";this._visualEditor||(this._visualEditor=new wikibase.queryService.ui.visualEditor.VisualEditor),this._visualEditor.setChangeListener(function(a){b._editor.setValue(a.getQuery())}),"true"===e.get(c)&&a(".visual-editor-trigger").show(),this._editor&&this._editor.registerCallback("change",d.debounce(function(){a(".visual-editor-trigger").is(":visible")||b._editor.getValue()===b._visualEditor.getQuery()||(a(".visual-editor").hide(),b._drawVisualEditor())},1500)),a(".visual-editor .panel-heading .close").click(function(){return e.set(c,!0),a(".visual-editor").hide(),a(".visual-editor-trigger").show(),!1}),a(".visual-editor-trigger").click(function(){return a(".visual-editor-trigger").hide(),e.set(c,!1),b._drawVisualEditor(),!1})},g.prototype._drawVisualEditor=function(){try{this._visualEditor.setQuery(this._editor.getValue()),this._visualEditor.draw(a(".visual-editor .panel-body")),a(".visual-editor").delay(500).fadeIn()}catch(b){b.stack&&c.console.log(b.stack)}},g.prototype._initExamples=function(){var b=this;new wikibase.queryService.ui.QueryExampleDialog(a("#QueryExamples"),this._querySamplesApi,function(a,c){a&&a.trim()&&b._editor.setValue("#"+c+"\n"+a)})},g.prototype._initRdfNamespaces=function(){var b,c,d,e=a(".namespace-shortcuts"),f=wikibase.queryService.RdfNamespaces.NAMESPACE_SHORTCUTS;e.click(function(a){a.stopPropagation()});for(b in f){c=a("