Smalyshev has uploaded a new change for review. https://gerrit.wikimedia.org/r/255054
Change subject: Use downloader from https://github.com/rndme/download ...................................................................... Use downloader from https://github.com/rndme/download This should allow us dealing with larger result sets Bug: T119239 Change-Id: I5fb654bd1358f92af69bad5c501633b7a93dec86 --- A gui/download.min.js M gui/gui.js M gui/index.html 3 files changed, 4 insertions(+), 22 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/rdf refs/changes/54/255054/1 diff --git a/gui/download.min.js b/gui/download.min.js new file mode 100644 index 0000000..082fc20 --- /dev/null +++ b/gui/download.min.js @@ -0,0 +1,2 @@ +//download.js v3.1, by dandavis; 2008-2015. [CCBY2] see http://danml.com/download.html for tests/usage +(function(f,a){"function"==typeof define&&define.amd?define([],a):"object"==typeof exports?module.exports=a():f.download=a()})(this,function(){return function(f,a,b){function n(l){var a=l.split(/[:;,]/);l=a[1];var a=("base64"==a[2]?atob:decodeURIComponent)(a.pop()),c=a.length,b=0,d=new Uint8Array(c);for(b;b<c;++b)d[b]=a.charCodeAt(b);return new g([d],{type:l})}function k(a,b){if("download"in d)return d.href=a,d.setAttribute("download",m),d.innerHTML="downloading...",h.body.appendChild(d),setTimeout(function(){d.click(),h.body.removeChild(d),!0===b&&setTimeout(function(){e.URL.revokeObjectURL(d.href)},250)},66),!0;if("undefined"!=typeof safari)return a="data:"+a.replace(/^data:([\w\/\-\+]+)/,"application/octet-stream"),!window.open(a)&&confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")&&(location.href=a),!0;var c=h.createElement("iframe");h.body.appendChild(c),b||(a="data:"+a.replace(/^data:([\w\/\-\+]+)/,"application/octet-stream")),c.src=a,setTimeout(function(){h.body.removeChild(c)},333)}var e=window;b=b||"application/octet-stream";var c=f,h=document,d=h.createElement("a");f=function(a){return String(a)};var g=e.Blob||e.MozBlob||e.WebKitBlob||f,g=g.call?g.bind(e):Blob,m=a||"download";"true"===String(this)&&(c=[c,b],b=c[0],c=c[1]);if(String(c).match(/^data\:[\w+\-]+\/[\w+\-]+[,;]/))return navigator.msSaveBlob?navigator.msSaveBlob(n(c),m):k(c);a=c instanceof g?c:new g([c],{type:b});if(navigator.msSaveBlob)return navigator.msSaveBlob(a,m);if(e.URL)k(e.URL.createObjectURL(a),!0);else{if("string"==typeof a||a.constructor===f)try{return k("data:"+b+";base64,"+e.btoa(a))}catch(p){return k("data:"+b+","+encodeURIComponent(a))}b=new FileReader,b.onload=function(a){k(this.result)},b.readAsDataURL(a)}return!0}}); diff --git a/gui/gui.js b/gui/gui.js index e0c3819..422a398 100644 --- a/gui/gui.js +++ b/gui/gui.js @@ -491,7 +491,7 @@ if ( !LAST_RESULT ) { return ''; } - download( filename, handler( LAST_RESULT ), mimetype ); + download( handler( LAST_RESULT ), filename, mimetype ); } } @@ -726,27 +726,6 @@ */ function getAllJsonData( data ) { return JSON.stringify( data ); - } - - /** - * Produce file download. - * - * @param {string} filename - * @param {string} text - * @param {string} contentType - */ - function download( filename, text, contentType ) { - if ( !text ) { - return; - } - var element = document.createElement( 'a' ); - element.setAttribute( 'href', 'data:' + contentType + ',' + encodeURIComponent( text ) ); - element.setAttribute( 'download', filename ); - - element.style.display = 'none'; - document.body.appendChild( element ); - element.click(); - document.body.removeChild( element ); } $( document ).ready( function () { diff --git a/gui/index.html b/gui/index.html index c98cf70..76352d4 100644 --- a/gui/index.html +++ b/gui/index.html @@ -14,6 +14,7 @@ <script src="vis.js"></script> <script src="wdqs.js"></script> <script src="wdqs-explorer.js"></script> +<script src="download.min.js"></script> <link rel="stylesheet" href="vendor/bootstrap/bootstrap.min.css"> <link rel="stylesheet" href="vendor/codemirror/lib/codemirror.css"> <link rel="stylesheet" href="vendor/codemirror/addon/hint/show-hint.css"> -- To view, visit https://gerrit.wikimedia.org/r/255054 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5fb654bd1358f92af69bad5c501633b7a93dec86 Gerrit-PatchSet: 1 Gerrit-Project: wikidata/query/rdf Gerrit-Branch: master Gerrit-Owner: Smalyshev <smalys...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits