|
|
|
|
alertEngineEx.js Functions
Variables
Libraries
TechNotes
|
|
The purpose of this library is to create Desktop Alerts.
The library scans for updates in alerts feeds or RSS feeds and optionally displays popup alerts when new headlines are retrieved.
This library stores history files on the local computer in order to maintain a list of latest headlines.
A standard XML configuration file must be used.
For more information: xmlSettings.js
The library supports bandwidth optimization. A small XML file containing the update version of the alert XML file is downloaded. When the version number is increased, the alert XML file is downloaded to check for new headlines.
More information: XML Alerts Feeds
Scanning for Alerts
Popup Alert window| |
The library can also be used with popupAlert.kLIB to automatically display the popup alert window.
To enable this feature:
Include the MioScript library popupAlert.kLIB in your project.
Call alertEngine_init from the main HTML document of your application;
The easier way to implement this feature is to create a new project using the template Desktop Alert.
|
Code Sample| |
The following code sample uses the library to scan alerts stored on an HTTP server, and displays a simple alert box to show the title, URL and publishing date. The automatic popup alert feature is not used.
|
ONLINE_ROOT = "http://www.mioplanet.com/"
CONFIG_FILE = "config.xml"
function loaded() {
log_enabled = true;
isDownloading = true;
// Loads the application data as it contains the history of alerts.
mio_data_load("data_load_completed()")
}
// Data loaded, starts downloading the XML configuration file
function data_load_completed() {
no_cache_counter = mio_data_get("INTERNAL_COUNTER", 0)
xml_settings_download(ONLINE_ROOT + CONFIG_FILE,
"settings_downloaded");
}
function settings_downloaded(status) {
isDownloading = false;
if(status == 0) {
sendToMio(
"dialog=You are not connected."
+ "^^Close^^settings_downloaded_close_cb"
);
} else {
if(!xml_settings_appUpdate()) { // No update required?
alertEngine_init(false, "alert_received")
}
}
function settings_downloaded_close_cb() {
mio_close()
}
// Alert received, shows the title, URL and publication date.
function alert_received(alert_bag) {
alert(alert_bag[B_TITLE]+" - "+alert_bag[B_URL]
+" - "+alert_bag[B_DATE])
alertEngine_processed()
}
|
|
|
|