-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHypeCommandPipeline.js
41 lines (37 loc) · 1.23 KB
/
HypeCommandPipeline.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*!
Hype CommandPipeline 1.3
copyright (c) 2019 Max Ziebell, (https://maxziebell.de). MIT-license
*/
/*
* Version-History
* 1.0 (Beta) Initial release under MIT-license
* 1.1 Fixed error handling and now the errors are detailed
* 1.2 Fixed pipeline and made parsing more robust
* 1.3 Converted into a selfcontained extension
*/
if("HypeCommandPipeline" in window === false) window['HypeCommandPipeline'] = (function () {
var commandPipeline = function(hypeDocument, element, event) {
if (event.customBehaviorName.indexOf('|')>-1) {
var cmd = event.customBehaviorName.split('|');
try {
var fnparams = JSON.parse('['+cmd[1]+']');
} catch (e) {
alert("Hype CommandPipeline:\n"+e.name+': '+e.message);
}
if (typeof fnparams === "object"){
var fn = cmd[0].trim();
if (hypeDocument.hasOwnProperty(fn)) {
if (typeof hypeDocument[fn] === "function") {
hypeDocument[fn].apply(hypeDocument, fnparams);
}
}
}
}
}
if("HYPE_eventListeners" in window === false) { window.HYPE_eventListeners = Array();}
window.HYPE_eventListeners.push({"type":"HypeTriggerCustomBehavior", "callback": commandPipeline});
/* Reveal Public interface to window['HypeCommandPipeline'] */
return {
version: '1.3'
};
})();