(function() { window.addEventListener("tizenhwkey", function(ev) { var activePopup = null, page = null, pageId = ""; if (ev.keyName === "back") { activePopup = document.querySelector(".ui-popup-active"); page = document.getElementsByClassName("ui-page-active")[0]; pageId = page ? page.id : ""; if (pageId === "main" && !activePopup) { try { tizen.application.getCurrentApplication().exit(); } catch (ignore) { } } else { window.history.back(); } } }); }()); function parseSitemap(sitemap) { var output = parseWidgets(sitemap.homepage.widgets); document.getElementById("main_text").innerHTML = output; } function parseWidgets(widgets) { var s=""; widgets.forEach( function(wdg) { switch (wdg.type) { case "Frame": s+="
"+wdg.label+"
";
if (("widgets" in wdg) && wdg.widgets.length >0){
s+=parseWidgets(wdg.widgets);
}
s+="