Fix "My RTHK Radio Player" Windows Gadget
Although looking elegant, the My RTHK radio player available in the official site (at least the Windows gadget version) suffers from two critical problems on displaying the schedule.
- If you are in a time zone different from HKT (GMT +8), the on-air program shown in minimized mode is based on the program schedule of the day and your local time. Suppose you are in the US. At the time you are in your morning while Hong Kong is at night, the live stream plays the night show, but the on-air program shown is some
morning show. - The gadget retrieves program schedules which is updated every midnight. However, each schedule covers time from 6.00am - 5.59am the next day. This means when you are at time from 0.00am - 5.59am, the schedules you have are for the next day.
- Download the gadget file.
- Unzip it. (Renaming the extension to
.zip
may help.) - Open
script/common.js
as a text file (with Notepad,
for example). Look for the linevar currentH = current.getHours();
(which is in the definition of the function isOnAir(obj)
)
Add the following linecurrentH = (currentH + current.getTimezoneOffset()/60 + 8)%24;
This fixes problem 1. - In the same file, look for the line
var fullRe = new
RegExp(/([0-9]{2})\:([0-9]{2})-([0-9]{2})\:([0-9]{2})[^a]*]*>(.*?)<\/a>/);
(which is in the definition of the functionrthk_parseSchedule(str)
)
Replace it withvar fullRe = new RegExp(/([0-9]{2})\:([0-9]{2}) -
([0-9]{2})\:([0-9]{2})[^a]*<a target=_blank
href="([^"]+)"[^>]*>(.*?)<\/a>/);
- In the same file, look for the line
link:result[5],
(which is in the definition of the functionrthk_parseSchedule(str)
)
Replace it withlink:'http://www.rthk.org.hk'+result[5],
- Open
RadioPlayer.js
as a text file. Look for the block// Parser RSS Data to array
// For Version 1.0.0
// var data = rthk_parseSchedule(gReader.req.responseText);// For Version 1.0.2
var data = rthk_parseScheduleV2(gReader.req.responseText);
lslib.trace('# onReaderLoaded:'+ data.length);
Change it to the following:// Parser RSS Data to array
// For Version 1.0.0
var data = rthk_parseSchedule(gReader.req.responseText);
// For Version 1.0.2//var data = rthk_parseScheduleV2(gReader.req.responseText);
//lslib.trace('# onReaderLoaded:'+ data.length); - Open AppConfig.js as a text file. Change the following lines as instructed below:
schedule:'http://www.rthk.org.hk/rthk_include/rthk_radio1_schedule.xml',
toschedule:'http://www.rthk.org.hk/rthk/schedule/radio1',
schedule:'http://www.rthk.org.hk/rthk_include/rthk_radio2_schedule.xml',
toschedule:'http://www.rthk.org.hk/rthk/schedule/radio2',
schedule:'http://www.rthk.org.hk/rthk_include/rthk_radio3_schedule.xml',
toschedule:'http://www.rthk.org.hk/rthk/schedule/radio3',
schedule:'http://www.rthk.org.hk/rthk_include/rthk_radio4_schedule.xml',
toschedule:'http://www.rthk.org.hk/rthk/schedule/radio4',
schedule:'http://www.rthk.org.hk/rthk_include/rthk_radio5_schedule.xml',
toschedule:'http://www.rthk.org.hk/rthk/schedule/radio5',
schedule:'http://www.rthk.org.hk/rthk_include/rthk_pth_schedule.xml',
toschedule:'http://www.rthk.org.hk/rthk/schedule/pth',
- To make sure that the schedule in the program is always up-to-date, in
AppConfig.js
find the lineDATA_REFRESH_TIME = 60; // Data Updates Time, by mintues
Change it toDATA_REFRESH_TIME = 1; // Data Updates Time, by mintues
So the program retrieves the schedule every minute. Sometimes it may be necessary because the schedule located in the remote RTHK site may not have updated at 6.00am HKT sharp, when the program is supposed to retrieve the schedule again. - Zip all the folders and files again. Name with whatever you like, but with a
.gadget
extension. Then double-click it to install.
Afternoon in New York, morning in Hong Kong
Morning show title in the modified gadget (at top right),
but evening news shown as title in original gadget (at middle right)
Morning show title in the modified gadget (at top right),
but evening news shown as title in original gadget (at middle right)
Comments
Post a Comment