1
0
Fork 0

Created empty data pattern

This commit is contained in:
Dan Hromada 2014-06-18 11:52:09 +02:00
parent a4c2ae5ba1
commit e728a3c380
2 changed files with 20 additions and 27 deletions

View file

@ -62,6 +62,16 @@
'//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js'
]
},
host: undefined,
emptyDataPattern: {
config: {
enable: false,
include: '',
extra: ''
},
source: ''
},
data: null,
editor: {
instance: null,
defaultValue: "// Here You can type your custom JavaScript...",
@ -235,6 +245,11 @@
delete response.customjs.src;
}
// Set-up data pattern if empty
if( !popup.data ) {
popup.data = $.extend(true, {}, popup.emptyDataPattern);
}
// Merge host's data to defaults
popup.data = $.extend(popup.data, response.customjs);
@ -256,15 +271,6 @@
popup.applyData(popup.storage.get('draft'));
}
},
host: undefined,
data: {
config: {
enable: false,
include: '',
extra: ''
},
source: ''
},
applyData: function(data, notDraft) {
if( data && !notDraft ) {
@ -374,14 +380,9 @@
// Remove customjs from frontend
chrome.tabs.sendRequest(popup.tabId, {method: "removeData", reload: false});
popup.data = {
config: {
enable: false,
include: '',
extra: ''
},
source: ''
};
// Set-up empty data
popup.data = $.extend(true, {}, popup.emptyDataPattern);
popup.applyData();
popup.removeDraft();
@ -499,14 +500,7 @@
}
// Hotfix for host without customjs
catch(err) {
popup.applyData({
config: {
enable: false,
include: '',
extra: ''
},
source: ''
}, true);
popup.applyData($.extend(true, {}, popup.emptyDataPattern), true);
}
}
else {

View file

@ -7,14 +7,13 @@
"version": "2.1.2",
"permissions": [
"storage",
"http://*/",
"https://*/",
"tabs"
],
"tabs": {},
"icons": { "128": "img/icon_128.png" },
"content_security_policy": "script-src 'self' https://*.googleapis.com; object-src 'self'",