diff --git a/procentric/application/lib/hoteltv.api.js b/procentric/application/lib/hoteltv.api.js index 2032d5b..e327f98 100755 --- a/procentric/application/lib/hoteltv.api.js +++ b/procentric/application/lib/hoteltv.api.js @@ -87,6 +87,7 @@ HotelTV.api = (function() { "get_site_info": __apifxn_get_base_url() + "/api/" + _api_ver + "/assets/" + _dev_familly + "/" + _serial_num + "/info", "get_guest_info": __apifxn_get_base_url() + "/api/" + _api_ver + "/assets/" + _dev_familly + "/" + _serial_num + "/guest", "get_opening_ctz": __apifxn_get_base_url() + "/api/" + _api_ver + "/assets/" + _dev_familly + "/" + _serial_num + "/opening", + "get_widget_ctz": __apifxn_get_base_url() + "/api/" + _api_ver + "/assets/" + _dev_familly + "/" + _serial_num + "/widget", "get_program_ctz": __apifxn_get_base_url() + "/api/" + _api_ver + "/assets/" + _dev_familly + "/" + _serial_num + "/program", "get_epg_info": __apifxn_get_base_url() + "/api/" + _api_ver + "/assets/" + _dev_familly + "/" + _serial_num + "/epg", "get_weather": __apifxn_get_base_url() + "/api/" + _api_ver + "/assets/" + _dev_familly + "/" + _serial_num + "/weather", @@ -354,6 +355,19 @@ HotelTV.api = (function() { }); }, + GetWidgetCtz: function() { + return new Promise((resolve, reject) => { + let sz_api_url = __apifxn_get_api_url("get_widget_ctz"); + __apifxn_CallCmsApi("GET", sz_api_url, "GetWidgetCtz", null).then(_result => { + //console.log(`Success::>${_result.data}`); + resolve(JSON.parse(_result.data)); + }).catch(_error => { + console.error(`Failure::>${_error.reason}`); + reject(_error.reason); + }); + }); + }, + GetProgramCtz: function() { return new Promise((resolve, reject) => { let sz_api_url = __apifxn_get_api_url("get_program_ctz"); diff --git a/procentric/application/lib/hoteltv.js b/procentric/application/lib/hoteltv.js index bc43bab..bbf4628 100755 --- a/procentric/application/lib/hoteltv.js +++ b/procentric/application/lib/hoteltv.js @@ -23,6 +23,7 @@ var HotelTV = HotelTV || { 'weather': {}, 'epg': {}, 'news': {}, + 'widget': {}, 'tvguide': {}, 'message': {}, 'translation': {}, @@ -56,7 +57,8 @@ var HotelTV = HotelTV || { }, 'schedule': { 'flight_reflash': false, - 'weather_reflash': false + 'weather_reflash': false, + 'widget_reflash': false }, 'token': null }, @@ -369,6 +371,29 @@ HotelTV.Init = async function() { console.error("Display Error page for get flight info"); } + try { + HotelTV.widget = await HotelTV.api.GetWidgetCtz(); + } catch (_error) { + //console.log("Display Error page for get widget info"); + HotelTV.ui_utils.ShowErrMsg(true, + "system.error.get-widget", + "SYSTEM ERROR", + "Fail to get tv widget contents information.\r\nplease contact your system administrator.", { + "timeout": _tmval, + "cb_disp": function() { + _tmval -= 1; + //console.log("time..." + _tmval); + if ($('.error #countdown').css("display") == "none") { + $('.error #countdown').fadeIn(1000); + } + $('.error #countdown #message').text(`The Device ID is ${HotelTV.devinfo.serial_number}.\r\n\r\nSystem will be reboot in ${_tmval} second...`); + }, + "cb_eoe": function() { + setTimeout(HotelTV.hcap.Reboot(), 500); + } + }); + } + try { HotelTV.tvguide = await HotelTV.api.GetProgramCtz(); } catch (_error) { @@ -421,6 +446,7 @@ HotelTV.Init = async function() { sessionStorage.setItem("opening", JSON.stringify(HotelTV.opening)); sessionStorage.setItem("flight", JSON.stringify(HotelTV.flight)); sessionStorage.setItem("weather", JSON.stringify(HotelTV.weather)); + sessionStorage.setItem("widget", JSON.stringify(HotelTV.widget)); sessionStorage.setItem("tvguide", JSON.stringify(HotelTV.tvguide)); sessionStorage.setItem("news", JSON.stringify(HotelTV.news)); sessionStorage.setItem("message", JSON.stringify(HotelTV.message)); @@ -457,6 +483,7 @@ HotelTV.LoadWelCome = async function() { HotelTV.guestinfo = await JSON.parse(sessionStorage.getItem("guestinfo")); HotelTV.hotelinfo = await JSON.parse(sessionStorage.getItem("hotelinfo")); HotelTV.opening = await JSON.parse(sessionStorage.getItem("opening")); + HotelTV.widget = await JSON.parse(sessionStorage.getItem("widget")); HotelTV.tvguide = await JSON.parse(sessionStorage.getItem("tvguide")); try { HotelTV.services = await HotelTV.api.GetServiceInfo(); @@ -592,6 +619,7 @@ HotelTV.LoadAppFull = async function() { HotelTV.hotelinfo = await JSON.parse(sessionStorage.getItem("hotelinfo")); HotelTV.weather = await JSON.parse(sessionStorage.getItem("weather")); HotelTV.opening = await JSON.parse(sessionStorage.getItem("opening")); + HotelTV.widget = await JSON.parse(sessionStorage.getItem("widget")); HotelTV.tvguide = await JSON.parse(sessionStorage.getItem("tvguide")); HotelTV.flight = await JSON.parse(sessionStorage.getItem("flight")); HotelTV.news = await JSON.parse(sessionStorage.getItem("news")); @@ -712,7 +740,11 @@ HotelTV.LoadAppFull = async function() { } } else if (recvMsg.event == "update_weather") { if (recvMsg.ret === "OK") { - HotelTV.weather =recvMsg.data; + HotelTV.weather = recvMsg.data; + } + } else if (recvMsg.event == "update_wiget") { + if (recvMsg.ret === "OK") { + HotelTV.widget = recvMsg.data; } } else if (recvMsg.event == "update_report") { HotelTV.hcap.GetUptime(); diff --git a/procentric/application/lib/hoteltv.service.js b/procentric/application/lib/hoteltv.service.js index 4608d14..9b0b026 100755 --- a/procentric/application/lib/hoteltv.service.js +++ b/procentric/application/lib/hoteltv.service.js @@ -19,6 +19,7 @@ var g_tm_prev = { "news": null, "epg": null, "weather": null, + "widget": null, "flight": null, "report": null, }; @@ -42,6 +43,7 @@ function __svcfxn_get_api_url(api_type) { "get_news": __svcfxn_get_base_url() + "/api/" + g_config.token.version + "/assets/" + g_config.dev_family + "/" + g_config.dev_snum + "/news", "get_epg": __svcfxn_get_base_url() + "/api/" + g_config.token.version + "/assets/" + g_config.dev_family + "/" + g_config.dev_snum + "/epg", "get_weather": __svcfxn_get_base_url() + "/api/" + g_config.token.version + "/assets/" + g_config.dev_family + "/" + g_config.dev_snum + "/weather", + "get_widget": __svcfxn_get_base_url() + "/api/" + g_config.token.version + "/assets/" + g_config.dev_family + "/" + g_config.dev_snum + "/widget", "get_flight": __svcfxn_get_base_url() + "/api/" + g_config.token.version + "/assets/" + g_config.dev_family + "/" + g_config.dev_snum + "/flight", } @@ -126,6 +128,7 @@ async function sworker_service(args) { "news": false, "flight": false, "weather": false, + "widget": false, "report": false, }; let _tm_cur = new Date(); @@ -206,13 +209,25 @@ async function sworker_service(args) { let _tm_diff_s = Math.floor(_tm_diff_ms / 1000); //WEATHER정보는 매 2시간 마다 한번씩 업데이트 - if (_tm_diff_s > 7200) { + //if (_tm_diff_s > 7200) { + if (_tm_diff_s > 60) { g_tm_prev.weather = _tm_cur; _bNeed_Update.weather = true; } } + // CHECK WIDGET INFORMATION UPDATE + if (g_tm_prev.widget != null) { + let _tm_diff_ms = _tm_cur.getTime() - g_tm_prev.weather.getTime(); + let _tm_diff_s = Math.floor(_tm_diff_ms / 1000); + //WEATHER정보는 매 1시간 마다 한번씩 업데이트 + //if (_tm_diff_s > 3600) { + if (_tm_diff_s > 60) { + g_tm_prev.widget = _tm_cur; + _bNeed_Update.widget = true; + } + } @@ -245,14 +260,23 @@ async function sworker_service(args) { } if (_bNeed_Update.weather == true) { - let sz_api_url = __svcfxn_get_api_url("get_flight"); - __svcfxn_CallCmsApi(sz_api_url, "GetFlight", null).then(_result => { + let sz_api_url = __svcfxn_get_api_url("get_weather"); + __svcfxn_CallCmsApi(sz_api_url, "GetWeather", null).then(_result => { g_port.postMessage({ "event": "update_weather", "ret": "OK", "data": JSON.parse(_result.data) }); }).catch(_error => { g_port.postMessage({ "event": "update_weather", "ret": "ERROR", "data": null }); }); } + if (_bNeed_Update.widget == true) { + let sz_api_url = __svcfxn_get_api_url("get_widget"); + __svcfxn_CallCmsApi(sz_api_url, "GetWidget", null).then(_result => { + g_port.postMessage({ "event": "update_widget", "ret": "OK", "data": JSON.parse(_result.data) }); + }).catch(_error => { + g_port.postMessage({ "event": "update_widget", "ret": "ERROR", "data": null }); + }); + } + if (_bNeed_Update.report == true) { g_port.postMessage({ "event": "update_report", "ret": "OK", "data": _bNeed_Update.report }); } diff --git a/procentric/application/lib/hoteltv.ui_appfull.js b/procentric/application/lib/hoteltv.ui_appfull.js index 3c3d516..0303ec8 100755 --- a/procentric/application/lib/hoteltv.ui_appfull.js +++ b/procentric/application/lib/hoteltv.ui_appfull.js @@ -2585,7 +2585,7 @@ HotelTV.ui_appfull = (function() { break; case 'accmodation_bed_type': __info_item.innerHTML = `${_trTbl.ui.mypage.accmodation.title.bed_type[_state.lang]}`; - __info_item.innerHTML += `${_guest.roomtype}`; + __info_item.innerHTML += `${_guest.roomtype[_state.lang]}`; break; case 'accmodation_room_num': __info_item.innerHTML = `${_trTbl.ui.mypage.accmodation.title.room_num[_state.lang]}`; @@ -2597,7 +2597,7 @@ HotelTV.ui_appfull = (function() { break; case 'accmodation_checkout': __info_item.innerHTML = `${_trTbl.ui.mypage.accmodation.title.checkout[_state.lang]}`; - __info_item.innerHTML += `${_guest.checkOu}`; + __info_item.innerHTML += `${_guest.checkOut}`; break; } _accomo_info.appendChild(__info_item); @@ -3233,7 +3233,6 @@ HotelTV.ui_appfull = (function() { $('.main .sub').fadeOut(600); //$('#lst_ctzgenbg').trigger('translate.owl.carousel', [0]); $('#lst_ctzgenbg').trigger('translate.owl.carousel', [0, 500, true]); - _state.menu.stage.cur = "ctzgen"; }); }); }); @@ -3298,6 +3297,12 @@ HotelTV.ui_appfull = (function() { console.log("CTZ(GEN) IDX::>" + _state.menu.main[_mmIdx][_smIdx].cur); HotelTV.api.ReportEvent([{'power': true, 'location':{'conId':_ctzinfo[_state.menu.main[_mmIdx][_smIdx].cur].id}}]) + + if ( _state.menu.stage.cur=="preparing_ctz_general" ){ + setTimeout(function() { + _state.menu.stage.cur = "ctzgen"; + }, 2000); + } }); $('#lst_ctzgenbg').on('translate.owl.carousel', function(event) { @@ -3358,7 +3363,10 @@ HotelTV.ui_appfull = (function() { // Append Sub elements::title let _sm_item_title = document.createElement('div'); _sm_item_title.setAttribute("id", "sm_item_title"); - _sm_item_title.textContent = _sminfo[_idx].title[_state.lang]; + + if (_sminfo[_idx].showTitle && _sminfo[_idx].showTitle == true) { + _sm_item_title.textContent = _sminfo[_idx].title[_state.lang]; + } // Append Sub elements::icon let _sm_item_icon = document.createElement('div'); @@ -3493,6 +3501,7 @@ HotelTV.ui_appfull = (function() { } else if (_program[_mmIdx].style.toLowerCase() == "content") { console.log("Invalid options"); } else if (_program[_mmIdx].style.toLowerCase() == "submenu") { + console.log('DDDBUG::> Go to CTZ>'); __uifxn_AppFull_BldPage_CtzGeneral(); } } @@ -3542,23 +3551,27 @@ HotelTV.ui_appfull = (function() { } else if (event.keyCode == gRmtKey.right) { $('#lst_ctzgenbg').trigger('next.owl', 700); } else if (event.keyCode == gRmtKey.back) { - $('.main .sub').show(); - $('.main').animate({ top: -1080, left: 0 }, 1000, () => { - $('.main .ctzgen').hide(); - _state.media.playing = false; - HotelTV.hcap.MediaStop(null, null); + _state.menu.stage.cur = "preparing_sub"; + $('.main .sub').show(0, function(){ + $('.main').animate({ top: -1080, left: 0 }, 1000, () => { + $('.main .ctzgen').hide(); + _state.media.playing = false; + HotelTV.hcap.MediaStop(null, null); - $('#lst_ctzgenbg').off('refresh.owl.carousel'); - $('#lst_ctzgenbg').off('change.owl.carousel'); - $('#lst_ctzgenbg').off('changed.owl.carousel'); - $('#lst_ctzgenbg').off('translate.owl.carousel'); - $('#lst_ctzgenbg').owlCarousel('destroy'); - $('.main .ctzgen .bg #lst_ctzgenbg div').remove(); - _hndl_ctzGenBg = null; - _state.menu.stage.cur = "sub"; - $('#lst_smsel').trigger('translate.owl.carousel', [0]); + $('#lst_ctzgenbg').off('refresh.owl.carousel'); + $('#lst_ctzgenbg').off('change.owl.carousel'); + $('#lst_ctzgenbg').off('changed.owl.carousel'); + $('#lst_ctzgenbg').off('translate.owl.carousel'); + $('#lst_ctzgenbg').owlCarousel('destroy'); + $('.main .ctzgen .bg #lst_ctzgenbg div').remove(); + _hndl_ctzGenBg = null; + $('#lst_smsel').trigger('translate.owl.carousel', [0]); + _state.menu.stage.cur = "sub"; + console.log('DDDBUG::> Return to SUB>'); + }); }); - } else if (event.keyCode == gRmtKey.start) { + + } else if (event.keyCode == gRmtKey.play) { if ($('.main .ctzgen .bg .owl-carousel .owl-item.active .ctz_mv_ctrl').length == 1) { let uri_video = $($('.main .ctzgen .bg .owl-carousel .owl-item.active .ctz_mv_ctrl')[0]).attr('video_url'); if (uri_video != null) { @@ -4187,6 +4200,16 @@ HotelTV.ui_appfull = (function() { //Shows Up Flight Contents if (_program[(_evt.page.index + 1)].type == "flight") { + $('.main .mm .flight').each(function (index, docObjFlight) { + //console.log(index); + if ( $(docObjFlight).css("display")!="none" ){ + if ( $(docObjFlight).find('#record').length>0 ){ + $(docObjFlight).find('#record').scrollTop(0); + } + $(docObjFlight).fadeOut(300); + } + }); + if ($(`.main .mm #flight_${_program[(_evt.page.index + 1)].location}`).css("display") == "none") { $(`.main .mm #flight_${_program[(_evt.page.index + 1)].location}`).fadeIn(1000, () => { $(document.activeElement).keydown(function(_evt) { @@ -4234,10 +4257,10 @@ HotelTV.ui_appfull = (function() { */ function __uifxn_AppFull_TopWidjet_BuildWeather() { const _state = HotelTV.state; - let _weather = HotelTV.weather[_state.weather.default_location]; + let _widget_weather = HotelTV.widget.weather; - $('.widjet .top .weather #icon').css({ "background-image": "url(" + _weather.smallicon_image[_weather.item.condition.code] + ")" }); - $('.widjet .top .weather #temp').text(_weather.item.condition.temp + "°C"); + $('.widjet .top .weather #icon').css({ "background-image": "url(" + _widget_weather.smallicon_image[_widget_weather.item.condition.code] + ")" }); + $('.widjet .top .weather #temp').text(_widget_weather.item.condition.temp + "°C"); $('.widjet .top .weather').show(); } @@ -4599,10 +4622,10 @@ HotelTV.ui_appfull = (function() { // Append Sub elements::title let _mm_item_title = document.createElement('div'); _mm_item_title.setAttribute("id", "mm_item_title"); - if (_program[_mm_idx].title_show && _program[_mm_idx].title_show == true) { + if (_program[_mm_idx].showTitle && _program[_mm_idx].showTitle == true) { _mm_item_title.textContent = _program[_mm_idx].title[_state.lang]; } else { - _mm_item_title.textContent = _program[_mm_idx].title[_state.lang]; + _mm_item_title.textContent = ""; } // Append Sub elements::icon @@ -4692,10 +4715,12 @@ HotelTV.ui_appfull = (function() { //Weather Contents Buildup if ( Object.keys(_state.weather.default_location).length != 0 ){ - //상단 날씨 아이콘 및 온도 표시 - __uifxn_AppFull_TopWidjet_BuildWeather(); __uifxn_AppFull_MM_BldWeather(); } + + //Buildup Widget: Weather + __uifxn_AppFull_TopWidjet_BuildWeather(); + //Build Flight __uifxn_AppFull_MM_BldFlight(); @@ -5171,6 +5196,8 @@ HotelTV.ui_appfull = (function() { _state.schedule.flight_reflash = true; }else if ( _evt == "update_weather" ){ _state.schedule.weather_reflash = true; + }else if ( _evt == "update_widget" ){ + _state.schedule.widget_reflash = true; } // Update flight schedule table if user doesn't watch flight schedule screen @@ -5193,12 +5220,23 @@ HotelTV.ui_appfull = (function() { //Weather Contents Buildup if ( Object.keys(_state.weather.default_location).length != 0 ){ - //상단 날씨 아이콘 및 온도 표시 - __uifxn_AppFull_TopWidjet_BuildWeather(); + //날씨 콘텐트 업데이트 __uifxn_AppFull_MM_BldWeather(); } } } + + // Update weather schedule table if user doesn't watch weather screen + if ( _state.schedule.widget_reflash == true) { + _state.schedule.widget_reflash = false; + console.log("Updated Widget UI"); + + //Widget:Weather Contents Buildup + if ( Object.keys(_state.weather.default_location).length != 0 ){ + //상단 날씨 아이콘 및 온도 표시 + __uifxn_AppFull_TopWidjet_BuildWeather(); + } + } }, MqttEvent: function(_evt) { @@ -5392,4 +5430,4 @@ HotelTV.ui_appfull = (function() { SpatialNavigation.clear(); }, } -})(); \ No newline at end of file +})();