70 lines
1.7 KiB
JavaScript
70 lines
1.7 KiB
JavaScript
define([
|
|
"jquery",
|
|
"underscore",
|
|
"utils",
|
|
"classes/Extension",
|
|
"fileSystem",
|
|
"settings",
|
|
"text!html/userCustomSettingsBlock.html",
|
|
"text!html/tooltipUserCustomExtension.html"
|
|
], function($, _, utils, Extension, fileSystem, settings, userCustomSettingsBlockHTML, tooltipUserCustomExtensionHTML) {
|
|
|
|
var userCustom = new Extension("userCustom", "UserCustom extension", true);
|
|
userCustom.settingsBlock = userCustomSettingsBlockHTML;
|
|
userCustom.defaultConfig = {
|
|
code: ""
|
|
};
|
|
|
|
var fileMgr;
|
|
userCustom.onFileMgrCreated = function(fileMgrParameter) {
|
|
fileMgr = fileMgrParameter;
|
|
};
|
|
|
|
var synchronizer;
|
|
userCustom.onSynchronizerCreated = function(synchronizerParameter) {
|
|
synchronizer = synchronizerParameter;
|
|
};
|
|
|
|
var publisher;
|
|
userCustom.onPublisherCreated = function(publisherParameter) {
|
|
publisher = publisherParameter;
|
|
};
|
|
|
|
var eventMgr;
|
|
userCustom.onEventMgrCreated = function(eventMgrParameter) {
|
|
eventMgr = eventMgrParameter;
|
|
};
|
|
|
|
userCustom.onLoadSettings = function() {
|
|
utils.setInputValue("#textarea-usercustom-code", userCustom.config.code);
|
|
};
|
|
|
|
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, /^$/);
|
|
}
|
|
};
|
|
|
|
userCustom.onInit = function() {
|
|
try {
|
|
/*jshint evil: true */
|
|
eval(userCustom.config.code);
|
|
}
|
|
catch(e) {
|
|
console.error(e);
|
|
}
|
|
};
|
|
|
|
userCustom.onReady = function() {
|
|
utils.createTooltip(".tooltip-usercustom-extension", tooltipUserCustomExtensionHTML);
|
|
};
|
|
|
|
return userCustom;
|
|
}); |