Created
September 24, 2013 03:25
-
-
Save hendra/6679995 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var checkUrlServer = function(){ | |
var chck = window.localStorage.getItem("key-url"); | |
if(chck == null){ | |
setUrlAppLication(); | |
}else{ | |
url = window.localStorage.getItem("key-url") + window.localStorage.getItem("key-url2"); | |
$("#loader-2").show(); | |
startAppGet(); | |
} | |
} | |
var startAppGet = function(){ | |
imei_global = device.uuid | |
ajaxRequest("POST", url+ "save_imei", {imei: imei_global}, function(data){ | |
$(".wrapper").show(); | |
getEmptyTable(); | |
} , | |
function(err){ | |
window.localStorage.clear(); | |
jAlert("Oops... Request time out. Please check connection to server!", 'Information'); | |
checkUrlServer(); | |
}) | |
} | |
var setUrlAppLication = function(){ | |
$("#loader-2").show(); | |
inputDataUrlApplication("checkUrlServer()"); | |
} | |
var inputDataUrlApplication = function(callFunction){ | |
$("#add-server-btn").click(function(){ | |
if($("#input-url-server").val() != ""){ | |
$("#input-server-modal").modal("hide"); | |
window.localStorage.setItem("key-url", "http://"+ $("#input-url-server").val()); | |
window.localStorage.setItem("key-url2", "/api/mobiles/beta/"); | |
url = window.localStorage.getItem("key-url") + window.localStorage.getItem("key-url2"); | |
ajaxRequest("GET", url+"get_image_or_text_logo", null, | |
function(dt){ | |
startAppGet(); | |
colorMenuSetting(dt.color_setting) | |
}, | |
function(err){ | |
window.localStorage.clear(); | |
jAlert("Oops... Request time out. Please check connection to server!", 'Information'); | |
eval(callFunction); | |
}); | |
} | |
else | |
{ | |
jAlert("Oops.. Server url could not be blank !"); | |
} | |
}); | |
} | |
var home_content = { | |
internet: function(){ | |
$("#internet-home").click(function(){ | |
window.open('http://www.google.com/', '_blank'); | |
}) | |
}, | |
games: function(){ | |
$("#games-home").click(function(){ | |
alert("We still working on this. Please stay tune..") | |
}) | |
}, | |
favorite: function(){ | |
$("#favorite-home").click(function(){ | |
$("#container").attr({menu: 'special'}) | |
ajaxRequest("GET", url+"special_weak_or_month", null, | |
function(dt){ | |
contentSpecials(dt) | |
home_content.animateMenu(); | |
reIndexAttribute(); | |
}, | |
function(err){ | |
jAlert("Oops... Request time out. Please check connection to server!", 'Information'); | |
}); | |
}); | |
}, | |
menu: function(){ | |
$("#menu-home").click(function(){ | |
home_content.animateMenu(); | |
if($("#container-list-menu span12").length == 0){ | |
home_content.widthMenuAndHideSideBar(); | |
var tmp_arr = $("#side-bar-menus li:first").attr("tmp_arr"); | |
var id = $("#side-bar-menus li:first").attr("id"); | |
$("#side-bar-menus li:first").attr("active", '1') | |
getSubMenu(id, tmp_arr); | |
} | |
$(".f_left ul li").click(function(){ | |
if($("#head-right-container").css("left") == "99%" ){ | |
$("#head-right-container").animate({ left: "71%" }, "fast"); | |
}else{ | |
$("#head-right-container").animate({left: "99%"}, "fast"); | |
} | |
$("#head-left-container").animate({ left: "-24%" }, "fast"); | |
}) | |
}) | |
}, | |
info: function(){ | |
$("#info-menu").click(function(){ | |
$("#restorant-info-home, .full-circle").modal("show"); | |
}) | |
$(".full-circle").click(function(){ | |
$("#restorant-info-home, .full-circle").modal("hide"); | |
}) | |
}, | |
location: function(){ | |
$("#location-menu").click(function(){ | |
$("#map-location-info").modal("show"); | |
$(".full-circle").show(); | |
generateMapModal() | |
}) | |
$(".full-circle").click(function(){ | |
$("#map-location-info").modal("hide"); | |
$(".full-circle").hide(); | |
}) | |
}, | |
share: function(){ | |
$("#share-menu").click(function(){ | |
if($(".a2a_default_style").is(":visible")){ | |
$('.a2a_default_style').hide(1000) | |
}else{ | |
$('.a2a_default_style').show(1000) | |
} | |
}) | |
}, | |
generateWidthUlAuto: function(d){}, | |
widthMenuAndHideSideBar: function(){ | |
var containerList = { marginLeft: "0%", width: "96%" }, | |
menuItem = { width: "21%", marginLeft: "4%"}; | |
$("#container-list-menu .menu-item").animate(menuItem, "fast"); | |
$("#container-list-menu").animate(containerList, "fast" ); | |
$("#container-menu").animate({ top: "-100%"}, "fast"); | |
$("#container-list-menu .notification-list").css("margin-left", "16%"); | |
}, | |
animateMenu: function(){ | |
$("#home").animate({top: "200%"}, "fast"); | |
$("#content-menu-page").animate({ top: "0%" }, "fast"); | |
$("#head-right-container").animate({ left: "99%" }, "fast"); | |
$("#side-right-container-togle").click(function(){ | |
if($("#head-right-container").css("left") == "99%" ){ | |
$("#head-right-container").animate({ left: "71%" }, "fast"); | |
}else{ | |
$("#head-right-container").animate({left: "99%"}, "fast"); | |
} | |
$("#head-left-container").animate({ left: "-24%" }, "fast"); | |
}); | |
}, | |
animateBindShow: function(){ | |
$("#menu-expanded, #hide-container-menu").click(function(){ | |
var containerList = { marginLeft: "0%", width: "96%" }, | |
menuItem = { width: "21%", marginLeft: "4%"}, | |
top = $("#container-menu").css("top") == "12%" ? "-100%" : "12%", | |
menuCount = 4; | |
$("#container-menu").show(); | |
if(top == "12%"){ | |
containerList = { marginLeft: "18%"}; | |
menuCount = 3; | |
} | |
$("#container-list-menu").animate(containerList, "fast" ); | |
$("#container-menu").animate({ top: top}, "fast"); | |
if(menuCount == 4){ | |
for(var x = 0; x < $("#container-list-menu .list-menu-content").length; x++){ | |
var loopMenu = $("#container-list-menu .list-menu-content")[x]; | |
var loopConter = menuCount - loopMenu.childElementCount; | |
for(var i = 0; i < loopConter; i++){ | |
nextTag = $("#container-list-menu .list-menu-content")[x + 1]; | |
$($(nextTag).children().get(0)).appendTo(loopMenu); | |
} | |
} | |
for(var x = 0; x < $("#container-list-menu .list-menu-content").length; x++){ | |
if($("#container-list-menu .list-menu-content:last .menu-item").length == 0) | |
$("#container-list-menu .list-menu-content:last").remove() | |
} | |
}else{ | |
$("#container-list-menu").text("") | |
var ulId | |
for(var x = 0; x < $("ul li[active=1]").length; x++){ | |
var parent = $("ul li[active=1]")[x].parentElement.id; | |
if($("#"+parent).is(":visible")) | |
ulId = parent; | |
} | |
var id = $("#"+ulId+" li[active=1]").attr("id"), | |
arr = $("#"+ulId+" li[active=1]").attr("tmp_arr"), | |
children = parseInt($("#"+ulId+" li[active=1]").attr("children")), | |
contentDet = "tmps.side_bar_tmp["+ arr +"].data_"+ id, | |
contentHtml = eval ("(" + contentDet+ ")"); | |
$(contentHtml[0]).appendTo("#container-list-menu"); | |
} | |
$("#container-list-menu .notification-list").css("margin-left", "16%"); | |
$(".menu-item-img").click(function(){ | |
bindDetailShow(this, false); | |
}) | |
notificationMenuList(); | |
bindMenuItemByOne(); | |
}); | |
} | |
} | |
var addOrderOnPopUp = function(){ | |
$(".btn-det-menu").click(function(){ | |
var top = $("#container-menu").css("top") == "12%" ? "-100%" : "12%" | |
createSummaryOrderAddByOne({ | |
id: $(this).attr("menu_id"), | |
menu_type: $(this).attr("menu_type"), | |
spacial: $(this).attr("menu_special"), | |
total_price: parseInt($("#select-order-many_dummy").val()) * parseFloat($(this).attr("price")), | |
price: parseFloat($(this).attr("price")), | |
name: $(this).attr("name"), | |
qty: parseInt($("#select-order-many_dummy").val()), | |
additional: $("#additional-detail-"+$(this).attr("menu_id")).val() | |
}, { | |
qty: parseInt($("#select-order-many_dummy").val()) , | |
price : parseInt($("#select-order-many_dummy").val()) * parseFloat($(this).attr("price")), | |
additional: $("#additional-detail-"+$(this).attr("menu_id")).val() | |
}); | |
$("#dish-details").modal("hide"); | |
$(".full-circle").hide(); | |
$("#container-list-menu .notification-list").css("margin-left", "16%"); | |
}); | |
} | |
var createSummaryOrderAddByOne = function(data1, data2){ | |
var content = ""; | |
if($("#menu-order-"+data1.id).length == 0){ | |
content = htmlSummaryOrderNew2(data1); | |
$(content).appendTo("#place-order-content"); | |
$("#menu-order-"+data1.id).click(function(){ | |
$("#place-order-content tr").css('background', 'none'); | |
$("#place-order-content tr").removeClass("active"); | |
$("#menu-order-"+data1.id).css('background', '#c1d021'); | |
$("#menu-order-"+data1.id).addClass("active"); | |
btnOrderSummary(data1); | |
}) | |
} | |
else | |
{ | |
$("#menu-order-"+data1.id+" .qty-order").text(data2.qty); | |
$("#menu-order-"+data1.id+" .price-order").text("$ "+data2.price.toFixed(2)); | |
$("#menu-order-"+data1.id+" .additional-order").text(data2.additional); | |
if(data2.additional != ""){ | |
$("#menu-order-"+data1.id+" .additional-order").show() | |
}else{ | |
$("#menu-order-"+data1.id+" .additional-order").hide() | |
} | |
} | |
checkEmailOrders(); | |
sumOrderSummary(); | |
notificationMenuList(); | |
} | |
$(document).ready(function(){ | |
$("#loader-2").show(); | |
app.initialize(); | |
app.settingApp(); | |
searchMenu(); | |
home_content.internet(); | |
home_content.games(); | |
home_content.menu(); | |
home_content.info(); | |
home_content.share(); | |
home_content.location(); | |
$(".back-home").click(function(){ | |
$("#content-menu-page").animate({ top: "200%" }, "fast"); | |
$("#home").animate({ top: "0%" }, "fast"); | |
}) | |
$(".search-clg-art").click(function(){ | |
var data = { | |
search: $(".search-text")[0].value != "" ? $(".search-text").val() : $(".search-text")[1].value | |
} | |
ajaxRequest("POST", url+"search_menu", data, function(dt){ | |
home_content.animateMenu(); | |
contentMenu(dt); | |
$(".menu-item-img").click(function(){ | |
bindDetailShow(this, false); | |
}) | |
}) | |
}); | |
WEB_SOCKET_DEBUG = true; | |
pusher = new Pusher('cf0a2650189b33bf751b'); | |
channel = pusher.subscribe(imei_global); | |
channel.bind('my_event', function(data) { | |
eval(data); | |
}); | |
channel.bind('color_setting', function(data) { | |
colorMenuSetting(data) | |
}); | |
channel.bind('tag_html', function(data) { | |
$(data[0]).appendTo('#pay-order-modal #content-pay-orders'); | |
for(var i= 0; i < $('.detail-order-counts-'+ data[1]).length; i ++){ | |
$('.detail-order-counts-'+ data[1])[i].textContent = "Order "+ (i + 1) +" Of "+ $('.detail-order-counts-'+ data[1]).length | |
} | |
}); | |
bindBackListMenu(); | |
SendPayNowToServer(); | |
}); | |
var app = { | |
initialize: function() { | |
this.bindEvents(); | |
}, | |
bindEvents: function() { | |
document.addEventListener('deviceready', this.onDeviceReady, false); | |
}, | |
onDeviceReady: function() { | |
app.receivedEvent('deviceready'); | |
}, | |
receivedEvent: function(id) { | |
checkUrlServer(); | |
}, | |
settingApp: function() { | |
$('#set-email').modal('show'); | |
$("#password-user").val(""); | |
$("#setting-app").click(function(){ | |
$("#setting-app-modal").modal("show"); | |
$("#login-btn").click(function(){ | |
checkPassword() | |
}) | |
}) | |
$("#btn-cnl-order").click(function(){ | |
$("#time-count").hide(); | |
$("#counting-back-2").hide(); | |
count = data_time; | |
timer.stop(); | |
$('#counter_2').text(""); | |
}); | |
$(".search-text").live('keyup',function(){ | |
$(".search-text").val(this.value); | |
$(".clear-search-text").show(); | |
$(".clear-search-text").click(function(){ | |
$(".clear-search-text").hide(); | |
$(".search-text").val(""); | |
}); | |
}); | |
$("#home-all").click(function(){ | |
backHome(); | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment