$(function () { }); function saveStep1(e) { var servermqtt = $("input[name='servermqtt']").val(); if (servermqtt === "") { alert($("input[name='HAY_NHAP_THONG_TIN']").val()); return; } var url = $("input[name='url']").val(); if (url === "") { alert($("input[name='HAY_NHAP_THONG_TIN']").val()); return; } common.modalBlock(true); $.ajax({ url: $(e).attr("data-href"), type: 'POST', data: { servermqtt: servermqtt, url: url }, success: function (data) { var c = 0; setInterval(function () { $.ajax({ url: data, type: 'POST', success: function (data) { if (data.status) { window.location = data.url; } else { if (data.text !== "") { if (data.text === "error") { c++; if (c == 5) { alert($("input[name='BOX_CHUA_DUOC_DANG_KI_TREN_CMS']").val()); window.location.reload(true); } } else { alert(data.text); window.location.reload(true); } } } }, error: function (jqXHR, textStatus, errorThrown) { common.ajaxError(); } }); }, 1000); }, error: function (jqXHR, textStatus, errorThrown) { common.modalBlock(false); common.ajaxError(); } }); } function saveStep2(e) { var cfgLists = $(".editform"); var cfg = []; for (var i = 0; i < cfgLists.length; i++) { cfg.push({ parent: $(cfgLists[i]).data("parent"), key: $(cfgLists[i]).data("key"), data: $(cfgLists[i]).html() }); } common.modalBlock(true); $.ajax({ url: $(e).attr("data-href"), type: 'POST', data: { config: cfg }, success: function (data) { if (data) notification.success($("input[name='DA_LUU_CAU_HINH']").val(), 2000); else notification.success($("input[name='LUU_CAU_HINH_THAT_BAI']").val(), 2000); common.modalBlock(false); }, error: function (jqXHR, textStatus, errorThrown) { common.modalBlock(false); common.ajaxError(); } }); } function SaveConfigDevice(e) { var server_api = $("input[name='server_api']").val(); var device_id = $("input[name='device_id']").val(); if (server_api === "" || device_id === "") { alert($("input[name='HAY_NHAP_THONG_TIN']").val()); return; } common.modalBlock(true); $.ajax({ url: $(e).attr("data-href"), type: 'POST', data: { server_api: server_api, device_id: device_id }, success: function (data) { if (data) notification.success($("input[name='DA_LUU_CAU_HINH']").val(), 2000); else notification.success($("input[name='LUU_CAU_HINH_THAT_BAI']").val(), 2000); common.modalBlock(false); }, error: function (jqXHR, textStatus, errorThrown) { common.modalBlock(false); common.ajaxError(); } }); }