Replace MediawikiJS with alternative library
This commit is contained in:
parent
0bd65a3d6f
commit
3cbcfb4bce
|
@ -1 +0,0 @@
|
||||||
/*! MediawikiJS v0.1.0 | MIT License | github.com/brettz9/mediawiki-js */(function(){'use strict';var JSONP=(function(global){var id=0,ns='MediaWikiJS',prefix='__JSONP__',document=global.document,documentElement=document.documentElement;return function(uri,callback){var src=prefix+id++,script=document.createElement('script'),JSONPResponse=function(){try{delete global[ns][src]}catch(e){global[ns][src]=null}documentElement.removeChild(script);callback.apply(this,arguments)};global[ns][src]=JSONPResponse;documentElement.insertBefore(script,documentElement.lastChild).src=uri+(uri.indexOf('?')>-1?'&':'?')+'callback='+ns+'.'+src}}(window));function MediaWikiJS(opts,argObj,cb){if(!(this instanceof MediaWikiJS)){return new MediaWikiJS(opts,argObj,cb)}if(typeof opts==='string'){this.baseURL=opts}else{this.apiPath=opts.apiPath;this.baseURL=opts.baseURL}if(!this.apiPath){this.apiPath='/w/api.php'}if(argObj){this.send(argObj,cb)}}MediaWikiJS.prototype.send=function MediaWikiJS__send(argObj,cb){cb=cb||function(){};var uri,arg,args='';for(arg in argObj){if(argObj.hasOwnProperty(arg)){args+='&'+arg+'='+encodeURIComponent(argObj[arg])}}uri=this.baseURL+this.apiPath+'?format=json'+args;JSONP(uri,cb)};window.MediaWikiJS=MediaWikiJS}());
|
|
11
index.html
11
index.html
|
@ -192,7 +192,7 @@
|
||||||
<a href="https://git.fwdekker.com/FWDekker/interlanguage-checker/src/branch/master/LICENSE">MIT License</a>.
|
<a href="https://git.fwdekker.com/FWDekker/interlanguage-checker/src/branch/master/LICENSE">MIT License</a>.
|
||||||
Source code available on <a href="https://git.fwdekker.com/FWDekker/interlanguage-checker/">git</a>.
|
Source code available on <a href="https://git.fwdekker.com/FWDekker/interlanguage-checker/">git</a>.
|
||||||
|
|
||||||
<div style="float: right;">v1.1.0</div>
|
<div style="float: right;">v1.0.2</div>
|
||||||
</section>
|
</section>
|
||||||
</footer>
|
</footer>
|
||||||
</main>
|
</main>
|
||||||
|
@ -200,7 +200,8 @@
|
||||||
|
|
||||||
<!-- Scripts -->
|
<!-- Scripts -->
|
||||||
<script src="https://static.fwdekker.com/js/common.js" crossorigin="anonymous"></script>
|
<script src="https://static.fwdekker.com/js/common.js" crossorigin="anonymous"></script>
|
||||||
<script src="MediawikiJS.js" crossorigin="anonymous"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/fetch-jsonp/1.1.3/fetch-jsonp.min.js"
|
||||||
|
integrity="sha256-1ar8IuE0nRpUw1CRhDsyndspfpqMu5tQTPRaKA6Rk+E=" crossorigin="anonymous"></script>
|
||||||
<script>
|
<script>
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
@ -312,8 +313,6 @@
|
||||||
/**
|
/**
|
||||||
* Interacts with the API in an asynchronous manner.
|
* Interacts with the API in an asynchronous manner.
|
||||||
*
|
*
|
||||||
* Wraps around the MediawikiJS library.
|
|
||||||
*
|
|
||||||
* @property baseUrl {string} the origin of the wiki's API
|
* @property baseUrl {string} the origin of the wiki's API
|
||||||
* @property apiPath {string} the path relative to the wiki's API; starts with a `/`
|
* @property apiPath {string} the path relative to the wiki's API; starts with a `/`
|
||||||
*/
|
*/
|
||||||
|
@ -325,7 +324,6 @@
|
||||||
*/
|
*/
|
||||||
constructor(apiUrl) {
|
constructor(apiUrl) {
|
||||||
const urlObj = new URL(apiUrl);
|
const urlObj = new URL(apiUrl);
|
||||||
this._mwjs = MediaWikiJS({baseURL: urlObj.origin, apiPath: urlObj.pathname});
|
|
||||||
this.origin = urlObj.origin;
|
this.origin = urlObj.origin;
|
||||||
this.apiPath = urlObj.pathname;
|
this.apiPath = urlObj.pathname;
|
||||||
}
|
}
|
||||||
|
@ -339,7 +337,8 @@
|
||||||
*/
|
*/
|
||||||
request(params) {
|
request(params) {
|
||||||
console.debug(`Requesting from ${this.origin}${this.apiPath} with params`, params);
|
console.debug(`Requesting from ${this.origin}${this.apiPath} with params`, params);
|
||||||
return new Promise(resolve => this._mwjs.send(params, it => resolve(it)));
|
return fetchJsonp(this.origin + this.apiPath + "?format=json&" + new URLSearchParams(params).toString())
|
||||||
|
.then(it => it.json());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue