2013-07-07 20:07:11 +00:00
|
|
|
define([
|
2014-04-26 00:53:06 +00:00
|
|
|
"jquery",
|
|
|
|
"underscore",
|
|
|
|
"utils",
|
|
|
|
"classes/Extension",
|
|
|
|
"fileSystem",
|
|
|
|
"settings",
|
|
|
|
"text!html/userCustomSettingsBlock.html",
|
|
|
|
"text!html/tooltipUserCustomExtension.html"
|
|
|
|
], function($, _, utils, Extension, fileSystem, settings, userCustomSettingsBlockHTML, tooltipUserCustomExtensionHTML) {
|
2013-07-07 20:07:11 +00:00
|
|
|
|
2014-04-26 00:53:06 +00:00
|
|
|
var userCustom = new Extension("userCustom", "UserCustom extension", true);
|
|
|
|
userCustom.settingsBlock = userCustomSettingsBlockHTML;
|
|
|
|
userCustom.defaultConfig = {
|
|
|
|
code: ""
|
|
|
|
};
|
2013-07-07 20:07:11 +00:00
|
|
|
|
2014-04-26 00:53:06 +00:00
|
|
|
var fileMgr;
|
|
|
|
userCustom.onFileMgrCreated = function(fileMgrParameter) {
|
|
|
|
fileMgr = fileMgrParameter;
|
|
|
|
};
|
2013-07-07 20:07:11 +00:00
|
|
|
|
2014-04-26 00:53:06 +00:00
|
|
|
var synchronizer;
|
|
|
|
userCustom.onSynchronizerCreated = function(synchronizerParameter) {
|
|
|
|
synchronizer = synchronizerParameter;
|
|
|
|
};
|
2013-07-07 20:07:11 +00:00
|
|
|
|
2014-04-26 00:53:06 +00:00
|
|
|
var publisher;
|
|
|
|
userCustom.onPublisherCreated = function(publisherParameter) {
|
|
|
|
publisher = publisherParameter;
|
|
|
|
};
|
2013-07-07 20:07:11 +00:00
|
|
|
|
2014-04-26 00:53:06 +00:00
|
|
|
var eventMgr;
|
|
|
|
userCustom.onEventMgrCreated = function(eventMgrParameter) {
|
|
|
|
eventMgr = eventMgrParameter;
|
2014-10-12 17:57:58 +00:00
|
|
|
eventMgr.addListener('onReady', function() {
|
|
|
|
utils.createTooltip(".tooltip-usercustom-extension", tooltipUserCustomExtensionHTML);
|
|
|
|
});
|
2014-04-26 00:53:06 +00:00
|
|
|
};
|
2013-07-07 20:07:11 +00:00
|
|
|
|
2014-04-26 00:53:06 +00:00
|
|
|
userCustom.onLoadSettings = function() {
|
|
|
|
utils.setInputValue("#textarea-usercustom-code", userCustom.config.code);
|
|
|
|
};
|
2013-07-07 20:07:11 +00:00
|
|
|
|
2014-04-26 00:53:06 +00:00
|
|
|
userCustom.onSaveSettings = function(newConfig, event) {
|
|
|
|
newConfig.code = utils.getInputValue("#textarea-usercustom-code");
|
|
|
|
try {
|
|
|
|
/*jshint evil: true */
|
|
|
|
eval(newConfig.code);
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
eventMgr.onError(e);
|
|
|
|
// Mark the textarea as error
|
|
|
|
utils.getInputTextValue("#textarea-usercustom-code", event, /^$/);
|
|
|
|
}
|
|
|
|
};
|
2013-07-07 20:07:11 +00:00
|
|
|
|
2014-04-26 00:53:06 +00:00
|
|
|
userCustom.onInit = function() {
|
|
|
|
try {
|
|
|
|
/*jshint evil: true */
|
|
|
|
eval(userCustom.config.code);
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
console.error(e);
|
|
|
|
}
|
|
|
|
};
|
2013-12-02 00:09:39 +00:00
|
|
|
|
2014-04-26 00:53:06 +00:00
|
|
|
return userCustom;
|
2013-07-07 20:07:11 +00:00
|
|
|
});
|