(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 === "page_0" || pageId === "page_unnamed") && !activePopup) { try { tizen.application.getCurrentApplication().exit(); } catch (ignore) { } } else { window.history.back(); } } }); }()); __page_count = 0; __unnamed_page = $('
') .addClass('ui-page') .prop('id', 'page_unnamed') .append($('').addClass('ui-header').text("Main")) .append($('').addClass('ui-content').prop('id', 'frame_unnamed')); function parseSitemap(sitemap, status) { parseWidgets(sitemap.homepage.widgets, __unnamed_page); if (__page_count === 0) { __unnamed_page.addClass('ui-page-active'); } $("body").append(__unnamed_page); var elPageIndicator = document.getElementById("pageIndicator"), pageIndicator = tau.widget.PageIndicator(elPageIndicator, {numberOfPages: __page_count+1}), index = 0; pageIndicator.setActive(0); } function createFrame(wdg, sitemap) { var newframe = $('') .addClass('ui-content') .prop('id', 'frame_' + __page_count.toString()); var newpage = $('') .addClass('ui-page') .prop('id', 'page_' + __page_count.toString()) .append($('').addClass('ui-header').text(wdg.label)) .append(newframe); if (__page_count === 0) { newpage.addClass('ui-page-active'); } __page_count += 1; $("body").append(newpage); return newframe; } function createSwitch(wdg, page) { } function createSelection(wdg, page) { } function createSlider(wdg, page) { var value = 0; if (wdg.item.state !== null) { value = wdg.item.state; } page.append($('') .append($('').text(wdg.label)) .append($('') .prop('data-link', wdg.item.link) .prop('data-item', wdg.item.name) .prop('type','range') .prop('data-freq','200') .prop('data-state',value) .prop('min','0') .prop('max','100') .prop('value',value) .change(function(){ updateItem($(this).prop('data-link'),$(this).val()); })) ); } function createText(wdg, page) { page.append($('').text(wdg.label)); } function parseWidgets(widgets, parent) { widgets.forEach(function (wdg) { switch (wdg.type) { case "Frame": var newframe = createFrame(wdg, null); if (("widgets" in wdg) && wdg.widgets.length > 0) { parseWidgets(wdg.widgets, newframe); } break; case "Switch": // if (wdg.mappings.length === 0) { // s += createElement( // wdg.label, // wdg.item.name, // wdg.item.link, // '