mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(config) add Notifications
This commit is contained in:
parent
de6f3096ff
commit
4cb7ec21e5
6 changed files with 52 additions and 1 deletions
1
HELP.md
1
HELP.md
|
|
@ -149,6 +149,7 @@ All main configuration could be done via [config.json](json/config.json "Config"
|
|||
"appCache" : false, /* cache files for offline use */
|
||||
"analytics" : true, /* google analytics suport */
|
||||
"diff" : false, /* when save - send patch, not whole file */
|
||||
"notifications" : false, /* show notifications when tab is not active*/
|
||||
"localStorage" : true, /* cache directory data */
|
||||
"minify" : true /* minification of js,css,html and img */
|
||||
"online" : true, /* load js files from cdn or local path */
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
<li><span><input type="checkbox" id="appCache" {{ appCache }} ></input></span><label for="appCache"> App cache</label></li>
|
||||
<li><span><input type="checkbox" id="analytics" {{ analytics }} ></input></span><label for="analytics"> Analytics</label></li>
|
||||
<li><span><input type="checkbox" id="diff" {{ diff }} ></input></span><label for="diff"> Diff</label></li>
|
||||
<li><span><input type="checkbox" id="notifications" {{ notifications }} ></input></span><label for="notifications"> Notifications</label></li>
|
||||
<li><span><input type="checkbox" id="localStorage" {{ localStorage }} ></input></span><label for="localStorage"> Local Storage</label></li>
|
||||
<li><span><input type="checkbox" id="minify" {{ minify }} ></input></span><label for="minify"> Minify</label></li>
|
||||
<li><span><input type="checkbox" id="online" {{ online }} ></input></span><label for="online"> Online</label></li>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
"appСache": false,
|
||||
"analytics": true,
|
||||
"diff": false,
|
||||
"notifications": false,
|
||||
"localStorage": true,
|
||||
"minify": true,
|
||||
"online": true,
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ var CloudCmd, Util, DOM;
|
|||
INPUT = 'INPUT',
|
||||
CONFIG,
|
||||
TEMPLATE,
|
||||
Notify = DOM.Notify,
|
||||
Config = this;
|
||||
|
||||
function init(pCallBack) {
|
||||
|
|
@ -130,6 +131,11 @@ var CloudCmd, Util, DOM;
|
|||
|
||||
obj[name] = data;
|
||||
|
||||
if (name === 'notifications') {
|
||||
if (data && !Notify.check())
|
||||
Notify.request();
|
||||
}
|
||||
|
||||
CloudCmd.setConfig(CONFIG, function() {
|
||||
CONFIG[name] = data;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ var CloudCmd, Util, DOM, $;
|
|||
MouseBinded,
|
||||
Key = CloudCmd.Key,
|
||||
Images = DOM.Images,
|
||||
Notify = DOM.Notify,
|
||||
Console = this;
|
||||
|
||||
function init() {
|
||||
|
|
@ -126,6 +127,7 @@ var CloudCmd, Util, DOM, $;
|
|||
|
||||
if (jqconsole && ret) {
|
||||
jqconsole.Write(Buffer[status], status + '-msg');
|
||||
Notify.send(Buffer[status]);
|
||||
Buffer[status] = '';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -642,6 +642,44 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
return lRet;
|
||||
};
|
||||
},
|
||||
NotifyProto = function() {
|
||||
var Notify = this,
|
||||
Show = false;
|
||||
|
||||
Events.add({
|
||||
'blur' :function() {
|
||||
Show = true;
|
||||
},
|
||||
'focus': function() {
|
||||
Show = false;
|
||||
}
|
||||
}, window);
|
||||
|
||||
this.send = function(msg) {
|
||||
var notify, granted = Notify.check();
|
||||
|
||||
if (granted && Show)
|
||||
notify = new Notification(msg);
|
||||
};
|
||||
|
||||
this.check = function () {
|
||||
var ret,
|
||||
Not = Notification,
|
||||
perm = Not.permission;
|
||||
|
||||
if (perm === 'granted')
|
||||
ret = true;
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
this.request = function () {
|
||||
var Not = Notification;
|
||||
|
||||
if (Not)
|
||||
Not.requestPermission();
|
||||
};
|
||||
},
|
||||
|
||||
LoaderProto = function() {
|
||||
var Loader = this;
|
||||
|
|
@ -1953,6 +1991,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
|
||||
DOMTree = Util.extendProto(DOMTreeProto),
|
||||
Events = Util.extendProto(EventsProto),
|
||||
Notify = Util.extendProto(NotifyProto),
|
||||
Loader = Util.extendProto(LoaderProto),
|
||||
Images = Util.extendProto(ImagesProto),
|
||||
RESTful = Util.extendProto(RESTfulProto),
|
||||
|
|
@ -1968,7 +2007,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
Events : Events,
|
||||
RESTful: RESTful,
|
||||
Images : Images,
|
||||
Cache : Cache
|
||||
Cache : Cache,
|
||||
Notify : Notify
|
||||
}
|
||||
]);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue