set-stem.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. var i = 1;
  2. function Add(evt){
  3. evt.style.display="none";
  4. i ++;
  5. var div = document.createElement('div');
  6. var from_hr = 'from_hr' + i;
  7. var from_min = 'from_min' + i;
  8. var to_hr = 'to_hr' + i;
  9. var to_min = 'to_min' + i;
  10. var id = evt.getAttribute('id');
  11. var len = id.length;
  12. var add = id.split('_')[0] + '_add' + i;
  13. var del = id.split('_')[0] + '_del' + i;
  14. var html = '';
  15. var begin = id.split('_')[0];
  16. if(begin == 'tem' || begin == 'tns' || begin == 'music' || begin == 'v' || begin == 'w'){
  17. if(begin == 'music' || begin == 'w'){
  18. html += '<div class="from row col-xl-12 col-lg-12 col-md-12 col-sm-12 col-xs-12" style="padding-right:0px;">';
  19. html += '<div class="col-md-3 col-sm-12 col-xs-12" style="padding-left:0px;padding-right:0px;margin-left:-10px;margin-right:10px;">';
  20. }else{
  21. html += '<div class="from row col-xl-12 col-lg-12 col-md-12 col-sm-12 col-xs-12">';
  22. html += '<div class="col-md-3 col-sm-12 col-xs-12">';
  23. };
  24. if(begin == 'tem'){
  25. html += '<select name="tem' + i + '" class="tem-select"><option selected value="23&#176;C">23&#176;C</option><option value="24&#176;C">24&#176;C</option><option value="25&#176;C">25&#176;C</option></select>';
  26. }else if(begin == 'tns'){
  27. html += '<select name="tem-near-stem' + i + '" class="tem-near-stem-select"><option selected value="23&#176;C">23&#176;C</option><option value="24&#176;C">24&#176;C</option><option value="25&#176;C">25&#176;C</option></select>';
  28. }else if(begin == 'music'){
  29. html += '<select name="music' + i + '" class="music-select"><option selected value="playlist1">playlist1</option><option value="playlist2">playlist2</option><option value="playlist3">playlist3</option></select>';
  30. }else if(begin == 'v'){
  31. html += '<select name="vibration' + i + '" class="vibration-select"><option selected value="5Hz">5Hz</option><option value="10Hz">10Hz</option><option value="15Hz">15Hz</option></select>';
  32. }else if (begin == 'w'){
  33. html += '<select name="wind-flow' + i + '" class="wind-select"><option selected value="5m/s">5m/s</option><option value="10m/s">10m/s</option><option value="15m/s">15m/s</option></select>';
  34. }
  35. html += '</div>';
  36. }else{
  37. html += '<div class="from row">';
  38. };
  39. html += '<div class="col-xs-3">';
  40. html += '<span>From</span>';
  41. html += '</div>';
  42. html += '<div class="col-xs-6">';
  43. if(id.split('_')[0] == 'tem'){
  44. html += '<select name="tem_from_hr' + i + '">';
  45. }else if(id.split('_')[0] == 'led'){
  46. html += '<select name="led_from_hr' + i + '">';
  47. }else if(id.split('_')[0] == 'tns'){
  48. html += '<select name="tns_from_hr' + i + '">';
  49. }else if(id.split('_')[0] == 'music'){
  50. html += '<select name="music_from_hr' + i + '">';
  51. }else if(id.split('_')[0] == 'us'){
  52. html += '<select name="us_from_hr' + i + '">';
  53. }else if(id.split('_')[0] == 'v'){
  54. html += '<select name="v_from_hr' + i + '">';
  55. }else if(id.split('_')[0] == 'w'){
  56. html += '<select name="w_from_hr' + i + '">';
  57. }else{
  58. html += '<select name="from_hr1">';
  59. };
  60. for(var hr = 0; hr < 24; hr++){
  61. if(hr < 10){
  62. html += '<option value="0' + hr + '">0' + hr + '</option>';
  63. }else{
  64. html += '<option value="' + hr + '">' + hr + '</option>';
  65. };
  66. };
  67. html += '</select>';
  68. if(id.split('_')[0] == 'tem'){
  69. html += ' :<select name="tem_from_min' + i + '">';
  70. }else if(id.split('_')[0] == 'led'){
  71. html += ' :<select name="led_from_min' + i + '">';
  72. }else if(id.split('_')[0] == 'tns'){
  73. html += ' :<select name="tns_from_min' + i + '">';
  74. }else if(id.split('_')[0] == 'music'){
  75. html += ' :<select name="music_from_min' + i + '">';
  76. }else if(id.split('_')[0] == 'us'){
  77. html += ' :<select name="us_from_min' + i + '">';
  78. }else if(id.split('_')[0] == 'v'){
  79. html += ' :<select name="v_from_min' + i + '">';
  80. }else if(id.split('_')[0] == 'w'){
  81. html += ' :<select name="w_from_min' + i + '">';
  82. }else{
  83. html += ' :<select name="from_min1">';
  84. };
  85. for(var min = 0; min < 60; min++){
  86. if(min < 10){
  87. html += '<option value="0' + min + '">0' + min + '</option>';
  88. }else{
  89. html += '<option value="' + min + '">' + min + '</option>';
  90. };
  91. };
  92. html += '</select>';
  93. html += '</div>';
  94. html += '<div class="col-xs-3">';
  95. html += '<input id=' + del + ' class="delete" type="button" value="Delete" onclick="Delete(' + del + ');">';
  96. html += '</div>';
  97. html += '</div>';
  98. html += '<div class="to row">';
  99. if(begin == 'tem' || begin == 'tns' || begin == 'music' || begin == 'v' || begin == 'w'){
  100. html += '<div class="col-md-3 col-sm-12 col-xs-12"></div>';
  101. }
  102. html += '<div class="col-xs-3">';
  103. if(begin == 'music' || begin == 'w'){
  104. html += '<span style="margin-left: 24px;">To</span>';
  105. }else{
  106. html += '<span style="margin-left: 20px;">To</span>';
  107. };
  108. html += '</div>';
  109. html += '<div class="col-xs-6">';
  110. if(id.split('_')[0] == 'tem'){
  111. html += '<select name="tem_to_hr' + i + '">';
  112. }else if(id.split('_')[0] == 'led'){
  113. html += '<select name="led_to_hr' + i + '">';
  114. }else if(id.split('_')[0] == 'tns'){
  115. html += '<select name="tns_to_hr' + i + '">';
  116. }else if(id.split('_')[0] == 'music'){
  117. html += '<select name="music_to_hr' + i + '">';
  118. }else if(id.split('_')[0] == 'us'){
  119. html += '<select name="us_to_hr' + i + '">';
  120. }else if(id.split('_')[0] == 'v'){
  121. html += '<select name="v_to_hr' + i + '">';
  122. }else if(id.split('_')[0] == 'w'){
  123. html += '<select name="w_to_hr' + i + '">';
  124. }else{
  125. html += '<select name="to_hr1">';
  126. };
  127. for(var hr = 0; hr < 24; hr++){
  128. if(hr < 10){
  129. html += '<option value="0' + hr + '">0' + hr + '</option>';
  130. }else{
  131. html += '<option value="' + hr + '">' + hr + '</option>';
  132. };
  133. };
  134. html += '</select>';
  135. if(id.split('_')[0] == 'tem'){
  136. html += ' :<select name="tem_to_min' + i + '">';
  137. }else if(id.split('_')[0] == 'led'){
  138. html += ' :<select name="led_to_min' + i + '">';
  139. }else if(id.split('_')[0] == 'tns'){
  140. html += ' :<select name="tns_to_min' + i + '">';
  141. }else if(id.split('_')[0] == 'music'){
  142. html += ' :<select name="music_to_min' + i + '">';
  143. }else if(id.split('_')[0] == 'us'){
  144. html += ' :<select name="us_to_min' + i + '">';
  145. }else if(id.split('_')[0] == 'v'){
  146. html += ' :<select name="v_to_min' + i + '">';
  147. }else if(id.split('_')[0] == 'w'){
  148. html += ' :<select name="w_to_min' + i + '">';
  149. }else{
  150. html += ' :<select name="to_min1">';
  151. };
  152. for(var min = 0; min < 60; min++){
  153. if(min < 10){
  154. html += '<option value="0' + min + '">0' + min + '</option>';
  155. }else{
  156. html += '<option value="' + min + '">' + min + '</option>';
  157. };
  158. };
  159. html += '</select><br>';
  160. html += '<input id=' + add + ' class="add" type="button" value="Add" onclick="Add(' + add + ');">';
  161. html += '</div>';
  162. html += '<div class="col-xs-3"></div>';
  163. html += '</div>';
  164. div.innerHTML = html;
  165. div.style.marginTop = '15px';
  166. div.style.zIndex = '100';
  167. evt.parentNode.parentNode.parentNode.parentNode.appendChild(div);
  168. };
  169. function Delete(evt){
  170. var id = evt.getAttribute('id');
  171. console.log(id.split('_')[0]);
  172. var add = id.split('_')[0] + '_' + 'add';
  173. var clo_xs_3 = evt.parentNode;
  174. var from = clo_xs_3.parentNode;
  175. var div = from.parentNode;
  176. var next_div = div.nextElementSibling;
  177. var pre_div = div.previousElementSibling;
  178. var begin = id.split('_')[0];
  179. if(next_div && pre_div == null){
  180. div.parentNode.removeChild(div);
  181. next_div.style.marginTop = '0px';
  182. }else if(next_div && pre_div){
  183. div.parentNode.removeChild(div);
  184. }else if(next_div == null && pre_div == null){
  185. if(id.split('_')[0] == 'us'){
  186. div.parentNode.parentNode.parentNode.children[4].style.display = 'inline-block';
  187. }else{
  188. div.parentNode.parentNode.parentNode.children[1].style.display = 'inline-block';
  189. }
  190. div.parentNode.style.display = 'none';
  191. var name = id.split('_')[0];
  192. var from_hr = name + '_from_hr' + 1;
  193. var from_min = name + '_from_min' + 1;
  194. var to_hr = name + '_to_hr' + 1;
  195. var to_min = name + '_to_min' + 1;
  196. $('select[name=' + from_hr + ']').val('00');
  197. $('select[name=' + from_min + ']').val('00');
  198. $('select[name=' + to_hr + ']').val('00');
  199. $('select[name=' + to_min + ']').val('00');
  200. }else{
  201. div.parentNode.removeChild(div);
  202. i --;
  203. add = add + i;
  204. add = document.getElementById(add);
  205. if(add == null){
  206. if(begin == 'tem' || begin == 'tns' || begin == 'music' || begin == 'v' || begin == 'w'){
  207. add = pre_div.children[1].children[2].children[3];
  208. }else{
  209. add = pre_div.children[1].children[1].children[3];
  210. };
  211. };
  212. add.style.display = 'block';
  213. };
  214. };
  215. $(function(){
  216. var tem = $(".set-schedule")[0];
  217. var tem_div = $("#tem_div");
  218. var led = $(".set-schedule")[1];
  219. var led_div = $("#led_div");
  220. var tem_near_stem = $(".set-schedule")[2];
  221. var tem_near_stem_div = $("#tem-near-stem_div");
  222. var music = $(".set-schedule")[3];
  223. var music_div = $("#music_div");
  224. var ultra_sonic = $(".set-schedule")[4];
  225. var ultra_sonic_div = $("#ultra-sonic_div");
  226. var vibration = $(".set-schedule")[5];
  227. var vibration_div = $("#vibration_div");
  228. var wind_flow = $(".set-schedule")[6];
  229. var wind_flow_div = $("#wind-flow_div");
  230. tem.onclick = function(){
  231. tem.style.display = 'none';
  232. tem_div.css('display','block');
  233. };
  234. led.onclick = function(){
  235. led.style.display = 'none';
  236. led_div.css('display','block');
  237. };
  238. tem_near_stem.onclick = function(){
  239. tem_near_stem.style.display = 'none';
  240. tem_near_stem_div.css('display','block');
  241. };
  242. music.onclick = function(){
  243. music.style.display = 'none';
  244. music_div.css('display','block');
  245. };
  246. ultra_sonic.onclick = function(){
  247. ultra_sonic.style.display = 'none';
  248. ultra_sonic_div.css('display','block');
  249. };
  250. vibration.onclick = function(){
  251. vibration.style.display = 'none';
  252. vibration_div.css('display','block');
  253. };
  254. wind_flow.onclick = function(){
  255. wind_flow.style.display = 'none';
  256. wind_flow_div.css('display','block');
  257. };
  258. var btn_con = $(".btn-configure");
  259. btn_con.click(function(){
  260. $("#configure").css('display','block');
  261. });
  262. $("#list li").click(function(){
  263. $("#list li").removeClass("current_li");
  264. $("#list li a").removeClass("current");
  265. });
  266. $(".js-color").click(function(){
  267. var $this = $(this);
  268. var hex = $this.attr('data-hex');
  269. var rgb = $this.attr('data-rgb');
  270. $(".show_color").css('background-color', hex);
  271. $("input[name=color]").val(rgb);
  272. $(".span_color").text(hex);
  273. });
  274. $(".down-arrow").click(function(){
  275. $(".color-top").css('display','none');
  276. $(".down-arrow").css('display','none');
  277. $(".up-arrow").css('display','inline-block');
  278. $(".color-set").css('display','block');
  279. });
  280. $(".up-arrow").click(function(){
  281. $(".color-top").css('display','block');
  282. $(".down-arrow").css('display','inline-block');
  283. $(".up-arrow").css('display','none');
  284. $(".color-set").css('display','none');
  285. });
  286. $("#brightness").click(function(){
  287. $(".brightness_info").css('display','block');
  288. $(".color_info").css('display','none');
  289. $(".recomendation_info").css('display','none');
  290. });
  291. $("#color").click(function(){
  292. $(".brightness_info").css('display','none');
  293. $(".color_info").css('display','block');
  294. $(".recomendation_info").css('display','none');
  295. });
  296. $("#recomendations").click(function(){
  297. $(".recomendation_info").css('display','block');
  298. $(".color_info").css('display','none');
  299. $(".brightness_info").css('display','none');
  300. });
  301. $(".color-cancel").click(function(){
  302. $("#configure").css('display','none');
  303. });
  304. $(".color-confirm").click(function(){
  305. $("#configure").css('display','none');
  306. });
  307. $(".form-control")[0].onclick = function(){
  308. window.location.href = '/online_fitolab';
  309. };
  310. });