Serence Inc.
Copyright © 2002-2006 Serence Inc.
support@serence.com
http://www.klipfolio.com/
Webcam Tracker
1.0
webcam_tracker_789234
2006.12.05:1700
Track your favourite webcam image with this Klip.
webcam track cam camera
http://www.klipfolio.com
http://www.serence.com/serence_klips/pics/webcam/webcam_tracker_icon.png
http://www.serence.com/serence_klips/pics/webcam/webcam_tracker_banner.jpg
http://www.serence.com/serence_klips/webcam_tracker.klip
4.0
525600
true
ca
--
Getting Webcam image...
No image available.
" +
"" +
"[Click here to enter a webcam location.]" +
"Click here to open the setup window, where you can enter a webcam location to monitor." +
"welcome_message" +
"" +
""
;
var gIntroStyles =
"introitem {type:item; definition: 'introtext,intronotecontent1,introiid';}" +
"introtext {itemcol:1; wrap:false;}" +
"intronotecontent1 {noterow:1; notelabel:false;}" +
"introiid {key:override}"
;
function onLoad()
{
var tab;
tab = Setup.addTab("Webcam");
tab.addText("Enter the address to your webcam (must be a direct link to the image file):");
gWebcam = tab.addTextField(Prefs.getPref("webcam"));
gButton = tab.addButton("Monitor Webcam");
gButton.onClick = buttonClick;
tab.addSpacer(true);
tab.addText("Select the amount of time to wait before refreshing the image:");
gRefreshRate = tab.addComboBox("1 minute", "2 minutes", "5 minutes", "10 minutes", "30 minutes", "1 hour", "2 hours");
p = Prefs.getPref ("refresh");
gRefreshRate.selected = (p.length != 0?Number (p):2);
gRefreshRate.onChange = changeRefreshRate;
// This call creates the timer
if(!KFVersionOutOfDate())
{
changeRefreshRate(gRefreshRate.selected);
}
Items.B = " ";
Setup.onClose = mySetupClose;
}
function buttonClick()
{
savePrefs();
Klip.requestRefresh();
}
function mySetupClose()
{
savePrefs();
}
function savePrefs()
{
Prefs.setPref("webcam", gWebcam.value);
Prefs.setPref("refresh", gRefreshRate.selected);
}
function onRefresh()
{
// Disable the automatic removal of items.
Items.autoremove = false;
Items.B = " ";
// Check to see if the version of KlipFolio is out of date. If not,
// refresh the webcam image.
if(KFVersionOutOfDate())
{
return false;
}
else
{
// The version is not out of date. Make sure the welcome message is
// not displayed.
if(Items.length == 1)
{
if(Items[0].getData("introiid") == "welcome_message")
{
Items.clear(true);
}
}
}
savePrefs();
var success = updateWebcam(false);
// Make sure the user can't delete or dim (visit) the webcam image
if(Items.length)
{
Items[0].canvisit = false;
Items[0].candelete = false;
}
return success;
}
function myTimer()
{
// Refresh the webcam image if the timer has ticked.
if ((Items.length) && (!gOutOfDate))
{
updateWebcam(false);
}
}
function changeRefreshRate(index)
{
if(gTimerCreated)
{
destroyTimer(gTimer);
}
var tickTime = 0;
switch(index)
{
case 0:
// 1 minute
tickTime = 60000;
break;
case 1:
// 2 minutes
tickTime = 120000;
break;
case 2:
// 5 minutes
tickTime = 300000;
break;
case 3:
// 10 minutes
tickTime = 600000;
break;
case 4:
// 30 minutes
tickTime = 1800000;
break;
case 5:
// 1 hour
tickTime = 3600000;
break;
case 6:
// 2 hours
tickTime = 7200000;
break;
}
gTimer = createTimer(tickTime);
gTimer.onTick = myTimer;
gTimerCreated = true;
savePrefs();
}
function updateWebcam(isImageNew)
{
var success = false;
if(gWebcam.value.length > 0)
{
if(gIntroDisplayed)
{
Items.clear(true);
gIntroDisplayed = false;
}
if(gWebcam.value.indexOf("http://") == -1)
{
// Prepend "http://" if the user didn't
gWebcam.value = "http://" + gWebcam.value;
}
if(isImageNew)
{
Items.clear(true);
}
var food = "- " + gWebcam.value + "
";
success = Engines.KlipFood.process(food);
}
else
{
// Display a message for the user
gIntroDisplayed = true;
introMessage();
}
return success;
}
function introMessage()
{
// create temporary items to educate the user
Items.clear (true);
var saveCreate = Engines.KlipFood.onCreate;
var saveUpdate = Engines.KlipFood.onUpdate;
Engines.KlipFood.onCreate = null;
Engines.KlipFood.onUpdate = null;
Engines.KlipFood.stylesheet = gIntroStyles;
try
{
Engines.KlipFood.process (gIntroText);
}
finally
{
Engines.KlipFood.onCreate = saveCreate;
Engines.KlipFood.onUpdate = saveUpdate;
}
idx = Items.length - 1;
Items[idx].canvisit = false; Items[idx].candelete = false; Items[idx].onClick = fn_configure_item_click;
Items.B = " ";
Engines.KlipFood.stylesheet = "@import klip";
}
function fn_configure_item_click()
{
Setup.open(0);
}
function KFVersionOutOfDate()
{
// Check to see if this version of KlipFolio is out of date. Any build
// number higher than 5892 represents version 4 or above.
//
// If the detected version of KlipFolio is older than version 4, then we will
// display a message to the user asking them to upgrade.
if (KlipFolio == null || KlipFolio.build <= 5892)
{
var introText =
"" +
"" +
"KlipFolio verison 4 is required to run this Klip. Click here to download the latest version." +
"http://www.klipfolio.com/inkf-beta" +
"welcome_message" +
"" +
"";
var introStyle =
"introitem {type:item; definition: 'introtext,introlink,introiid';}" +
"introtext {itemcol:1; noterow:1; wrap:true; notelabel:false;}" +
"introlink {type:link;}" +
"introiid {key:override}";
Engines.KlipFood.stylesheet = introStyle;
Engines.KlipFood.process (introText);
Engines.KlipFood.stylesheet = "@import klip";
gOutOfDate = true;
return true;
}
gOutOfDate = false;
return false;
}
]]>