diff --git a/data/epplets/clock/README b/data/epplets/clock/README new file mode 100644 index 000000000..3981a3437 --- /dev/null +++ b/data/epplets/clock/README @@ -0,0 +1,12 @@ +This directory contains the following epplets: + - clock.fe + - large time-only display + - clock2.fe + - more graphical clock display with date as well as time + +To use these epplets, simply copy this directory to ~/.e/desktop/default/.e_epplets. This will show clock.fe by default. In order to use clock2.fe, simply rename clock2.fe to clock.fe. + +Thanks to: + - Brian Mattern for helping me get started + - Thibaud for the clock2 background graphic + - The graphic is from his Saona theme (http://www.deviantart.com/deviation.php?id=73252) for HoverDesk diff --git a/data/epplets/clock/clock.fe b/data/epplets/clock/clock.fe index 6115b48e1..8a3ba1a23 100644 --- a/data/epplets/clock/clock.fe +++ b/data/epplets/clock/clock.fe @@ -21,7 +21,7 @@ function clock_update(object data, number val){ string seconds = String.copySection(time,6,8); string timeofday = "AM"; - if(hour > 12 || hour==12){ + if(hour=>12){ timeofday = "PM"; hour -= 12; } @@ -35,7 +35,6 @@ function clock_update(object data, number val){ /* declare vars */ object clock; -object ebits; /* create a new epplet */ epp = new Epplet(); diff --git a/data/epplets/clock/clock2.fe b/data/epplets/clock/clock2.fe new file mode 100644 index 000000000..e63588147 --- /dev/null +++ b/data/epplets/clock/clock2.fe @@ -0,0 +1,123 @@ +/*-------------------------------------------------------* + * Simple clock epplet * + * by Brendon Davidson * + * Thanks to Brian Mattern for helping me understand * + * how epplets work. * + *-------------------------------------------------------*/ + +uses String, Time; + +/* global vars */ +global { + object epp; + object dateObj; + string theDay = ""; +} + +/* function to update time display */ +function time_update(object data, number val){ + string date = Time.ctime(Time.time()); + string month = String.copySection(date,4,7); + string day = String.copySection(date,8,10); + string time = String.copySection(date,11,20); + number hour = String.toLong(String.copySection(time,0,2)); + string min = String.copySection(time,3,5); + string seconds = String.copySection(time,6,8); + string timeofday = "AM"; + + if(hour>12||hour==12){ + timeofday = "PM"; + hour = hour - 12; + } + if(hour==0) hour = 12; + + + /* Is it time to update the date? */ + if(day!=theDay){ + theDay = day; + switch(month){ + case "Jan": + month = "January"; + break; + case "Feb": + month = "February"; + break; + case "Mar": + month = "March"; + break; + case "Apr": + month = "April"; + break; + case "Jun": + month = "June"; + break; + case "Jul": + month = "July"; + break; + case "Aug": + month = "August"; + break; + case "Sep": + month = "September"; + break; + case "Oct": + month = "October"; + break; + case "Nov": + month = "November"; + break; + case "Dec": + month = "December"; + break; + } + dateObj.setText(month+" "+day+", 2002"); + } + + + data.setText(""+hour+" "+min+" "+seconds+" "+timeofday); + epp.addTimer("clockTimer",0.5,"time_update",0,data); +} + +/* main function */ + +/* declare vars */ +object timeObj; +object backgroundObj; + +/* create a new epplet */ +epp = new Epplet(); + +/* move the epplet to desired position*/ +epp.move(epp.getViewW() - 250, 2); +epp.resize(100, 30); + +/* create background image object for clock */ +backgroundObj = new EvasObject(epp); +backgroundObj.addImage("clockbg.png"); +backgroundObj.move(epp.getX(),epp.getY()); +backgroundObj.setLayer(9998); +backgroundObj.show(); + +/* create text object for clock display */ +timeObj = new EvasObject(epp); +timeObj.addText("borzoib",6,"Hi"); +timeObj.move(epp.getX()+epp.getW()-40, epp.getY()+4); +timeObj.setLayer(9999); +timeObj.setColor(0,0,0,140); +timeObj.show(); + +/* create text object for date display */ +dateObj = new EvasObject(epp); +dateObj.addText("borzoib",6,"Hello"); +dateObj.move(epp.getX()+epp.getW()-60,epp.getY()+12); +dateObj.setLayer(9999); +dateObj.setColor(0,0,0,140); +dateObj.show(); + +/* update clock display */ +time_update(timeObj,0); + + + + + diff --git a/data/epplets/clock/clockbg.png b/data/epplets/clock/clockbg.png new file mode 100644 index 000000000..f59fe7fbf Binary files /dev/null and b/data/epplets/clock/clockbg.png differ