'use strict';
(function() {
var apiPdf = {};
var serverName = 'pdftoppt';
var serverMap = {
'pdftoword':'api-pdf-to-word',
'pdftopng':'api-pdf-to-png',
'pdftojpg':'api-pdf-to-jpg',
'pdftoexcel':'api-pdf-to-excel',
'pdftoppt':'api-pdf-to-ppt',
'pdftotxt':'api-pdf-to-txt',
};
apiPdf.apower={
lang: 'tw',
};
var server = serverMap['pdftoword'];
if(serverName)
{
server = serverMap[serverName]||serverMap['pdftoword'];
}
var langArr=['cs','da','de','el','en','es','fi','fr','hu','it','ja','nl','no','pl','pt','sv','tr','tw','zh',];
window.apiPdf = apiPdf;
if(langArr.indexOf(apiPdf.apower.lang)==-1){
apiPdf.apower.lang = 'en';
}
var sortLoad = {
CDN_ROOT: 'https://cdn.aoscdn.com/local/lightpdf.com',
isLocal:function(){
return location.hostname.endsWith('test');
},
arr:[],
index:-1,
addScript : function (src){
var head= document.getElementsByTagName('head')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
script.src= src+'?1.2.3';
script.onload = function(){
sortLoad.index++;
var fun = sortLoad.arr[sortLoad.index]
if(fun){
fun();
}
};
head.appendChild(script);
return sortLoad;
},
then(fun){
if(fun){
sortLoad.arr.push(fun);
}
return sortLoad;
},
};
// addScript();
if(!sortLoad.isLocal()){
document.head.insertAdjacentHTML('beforeEnd', '');
document.head.insertAdjacentHTML('beforeEnd', '');
sortLoad.addScript(sortLoad.CDN_ROOT+"/js/jquery.min.js").then(
function(){
window['$_lightpdf_'] = $.noConflict(true);
sortLoad.addScript(sortLoad.CDN_ROOT+"/js/api-jquery.js");
}
).then(
function(){
sortLoad.addScript(sortLoad.CDN_ROOT+"/js/polyfill.duplicate.min.js");
}
).then(
function(){
sortLoad.addScript(sortLoad.CDN_ROOT+"/langs/api-"+apiPdf.apower.lang+".js");
}
).then(
function(){
sortLoad.addScript(sortLoad.CDN_ROOT+"/pdf.js/js/pdf.js");
}
).then(
function(){
sortLoad.addScript(sortLoad.CDN_ROOT+"/lib/aliyun-oss-sdk-6.0.1.min.js");
}
).then(
function(){
sortLoad.addScript(sortLoad.CDN_ROOT+"/js/api-common.js");
}
).then(
function(){
sortLoad.addScript(sortLoad.CDN_ROOT+"/js/"+server+".js");
}
);
}else{
document.head.insertAdjacentHTML('beforeEnd', '');
document.head.insertAdjacentHTML('beforeEnd', '');
sortLoad.addScript("/frontend/com/js/jquery.min.js").then(
function(){
sortLoad.addScript("/frontend/com/js/jquery.transform.js");
}
).then(
function(){
sortLoad.addScript("/frontend/com/js/jquery.md5.js");
}
).then(
function(){
sortLoad.addScript("/frontend/js/api-jquery.extend.js");
}
).then(
function(){
sortLoad.addScript("/frontend/js/api-apower.js");
}
).then(
function(){
sortLoad.addScript("/frontend/langs/api-en.js");
}
).then(
function(){
sortLoad.addScript("/frontend/langs/api-zh.js");
}
).then(
function(){
sortLoad.addScript("/frontend/pdf.js/js/pdf.js");
}
).then(
function(){
sortLoad.addScript("/frontend/lib/aliyun-oss-sdk-6.0.1.min.js");
}
).then(
function(){
sortLoad.addScript("/frontend/js/api-common.js");
}
).then(
function(){
sortLoad.addScript("/frontend/js/"+server+".js");
}
).then(
function(){
$.noConflict(true);
}
);
}
})();