473,396 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Making icon in taskbar flash

eragon
431 256MB
hello good people. i have a chatroom on my website and i was looking for a script that would make the little icon for the browser flash when there is new activity, or make a popup, or something. is there a javascript code i can make that lets the browser know when there is activity. i use a div that is updated with AJAX to hold the content. when a new message is sent i would like to have something blink, a visual notification, and a little ding or some sound that would let people know somebody said something.

thanks
Nov 22 '07 #1
7 6044
acoder
16,027 Expert Mod 8TB
You can't make the icon flash, but you could play a sound (depending upon support and user preferences). Visual notification would have to be limited to within the browser, not outside.
Nov 23 '07 #2
eragon
431 256MB
thats interesting, because i used meebo and when i get a message the button for firefox flashes. maybe its just really hard. on my page is a div tag that is updated with ajax, i would like to know how to play a sound when a new line is added to the div. can you help me?
Nov 23 '07 #3
acoder
16,027 Expert Mod 8TB
There is one possibility: you could change the title repeatedly using setInterval.
Nov 25 '07 #4
eragon
431 256MB
my title already flashes between my sites name and the short url, so i can add another, like, New Message, that will join the cycle and let me know, but i am not ajax savvy and have absolutely no clue on earth how to detect more information in the box. maybe find a difference of scroll height? and how does it know when i view the messages? i could put a onClick in my text entry field... i dont know... thats why im asking for help. please?
Nov 25 '07 #5
acoder
16,027 Expert Mod 8TB
You know that it's updated when the Ajax object's readyState is 4.

What does your code look like? Can you post some of it?
Nov 26 '07 #6
eragon
431 256MB
soyatinly... (its a large script)

[html]
<?php session_start();
if(!isset($_SESSION['userid'])) { exit; } ?>
<html>
<head>
<title>Ajax Chat 3.1 (Room 1)</title>
<style type="text/css">
#content {
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
}
<!--username styles goe here-->
</style>
<script type="text/javascript">
function moveToBottom()
{
var div = document.getElementById('chatwindow');
h = div.scrollHeight;
sh = div.scrollTop;
st = div.offsetHeight;
difference = h - sh;
alt = st + 50
if (difference > alt) {
} else {
div.scrollTop = h;
}
}

function forceToBottom()
{
var div = document.getElementById('chatwindow');
h = div.scrollHeight;
div.scrollTop = h;
}

var t
function timedCount()
{
t=setTimeout("moveToBottom()",200)
t=setTimeout("timedCount()",200)
}
</script>
</head>
<body>



<div id="content" style="overflow:hidden;">
<div id="chatwindow" style="overflow:auto; height:300px; border: 1px solid #CCCCCC;" height="300px"></div>
<input id="chatnick" type="hidden" value="<?php echo(''.$_SESSION['userid'].''); ?>">
Smilies and other options coming soon! &nbsp;<br>
<input id="chatmsg" type="text" size="60" maxlength="80" onkeyup="keyup(event.keyCode); timedCount();">
<input type="button" value="add" onClick="submit_msg(); timedCount();" style="cursor:pointer;border:1px solid gray;">
<input name="button" type="button" style="cursor:pointer;border:1px solid gray;" onClick="forceToBottom();" value="&dArr;">
</div>

</body>
</html>

<script type="text/javascript">

/* Settings you might want to define */
var waittime=10;

/* Internal Variables & Stuff */
chatmsg.focus()
document.getElementById("chatwindow").innerHTML = "<center><b><p><p>Loading...</b></center>";

var xmlhttp = false;
var xmlhttp2 = false;


/* Request for Reading the Chat Content */
function ajax_read(url) {
if(window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
if(xmlhttp.overrideMimeType){
xmlhttp.overrideMimeType('text/xml');
}
} else if(window.ActiveXObject){
try{
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
} catch(e){
}
}
}

if(!xmlhttp) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}

xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState==4) {
document.getElementById("chatwindow").innerHTML = xmlhttp.responseText;

zeit = new Date();
ms = (zeit.getHours() * 24 * 60 * 1000) + (zeit.getMinutes() * 60 * 1000) + (zeit.getSeconds() * 1000) + zeit.getMilliseconds();
intUpdate = setTimeout("ajax_read('chat.txt?x=" + ms + "')", waittime)
}
}

xmlhttp.open('GET',url,true);
xmlhttp.send(null);
}

/* Request for Writing the Message */
function ajax_write(url){
if(window.XMLHttpRequest){
xmlhttp2=new XMLHttpRequest();
if(xmlhttp2.overrideMimeType){
xmlhttp2.overrideMimeType('text/xml');
}
} else if(window.ActiveXObject){
try{
xmlhttp2=new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try{
xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
} catch(e){
}
}
}

if(!xmlhttp2) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}

xmlhttp2.open('GET',url,true);
xmlhttp2.send(null);
}

/* Submit the Message */
function submit_msg(){
nick = document.getElementById("chatnick").value;
msg = document.getElementById("chatmsg").value;

if (nick == "") {
check = prompt("please enter username:");
if (check === null) return 0;
if (check == "") check = "anonymous";
document.getElementById("chatnick").value = check;
nick = check;
}

document.getElementById("chatmsg").value = "";
ajax_write("w.php?m=" + msg + "&n=" + nick);
}

/* Check if Enter is pressed */
function keyup(arg1) {
if (arg1 == 13) submit_msg();
}

/* Start the Requests! ;) */
var intUpdate = setTimeout("ajax_read('chat.txt')", waittime);

</script>
[/html]

and theres another page, see next post
Nov 28 '07 #7
eragon
431 256MB
contd.

[php]
<?php
session_start();
//$_SERVER['REQUEST_TIME'];
date_default_timezone_set('America/New_York');
/* author: chris at linuxuser.at
licence: GPLv2
*/

$fn = "chat.txt";
$maxlines = 180000;
$nick_length = 100;

/* Set this to a minimum wait time between posts (in sec) */
$waittime_sec = 0;

/* spam keywords */


/* IP's to block */
$blockip[] = "72.60.167.89";

/* spam, if message IS exactly that string */
$espam[] = "ajax";

/* Get Message & Nick from the Request and Escape them */
$msg = $_REQUEST["m"];
$msg = htmlspecialchars(stripslashes($msg));

$n = $_REQUEST["n"];
$n = htmlspecialchars(stripslashes($n));

if (strlen($n) >= $nick_length) {
$n = substr($n, 0, $nick_length);
} else {
for ($i=strlen($n); $i<$nick_length; $i++) $n .= "";
}

if ($waittime_sec > 0) {
$lastvisit = $_COOKIE["lachatlv"];
setcookie("lachatlv", time());

if ($lastvisit != "") {
$diff = time() - $lastvisit;
if ($diff < 5) { die(); }
}
}

if ($msg != "") {
if (strlen($msg) < 2) { die(); }
if (strlen($msg) > 3) {
/* Smilies are ok */
if (strtoupper($msg) == $msg) { die(); }
}
if (strlen($msg) > 150) { die(); }
if (strlen($msg) > 15) {
if (substr_count($msg, substr($msg, 6, 8)) > 1) { die(); }
}

foreach ($blockip as $a) {
if ($_SERVER["REMOTE_ADDR"] == $a) { die(); }
}

$mystring = strtoupper($msg);
foreach ($spam as $a) {
if (strpos($mystring, strtoupper($a)) === false) {
/* Everything Ok Here */
} else {
die();
}
}

foreach ($espam as $a) {
if (strtoupper($msg) == strtoupper($a)) { die(); }
}

$handle = fopen ($fn, 'r');
$chattext = fread($handle, filesize($fn)); fclose($handle);

$arr1 = explode("\n", $chattext);

if (count($arr1) > $maxlines) {
/* Pruning */
$arr1 = array_reverse($arr1);
for ($i=0; $i<$maxlines; $i++) { $arr2[$i] = $arr1[$i];
}
$arr2 = array_reverse($arr2);
} else {
$arr2 = $arr1;
}

$chattext = implode("\n", $arr2);

if (substr_count($chattext, $msg) > 2) { die(); }
//Now we add the time:
$today = date("g:i A");

$out = $chattext . "<font class=\"".$_SESSION['userid']."\">[".$today."] " . $n . ":</font> " . $msg . "<br>\n";
$out = str_replace("\'", "'", $out);
$out = str_replace("\\\"", "\"", $out);

// lovely smilies :)
$raw = array(
":)",
":(",
";)",
":o",
":@",
"-.-",
":D",
">.>",
":,("
);
$happy = array(
"<img src=\"../images/smile/1.gif\" />",
"<img src=\"../images/smile/2.gif\" />",
"<img src=\"../images/smile/5.gif\" />",
"<img src=\"../images/smile/3.gif\" />",
"<img src=\"../images/smile/6.gif\" />",
"<img src=\"../images/smile/8.gif\" />",
"<img src=\"../images/smile/4.gif\" />",
"<img src=\"../images/smile/9.gif\" />",
"<img src=\"../images/smile/7.gif\" />"
);
$outs = str_replace($raw, $happy, $out);

$handle = fopen ($fn, 'w'); fwrite ($handle, $outs); fclose($handle);
}
?>
[/php]
yay php. this one is the trimmer that cleans up the posts. if you want i would be more than happy if you cleaned it up, also, if you made a way to have multiple rooms in onw by setting a get paramatre in cht.php so it writes to a different text file. also, how do i get ajax to stop refreshing my smilies every second, it gets annoying... thanks!
Nov 28 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Morten Bendsen | last post by:
Is it possible to set the icon and title for a group of buttons on the taskbar? The group appears when several applicationwindows are opened, and when "Group similar taskbar buttons" are...
5
by: Dave | last post by:
Hi I am trying to set my windows xp pro system up so that i can write and test ..asp pages.I have followed the instructions given by www.w3schools.com to install the internet information...
0
by: Huw Lloyd | last post by:
I am trying to develop a small VB.NET server application that runs in the background and places an icon in the Windows Taskbar. When the user double clicks on the taskbar icon the application...
3
by: jm | last post by:
Hi, I have a C# program that changes the notifyIcon during the program. What I have noticed is that sometimes when the program is over the old icon will still be in the system tray. But when i...
2
by: Brian | last post by:
Dear my friends, I have been helped by many C# gurus here, thank you very much. My small application can help you fetch some good pictures from Internet. You can get it from...
0
by: Jean Bredeche | last post by:
Hi: My application creates multiple forms, all of which appear in the taskbar. Because I have my Windows XP configured to "Group similar taskbar buttons", the multiple forms get put into the...
0
by: Richard | last post by:
Hi All, I'm running MySQL 5.0.15-nt over WinXP-Pro/SP2. I just got "My Definitive Guide to MySQL 5", which I find very helpful. It suggests that there should be a "MySQL" icon in the...
2
by: flaper87 | last post by:
Hi everybody!!!! I am developing an aplication, and i want it to stay on the system tray, i found out how to put the icon, but i can minimize it there, What do i have to do?, I'm using python(of...
1
by: meagain | last post by:
How can I let the browser icon/button blink in the taskbar to alert a user that (f.e.) he has an new message when his browser-window is not focused or minimized?? Working with a flash-movie with...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.