# HG changeset patch # User ivanl # Date 1248174985 -3600 # Node ID 07ac2f6a36a9ce11ab89539f63c0d8e981ff5a2a # Parent 5e0dece09f96b8181da84c6018324313d0818aac 1.0rc10 Fixes annoyances and buglets in reading forums and blog. diff -r 5e0dece09f96 -r 07ac2f6a36a9 Symbian.org/FeedUpdateBroker.js --- a/Symbian.org/FeedUpdateBroker.js Mon Jul 13 10:42:26 2009 +0100 +++ b/Symbian.org/FeedUpdateBroker.js Tue Jul 21 12:16:25 2009 +0100 @@ -4,6 +4,7 @@ // Constructor. function FeedUpdateBroker() { + this.escapeLtGt=true; this.httpReq = null; this.feedAddress = null; this.callback = null; @@ -95,7 +96,7 @@ if (node.nodeName == "pubDate" || node.nodeName == "lastBuildDate" || node.nodeName == "dc:date") { - lastModified = getTextOfNode(node); + lastModified = getTextOfNode(node, this.escapeLtGt); break; } } @@ -125,18 +126,18 @@ if (node.nodeType == Node.ELEMENT_NODE) { if (node.nodeName == "title") { // item title - title = getTextOfNode(node); + title = getTextOfNode(node, this.escapeLtGt); } else if (node.nodeName == "pubDate" || node.nodeName == "dc:date") { // item publishing date - date = getTextOfNode(node); + date = getTextOfNode(node, this.escapeLtGt); } else if (node.nodeName == "description" && !this.ignoreContent ) { // item description - description = getTextOfNode(node); + description = getTextOfNode(node, this.escapeLtGt); } else if (node.nodeName == "link") { // link URL - url = getTextOfNode(node); + url = getTextOfNode(node, this.escapeLtGt); } else if (node.nodeName == "dc:creator" ) { - author = getTextOfNode(node); + author = getTextOfNode(node, this.escapeLtGt); } } node = node.nextSibling; @@ -155,7 +156,7 @@ } // Returns the text of a node. -function getTextOfNode(node) { +function getTextOfNode(node, escapeLtGt) { var buf = ""; // iterate through all child elements and collect all text to the buffer var child = node.firstChild; @@ -165,44 +166,51 @@ if (buf != "") { buf += " "; } - buf += escapeLtGt(child.nodeValue); + buf += child.textContent; +// if (escapeLtGt) { +// buf += doEscapeLtGt(child.nodeValue); +// } else { +// buf += child.nodeValue; +// } } child = child.nextSibling; } - // strip all tags from the buffer - var strippedBuf = ""; - var textStartPos = -1; - var tagBalance = 0; - var pos; - // iterate through the text and append all text to the stripped buffer - // that is at a tag balance of 0 - for (pos = 0; pos < buf.length; pos++) { - var c = buf.charAt(pos); - if (c == '<') { - // entering a tag - if (tagBalance == 0 && textStartPos != -1) { - // everything up to here was valid text - strippedBuf += buf.substring(textStartPos, pos); - textStartPos = -1; - } - tagBalance++; - } else if (c == '>') { - // leaving a tag - tagBalance--; - textStartPos = -1; - } else if (tagBalance == 0 && textStartPos == -1) { - // first char of text - textStartPos = pos; - } - } + return buf; +// // strip all tags from the buffer +// var strippedBuf = ""; +// var textStartPos = -1; +// var tagBalance = 0; +// +// var pos; +// // iterate through the text and append all text to the stripped buffer +// // that is at a tag balance of 0 +// for (pos = 0; pos < buf.length; pos++) { +// var c = buf.charAt(pos); +// if (c == '<') { +// // entering a tag +// if (tagBalance == 0 && textStartPos != -1) { +// // everything up to here was valid text +// strippedBuf += buf.substring(textStartPos, pos); +// textStartPos = -1; +// } +// tagBalance++; +// } else if (c == '>') { +// // leaving a tag +// tagBalance--; +// textStartPos = -1; +// } else if (tagBalance == 0 && textStartPos == -1) { +// // first char of text +// textStartPos = pos; +// } +// } +// +// // add remaining text - if any +// if (tagBalance == 0 && textStartPos != -1) { +// strippedBuf += buf.substring(textStartPos, pos); +// } - // add remaining text - if any - if (tagBalance == 0 && textStartPos != -1) { - strippedBuf += buf.substring(textStartPos, pos); - } - - return strippedBuf; +// return strippedBuf; } FeedUpdateBroker.prototype.cancel = function() { @@ -210,7 +218,7 @@ this.httpReq.abort(); } -function escapeLtGt(text){ +function doEscapeLtGt(text){ var lt = "<"; var gt = ">"; return text.replace(//g, gt); diff -r 5e0dece09f96 -r 07ac2f6a36a9 Symbian.org/Forums.js --- a/Symbian.org/Forums.js Mon Jul 13 10:42:26 2009 +0100 +++ b/Symbian.org/Forums.js Tue Jul 21 12:16:25 2009 +0100 @@ -456,7 +456,7 @@ if ( ind3 != -1 && ind3 < ind2) { tag = s.substring(ind+1,ind3); } - var ind4 = s.indexOf("[/"+tag+"]"); + var ind4 = s.indexOf("[/"+tag+"]", ind2); var tagContent = s.substring(ind2+1, ind4); buf += convertTag(tag, fulltag, tagContent); if ( ind4 != -1 ) { diff -r 5e0dece09f96 -r 07ac2f6a36a9 Symbian.org/Main.js --- a/Symbian.org/Main.js Mon Jul 13 10:42:26 2009 +0100 +++ b/Symbian.org/Main.js Tue Jul 21 12:16:25 2009 +0100 @@ -172,7 +172,8 @@ // create blog screen blog = new RssReader(blogFeedName, blogFeedUrl, null, home, null); - + blog.escapeLtGt = false; + // create wiki screen wiki = new RssReader(wikiFeedName, wikiFeedUrl, new ButtonFeedPresenter(null), home, null); diff -r 5e0dece09f96 -r 07ac2f6a36a9 Symbian.org/RssReader.js --- a/Symbian.org/RssReader.js Mon Jul 13 10:42:26 2009 +0100 +++ b/Symbian.org/RssReader.js Tue Jul 21 12:16:25 2009 +0100 @@ -16,6 +16,7 @@ this.hasData = false; this.startFromItem = 0; this.maxItems = 0; + this.escapeLtGt = true; var caption = createCaption(aFeedName); @@ -116,6 +117,7 @@ // fetch the feed from the specified URL this.feedUpdateBrokerActive = true; this.feedUpdateBroker = new FeedUpdateBroker(); + this.feedUpdateBroker.escapeLtGt = this.escapeLtGt; this.feedUpdateBroker.startFromItem = this.startFromItem; this.feedUpdateBroker.maxItems = this.maxItems; diff -r 5e0dece09f96 -r 07ac2f6a36a9 Symbian.org/preview/css/style.css --- a/Symbian.org/preview/css/style.css Mon Jul 13 10:42:26 2009 +0100 +++ b/Symbian.org/preview/css/style.css Tue Jul 21 12:16:25 2009 +0100 @@ -1,188 +1,633 @@ -iframe#widgetIframeWindow { - height: 300px; - z-index: 1; -} +@charset "utf-8"; body { + background-image: url(../images/Gradient0Background.png); + background-repeat: repeat-x; margin: 0px; + font-family: "Nokia Sans", "Nokia Sans SemiBold", "Arial Narrow"; padding: 0px; - margin-top: 70px; - font-family: "Nokia Sans", Arial, Verdana; - font-size: 10px; - overflow-x: hidden; - overflow-y: auto; + overflow: hidden; +} +.hide{ + display:none; +} +.show{ + display:block; +} + +code{ + background-color: #ffffa6; + color: #000000; + padding: 3px; + display: block; + font-size: 110%; + margin: 3px 0px; +} + +#DisplaySFKWrapper{ + overflow: hidden; +} +#DisplayArea { + margin-right: auto; + margin-left: auto; + overflow: hidden; + +} + +#WidgetArea{ + position: relative; + z-index: 99; +} +#WidgetArea iframe{ + width: 100%; + height: 100%; + border: 0px; + margin-left: auto; + margin-top: auto; +} + +#WidgetArea.hs_portrait{ + background-image: url(../images/device/360x640/hs-portrait.png); + background-repeat: no-repeat; +} + +#WidgetArea.hs_landscape{ + background-image: url(../images/device/360x640/hs-landscape.png); + background-repeat: no-repeat; } -#WrapperDiv { - width: 100%; - min-height: 700px; +#WidgetArea.hs_portrait iframe{ + width: 306px; + height: 76px; + margin-left: 26px; + margin-top: 321px; + overflow: hidden !important; +} + +#WidgetArea.hs_landscape iframe{ + width: 306px; + height: 76px; + margin-left: 322px !important; + margin-top: 151px !important; + overflow: hidden !important; +} + +#iframeMask +{ + width: 328px; + height: 100px; + position: absolute; + z-index: 900; + background-image: url(../images/hs-iframeMask.png); + background-repeat: no-repeat; + background-position: top left; +} + +#iframeMask:hover +{ + background-repeat: no-repeat; + background-position: bottom left; +} + + +#WidgetArea.hs_portrait #iframeMask{ + margin-left: 16px !important; + margin-top: 310px !important; +} +#WidgetArea.hs_landscape #iframeMask{ + margin-left: 312px !important; + margin-top: 140px !important; +} + + +#SoftKeys{ + height: 50px; + width: 240px; + margin-right: auto; + margin-left: auto; + margin-top: 10px; +} + +div.clear{ + clear: both; +} +#DeviceDisplayLayout { + background-repeat: no-repeat; + background-position: center center; + margin-right: auto; + margin-left: auto; + margin-top: 0px; overflow: hidden; } -div#navigation { - background-image: url(../images/top-navigation-bg.png); - height: 52px; - overflow: hidden; - position: absolute; - width: 100%; - left: 0px; - top: 0px; +#DeviceDisplayLayout.portrait_240x320 { + background-image: url(../images/device/240x320/Portrait.png); + width: 600px; + height: 536px; +} + +#DeviceDisplayLayout.landscape_240x320 { + background-image: url(../images/device/240x320/Landscape.png); + width: 848px; + height: 408px; +} + +#SoftKeysArea{ + z-index: 101; + position: relative; +/* background-image: url(../images/device/menuKeys-bg.png); + background-repeat: no-repeat; + background-position: center top; +*/ + background-color: #666666; +} + +#SoftKeysArea ul{ + list-style: none; + margin: 0px; + padding: 0px; + +} + +#SoftKeysArea ul li{ + margin: 0px; + font-weight: bold; + font-size: 15px; + float: left; + padding: 5px; +} + + +#SoftKeysArea ul li a{ + color: #FFFFFF; + text-decoration: none; + display: block; +} + +li#RskLabel{ + text-align: right; +} + +#MenuItemsArea{ + z-index: 100; + display: none; +} + +#MenuItemsArea ul{ + margin: 0px; + padding: 5px; + list-style-position: inside; + list-style-image: none; + list-style-type: none; + background-color: #CCCCCC; +} + +#MenuItemsArea ul li{ + font-size: 13px; + font-weight: bold; } -div#navigation strong{ - color: #ffffff; + +#MenuItemsArea li.active{ + background-color: #75ea00; +} + +#MenuItemsArea a{ + color: #000; + text-decoration: none; + display: block; + padding: 5px; + height: 14px; +} +#MenuItemsArea a:hover{ + background-color: #75ea00; +} + +#MenuItemsArea a.subMenuItem{ + background-image: url(../images/sub-menu-arrow.png); + background-repeat: no-repeat; + background-position: right 0px; +} + +#MenuItemsArea a.subMenuItem:hover{ + background-position: right -20px; +} +#MenuItemsArea a.subMenuItem:active{ + background-position: right -40px; +} + +#MenuItemsArea li.active a.subMenuItem{ + background-position: right -20px; } -#device { +div#IconArea{ + display: none; + font-size: 0.9em; + font-weight: bold; + background-repeat: no-repeat; +} + +div#IconArea.portrait240x320{ + background-image: url(../images/statusBar_240x320.png); +} +div#IconArea.landscape240x320{ + background-image: url(../images/statusBar_320x240.png); +} + +div#IconArea.portrait320x240{ + background-image: url(../images/statusBar_320x240.png); +} +div#IconArea.landscape320x240{ + background-image: url(../images/statusBar_240x320.png); +} + +div#IconArea.portrait360x640{ + background-image: url(../images/statusBar_360x640.png); +} +div#IconArea.landscape360x640{ + background-image: url(../images/statusBar_640x360.png); +} + +div#IconArea.landscape800x352{ + background-image: url(../images/statusBar_800x352.png); +} + + +div.IconFile{ + margin-left: auto; margin-right: auto; - margin-left: auto; - width: 10px; + text-align: center; + padding: 20px; } -#DisplayOrientation { - height: 34px; - width: 250px; - margin-right: auto; - margin-left: auto; - margin-bottom: 10px; - background-image: url(../images/display-orientation.png); + +div.IconFile:hover{ + background-image: url(../images/IconArea-hover.png); + background-position: center center; background-repeat: no-repeat; - overflow:hidden; - background-color:#FFFFFF; +} + +div.IconFile p{ + margin: 0px; } -#DisplayOrientation.portrait { - background-position: 0px 0px; -} -#DisplayOrientation.landscape { - background-position: 0px -45px; -} - -div#iframePreviewWindow { - background-color: #FFFFFF; - height: 320px; - width: 240px; -} - -div#display { - background-image: url(../images/device-right.png); - background-repeat: no-repeat; - background-position: right top; -} -div#displayLeft { - background-image: url(../images/device-left.png); - background-repeat: no-repeat; - background-position: left top; - padding-top: 10px; - padding-right: 8px; - padding-bottom: 0px; - padding-left: 9px; +p.highlight span{ + background-color: #fbf7a2; + font-weight: normal; + font-size: 0.8em; + padding: 3px; } -iframe{ - overflow:hidden; +/* + preferences CSS +*/ + +div#PreferencesBtn{ + width: 75px; + height: 85px; + background-image: url(../images/settings-icon.png); + position: absolute; + top: 10px; + left: 10px; + background-position: left bottom; + z-index: 200; } -#DeviceSettings { + +div#PreferencesBtn:hover{ + background-position: left top; +} + +div#loaderDiv{ + padding: 10px; + font-size: 1.1em; position: absolute; top: 0px; - z-index: 1000; - font-size: 12px; - background-color: #ffffff; - padding-top: 0px; - padding-right: 0px; - padding-left: 10px; - display: block; - overflow: hidden; - color: #999999; - opacity: 0.9; - height: 100%; - background-image: url(../images/toolbar-bg-shadow.png); - background-repeat: repeat-y; - background-position: left top; -} -div#pullDown { - height: 50px; - width: 69px; - background-repeat: no-repeat; - margin-left: -61px; - position: absolute; - z-index: 1005; -} -div#pullDown.down { - background-image: url(../images/new-pull-down-btn.png); - background-position: 0px -50px; -} -div#pullDown.up { - background-image: url(../images/new-pull-down-btn.png); - background-position: 0px 0px; + right: 0px; + display: none; + z-index: 202; } -#DeviceSettings strong { +div#loaderDiv.green{ + background-color: #5abd2b; + color: #FFFFFF; +} + +div#loaderDiv.yellow{ + background-color: #ffff00; color: #000000; } -#Toolbar { - position: fixed; - right: 0px; - width: 320px; +div#orientationIcon{ + background-image: url(../images/normal-orientation-icon.png); + background-repeat: no-repeat; + width: 191px; + height: 72px; + float: left; + position: absolute; + left: 10px; + top: 0px; + display: none; +} +div#orientationIcon:hover{ + background-image: url(../images/active-orientation-icon.png); +} + +table{ + border-top: 1px solid #808080; + border-left: 1px solid #808080; +} + +table a.link{ + background-color: #20c41c; + color: #ffffff; + font-weight: bold; + border: 1px solid #4e872c; + padding: 3px 2px; + text-decoration: none; + font-size: 80%; +} + +table th, table td{ + padding: 6px 5px; + border-bottom: 1px solid #808080; + border-right: 1px solid #808080; + font-size: 0.9em; +} +table th{ + width: 150px; + text-align: left; + background-image: url(../images/th-bg-gradient.png); + background-repeat: repeat-x; + background-position: left bottom; +} + +#NotificationDiv p{ + color: #ffffff; + font-size: 95%; + padding: 5px; +} + +strong{ + color: #eee46c; +} + +#BrowserNotificationBar{ + z-index: 2000; + background-color: #f2eb8e; + border-bottom: 2px solid #f0d25e; + display: none; + position: absolute; + left: 0; top: 0; - height: 100%; + width: 100%; + font-size: 80%; + font-weight: bolder; + text-align: right; + margin: 0px; + opacity: 0.9; +} +#BrowserNotificationBar a{ + height: 10px; + width: 10px; + float: right; + background-image: url(../images/BrowserNotificationBar-Toogle.gif); + background-position: 0px -10px; + margin : 4px 15px 0px 10px; + cursor: hand; + overflow: hidden; +} +/* + Event Triggering CSS +*/ + +h2{ + font-size: 120%; + margin: 3px 0px; + padding: 0px; +} + +#tabs-1, #tabs-2{ + height: 223px; + overflow: auto; } -#pullDown { - margin-top: 10px; + +#connect-charger-icon, #dis-connect-charger-icon{ + background-repeat: no-repeat; + background-position: left top; + width: 165px; + height: 36px; + margin: 5px auto; +} + +#connect-charger-icon{ + background-image: url(../images/connect-charger-icon.png); +} + +#dis-connect-charger-icon{ + background-image: url(../images/dis-connect-charger-icon.png); +} + +#connect-charger-icon:hover, #dis-connect-charger-icon:hover{ + background-position: left bottom; +} + +div#event-battery, div#event-messaging, div#event-memory{ + float: left; + width: 150px; + height: 50px; + background-position: left top; + margin: 10px; + background-repeat: no-repeat; + border: 1px solid #6f6f6f; +} + +div#event-battery.active:hover, div#event-messaging.active:hover, div#event-memory.active:hover{ + background-position: 0px -50px; + border: 1px solid #75ea4f; +} + +div#event-messaging.inactive, div#event-memory.inactive{ + background-position: 0px -100px; + border: 1px solid #676767; } -#save { - background-image: url(../images/select-device-tab.png); +div#event-battery{ + background-image: url(../images/battery-icon.png); +} + +div#event-messaging{ + background-image: url(../images/messaging-icon.png); +} + +div#event-memory{ + background-image: url(../images/memory-icon.png); +} + +div.ui-panel{ + height:30px; +} + +a.ui-button, a.ui-button-fixed { + background:#555555 url(../script/jquery-ui/css/ui-darkness/images/555555_40x100_textures_02_glass_20.png) repeat-x scroll 0 50%; + border:1px solid #666666; + color:#EEEEEE; + cursor:pointer; + font-size:0.9em; + font-weight:bolder; + line-height:1.4em; + margin:0.5em 8px 0.5em 0; + padding:0.2em 0.6em 0.3em; + text-decoration: none; +} +a.ui-button:hover, a.ui-button-fixed:hover { + background:#0078A3 url(../script/jquery-ui/css/ui-darkness/images/0078a3_40x100_textures_02_glass_40.png) repeat-x scroll 0 50%; + border:1px solid #4bd94b; + color:#FFFFFF; +} + +a.ui-button-fixed{ + float: left; + padding: 0.4em 0.6em 0.8em; + text-align: center; + width: 145px !important; +} + +div#slider-value-panel{ + text-align: center; + margin-top: 10px; +} + +div#slider-value-panel span{ + padding: 3px; + background:#0078A3 url(../script/jquery-ui/css/ui-darkness/images/0078a3_40x100_textures_02_glass_40.png) repeat-x scroll 0 50%; + border:1px solid #4bd94b; + color:#FFFFFF; + font-weight: bolder; +} + + +/* + Console UI +*/ +#preview-ui-top{ + overflow:auto; +} + +#preview-ui-bottom{ + overflow:hidden; + display: none; +} +#preview-ui-bottom-header{ + background-color: #aeaeae; + background-image: url(../images/console-icon.gif); + background-repeat: repeat-x; + background-position: 0px -28px; +} +span#Console-Toggle-Button{ + height: 9px; + width: 15px; + float: right; background-repeat: no-repeat; - background-position: center center; - font-weight: bold; - color: #FFFFFF; - padding-top: 5px; - padding-bottom: 5px; - border-top-width: 2px; - border-right-width: 2px; - border-bottom-width: 2px; - border-left-width: 2px; - border-top-style: solid; - border-right-style: solid; - border-bottom-style: solid; - border-left-style: solid; - border-top-color: #225311; - border-right-color: #3C931E; - border-bottom-color: #3C931E; - border-left-color: #225311; + margin : 12px 8px 0px 0px; + cursor: hand; +} + +span#Console-Toggle-Button.open{ + background-position: 0px 0px; + background-image: url(../images/console-close-icon.png); +} + +span#Console-Toggle-Button.open:hover{ + background-position: 0px -9px; } -#DeviceSettings p { - border-bottom: 1px solid #E0E0E0; - padding-bottom: 5px; - margin-right: 20px; - margin-left: 20px; - padding-top: 0px; - margin-top: 0px; - margin-bottom: 8px; +span#Console-Toggle-Button.open:active{ + background-position: 0px -18px; +} + + +span#Console-Toggle-Button.close{ + background-position: 0px 0px; + background-image: url(../images/console-open-icon.png); +} + +span#Console-Toggle-Button.close:hover{ + background-position: 0px -9px; +} + +span#Console-Toggle-Button.close:active{ + background-position: 0px -18px; +} + + +span#Console-Clear-Button{ + height: 16px; + width: 39px; + float: right; + background-image: url(../images/console-clear-button.png); + background-repeat: no-repeat; + margin : 10px 10px 0px 0px; + cursor: hand; +} +span#Console-Clear-Button:hover{ + background-position: -0px -16px; +} + +#preview-ui-bottom-body{ + overflow:auto; + background-color: #ffffff; + display: none; +} + +#preview-ui-bottom-body p{ + font-family: "Courier New", Courier, monospace; + font-size: 11px; + padding: 2px 5px; + border-bottom: 1px solid silver; + margin: 0px; } -select#deviceResolution { - margin-left: 15px; - font-size: 13px; - width: 200px; - border: 1px solid #999999; - height: 90px; - margin-top: 10px; -} -#deviceResolution option { - padding: 3px; - font-family: "Nokia Sans", "Nokia Sans SemiBold"; +#preview-ui-bottom-body p.log{ } -#DeviceSettings img { - margin-top: 8px; + +#preview-ui-bottom-body p.info{ + background-image: url(../images/infoIcon.png); + background-repeat: no-repeat; + background-position: 5px center; + padding-left: 26px; +} +#preview-ui-bottom-body p.warn{ + background: #00ffff url(../images/warningIcon.png); + background-repeat: no-repeat; + background-position: 5px center; + padding-left: 26px; +} +#preview-ui-bottom-body p.error{ + background: #ffffe0 url(../images/errorIcon.png); + background-repeat: no-repeat; + background-position: 5px center; + padding-left: 26px; + color: #ff0000; } -label { - padding-top: 8px; - font-weight: bold; - color: #000000; + + +#preview-ui-bottom-header div{ + float: left; + margin: 9px; + color: #ffffff; + font-size: 11px; + font-weight: bolder; + font-family: "Arial"; } -#DeviceSettings input { - margin-top: 5px; + + +span#wrt-help{ + height: 28px; + width: 28px; + float: right; + background-repeat: no-repeat; + background-image: url(../images/wrt-help-icon.png); } + +span#wrt-help:hover{ + background-position: -28px 0px; +} \ No newline at end of file diff -r 5e0dece09f96 -r 07ac2f6a36a9 Symbian.org/preview/nopreview.html --- a/Symbian.org/preview/nopreview.html Mon Jul 13 10:42:26 2009 +0100 +++ b/Symbian.org/preview/nopreview.html Tue Jul 21 12:16:25 2009 +0100 @@ -1,8 +1,44 @@ + -Widget preview is not available for this file, it is not the main html file for the widget. +
Widget preview is not available for this file, it is not the MainHtml file for the widget. +
diff -r 5e0dece09f96 -r 07ac2f6a36a9 Symbian.org/preview/script/lib/loader.js --- a/Symbian.org/preview/script/lib/loader.js Mon Jul 13 10:42:26 2009 +0100 +++ b/Symbian.org/preview/script/lib/loader.js Tue Jul 21 12:16:25 2009 +0100 @@ -1,9 +1,179 @@ -addScript("preview/script/lib/systeminfo.js"); -addScript("preview/script/lib/menu.js"); -addScript("preview/script/lib/menuItem.js"); -addScript("preview/script/lib/widget.js"); +/* + * Emulator, which manages the device interacations + */ +if (typeof _BRIDGE_REF == "undefined" || !_BRIDGE_REF) { + + var _BRIDGE_REF = { + parent: window.parent || false, + nokia: window.parent.NOKIA || false, + sysInfoObject : null + }; -// Includes a script file by writing a script tag. -function addScript(src) { - document.write(""); + _BRIDGE_REF.namespace = function(name){ + var parts = name.split('.'); + var current = _BRIDGE_REF; + for (var key in parts) { + if (!current[parts[key]]) { + current[parts[key]] = {}; + } + current = current[parts[key]]; + } + }; + + /* + * _BRIDGE_REF.helper functions + */ + _BRIDGE_REF.namespace('helper.loadScript'); + _BRIDGE_REF.helper = { + path: document.location.pathname, + loadScript: function(path){ + var head = document.getElementsByTagName("head")[0] || document.documentElement; + var script = document.createElement("script"); + + script.type = "text/javascript"; + script.src = path; + head.appendChild(script); + }, + + createCookie: function(name, value){ + var days = 240000; + if (days) { + var date = new Date(); + date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); + var expires = "; expires=" + date.toGMTString(); + } + else + var expires = ""; + var value = "Nokia_WRT#" + _BRIDGE_REF.helper.path + "#" + name + "=" + value; + document.cookie = value + expires + "; Emulator.path=/" + }, + + readCookie: function(name){ + name = "Nokia_WRT#" + _BRIDGE_REF.helper.path + "#" + name; + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for (var i = 0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0) == ' ') + c = c.substring(1, c.length); + if (c.indexOf(nameEQ) == 0) { + return c.substring(nameEQ.length, c.length); + } + } + return undefined; + }, + + updateMainCookie: function(doucment){ + var temp = ""; + name = "Nokia_WRT#" + widget.path; + for (var k = 0; k < widget.preferenceArray.length; k++) { + temp = temp + "|" + widget.preferenceArray[k]; + } + this.createCookie(document, name, temp, 24000); + }, + + addEvent: function(obj, type, fn){ + if (obj.addEventListener) { + obj.addEventListener(type, fn, false); + } + else + if (obj.attachEvent) { + obj["e" + type + fn] = fn; + obj[type + fn] = function(){ + obj["e" + type + fn](window.event); + } + obj.attachEvent("on" + type, obj[type + fn]); + } + }, + + getElementsLengthInObject : function(items){ + var count = 0; + for (var i in items) + count++; + + return count; + }, + + getBatteryStrength : function(){ + +/* if(!_BRIDGE_REF.sysInfoObject) + _BRIDGE_REF.sysInfoObject = device.getServiceObject("Service.SysInfo", "ISysInfo"); + + var result = _BRIDGE_REF.sysInfoObject.ISysInfo.GetInfo({ + Entity : 'Battery', + Key : 'ChargingStatus' + }); + + if(!result.ErrorCode) + { + return result.Status; + }else + { + alert('Error in getting Battery Strength: '+result.ErrorCode); + return 0; + } + if(typeof device.implementation.data["Service.SysInfo"].default.battery.batterystrength.Status != 'undefined') + return device.implementation.data["Service.SysInfo"].default.battery.batterystrength.Status; + else + return 0; +*/ + }, + + console : function(){ + if (!typeof window.console) { + _BRIDGE_REF.helper.loadScript("preview/script/lib/console.js"); + } + } + + }; + + + /* + Load Scripts + */ + _BRIDGE_REF.helper.loadScript("preview/script/lib/widget.js"); + _BRIDGE_REF.helper.loadScript("preview/script/lib/systeminfo.js"); + _BRIDGE_REF.helper.loadScript("preview/script/lib/menu.js"); + _BRIDGE_REF.helper.loadScript("preview/script/lib/menuItem.js"); + _BRIDGE_REF.helper.loadScript("preview/script/lib/console.js"); + + // Inject SAPI scripts + if (_BRIDGE_REF.nokia) { + var wrtVersion = _BRIDGE_REF.nokia.helper.readCookie('_WRT_VERSION'); + if ((typeof wrtVersion == 'undefined') || (wrtVersion == 'WRT 1.1')) { + _BRIDGE_REF.nokia.version = 'WRT 1.1'; + _BRIDGE_REF.nokia.helper.createCookie('_WRT_VERSION', 'WRT 1.1'); + _BRIDGE_REF.helper.loadScript("preview/script/lib/device.js"); + } + else { + _BRIDGE_REF.nokia.version = 'WRT 1.0'; + } + } + else { + _BRIDGE_REF.helper.loadScript("preview/script/lib/device.js"); + } + + /* + window native functions over-riding + */ + if ( (typeof window.frameElement != 'undefined') && (typeof _BRIDGE_REF.nokia != 'undefined') && window !== window.parent) { + // alert + window.alert = function(msg){ + return window.parent.alert(msg); + }; + + // confirm + window.confirm = function(msg){ + return window.parent.confirm(msg); + }; + + // prompt + window.prompt = function(msg, str){ + return window.parent.prompt(msg, str) + }; + } + + // make TRUE loader.js script loaded + window.parent.NOKIA.scriptsLoaded.loader = true; + } \ No newline at end of file diff -r 5e0dece09f96 -r 07ac2f6a36a9 Symbian.org/preview/script/lib/menu.js --- a/Symbian.org/preview/script/lib/menu.js Mon Jul 13 10:42:26 2009 +0100 +++ b/Symbian.org/preview/script/lib/menu.js Tue Jul 21 12:16:25 2009 +0100 @@ -1,492 +1,497 @@ -/* - Function : menu() - Argument : Void - Returns : Void - Description : Constructor Function creates a Menu object to the WINDOW -*/ +/** + * widget object constructor + * @param {void} + * widget() + * @return {void} + */ -function Menu() +if (typeof window.menu == "undefined" || !window.menu) { - this.items = Array(); - this.index = null; - this.isDimmed = false; - - // Event triggers - this.onShow = null; - this.onRightSoftKeySelect = null; - - // Flag for Menu softkeys disabled to show - this.is_sfk_disabled = false; -} - - -/* - Function : menu.append() - Argument : MenuItem Object - Returns : Void - Description : Function appends MenuItem to a Menu Object -*/ -Menu.prototype.append = function(MenuItem) -{ - if(this.allowedTypeOf(MenuItem)) + window.menu = { - var i; - var flag = true; - try{ - for(i=0; i a")[0].innerHTML = label; + _BRIDGE_REF.nokia.menu.rsk_label = label; + _BRIDGE_REF.nokia.menu.rsk_event = callback; + _BRIDGE_REF.nokia.menu.is_rsk_overridden = true; + } + else + this.setExitToRsk(); + + }catch(e){ + // alert(e); + } + } -/* - Function : Menu.getMenuItemById(id) - Argument : Integer - Returns : MenuItem Object - Description : Function get the MenuItem Object with the reference of id -*/ -Menu.prototype.getMenuItemById = function(id) -{ - var menuItemRef = menuItemExhistsById(this, id, 0); - if(this.allowedTypeOf(menuItemRef)) - return menuItemRef; - else - return undefined; -} + menu.setExitToRsk = function() + { + this.onRightSoftKeySelect = null; + + _BRIDGE_REF.nokia.menu.is_rsk_overridden = false; + _BRIDGE_REF.nokia.menu.rsk_label = ''; + _BRIDGE_REF.nokia.menu.rsk_event = null; + _BRIDGE_REF.parent.$("#RskLabel > a")[0].innerHTML = 'Exit'; + + _BRIDGE_REF.nokia.menu.setRsk(function(){ + _BRIDGE_REF.nokia.menu.exit(); + }); + } + + /* + Function : Menu.showSoftkeys() + Argument : Void + Returns : Void + Description : Makes the softkeys visible. By default the softkeys are not visible + + */ + menu.showSoftkeys = function() + { + /* + * Shows showSoftkeys + */ + _BRIDGE_REF.nokia.menu.softkeys_visibility = true; + _BRIDGE_REF.nokia.menu.showSoftKeys(); + } + + /* + Function : Menu.hideSoftkeys() + Argument : Void + Returns : Void + Description : Makes the softkeys invisible. By default the softkeys are not visible. + + */ + menu.hideSoftkeys = function() + { + /* + * Hide showSoftkeys + */ + _BRIDGE_REF.nokia.menu.softkeys_visibility = false; + _BRIDGE_REF.nokia.menu.hideSoftKeys(); + } + + + /* + * + * ---------------------------------------------------------------- + * Exta Functionalities which helps to make main functions to work + * ---------------------------------------------------------------- + * + */ + + menu.cancel = function() + { + _BRIDGE_REF.nokia.menu.cancel(); + } + + menu.exit = function() + { + _BRIDGE_REF.nokia.menu.exit(); + } + + + menu.triggeLSKEvent = function() + { + if(typeof(window.menu.onShow) == 'function') + { + window.menu.onShow(); + } + _BRIDGE_REF.parent.$('#softKeysPane').show(); + this.show(); + } + + menu.triggerEvent = function(MenuItemId) + { + try{ + var menuItemRef = this.menuItemExhistsById(this, MenuItemId, 0); + if(menuItemRef != null) + { + if(typeof menuItemRef.onSelect == 'function') + menuItemRef.onSelect(MenuItemId); + + if(_BRIDGE_REF.helper.getElementsLengthInObject(menuItemRef.items)) + this.show(MenuItemId); + else + this.cancel(); + + }else + { + this.show(); + } + } + catch(e) + { + alert('triggeEvent: '+MenuItemId+' >> '+e); + } + } + + menu.hasChild = function(parentId) + { + for(var i in this.items) + { + if(this.items[i].parentId == parentId) + { + return true; + } + } + return false; + } + + + menu.allowedTypeOf = function(MenuItem) + { + try + { + if( (typeof(MenuItem) == 'object') && (MenuItem.type == 'MenuItem')) + return true; + } + catch(e) + { + return false; + } + } + + menu.show = function(parentId) + { + try + { + var menuItemsPane = _BRIDGE_REF.parent.$('#MenuItemsArea') + menuItemsPane = menuItemsPane[0]; + + menuItemsPane.innerHTML = ''; + + var ul = document.createElement('ul'); + var ele = window.menu; + + if(typeof parentId != 'undefined' && typeof parentId == 'object') + { + if (typeof window.menu.onShow != null && typeof window.menu.onShow == 'function') { + window.menu.onShow(); + } + } + + if(typeof parentId == 'number') + { + var tempRef = menu.menuItemExhistsById(ele, parentId, 0); + + if(typeof parentId != 'undefined' && typeof tempRef != 'undefined') + ele = tempRef; + } + + if(_BRIDGE_REF.helper.getElementsLengthInObject(ele.items)) + { + for(var key in ele.items) + { + if(!ele.items[key].isDimmed){ + + try{ + ul.appendChild(menu.create_menuElement(ele.items[key])); + }catch(e){ } + } + } + if(typeof parentId == 'number' && _BRIDGE_REF.helper.getElementsLengthInObject(ele.items)) + { + if(ele.parent) + ul.appendChild(menu.create_normalMenuItem('Back', ele.parent.id)); + else + ul.appendChild(menu.create_normalMenuItem('Back', null)); + } + else + { + ul.appendChild(menu.create_exitMenuItem()); + } + + + if(_BRIDGE_REF.helper.getElementsLengthInObject(ele.items) > 5) + menuItemsPane.style.overflowY = 'scroll'; + else + menuItemsPane.style.overflowY = 'hidden'; + + } + else + { + menuItemsPane.style.overflowY = 'hidden'; + ul.appendChild(menu.create_exitMenuItem()); + } + menuItemsPane.innerHTML = ''; + + _BRIDGE_REF.nokia.menu.show(); + } + catch(e) + { + alert('menu.show: '+e); + } + } + /* - Function : Menu.getMenuItemByName(name) - Argument : String - Returns : MenuItem Object - Description : Function get the MenuItem Object with the reference of String name -*/ -Menu.prototype.getMenuItemByName = function(name) -{ - var menuItemRef = menuItemExhistsById(this, name, 1); - -// if(menuItemRef !=null) - if(this.allowedTypeOf(menuItemRef)) - return menuItemRef; - else - return undefined; -} - -/* - Function : Menu.setRightSoftkeyLabel() - Argument : String, Function - Returns : Void - Description : Set the label of the right soft key to str. This enables the default text - to be changed from �exit� and a new function assigned by setting a callbackfunction -*/ -Menu.prototype.setRightSoftkeyLabel = function(label, callbackfunction) -{ - window.menu = this; - - try - { - var rightSoftKey = childToParent_Reference.$('rightSoftKey'); - if(typeof(callbackfunction) == 'function') - { - rightSoftKey.innerHTML = label; - - this.onRightSoftKeySelect = callbackfunction; - rightSoftKey.setAttribute('onClick', 'javascript:Emulator.triggerChildRSK();'); - } - else - { - rightSoftKey.innerHTML = "Cancel"; - this.onRightSoftKeySelect = null; - rightSoftKey.setAttribute('onClick', 'javascript:Emulator.triggerChildRSK();'); - } - }catch(e){ } -} - -/* - Function : Menu.showSoftkeys() - Argument : Void - Returns : Void - Description : Makes the softkeys visible. By default the softkeys are not visible - -*/ -Menu.prototype.showSoftkeys = function() -{ - /* - * Shows showSoftkeys - */ - this.is_sfk_disabled = false; - childToParent_Reference.Emulator.showDeviceSoftKeys(); -} - -/* - Function : Menu.hideSoftkeys() - Argument : Void - Returns : Void - Description : Makes the softkeys invisible. By default the softkeys are not visible. - -*/ -Menu.prototype.hideSoftkeys = function() -{ - /* - * Hide showSoftkeys - */ - this.is_sfk_disabled = true; - childToParent_Reference.Emulator.hideDeviceSoftKeys(); -} - - -/* - * - * ---------------------------------------------------------------- - * Exta Functionalities which helps to make main functions to work - * ---------------------------------------------------------------- - * +* +* HELPER FUNCTIONS +* */ -Menu.prototype.cancel = function() -{ - /* - * Clear menu and Exit the widget - */ - - childToParent_Reference.$('menuItemsPane').innerHTML = ''; - childToParent_Reference.$('menuItemsPane').style.display = 'none'; - - if(this.is_sfk_disabled) - childToParent_Reference.Emulator.hideDeviceSoftKeys(); -} - -Menu.prototype.exit = function() -{ - /* - * Clear menu and Exit the widget - */ - - childToParent_Reference.$('menuItemsPane').innerHTML = ''; - childToParent_Reference.$('menuItemsPane').style.display = 'none'; - - if(childToParent_Reference.Emulator.showSoftKeys_disabled) - childToParent_Reference.$('menuPane').style.display = 'none'; - - // call the Parent function - childToParent_Reference.Emulator.triggerExit(); -} - - -Menu.prototype.showMenu = function(parentId) -{ - try{ - var menuItemsPane = childToParent_Reference.$('menuItemsPane') - menuItemsPane.innerHTML = ''; - - var menuPane = childToParent_Reference.$('menuPane'); - menuPane.style.display = 'block'; - - var ul = document.createElement('ul'); - var ele = this; - if(parentId) + menu.menuItemExhistsById = function(menuReference, value, argumentType) { - ele = menuItemExhistsById(ele, parentId, 0); - } - if(ele.items.length) - { - for(var i=0; i 1) - menuItemsPane.style.overflowY = 'scroll'; - else - menuItemsPane.style.overflowY = 'hidden'; - } - else - { - menuItemsPane.style.overflowY = 'hidden'; - ul.appendChild(createExitMenuElement()); + return null; } - menuItemsPane.innerHTML = ''; - /* - * Set the MenuKeys DIV style.top - */ - childToParent_Reference.Emulator.showDeviceSoftKeys(); - } - catch(e) + + menu.create_menuElement = function(MenuItem) { - alert('showMenu: '+e); - } -} - -Menu.prototype.triggeLeftSoftKeyEvent = function() -{ - if(typeof(window.menu.onShow) == 'function') - { - window.menu.onShow(); + var listitem = document.createElement('li'); + listitem.id = MenuItem.id; + listitem.setAttribute('onClick', 'javascript:NOKIA.emulator.child.menu.triggerEvent('+MenuItem.id+');'); + + var anchor = document.createElement('a'); + anchor.id = 'subMenuItem_'+MenuItem.id; + anchor.innerHTML = MenuItem.name; + if(_BRIDGE_REF.helper.getElementsLengthInObject(MenuItem.items)) + { + anchor.className = 'subMenuItem'; + anchor.setAttribute('href', 'javascript:NOKIA.emulator.child.menu.show('+MenuItem.id+');'); + } + listitem.appendChild(anchor); + return (listitem); } - childToParent_Reference.$('softKeysPane').style.display = 'block'; - this.showMenu(); -} - -Menu.prototype.triggeEvent = function(MenuItemId) -{ - try{ - var menuItemRef = menuItemExhistsById(this, MenuItemId, 0); - if(menuItemRef != null) - { - if(typeof menuItemRef.onSelect == 'function') - menuItemRef.onSelect(MenuItemId); + + menu.create_normalMenuItem = function(MenuTitle, index) + { + var listitem = document.createElement('li'); + + var anchor = document.createElement('a'); + anchor.id = 'subMenuItem_BACK'; + anchor.innerHTML = MenuTitle; + + if (MenuTitle == 'Back') { + listitem.className = 'exitOrBackBtn'; + anchor.setAttribute('href', 'javascript:NOKIA.emulator.child.menu.triggerEvent(' + index + ');'); + } + else + anchor.setAttribute('href', 'javascript:NOKIA.emulator.child.menu.triggerEvent(' + index + ');'); + + listitem.appendChild(anchor); + return (listitem); + } - if(menuItemRef.items.length) - this.showMenu(MenuItemId); - else - this.cancel(); - } - } - catch(e) + menu.create_exitMenuItem = function() { - alert('triggeEvent: '+MenuItemId+' >> '+e); + var listitem = document.createElement('li'); + listitem.className = 'exitOrBackBtn'; + var anchor = document.createElement('a'); + anchor.id = 'subMenuItem_EXIT'; + anchor.innerHTML = 'Exit'; + anchor.setAttribute('href', 'javascript:NOKIA.emulator.child.menu.exit();'); + listitem.setAttribute('onClick', 'javascript:NOKIA.emulator.child.menu.exit();'); + + listitem.appendChild(anchor); + return (listitem); } -} - -Menu.prototype.hasChild = function(parentId) -{ - for(var i=0; i0){ - this.preferenceKey--; +if (typeof window.widget == "undefined" || !window.widget) { + window.widget = { + author : 'Nokia WRT Emulation Library', + // widget identifier, dummy value + identifier: 14021981, + isrotationsupported: true, + + // widget event triggers + onshow: null, + onhide: null, + + sysInfo: [], + onload: null, + opacity: 50, + interval: 20, + isFront: false, + preferenceArray: [], + preferenceKey: 0 + }; + + + /** + * Launches the browser with the specified url + * @param {String} url + * openURL() + * @return {Void} + */ + widget.openURL = function(url){ + if (url) { + window.open(url, "New Widget Window", 'height=200 width=250'); } - //delete from cookies } - value = "Nokia_WRT#"+this.path+"#"+key; - this.preferenceArray[this.preferenceKey] = value; + - createCookie(document,value,preference,240000); - this.preferenceKey++; - - //save cookie for cookies - updateMainCookie(document); -} - - + /** + * Returns previously stored preference associated with the specified key + * @param {String} Key preference value to be fetch + * preferenceForKey() + * @return {String} Value + */ + widget.preferenceForKey = function(key){ -/** - * Toggle between Tabbed navigation mode or Cursor mode - * @param {Boolean} Value - * setNavigationEnabled() - * @return {Void} - */ -Widget.prototype.setNavigationEnabled = function(bool) -{ - //This function can not be used on preview browser -} - - - -/** - * Open S0-Application identified by UID along with the specified params - * @param {Integer} Uid hexadecimal value to a specified application - * @param {String} Value - * openApplication() - * @return {Void} - */ -Widget.prototype.openApplication = function(Uid, param) -{ - alert("openApplication function won't be simulated in this application"); -} - - - -/** - * Prepares the Widget.to do transition to specified transitionState - * @param {String} Value Transition state - * prepareForTransition() - * @return {Void} - */ -Widget.prototype.prepareForTransition = function(transitionState) -{ - this.isFront = ("" + transitionState).toLowerCase() != "toback"; - window.document.getElementsByTagName("body")[0].style.opacity = "0.3"; -} - - + var name = key; //"Nokia_WRT#" + this.path + "#" + key; - -/** - * Does the animation to make the transition between the specified transitionState - * @param {Void} - * performTransition() - * @return {Void} - */ -Widget.prototype.performTransition = function() -{ - var _self = this; - this.opacity = 0; - this.interval = window.setInterval(function() { - _self.opacity += 0.2; - if (_self.opacity > 1) { - _self.opacity = 1; - } - window.document.getElementsByTagName("body")[0].style.opacity = _self.opacity + ""; - if (_self.opacity >= 1) { - window.clearInterval(_self.interval); - window.document.getElementsByTagName("body")[0].style.opacity = "1"; - } - //do nothing - }, 50); - //do nothing -} - - - - - -/** - * Set the preferred screen orientation to landscape. - * The display will flip if the phone display orientation - * is portrait and the phone supports landscape mode. - * @param {Void} - * setDisplayLandscape() - * @return {Void} - */ -Widget.prototype.setDisplayLandscape = function(){ - try - { - if (this.isrotationsupported && childToParent_Reference.Emulator.orientation_mode != 'landscape') - { - childToParent_Reference.Emulator.changeOrientation(childToParent_Reference.$('DisplayOrientation')); + var result = _BRIDGE_REF.helper.readCookie(name); + return result; + } + + + /** + * Stores the key associated with the specified preference + * @param {String} Preference value to be stored + * @param {String} Key Preference value associated to + * setPreferenceForKey() + * @return {Void} + */ + widget.setPreferenceForKey = function(preference, key){ + var value; + //Specifying null for the preference parameter removes the specified key from the preferences + if (key == null) { + if (this.preferenceKey > 0) { + this.preferenceKey--; + } + //delete from cookies } - } - catch (e) {} -} - - - + value = key;//"Nokia_WRT#" + this.path + "#" + key; + this.preferenceArray[this.preferenceKey] = value; + + _BRIDGE_REF.helper.createCookie(value, preference, 240000); + this.preferenceKey++; + + //save cookie for cookies + _BRIDGE_REF.helper.updateMainCookie(document); + } + + + + /** + * Toggle between Tabbed navigation mode or Cursor mode + * @param {Boolean} Value + * setNavigationEnabled() + * @return {Void} + */ + widget.setNavigationEnabled = function(bool){ + //This function can not be used on preview browser + } + + + + /** + * Open S0-Application identified by UID along with the specified params + * @param {Integer} Uid hexadecimal value to a specified application + * @param {String} Value + * openApplication() + * @return {Void} + */ + widget.openApplication = function(Uid, param){ + alert("openApplication function won't be simulated in this application"); + } + + + + /** + * Prepares the Widget.to do transition to specified transitionState + * @param {String} Value Transition state + * prepareForTransition() + * @return {Void} + */ + widget.prepareForTransition = function(transitionState){ + this.isFront = ("" + transitionState).toLowerCase() != "toback"; + window.document.getElementsByTagName("body")[0].style.opacity = "0.3"; + } + + + + + /** + * Does the animation to make the transition between the specified transitionState + * @param {Void} + * performTransition() + * @return {Void} + */ + widget.performTransition = function(){ + var _self = this; + this.opacity = 0; + this.interval = window.setInterval(function(){ + _self.opacity += 0.2; + if (_self.opacity > 1) { + _self.opacity = 1; + } + window.document.getElementsByTagName("body")[0].style.opacity = _self.opacity + ""; + if (_self.opacity >= 1) { + window.clearInterval(_self.interval); + window.document.getElementsByTagName("body")[0].style.opacity = "1"; + } + //do nothing + }, 50); + //do nothing + } + + + + + + /** + * Set the preferred screen orientation to landscape. + * The display will flip if the phone display orientation + * is portrait and the phone supports landscape mode. + * @param {Void} + * setDisplayLandscape() + * @return {Void} + */ + widget.setDisplayLandscape = function(){ + try { + if (this.isrotationsupported && _BRIDGE_REF.nokia.emulator.orientationSupports()) { + _BRIDGE_REF.nokia.emulator.setMode('landscape'); + } + } + catch (e) { + } + } + + + + + /** + * Set the preferred screen orientation to portrait. + * The display will flip if the phone display orientation + * is landscape and the phone supports portrait mode. + * @param {Void} + * setDisplayPortrait() + * @return {Void} + */ + widget.setDisplayPortrait = function(){ + try { + if (this.isrotationsupported && _BRIDGE_REF.nokia.emulator.orientationSupports()) { + _BRIDGE_REF.nokia.emulator.setMode('portrait'); + } + } + catch (e) { + } + } + + /** + * Allows the definition of a function to be called + * when a Widget.is displayed + * @param {Void} + * onshow() + * @return {Void} + */ + widget.onshow = function(){ + // to be implemented + } + + + + + /** + * Allows the definition of a function to be called + * when a Widget.sent into the background (hidden) + * @param {Void} + * onhide() + * @return {Void} + */ + widget.onhide = function(){ + // to be implemented + } + + + + /** + * This function returns the System API if sysinfo is included in document embed + */ + widget.enableSystemApi = function(){ + + // Identify, and Attach System-Info-Object properties + try { + var parentIframeRef = window.parent.frames[0]; + if (typeof parentIframeRef == 'object') { + if (parentIframeRef.document.embeds.length > 0) { + for (var i = 0; i < parentIframeRef.document.embeds.length; i++) { + //match the system Info API embed tag + if (parentIframeRef.document.embeds[i].type == 'application/x-systeminfo-widget') { + new systemAPI(parentIframeRef.document.embeds[i]); +// widget.sysInfo = parentIframeRef.document.embeds[i]; + + // hide the object + parentIframeRef.document.embeds[i].style.display='none'; + + // push the reference object into widget + widget.sysInfo.push(parentIframeRef.document.embeds[i]); + } + } + } + } + } + catch (e) { + alert('Error in attachSysInfo: ' + e); + } + } + + /** + * + */ + + widget.triggerListener = function(provider, eventType, data){ + if(widget.sysInfo.length){ + for(var i=0; i 0) { - for (var i = 0; i < parentIframeRef.document.embeds.length; i++) - { - //match the system Info API embed tag - if (parentIframeRef.document.embeds[i].type == 'application/x-systeminfo-widget') - { - new systemAPI(parentIframeRef.document.embeds[i]); - widget.sysAPI = parentIframeRef.document.embeds[i]; + case "chargelevel" : + widget.sysInfo[i].chargelevel = data; + if(typeof widget.sysInfo[i].onchargelevel != 'undefined'){ + // widget.sysInfo[i].onchargelevel(); + setTimeout(widget.sysInfo[i].onchargelevel, 0); + } + break; } } } } - } - catch (e) { - alert('Error in attachSysInfo: ' + e); - } - - // Attach menu object to window - window.menu = new Menu(); - - // Attach window reference to the Parent Window - window.parent.Emulator.parentToChild_Reference = window; - - // add event listener to window.focus - window.onfocus = function(){ menu.cancel(); } - - // add event listener to window.focus - window.onunload = function() - { - try - { - // Trigger Callback of Widget.onHide function - if(typeof(widget.onhide) == 'function') - { - widget.onhide(); - } - } - catch(e){ errorLog('widget.onhide: '+e.description, 0); } } - - - /* - * Used as a bridge between, Child widget & Parent window - */ - window.childToParent_Reference = window.parent; - -} - -/* - * support functions for widget object - */ - -/** - * This function stores cookie for all the cookies - * to help finding cookies of the same document while clearing preferences - * @param doucment -- Document object - */ -function updateMainCookie(doucment){ - var temp=""; - name = "Nokia_WRT#"+widget.path; - for (var k = 0; k