Skip to content

Instantly share code, notes, and snippets.

@theredpea
Last active September 4, 2018 15:25
Show Gist options
  • Save theredpea/a97986c58bad6c724106b594b4aebed9 to your computer and use it in GitHub Desktop.
Save theredpea/a97986c58bad6c724106b594b4aebed9 to your computer and use it in GitHub Desktop.
define("apis/qvariable", [], function() {
"use strict";
function a(a) {
return a.waitForOpen.promise.then(function() {
return a.enigmaModel
})
}
function b(a, b) {
this.app = a,
this.qapp = b
}
function c(a) {
var b = "string" == typeof a ? {
qName: a
} : a;
return b.qInfo = b.qInfo || {},
b.qInfo.qType = b.qInfo.qType || "variable",
b
}
return b.prototype.create = function(b) {
var d = c(b);
return a(this.app).then(function(a) {
return a.createVariableEx(d)
})
}
,
b.prototype.createSessionVariable = function(b) {
var d = c(b);
return a(this.app).then(function(a) {
return a.createSessionVariable(d)
})
}
,
b.prototype.get = function(b) {
return a(this.app).then(function(a) {
return a.getVariableById(b)
})
}
,
b.prototype.getByName = function(b) {
return a(this.app).then(function(a) {
return a.getVariableByName(b)
})
}
,
b.prototype.setStringValue = function(b, c) {
return a(this.app).then(function(a) {
return a.getVariableByName(b)
}).then(function(a) {
return a.setStringValue(c).then(function() {
return a.getLayout()
})
})
}
,
b.prototype.setNumValue = function(b, c) {
return a(this.app).then(function(a) {
return a.getVariableByName(b)
}).then(function(a) {
return a.setNumValue(c).then(function() {
return a.getLayout()
})
})
}
,
b.prototype.setContent = function(a, b) {
return this.setStringValue(a, b + "")
}
,
b.prototype.getContent = function(a, b) {
var c = this.qapp
, d = b ? function(a) {
b(a, c)
}
: function() {}
;
return this.getByName(a).then(function(a) {
return a ? a.getLayout().then(function(a) {
var b = {
qContent: {
qString: a.qText,
qIsNum: !isNaN(a.qNum)
}
};
return d(b, c),
b
}) : a
})
}
,
b
}),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment