[Phpfreechat-svn] SF.net SVN: phpfreechat: [752] trunk
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-09-11 21:20:42
|
Revision: 752 http://svn.sourceforge.net/phpfreechat/?rev=752&view=rev Author: kerphi Date: 2006-09-11 14:20:26 -0700 (Mon, 11 Sep 2006) Log Message: ----------- Work in progress: window notifications Modified Paths: -------------- trunk/src/client/pfcclient.js trunk/src/client/pfcgui.js trunk/src/phpfreechat.class.php Added Paths: ----------- trunk/lib/javascript/activity.js Added: trunk/lib/javascript/activity.js =================================================================== --- trunk/lib/javascript/activity.js (rev 0) +++ trunk/lib/javascript/activity.js 2006-09-11 21:20:26 UTC (rev 752) @@ -0,0 +1,68 @@ +var DetectActivity = Class.create(); +DetectActivity.prototype = { + initialize: function(subject) + { + this.onunactivate = function() {}; + this.onactivate = function() {}; + this.isactive = true; + Event.observe(subject, 'mousemove', this._OnFocus, false); + Event.observe(subject, 'mouseout', this._OnBlur, false); + }, + _OnFocus: function(e) + { +// document.title = 'focus'; + this.isactive = true; +// this.onactivate(); + }, + _OnBlur: function(e) + { +// document.title = 'blur'; + this.isactive = false; +// this.onunactivate(); + }, + isActive: function() + { + return this.isactive; + } +} + + + +/* +// Unused code, by usefull for further auto idle features + + _launchTimeout: function(myself) + { +var oldisactive = this.isactive; + if (this.oldposx == this.posx && + this.oldposy == this.posy) + this.isactive = false; + else + this.isactive = true; +this.oldposx = this.posx; +this.oldposy = this.posy; +if (oldisactive != this.isactive) alert("switch"); + setTimeout(function() { myself._launchTimeout(myself); }, 1000); + }, + + _OnMouseMove: function(e) + { + var posx = 0; + var posy = 0; + if (!e) var e = window.event; + if (e.pageX || e.pageY) + { + posx = e.pageX; + posy = e.pageY; + } + else if (e.clientX || e.clientY) + { + posx = e.clientX + document.body.scrollLeft + + document.documentElement.scrollLeft; + posy = e.clientY + document.body.scrollTop + + document.documentElement.scrollTop; + } + this.posx = posx; + this.posy = posy; + }, +*/ Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-09-11 16:36:33 UTC (rev 751) +++ trunk/src/client/pfcclient.js 2006-09-11 21:20:26 UTC (rev 752) @@ -28,6 +28,7 @@ this.cmdhistoryid = -1; this.cmdhistoryissearching = false; + /* this.channels = Array(); this.channelids = Array(); @@ -50,7 +51,6 @@ this.blinktmp = Array(); this.blinkloop = Array(); this.blinktimeout = Array(); - }, connectListener: function() @@ -61,6 +61,9 @@ // this.el_online = $('pfc_online'); this.el_errors = $('pfc_errors'); + this.detectactivity = new DetectActivity(this.el_container); +// this.detectactivity.onunactivate = this.gui.unnotifyWindow; + /* the events callbacks */ this.el_words.onkeypress = this.callbackWords_OnKeypress.bindAsEventListener(this); this.el_words.onkeydown = this.callbackWords_OnKeydown.bindAsEventListener(this); @@ -71,6 +74,7 @@ this.el_container.onmousedown = this.callbackContainer_OnMousedown.bindAsEventListener(this); this.el_container.onmouseup = this.callbackContainer_OnMouseup.bindAsEventListener(this); document.body.onunload = this.callback_OnUnload.bindAsEventListener(this); + }, refreshGUI: function() @@ -699,7 +703,8 @@ if (this.gui.getTabId() != tabid) this.gui.notifyTab(tabid); // notify the window (change the title) - this.gui.notifyWindow(); + if (!this.detectactivity.isActive()) + this.gui.notifyWindow(); } if (msg_html[recipientid] == null) Modified: trunk/src/client/pfcgui.js =================================================================== --- trunk/src/client/pfcgui.js 2006-09-11 16:36:33 UTC (rev 751) +++ trunk/src/client/pfcgui.js 2006-09-11 21:20:26 UTC (rev 752) @@ -17,6 +17,7 @@ this.onlinecontent = $H(); this.scrollpos = $H(); this.elttoscroll = $H(); + this.windownotifynb = 0; }, /** @@ -267,11 +268,19 @@ */ notifyWindow: function() { - var el_title = document.getElementsByTagName('title'); -// el_title[0].innerHTML = '[*]'; +//alert(this.windownotifynb); + this.windownotifynb += 1; + var rx = new RegExp('^\\[[0-9]+\\](.*)','ig'); + document.title = document.title.replace(rx,'$1'); + document.title = '['+this.windownotifynb+']'+document.title; }, + unnotifyWindow: function() + { + this.windownotifynb = 0; + var rx = new RegExp('^\\[[0-9]+\\](.*)','ig'); + document.title = document.title.replace(rx,'$1'); + }, - /** * This function change the tab icon in order to catch the attention */ Modified: trunk/src/phpfreechat.class.php =================================================================== --- trunk/src/phpfreechat.class.php 2006-09-11 16:36:33 UTC (rev 751) +++ trunk/src/phpfreechat.class.php 2006-09-11 21:20:26 UTC (rev 752) @@ -109,6 +109,7 @@ $js[] = "javascript/regex.js"; $js[] = "javascript/utf8.js"; $js[] = "javascript/sprintf2.js"; + $js[] = "javascript/activity.js"; $js[] = "pfcclient.js"; $js[] = "pfcgui.js"; $js[] = "pfcresource.js"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |