Hi Ben,
Just send it as an attachment to this list. Thanks for contributing ! :)
done! it's nice to contribute to a project that i really like. 'winres' has been a saviour of mine many times :)
- Ben
--
There are 10 types of people in the world: Those who understand binary, and those who don't.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Ben Williams
Sent: Thursday, June 12, 2003 6:42 AM
To: [EMAIL PROTECTED]
Subject: [DQSD-Devel] new alarm function
hi all,
i've made some modifications to the alarm function (searches/alarm.xml), to add a "minutes from now" option as well as a timestamp option. e.g. it will now allow you to enter:
alarm 5 my notification message
to make an alarm go off in 5 minutes.
i also made some changes in the way it handled timestamps (times greater than 23:59 are now scaled back to 23:59) and gave it a nicer error message (i think ;-) ).
who should i send my modified alarm.xml file to?
- Ben
<search function="alarm">
<name>Alarm</name>
<description>
Schedule an alarm to go off at a certain time. The alarm message is optional. (All times are in Military (24hr) Time. Supports only a single alarm.)<br/>
<div class="helpboxDescLabels">Usage:</div>
<table class="helpboxDescTable">
<tr><td>Set Alarm</td><td> - </td><td>alarm <<i>time</i>> [<<i>message</i>>]</td></tr>
<tr><td>Cancel Alarm</td><td> - </td><td>alarm cancel</td></tr>
</table>
<div class="helpboxDescLabels">Example:</div>
<table class="helpboxDescTable">
<tr><td>alarm 14:00 Staff Meeting</td></tr>
</table>
</description>
<category>Functions</category>
<contributor>Monty Scroggins</contributor>
<contributor>Ben Williams ([EMAIL PROTECTED])</contributor>
<script><![CDATA[
var alarmTime;
var curTime;
var alarmMsg;
var alNum;
var parsedLine;
var parsedMsg;
function alarm(t)
{
if( nullArgs("alarm",t) )
return false;
if( t.match(/^cancel.*$/i) )
{
clearInterval(alNum);
setSearchWindowText("Alarm Canceled.");
setTimeout("document.deff.q.value='';",1000);
}
else if( parsedLine = t.match(/(\d\d\:\d\d)\s+(.*)/) )
{
if( parsedLine[1] != null && parsedLine[1].length != 0) {
if(parsedTime = parsedLine[1].match(/(\d\d):(\d\d)/)) {
alarmTimeHours = parsedTime[1];
alarmTimeMins = parsedTime[2];
if(alarmTimeHours > 23) alarmTimeHours = 23;
if(alarmTimeMins > 59) alarmTimeMins = 59;
alarmTime = alarmTimeHours+":"+alarmTimeMins;
}
}
parsedMsg = parsedLine[2];
alarmMsg = 'Alarm: ' + alarmTime + '\n\nAlarm has Expired';
if(parsedMsg != null && parsedMsg.length != 0 )
alarmMsg = 'Alarm: ' + alarmTime + '\n\n' + parsedMsg;
alarmOn();
setSearchWindowText("Alarm Set for "+alarmTime+".");
setTimeout("document.deff.q.value='';",1000);
}
else if( parsedLine = t.match(/^(\d+)\s+(.*)$/) )
{
if( parsedLine[1] != null && parsedLine[1].length != 0) {
var dt = new Date();
minutesToAdd = parsedLine[1];
alarmTimeMs = Date.parse(dt.toString()) + (minutesToAdd * 60000);
alarmTimeDate = dt.setTime(alarmTimeMs);
alarmTime = IfZero(dt.getHours()) + ":" + IfZero(dt.getMinutes());
}
parsedMsg = parsedLine[2];
alarmMsg = 'Alarm: ' + alarmTime + '\n\nAlarm has Expired';
if(parsedMsg != null && parsedMsg.length != 0 )
alarmMsg = 'Alarm: ' + alarmTime + '\n\n' + parsedMsg;
alarmOn();
setSearchWindowText("Alarm Set for "+alarmTime+".");
setTimeout("document.deff.q.value='';",1000);
}
else
{
window.alert("Sorry, the timestamp you entered for the alarm could not be read.\n\nThe format should be HH:MM in 24-hour time, or the number of minutes from now for the alarm to go off.");
return;
}
}
function IfZero( num )
{
return (num <= 9) ? ("0" + num) : num;
}
function alarmOn()
{
var dt = new Date();
curTime = IfZero(dt.getHours()) + ":" + IfZero(dt.getMinutes());
if( alarmTime == curTime )
{
clearInterval(alNum);
window.alert(alarmMsg);
}
else
alNum=setTimeout("alarmOn()", 6000)
}
]]></script>
<copyright>
Copyright (c) 2002 David Bau
Distributed under the terms of the
GNU Public License, Version 2 (http://www.gnu.org/copyleft/gpl.txt)
</copyright>
</search>
