1
0
Fork 0

make fgcommand.js a AMD module

This commit is contained in:
Torsten Dreyer 2015-02-04 21:03:16 +01:00
parent 5dcc0aa2ef
commit 1ff18c2cba

View file

@ -1,21 +1,34 @@
/** /**
* *
*/ */
var fgCommand = { (function(factory) {
if (typeof define === "function" && define.amd) {
// AMD. Register as an anonymous module.
define([], factory);
} else {
// Browser globals
factory(jQuery);
}
}(function(arg) {
fgCommand = {
oneArg : function(t1, p1) { oneArg : function(t1, p1) {
return { return {
name : '', name : '',
children : [ { children : [
{
name : t1, name : t1,
index : 0, index : 0,
value : p1 value : p1
} ] }
]
}; };
}, },
twoArgs : function(t1, p1, t2, p2) { twoArgs : function(t1, p1, t2, p2) {
return { return {
name : '', name : '',
children : [ { children : [
{
name : t1, name : t1,
index : 0, index : 0,
value : p1 value : p1
@ -23,7 +36,8 @@ var fgCommand = {
name : t2, name : t2,
index : (t1 == t2 ? 1 : 0), index : (t1 == t2 ? 1 : 0),
value : p2 value : p2
} ] }
]
}; };
}, },
@ -55,6 +69,14 @@ var fgCommand = {
$.post("/run.cgi?value=pause"); $.post("/run.cgi?value=pause");
}, },
reset : function() {
$.post("/run.cgi?value=reset");
},
exit : function() {
$.post("/run.cgi?value=exit");
},
dialogShow : function(dlg) { dialogShow : function(dlg) {
this.sendCommand("dialog-show", this.oneArg("dialog-name", dlg)); this.sendCommand("dialog-show", this.oneArg("dialog-name", dlg));
}, },
@ -69,3 +91,5 @@ var fgCommand = {
} }
}; };
return fgCommand;
}));