Hi.
I have made a script which makes a countdown in my personal message. It works until I close messenger - not log out - close.
When I close it and open it again my countdown stops, but when i log out and log in my countdown works fine.
It is written on danish, but i have you understand what the variables contains
Here is my code:
code:
function OnEvent_SignIn(Email)
{
Opdater();
}
function Opdater()
{
if(Status == "til")
{
var Idag = new Date();
var Dato = new Date(gemAar,gemMaaned - 1,gemDag);
if(Idag >= Dato)
{
Messenger.MyPersonalMessage = gemEfterBegivenhed;
}
else
{
Dato.setHours(gemTimer);
Dato.setMinutes(gemMinutter);
var Forskel = Dato.getTime() - Idag.getTime();
var dageForskel = Math.floor(Forskel/1000/60/60/24);
Forskel -= dageForskel*1000*60*60*24
var timerForskel = Math.floor(Forskel/1000/60/60);
Forskel -= timerForskel*1000*60*60
var minutterForskel = Math.floor(Forskel/1000/60);
Forskel -= minutterForskel*1000*60
var sekunderForskel = Math.floor(Forskel/1000);
if(dageForskel == "1")
{
var visDage = "dag";
}
else
{
var visDage = "dage";
}
if(timerForskel == "1")
{
var visTimer = "time";
}
else
{
var visTimer = "timer";
}
if(minutterForskel == "1")
{
var visMinutter = "minut";
}
else
{
var visMinutter = "minutter";
}
if(sekunderForskel == "1")
{
var visSekunder = "sekund";
}
else
{
var visSekunder = "sekunder";
}
Messenger.MyPersonalMessage = dageForskel + " " + visDage + ", " + timerForskel + " " + visTimer + ", " + minutterForskel + " " + visMinutter + " og " + sekunderForskel + " " + visSekunder + gemBegivenhed;
MsgPlus.AddTimer("OpdaterDato",1000);
}
}
}
function OnEvent_Timer(Id)
{
if(Id = "OpdaterDato")
{
Opdater();
}
}
function Vindue()
{
Popup = MsgPlus.CreateWnd("vindue.xml","WndMain");
try {
var x = shell.RegRead(regPath+"Top");
}
catch(e) {}
if (x == 1) {
Interop.Call("User32.dll","SetWindowPos",Popup.Handle,-1,0,0,0,0,19);Popup.Button_SetCheckState("Chk",true);
}
}
function OnGetScriptMenu(Location)
{
ScriptMenu = "<ScriptMenu>";
ScriptMenu += "<MenuEntry Id=\"indstillinger\">";
ScriptMenu += "Indstillinger";
ScriptMenu += "</MenuEntry>";
ScriptMenu += "<MenuEntry Id=\"tilfra\">";
ScriptMenu += "Slå til/fra";
ScriptMenu += "</MenuEntry>";
ScriptMenu += "</ScriptMenu>";
return ScriptMenu;
}
function OnEvent_MenuClicked(MenuItemId,Location,OriginWnd)
{
switch(MenuItemId)
{
case "indstillinger":
try {var x = Wnd_.Handle;};catch(e) {}
if (x == null){
Vindue();
}
break;
case "tilfra":
if(Status == "til")
{
Status = "fra";
Messenger.MyPersonalMessage = oprindeligPb;
MsgPlus.DisplayToast("Nedtælling","Nedtælling er slået fra.");
}
else
{
Status = "til";
Opdater();
MsgPlus.DisplayToast("Nedtælling","Nedtælling er slået til.");
}
break;
}
}
function OnWndMainEvent_CtrlClicked(Wnd, Handling)
{
switch(Handling)
{
case "knap_gem":
gemDag = Wnd.GetControlText("input_dag");
gemMaaned = Wnd.GetControlText("input_maaned");
gemAar = Wnd.GetControlText("input_aar");
gemTimer = Wnd.GetControlText("input_timer");
gemMinutter = Wnd.GetControlText("input_minutter");
gemBegivenhed = Wnd.GetControlText("input_begivenhed");
gemEfterBegivenhed = Wnd.GetControlText("input_efterBegivenhed");
Status = "til";
Opdater();
Wnd.Close(0);
break;
case "knap_luk":
Wnd.Close(0);
break;
}
}
Thanks in advance.
- Simon