Files
ct-dtv-hx0100-002kwos/procentric/application/lib/hoteltv.ui_appfull.js

4252 lines
217 KiB
JavaScript
Executable File

/**
* Copyright (c) 2020
*
* CENTIRM HotelTV UI-WELCOME module javascript.
*
* @summary short description for the file
* @author Joel <joel.kim@centirm.com>
*
* Created at : 2020-11-26 02:21:56
* Last modified : 2020-11-26 15:31:40
*/
HotelTV.namespace('HotelTV.ui_appfull');
HotelTV.ui_appfull = (function() {
//// 의존 관계 선언
var _hndl_mmSel = null;
var _hndl_mmBg = null;
var _hndl_smSel = null;
var _hndl_smBg = null;
var _hndl_mpSel = null;
var _hndl_mpBg = null;
var _hndl_ctzGenBg = null;
var _hndl_brochureBg = null;
var _hndl_widget_topTime = null;
var _hndl_tmrTvChnMngr = null;
var _hndl_tmrUgMngr = null;
var _hndl_tmrCtzThumbAni = null;
const _lastTm = {
'tvchannel_changed': null,
'keyevt': null,
};
//// 비공개 프로퍼티
/**
* HotelTV UI[AppFull] Wrapper Function::> Keydown event time recorder
* @param {dictionary} _evt event information
*/
function __uifxn_AppFull_OnKeyDnEvtRec(_evt) {
let _tm_diff_ms = 0;
_lastTm.keyevt = new Date();
}
/**
* HotelTV UI Wrapper Function::> received event handling function
* @param {dictionary} _evt event information
*/
function __uifxn_AppFull_OnMediaEvt(_evt) {
let _state = HotelTV.state;
console.log("media_event_received = " + _evt.eventType);
let _stateMedia = _evt.eventType;
if (_state.menu.stage == "ctzgen") {
switch (_stateMedia) {
case 'play_start':
_state.media.playing = true;
$('.main .ctzgen .bg .owl-carousel .owl-stage-outer .owl-stage .owl-item').removeClass('movieplay');
$('.main .ctzgen .bg .owl-carousel .owl-stage-outer .owl-stage .owl-item.active').addClass('movieplay');
$('.owl-theme .owl-nav.disabled+.owl-dots').fadeOut(500);
HotelTV.hcap.VideoWinSize(null);
break;
case 'play_end':
_state.media.playing = false;
HotelTV.hcap.MediaStop(
function() {
$('.main .ctzgen .bg .owl-carousel .owl-stage-outer .owl-stage .owl-item').removeClass('movieplay');
$('.owl-theme .owl-nav.disabled+.owl-dots').fadeIn(500);
},
function() {
$('.main .ctzgen .bg .owl-carousel .owl-stage-outer .owl-stage .owl-item').removeClass('movieplay');
$('.owl-theme .owl-nav.disabled+.owl-dots').fadeIn(500);
});
break;
case 'error_in_playing':
break;
case 'buffer_full':
break;
case 'file_not_found':
break;
case 'network_disconnected':
break;
case 'network_busy':
break;
case 'seek_done':
break;
}
}
}
/**
* HotelTV UI Wrapper Function::> received event handling function
* @param {dictionary} _evt event information
*/
function __uifxn_AppFull_OnNetEvt(_evt) {
let _state = HotelTV.state;
console.log("network_event_received = " + _evt.eventType);
let _typeNetEvt = _evt.eventType;
switch (_typeNetEvt) {
case 'play_start':
break;
case 'play_end':
break;
case 'error_in_playing':
break;
case 'buffer_full':
break;
case 'file_not_found':
break;
case 'network_disconnected':
break;
case 'network_busy':
break;
case 'seek_done':
break;
}
}
/**
* HotelTV UI Wrapper Function::> received event handling function
* @param {dictionary} _evt event information
*/
function __uifxn_AppFull_OnAppFocusEvt(_evt) {
let _state = HotelTV.state;
console.log("hcap_application_focus_changed = " + _evt.eventType);
let _typeAppFocusEvt = _evt.eventType;
if (_typeAppFocusEvt == "focused") {
// HotelTV.hcap.SetSoftAp({
// "enable": false,
// });
}
}
/**
* HotelTV UI Wrapper Function::> received event handling function
* @param {dictionary} _evt event information
*/
function __uifxn_AppFull_OnHdmiConChangeEvt(_evt) {
let _state = HotelTV.state;
// {Number} param.index - index of the HDMI which was connected or disconnected.
// {Boolean} param.connected - true if the HDMI is connected, else false.
console.log(
"Event 'hdmi_connection_changed' is received.\n" +
"HDMI-" + param.index + " : " + "connected = " + param.connected
);
}
/**
* HotelTV UI[AppFull] Wrapper Function::> show/hide special hotkey(red/yellow/green/blue/etc...) btn
* @param {boolean} e event
*/
function __uifxn_AppFull_ShowMMHotKeyBtn(_show) {
let _state = HotelTV.state;
let _opening = HotelTV.opening;
let _brochure = _opening.brochures;
// Draw Amenity & Room Service
if (_opening.amenity) {
let _amenityCtz = _opening.amenity;
// TITLE
$(`.control .mm .hotkey_${_amenityCtz.button}`).text(_amenityCtz.title[_state.lang]);
// HOTKEY 버튼 Show/Hide
$(`.control .mm .hotkey_${_amenityCtz.button}`).css({ "background-image": "url(" + _amenityCtz.buttonImage.file.download + ")" });
$(`.control .mm .hotkey_${_amenityCtz.button}`).css({ "top": _amenityCtz.positionY + "%" });
$(`.control .mm .hotkey_${_amenityCtz.button}`).css({ "left": _amenityCtz.positionX + "%" });
if (_show == true) {
if ($(`.control .mm .hotkey_${_amenityCtz.button}`).css("display") == "none") {
$(`.control .mm .hotkey_${_amenityCtz.button}`).fadeIn(300);
}
} else {
if ($(`.control .mm .hotkey_${_amenityCtz.button}`).css("display") != "none") {
$(`.control .mm .hotkey_${_amenityCtz.button}`).fadeOut(300);
}
}
}
if (_opening.roomService) {
let _roomserviceCtz = _opening.roomService;
// TITLE
$(`.control .mm .hotkey_${_roomserviceCtz.button}`).text(_roomserviceCtz.title[_state.lang]);
// HOTKEY 버튼 Show/Hide
$(`.control .mm .hotkey_${_roomserviceCtz.button}`).css({ "background-image": "url(" + _roomserviceCtz.buttonImage.file.download + ")" });
$(`.control .mm .hotkey_${_roomserviceCtz.button}`).css({ "top": _roomserviceCtz.positionY + "%" });
$(`.control .mm .hotkey_${_roomserviceCtz.button}`).css({ "left": _roomserviceCtz.positionX + "%" });
if (_show == true) {
if ($(`.control .mm .hotkey_${_roomserviceCtz.button}`).css("display") == "none") {
$(`.control .mm .hotkey_${_roomserviceCtz.button}`).fadeIn(300);
}
} else {
if ($(`.control .mm .hotkey_${_roomserviceCtz.button}`).css("display") != "none") {
$(`.control .mm .hotkey_${_roomserviceCtz.button}`).fadeOut(300);
}
}
}
// Draw Brochure contents
for (let _idx = 1; _idx <= _brochure.length; _idx++) {
let _brcCtz = _brochure[_idx];
// TITLE
$(`.control .mm .hotkey_${_brcCtz.button}`).text(_brcCtz.title[_state.lang]);
// HOTKEY 버튼 Show/Hide
$(`.control .mm .hotkey_${_brcCtz.button}`).css({ "background-image": "url(" + _brcCtz.buttonImage.file.download + ")" });
$(`.control .mm .hotkey_${_brcCtz.button}`).css({ "top": _brcCtz.positionY + "%" });
$(`.control .mm .hotkey_${_brcCtz.button}`).css({ "left": _brcCtz.positionX + "%" });
if (_show == true) {
if ($(`.control .mm .hotkey_${_brcCtz.button}`).css("display") == "none") {
$(`.control .mm .hotkey_${_brcCtz.button}`).fadeIn(300);
}
} else {
if ($(`.control .mm .hotkey_${_brcCtz.button}`).css("display") != "none") {
$(`.control .mm .hotkey_${_brcCtz.button}`).fadeOut(300);
}
}
}
}
/**
* HotelTV UI[AppFull] Wrapper Function::> build Brochure and In-room dining
* @param {boolean} e event
*/
function __uifxn_AppFull_BuildBrochure() {
let _state = HotelTV.state;
let _brochure = HotelTV.opening.brochures;
for (let _idx = 1; _idx <= _brochure.length; _idx++) {
let _brcCtz = _brochure[_idx];
// BROCHURE 이미지 노드를 동적으로 구성
let _div_popup_mm_red_bglist = document.querySelector(`#lst_hotkey_mm_${_brcCtz.button}`);
for (let _page_idx = 1; _page_idx <= _brcCtz.page[_state.lang].length; _page_idx++) {
let _div_popup_mm_red_item = document.createElement('div');
let _sz_styleOpt = null;
_div_popup_mm_red_item.className = 'item';
_div_popup_mm_red_item.setAttribute(`popup_hotkey_mm_${_brcCtz.button}`, _page_idx);
_sz_styleOpt = "background-image: url(" + _brcCtz.page[_state.lang][_page_idx].download + "); ";
_sz_styleOpt += "background-repeat: no-repeat; background-position: center center; background-size: 100% 100%; ";
_div_popup_mm_red_item.setAttribute("style", _sz_styleOpt);
_div_popup_mm_red_bglist.appendChild(_div_popup_mm_red_item);
}
_hndl_brochureBg = $(`#lst_hotkey_mm_${_brcCtz.button}`);
_hndl_brochureBg.owlCarousel({
center: false,
items: 1, //Number of Items on Screen what you want
nav: true,
loop: false,
margin: 0,
smartSpeed: 1000,
lazyLoad: true,
mouseDrag: false,
touchDrag: false,
pullDrag: false,
freeDrag: false,
navText: ["<div class='nav-btn prev-slide'></div>", "<div class='nav-btn next-slide'></div>"],
startPosition: 0,
});
// HOTKEY정보를 state에 기록
if (!(_brcCtz.button in _state.hotkey.mm)) {
_state.hotkey.mm[_brcCtz.button] = { 'type': "brochure" };
}
}
}
/**
* HotelTV UI[AppFull] Wrapper Function::> update amenity item
* @param {boolean} e event
*/
async function __uifxn_AppFull_DrawAmenityItem() {
let _state = HotelTV.state;
let _amenity = HotelTV.opening.amenity;
let _carts = null;
let _elAmItemsRoot = $(`.popup .amenity>.items`);
const __fxn_fmexist = function(_object, _itemID) {
for (__j = 1; __j <= _object.length; __j++) {
if (_object[__j].itemId == _itemID) {
return true;
}
}
return false;
}
const __fxn_fmvalue = function(_object, _key, _itemID) {
for (__j = 1; __j <= _object.length; __j++) {
if (_object[__j].itemId == _itemID) {
return _object[__j][_key];
}
}
}
try {
HotelTV.carts.amenity = _carts = await HotelTV.api.GetAmenityCarts();
for (let _idx = 1; _idx <= _amenity.children.length; _idx++) {
let _amItem = _amenity.children[_idx];
let _elAmItemTblRecRoot = _elAmItemsRoot.children('table').children(`tr#${_amItem.id}`).children('div.products');
if (_carts.items.length && __fxn_fmexist(_carts.items, _amItem.id) == true) {
// Free count value
_elAmItemTblRecRoot.children('div#details').children(`div#freecnt_val`).text(__fxn_fmvalue(_carts.items, "freeCount", _amItem.id));
// Price value
_elAmItemTblRecRoot.children('div#details').children(`div#price_val`).text(__fxn_fmvalue(_carts.items, "price", _amItem.id)[_state.lang].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + _amenity.currency[_state.lang]);
// Order Count
_elAmItemTblRecRoot.children(`div#quantity_val`).text(__fxn_fmvalue(_carts.items, "quantity", _amItem.id));
}
}
} catch (_error) {
console.log(`Fail to call API::> ${_error}`);
}
}
/**
* HotelTV UI[AppFull] Wrapper Function::> build amenity
* @param {boolean} e event
*/
async function __uifxn_AppFull_BuildAmenityOrderDetails() {
let _state = HotelTV.state;
let _trTbl = HotelTV.translation;
let _opening = HotelTV.opening;
let _elAmODRoot = $(`.popup .amenity>.order-details`);
let _amenity = null;
const __fxn_fmvalue = function(_object, _key, _itemID) {
for (__j = 1; __j <= _object.length; __j++) {
if (_object[__j].id == _itemID) {
return _object[__j][_key];
}
}
}
if (!_opening.amenity) {
return;
}
_amenity = _opening.amenity;
try {
HotelTV.orders.amenity = _order = await HotelTV.api.GetAmenityOrders(null);
} catch (_error) {
console.log(`Fail to call API::> ${_error}`);
return;
}
_elAmODRoot.children('.title').text(_trTbl.ui.amenity.title.carts[_state.lang]);
_elAmODRoot.children('.usage').text(_trTbl.ui.amenity.usage.details[_state.lang]);
//Draw Amenity Order Items
try {
let _elAmDOdItemsRoot = _elAmODRoot.children(`.items`);
// Delete elements under amenity item table
if (_elAmDOdItemsRoot.children('table').children('tr').length) {
_elAmDOdItemsRoot.children('table').children('tr').remove();
}
let _eltbl_am_items = _elAmDOdItemsRoot.children('table#item_list');
for (let _odix = 1; _odix <= _order.orders.length; _odix++) {
let _amOrds = _order.orders[_odix];
for (let _idx = 1; _idx <= _amOrds.items.length; _idx++) {
let _amOrdItem = _amOrds.items[_idx];
var _eltr_item = document.createElement('tr');
_eltr_item.setAttribute("id", `${_odix}-${_idx}`);
_eltr_item.setAttribute("ctz_idx", (_odix - 1) * _order.orders.length + _idx);
//어메니티 아이탬 화면 드로잉
var _eldiv_item_ctz = document.createElement('div');
_eldiv_item_ctz.setAttribute("class", "products");
// Append Sub elements::title
let _elDiv_odNum = document.createElement('div');
_elDiv_odNum.setAttribute("id", "order_num");
_elDiv_odNum.textContent = `${_trTbl.ui.amenity.title.ordernum[_state.lang]} ${_amOrds.id}`;
_eldiv_item_ctz.appendChild(_elDiv_odNum);
// Append Sub elements::thumbnail iamge
let _elDiv_thumb = document.createElement('div');
_elDiv_thumb.setAttribute("id", "thumb");
let _sz_styleOpt = "background-image: url(" + __fxn_fmvalue(_amenity.children, "thumbnail", _amOrdItem.itemId).file.download + "); ";
_sz_styleOpt += "background-repeat: no-repeat; background-position: center center; background-size: contain ";
_elDiv_thumb.setAttribute("style", _sz_styleOpt);
_eldiv_item_ctz.appendChild(_elDiv_thumb);
// Append Sub elements::quantity and amount summary
let _elDiv_summary = document.createElement('div');
_elDiv_summary.setAttribute("id", "summary");
// Append Sub elements::free count Order quantity_title
let _elDiv_quantityTitle = document.createElement('div');
_elDiv_quantityTitle.setAttribute("id", "quantity_title");
_elDiv_quantityTitle.textContent = _trTbl.ui.amenity.title.quantity[_state.lang];
_elDiv_summary.appendChild(_elDiv_quantityTitle);
// Append Sub elements::free count Order amount_title
let _elDiv_amountTitle = document.createElement('div');
_elDiv_amountTitle.setAttribute("id", "amount_title");
_elDiv_amountTitle.textContent = _trTbl.ui.amenity.title.amount[_state.lang];
_elDiv_summary.appendChild(_elDiv_amountTitle);
// Append Sub elements::free count Order quantity_val
let _elDiv_quantity = document.createElement('div');
_elDiv_quantity.setAttribute("id", "quantity_val");
_elDiv_quantity.textContent = _amOrdItem.quantity;
_elDiv_summary.appendChild(_elDiv_quantity);
// Append Sub elements::free count Order amount_val
let _elDiv_amount = document.createElement('div');
_elDiv_amount.setAttribute("id", "amount_val");
_elDiv_amount.textContent = `${_order.currency[_state.lang]}${_amOrdItem.amount[_state.lang]}`;
_elDiv_summary.appendChild(_elDiv_amount);
_eldiv_item_ctz.appendChild(_elDiv_summary);
_eltr_item.appendChild(_eldiv_item_ctz);
_eltbl_am_items.append(_eltr_item);
}
}
// 첫번째 테이블 아애템에 active 클래스 추가 (플래그용으로 사용)
_elAmDOdItemsRoot.children('table').children('tr').first().addClass('active');
} catch (_error) {
console.log(_error.message);
}
_elAmODRoot.children('.total_amount').children('.title').text(_trTbl.ui.amenity.title.Sum[_state.lang]);
_elAmODRoot.children('.total_amount').children('.value').text(`${_order.currency[_state.lang]}${_order.amount[_state.lang]}`);
// last_OrderTbl_idx 초기화
if (!(_amenity.button in _state.hotkey.mm)) {
_state.hotkey.mm[_amenity.button].last_OrderTbl_idx = 0;
}
}
/**
* HotelTV UI[AppFull] Wrapper Function::> build amenity
* @param {boolean} e event
*/
function __uifxn_AppFull_BuildAmenity() {
let _state = HotelTV.state;
let _trTbl = HotelTV.translation;
let _opening = HotelTV.opening;
let _order = HotelTV.orders.amenity;
let _amenity = null;
let _elAmRoot = $(`.popup .amenity`);
let _elAmBtnRoot = $(`.popup .amenity>.buttons`);
if (!_opening.amenity) {
return;
}
_amenity = _opening.amenity;
_elAmRoot.children('.title').text(_amenity.title[_state.lang]);
_elAmRoot.children('.usage').text(_trTbl.ui.amenity.usage.order[_state.lang]);
//Draw Amenity Cart Items
let _elAmItemsRoot = $(`.popup .amenity>.items`);
try {
// Delete elements under amenity item table
if (_elAmItemsRoot.children('table').children('tr').length) {
_elAmItemsRoot.children('table').children('tr').remove();
}
let _eltbl_am_items = _elAmItemsRoot.children('.table#item_list');;
for (let _idx = 1; _idx <= _amenity.children.length; _idx++) {
let _amItem = _amenity.children[_idx];
var _eltr_item = document.createElement('tr');
_eltr_item.setAttribute("id", _amenity.children[_idx].id);
_eltr_item.setAttribute("ctz_idx", _idx);
//어메니티 아이탬 화면 드로잉
var _eldiv_item_ctz = document.createElement('div');
_eldiv_item_ctz.setAttribute("class", "products");
// Append Sub elements::title
let _elDiv_title = document.createElement('div');
_elDiv_title.setAttribute("id", "item_title");
_elDiv_title.textContent = _amItem.title[_state.lang];
_eldiv_item_ctz.appendChild(_elDiv_title);
// Append Sub elements::thumbnail iamge
let _elDiv_thumb = document.createElement('div');
_elDiv_thumb.setAttribute("id", "thumb");
let _sz_styleOpt = "background-image: url(" + _amItem.thumbnail.file.download + "); ";
_sz_styleOpt += "background-repeat: no-repeat; background-position: center center; background-size: contain ";
_elDiv_thumb.setAttribute("style", _sz_styleOpt);
_eldiv_item_ctz.appendChild(_elDiv_thumb);
// Append Sub elements::free count Title & Value
let _elDiv_details = document.createElement('div');
_elDiv_details.setAttribute("id", "details");
let _elDiv_freecntTitle = document.createElement('div');
_elDiv_freecntTitle.setAttribute("id", "freecnt_title");
_elDiv_freecntTitle.textContent = _trTbl.ui.amenity.title.freecnt[_state.lang];
_elDiv_details.appendChild(_elDiv_freecntTitle);
let _elDiv_freecntValue = document.createElement('div');
_elDiv_freecntValue.setAttribute("id", "freecnt_val");
_elDiv_freecntValue.textContent = "";
_elDiv_details.appendChild(_elDiv_freecntValue);
// Append Sub elements::price Title & Value
let _elDiv_priceTitle = document.createElement('div');
_elDiv_priceTitle.setAttribute("id", "price_title");
_elDiv_priceTitle.textContent = _trTbl.ui.amenity.title.price[_state.lang];
_elDiv_details.appendChild(_elDiv_priceTitle);
let _elDiv_priceValue = document.createElement('div');
_elDiv_priceValue.setAttribute("id", "price_val");
_elDiv_priceValue.textContent = "";
_elDiv_details.appendChild(_elDiv_priceValue);
_eldiv_item_ctz.appendChild(_elDiv_details);
// Append Sub elements::free count Order quantity_val
let _elDiv_quantity = document.createElement('div');
_elDiv_quantity.setAttribute("id", "quantity_val");
_elDiv_quantity.textContent = "";
_eldiv_item_ctz.appendChild(_elDiv_quantity);
_eltr_item.appendChild(_eldiv_item_ctz);
_eltbl_am_items.append(_eltr_item);
}
// 첫번째 테이블 아애템에 active 클래스 추가 (플래그용으로 사용)
_elAmItemsRoot.children('.table').children('tr').first().addClass('active');
} catch (_error) {
console.log(_error.message);
}
//Fill up amenity important information such as free count and price, etc...
__uifxn_AppFull_DrawAmenityItem();
_elAmBtnRoot.children('.order').text(_trTbl.ui.amenity.title.order[_state.lang]);
_elAmBtnRoot.children('.cancel').text(_trTbl.ui.amenity.title.cancel[_state.lang]);
_elAmBtnRoot.children('.details').text(_trTbl.ui.amenity.title.carts[_state.lang]);
// HOTKEY정보를 state에 기록
if (!(_amenity.button in _state.hotkey.mm)) {
_state.hotkey.mm[_amenity.button] = {
'type': "amenity",
"status": {
"focus": "table",
"last_CartTbl_idx": 0,
"last_CartBtn_idx": null,
"last_OrderTbl_idx": 0,
}
};
}
}
/**
* HotelTV UI[AppFull] Wrapper Function::> amenity handling function
* @param {boolean} e event
*/
async function __uifxn_AppFull_HandleAmenity(_evt, _isFlushCart, _isDoOrder) {
let _state = HotelTV.state;
let _trTbl = HotelTV.translation;
let _opening = HotelTV.opening;
let _amenity = null;
let _carts = HotelTV.carts.amenity;
let _scrollTopVal = 0;
const _checkEmptyOrder = function(_object) {
for (__j = 1; __j <= _object.length; __j++) {
if (_object[__j].id) {
return false;
}
}
return true;
}
if (!_opening.amenity) {
return;
}
_amenity = _opening.amenity;
if (_evt == "up") {
if (_state.hotkey.mm[_amenity.button].status.focus == "table") {
let activeTableRow = $('.popup .amenity>.items table tr.active').prev(".table tr");
if (activeTableRow.length) {
$('.popup .amenity>.items table tr.active').removeClass("active");
activeTableRow.addClass('active');
_state.hotkey.mm[_amenity.button].status.last_CartTbl_idx = activeTableRow.prop('rowIndex');
_scrollTopVal = activeTableRow.prop('scrollHeight') * _state.hotkey.mm[_amenity.button].status.last_CartTbl_idx;
$('.popup .amenity>.items').animate({ scrollTop: _scrollTopVal }, 500);
}
} else if (_state.hotkey.mm[_amenity.button].status.focus == "button") {
if (_state.hotkey.mm[_amenity.button].status.last_CartBtn_idx == "details") {
_state.hotkey.mm[_amenity.button].status.last_CartBtn_idx = "cancel";
$('.popup .amenity>.buttons div').removeClass("active");
$('.popup .amenity>.buttons div.cancel').addClass("active");
} else if (_state.hotkey.mm[_amenity.button].status.last_CartBtn_idx == "cancel") {
if (_checkEmptyOrder(_carts.items) == false) {
_state.hotkey.mm[_amenity.button].status.last_CartBtn_idx = "order";
$('.popup .amenity>.buttons div').removeClass("active");
$('.popup .amenity>.buttons div.order').addClass("active");
} else {
_state.hotkey.mm[_amenity.button].status.last_CartBtn_idx = null;
_state.hotkey.mm[_amenity.button].status.focus = "table";
$('.popup .amenity>.buttons div').removeClass("active");
$('.popup .amenity>.items table tr').eq(_state.hotkey.mm[_amenity.button].status.last_CartTbl_idx).addClass('active');
}
} else {
_state.hotkey.mm[_amenity.button].status.last_CartBtn_idx = null;
_state.hotkey.mm[_amenity.button].status.focus = "table";
$('.popup .amenity>.buttons div').removeClass("active");
$('.popup .amenity>.items table tr').eq(_state.hotkey.mm[_amenity.button].status.last_CartTbl_idx).addClass('active');
}
} else if (_state.hotkey.mm[_amenity.button].status.focus == "order_details") {
let activeTableRow = $('.popup .amenity>.order-details>.items table tr.active').prev(".table tr");
if (activeTableRow.length) {
$('.popup .amenity>.order-details>.items table tr.active').removeClass("active");
activeTableRow.addClass('active');
_state.hotkey.mm[_amenity.button].status.last_OrderTbl_idx = activeTableRow.prop('rowIndex');
_scrollTopVal = activeTableRow.prop('scrollHeight') * _state.hotkey.mm[_amenity.button].status.last_OrderTbl_idx;
$('.popup .amenity>.order-details>.items').animate({ scrollTop: _scrollTopVal }, 500);
}
}
console.log(`STATUS::> ${JSON.stringify(_state.hotkey.mm[_amenity.button].status)}`);
} else if (_evt == "down") {
if (_state.hotkey.mm[_amenity.button].status.focus == "table") {
let activeTableRow = $('.popup .amenity>.items table tr.active').next(".table tr");
if (activeTableRow.length) {
$('.popup .amenity>.items table tr.active').removeClass("active");
activeTableRow.addClass('active');
_state.hotkey.mm[_amenity.button].status.last_CartTbl_idx = activeTableRow.prop('rowIndex');
_scrollTopVal = activeTableRow.prop('scrollHeight') * _state.hotkey.mm[_amenity.button].status.last_CartTbl_idx;
$('.popup .amenity>.items').animate({ scrollTop: _scrollTopVal }, 500);
} else {
_state.hotkey.mm[_amenity.button].status.focus = "button";
if (!_state.hotkey.mm[_amenity.button].status.last_CartBtn_idx) {
$('.popup .amenity>.items table tr.active').removeClass("active");
$('.popup .amenity>.buttons div').removeClass("active");
if (_checkEmptyOrder(_carts.items) == false) {
_state.hotkey.mm[_amenity.button].status.last_CartBtn_idx = "order";
$('.popup .amenity>.buttons div.order').addClass("active");
} else {
_state.hotkey.mm[_amenity.button].status.last_CartBtn_idx = "cancel";
$('.popup .amenity>.buttons div.cancel').addClass("active");
}
}
}
} else if (_state.hotkey.mm[_amenity.button].status.focus == "button") {
if (_state.hotkey.mm[_amenity.button].status.last_CartBtn_idx == "order") {
_state.hotkey.mm[_amenity.button].status.last_CartBtn_idx = "cancel";
$('.popup .amenity>.buttons div').removeClass("active");
$('.popup .amenity>.buttons div.cancel').addClass("active");
} else if (_state.hotkey.mm[_amenity.button].status.last_CartBtn_idx == "cancel") {
_state.hotkey.mm[_amenity.button].status.last_CartBtn_idx = "details";
$('.popup .amenity>.buttons div').removeClass("active");
$('.popup .amenity>.buttons div.details').addClass("active");
}
} else if (_state.hotkey.mm[_amenity.button].status.focus == "order_details") {
let activeTableRow = $('.popup .amenity>.order-details>.items table tr.active').next(".table tr");
if (activeTableRow.length) {
$('.popup .amenity>.order-details>.items table tr.active').removeClass("active");
activeTableRow.addClass('active');
_state.hotkey.mm[_amenity.button].status.last_OrderTbl_idx = activeTableRow.prop('rowIndex');
_scrollTopVal = activeTableRow.prop('scrollHeight') * _state.hotkey.mm[_amenity.button].status.last_OrderTbl_idx;
$('.popup .amenity>.order-details>.items').animate({ scrollTop: _scrollTopVal }, 200);
}
}
console.log(`STATUS::> ${JSON.stringify(_state.hotkey.mm[_amenity.button].status)}`);
} else if (_evt == "enter") {
_state.hotkey.mm[_amenity.button].status.focus = "order_details";
} else if (_evt == "reset") {
_state.hotkey.mm[_amenity.button].status = {
"focus": "table",
"last_CartTbl_idx": 0,
"last_CartBtn_idx": null,
"last_OrderTbl_idx": 0,
};
$('.popup .amenity>.buttons div').removeClass("active");
$('.popup .amenity>.items table tr').removeClass("active");
$('.popup .amenity>.items table tr:first').addClass('active');
$('.popup .amenity>.order-details>.items table tr').removeClass("active");
$('.popup .amenity>.order-details>.items table tr:first').addClass('active');
// Flush CART
if (_isFlushCart == true && HotelTV.carts.amenity.items) {
let _cartsItems = HotelTV.carts.amenity.items;
for (_k = 1; _k <= _cartsItems.length; _k++) {
if (_cartsItems[_k].id) {
try {
let _result = await HotelTV.api.DeleteAmenityCarts(_cartsItems[_k].id);
if (_result) {
console.log(`Success to flush CARTID::> ${_cartsItems[_k].id}`);
} else {
console.log(`Fail to flush CARTID::> ${_cartsItems[_k].id}`);
}
} catch (_error) {
console.log(`Fail to call API::> ${_error}`);
}
}
}
__uifxn_AppFull_DrawAmenityItem();
}
// Order
if (_isDoOrder == true && HotelTV.carts.amenity.items) {
try {
let _result = await HotelTV.api.PutAmenityOrders();
if (_result) {
console.log(`Success to order CARTID::>`);
__uifxn_AppFull_DrawAmenityItem();
} else {
console.log(`Fail to order CARTID::>`);
}
} catch (_error) {
console.log(`Fail to call API::> ${_error}`);
}
}
} else if (_evt == "add") {
if (_state.hotkey.mm[_amenity.button].status.focus == "table") {
let activedTableRow = $('.popup .amenity>.items table tr.active');
let _sel_itemID = activedTableRow.attr('id');
try {
let _result = await HotelTV.api.PutAmenityCarts(_sel_itemID, 1);
if (_result) {
__uifxn_AppFull_DrawAmenityItem();
}
} catch (_error) {
console.log(`Fail to call API::> ${_error}`);
}
}
} else if (_evt == "del") {
if (_state.hotkey.mm[_amenity.button].status.focus == "table") {
let activedTableRow = $('.popup .amenity>.items table tr.active');
let _sel_itemID = activedTableRow.attr('id');
try {
let _result = await HotelTV.api.PutAmenityCarts(_sel_itemID, -1);
if (_result) {
__uifxn_AppFull_DrawAmenityItem();
}
} catch (_error) {
console.log(`Fail to call API::> ${_error}`);
}
}
}
}
/**
* HotelTV UI[AppFull] Wrapper Function::> update room service item
* @param {boolean} e event
*/
async function __uifxn_AppFull_DrawRoomserviceItem() {
let _state = HotelTV.state;
let _roomservice = HotelTV.opening.roomService;
let _carts = null;
const __fxn_fmexist = function(_object, _itemID) {
for (__j = 1; __j <= _object.length; __j++) {
if (_object[__j].itemId == _itemID) {
return true;
}
}
return false;
}
const __fxn_fmvalue = function(_object, _key, _itemID) {
for (__j = 1; __j <= _object.length; __j++) {
if (_object[__j].itemId == _itemID) {
return _object[__j][_key];
}
}
}
try {
let _elRsMnRoot = $(`.popup .roomservice .menu`);
HotelTV.carts.roomservice = _carts = await HotelTV.api.GetRoomserviceCarts();
for (let _idx = 1; _idx <= _roomservice.children.length; _idx++) {
let _rsItem = _roomservice.children[_idx];
let _elRsItemTblRecRoot = _elRsMnRoot.children('div.items').children('table').children(`tr#${_rsItem.id}`).children('div.products');
if (_carts.items.length && __fxn_fmexist(_carts.items, _rsItem.id) == true) {
// amount value
_elRsItemTblRecRoot.children('div#details').children('#price').text(__fxn_fmvalue(_carts.items, "amount", _rsItem.id)[_state.lang].toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + _roomservice.currency[_state.lang]);
// Order Count
_elRsItemTblRecRoot.children('div#details').children('#quantity').children(`#value`).text(__fxn_fmvalue(_carts.items, "quantity", _rsItem.id));
}
}
} catch (_error) {
console.log(_error.message);
}
}
/**
* HotelTV UI[AppFull] Wrapper Function::> build roomservice details
* @param {boolean} e event
*/
async function __uifxn_AppFull_BuildRoomserviceOrderDetails() {
let _state = HotelTV.state;
let _trTbl = HotelTV.translation;
let _opening = HotelTV.opening;
let _roomservice = null;
let _elRsODRoot = $(`.popup .roomservice .menu>.order-details`);
const __fxn_fmvalue = function(_object, _key, _itemID) {
for (__j = 1; __j <= _object.length; __j++) {
if (_object[__j].id == _itemID) {
return _object[__j][_key];
}
}
}
if (!_opening.roomService) {
return;
}
_roomservice = _opening.roomService;
try {
HotelTV.orders.roomservice = _order = await HotelTV.api.GetRoomserviceOrders(null);
} catch (_error) {
console.log(`Fail to call API::> ${_error}`);
return;
}
_elRsODRoot.children(`.title`).text(_trTbl.ui.roomservice.title.carts[_state.lang]);
_elRsODRoot.children(`.usage`).text(_trTbl.ui.roomservice.usage.details[_state.lang]);
//Draw Room service Order Items
try {
// Delete elements under room service item table
let _elRsRDOdItemsRoot = _elRsODRoot.children(`.items`);
if (_elRsRDOdItemsRoot.children('table').children('tr').length) {
_elRsRDOdItemsRoot.children('table').children('tr').remove();
}
let _eltbl_am_items = _elRsODRoot.children('.items').children('.table#item_list');
for (let _odix = 1; _odix <= _order.orders.length; _odix++) {
let _rsOrds = _order.orders[_odix];
for (let _idx = 1; _idx <= _rsOrds.items.length; _idx++) {
let _rsOrdItem = _rsOrds.items[_idx];
var _eltr_item = document.createElement('tr');
_eltr_item.setAttribute("id", `${_odix}-${_idx}`);
_eltr_item.setAttribute("ctz_idx", (_odix - 1) * _order.orders.length + _idx);
//어메니티 아이탬 화면 드로잉
var _eldiv_item_ctz = document.createElement('div');
_eldiv_item_ctz.setAttribute("class", "products");
// Append Sub elements::title
let _elDiv_odNum = document.createElement('div');
_elDiv_odNum.setAttribute("id", "order_num");
_elDiv_odNum.textContent = `${_trTbl.ui.roomservice.title.ordernum[_state.lang]} ${_rsOrds.id}`;
_eldiv_item_ctz.appendChild(_elDiv_odNum);
// Append Sub elements::thumbnail iamge
let _elDiv_thumb = document.createElement('div');
_elDiv_thumb.setAttribute("id", "thumb");
// let _sz_styleOpt = "background-image: url(" + __fxn_fmvalue(_roomservice.children, "thumbnail", _rsOrdItem.itemId).file.download + "); ";
// _sz_styleOpt += "background-repeat: no-repeat; background-position: center center; background-size: contain ";
// _elDiv_thumb.setAttribute("style", _sz_styleOpt);
_eldiv_item_ctz.appendChild(_elDiv_thumb);
// Append Sub elements::quantity and amount summary
let _elDiv_summary = document.createElement('div');
_elDiv_summary.setAttribute("id", "summary");
// Append Sub elements::free count Order quantity_title
let _elDiv_quantityTitle = document.createElement('div');
_elDiv_quantityTitle.setAttribute("id", "quantity_title");
_elDiv_quantityTitle.textContent = _trTbl.ui.roomservice.title.quantity[_state.lang];
_elDiv_summary.appendChild(_elDiv_quantityTitle);
// Append Sub elements::free count Order amount_title
let _elDiv_amountTitle = document.createElement('div');
_elDiv_amountTitle.setAttribute("id", "amount_title");
_elDiv_amountTitle.textContent = _trTbl.ui.roomservice.title.amount[_state.lang];
_elDiv_summary.appendChild(_elDiv_amountTitle);
// Append Sub elements::free count Order quantity_val
let _elDiv_quantity = document.createElement('div');
_elDiv_quantity.setAttribute("id", "quantity_val");
_elDiv_quantity.textContent = _rsOrdItem.quantity;
_elDiv_summary.appendChild(_elDiv_quantity);
// Append Sub elements::free count Order amount_val
let _elDiv_amount = document.createElement('div');
_elDiv_amount.setAttribute("id", "amount_val");
_elDiv_amount.textContent = `${_order.currency[_state.lang]}${_rsOrdItem.amount[_state.lang]}`;
_elDiv_summary.appendChild(_elDiv_amount);
_eldiv_item_ctz.appendChild(_elDiv_summary);
_eltr_item.appendChild(_eldiv_item_ctz);
_eltbl_am_items.append(_eltr_item);
}
}
// 첫번째 테이블 아애템에 active 클래스 추가 (플래그용으로 사용)
_elRsRDOdItemsRoot.children('table').children('tr').first().addClass('active');
//$('.popup .roomservice .menu>.order-details>.items table tr:first').addClass('active');
} catch (_error) {
console.log(_error.message);
}
_elRsODRoot.children('.total_amount').children('.title').text(_trTbl.ui.roomservice.title.Sum[_state.lang]);
_elRsODRoot.children('.total_amount').children('.value').text(`${_order.currency[_state.lang]}${_order.amount[_state.lang]}`);
// last_OrderTbl_idx 초기화
if (!(_roomservice.button in _state.hotkey.mm)) {
_state.hotkey.mm[_roomservice.button].last_OrderTbl_idx = 0;
}
}
/**
* HotelTV UI[AppFull] Wrapper Function::> build room service
* @param {boolean} e event
*/
function __uifxn_AppFull_BuildRoomService() {
let _state = HotelTV.state;
let _trTbl = HotelTV.translation;
let _opening = HotelTV.opening;
let _order = HotelTV.orders.roomService;
let _roomservice = null;
let _elRsMnRoot = $(`.popup .roomservice .menu`);
let _elRsMnBtn = $(`.popup .roomservice .menu .buttons`);
let _elRsMnDesc = $(`.popup .roomservice .description`);
const __fxn_fmvalue = function(_object, _key, _itemID) {
for (__j = 1; __j <= _object.length; __j++) {
if (_object[__j].id == _itemID) {
return _object[__j][_key];
}
}
}
if (!_opening.roomService) {
return;
}
_roomservice = _opening.roomService;
_elRsMnRoot.children('.title').text(_roomservice.title[_state.lang]);
_elRsMnRoot.children('.usage').text(_trTbl.ui.roomservice.usage.order[_state.lang]);
//Draw Roomservice Cart Items
try {
let _elRsMnItems = _elRsMnRoot.children(`.items`);
// Delete elements under room service item table
if (_elRsMnItems.children('table').children('tr').length) {
_elRsMnItems.children('table').children('tr').remove();
}
let _eltbl_rs_items = _elRsMnItems.children('.table#item_list');
for (let _idx = 1; _idx <= _roomservice.children.length; _idx++) {
let _rsItem = _roomservice.children[_idx];
var _eltr_item = document.createElement('tr');
_eltr_item.setAttribute("id", _roomservice.children[_idx].id);
_eltr_item.setAttribute("ctz_idx", _idx);
//어메니티 아이탬 화면 드로잉
var _eldiv_item_ctz = document.createElement('div');
_eldiv_item_ctz.setAttribute("class", "products");
// Append Sub elements::title
let _elDiv_title = document.createElement('div');
_elDiv_title.setAttribute("id", "title");
_elDiv_title.textContent = _rsItem.title[_state.lang];
_eldiv_item_ctz.appendChild(_elDiv_title);
// Append Sub elements:: Price & Quantity
let _elDiv_details = document.createElement('div');
_elDiv_details.setAttribute("id", "details");
let _elDiv_price = document.createElement('div');
// Append Sub elements::price Value
_elDiv_price.setAttribute("id", "price");
_elDiv_price.textContent = _rsItem.price[_state.lang];
_elDiv_details.appendChild(_elDiv_price);
// Append Sub elements::Quantity
let _elDiv_qualtity = document.createElement('div');
_elDiv_qualtity.setAttribute("id", "quantity");
// Append Sub elements::Quantity:Title
let _elDiv_qualtityTitle = document.createElement('div');
_elDiv_qualtityTitle.setAttribute("id", "title");
_elDiv_qualtityTitle.textContent = _trTbl.ui.roomservice.title.quantity[_state.lang];
_elDiv_qualtity.appendChild(_elDiv_qualtityTitle);
// Append Sub elements::Quantity:Title
let _elDiv_qualtityValue = document.createElement('div');
_elDiv_qualtityValue.setAttribute("id", "value");
_elDiv_qualtityValue.textContent = "";
_elDiv_qualtity.appendChild(_elDiv_qualtityValue);
_elDiv_details.appendChild(_elDiv_qualtity);
_eldiv_item_ctz.appendChild(_elDiv_details);
_eltr_item.appendChild(_eldiv_item_ctz);
_eltbl_rs_items.append(_eltr_item);
}
// 첫번째 테이블 아애템에 active 클래스 추가 (플래그용으로 사용)
_elRsMnItems.children('table').children('tr').first().addClass('active');
} catch (_error) {
console.log(_error.message);
}
//Fill up roomservice important information such as free count and price, etc...
__uifxn_AppFull_DrawRoomserviceItem();
_elRsMnBtn.children('.order').text(_trTbl.ui.roomservice.title.order[_state.lang]);
_elRsMnBtn.children('.cancel').text(_trTbl.ui.roomservice.title.cancel[_state.lang]);
_elRsMnBtn.children('.details').text(_trTbl.ui.roomservice.title.carts[_state.lang]);
// HOTKEY정보를 state에 기록
if (!(_roomservice.button in _state.hotkey.mm)) {
_state.hotkey.mm[_roomservice.button] = {
'type': "roomservice",
"status": {
"focus": "table",
"last_CartTbl_idx": 0,
"last_CartBtn_idx": null,
"last_OrderTbl_idx": 0,
}
};
}
if (_elRsMnRoot.css('box-shadow') == 'none') {
$('.popup .roomservice .menu').css('box-shadow', '0px 0px 30px rgba(0, 0, 0, 1)');
$('.popup .roomservice').animate({ backgroundColor: 'rgba(46,46,46,1.0)' }, 200, function() { $('.popup .roomservice .description').show() });
}
//Activated된 테이블 레코드의 ID속성값 읽어오기
let _ActiveItemID = _elRsMnRoot.children(`.items`).children('table').children('tr.active').prop('id');
//Description
_elRsMnDesc.children('.rstitle').text(__fxn_fmvalue(_roomservice.children, "title", _ActiveItemID)[_state.lang]);
_elRsMnDesc.children('.rscomment').text(__fxn_fmvalue(_roomservice.children, "description", _ActiveItemID)[_state.lang]);
_elRsMnDesc.children('.image').css('background-image', 'url(' + __fxn_fmvalue(_roomservice.children, "thumbnails", _ActiveItemID).files[_state.lang][1].download + ')');
}
/**
* HotelTV UI[AppFull] Wrapper Function::> room service handling function
* @param {boolean} e event
*/
async function __uifxn_AppFull_HandleRoomservice(_evt, _isFlushCart, _isDoOrder) {
let _state = HotelTV.state;
let _trTbl = HotelTV.translation;
let _opening = HotelTV.opening;
let _roomservice = null;
let _carts = HotelTV.carts.roomservice;
let _scrollTopVal = 0;
let _elRsRoot = $(`.popup .roomservice`);
let _elRsMnRoot = $(`.popup .roomservice .menu`);
let _elRsMnItems = _elRsMnRoot.children('.items');
let _elRsMnBtn = _elRsMnRoot.children('.buttons');
let _elRsODRoot = _elRsMnRoot.children('.order-details');
let _elRsMnDesc = $(`.popup .roomservice .description`);
const _checkEmptyOrder = function(_object) {
for (__j = 1; __j <= _object.length; __j++) {
if (_object[__j].id) {
return false;
}
}
return true;
}
const __fxn_fmvalue = function(_object, _key, _itemID) {
for (__j = 1; __j <= _object.length; __j++) {
if (_object[__j].id == _itemID) {
return _object[__j][_key];
}
}
}
if (!_opening.roomService) {
return;
}
_roomservice = _opening.roomService;
if (_evt == "up") {
if (_state.hotkey.mm[_roomservice.button].status.focus == "table") {
let activeTableRow = _elRsMnItems.children('table').children('tr.active').prev(".table tr");
if (activeTableRow.length) {
_elRsMnItems.children('table').children('tr.active').removeClass("active");
activeTableRow.addClass('active');
_state.hotkey.mm[_roomservice.button].status.last_CartTbl_idx = activeTableRow.prop('rowIndex');
_scrollTopVal = activeTableRow.prop('scrollHeight') * _state.hotkey.mm[_roomservice.button].status.last_CartTbl_idx;
_elRsMnItems.animate({ scrollTop: _scrollTopVal }, 200);
//Activated된 테이블 레코드의 ID속성값 읽어오기
let _ActiveItemID = activeTableRow.prop('id');
//Description
_elRsMnDesc.children('.rstitle').text(__fxn_fmvalue(_roomservice.children, "title", _ActiveItemID)[_state.lang]);
_elRsMnDesc.children('.rscomment').text(__fxn_fmvalue(_roomservice.children, "description", _ActiveItemID)[_state.lang]);
_elRsMnDesc.children('.image').css('background-image', 'url(' + __fxn_fmvalue(_roomservice.children, "thumbnails", _ActiveItemID).files[_state.lang][1].download + ')');
}
if (_elRsMnRoot.css('box-shadow') == 'none') {
_elRsMnRoot.css('box-shadow', '0px 0px 30px rgba(0, 0, 0, 1)');
_elRsRoot.animate({ backgroundColor: 'rgba(46,46,46,1.0)' }, 200, function() {
_elRsMnDesc.children('.title').text(__fxn_fmvalue(_roomservice, "title", activeTableRow.prop('id'))[_state.lang]);
_elRsMnDesc.show()
});
}
} else if (_state.hotkey.mm[_roomservice.button].status.focus == "button") {
_elRsMnBtn.children('div').removeClass("active");
if (_state.hotkey.mm[_roomservice.button].status.last_CartBtn_idx == "details") {
_state.hotkey.mm[_roomservice.button].status.last_CartBtn_idx = "cancel";
_elRsMnBtn.children('div.cancel').addClass("active");
if (_elRsMnRoot.css('box-shadow') != 'none') {
_elRsMnRoot.css('box-shadow', 'none');
_elRsRoot.animate({ backgroundColor: 'rgba(46,46,46,0.0)' }, 200, function() { _elRsMnDesc.hide() });
}
} else if (_state.hotkey.mm[_roomservice.button].status.last_CartBtn_idx == "cancel") {
if (_checkEmptyOrder(_carts.items) == false) {
_state.hotkey.mm[_roomservice.button].status.last_CartBtn_idx = "order";
_elRsMnBtn.children('div.order').addClass("active");
if (_elRsMnRoot.css('box-shadow') != 'none') {
_elRsMnRoot.css('box-shadow', 'none');
_elRsRoot.animate({ backgroundColor: 'rgba(46,46,46,0.0)' }, 200, function() { _elRsMnDesc.hide() });
}
} else {
_state.hotkey.mm[_roomservice.button].status.last_CartBtn_idx = null;
_state.hotkey.mm[_roomservice.button].status.focus = "table";
_elRsMnItems.children('table').children('tr').eq(_state.hotkey.mm[_roomservice.button].status.last_CartTbl_idx).addClass('active');
//Activated된 테이블 레코드의 ID속성값 읽어오기
let _ActiveItemID = _elRsMnItems.children('table').children('tr.active').prop('id');
//Description
_elRsMnDesc.children('.rstitle').text(__fxn_fmvalue(_roomservice.children, "title", _ActiveItemID)[_state.lang]);
_elRsMnDesc.children('.rscomment').text(__fxn_fmvalue(_roomservice.children, "description", _ActiveItemID)[_state.lang]);
_elRsMnDesc.children('.image').css('background-image', 'url(' + __fxn_fmvalue(_roomservice.children, "thumbnails", _ActiveItemID).files[_state.lang][1].download + ')');
if (_elRsMnRoot.css('box-shadow') == 'none') {
_elRsMnRoot.css('box-shadow', '0px 0px 30px rgba(0, 0, 0, 1)');
_elRsRoot.animate({ backgroundColor: 'rgba(46,46,46,1.0)' }, 200, function() { _elRsMnDesc.show() });
}
}
} else {
_state.hotkey.mm[_roomservice.button].status.last_CartBtn_idx = null;
_state.hotkey.mm[_roomservice.button].status.focus = "table";
_elRsMnItems.children('table').children('tr').eq(_state.hotkey.mm[_roomservice.button].status.last_CartTbl_idx).addClass('active');
//Activated된 테이블 레코드의 ID속성값 읽어오기
let _ActiveItemID = _elRsMnItems.children('table').children('tr.active').prop('id');
//Description
_elRsMnDesc.children('.rstitle').text(__fxn_fmvalue(_roomservice.children, "title", _ActiveItemID)[_state.lang]);
_elRsMnDesc.children('.rscomment').text(__fxn_fmvalue(_roomservice.children, "description", _ActiveItemID)[_state.lang]);
_elRsMnDesc.children('.image').css('background-image', 'url(' + __fxn_fmvalue(_roomservice.children, "thumbnails", _ActiveItemID).files[_state.lang][1].download + ')');
if (_elRsMnRoot.css('box-shadow') == 'none') {
_elRsMnRoot.css('box-shadow', '0px 0px 30px rgba(0, 0, 0, 1)');
_elRsRoot.animate({ backgroundColor: 'rgba(46,46,46,1.0)' }, 200, function() {
_elRsMnDesc.show()
});
}
}
} else if (_state.hotkey.mm[_roomservice.button].status.focus == "order_details") {
let activeTableRow = _elRsODRoot.children('.items').children('table').children('tr.active').prev(".table tr");
if (activeTableRow.length) {
_elRsODRoot.children('.items').children('table').children('tr.active').removeClass("active");
activeTableRow.addClass('active');
_state.hotkey.mm[_roomservice.button].status.last_OrderTbl_idx = activeTableRow.prop('rowIndex');
_scrollTopVal = activeTableRow.prop('scrollHeight') * _state.hotkey.mm[_roomservice.button].status.last_OrderTbl_idx;
_elRsODRoot.children('.items').animate({ scrollTop: _scrollTopVal }, 200);
}
if (_elRsMnRoot.css('box-shadow') != 'none') {
_elRsMnRoot.css('box-shadow', 'none');
_elRsRoot.animate({ backgroundColor: 'rgba(46,46,46,0.0)' }, 200, function() { _elRsMnDesc.hide() });
}
}
console.log(`STATUS::> ${JSON.stringify(_state.hotkey.mm[_roomservice.button].status)}`);
} else if (_evt == "down") {
if (_state.hotkey.mm[_roomservice.button].status.focus == "table") {
let activeTableRow = _elRsMnItems.children('table').children('tr.active').next(".table tr");
if (activeTableRow.length) {
_elRsMnItems.children('table').children('tr.active').removeClass("active");
activeTableRow.addClass('active');
_state.hotkey.mm[_roomservice.button].status.last_CartTbl_idx = activeTableRow.prop('rowIndex');
_scrollTopVal = activeTableRow.prop('scrollHeight') * _state.hotkey.mm[_roomservice.button].status.last_CartTbl_idx;
_elRsMnItems.animate({ scrollTop: _scrollTopVal }, 200);
//Activated된 테이블 레코드의 ID속성값 읽어오기
let _ActiveItemID = activeTableRow.prop('id');
//Description
_elRsMnDesc.children('.rstitle').text(__fxn_fmvalue(_roomservice.children, "title", _ActiveItemID)[_state.lang]);
_elRsMnDesc.children('.rscomment').text(__fxn_fmvalue(_roomservice.children, "description", _ActiveItemID)[_state.lang]);
_elRsMnDesc.children('.image').css('background-image', 'url(' + __fxn_fmvalue(_roomservice.children, "thumbnails", _ActiveItemID).files[_state.lang][1].download + ')');
if (_elRsMnRoot.css('box-shadow') == 'none') {
_elRsMnRoot.css('box-shadow', '0px 0px 30px rgba(0, 0, 0, 1)');
_elRsRoot.animate({ backgroundColor: 'rgba(46,46,46,1.0)' }, 200, function() { _elRsMnDesc.show() });
}
} else {
_state.hotkey.mm[_roomservice.button].status.focus = "button";
if (!_state.hotkey.mm[_roomservice.button].status.last_CartBtn_idx) {
_elRsMnItems.children('table').children('tr.active').removeClass("active");
_elRsMnBtn.children('div').removeClass("active");
if (_checkEmptyOrder(_carts.items) == false) {
_state.hotkey.mm[_roomservice.button].status.last_CartBtn_idx = "order";
_elRsMnBtn.children('div.order').addClass("active");
} else {
_state.hotkey.mm[_roomservice.button].status.last_CartBtn_idx = "cancel";
_elRsMnBtn.children('div.cancel').addClass("active");
}
}
if (_elRsMnRoot.css('box-shadow') != 'none') {
_elRsMnRoot.css('box-shadow', 'none');
_elRsRoot.animate({ backgroundColor: 'rgba(46,46,46,0.0)' }, 200, function() { _elRsMnDesc.hide() });
}
}
} else if (_state.hotkey.mm[_roomservice.button].status.focus == "button") {
if (_state.hotkey.mm[_roomservice.button].status.last_CartBtn_idx == "order") {
_elRsMnBtn.children('div').removeClass("active");
_state.hotkey.mm[_roomservice.button].status.last_CartBtn_idx = "cancel";
_elRsMnBtn.children('div.cancel').addClass("active");
} else if (_state.hotkey.mm[_roomservice.button].status.last_CartBtn_idx == "cancel") {
_elRsMnBtn.children('div').removeClass("active");
_state.hotkey.mm[_roomservice.button].status.last_CartBtn_idx = "details";
_elRsMnBtn.children('div.details').addClass("active");
}
if (_elRsMnRoot.css('box-shadow') != 'none') {
_elRsMnRoot.css('box-shadow', 'none');
_elRsRoot.animate({ backgroundColor: 'rgba(46,46,46,0.0)' }, 200, function() { _elRsMnDesc.hide() });
}
} else if (_state.hotkey.mm[_roomservice.button].status.focus == "order_details") {
let activeTableRow = _elRsODRoot.children('.items').children('table').children('tr.active').next(".table tr");
if (activeTableRow.length) {
_elRsODRoot.children('.items').children('table').children('tr.active').removeClass("active");
activeTableRow.addClass('active');
_state.hotkey.mm[_roomservice.button].status.last_OrderTbl_idx = activeTableRow.prop('rowIndex');
_scrollTopVal = activeTableRow.prop('scrollHeight') * _state.hotkey.mm[_roomservice.button].status.last_OrderTbl_idx;
_elRsODRoot.children('.items').animate({ scrollTop: _scrollTopVal }, 200);
}
if (_elRsMnRoot.css('box-shadow') != 'none') {
_elRsMnRoot.css('box-shadow', 'none');
_elRsRoot.animate({ backgroundColor: 'rgba(46,46,46,0.0)' }, 200, function() { _elRsMnDesc.hide() });
}
}
console.log(`STATUS::> ${JSON.stringify(_state.hotkey.mm[_roomservice.button].status)}`);
} else if (_evt == "enter") {
_state.hotkey.mm[_roomservice.button].status.focus = "order_details";
} else if (_evt == "reset") {
_state.hotkey.mm[_roomservice.button].status = {
"focus": "table",
"last_CartTbl_idx": 0,
"last_CartBtn_idx": null,
"last_OrderTbl_idx": 0,
};
_elRsMnBtn.children('div').removeClass("active");
_elRsMnItems.children('table').children('tr').removeClass("active");
_elRsMnItems.children('table').children('tr').first().addClass('active');
_elRsODRoot.children('.items').children('table').children('tr').removeClass("active");
_elRsODRoot.children('.items').children('table').children('tr').first().addClass('active');
if (_elRsMnRoot.css('box-shadow') == 'none') {
$('.popup .roomservice .menu').css('box-shadow', '0px 0px 30px rgba(0, 0, 0, 1)');
$('.popup .roomservice').animate({ backgroundColor: 'rgba(46,46,46,1.0)' }, 200, function() { $('.popup .roomservice .description').show() });
}
//Activated된 테이블 레코드의 ID속성값 읽어오기
let _ActiveItemID = _elRsMnRoot.children(`.items`).children('table').children('tr.active').prop('id');
//Description
_elRsMnDesc.children('.rstitle').text(__fxn_fmvalue(_roomservice.children, "title", _ActiveItemID)[_state.lang]);
_elRsMnDesc.children('.rscomment').text(__fxn_fmvalue(_roomservice.children, "description", _ActiveItemID)[_state.lang]);
_elRsMnDesc.children('.image').css('background-image', 'url(' + __fxn_fmvalue(_roomservice.children, "thumbnails", _ActiveItemID).files[_state.lang][1].download + ')');
// Flush CART
if (_isFlushCart == true && HotelTV.carts.roomservice.items) {
let _cartsItems = HotelTV.carts.roomservice.items;
for (_k = 1; _k <= _cartsItems.length; _k++) {
if (_cartsItems[_k].id) {
try {
let _result = await HotelTV.api.DeleteRoomserviceCarts(_cartsItems[_k].id);
if (_result) {
console.log(`Success to flush CARTID::> ${_cartsItems[_k].id}`);
} else {
console.log(`Fail to flush CARTID::> ${_cartsItems[_k].id}`);
}
} catch (_error) {
console.log(`Fail to call API::> ${_error}`);
}
}
}
__uifxn_AppFull_DrawRoomserviceItem();
}
// Order
if (_isDoOrder == true && HotelTV.carts.roomservice.items) {
try {
let _result = await HotelTV.api.PutRoomserviceOrders();
if (_result) {
console.log(`Success to order CARTID::>`);
__uifxn_AppFull_DrawRoomserviceItem();
} else {
console.log(`Fail to order CARTID::>`);
}
} catch (_error) {
console.log(`Fail to call API::> ${_error}`);
}
}
} else if (_evt == "add") {
if (_state.hotkey.mm[_roomservice.button].status.focus == "table") {
let activedTableRow = _elRsMnItems.children('table').children('tr.active');
let _sel_itemID = activedTableRow.attr('id');
try {
let _result = await HotelTV.api.PutRoomserviceCarts(_sel_itemID, 1);
if (_result) {
__uifxn_AppFull_DrawRoomserviceItem();
}
} catch (_error) {
console.log(`Fail to call API::> ${_error}`);
}
}
} else if (_evt == "del") {
if (_state.hotkey.mm[_roomservice.button].status.focus == "table") {
let activedTableRow = _elRsMnItems.children('table').children('tr.active');
let _sel_itemID = activedTableRow.attr('id');
try {
let _result = await HotelTV.api.PutRoomserviceCarts(_sel_itemID, -1);
if (_result) {
__uifxn_AppFull_DrawRoomserviceItem();
}
} catch (_error) {
console.log(`Fail to call API::> ${_error}`);
}
}
}
}
/**
* HotelTV UI[AppFull] Wrapper Function::> build news
* @param {boolean} e event
*/
function __uifxn_AppFull_BldNews() {
let _state = HotelTV.state;
let _newsInfo = HotelTV.news;
if (!(_newsInfo) || _newsInfo.length == 0) {
$('.news').hide();
} else {
let _hndlNewsTicker = $('.news>.newsctz #hoteltv-news-ticker');
if (_hndlNewsTicker.children().length == 0) {
let sz_li_news = "";
for (let _nwsIdx = 1; _nwsIdx <= _newsInfo.length; _nwsIdx++) {
if (_newsInfo[_nwsIdx].logo.download != "") {
sz_li_news += `<li data-update=item${_nwsIdx}><img src=" ${_newsInfo[_nwsIdx].logo.download}"/>${_newsInfo[_nwsIdx].content[_state.lang]}</li>`;
} else {
sz_li_news += `<li data-update=item${_nwsIdx}>${_newsInfo[_nwsIdx].content[_state.lang]}</li>`;
}
}
_hndlNewsTicker.html(sz_li_news);
_hndlNewsTicker.webTicker({
height: '26px',
speed: 100
});
} else {
let sz_li_news = "";
for (let _nwsIdx = 1; _nwsIdx <= _newsInfo.length; _nwsIdx++) {
if (_newsInfo[_nwsIdx].logo.download != "") {
if (_newsInfo[_nwsIdx].multilanguage == true) {
sz_li_news += `<li data-update=item${_nwsIdx}><img src=" ${_newsInfo[_nwsIdx].logo.download}"/>${_newsInfo[_nwsIdx].content[_state.lang]}</li>`;
} else {
sz_li_news += `<li data-update=item${_nwsIdx}><img src=" ${_newsInfo[_nwsIdx].logo.download}"/>${_newsInfo[_nwsIdx].content.default}</li>`;
}
} else {
if (_newsInfo[_nwsIdx].multilanguage == true) {
sz_li_news += `<li data-update=item${_nwsIdx}>${_newsInfo[_nwsIdx].content[_state.lang]}</li>`;
} else {
sz_li_news += `<li data-update=item${_nwsIdx}>${_newsInfo[_nwsIdx].content.default}</li>`;
}
}
}
$(".news>.newsctz #hoteltv-news-ticker").webTicker('update', sz_li_news,
'swap',
true,
false
);
}
}
}
/**
* HotelTV UI[AppFull] Wrapper Function::> received event handling function
* @param {boolean} e event
*/
function __uifxn_AppFull_OnKeyDnEvt_SmSel(_evt) {
let _state = HotelTV.state;
let _sminfo = HotelTV.tvguide.program[_state.menu.main.cur].children;
//console.log(`Evnt: ${_evt.item.index} Of ${_evt.item.count} page::> ${_evt.page.index} of ${_evt.page.count}`);
$('#lst_smbg').trigger("to.owl.carousel", [_evt.page.index, 1000, true]);
}
/**
* HotelTV UI[AppFull] Wrapper Function::> Get EPG Info by channel name
* @param {string} _ch_name channel name
*/
function __uifxn_AppFull_GetEpgInfoById(_ch_name) {
let _epgInfo = HotelTV.epg;
let _tm_cur = new Date();
if (_epgInfo == 'undefined' || _epgInfo == null) {
return null;
}
if (Object.keys(_epgInfo).includes('schedules') != true || Object.keys(_epgInfo).includes('channels') != true) {
return null;
}
//Find out epg schedule id
let _epg_schId = null;
for (let _j = 0; _j < _epgInfo.channels.length; _j++) {
if (_epgInfo.channels[_j].name == _ch_name) {
_epg_schId = _epgInfo.channels[_j].id;
}
}
// EPG SHEDULE ID를 찾을 수 없으므로, null 반환.
if (_epg_schId == null) { return null; }
let _epg_prom_info = null;
if (Object.keys(_epgInfo.schedules).includes(_epg_schId) != true) {
return null;
}
_epg_prom_info = _epgInfo.schedules[_epg_schId];
let _rtn_epg = null;
for (let _j in _epg_prom_info) {
let _schTm = new Date();
if (_epg_prom_info[_j].time.length != 5) {
console.log("EPT Schedule org time is NULL");
} else {
_schTm.setHours(Number(_epg_prom_info[_j].time.charAt(0) + _epg_prom_info[_j].time.charAt(1)));
_schTm.setMinutes(Number(_epg_prom_info[_j].time.charAt(3) + _epg_prom_info[_j].time.charAt(4)));
}
let _tdiff_cur = Math.round((_schTm - _tm_cur) / 60000); //Time diff in minuate
if (_rtn_epg == null) {
_rtn_epg = _epg_prom_info[_j];
}
if (_tdiff_cur > 0) {
return _rtn_epg;
}
_rtn_epg = _epg_prom_info[_j];
//console.log("CHNAME::>" + _ch_name + " TDiff::> " + _tdiff_cur);
}
return _rtn_epg;
}
/**
* HotelTV UI[AppFull] Wrapper Function::> TV Channel manager ui show/hide
*/
function __uifxn_AppFull_TVChMngrUi() {
let _state = HotelTV.state;
let _tm_diff_ms = 0;
if (_lastTm.keyevt == null) {
return;
}
let _tm_cur = new Date();
_tm_diff_ms = Math.floor(_tm_cur.getTime() - _lastTm.keyevt.getTime());
//마지막 KEY 이벤트 수신 시간 갱신
//console.log(`KeyDn Event Recoreded::> ${_lastTm.keyevt} TMDiff::> ${_tm_diff_ms}`);
// TV Channel UI 지속 시간 8초
if (_tm_diff_ms < 8000) {
let el_width = $('.main .tv .bg .owl-carousel .owl-stage-outer .owl-stage .item').width();
el_width = (el_width + 100) * -1;
if ($('.main .tv .bg .owl-carousel .owl-stage-outer').position().left == el_width) {
$('.main .tv .bg .owl-carousel .owl-stage-outer').stop().animate({ left: '0px' }, 800, function() {
_state.menu.stage = "tvCtgShow";
});
}
} else {
if ($('.main .tv .bg .owl-carousel .owl-stage-outer').position().left == 0) {
_state.menu.stage = "tvCtgHide";
let el_width = $('.main .tv .bg .owl-carousel .owl-stage-outer .owl-stage .item').width();
el_width = (el_width + 100) * -1;
$('.main .tv .bg .owl-carousel .owl-stage-outer').stop().animate({ left: el_width.toString() + 'px' }, 800);
}
}
}
/**
* HotelTV UI[AppFull] Wrapper Function::> update message selection on mypage
* @param {string} _action parameter
*/
function __uifxn_AppFull_MyPageSelectMessage(_action) {
const _state = HotelTV.state;
if (!(HotelTV.message)) {
console.log("INFO::> No messages");
return;
}
const _msg = HotelTV.message;
const _mmIdx = _state.menu.main.cur;
const _mmInfo = HotelTV.tvguide.program[_mmIdx];
let _state_mypage = _state.menu.main[_mmIdx];
if (_mmInfo.children[_state_mypage.cur].type == 'message') {
const _total_cnt = _state_mypage['message']['cnt'];
let _cur_idx = _state_mypage['message']['cur'];
//mp_msg_tblrec tr엘리멘트들을 Query
let _el_target = $('.main>.mypage>.bg>.owl-carousel .owl-item #mp_msg_tblrec tbody');
if (_action == "up") {
if ((_cur_idx - 1) < 0) {
_cur_idx = 0;
} else {
_cur_idx -= 1;
}
$('.main>.mypage>.bg>.owl-carousel .owl-item #mp_msg_tblrec tr').removeClass('focus');
$('.main>.mypage>.bg>.owl-carousel .owl-item #mp_msg_tblrec tr').filter("[msgidx='" + _cur_idx.toString() + "']").addClass('focus');
_state.menu.main[_mmIdx]['message']['cur'] = _cur_idx;
if ((_cur_idx >= 3) && (_cur_idx < (_total_cnt - 3))) {
_el_target.stop().animate({ scrollTop: ((_cur_idx - 3) * 52).toString() }, 500, function() {
console.log("SCROLL DONE>>>1");
});
}
} else if (_action == "down") {
if ((_cur_idx + 1) > (_total_cnt - 1)) {
_cur_idx = (_total_cnt - 1);
} else {
_cur_idx += 1;
}
$('.main>.mypage>.bg>.owl-carousel .owl-item #mp_msg_tblrec tr').removeClass('focus');
$('.main>.mypage>.bg>.owl-carousel .owl-item #mp_msg_tblrec tr').filter("[msgidx='" + _cur_idx.toString() + "']").addClass('focus');
_state.menu.main[_mmIdx]['message']['cur'] = _cur_idx;
if ((_cur_idx > 3) && (_cur_idx < (_total_cnt - 2))) {
_el_target.stop().animate({ scrollTop: ((_cur_idx - 3) * 52).toString() }, 500, function() {
console.log("SCROLL DONE>>>2");
});
}
}
} else {
console.log("ERROR::> No centered Item");
}
}
/**
* HotelTV UI[AppFull] Wrapper Function::> My Page
*/
function __uifxn_AppFull_BuildMyPage() {
const _trTbl = HotelTV.translation;
const _state = HotelTV.state;
const _msg = HotelTV.message;
const _guest = HotelTV.guestinfo;
const _hotel = HotelTV.hotelinfo;
const _mmIdx = _state.menu.main.cur;
const _mpinfo = HotelTV.tvguide.program[_mmIdx].children;
if (!(_mmIdx in _state.menu.main)) {
_state.menu.main[_mmIdx] = {
'cnt': 0,
'cur': null,
'prev': null,
};
_state.menu.main[_mmIdx].cnt = _mpinfo.length;
}
// 초기 메인 메뉴 KEY설정
_state.menu.stage = "preparing_mypage";
if (_state.menu.main[_mmIdx].cur == null) {
_state.menu.main[_mmIdx].cur = Object.keys(_mpinfo)[0];
}
// MYPAGE 메뉴 셀렉터 노드를 동적으로 구성
let _div_mp_slist = document.querySelector('#lst_mypagesel');
for (let _i = 1; _i <= _mpinfo.length; _i++) {
let _div_mpsel_item = document.createElement('div');
_div_mpsel_item.className = 'item';
_div_mpsel_item.id = 'mpsel_' + _mpinfo[_i].id;
_div_mpsel_item.setAttribute("mpid", _mpinfo[_i].id);
// Append Sub elements::title
let _mp_item_title = document.createElement('div');
_mp_item_title.setAttribute("id", "mp_item_title");
if (_mpinfo.length > 1) {
_mp_item_title.textContent = _mpinfo[_i].title[_state.lang];
// Append Sub elements::icon
let _mp_item_icon = document.createElement('div');
_mp_item_icon.setAttribute("id", "mp_item_icon");
let _sz_styleOpt = "--icon_unfocus: url(" + _mpinfo[_i].unfocusIcon.file.download + "); ";
_sz_styleOpt += "--icon_focus: url(" + _mpinfo[_i].focusIcon.file.download + "); ";
_sz_styleOpt += "background-repeat: no-repeat; background-position: center bottom; background-size: 100% 100%; ";
_mp_item_icon.setAttribute("style", _sz_styleOpt);
_div_mpsel_item.appendChild(_mp_item_icon);
} else {
}
_div_mpsel_item.appendChild(_mp_item_title);
_div_mp_slist.appendChild(_div_mpsel_item);
}
// MYPAGE 메뉴 백그라운드 노드를 동적으로 구성
let _div_mp_bglist = document.querySelector('#lst_mypagebg');
for (let _i = 1; _i <= _mpinfo.length; _i++) {
let _div_mpbg_item = document.createElement('div');
_div_mpbg_item.className = 'item';
_div_mpbg_item.id = 'mpbg_' + _mpinfo[_i].id;
let _sz_styleOpt = "background-image: url(" + _mpinfo[_i].background.file.download + "); ";
_sz_styleOpt += "background-repeat: no-repeat; background-position: center center; background-size: contain ";
_div_mpbg_item.setAttribute("style", _sz_styleOpt);
if (_mpinfo[_i].type == "accommodation") {
let _accomo_title = document.createElement('div');
_accomo_title.setAttribute("id", "mp_accomo_title");
_accomo_title.textContent = _guest.name + _trTbl.ui.mypage.accmodation.title.title[_state.lang];
_div_mpbg_item.appendChild(_accomo_title);
let _accomo_info = document.createElement('div');
_accomo_info.setAttribute("id", "mp_accomo_infowin");
const _accmo_item_list = ["accmodation_gstname", "accmodation_rsvcode", "accmodation_hotel", "accmodation_bed_type", "accmodation_room_num", "accmodation_checkin", "accmodation_checkout"];
for (let _j = 0; _j < _accmo_item_list.length; _j++) {
let __info_item = document.createElement('div');
__info_item.className = 'accmoinf_item';
switch (_accmo_item_list[_j]) {
case 'accmodation_gstname':
__info_item.innerHTML = `<span id="header">${_trTbl.ui.mypage.accmodation.title.gstname[_state.lang]}</span>`;
__info_item.innerHTML += `<span id="value">${_guest.name}</span>`;
break;
case 'accmodation_rsvcode':
__info_item.innerHTML = `<span id="header">${_trTbl.ui.mypage.accmodation.title.rsvcode[_state.lang]}</span>`;
__info_item.innerHTML += `<span id="value">${_guest.id}</span>`;
break;
case 'accmodation_hotel':
__info_item.innerHTML = `<span id="header">${_trTbl.ui.mypage.accmodation.title.hotel[_state.lang]}</span>`;
__info_item.innerHTML += `<span id="value">${_hotel.name}</span>`;
break;
case 'accmodation_bed_type':
__info_item.innerHTML = `<span id="header">${_trTbl.ui.mypage.accmodation.title.bed_type[_state.lang]}</span>`;
__info_item.innerHTML += `<span id="value">${_guest.roomtype}</span>`;
break;
case 'accmodation_room_num':
__info_item.innerHTML = `<span id="header">${_trTbl.ui.mypage.accmodation.title.room_num[_state.lang]}</span>`;
__info_item.innerHTML += `<span id="value">${_guest.room}</span>`;
break;
case 'accmodation_checkin':
__info_item.innerHTML = `<span id="header">${_trTbl.ui.mypage.accmodation.title.checkin[_state.lang]}</span>`;
__info_item.innerHTML += `<span id="value">${_guest.checkIn}</span>`;
break;
case 'accmodation_checkout':
__info_item.innerHTML = `<span id="header">${_trTbl.ui.mypage.accmodation.title.checkout[_state.lang]}</span>`;
__info_item.innerHTML += `<span id="value">${_guest.checkOu}</span>`;
break;
}
_accomo_info.appendChild(__info_item);
}
_div_mpbg_item.appendChild(_accomo_info);
//Hotel info win
let _hotel_info = document.createElement('div');
_hotel_info.setAttribute("id", "mp_hotel_infowin");
const _hotelinfo_item_list = ["address", "custominquiry", "resvinquiry"];
for (let _j = 0; _j < _hotelinfo_item_list.length; _j++) {
let __info_item = document.createElement('div');
__info_item.className = 'hotelinfo_item';
switch (_hotelinfo_item_list[_j]) {
case 'address':
__info_item.innerHTML = `<span id="title">${_trTbl.ui.mypage.accmodation.title.address[_state.lang]}</span>`;
__info_item.innerHTML += `<span id="address">${_hotel.address[_state.lang]}</span>`;
break;
case 'custominquiry':
__info_item.innerHTML = `<span id="title">${_trTbl.ui.mypage.accmodation.title.custominquiry[_state.lang]}</span>`;
__info_item.innerHTML += `<span id="email">${_hotel.inquiry.custom.email}</span>`;
__info_item.innerHTML += `<span id="phone">${_hotel.inquiry.custom.phone[_state.lang]}</span>`;
break;
case 'resvinquiry':
__info_item.innerHTML = `<span id="title">${_trTbl.ui.mypage.accmodation.title.resvinquiry[_state.lang]}</span>`;
__info_item.innerHTML += `<span id="email">${_hotel.inquiry.reservation.email}</span>`;
__info_item.innerHTML += `<span id="phone">${_hotel.inquiry.reservation.phone[_state.lang]}</span>`;
break;
}
_hotel_info.appendChild(__info_item);
}
_div_mpbg_item.appendChild(_hotel_info);
} else if (_mpinfo[_i].type == "message") {
// 메시지 상태 오브젝트 초기화
if (!("message" in _state.menu.main[_mmIdx])) {
_state.menu.main[_mmIdx]['message'] = {
'cnt': 0,
'cur': null,
'prev': null,
};
_state.menu.main[_mmIdx]['message'].cnt = _msg.length;
}
let _msg_title = document.createElement('div');
_msg_title.setAttribute("id", "mp_message_title");
let _msg_unread_cnt = 0;
for (let _j = 1; _j <= _msg.length; _j++) {
if (_msg[_j].read == false) {
_msg_unread_cnt++;
}
}
_msg_title.textContent = _guest.name + _trTbl.ui.mypage.message.title.title[_state.lang].replace("_XX", _msg_unread_cnt.toString());
_div_mpbg_item.appendChild(_msg_title);
let _msg_table = document.createElement('div');
_msg_table.setAttribute("id", "mp_message_table");
let _msg_tblhdr = document.createElement('table');
_msg_tblhdr.setAttribute("id", "mp_msg_tblhdr");
_msg_tblhdr.innerHTML = '<tbody><tr>' +
'<th id="num">' + _trTbl.ui.mypage.message.title.table.num[_state.lang] + '</th>' +
'<th id="title">' + _trTbl.ui.mypage.message.title.table.title[_state.lang] + '</th>' +
'<th id="from">' + _trTbl.ui.mypage.message.title.table.from[_state.lang] + '</th>' +
'<th id="date">' + _trTbl.ui.mypage.message.title.table.date[_state.lang] + '</th>' +
'</tr></tbody>';
_msg_table.appendChild(_msg_tblhdr);
let _msg_tblrec = document.createElement('table');
_msg_tblrec.setAttribute("id", "mp_msg_tblrec");
let _sz_innerHTML = '<tbody>';
let _num_msgIdx = 0;
for (let _j = _msg.length; _j > 0; _j--) {
_sz_innerHTML += '<tr msgnum=' + _j + ' msgidx=' + _num_msgIdx.toString() + ' >';
if (_msg[_j].read == false) {
_sz_innerHTML += '<td id="num">' + _j.toString() + '</td>';
} else {
_sz_innerHTML += '<td id="num" class="read">' + _j.toString() + '</td>';
}
if (_msg[_j].multilanguage == false) {
_sz_innerHTML += '<td id="title">' + _msg[_j].title.default+'</td>';
} else {
_sz_innerHTML += '<td id="title">' + _msg[_j].title[_state.lang] + '</td>';
}
_sz_innerHTML += '<td id="from">' + _msg[_j].from + '</td>';
_sz_innerHTML += '<td id="date">' + _msg[_j].createdAt + '</td>';
_sz_innerHTML += '</tr>';
_num_msgIdx++;
}
_sz_innerHTML += '</tbody>';
_msg_tblrec.innerHTML = _sz_innerHTML;
_msg_table.appendChild(_msg_tblrec);
_div_mpbg_item.appendChild(_msg_table);
}
_div_mp_bglist.appendChild(_div_mpbg_item);
}
_hndl_mpBg = $('#lst_mypagebg');
_hndl_mpBg.owlCarousel({
center: true,
items: 1, //Number of Items on Screen what you want
loop: true,
nav: false,
dots: false,
margin: 0,
smartSpeed: 700,
autoWidth: false,
mouseDrag: false,
touchDrag: false,
pullDrag: false,
freeDrag: false,
//MYPAGE는 항상 accommodation부터 시작
startPosition: 0,
});
_hndl_mpSel = $('#lst_mypagesel');
_hndl_mpSel.owlCarousel({
center: true,
items: 3, //Number of Items on Screen what you want
loop: true,
nav: false,
dots: true,
margin: 0,
smartSpeed: 700,
autoWidth: false,
mouseDrag: false,
touchDrag: false,
pullDrag: false,
freeDrag: false,
//MYPAGE는 항상 accommodation부터 시작
startPosition: 0,
});
$('.main .mypage').show();
$('.main .mypage .bg').show();
//메인 페이지->MyPage 페이지 화면 전환
$('.main .mypage .slider').show(function() {
$('.main').animate({ top: -1080, left: 0 }, 1000, function() {
$('.main .mm').fadeOut(1000);
$('#lst_mypagesel').trigger('translate.owl.carousel', [0]);
$(document.activeElement).keydown(function(event) { //attach event listener
if (_state.menu.stage == "mypage") {
if (event.keyCode == 37) {
$('#lst_mypagesel').trigger('prev.owl')
$('#lst_mypagebg').trigger('prev.owl')
} else if (event.keyCode == 39) {
$('#lst_mypagesel').trigger('next.owl')
$('#lst_mypagebg').trigger('next.owl')
} else if (event.keyCode == 38) {
//UP
__uifxn_AppFull_MyPageSelectMessage("up");
} else if (event.keyCode == 40) {
//DOWN
__uifxn_AppFull_MyPageSelectMessage("down");
} else if (event.keyCode == 13) {
const _mpinfo = HotelTV.tvguide.program[_mmIdx].children;
// 메시지 팝업 빌드 및 화면 전환
if (HotelTV.tvguide.program[_mmIdx].children[_state.menu.main[_mmIdx].cur].type == 'message') {
let _msginf = HotelTV.message;
let _cur_msglst_idx = _state.menu.main[_mmIdx]['message']['cur'];
// 현재 선택된 메시지의 디테일 정보 가져오기
let _cur_msgnum = $($('.main>.mypage>.bg>.owl-carousel .owl-item.center #mp_msg_tblrec tbody .focus')[0]).attr('msgnum');
// 마이페이지 메뉴에서 메시지를 선택하지 않고 엔터키를 누른경우
if (!(_cur_msgnum)) {
return;
}
let _cur_msgdesc = _msginf[_cur_msgnum];
// Message card 구성
switch (_state.lang) {
case 'ko-KR':
$('.popup>.mypage>.message').css('font-family', 'Nanum Pen Script');
$('.popup>.mypage>.message>#msg_ctz').css('font-size', '34px');
$('.popup>.mypage>.message>#title').css('font-size', '50px');
break;
case 'zh-CN':
$('.popup>.mypage>.message').css('font-family', 'Ma Shan Zheng');
$('.popup>.mypage>.message>#msg_ctz').css('font-size', '34px');
$('.popup>.mypage>.message>#title').css('font-size', '50px');
break;
case 'zh-TW':
$('.popup>.mypage>.message').css('font-family', 'Ma Shan Zheng');
$('.popup>.mypage>.message>#msg_ctz').css('font-size', '34px');
$('.popup>.mypage>.message>#title').css('font-size', '50px');
break;
default:
$('.popup>.mypage>.message').css('font-family', 'Parisienne');
$('.popup>.mypage>.message>#msg_ctz').css('font-size', '32px');
break;
}
$('.popup>.mypage>.message>#title').text(_cur_msgdesc.from);
if (_cur_msgdesc.multilanguage == true) {
$('.popup>.mypage>.message>#msg_ctz').html(_cur_msgdesc.content[_state.lang].replace(/(?:\r\n|\r|\n)/g, '<br>'));
} else {
$('.popup>.mypage>.message>#msg_ctz').html(_cur_msgdesc.content.default.replace(/(?:\r\n|\r|\n)/g, '<br>'));
}
//Back button
$('.popup>.mypage>.message>#btn_back').text(_trTbl.system.btn.back[_state.lang]);
//SHOW ANIMATION
if ($('.popup>.mypage>.message').css('display') == "none") {
_state.menu.stage = "popup_message_card";
$('.main>.mypage>.slider').animate({ top: 1080, left: 0 }, 1000, function() {
$('.popup>.mypage>.message').fadeIn(500);
//메시지 읽음 처리
HotelTV.api.SetMessageStatus(_cur_msgdesc._id);
_cur_msgdesc.read = true;
$('.main>.mypage>.bg>.owl-carousel .owl-item #mp_msg_tblrec tr').filter("[msgidx='" + _cur_msglst_idx.toString() + "']").children('td#num').addClass('read');
__uifxn_AppFull_TopWidjet_BuildMsgCnt();
});
}
}
} else if (event.keyCode == 461) {
// 메인 메뉴로 귀환
$(document.activeElement).off('keydown');
$('.main .mm').show(function() {
$('#lst_mmsel').trigger('refresh.owl.carousel', [0]);
});
$('.main').animate({ top: 0, left: 0 }, 1000, () => {
$('#lst_mypagesel').off('translate.owl.carousel');
$('#lst_mypagebg').owlCarousel('destroy');
$('#lst_mypagesel').owlCarousel('destroy');
$('.main .mypage .slider #lst_mypagesel div').remove();
$('.main .mypage .bg #lst_mypagebg div').remove();
$('.main .mypage').hide();
_hndl_mpSel = null;
_hndl_mpBg = null;
_state.menu.stage = "main"
setTimeout(function() {
__uifxn_AppFull_ShowMMHotKeyBtn(true);
}, 500);
});
} else {
console.log("MYPAGE KEYEVT: Skip events::>" + event.keyCode);
}
} else if (_state.menu.stage == "popup_message_card") {
if (event.keyCode == 461) {
if ($('.popup>.mypage>.message').css('display') != "none") {
$('.popup>.mypage>.message').fadeOut(500, function() {
_state.menu.stage = "mypage";
$('.main>.mypage>.slider').animate({ top: 864, left: 0 }, 1000)
});
}
} else {
console.log("POPUP MESSAGE CARD KEYEVT: Skip events::>" + event.keyCode);
}
} else {
console.log("INVALID MYPAGE SUBMENU STAGE::>" + _state.menu.stage);
}
});
_state.menu.stage = "mypage";
});
$('#lst_mypagesel').on('translate.owl.carousel', function(event) {
// 메뉴 셀렉터 좌/우 헨들링 및 이펙트
let idx = 0;
if (typeof event.item != 'undefined') {
idx = event.item.index;
} else {
idx = $('.main .mypage .slider .owl-item.active.center').index();
}
console.log("MYPAGE EVT(TRANSLATED) IDX::>" + idx);
if ($('.main .mypage .slider .owl-item').eq(idx).children('.item').length == 1) {
let _mp_sm = $('.main .mypage .slider .owl-item').eq(idx).children('.item')[0].id;
if (_mp_sm == "mpsel_accomodation") {
// MYPAGE서브 메뉴 인덱스 갱신
_state.menu.main[_mmIdx].cur = 'accomodation';
} else if (_mp_sm == "mpsel_message") {
let __curMsgDspIdx = 0;
// MYPAGE서브 메뉴 인덱스 갱신
_state.menu.main[_mmIdx].cur = 'message';
// 메시지 포커싱
if ('message' in Object.keys(_state.menu.main[_mmIdx])) {
__curMsgDspIdx = _state.menu.main[_mmIdx].message.cur;
} else {
_state.menu.main[_mmIdx]['message'] = {
"cnt": Object.keys(_msg).length,
"cur": __curMsgDspIdx,
"prev": null,
}
}
$('.main>.mypage>.bg>.owl-carousel .owl-item #mp_msg_tblrec tr').removeClass('focus');
$('.main>.mypage>.bg>.owl-carousel .owl-item #mp_msg_tblrec tr').filter("[msgidx='" + __curMsgDspIdx + "']").addClass('focus');
}
console.log("MYPAGE EVT(TRANSLATED) MYPAGE MENU::>" + _state.menu.main[_mmIdx].cur);
}
$('.main .mypage .slider .owl-item.focus').removeClass('focus');
$('.main .mypage .slider .owl-item.unfocus').removeClass('unfocus');
$('.main .mypage .slider .owl-item').eq(idx).addClass('focus');
$('.main .mypage .slider .owl-item').eq(idx - 1).addClass('unfocus');
$('.main .mypage .slider .owl-item').eq(idx + 1).addClass('unfocus');
});
});
}
/**
* HotelTV UI[AppFull] Wrapper Function::> request tv channel function
*/
function __uifxn_AppFull_TVRequestChannel() {
const _state = HotelTV.state;
const _trTbl = HotelTV.translation;
const _mmIdx_tv = _state.menu.main.cur;
const _tvCtgIdx = _state.menu.main[_mmIdx_tv].cur;
const _tvChIdx = _state.menu.main[_mmIdx_tv][_tvCtgIdx].cur;
const _program = HotelTV.tvguide.program;
const _tvProg = _program[_mmIdx_tv].categories;
const _tvChInfo = _tvProg[_tvCtgIdx].channels[_tvChIdx];
let _need_to_changeTVChannel = false;
let _tm_diff_ms = 0;
if (_lastTm.tvchannel_changed == null) {
_lastTm.tvchannel_changed = new Date();
_need_to_changeTVChannel = true;
} else {
let _tm_cur = new Date();
_tm_diff_ms = Math.floor(_tm_cur.getTime() - _lastTm.tvchannel_changed.getTime());
//마지막 TV채널 변경 시간 갱신
_lastTm.tvchannel_changed = _tm_cur;
if (_tm_diff_ms > 200) {
_need_to_changeTVChannel = true;
}
}
if (_need_to_changeTVChannel == true) {
console.log(`CHANGE::TVCTG[${_tvProg[_tvCtgIdx].name}]` +
` CUR CH IDX::>${_tvChIdx} EPGID: ${_tvChInfo.epg_id} URL::>${_tvChInfo.url} TMDIFF::>${_tm_diff_ms}`);
//TODO: 아래 실제 채널 셋업 부분 주석처리 되어 있는데, IP와 RF모두 처리 할 수 있도록 구현할것
//let _uri_stream = _tvChInfo.url.split('://@')[1];
//let _typ_proto = _tvChInfo.url.split('://@')[0];
//let _uri_ip = _uri_stream.split(':')[0];
//let _uri_port = _uri_stream.split(':')[1];
//console.log(`ip = ${_uri_ip} port=${_uri_port} protocol=${_typ_proto}`);
//HotelTV.hcap.ChannelSetup("ip", { "ip": _uri_ip, "port": Number(_uri_port), "ptype": _typ_proto });
// {
// let min = Math.ceil(0);
// let max = Math.floor(16);
// let _major = Math.floor(Math.random() * (max - min + 1)) + min;
// console.log("Major=5 minor=" + _major);
// HotelTV.hcap.ChannelSetup("rf_analog_ntsc", { "major": _major, "minor": 0 });
// }
} else {
console.log(`SKIPPED::TVCTG[${_tvProg[_tvCtgIdx].name}]` +
` CUR CH IDX::>${_tvChIdx} EPGID: ${_tvChInfo.epg_id} URL::>${_tvChInfo.url} TMDIFF::>${_tm_diff_ms}`);
}
}
/**
* HotelTV UI[AppFull] Wrapper Function::> update tv channel list within selected tv category
* @param {string} _action parameter
*/
function __uifxn_AppFull_TVUpdateChList(_action) {
const _state = HotelTV.state;
const _mmIdx_tv = _state.menu.main.cur;
const _tvCtgIdx = _state.menu.main[_mmIdx_tv].cur;
const _tvChIdx = _state.menu.main[_mmIdx_tv][_tvCtgIdx].cur; //프로파일 상의 채널 인덱스(문자열)
let tv_chElIdx = Number(_tvChIdx) - 1; //엘리멘트 인덱스(0베이스)
//CENTER로 마킹된 엘리멘트 가져오기
let _hndlOwlCtrEl = $('.main .tv .bg .owl-carousel .owl-stage-outer .owl-item.center');
if (_hndlOwlCtrEl.length == 1) {
//현재 ACTIVATED(CENTER)된 OWL로부터 tvctgfrm_xxx과 같은 아이디 가져오기
let _targetChListId = $(_hndlOwlCtrEl.find(".item")).attr('id');
//_targetChListId는 tvctgfrm_xxxx와 같은 형식임
let _el_target = $('#' + _targetChListId + ' .tvctg_chlist');
if (_action == "on_load") {
if (_el_target.find('.focused').length == 0) {
_el_target.stop().animate({ scrollTop: ((tv_chElIdx - 2) * 120).toString() }, 500, function() {
__uifxn_AppFull_TVRequestChannel();
});
_el_target.each(function(index, item) {
$($(item).children()[tv_chElIdx]).addClass("focused");
});
_state.menu.stage = "tvCtgShow";
console.log("1st time ....");
}
} else if (_action == "ch_up") {
if ((tv_chElIdx >= 2) && (tv_chElIdx < (Number(_state.menu.main[_mmIdx_tv][_tvCtgIdx].cnt) - 3))) {
_el_target.stop().animate({ scrollTop: ((tv_chElIdx - 2) * 120).toString() }, 500, function() {
__uifxn_AppFull_TVRequestChannel();
});
} else {
__uifxn_AppFull_TVRequestChannel();
}
_el_target.each(function(index, item) {
$($(item).children()[tv_chElIdx + 1]).removeClass("focused");
$($(item).children()[tv_chElIdx]).addClass("focused");
});
} else if (_action == "ch_down") {
if ((tv_chElIdx > 2) && (tv_chElIdx < (Number(_state.menu.main[_mmIdx_tv][_tvCtgIdx].cnt) - 2))) {
_el_target.stop().animate({ scrollTop: ((tv_chElIdx - 2) * 120).toString() }, 500, function() {
__uifxn_AppFull_TVRequestChannel();
});
} else {
__uifxn_AppFull_TVRequestChannel();
}
_el_target.each(function(index, item) {
$($(item).children()[tv_chElIdx - 1]).removeClass("focused");
$($(item).children()[tv_chElIdx]).addClass("focused");
});
}
} else {
console.log("ERROR::> No centered Item");
}
}
/**
* HotelTV UI[AppFull] Wrapper Function::> Buildup sub menu and main bg
*/
function __uifxn_AppFull_Update_CtzThumbnail() {
let _state = HotelTV.state;
let _mmIdx = _state.menu.main.cur;
let _smIdx = _state.menu.main[_mmIdx].cur;
if (_state.menu.main[_mmIdx][_smIdx] && _state.menu.main[_mmIdx][_smIdx].cur) {
let _ctzidx = _state.menu.main[_mmIdx][_smIdx].cur;
let _program = HotelTV.tvguide.program;
let _ctzinfo = _program[_mmIdx].children[_smIdx].children;
if (_state.menu.main[_mmIdx][_smIdx].thumbimg[_ctzidx].idx < _state.menu.main[_mmIdx][_smIdx].thumbimg[_ctzidx].cnt) _state.menu.main[_mmIdx][_smIdx].thumbimg[_ctzidx].idx++;
else _state.menu.main[_mmIdx][_smIdx].thumbimg[_ctzidx].idx = 1;
let _img_ctz_thumbnail = $('.main .ctzgen .bg .owl-carousel .owl-item.active .ctz_desc_frame #ctz_thumbnail img');
_img_ctz_thumbnail.fadeOut(1000, function() {
_img_ctz_thumbnail.attr({
src: _ctzinfo[_ctzidx].thumbnails.files[_state.lang][_state.menu.main[_mmIdx][_smIdx].thumbimg[_ctzidx].idx].download
});
}).fadeIn(1000);
//console.log("CTZ(THUMBNAIL) UPDATED::> " + _state.menu.main[_mmIdx][_smIdx].thumbimg[_ctzidx].idx);
}
}
/**
* HotelTV UI[AppFull] Wrapper Function::> Buildup sub menu and main bg
*/
function __uifxn_AppFull_BldPage_CtzGeneral() {
let _trTbl = HotelTV.translation;
let _state = HotelTV.state;
let _mmIdx = _state.menu.main.cur;
let _smIdx = _state.menu.main[_mmIdx].cur;
let _program = HotelTV.tvguide.program;
let _ctzinfo = _program[_mmIdx].children[_smIdx].children;
if (!(_smIdx in _state.menu.main[_mmIdx])) {
_state.menu.main[_mmIdx][_smIdx] = {
'cnt': 0,
'cur': null,
'prev': null,
'thumbimg': {}
};
_state.menu.main[_mmIdx][_smIdx].cnt = _ctzinfo.length;
}
// UI State Flag 설정
_state.menu.stage = "preparing_ctz_general";
if (_state.menu.main[_mmIdx][_smIdx].cur == null) {
_state.menu.main[_mmIdx][_smIdx].cur = Object.keys(_ctzinfo)[0];
}
// 컨텐트 매뉴 백그라운드 이미지 노드를 동적으로 구성
let _div_ctzgen_bglist = document.querySelector('#lst_ctzgenbg');
for (let _ctzidx = 1; _ctzidx <= _ctzinfo.length; _ctzidx++) {
let _div_ctz_item = document.createElement('div');
let _sz_styleOpt = null;
_div_ctz_item.className = 'item';
_div_ctz_item.id = _ctzinfo[_ctzidx].id;
_div_ctz_item.setAttribute("cgzgenid", _ctzidx);
_sz_styleOpt = "--bg_noplay: url(" + _ctzinfo[_ctzidx].background.file.download + "); ";
_sz_styleOpt += "background-repeat: no-repeat; background-position: center bottom; background-size: 100% 100%; ";
_div_ctz_item.setAttribute("style", _sz_styleOpt);
// 컨텐트 DESCRIPTION용 DIV 삽입
let _div_ctz_frame = document.createElement('div');
_div_ctz_frame.setAttribute("class", "ctz_desc_frame");
// 컨텐트 타이틀 삽입
let _div_ctz_title = document.createElement('div');
_div_ctz_title.setAttribute("id", "ctz_title");
_div_ctz_title.textContent = _ctzinfo[_ctzidx].title[_state.lang];
_div_ctz_frame.appendChild(_div_ctz_title);
// 컨텐트 썸네일 삽입
let _div_ctz_thumbnail = document.createElement('div');
_div_ctz_thumbnail.setAttribute("id", "ctz_thumbnail");
// if (_ctzinfo[_ctzidx].thumbnails.interval > 0) {
// let _ul_ctz_thumbnail = document.createElement('ul');
// for (_tmbidx = 1; _tmbidx <= _ctzinfo[_ctzidx].thumbnails.files[_state.lang].length; _tmbidx++) {
// let _ui_ctz_thumbnail = document.createElement('li');
// let _img_ctz_thumbnail = document.createElement('img');
// _img_ctz_thumbnail.src = _ctzinfo[_ctzidx].thumbnails.files[_state.lang][_tmbidx].download;
// _ui_ctz_thumbnail.appendChild(_img_ctz_thumbnail);
// _ul_ctz_thumbnail.appendChild(_ui_ctz_thumbnail);
// }
// _div_ctz_thumbnail.appendChild(_ul_ctz_thumbnail);
// } else {
// _sz_styleOpt = "background-image: url(" + _ctzinfo[_ctzidx].thumbnails.files[_state.lang][1].download + "); ";
// _sz_styleOpt += "background-repeat: no-repeat; background-position: left center; background-size: contain; ";
// _div_ctz_thumbnail.setAttribute("style", _sz_styleOpt);
// }
// _sz_styleOpt = "background-image: url(" + _ctzinfo[_ctzidx].thumbnails.files[_state.lang][1].download + "); ";
// _sz_styleOpt += "background-repeat: no-repeat; background-position: left center; background-size: contain; ";
// _div_ctz_thumbnail.setAttribute("style", _sz_styleOpt);
let _img_ctz_thumbnail = document.createElement('img');
_img_ctz_thumbnail.src = _ctzinfo[_ctzidx].thumbnails.files[_state.lang][1].download;
_div_ctz_thumbnail.appendChild(_img_ctz_thumbnail);
_div_ctz_frame.appendChild(_div_ctz_thumbnail);
// 썸네일 에니메이션 관리용 맴버 추가 및 초기화
_state.menu.main[_mmIdx][_smIdx].thumbimg[_ctzidx] = { "cnt": _ctzinfo[_ctzidx].thumbnails.files[_state.lang].length, "idx": 1 };
// 컨텐트 설명 삽입
let _div_ctz_desc = document.createElement('div');
_div_ctz_desc.setAttribute("id", "ctz_description");
_div_ctz_desc.innerHTML = "<p>" + _ctzinfo[_ctzidx].description[_state.lang].replace(/(?:\r\n|\r|\n)/g, '<br>') + "</p>";
_div_ctz_frame.appendChild(_div_ctz_desc);
_div_ctz_item.appendChild(_div_ctz_frame);
// 동영상이 있는 경우, PLAY안내 버튼 노출
if (_ctzinfo[_ctzidx].video.enable == true && _ctzinfo[_ctzidx].video.files[_state.lang]) {
let _div_ctz_mvctrl = document.createElement('div');
_div_ctz_mvctrl.setAttribute("class", "ctz_mv_ctrl");
_div_ctz_mvctrl.setAttribute("video_url", _ctzinfo[_ctzidx].video.files[_state.lang].download);
_sz_styleOpt = '--playmsg: "' + _trTbl.ui.player.watch_movie[_state.lang] + '";';
_sz_styleOpt += '--stopmsg: "' + _trTbl.ui.player.stop_movie[_state.lang] + '";';
_div_ctz_mvctrl.setAttribute("style", _sz_styleOpt);
_div_ctz_item.appendChild(_div_ctz_mvctrl);
}
_div_ctzgen_bglist.appendChild(_div_ctz_item);
}
_hndl_ctzGenBg = $('#lst_ctzgenbg');
_hndl_ctzGenBg.owlCarousel({
center: false,
items: 1, //Number of Items on Screen what you want
loop: false,
margin: 0,
smartSpeed: 0,
lazyLoad: true,
mouseDrag: false,
touchDrag: false,
pullDrag: false,
freeDrag: false,
startPosition: Number(_state.menu.main[_mmIdx][_smIdx].cur) - 1,
});
//서브 페이지->콘텐트 페이지 화면 전환
$('.main .ctzgen').show(function() {
$('.main .ctzgen .bg').show(function() {
$('.main').animate({ top: -2160, left: 0 }, 1000, function() {
$('.main .sub').fadeOut(600);
//$('#lst_ctzgenbg').trigger('translate.owl.carousel', [0]);
$('#lst_ctzgenbg').trigger('translate.owl.carousel', [0, 500, true]);
_state.menu.stage = "ctzgen";
});
});
});
$('#lst_ctzgenbg').on('change.owl.carousel', function(event) {
// Update HotelTV sub menu status
let _state = HotelTV.state;
let _mmIdx = _state.menu.main.cur;
let _smIdx = _state.menu.main[_mmIdx].cur;
let _program = HotelTV.tvguide.program;
let _ctzinfo = _program[_mmIdx].children[_smIdx].children;
_state.menu.main[_mmIdx][_smIdx].prev = Object.keys(_ctzinfo)[event.page.index];
});
$('#lst_ctzgenbg').on('changed.owl.carousel', function(event) {
// Update HotelTV sub menu status
let _state = HotelTV.state;
let _mmIdx = _state.menu.main.cur;
let _smIdx = _state.menu.main[_mmIdx].cur;
let _program = HotelTV.tvguide.program;
let _ctzinfo = _program[_mmIdx].children[_smIdx].children;
_state.menu.main[_mmIdx][_smIdx].cur = Object.keys(_ctzinfo)[event.page.index];
if (_ctzinfo[_state.menu.main[_mmIdx][_smIdx].cur].thumbnails.interval > 0 && _ctzinfo[_state.menu.main[_mmIdx][_smIdx].cur].thumbnails.files[_state.lang].length > 1) {
if (_hndl_tmrCtzThumbAni != null) {
clearInterval(_hndl_tmrCtzThumbAni);
_hndl_tmrCtzThumbAni = null;
console.log("TMR(CTZ ANI)::>Destoried...");
}
_hndl_tmrCtzThumbAni = setInterval(__uifxn_AppFull_Update_CtzThumbnail, Number(_ctzinfo[_state.menu.main[_mmIdx][_smIdx].cur].thumbnails.interval) * 1000);
console.log("TMR::>Created...");
} else {
if (_hndl_tmrCtzThumbAni != null) {
clearInterval(_hndl_tmrCtzThumbAni);
_hndl_tmrCtzThumbAni = null;
console.log("TMR(CTZ ANI)::>Destoried...");
}
}
console.log("CTZ(GEN) IDX::>" + _state.menu.main[_mmIdx][_smIdx].cur);
});
$('#lst_ctzgenbg').on('translate.owl.carousel', function(event) {
// 메뉴 셀렉터 좌/우 헨들링 및 이펙트
let idx = 0;
if (typeof event.item != 'undefined') {
idx = event.item.index;
} else {
idx = $('.main .ctzgen .bg .owl-item.active').index();
}
if ($('.main .ctzgen .bg .owl-item').eq(idx).hasClass('movieplay') == true) {
if ($('.owl-theme .owl-nav.disabled+.owl-dots').css('display') != 'none') {
$('.owl-theme .owl-nav.disabled+.owl-dots').fadeOut(500);
}
} else {
if ($('.owl-theme .owl-nav.disabled+.owl-dots').css('display') == 'none') {
$('.owl-theme .owl-nav.disabled+.owl-dots').fadeIn(500);
}
}
});
}
/**
* HotelTV UI[AppFull] Wrapper Function::> Buildup sub menu and main bg
*/
function __uifxn_AppFull_BldPage_SubGeneral() {
let _trTbl = HotelTV.translation;
let _state = HotelTV.state;
let _mmIdx = _state.menu.main.cur;
let _program = HotelTV.tvguide.program;
let _sminfo = _program[_mmIdx].children;
if (!(_mmIdx in _state.menu.main)) {
_state.menu.main[_mmIdx] = {
'cnt': 0,
'cur': null,
'prev': null,
};
_state.menu.main[_mmIdx].cnt = _sminfo.length;
}
// 초기 메인 메뉴 KEY설정
_state.menu.stage = "preparing_sub";
if (_state.menu.main[_mmIdx].cur == null) {
_state.menu.main[_mmIdx].cur = Object.keys(_sminfo)[0];
}
// 서브 메뉴 셀렉터 노드를 동적으로 구성
let _div_sm_slist = document.querySelector('#lst_smsel');
for (let _idx = 1; _idx <= _sminfo.length; _idx++) {
let _div_sm_item = document.createElement('div');
_div_sm_item.className = 'item';
_div_sm_item.id = _sminfo[_idx].id;
_div_sm_item.setAttribute("smid", _idx);
// 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];
// Append Sub elements::icon
let _sm_item_icon = document.createElement('div');
_sm_item_icon.setAttribute("id", "sm_item_icon");
let _sz_styleOpt = "--icon_unfocus: url(" + _sminfo[_idx].unfocusIcon.file.download + "); ";
_sz_styleOpt += "--icon_focus: url(" + _sminfo[_idx].focusIcon.file.download + "); ";
//_sz_styleOpt += "background-repeat: no-repeat; background-position: center bottom; background-size: 100% 100%; ";
_sz_styleOpt += "background-repeat: no-repeat; background-position: center bottom;";
_sm_item_icon.setAttribute("style", _sz_styleOpt);
_div_sm_item.appendChild(_sm_item_icon);
_div_sm_item.appendChild(_sm_item_title);
_div_sm_slist.appendChild(_div_sm_item);
}
// 서브 메뉴 백그라운드 이미지 노드를 동적으로 구성
let _div_sm_bglist = document.querySelector('#lst_smbg');
for (let _idx = 1; _idx <= _sminfo.length; _idx++) {
let _div_sm_item = document.createElement('div');
let _sz_styleOpt = null;
_div_sm_item.className = 'item';
_div_sm_item.id = _sminfo[_idx].id;
_div_sm_item.setAttribute("smid", _idx);
_sz_styleOpt = "background-image: url(" + _sminfo[_idx].background.file.download + "); ";
_sz_styleOpt += "background-repeat: no-repeat; background-position: center center; background-size: 100% 100%; ";
_div_sm_item.setAttribute("style", _sz_styleOpt);
//해당 서버메뉴가 하위에 콘텐트를 가지고 있는 경우
if (_sminfo[_idx].type.toLowerCase() == 'menu') {
// 컨텐트 썸네일 베경 화면에 삽입
let _div_sm_ctz_frame = document.createElement('div');
_div_sm_ctz_frame.setAttribute("class", "bg_ctz_thumb_frame");
// 컨텐트 썸네일 타이틀(신규 콘텐트)문구 삽입
let _div_sm_ctz_title = document.createElement('div');
_div_sm_ctz_title.setAttribute("id", "bg_ctz_thumb_title");
_div_sm_ctz_title.textContent = _trTbl.ui.misc.title.new_ctz[_state.lang];
_div_sm_ctz_frame.appendChild(_div_sm_ctz_title);
let _ctz_info = _sminfo[_idx].children;
for (let _ctzidx = 1; _ctzidx <= _sminfo[_idx].children.length; _ctzidx++) {
if (Number(_ctzidx) < 4) {
let _div_sm_ctz_item = document.createElement('div');
_div_sm_ctz_item.setAttribute("id", "bg_ctz_thumb_item");
// 해당 서브메뉴 아이탬의 하위 콘텐트들의 첫 썸네일 이미지
_sz_styleOpt = "background-image: url(" + _ctz_info[_ctzidx].thumbnails.files[_state.lang][1].download + "); ";
_sz_styleOpt += "background-repeat: no-repeat; background-position: center center; background-size: 100% 100%; ";
_sz_styleOpt += "background-color: rgba(0,0,0,0.4)";
_div_sm_ctz_item.setAttribute("style", _sz_styleOpt);
_div_sm_ctz_item.textContent = _ctz_info[_ctzidx].title[_state.lang];
_div_sm_ctz_frame.appendChild(_div_sm_ctz_item);
}
}
// 추가 콘텐트 갯수 표시
if (_ctz_info.length > 3) {
let _div_sm_ctz_notice = document.createElement('div');
_div_sm_ctz_notice.setAttribute("id", "bg_ctz_thumb_morenotice");
let _remain_ctz_cnt = _ctz_info.length - 3;
let _str_remain_ctz_cnt = _trTbl.ui.submenu.info.remain_ctz_cnt;
_div_sm_ctz_notice.textContent = _str_remain_ctz_cnt[_state.lang].replace('__CTZCNT', _remain_ctz_cnt);
_div_sm_ctz_frame.appendChild(_div_sm_ctz_notice);
}
_div_sm_item.appendChild(_div_sm_ctz_frame);
//Set Attribute
_div_sm_item.setAttribute("ctzUse", true);
} else {
_div_sm_item.setAttribute("ctzUse", false);
//contents_use가 1이 아닌경우, 이에 대한 페이지 활용 아이디어 필요
}
_div_sm_bglist.appendChild(_div_sm_item);
}
_hndl_smBg = $('#lst_smbg');
_hndl_smBg.owlCarousel({
center: true,
items: 1, //Number of Items on Screen what you want
loop: true,
margin: 0,
smartSpeed: 1000,
lazyLoad: true,
mouseDrag: false,
touchDrag: false,
pullDrag: false,
freeDrag: false,
startPosition: (Number(_state.menu.main[_mmIdx].cur) - 1),
});
$('.main .sub').show(function() {
$('.main .mm').fadeOut(800);
});
_hndl_smSel = $('#lst_smsel');
_hndl_smSel.owlCarousel({
center: true,
items: 3, //Number of Items on Screen what you want
loop: true,
margin: 0,
smartSpeed: 0,
autoWidth: false,
mouseDrag: false,
touchDrag: false,
pullDrag: false,
freeDrag: false,
startPosition: (Number(_state.menu.main[_mmIdx].cur) - 1),
});
//메인 페이지->서브 페이지 화면 전환
$('.main .sub .slider').show(function() {
$('.main').animate({ top: -1080, left: 0 }, 1000, function() {
$('.main .sub .slider .owl-item').addClass('unfocus');
$('#lst_smsel').trigger("to.owl.carousel", [(Number(_state.menu.main[_mmIdx].cur) - 1), 10, true]);
$('#lst_smsel').trigger('translate.owl.carousel', [0, 500, true]);
$(document.activeElement).keydown(function(event) { //attach event listener
if (_state.menu.stage == "sub") {
if (event.keyCode == 37) {
$('#lst_smsel').trigger('prev.owl', 700);
} else if (event.keyCode == 39) {
$('#lst_smsel').trigger('next.owl', 700);
} else if (event.keyCode == 13) {
// 콘텐트 리스트 화면 빌드 및 화면 전환
let _program = HotelTV.tvguide.program;
let _mmIdx = _state.menu.main.cur;
if (_program[_mmIdx].type.toLowerCase() == "normal") {
if (_program[_mmIdx].style.toLowerCase() == "none") {
console.log("Invalid options");
} else if (_program[_mmIdx].style.toLowerCase() == "content") {
console.log("Invalid options");
} else if (_program[_mmIdx].style.toLowerCase() == "submenu") {
__uifxn_AppFull_BldPage_CtzGeneral();
}
}
} else if (event.keyCode == 461) {
// 컨텐트 폼의 썸네일 에니메이션용 타이머 제거
if (_hndl_tmrCtzThumbAni != null) {
clearInterval(_hndl_tmrCtzThumbAni);
_hndl_tmrCtzThumbAni = null;
console.log("TMR(CTZ ANI)::>Destoried...");
}
// 메인 메뉴로 귀환
$(document.activeElement).off('keydown');
$('.main .mm').show(function() {
$('#lst_mmsel').trigger('translate.owl.carousel', [0]);
});
$('.main').animate({ top: 0, left: 0 }, 1000, () => {
$('#lst_smsel').off('refresh.owl.carousel');
$('#lst_smsel').off('change.owl.carousel');
$('#lst_smsel').off('changed.owl.carousel');
$('#lst_smsel').off('translate.owl.carousel');
$('#lst_smbg').owlCarousel('destroy');
$('#lst_smsel').owlCarousel('destroy');
$('.main .sub .slider #lst_smsel div').remove();
$('.main .sub .bg #lst_smbg div').remove();
$('.main .sub').hide();
_hndl_smSel = null;
_hndl_smBg = null;
_state.menu.stage = "main"
setTimeout(function() {
__uifxn_AppFull_ShowMMHotKeyBtn(true);
}, 500);
});
}
} else if (_state.menu.stage == "ctzgen") {
if (event.keyCode == 37) {
$('#lst_ctzgenbg').trigger('prev.owl', 700);
} else if (event.keyCode == 39) {
$('#lst_ctzgenbg').trigger('next.owl', 700);
} else if (event.keyCode == 461) {
$('.main .sub').show();
$('.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 = "sub";
$('#lst_smsel').trigger('translate.owl.carousel', [0]);
});
} else if (event.keyCode == 415) {
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) {
HotelTV.hcap.MediaPlay(
HotelTV.api.GetBaseUrl() + uri_video,
"",
"video/mp4",
1,
() => {
console.log("STARTUP Done CB.");
},
() => {
console.log("STARTUP Fail CB.");
}
);
}
}
} else if (event.keyCode == 413) {
if (_state.media.playing == true) {
_state.media.playing = false;
HotelTV.hcap.MediaStop(
function() {
$('.main .ctzgen .bg .owl-carousel .owl-stage-outer .owl-stage .owl-item').removeClass('movieplay');
$('.owl-theme .owl-nav.disabled+.owl-dots').fadeIn(1000);
},
function() {
$('.main .ctzgen .bg .owl-carousel .owl-stage-outer .owl-stage .owl-item').removeClass('movieplay');
$('.owl-theme .owl-nav.disabled+.owl-dots').fadeIn(1000);
});
}
} else {
console.log('CTZ MENU: KEY::> ' + event.keyCode);
}
} else {
console.log("SUBMENU KEYEVT: Skip events");
}
});
_state.menu.stage = "sub";
});
});
$('#lst_smsel').on('change.owl.carousel', function(event) {
// Update HotelTV sub menu status
let _state = HotelTV.state;
let _mmIdx = _state.menu.main.cur;
let _sminfo = HotelTV.tvguide.program[_mmIdx].children;
_state.menu.main[_mmIdx].prev = Object.keys(_sminfo)[event.page.index];
});
$('#lst_smsel').on('changed.owl.carousel', function(event) {
// Update HotelTV sub menu status
let _state = HotelTV.state;
let _mmIdx = _state.menu.main.cur;
let _sminfo = HotelTV.tvguide.program[_mmIdx].children;
_state.menu.main[_mmIdx].cur = Object.keys(_sminfo)[event.page.index];
//console.log("SUB IDX::>" + _state.menu.main[_mmIdx].cur);
__uifxn_AppFull_OnKeyDnEvt_SmSel(event);
});
$('#lst_smsel').on('translate.owl.carousel', function(event) {
// 메뉴 셀렉터 좌/우 헨들링 및 이펙트
let idx = 0;
if (typeof event.item != 'undefined') {
idx = event.item.index;
} else {
idx = $('.main .sub .slider .owl-item.active.center').index();
}
console.log("SUB IDX4::>" + idx);
$('.main .sub .slider .owl-item.focus').addClass('unfocus');
$('.main .sub .slider .owl-item.focus').removeClass('focus');
$('.main .sub .slider .owl-item').eq(idx).addClass('focus');
$('.main .sub .slider .owl-item').eq(idx).removeClass('unfocus');
});
}
/**
* HotelTV UI[AppFull] Wrapper Function::> Buildup sub menu and main bg
*/
function __uifxn_AppFull_BldPage_SubTV() {
let _state = HotelTV.state;
let _mmIdx = _state.menu.main.cur;
let _trTbl = HotelTV.translation;
let _program = HotelTV.tvguide.program;
let _tvProg = _program[_mmIdx].categories;
if (!(_mmIdx in _state.menu.main)) {
_state.menu.main[_mmIdx] = {
'cnt': 0,
'cur': null, //현재 TV카테고리
'prev': null, //마지막 TV카테고리
};
// TV Program category 개수
_state.menu.main[_mmIdx].cnt = _tvProg.length;
}
// 초기 메인 메뉴 KEY설정
_state.menu.stage = "preparing_tv";
if (_state.menu.main[_mmIdx].cur == null) {
_state.menu.main[_mmIdx].cur = Object.keys(_tvProg)[0];
// 각 채널 카테고리별 채널 개수 및 이전 시청 채널 과 현재 시청 채널 정보 초기화
//for (let _tvCtg_item in _tvProg) {
for (let _i = 1; _i <= _tvProg.length; _i++) {
_state.menu.main[_mmIdx][_i] = {
'cnt': 0,
'cur': null,
'prev': null,
};
_state.menu.main[_mmIdx][_i].cnt = _tvProg[_i].channels.length;
_state.menu.main[_mmIdx][_i].cur = Object.keys(_tvProg[_i].channels)[0];
}
}
// TV 메뉴 카테고리 노드를 동적으로 구성
let _div_tvCgh_bglist = document.querySelector('#lst_tvCtgbg');
//for (let _tvCtg_item in _tvProg) {
for (let _tvCtg_idx = 1; _tvCtg_idx <= _tvProg.length; _tvCtg_idx++) {
let _tvCtgInfo = _tvProg[_tvCtg_idx];
let _div_tvCtg_frame = document.createElement('div');
let _sz_styleOpt = null;
// TV 메뉴 카테고리 노드를 동적으로 구성
_div_tvCtg_frame.className = 'item';
_div_tvCtg_frame.id = 'tvctgfrm_' + _tvCtgInfo.name.replace(/\s/g, '').toLowerCase();
_div_tvCtg_frame.setAttribute("tvctgidx", _tvCtg_idx);
// TV 카테고리 타이틀
let _div_tvCtg_title = document.createElement('div');
_div_tvCtg_title.setAttribute("id", "tvctg_title");
_div_tvCtg_title.textContent = _trTbl.ui.tv.title.category[_tvCtgInfo.name][_state.lang];
_div_tvCtg_frame.appendChild(_div_tvCtg_title);
// ADD Upper Arrow
let _div_tvCtg_arUp = document.createElement('div');
_div_tvCtg_arUp.setAttribute("id", "tvctg_arrow_up");
_div_tvCtg_frame.appendChild(_div_tvCtg_arUp);
// TV CHANNEL LIST LIST UNDER Given TV CATEGORY
let _div_tv_chlist = document.createElement('div');
_div_tv_chlist.setAttribute("class", "tvctg_chlist");
for (let _tvCh_idx = 1; _tvCh_idx <= _tvCtgInfo.channels.length; _tvCh_idx++) {
let _tvChInfo = _tvCtgInfo.channels[_tvCh_idx];
let _div_tv_chframe = document.createElement('div');
_div_tv_chframe.setAttribute("class", "tvch_item_frame");
_div_tv_chframe.setAttribute("idx", _tvCh_idx);
let _div_tv_chepg = document.createElement('div');
_div_tv_chepg.setAttribute("class", "tvch_epg");
let _span_tv_chtitle = document.createElement('span');
_span_tv_chtitle.setAttribute("id", "tvch_epg_title");
_span_tv_chtitle.textContent = _tvChInfo.title[_state.lang];
_span_tv_chtitle.setAttribute("ch_num", "CH:" + _tvChInfo.number + "]");
_div_tv_chepg.appendChild(_span_tv_chtitle);
let _span_tv_chepginfo = document.createElement('span');
_span_tv_chepginfo.setAttribute("id", "tvch_epg_info");
_span_tv_chepginfo.setAttribute("epg_id", _tvChInfo.epg);
let _egp_prog_inf = __uifxn_AppFull_GetEpgInfoById(_tvChInfo.epg);
if (_egp_prog_inf != null) {
_span_tv_chepginfo.textContent = _egp_prog_inf.name;
}
_div_tv_chepg.appendChild(_span_tv_chepginfo);
_div_tv_chframe.appendChild(_div_tv_chepg);
let _div_tv_chlogo = document.createElement('div');
_div_tv_chlogo.setAttribute("id", "tvch_logo");
_sz_styleOpt = "background-image: url(" + _tvChInfo.logo.file.download + "); ";
_sz_styleOpt += "background-repeat: no-repeat; background-position: center center; background-size: 100%; ";
_div_tv_chlogo.setAttribute("style", _sz_styleOpt);
_div_tv_chframe.appendChild(_div_tv_chlogo);
_div_tv_chlist.appendChild(_div_tv_chframe);
}
_div_tvCtg_frame.appendChild(_div_tv_chlist);
// ADD Down Arrow
let _div_tvCtg_arDn = document.createElement('div');
_div_tvCtg_arDn.setAttribute("id", "tvctg_arrow_down");
_div_tvCtg_frame.appendChild(_div_tvCtg_arDn);
//TV 카테고리 프레임 엘리멘트에 Child엘레멘트 추가
_div_tvCgh_bglist.appendChild(_div_tvCtg_frame);
}
_hndl_tvCtg = $('#lst_tvCtgbg');
//owlCarousel을 초기화 하기 전에 등록해야할 callback 함수들
//initialized.owl.carousel같은 이벤트는 생성하기 전에 등록해야함.
//이벤트 발생 순서는 대략 아래와 같음.
//[1]change
//[2]changed
//[3]prepared
//[4]initialized
//[5]refresh
//[6]translate
_hndl_tvCtg.owlCarousel({
center: true,
items: 1, //Number of Items on Screen what you want
loop: true,
margin: 0,
nav: true,
dots: false,
smartSpeed: 100,
lazyLoad: true,
mouseDrag: false,
touchDrag: false,
pullDrag: false,
freeDrag: false,
startPosition: (Number(_state.menu.main[_mmIdx].cur) - 1),
});
$('.main .tv .bg').show(function() {
$('.main .mm').fadeOut(1000);
$('.main').animate({ top: -1080, left: 0 }, 1000, function() {
// Create Timer handle for channel guide ui show/hide
if (_hndl_tmrTvChnMngr == null) {
_hndl_tmrTvChnMngr = setInterval(__uifxn_AppFull_TVChMngrUi, 1000);
console.log("TMR::>Created...");
}
$('#lst_tvCtgbg').trigger('translated.owl.carousel', [0]);
$(document.activeElement).keydown(function(event) { //attach event listener
if (_state.menu.stage == "tvCtgShow") {
if (event.keyCode == 37) {
$('#lst_tvCtgbg').trigger('prev.owl', [1000])
} else if (event.keyCode == 39) {
$('#lst_tvCtgbg').trigger('next.owl', [1000])
} else if (event.keyCode == 38 || event.keyCode == 427) {
// 채널 리스트 아이탬 이동(UP)
let _mmIdx = _state.menu.main.cur;
let _curChCtg = _state.menu.main[_mmIdx].cur;
let _curChIdx = Number(_state.menu.main[_mmIdx][_curChCtg].cur);
if ((_curChIdx - 1) >= 1) {
_curChIdx -= 1;
_state.menu.main[_mmIdx][_curChCtg].cur = _curChIdx.toString();
console.log(`TVCTG[${_tvProg[_curChCtg].name}] CUR CH::>${_state.menu.main[_mmIdx][_curChCtg].cur}`);
__uifxn_AppFull_TVUpdateChList("ch_up");
}
} else if (event.keyCode == 40 || event.keyCode == 428) {
// 채널 리스트 아이탬 이동(DOWN)
let _mmIdx = _state.menu.main.cur;
let _curChCtg = _state.menu.main[_mmIdx].cur;
let _curChIdx = Number(_state.menu.main[_mmIdx][_curChCtg].cur);
if ((_curChIdx + 1) <= Number(_state.menu.main[_mmIdx][_curChCtg].cnt)) {
_curChIdx += 1;
_state.menu.main[_mmIdx][_curChCtg].cur = _curChIdx.toString();
console.log(`TVCTG[${_tvProg[_curChCtg].name}] CUR CH::>${_state.menu.main[_mmIdx][_curChCtg].cur}`);
__uifxn_AppFull_TVUpdateChList("ch_down");
}
} else if (event.keyCode == 13) {
// TV채널 플레이
} else if (event.keyCode == 461) {
// 현재 재생중인 TV채널 종료
HotelTV.hcap.ChannelShutDown();
if (_hndl_tmrTvChnMngr != null) {
clearInterval(_hndl_tmrTvChnMngr);
_hndl_tmrTvChnMngr = null;
console.log("TMR::>Destoried...");
}
// 메인 메뉴로 귀환
$(document.activeElement).off('keydown');
$('.main .mm').show(function() {
$('#lst_mmsel').trigger('refresh.owl.carousel', [0]);
});
$('.main').animate({ top: 0, left: 0 }, 1000, () => {
$('#lst_tvCtgbg').off('refresh.owl.carousel');
$('#lst_tvCtgbg').off('change.owl.carousel');
$('#lst_tvCtgbg').off('changed.owl.carousel');
$('#lst_tvCtgbg').off('translated.owl.carousel');
$('#lst_tvCtgbg').owlCarousel('destroy');
$('.main .tv .bg #lst_tvCtgbg div').remove();
_hndl_tvCtg = null;
_state.menu.stage = "main";
setTimeout(function() {
__uifxn_AppFull_ShowMMHotKeyBtn(true);
}, 500);
});
}
} else if (_state.menu.stage == "tvCtgHide") {
if (event.keyCode == 427) {
// 채널 리스트 아이탬 이동(UP)
let _mmIdx = _state.menu.main.cur;
let _curChCtg = _state.menu.main[_mmIdx].cur;
let _curChIdx = Number(_state.menu.main[_mmIdx][_curChCtg].cur);
if ((_curChIdx - 1) >= 1) {
_curChIdx -= 1;
_state.menu.main[_mmIdx][_curChCtg].cur = _curChIdx.toString();
console.log(`TVCTG[${_tvProg[_curChCtg].name}] CUR CH::>${_state.menu.main[_mmIdx][_curChCtg].cur}`);
__uifxn_AppFull_TVUpdateChList("ch_up");
}
} else if (event.keyCode == 428) {
// 채널 리스트 아이탬 이동(DOWN)
let _mmIdx = _state.menu.main.cur;
let _curChCtg = _state.menu.main[_mmIdx].cur;
let _curChIdx = Number(_state.menu.main[_mmIdx][_curChCtg].cur);
if ((_curChIdx + 1) <= Number(_state.menu.main[_mmIdx][_curChCtg].cnt)) {
_curChIdx += 1;
_state.menu.main[_mmIdx][_curChCtg].cur = _curChIdx.toString();
console.log(`TVCTG[${_tvProg[_curChCtg].name}] CUR CH::>${_state.menu.main[_mmIdx][_curChCtg].cur}`);
__uifxn_AppFull_TVUpdateChList("ch_down");
}
} else if (event.keyCode == 461) {
// 현재 재생중인 TV채널 종료
HotelTV.hcap.ChannelShutDown();
if (_hndl_tmrTvChnMngr != null) {
clearInterval(_hndl_tmrTvChnMngr);
_hndl_tmrTvChnMngr = null;
console.log("TMR::>Destoried...");
}
// 메인 메뉴로 귀환
$(document.activeElement).off('keydown');
$('.main .mm').show(function() {
$('#lst_mmsel').trigger('refresh.owl.carousel', [0]);
});
$('.main').animate({ top: 0, left: 0 }, 1000, () => {
$('#lst_tvCtgbg').off('refresh.owl.carousel');
$('#lst_tvCtgbg').off('change.owl.carousel');
$('#lst_tvCtgbg').off('changed.owl.carousel');
$('#lst_tvCtgbg').off('translated.owl.carousel');
$('#lst_tvCtgbg').owlCarousel('destroy');
$('.main .tv .bg #lst_tvCtgbg div').remove();
_hndl_tvCtg = null;
_state.menu.stage = "main";
setTimeout(function() {
__uifxn_AppFull_ShowMMHotKeyBtn(true);
}, 500);
});
} else {
console.log("event.keyCode::>" + event.keyCode);
}
} else {
console.log("TVMENU KEYEVT: Skip events::> Invalid menu stage:" + _state.menu.stage);
}
});
});
});
$('#lst_tvCtgbg').on('translated.owl.carousel', function(event) {
__uifxn_AppFull_TVUpdateChList("on_load");
});
$('#lst_tvCtgbg').on('changed.owl.carousel', function(event) {
// Update HotelTV sub menu status
let _state = HotelTV.state;
let _mmIdx = _state.menu.main.cur;
let _hndlOwlEl = $('.main .tv .bg .owl-carousel .owl-stage-outer .owl-item');
let _acvatedEl = null;
let _curChListEl = null;
let _curChCtg = null;
let _bHasValidData = false;
if (_hndlOwlEl) {
_acvatedEl = $(_hndlOwlEl.children()[event.item.index]);
if (_acvatedEl) {
_curChListEl = _acvatedEl.find(".tvctg_chlist");
if (_curChListEl) {
_curChCtg = _acvatedEl.attr('tvctgidx');
_bHasValidData = true;
}
}
}
if (_bHasValidData != true) {
return;
}
// 현재 채널 카테고리 인덱스 갱신
_state.menu.main[_mmIdx].prev = _state.menu.main[_mmIdx].cur;
_state.menu.main[_mmIdx].cur = _curChCtg;
console.log("CHANGED TV CATEGORY::> CURRENT TV CTG IDX::> " + _curChCtg);
__uifxn_AppFull_TVRequestChannel();
});
}
/**
* HotelTV UI[AppFull] Wrapper Function::> Bottom Guide Bar UI mngr
*/
function __uifxn_AppFull_GuideBarUiMngr() {
let _state = HotelTV.state;
let _newsInfo = HotelTV.news;
let _trTbl = HotelTV.translation;
let _tm_diff_ms = 0;
if (_lastTm.keyevt == null) {
_lastTm.keyevt = new Date();
return;
}
let _tm_cur = new Date();
_tm_diff_ms = Math.floor(_tm_cur.getTime() - _lastTm.keyevt.getTime());
//마지막 KEY 이벤트 수신 시간 갱신
//console.log(`KeyDn Event Recoreded::> ${_lastTm.keyevt} TMDiff::> ${_tm_diff_ms}`);
//
if (_state.menu.stage == "popup_message_card") {
//HIDE NEWS and USER GUIDE TIPS
if (_newsInfo == null || _newsInfo.length == 0) {
if ($('.news').css('display') != "none") {
$('.news').hide();
}
}
if ($('.guide>.tips').css('display') != "none") {
$('.guide>.tips').fadeOut(500);
}
return;
} else if (_state.menu.stage == "tvCtgHide") {
//HIDE NEWS and USER GUIDE TIPS
if (_newsInfo == null || newsInfo.length == 0) {
if ($('.news').css('display') != "none") {
$('.news').hide();
}
}
if ($('.guide>.tips').css('display') != "none") {
$('.guide>.tips').fadeOut(500);
}
}
// TV Channel UI 지속 시간 8초
if (_state.media.playing == false) {
if (_tm_diff_ms < 8000) {
//SHOW USER GUIDE TIPS
let show_stages = ["hotkey_mm_red", "hotkey_mm_green", "hotkey_mm_yellow", "hotkey_mm_blue", "main", "sub", "ctzgen", "tvCtgShow", "mypage"];
let sz_msg = null;
if (show_stages.includes(_state.menu.stage) == true) {
switch (_state.menu.stage) {
case "hotkey_mm_red":
sz_msg = _trTbl.ui.guide.navi_brochure[_state.lang];
if ($('.guide>.tips').text() != sz_msg) {
$('.guide>.tips').text(sz_msg);
}
break;
case "hotkey_mm_green":
sz_msg = _trTbl.ui.guide.navi_brochure[_state.lang];
if ($('.guide>.tips').text() != sz_msg) {
$('.guide>.tips').text(sz_msg);
}
break;
case "hotkey_mm_yellow":
sz_msg = _trTbl.ui.guide.navi_brochure[_state.lang];
if ($('.guide>.tips').text() != sz_msg) {
$('.guide>.tips').text(sz_msg);
}
break;
case "hotkey_mm_blue":
sz_msg = _trTbl.ui.guide.navi_brochure[_state.lang];
if ($('.guide>.tips').text() != sz_msg) {
$('.guide>.tips').text(sz_msg);
}
break;
case "main":
//sz_msg = _trTbl.ui.guide.navi_menu[_state.lang] || "";
sz_msg = _trTbl.ui.guide.navi_menu[_state.lang];
if ($('.guide>.tips').text() != sz_msg) {
$('.guide>.tips').text(sz_msg);
}
break;
case "sub":
sz_msg = _trTbl.ui.guide.navi_menu[_state.lang];
if ($('.guide>.tips').text() != sz_msg) {
$('.guide>.tips').text(sz_msg);
}
break;
case "ctzgen":
sz_msg = _trTbl.ui.guide.navi_ctz[_state.lang];
if ($('.guide>.tips').text() != sz_msg) {
$('.guide>.tips').text(sz_msg);
}
break;
case "tvCtgShow":
sz_msg = _trTbl.ui.guide.navi_tvchannel[_state.lang];
if ($('.guide>.tips').text() != sz_msg) {
$('.guide>.tips').text(sz_msg);
}
break;
}
if ($('.guide>.tips').css('display') == "none") {
$('.guide>.tips').fadeIn(500, function() {
//SHOW NEWS
if (_newsInfo == null || _newsInfo.length == 0) {
if ($('.news').css('display') != "none") {
$('.news').hide();
}
} else {
if ($('.news').css('display') != "none") {
if ($('.news>.newsctz #hoteltv-news-ticker').children().length > 0) {
$('.news>.newsctz #hoteltv-news-ticker').webTicker('stop');
$('.news').fadeOut(500);
}
}
}
});
}
} else {
if ($('.guide>.tips').css('display') == "block") {
$('.guide>.tips').fadeOut(500);
}
if ($('.news').css('display') != "block") {
if ($('.news>.newsctz #hoteltv-news-ticker').children().length > 0) {
$('.news>.newsctz #hoteltv-news-ticker').webTicker('stop');
$('.news').fadeOut(500);
}
}
}
} else {
//HIDE TIPS and then SHOW NEWS
if ($('.guide>.tips').css('display') == "block") {
$('.guide>.tips').fadeOut(500, function() {
if (_newsInfo == null || _newsInfo.length == 0) {
if ($('.news').css('display') != "none") {
$('.news').hide();
}
} else {
if ($('.news').css('display') != "block") {
$('.news').fadeIn(500, function() {
__uifxn_AppFull_BldNews();
$('.news>.newsctz #hoteltv-news-ticker').webTicker('cont');
});
}
}
});
} else {
if (_newsInfo == null || _newsInfo.length == 0) {
if ($('.news').css('display') != "none") {
$('.news').hide();
}
} else {
if ($('.news').css('display') != "block") {
$('.news').fadeIn(500, function() {
__uifxn_AppFull_BldNews();
$('.news>.newsctz #hoteltv-news-ticker').webTicker('cont');
});
}
}
}
}
} else {
//HIDE NEWS and USER GUIDE TIPS
if (_newsInfo == null || _newsInfo.length == 0) {
if ($('.news').css('display') != "none") {
$('.news').hide();
}
}
if ($('.guide>.tips').css('display') != "none") {
$('.guide>.tips').fadeOut(500, function() {
if (_newsInfo == null || _newsInfo.length == 0) {
if ($('.news').css('display') != "none") {
$('.news').hide();
}
} else {
if ($('.news').css('display') != "none") {
if ($('.news>.newsctz #hoteltv-news-ticker').children().length > 0) {
$('.news>.newsctz #hoteltv-news-ticker').webTicker('stop');
$('.news').fadeOut(500);
}
}
}
});
}
}
}
/**
* HotelTV UI Wrapper Function::> received event handling function
* @param {boolean} _evt event
*/
function __uifxn_AppFull_OnKeyDnEvt_MmSel(_evt) {
let _program = HotelTV.tvguide.program;
let _state = HotelTV.state;
if ((_program[(_evt.page.index + 1)].type == "weather") || (_program[(_evt.page.index + 1)].type == "flight")) {
__uifxn_AppFull_ShowMMHotKeyBtn(false);
} else {
__uifxn_AppFull_ShowMMHotKeyBtn(true);
}
//console.log(`Evnt: ${_evt.item.index} Of ${_evt.item.count} page::> ${_evt.page.index} of ${_evt.page.count}`);
//Shows Up Weather Contents
if (_program[(_evt.page.index + 1)].type == "weather") {
if ($('.main .mm .weather').css("display") == "none") {
$('.main .mm .weather').fadeIn(1000);
}
} else {
if ($('.main .mm .weather').css("display") != "none") {
$('.main .mm .weather').fadeOut(300);
}
}
//Shows Up Flight Contents
if (_program[(_evt.page.index + 1)].type == "flight") {
if ($('.main .mm .flight').css("display") == "none") {
$('.main .mm .flight').fadeIn(1000, () => {
$(document.activeElement).keydown(function(_evt) {
let _curPos = 0;
let _maxHeight = 0;
switch (_evt.keyCode) {
case 38:
_curPos = $('.main .mm .flight .departure tbody#record').scrollTop();
_maxHeight = $('.main .mm .flight .departure tbody#record')[0].scrollHeight;
_curPos = (_curPos - 50) < 0 ? 0 : (_curPos - 50);
$('.main .mm .flight tbody#record').scrollTop(_curPos);
break;
case 40:
_curPos = $('.main .mm .flight .departure tbody#record').scrollTop();
_maxHeight = $('.main .mm .flight .departure tbody#record')[0].scrollHeight;
_curPos = (_curPos + 50) > _maxHeight ? _maxHeight : (_curPos + 50);
$('.main .mm .flight tbody#record').scrollTop(_curPos);
break;
}
});
});
}
} else {
if ($('.main .mm .flight').css("display") != "none") {
if ($(".main .mm .flight tbody#record").length > 0) {
$('.main .mm .flight tbody#record').scrollTop(0);
}
$('.main .mm .flight').fadeOut(300, () => {
$(document.activeElement).off('keydown');
});
}
}
$('#lst_mmbg').trigger("to.owl.carousel", [_evt.page.index, 1000, true]);
}
/**
* HotelTV UI Wrapper Function::> Show Top Widjet Weather
* @param {boolean} _en show/hide
*/
function __uifxn_AppFull_TopWidjet_BuildWeather() {
let _weather = HotelTV.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').show();
}
/**
* HotelTV UI Wrapper Function::> Show Top Widjet Message Cnt(Unread)
* @param {boolean} _en show/hide
*/
function __uifxn_AppFull_TopWidjet_BuildMsgCnt(_en) {
let _msgCnt = 0;
const _state = HotelTV.state;
const _guest = HotelTV.guestinfo;
let _trTbl = HotelTV.translation;
const _get_unread_msgCnt = function(_object) {
let _msg_unread_cnt = 0;
for (__j = 1; __j <= _object.length; __j++) {
if (_object[__j].read == false) {
_msg_unread_cnt++;
}
}
return _msg_unread_cnt;
}
_msgCnt = _get_unread_msgCnt(HotelTV.message);
if (_msgCnt > 0) {
$('.widjet .top .message #unread_cnt').text(_msgCnt.toString());
$('.widjet .top .message').show();
} else {
$('.widjet .top .message').hide();
}
$('div#lst_mypagebg div #mp_message_title').text(_guest.name + _trTbl.ui.mypage.message.title.title[_state.lang].replace("_XX", _msgCnt.toString()));
}
/**
* HotelTV UI Wrapper Function::> Show Top Widjet Weather
* @param {boolean} _show show/hide
*/
function __uifxn_AppFull_TopWidjetShow(_show) {
if (_show == true) {
if ($('.widjet .top').css("display") == "none") {
$('.widjet .top').fadeIn(300);
}
} else {
if ($('.widjet .top').css("display") != "none") {
$('.widjet .top').fadeOut(300);
}
}
}
/**
* HotelTV UI Wrapper Function::> Build Main Menu::> Flight
*/
function __uifxn_AppFull_MM_BldFlight() {
let _flight = HotelTV.flight;
let _state = HotelTV.state;
let _trTbl = HotelTV.translation;
let _curDaTm = new Date();
const ar_tdItem = ['airline', 'flight', 'scheduled', 'origin', 'destination', 'type', 'gate', 'status']
$('.main .mm .flight .departure #title').text(_trTbl.ui.flight.title.departure[_state.lang]);
$('.main .mm .flight .arrival #title').text(_trTbl.ui.flight.title.arrival[_state.lang]);
let _tblHdr = $('.main .mm .flight table th')
for (let _i = 0; _i < _tblHdr.length; ++_i) {
if (_tblHdr[_i].id == "airline") {
_tblHdr[_i].innerText = _trTbl.ui.flight.title.airline[_state.lang];
} else if (_tblHdr[_i].id == "flight") {
_tblHdr[_i].innerText = _trTbl.ui.flight.title.flight_no[_state.lang];
} else if (_tblHdr[_i].id == "scheduled") {
_tblHdr[_i].innerText = _trTbl.ui.flight.title.scheduled[_state.lang];
} else if (_tblHdr[_i].id == "origin") {
_tblHdr[_i].innerText = _trTbl.ui.flight.title.origin[_state.lang];
} else if (_tblHdr[_i].id == "destination") {
_tblHdr[_i].innerText = _trTbl.ui.flight.title.destination[_state.lang];
} else if (_tblHdr[_i].id == "type") {
_tblHdr[_i].innerText = _trTbl.ui.flight.title.classification[_state.lang];
} else if (_tblHdr[_i].id == "gate") {
_tblHdr[_i].innerText = _trTbl.ui.flight.title.boarding_gate[_state.lang];
} else if (_tblHdr[_i].id == "status") {
_tblHdr[_i].innerText = _trTbl.ui.flight.status[_state.lang];
}
}
//Delete all table record for departure & arrival
let _el_departure_tbl_rec = document.querySelector('.main .mm .flight .departure table #record');
let _el_arrival_tbl_rec = document.querySelector('.main .mm .flight .arrival table #record');
//Delete all table record for departure & arrival
$('.main .mm .flight .departure table tr#record').remove();
$('.main .mm .flight .arrival table tr#record').remove();
for (let _i = 0; _i < _flight.count; _i++) {
let _schOrg = new Date();
let _schEdt = new Date();
let _flitem = _flight.items[_i];
//let _sTmOrg = _flitem.std.length != 4 ? null : ;
//let _sTmChanged = _flitem.etd;
if (_flitem.std.length != 4) {
console.log("Flight Schedule org time is NULL");
} else {
_schOrg.setHours(Number(_flitem.std.charAt(0) + _flitem.std.charAt(1)));
_schOrg.setMinutes(Number(_flitem.std.charAt(2) + _flitem.std.charAt(3)));
}
if (_flitem.std.length != 4) {
console.log("Flight Schedule edited time is NULL");
} else {
_schEdt.setHours(Number(_flitem.std.charAt(0) + _flitem.std.charAt(1)));
_schEdt.setMinutes(Number(_flitem.std.charAt(2) + _flitem.std.charAt(3)));
}
let diffMs = (_schOrg - _curDaTm); // milliseconds between now & Christmas
// let diffDays = Math.floor(diffMs / 86400000); // days
// let diffHrs = Math.floor((diffMs % 86400000) / 3600000); // hours
// let diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000); // minutes
// console.log(diffDays + " days, " + diffHrs + " hours, " + diffMins + " minutes");
let diffMins = Math.round(diffMs / 60000);
//console.log("TDiff::> " + diffMins);
if ((-60 < diffMins) && (diffMins < 120)) {
if (_flitem.io == "O") {
let _el_tr = document.createElement('tr');
_el_tr.setAttribute("id", "record");
ar_tdItem.forEach(_itm => {
let _el_td = document.createElement('td');
_el_td.setAttribute("id", _itm);
if (_itm == "airline") {
_el_td.innerText = HotelTV.ui_utils.Get_Airline(_trTbl.ui.flight.airlines, _flitem.airline, _state.lang);
} else if (_itm == "flight") {
_el_td.innerText = _flitem.airFln;
} else if (_itm == "scheduled") {
_el_td.innerText = _flitem.std.charAt(0) + _flitem.std.charAt(1) + ":" + _flitem.std.charAt(2) + _flitem.std.charAt(3) + " - ";
_el_td.innerText += _flitem.etd.charAt(0) + _flitem.etd.charAt(1) + ":" + _flitem.etd.charAt(2) + _flitem.etd.charAt(3);
} else if (_itm == "origin") {
_el_td.innerText = HotelTV.ui_utils.Get_Airport(_trTbl.ui.flight.city, _flitem.boarding, _state.lang);
} else if (_itm == "destination") {
_el_td.innerText = HotelTV.ui_utils.Get_Airport(_trTbl.ui.flight.city, _flitem.arrived, _state.lang);
} else if (_itm == "type") {
_el_td.innerText = _trTbl.ui.flight.line[_flitem.line][_state.lang];
} else if (_itm == "gate") {
_el_td.innerText = _flitem.gate;
} else if (_itm == "status") {
_el_td.innerText = HotelTV.ui_utils.Get_FlightStatus(_trTbl.ui.flight.result, _flitem.rmk, _state.lang);
}
_el_tr.appendChild(_el_td);
});
_el_departure_tbl_rec.appendChild(_el_tr);
} else {
let _el_tr = document.createElement('tr');
_el_tr.setAttribute("id", "record");
ar_tdItem.forEach(_itm => {
let _el_td = document.createElement('td');
_el_td.setAttribute("id", _itm);
if (_itm == "airline") {
_el_td.innerText = HotelTV.ui_utils.Get_Airline(_trTbl.ui.flight.airlines, _flitem.airline, _state.lang);
} else if (_itm == "flight") {
_el_td.innerText = _flitem.airFln;
} else if (_itm == "scheduled") {
_el_td.innerText = _flitem.std.charAt(0) + _flitem.std.charAt(1) + ":" + _flitem.std.charAt(2) + _flitem.std.charAt(3) + " - ";
_el_td.innerText += _flitem.etd.charAt(0) + _flitem.etd.charAt(1) + ":" + _flitem.etd.charAt(2) + _flitem.etd.charAt(3);
} else if (_itm == "origin") {
_el_td.innerText = HotelTV.ui_utils.Get_Airport(_trTbl.ui.flight.city, _flitem.boarding, _state.lang);
} else if (_itm == "destination") {
_el_td.innerText = HotelTV.ui_utils.Get_Airport(_trTbl.ui.flight.city, _flitem.arrived, _state.lang);
} else if (_itm == "type") {
if (_trTbl.ui.flight.line[_flitem.line]) {
_el_td.innerText = _trTbl.ui.flight.line[_flitem.line][_state.lang];
}
} else if (_itm == "gate") {
_el_td.innerText = _flitem.gate;
} else if (_itm == "status") {
_el_td.innerText = HotelTV.ui_utils.Get_FlightStatus(_trTbl.ui.flight.result, _flitem.rmk, _state.lang);
}
_el_tr.appendChild(_el_td);
});
_el_arrival_tbl_rec.appendChild(_el_tr);
}
}
}
$('.main .mm .flight #caution').text(_trTbl.ui.flight.caution.body[_state.lang]);
}
/**
* HotelTV UI Wrapper Function::> Build Main Menu::> Weather
*/
function __uifxn_AppFull_MM_BldWeather() {
let _trTbl = HotelTV.translation;
let _weather = HotelTV.weather;
let _cur_cond = _weather.item.condition
let _state = HotelTV.state;
let _elWeatherRoot = $('.main .mm .weather');
let _elWeatherToday = _elWeatherRoot.children('.today');
let _elWeatherForcast = _elWeatherRoot.children('.forcast');
let _elWeatherCation = _elWeatherRoot.children('#caution');
_elWeatherRoot.children('.location').text(_trTbl.system.locale.city[_weather.location][_state.lang] || null);
_elWeatherToday.children('#temp_cur').text(_weather.item.condition.temp + "°C");
_elWeatherToday.children('#temp_minmax').text(_weather.item.forecast[0].low + "°C/" + _weather.item.forecast[0].high + " °C");
_elWeatherToday.children('.detail').children('#discription').text(_trTbl.ui.weather.cond[_cur_cond.code][_state.lang]);
_elWeatherToday.children('.detail').children('#img_status').css('background-image', 'url(' + _weather.icon_image[_cur_cond.code] + ')');
_elWeatherToday.children('.detail').children('#humidity').children('#icon').css('background-image', 'url(./images/icons/icon_humidity.png)');
_elWeatherToday.children('.detail').children('#humidity').children('#value').text(_weather.daily['1'].main.humidity + " %");
_elWeatherToday.children('.detail').children('#wind').children('#icon').css('background-image', 'url(./images/icons/icon_wind.png)');
_elWeatherToday.children('.detail').children('#wind').children('#value').text(HotelTV.ui_utils.Weather_GetWindReport(_trTbl.ui.weather.wind_dir, _weather.wind.speed, _weather.wind.direction, _state.lang));
//Daily Summary
_elWeatherForcast.children('.daily').children('#title').text(_trTbl.ui.weather.fc_today[_state.lang]);
let _eltbl_fc_daily_items = _elWeatherForcast.children('.daily').children('ul').children('li');
for (let _idx = 0; _idx < _eltbl_fc_daily_items.length; ++_idx) {
let _wData = _weather.daily[Number(_idx) + 1];
let _time = _wData.dt_txt.split(' ')[1];
let _temp = _wData.main.temp;
$(_eltbl_fc_daily_items[_idx]).css('background-image', 'url(' + _weather.icon_image[_wData.weather.code] + ')');
$(_eltbl_fc_daily_items[_idx].children.time)[0].innerText = _time.split(":")[0] + ":" + _time.split(":")[1];
$(_eltbl_fc_daily_items[_idx].children.temp)[0].innerText = _temp.toString() + " °C";
}
//Weekly Summary
_elWeatherForcast.children('.weekly').children('#title').text(_trTbl.ui.weather.fc_weekly[_state.lang]);
let _eltbl_fc_weekly_items = _elWeatherForcast.children('.weekly').children('ul').children('li');
for (let _idx = 0; _idx < _eltbl_fc_weekly_items.length; ++_idx) {
let _wData = _weather.item.forecast[Number(_idx)];
$(_eltbl_fc_weekly_items[_idx]).css('background-image', 'url(' + _weather.icon_image[_wData.code] + ')');
$(_eltbl_fc_weekly_items[_idx].children.date)[0].innerText = _trTbl.system.days[_wData.day][_state.lang];
$(_eltbl_fc_weekly_items[_idx].children.temp)[0].innerText = _wData.low + " °C /" + _wData.high + " °C";
}
_elWeatherCation.text(_trTbl.ui.weather.caution.body[_state.lang]);
}
/**
* HotelTV UI[AppFull] Wrapper Function::> Buildup main menu and main bg
* @param {boolean} uri_img background image url
*/
function __uifxn_AppFull_BldPage_Main() {
let _program = HotelTV.tvguide.program;
let _weather = HotelTV.weather;
let _state = HotelTV.state;
let _mmcnt = 0;
_mmcnt = _program.length;
//_mm_width = 1920 / (_mmcnt - 1);
_mm_width = 266;
// 초기 메인 메뉴 KEY설정
_state.menu.stage = "preparing_main";
if (_state.menu.main.cur == null) {
_state.menu.main.cur = Object.keys(_program)[0];
}
// 메인 메뉴 셀렉터 노드를 동적으로 구성
let _div_mm_slist = document.querySelector('#lst_mmsel');
for (let _mm_idx = 1; _mm_idx <= _program.length; _mm_idx++) {
let _div_mm_item = document.createElement('div');
_div_mm_item.className = 'item';
_div_mm_item.id = _program[_mm_idx].id;
_div_mm_item.setAttribute("mmid", _mm_idx);
_div_mm_item.style.height = '92px';
// _div_mm_item.style.width = _mm_width + 'px';
// 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) {
_mm_item_title.textContent = _program[_mm_idx].title[_state.lang];
} else {
_mm_item_title.textContent = _program[_mm_idx].title[_state.lang];
}
// Append Sub elements::icon
let _mm_item_icon = document.createElement('div');
_mm_item_icon.setAttribute("id", "mm_item_icon");
let _sz_styleOpt = "--icon_unfocus: url(" + _program[_mm_idx].unfocusIcon.file.download + "); ";
_sz_styleOpt += "--icon_focus: url(" + _program[_mm_idx].focusIcon.file.download + "); ";
//_sz_styleOpt += "background-repeat: no-repeat; background-position: center bottom; background-size: 100% 100%; ";
_sz_styleOpt += "background-repeat: no-repeat; background-position: center bottom;";
_mm_item_icon.setAttribute("style", _sz_styleOpt);
_div_mm_item.appendChild(_mm_item_icon);
_div_mm_item.appendChild(_mm_item_title);
_div_mm_slist.appendChild(_div_mm_item);
// Record Special key map info
if (['flight', 'weather', 'tv'].includes(_program[_mm_idx].type)) {
if (!('specialKey' in _state)) {
_state['specialKey'] = {};
}
if (!(_program[_mm_idx].type in _state['specialKey'])) {
_state['specialKey'][_program[_mm_idx].type] = { "mm_index": _mm_idx };
}
}
}
// 메인 메뉴 백그라운드 이미지 노드를 동적으로 구성
let _div_mm_bglist = document.querySelector('#lst_mmbg');
for (let _mm_idx = 1; _mm_idx <= _program.length; _mm_idx++) {
let _div_mm_item = document.createElement('div');
let _sz_styleOpt = null;
_div_mm_item.className = 'item';
_div_mm_item.id = 'mmbg_' + _program[_mm_idx].name.replace(/\s/g, '').toLowerCase();
_div_mm_item.setAttribute("mmid", _mm_idx);
if (_program[_mm_idx].type.toLowerCase() == "weather") {
if (_weather != null) {
_sz_styleOpt = "background-image: url(" + _weather.background_image[_weather.item.condition.code] + "); ";
} else {
_sz_styleOpt = "background-image: url(" + _program[_mm_idx].background.file.download + "); ";
}
} else {
_sz_styleOpt = "background-image: url(" + _program[_mm_idx].background.file.download + "); ";
}
_sz_styleOpt += "background-repeat: no-repeat; background-position: center center; background-size: 100% 100%; ";
_div_mm_item.setAttribute("style", _sz_styleOpt);
_div_mm_bglist.appendChild(_div_mm_item);
}
_hndl_mmBg = $('#lst_mmbg');
_hndl_mmBg.owlCarousel({
center: true,
items: 1, //Number of Items on Screen what you want
loop: true,
margin: 0,
smartSpeed: 1000,
lazyLoad: true,
mouseDrag: false,
touchDrag: false,
pullDrag: false,
freeDrag: false,
startPosition: Number(_state.menu.cur) - 1,
});
$('.main .mm .bg').show(function() {
//호텔 로고 출력
$('.widjet .top .hotellogo').css({ "background-image": "url(" + HotelTV.hotelinfo.subLogo.download + ")" });
//상단 날씨 아이콘 및 온도 표시
__uifxn_AppFull_TopWidjet_BuildWeather();
//상단 메시지(unread)개수 표시
__uifxn_AppFull_TopWidjet_BuildMsgCnt();
// //상단 시계 표시
_hndl_widget_topTime = setInterval(() => {
let _szCurTm = HotelTV.ui_utils.GetCur_DateTime();
//console.log("_szCurTm=>" + _szCurTm);
$('.widjet .top .datetime .time').text(_szCurTm.time);
$('.widjet .top .datetime .date').text(_szCurTm.date);
}, 1000);
__uifxn_AppFull_TopWidjetShow(true);
//Weather Contents Buildup
__uifxn_AppFull_MM_BldWeather();
//Flight Contents Buildup
__uifxn_AppFull_MM_BldFlight();
//Build Brochures
__uifxn_AppFull_BuildBrochure();
//Build Amenity
__uifxn_AppFull_BuildAmenity();
//Build Room Service
__uifxn_AppFull_BuildRoomService();
//위젯 표시
$('.widjet').show();
});
_hndl_mmSel = $('#lst_mmsel');
_hndl_mmSel.owlCarousel({
center: true,
items: 5, //Number of Items on Screen what you want
loop: true,
margin: 0,
smartSpeed: 10,
autoWidth: false,
mouseDrag: false,
touchDrag: false,
pullDrag: false,
freeDrag: false,
startPosition: Number(_state.menu.cur) - 1,
});
$('.main .mm .slider').fadeIn(500, function() {
if (_hndl_tmrUgMngr == null) {
_hndl_tmrUgMngr = setInterval(__uifxn_AppFull_GuideBarUiMngr, 1000);
console.log("TMR::>Created...");
}
$('.main .mm .slider .owl-item').addClass('unfocus');
$('#lst_mmsel').trigger("to.owl.carousel", [0, 10, true]);
$('#lst_mmsel').trigger('translate.owl.carousel', [0, 500, true]);
HotelTV.ui_utils.SetBusy(false);
_state.menu.stage = "main";
});
$(document).on('keydown', function(_evt) { //attach event listener
let _opening = HotelTV.opening;
if (_state.menu.stage == "main") {
console.log(`MM KEY EVENT::> ${_evt.keyCode}, UINT=>${parseInt(_evt.keyCode)}`);
//console.log("MM KEY EVENT::> " + _evt.keyCode);
if (_evt.keyCode == 37) {
$('#lst_mmsel').trigger('prev.owl', 700)
} else if (_evt.keyCode == 39) {
$('#lst_mmsel').trigger('next.owl', 700)
} else if (_evt.keyCode == 13) {
// 서브 메뉴 빌드 및 화면 전환
__uifxn_AppFull_ShowMMHotKeyBtn(false);
if (_program[Number(_state.menu.main.cur)].type.toLowerCase() == "normal") {
if (_program[Number(_state.menu.main.cur)].style.toLowerCase() == "none") {
console.log("It's Top level contents...");
} else if (_program[Number(_state.menu.main.cur)].style.toLowerCase() == "content") {
console.log("Preparing General sub contents...");
} else if (_program[Number(_state.menu.main.cur)].style.toLowerCase() == "submenu") {
console.log("Preparing General sub menu...");
__uifxn_AppFull_BldPage_SubGeneral();
}
} else if (_program[Number(_state.menu.main.cur)].type.toLowerCase() == "mypage") {
console.log("Preparing Mypage sub menu...");
__uifxn_AppFull_BuildMyPage();
} else if (_program[Number(_state.menu.main.cur)].type.toLowerCase() == "tv") {
console.log("Preparing TV sub menu...");
__uifxn_AppFull_BldPage_SubTV();
} else if (_program[Number(_state.menu.main.cur)].type.toLowerCase() == "application") {
console.log("Preparing TV APP::>" + _program[Number(_state.menu.main.cur)].service);
if (_program[Number(_state.menu.main.cur)].service == "youtube") {
// console.log(`Type:${_program[Number(_state.menu.main.cur)].type} preparing WIFI AP...`);
// HotelTV.hcap.SetSoftAp({
// "enable": true,
// "ssid": "TVWIFI-" + HotelTV.guestinfo.room,
// "password": "12345678",
// });
HotelTV.hcap.LaunchPreApp(_program[Number(_state.menu.main.cur)].service, null);
} else if (_program[Number(_state.menu.main.cur)].service == "netflix") {
let _foundNetflix = false;
for (_i = 0; _i < _state['hcap_app'].length; _i++) {
if (_state['hcap_app'][_i].title == 'Netflix') {
_foundNetflix = true;
}
}
if (_foundNetflix == true) {
HotelTV.hcap.LaunchPreApp(_program[Number(_state.menu.main.cur)].service, { "hotel_name": HotelTV.hotelinfo.name });
} else {
HotelTV.ui_utils.ShowNotificationMsgBalloon("서비스를 중비 중입니다. 잠시후에 이용해 주세요.", 5);
}
}
} else {
console.log(`Type:${_program[Number(_state.menu.main.cur)].type} doen's have sub menu...`);
}
} else if (_evt.keyCode == 403) {
// RED BUTTON
if ("red" in _state.hotkey.mm) {
$('.guide>.tips').stop().animate({ backgroundColor: "rgba(0,0,0,0.8)" }, 500, function() {
if (_state.hotkey.mm.red.type == "brochure") {
$('.popup .hotkey_mm_red').fadeIn(1000, function() {
_state.menu.stage = "hotkey_mm_red";
__uifxn_AppFull_ShowMMHotKeyBtn(false);
__uifxn_AppFull_TopWidjetShow(false);
});
} else if (_state.hotkey.mm.red.type == "amenity") {
$('.popup .amenity').show(0, function() {
$('.popup .amenity').animate({ top: 96, left: 64 }, 500, () => {
_state.menu.stage = "hotkey_mm_amenity";
__uifxn_AppFull_ShowMMHotKeyBtn(false);
});
});
} else if (_state.hotkey.mm.red.type == "roomservice") {
$('.popup .roomservice').show(0, function() {
$('.popup .roomservice').animate({ top: 96, left: 64 }, 500, () => {
_state.menu.stage = "hotkey_mm_roomservice";
__uifxn_AppFull_ShowMMHotKeyBtn(false);
});
});
}
});
}
} else if (_evt.keyCode == 404) {
// GREEN BUTTON
if ("green" in _state.hotkey.mm) {
$('.guide>.tips').stop().animate({ backgroundColor: "rgba(0,0,0,0.8)" }, 500, function() {
if (_state.hotkey.mm.green.type == "brochure") {
$('.popup .hotkey_mm_green').fadeIn(1000, function() {
_state.menu.stage = "hotkey_mm_green";
__uifxn_AppFull_ShowMMHotKeyBtn(false);
__uifxn_AppFull_TopWidjetShow(false);
});
} else if (_state.hotkey.mm.green.type == "amenity") {
$('.popup .amenity').show(0, function() {
$('.popup .amenity').animate({ top: 96, left: 64 }, 500, () => {
_state.menu.stage = "hotkey_mm_amenity";
__uifxn_AppFull_ShowMMHotKeyBtn(false);
});
});
} else if (_state.hotkey.mm.green.type == "roomservice") {
$('.popup .roomservice').show(0, function() {
$('.popup .roomservice').animate({ top: 96, left: 64 }, 500, () => {
_state.menu.stage = "hotkey_mm_roomservice";
__uifxn_AppFull_ShowMMHotKeyBtn(false);
});
});
}
});
}
} else if (_evt.keyCode == 405) {
// YELLOW BUTTON
if ("yellow" in _state.hotkey.mm) {
$('.guide>.tips').stop().animate({ backgroundColor: "rgba(0,0,0,0.8)" }, 500, function() {
if (_state.hotkey.mm.yellow.type == "brochure") {
$('.popup .hotkey_mm_yellow').fadeIn(1000, function() {
_state.menu.stage = "hotkey_mm_yellow";
__uifxn_AppFull_ShowMMHotKeyBtn(false);
__uifxn_AppFull_TopWidjetShow(false);
});
} else if (_state.hotkey.mm.yellow.type == "amenity") {
$('.popup .amenity').show(0, function() {
$('.popup .amenity').animate({ top: 96, left: 64 }, 500, () => {
_state.menu.stage = "hotkey_mm_amenity";
__uifxn_AppFull_ShowMMHotKeyBtn(false);
});
});
} else if (_state.hotkey.mm.yellow.type == "roomservice") {
$('.popup .roomservice').show(0, function() {
$('.popup .roomservice').animate({ top: 96, left: 64 }, 500, () => {
_state.menu.stage = "hotkey_mm_roomservice";
__uifxn_AppFull_ShowMMHotKeyBtn(false);
});
});
}
});
}
} else if (_evt.keyCode == 406) {
// BLUE BUTTON
if ("blue" in _state.hotkey.mm) {
$('.guide>.tips').stop().animate({ backgroundColor: "rgba(0,0,0,0.8)" }, 500, function() {
if (_state.hotkey.mm.blue.type == "brochure") {
$('.popup .hotkey_mm_blue').fadeIn(1000, function() {
_state.menu.stage = "hotkey_mm_blue";
__uifxn_AppFull_ShowMMHotKeyBtn(false);
__uifxn_AppFull_TopWidjetShow(false);
});
} else if (_state.hotkey.mm.blue.type == "amenity") {
$('.popup .amenity').show(0, function() {
$('.popup .amenity').animate({ top: 96, left: 64 }, 500, () => {
_state.menu.stage = "hotkey_mm_amenity";
__uifxn_AppFull_ShowMMHotKeyBtn(false);
});
});
} else if (_state.hotkey.mm.blue.type == "roomservice") {
$('.popup .roomservice').show(0, function() {
$('.popup .roomservice').animate({ top: 96, left: 64 }, 500, () => {
_state.menu.stage = "hotkey_mm_roomservice";
__uifxn_AppFull_ShowMMHotKeyBtn(false);
});
});
}
});
}
} else if (_evt.keyCode == -2072433963) {
// DEDICATED HOT KEY: Amenity
// Check amenity menu enabled
if (_opening.amenity) {
$('.popup .amenity').show(0, function() {
$('.popup .amenity').animate({ top: 96, left: 64 }, 500, () => {
_state.menu.stage = "hotkey_mm_amenity";
__uifxn_AppFull_ShowMMHotKeyBtn(false);
});
});
}
} else if (_evt.keyCode == -2072437788) {
// DEDICATED HOT KEY: Room service
// Check room service menu enabled
if (_opening.roomService) {
$('.popup .roomservice').show(0, function() {
$('.popup .roomservice').animate({ top: 96, left: 64 }, 500, () => {
_state.menu.stage = "hotkey_mm_roomservice";
__uifxn_AppFull_ShowMMHotKeyBtn(false);
});
});
}
} else if (_evt.keyCode == -2072437533) {
// DEDICATED HOT KEY: Flight
// Check flight main menu index and go
if (('flight' in _state['specialKey'])) {
$('#lst_mmsel').trigger("to.owl.carousel", [Number(_state['specialKey']['flight'].mm_index) - 1, 10, true]);
}
} else if (_evt.keyCode == -2072438298) {
// DEDICATED HOT KEY: Weather
// Check flight main menu index and go
if (('weather' in _state['specialKey'])) {
$('#lst_mmsel').trigger("to.owl.carousel", [Number(_state['specialKey']['weather'].mm_index) - 1, 10, true]);
}
} else if (_evt.keyCode == -2072443143) {
// DEDICATED HOT KEY: TV
// Check flight main menu index and go
if (('tv' in _state['specialKey'])) {
$('#lst_mmsel').trigger("to.owl.carousel", [Number(_state['specialKey']['tv'].mm_index) - 1, 10, true]);
}
}
} else if (_state.menu.stage == "hotkey_mm_red") {
console.log("HOTKEY(MM:RED) KEY EVENT::> " + _evt.keyCode);
if (_evt.keyCode == 37) {
$('#lst_hotkey_mm_red').trigger('prev.owl')
} else if (_evt.keyCode == 39) {
$('#lst_hotkey_mm_red').trigger('next.owl')
} else if (_evt.keyCode == 461) {
$('.popup .hotkey_mm_red').fadeOut(1000, function() {
$('.popup .hotkey_mm_red').stop().animate({ backgroundColor: "rgba(0,0,0,0.0)" }, 500, function() {
$('.popup .hotkey_mm_red').css({ "background-color": "" });
_state.menu.stage = "main";
__uifxn_AppFull_ShowMMHotKeyBtn(true);
__uifxn_AppFull_TopWidjetShow(true);
});
});
}
} else if (_state.menu.stage == "hotkey_mm_green") {
console.log("HOTKEY(MM:GREEN) KEY EVENT::> " + _evt.keyCode);
if (_evt.keyCode == 37) {
$('#lst_hotkey_mm_green').trigger('prev.owl')
} else if (_evt.keyCode == 39) {
$('#lst_hotkey_mm_green').trigger('next.owl')
} else if (_evt.keyCode == 461) {
$('.popup .hotkey_mm_green').fadeOut(1000, function() {
$('.popup .hotkey_mm_green').stop().animate({ backgroundColor: "rgba(0,0,0,0.0)" }, 500, function() {
$('.popup .hotkey_mm_green').css({ "background-color": "" });
_state.menu.stage = "main";
__uifxn_AppFull_ShowMMHotKeyBtn(true);
__uifxn_AppFull_TopWidjetShow(true);
});
});
}
} else if (_state.menu.stage == "hotkey_mm_yellow") {
console.log("HOTKEY(MM:YELLOW) KEY EVENT::> " + _evt.keyCode);
if (_evt.keyCode == 37) {
console.log("LEFT");
} else if (_evt.keyCode == 38) {
console.log("UP");
} else if (_evt.keyCode == 39) {
console.log("RIGHT");
} else if (_evt.keyCode == 40) {
console.log("DOWN");
} else if (_evt.keyCode == 461) {
$('.popup .hotkey_mm_yellow').fadeOut(1000, function() {
$('.popup .hotkey_mm_yellow').stop().animate({ backgroundColor: "rgba(0,0,0,0.0)" }, 500, function() {
$('.popup .hotkey_mm_yellow').css({ "background-color": "" });
_state.menu.stage = "main";
__uifxn_AppFull_ShowMMHotKeyBtn(true);
__uifxn_AppFull_TopWidjetShow(true);
});
});
}
} else if (_state.menu.stage == "hotkey_mm_blue") {
console.log("HOTKEY(MM:BLUE) KEY EVENT::> " + _evt.keyCode);
if (_evt.keyCode == 37) {
console.log("LEFT");
} else if (_evt.keyCode == 38) {
console.log("UP");
} else if (_evt.keyCode == 39) {
console.log("RIGHT");
} else if (_evt.keyCode == 40) {
console.log("DOWN");
} else if (_evt.keyCode == 461) {
$('.popup .hotkey_mm_blue').fadeOut(1000, function() {
$('.popup .hotkey_mm_blue').stop().animate({ backgroundColor: "rgba(0,0,0,0.0)" }, 500, function() {
$('.popup .hotkey_mm_blue').css({ "background-color": "" });
_state.menu.stage = "main";
__uifxn_AppFull_ShowMMHotKeyBtn(true);
__uifxn_AppFull_TopWidjetShow(true);
});
});
}
} else if (_state.menu.stage == "hotkey_mm_amenity") {
console.log("HOTKEY(MM:AMENITY) KEY EVENT::> " + _evt.keyCode);
if (_evt.keyCode == 37) {
console.log("LEFT");
__uifxn_AppFull_HandleAmenity("del", false, false);
} else if (_evt.keyCode == 38) {
console.log("UP");
__uifxn_AppFull_HandleAmenity("up", false, false);
} else if (_evt.keyCode == 39) {
console.log("RIGHT");
__uifxn_AppFull_HandleAmenity("add", false, false);
} else if (_evt.keyCode == 40) {
console.log("DOWN");
__uifxn_AppFull_HandleAmenity("down", false, false);
} else if (_evt.keyCode == 13) {
console.log("ENTER");
if (_state.hotkey.mm[_opening.amenity.button].status.last_CartBtn_idx == "cancel") {
// Move to top of item list
$('.popup .amenity .items').animate({ scrollTop: 0 }, 0);
$('.popup .amenity').animate({ top: 96, left: -560 }, 500, () => {
$('.popup .amenity>.items').animate({ scrollTop: 0 }, 0, () => {
_state.menu.stage = "main";
$('.popup .amenity').hide(0, 'linear', () => {
// HOTKEY STATUS 리셋
__uifxn_AppFull_HandleAmenity("reset", true, false);
__uifxn_AppFull_ShowMMHotKeyBtn(true);
});
});
});
} else if (_state.hotkey.mm[_opening.amenity.button].status.last_CartBtn_idx == "order") {
$('.popup .amenity').animate({ top: 96, left: -560 }, 500, () => {
// Move to top of item list
$('.popup .amenity>.items').animate({ scrollTop: 0 }, 0, () => {
_state.menu.stage = "main";
$('.popup .amenity').hide(0, 'linear', () => {
// HOTKEY STATUS 리셋
__uifxn_AppFull_HandleAmenity("reset", false, true);
__uifxn_AppFull_ShowMMHotKeyBtn(true);
});
});
});
} else if (_state.hotkey.mm[_opening.amenity.button].status.last_CartBtn_idx == "details") {
$('.popup .amenity').animate({ scrollTop: $('.popup .amenity').prop('offsetHeight') }, 500, () => {
// scroll to show amenity order details
__uifxn_AppFull_HandleAmenity("enter", false, false);
_state.menu.stage = "hotkey_mm_amenity_order_details";
__uifxn_AppFull_BuildAmenityOrderDetails();
});
}
} else if (_evt.keyCode == 461) {
$('.popup .amenity').animate({ top: 96, left: -560 }, 500, () => {
// Move to top of item list
$('.popup .amenity>.items').animate({ scrollTop: 0 }, 0, () => {
_state.menu.stage = "main";
$('.popup .amenity').hide(0, 'linear', () => {
// HOTKEY STATUS 리셋
__uifxn_AppFull_HandleAmenity("reset", true, false);
__uifxn_AppFull_ShowMMHotKeyBtn(true);
});
});
});
}
} else if (_state.menu.stage == "hotkey_mm_amenity_order_details") {
console.log("HOTKEY(MM:ROOMSERVICE) KEY EVENT::> " + _evt.keyCode);
if (_evt.keyCode == 37) {
console.log("LEFT");
} else if (_evt.keyCode == 38) {
console.log("UP");
__uifxn_AppFull_HandleAmenity("up", false, false);
} else if (_evt.keyCode == 39) {
console.log("RIGHT");
} else if (_evt.keyCode == 40) {
console.log("DOWN");
__uifxn_AppFull_HandleAmenity("down", false, false);
} else if (_evt.keyCode == 461) {
$('.popup .amenity').animate({ top: 96, left: -560 }, 500, () => {
$('.popup .amenity').animate({ scrollTop: 0 }, 0, () => {
// Move to top of item list
$('.popup .amenity>.items').animate({ scrollTop: 0 }, 0, () => {
_state.menu.stage = "main";
$('.popup .amenity').hide(0, 'linear', () => {
// HOTKEY STATUS 리셋
__uifxn_AppFull_HandleAmenity("reset", true, false);
__uifxn_AppFull_ShowMMHotKeyBtn(true);
});
});
});
});
}
} else if (_state.menu.stage == "hotkey_mm_roomservice") {
console.log("HOTKEY(MM:ROOMSERVICE) KEY EVENT::> " + _evt.keyCode);
if (_evt.keyCode == 37) {
console.log("LEFT");
__uifxn_AppFull_HandleRoomservice("del", false, false);
} else if (_evt.keyCode == 38) {
console.log("UP");
__uifxn_AppFull_HandleRoomservice("up", false, false);
} else if (_evt.keyCode == 39) {
console.log("RIGHT");
__uifxn_AppFull_HandleRoomservice("add", false, false);
} else if (_evt.keyCode == 40) {
console.log("DOWN");
__uifxn_AppFull_HandleRoomservice("down", false, false);
} else if (_evt.keyCode == 13) {
console.log("ENTER");
if (_state.hotkey.mm[_opening.roomService.button].status.last_CartBtn_idx == "cancel") {
let _elRsMnRoot = $(`.popup .roomservice`);
_elRsMnRoot.children('.menu').animate({ scrollTop: 0 }, 0);
_elRsMnRoot.animate({ top: 96, left: -560 }, 500, () => {
_elRsMnRoot.children('.menu').children('.items').animate({ scrollTop: 0 }, 0, () => {
_state.menu.stage = "main";
_elRsMnRoot.hide(0, 'linear', () => {
// HOTKEY STATUS 리셋
__uifxn_AppFull_HandleRoomservice("reset", true, false);
__uifxn_AppFull_ShowMMHotKeyBtn(true);
});
});
});
} else if (_state.hotkey.mm[_opening.roomService.button].status.last_CartBtn_idx == "order") {
let _elRsMnRoot = $(`.popup .roomservice`);
_elRsMnRoot.children('.menu').animate({ scrollTop: 0 }, 0);
_elRsMnRoot.animate({ top: 96, left: -560 }, 500, () => {
_elRsMnRoot.children('.menu').children('.items').animate({ scrollTop: 0 }, 0, () => {
_state.menu.stage = "main";
_elRsMnRoot.hide(0, 'linear', () => {
// HOTKEY STATUS 리셋
__uifxn_AppFull_HandleRoomservice("reset", false, true);
__uifxn_AppFull_ShowMMHotKeyBtn(true);
});
});
});
} else if (_state.hotkey.mm[_opening.roomService.button].status.last_CartBtn_idx == "details") {
let _elRsMnRoot = $(`.popup .roomservice .menu`);
_elRsMnRoot.animate({ scrollTop: _elRsMnRoot.prop('offsetHeight') }, 500, () => {
// scroll to show roomservice order details
__uifxn_AppFull_HandleRoomservice("enter", false, false);
_state.menu.stage = "hotkey_mm_roomservice_order_details";
__uifxn_AppFull_BuildRoomserviceOrderDetails();
});
}
} else if (_evt.keyCode == 461) {
let _elRsMnRoot = $(`.popup .roomservice`);
_elRsMnRoot.animate({ top: 96, left: -560 }, 500, () => {
// Move to top of item list
_elRsMnRoot.children('.menu').children('.items').animate({ scrollTop: 0 }, 0, () => {
_state.menu.stage = "main";
_elRsMnRoot.hide(0, 'linear', () => {
// HOTKEY STATUS 리셋
__uifxn_AppFull_HandleRoomservice("reset", true, false);
__uifxn_AppFull_ShowMMHotKeyBtn(true);
});
});
});
}
} else if (_state.menu.stage == "hotkey_mm_roomservice_order_details") {
console.log("HOTKEY(MM:ROOMSERVICE) KEY EVENT::> " + _evt.keyCode);
if (_evt.keyCode == 37) {
console.log("LEFT");
} else if (_evt.keyCode == 38) {
console.log("UP");
__uifxn_AppFull_HandleRoomservice("up", false, false);
} else if (_evt.keyCode == 39) {
console.log("RIGHT");
} else if (_evt.keyCode == 40) {
console.log("DOWN");
__uifxn_AppFull_HandleRoomservice("down", false, false);
} else if (_evt.keyCode == 461) {
$('.popup .roomservice').animate({ top: 96, left: -560 }, 500, () => {
$('.popup .roomservice .menu').animate({ scrollTop: 0 }, 0, () => {
// Move to top of item list
$('.popup .roomservice .menu>.items').animate({ scrollTop: 0 }, 0, () => {
_state.menu.stage = "main";
$('.popup .roomservice').hide(0, 'linear', () => {
// HOTKEY STATUS 리셋
__uifxn_AppFull_HandleRoomservice("reset", true, false);
__uifxn_AppFull_ShowMMHotKeyBtn(true);
});
});
});
});
}
}
});
_hndl_mmSel.on('change.owl.carousel', function(event) {
// Update HotelTV menu status
let _state = HotelTV.state;
_state.menu.main.prev = Object.keys(_program)[event.page.index];
});
_hndl_mmSel.on('changed.owl.carousel', function(event) {
// Update HotelTV menu status
let _state = HotelTV.state;
_state.menu.main.cur = Object.keys(_program)[event.page.index];
__uifxn_AppFull_OnKeyDnEvt_MmSel(event);
//console.log("MAIN IDX::>" + _state.menu.main.cur);
});
_hndl_mmSel.on('translate.owl.carousel', function(event) {
/** 메뉴 셀렉터 좌/우 헨들링 및 이펙트 */
//console.log("MM::> Translaged Event");
let idx = 0;
if (typeof event.item != 'undefined') {
idx = event.item.index;
} else {
idx = $('.main .mm .slider .owl-item.active.center').index();
}
//console.log("Get Translate Event::>" + idx);
$('.main .mm .slider .owl-item.focus').addClass('unfocus');
$('.main .mm .slider .owl-item.focus').removeClass('focus');
$('.main .mm .slider .owl-item').eq(idx).addClass('focus');
$('.main .mm .slider .owl-item').eq(idx).removeClass('unfocus');
});
}
/// 초기화 루틴
//// 공개 API
return {
Init: function(width, height) {
//ADD Media related event haldner
document.addEventListener("media_event_received", __uifxn_AppFull_OnMediaEvt, false);
//ADD Key(remote control) event handler
document.addEventListener("keydown", __uifxn_AppFull_OnKeyDnEvtRec, false);
//ADD Network related event handler
document.addEventListener("network_event_received", __uifxn_AppFull_OnNetEvt, false);
//ADD Event for the focus change of HCAP application
document.addEventListener("hcap_application_focus_changed", __uifxn_AppFull_OnAppFocusEvt, false);
//ADD Event for the result of HDMI connection change
document.addEventListener("hdmi_connection_changed", __uifxn_AppFull_OnHdmiConChangeEvt, false);
},
Show: function() {
let _ctzWc = HotelTV.welcome;
let _ctzGst = HotelTV.guestinfo;
let _ctzHotel = HotelTV.hotelinfo;
console.log("Preparing APP[FULL] Page");
__uifxn_AppFull_BldPage_Main();
},
MqttEvent: function(_evt) {
let _state = HotelTV.state;
console.log("MQTT RECEVED MESSAGE::> " + _evt);
if (_evt == "EVENT-MESSAGE-CREATE" || _evt == "EVENT-MESSAGE-UPDATE" || _evt == "EVENT-MESSAGE-DELETE") {
//DO NEW GUEST MESSAGE&DO CHANGE GUEST MESSAGE
HotelTV.api.GetMessage().then(_ret => {
HotelTV.message = _ret;
console.log("Get New Message contents");
let _el_tbls = $('div#lst_mypagebg div #mp_message_table #mp_msg_tblrec');
let _msg = HotelTV.message;
let _msg_unread_cnt = 0;
//기존 메시지 테이블 레코드 삭제
_el_tbls.children('tbody').remove();
_el_tbls.each(function(_idx, _item) {
let _sz_innerHTML = '<tbody>';
let _num_msgIdx = 0;
for (let _j = _msg.length; _j > 0; _j--) {
_sz_innerHTML += '<tr msgnum=' + _j + ' msgidx=' + _num_msgIdx.toString() + ' >';
if (_msg[_j].read == false) {
_sz_innerHTML += '<td id="num">' + _j.toString() + '</td>';
} else {
_sz_innerHTML += '<td id="num" class="read">' + _j.toString() + '</td>';
}
if (_msg[_j].multilanguage == false) {
_sz_innerHTML += '<td id="title">' + _msg[_j].title.default+'</td>';
} else {
_sz_innerHTML += '<td id="title">' + _msg[_j].title[_state.lang] + '</td>';
}
_sz_innerHTML += '<td id="from">' + _msg[_j].from + '</td>';
_sz_innerHTML += '<td id="date">' + _msg[_j].createdAt + '</td>';
_sz_innerHTML += '</tr>';
_num_msgIdx++;
}
_sz_innerHTML += '</tbody>';
$(_item).html(_sz_innerHTML);
});
// 사용자가 메시지 메뉴를 사용중인경우에 대한 처리
if (_state.menu.stage == "popup_message_card" || _state.menu.stage == "mypage") {
const _mmIdx = _state.menu.main.cur;
// 메시지 상태 오브젝트 초기화
if ("message" in _state.menu.main[_mmIdx]) {
_state.menu.main[_mmIdx]['message'] = {
'cnt': _msg.length,
'cur': 0,
'prev': null,
};
}
$('.main>.mypage>.bg>.owl-carousel .owl-item #mp_msg_tblrec tr').removeClass('focus');
$('.main>.mypage>.bg>.owl-carousel .owl-item #mp_msg_tblrec tr').filter("[msgidx='" + _state.menu.main[_mmIdx]['message']['cur'] + "']").addClass('focus');
}
//메시지 개수 표시
const _guest = HotelTV.guestinfo;
let _trTbl = HotelTV.translation;
for (let _j = _msg.length; _j > 0; _j--) {
if (_msg[_j].read == false) {
_msg_unread_cnt++;
}
}
$('div#lst_mypagebg div #mp_message_title').text(_guest.name + _trTbl.ui.mypage.message.title.title[_state.lang].replace("_XX", _msg_unread_cnt.toString()));
//widjet 상단 메시지(unread)개수 표시
__uifxn_AppFull_TopWidjet_BuildMsgCnt();
}).catch(_error => {
console.log("Fail to get Message info");
});
} else if (_evt == "EVENT-NEWS-UPDATE") {
//DO NEW NEWS
HotelTV.api.GetNews().then(_ret => {
HotelTV.news = _ret;
console.log("Get New News contents");
__uifxn_AppFull_BldNews();
}).catch(_error => {
console.log("Fail to get news info");
});
} else if (_evt == "EVENT-EMERGENCY-START") {
} else if (_evt == "EVENT-EMERGENCY-STOT") {
} else if (_evt == "COMMAND-SYSTEM-RESTART") {
} else if (_evt == "GUEST-CHECKIN") {
} else if (_evt == "GUEST-CHECKOUT") {
} else if (_evt == "GUEST-UPDATE") {
} else if (_evt == "GUEST-ROOMCHANGE") {
}
},
UpdateEpg: function() {
let _state = HotelTV.state;
let _trTbl = HotelTV.translation;
if (_state.menu.stage != 'tvCtgHide') {
return;
}
let _el_tvctglst = $('.main .tv .bg .owl-item>.item');
if (_el_tvctglst.length > 0) {
_el_tvctglst.each(function(_idx, _item) {
let _el_epg_items = $(_item[_idx]).find('span#tvch_epg_info')
_el_epg_items.each(function(_j, _ch) {
let _epg_id = _ch.attr('epg_id');
let _epg_inf = __uifxn_AppFull_GetEpgInfoById(_epg_id);
if (_epg_inf != null) {
_ch.text(_egp_prog_inf.name);
} else {
_ch.text(_trTbl.ui.tv.epg.msg.none_epg_info[_state.lang]);
}
});
});
}
},
Close: function() {
SpatialNavigation.clear();
},
}
})();