var i = 1; function Add(evt){ evt.style.display="none"; i ++; var div = document.createElement('div'); var from_hr = 'from_hr' + i; var from_min = 'from_min' + i; var to_hr = 'to_hr' + i; var to_min = 'to_min' + i; var id = evt.getAttribute('id'); var len = id.length; var add = id.split('_')[0] + '_add' + i; var del = id.split('_')[0] + '_del' + i; var html = ''; if(id.split('_')[0] == 'tem'){ html += '
'; html += '
'; html += ''; html += '
'; }else{ html += '
'; }; html += '
'; html += 'From'; html += '
'; html += '
'; if(id.split('_')[0] == 'tem'){ html += ''; }else{ html += ''; if(id.split('_')[0] == 'tem'){ html += ' :'; }else{ html += ' :'; html += '
'; html += '
'; html += ''; html += '
'; html += '
'; html += '
'; if(id.split('_')[0] == 'tem'){ html += '
'; }; html += '
'; html += 'To'; html += '
'; html += '
'; if(id.split('_')[0] == 'tem'){ html += ''; }else{ html += ''; if(id.split('_')[0] == 'tem'){ html += ' :'; }else{ html += ' :
'; html += ''; html += '
'; html += '
'; html += '
'; div.innerHTML = html; div.style.marginTop = '15px'; div.style.zIndex = '100'; evt.parentNode.parentNode.parentNode.parentNode.appendChild(div); }; function Delete(evt){ var id = evt.getAttribute('id'); var add = id.split('_')[0] + '_' + 'add'; var clo_xs_3 = evt.parentNode; var from = clo_xs_3.parentNode; var div = from.parentNode; var next_div = div.nextElementSibling; var pre_div = div.previousElementSibling; var begin = id.split('_')[0]; if(next_div && pre_div == null){ div.parentNode.removeChild(div); next_div.style.marginTop = '0px'; }else if(next_div && pre_div){ div.parentNode.removeChild(div); }else if(next_div == null && pre_div == null){ div.parentNode.parentNode.parentNode.children[1].style.display = 'inline-block'; div.parentNode.style.display = 'none'; var name = id.split('_')[0]; var from_hr = name + '_from_hr' + 1; var from_min = name + '_from_min' + 1; var to_hr = name + '_to_hr' + 1; var to_min = name + '_to_min' + 1; $('select[name=' + from_hr + ']').val('00'); $('select[name=' + from_min + ']').val('00'); $('select[name=' + to_hr + ']').val('00'); $('select[name=' + to_min + ']').val('00'); }else{ div.parentNode.removeChild(div); i --; add = add + i; add = document.getElementById(add); if(add == null){ if(begin == 'tem'){ add = pre_div.children[1].children[2].children[3]; }else{ add = pre_div.children[1].children[1].children[3]; }; }; add.style.display = 'block'; }; }; $(function(){ var tem = $(".set-schedule")[0]; var tem_div = $("#tem_div"); var lamp = $(".set-schedule")[1]; var lamp_div = $("#lamp_div"); tem.onclick = function(){ tem.style.display = 'none'; tem_div.css('display','block'); }; lamp.onclick = function(){ lamp.style.display = 'none'; lamp_div.css('display','block'); }; var btn_con = $(".btn-configure"); btn_con.click(function(){ $("#configure").css('display','block'); }); $("#list li").click(function(){ $("#list li").removeClass("current_li"); $("#list li a").removeClass("current"); }); $(".js-color").click(function(){ var $this = $(this); var hex = $this.attr('data-hex'); var rgb = $this.attr('data-rgb'); $(".show_color").css('background-color', hex); $("input[name=color]").val(rgb); $(".span_color").text(hex); }); $(".down-arrow").click(function(){ $(".color-top").css('display','none'); $(".down-arrow").css('display','none'); $(".up-arrow").css('display','inline-block'); $(".color-set").css('display','block'); }); $(".up-arrow").click(function(){ $(".color-top").css('display','block'); $(".down-arrow").css('display','inline-block'); $(".up-arrow").css('display','none'); $(".color-set").css('display','none'); }); $("#brightness").click(function(){ $(".brightness_info").css('display','block'); $(".color_info").css('display','none'); $(".recomendation_info").css('display','none'); }); $("#color").click(function(){ $(".brightness_info").css('display','none'); $(".color_info").css('display','block'); $(".recomendation_info").css('display','none'); }); $("#recomendations").click(function(){ $(".recomendation_info").css('display','block'); $(".color_info").css('display','none'); $(".brightness_info").css('display','none'); }); $(".color-cancel").click(function(){ $("#configure").css('display','none'); }); $(".color-confirm").click(function(){ $("#configure").css('display','none'); }); $(".form-control")[0].onclick = function(){ window.location.href = '/setting_stem'; }; });