-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathsandcage.min.js
1 lines (1 loc) · 1.42 KB
/
sandcage.min.js
1
var SandCage;SandCage=function(){function e(e){return this.apikey=e,this.apikey?(t=this,("undefined"==typeof JSON||null===JSON)&&this.loadScript("json2.min.js"),this):{status:"error",name:"MissingKey",message:"Provide your SandCage API Key."}}var t={},n="0.2",r="https://api.sandcage.com/"+n+"/";return e.call=function(e,n,r,a){var s,i;if(null==n||n==={})return!1;i={key:t.apikey};for(s in n)i[s]=n[s];return this.ajaxCall(e,i,r,a)},e.ajaxCall=function(e,t,n,a){var s;return n||(t.callback_url=n),t=JSON.stringify(t),s=new XMLHttpRequest,s.open("POST",""+r+e,!1),s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.onreadystatechange=function(){var e;return 4!==s.readyState?!1:(e=JSON.parse(s.responseText),null==e&&(e={status:"error",name:"GenericError",message:"An error occurred."}),a?a(e):!1)},s.send(t)},e.loadScript=function(e){var t;t=new XMLHttpRequest,t.open("GET",e,!1),t.onreadystatechange=function(){var n;4===t.readyState&&200===t.status&&(n=document.createElement("script"),n.setAttribute("type","text/javascript"),n.setAttribute("charset","UTF-8"),n.setAttribute("src",e),document.head.appendChild(n))},t.send(null)},e.getInfo=function(e,t){return null==t?!1:this.call("get-info",e,"",t)},e.listFiles=function(e,t){return null==t?!1:this.call("list-files",e,"",t)},e.scheduleFiles=function(e,t,n){return this.call("schedule-tasks",e,t,n)},e.destroyFiles=function(e,t,n){return this.call("destroy-files",e,t,n)},e}();