forked from whydoidoit/babel-playcanvas-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathexerpt.js
22 lines (21 loc) · 744 Bytes
/
exerpt.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
var getFileUrl = pc.Asset.prototype.getFileUrl;
pc.Asset.prototype.getFileUrl = function () {
var file = this.getPreferredFile();
var local;
if (this.type === 'script') {
if (!!(local = getParameterByName('local'))) {
var url = file.url.slice(file.url.lastIndexOf('/'));
return local + url;
}
}
return getFileUrl.call(this);
};