Automatic Away Mode
Add functions for changing user presence to ``away`` or ``xa``
This commit is contained in:
parent
0511f9a588
commit
d631af58a9
43
converse.js
43
converse.js
@ -228,6 +228,8 @@
|
|||||||
allow_logout: true,
|
allow_logout: true,
|
||||||
allow_muc: true,
|
allow_muc: true,
|
||||||
allow_otr: true,
|
allow_otr: true,
|
||||||
|
auto_away: 0, //in seconds
|
||||||
|
auto_xa: 0, //in seconds
|
||||||
allow_registration: true,
|
allow_registration: true,
|
||||||
animate: true,
|
animate: true,
|
||||||
auto_list_rooms: false,
|
auto_list_rooms: false,
|
||||||
@ -351,6 +353,46 @@
|
|||||||
|
|
||||||
// Module-level functions
|
// Module-level functions
|
||||||
// ----------------------
|
// ----------------------
|
||||||
|
|
||||||
|
this.autoAwayReset=function(){
|
||||||
|
if (converse._idleCounter > 0) {
|
||||||
|
converse._idleCounter = 0;
|
||||||
|
if (converse._autoAway>0) {
|
||||||
|
converse._autoAway=0;
|
||||||
|
converse.xmppstatus.setStatus('online');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.registerAutoAwayHandler = function (){
|
||||||
|
if (converse.auto_away>0 || converse.auto_xa>0){
|
||||||
|
if (converse.auto_xa>0 && converse.auto_xa<converse.auto_away) converse.auto_xa=converse.auto_away;
|
||||||
|
converse._idleCounter=0;
|
||||||
|
converse._autoAway=0;
|
||||||
|
|
||||||
|
$(window).on('click' , function(){converse.autoAwayReset()});
|
||||||
|
$(window).on('mousemove' , function(){converse.autoAwayReset()});
|
||||||
|
$(window).on('keypress' , function(){converse.autoAwayReset()});
|
||||||
|
$(window).on('focus' , function(){converse.autoAwayReset()});
|
||||||
|
$(window).on('beforeunload' , function(){converse.autoAwayReset()});
|
||||||
|
|
||||||
|
window.setInterval(function () {
|
||||||
|
if (converse._idleCounter <= converse.auto_away || (converse.auto_xa>0 && converse._idleCounter <= converse.auto_xa)){
|
||||||
|
converse._idleCounter++;
|
||||||
|
}
|
||||||
|
if (converse.auto_away>0 && converse._autoAway!=1 && converse._idleCounter > converse.auto_away && converse._idleCounter <= converse.auto_xa){
|
||||||
|
converse._autoAway=1;
|
||||||
|
converse.xmppstatus.setStatus('away');
|
||||||
|
}
|
||||||
|
else if (converse.auto_xa>0 && converse._autoAway!=2 && converse._idleCounter > converse.auto_xa){
|
||||||
|
converse._autoAway=2;
|
||||||
|
converse.xmppstatus.setStatus('xa');
|
||||||
|
}
|
||||||
|
}, 1000); //every seconds
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
this.playNotification = function () {
|
this.playNotification = function () {
|
||||||
var audio;
|
var audio;
|
||||||
if (converse.play_sounds && typeof Audio !== "undefined"){
|
if (converse.play_sounds && typeof Audio !== "undefined"){
|
||||||
@ -684,6 +726,7 @@
|
|||||||
this.enableCarbons();
|
this.enableCarbons();
|
||||||
this.initStatus($.proxy(function () {
|
this.initStatus($.proxy(function () {
|
||||||
|
|
||||||
|
this.registerAutoAwayHandler();
|
||||||
this.chatboxes.onConnected();
|
this.chatboxes.onConnected();
|
||||||
this.giveFeedback(__('Contacts'));
|
this.giveFeedback(__('Contacts'));
|
||||||
if (this.callback) {
|
if (this.callback) {
|
||||||
|
@ -8,6 +8,7 @@ Changelog
|
|||||||
* Bugfix. Manual login doesn't work when only websocket_url is set and not bosh_service_url. [jcbrand]
|
* Bugfix. Manual login doesn't work when only websocket_url is set and not bosh_service_url. [jcbrand]
|
||||||
* Bugfix. clearSessions during unload event would throw an error when not logged in. [gbonvehi]
|
* Bugfix. clearSessions during unload event would throw an error when not logged in. [gbonvehi]
|
||||||
* #389 Allow login panel placeholders and roster item 'Name' translations. [gbonvehi]
|
* #389 Allow login panel placeholders and roster item 'Name' translations. [gbonvehi]
|
||||||
|
* Add automatic Away mode [thierrytiti]
|
||||||
|
|
||||||
0.9.3 (2015-05-01)
|
0.9.3 (2015-05-01)
|
||||||
------------------
|
------------------
|
||||||
|
@ -175,6 +175,27 @@ It should be used either with ``authentication`` set to ``anonymous`` or to
|
|||||||
If ``authentication`` is set to ``login``, then you will also need to provide a
|
If ``authentication`` is set to ``login``, then you will also need to provide a
|
||||||
valid ``jid`` and ``password`` values.
|
valid ``jid`` and ``password`` values.
|
||||||
|
|
||||||
|
auto_away
|
||||||
|
---------
|
||||||
|
|
||||||
|
* Default: ``0``
|
||||||
|
|
||||||
|
This option can be used to let converse.js automatically change user presence
|
||||||
|
|
||||||
|
This set the number a seconds before user presence become ``away``
|
||||||
|
If the value if negative or ``0``, the function is disabled.
|
||||||
|
|
||||||
|
auto_xa
|
||||||
|
-------
|
||||||
|
|
||||||
|
* Default: ``0``
|
||||||
|
|
||||||
|
This option can be used to let converse.js automatically change user presence
|
||||||
|
|
||||||
|
This set the number a seconds before user presence become ``xa`` (eXtended Away)
|
||||||
|
The value must be greater than ``auto_away``
|
||||||
|
If the value if negative or ``0``, the function is disabled.
|
||||||
|
|
||||||
auto_reconnect
|
auto_reconnect
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user