2013-07-07 20:07:11 +00:00
|
|
|
define([
|
|
|
|
"jquery",
|
|
|
|
"underscore",
|
|
|
|
"utils",
|
|
|
|
"classes/Extension",
|
|
|
|
"fileSystem",
|
|
|
|
"settings",
|
|
|
|
"text!html/userCustomSettingsBlock.html",
|
|
|
|
], function($, _, utils, Extension, fileSystem, settings, userCustomSettingsBlockHTML) {
|
|
|
|
|
|
|
|
var userCustom = new Extension("userCustom", "UserCustom extension", true);
|
|
|
|
userCustom.settingsBlock = userCustomSettingsBlockHTML;
|
|
|
|
userCustom.defaultConfig = {
|
|
|
|
code: "",
|
|
|
|
};
|
|
|
|
|
|
|
|
var fileMgr = undefined;
|
|
|
|
userCustom.onFileMgrCreated = function(fileMgrParameter) {
|
|
|
|
fileMgr = fileMgrParameter;
|
|
|
|
};
|
|
|
|
|
|
|
|
var synchronizer = undefined;
|
|
|
|
userCustom.onSynchronizerCreated = function(synchronizerParameter) {
|
|
|
|
synchronizer = synchronizerParameter;
|
|
|
|
};
|
|
|
|
|
|
|
|
var publisher = undefined;
|
|
|
|
userCustom.onPublisherCreated = function(publisherParameter) {
|
|
|
|
publisher = publisherParameter;
|
|
|
|
};
|
|
|
|
|
2013-07-30 08:46:36 +00:00
|
|
|
var eventMgr = undefined;
|
|
|
|
userCustom.onEventMgrCreated = function(eventMgrParameter) {
|
|
|
|
eventMgr = eventMgrParameter;
|
2013-07-07 20:07:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
userCustom.onLoadSettings = function() {
|
|
|
|
utils.setInputValue("#textarea-usercustom-code", userCustom.config.code);
|
|
|
|
};
|
|
|
|
|
|
|
|
userCustom.onSaveSettings = function(newConfig, event) {
|
|
|
|
newConfig.code = utils.getInputValue("#textarea-usercustom-code");
|
|
|
|
try {
|
|
|
|
eval(newConfig.code);
|
|
|
|
}
|
|
|
|
catch(e) {
|
2013-07-30 08:46:36 +00:00
|
|
|
eventMgr.onError(e);
|
2013-07-07 20:07:11 +00:00
|
|
|
// Mark the textarea as error
|
|
|
|
utils.getInputTextValue("#textarea-usercustom-code", event, /^$/);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
userCustom.onInit = function() {
|
|
|
|
try {
|
|
|
|
eval(userCustom.config.code);
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
console.error(e);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return userCustom;
|
|
|
|
});
|