import { isUndefined } from './type.js'; /* * getPath * 功能:获取该js文件所在路径 */ function getPath(siz) { var scriptList = document.scripts, thisPath = scriptList[scriptList.length - 1].src; for (var i = 0; i < scriptList.length; i++) { var scriptName = scriptList[i].getAttribute('name') || scriptList[i].getAttribute('data-name'); var src = scriptList[i].src.slice(scriptList[i].src.lastIndexOf('/') + 1, scriptList[i].src.lastIndexOf('.')); if ((scriptName && (scriptName == 'moeplayer' || scriptName == 'moeplayer.min')) || (scriptList[i].src && (src == 'moeplayer' || src == 'moeplayer.min'))) { thisPath = scriptList[i].src; break; } } var path=thisPath.substring(0, thisPath.lastIndexOf('/js/') + 1); if(!isUndefined(siz)){ path+=siz+'/'; } return path; } export { getPath };