scripts.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. $("#message").draggable();
  2. $("#orientation").draggable();
  3. $("#settings").draggable();
  4. function setMessage(bheader, bcontent) {
  5. //console.log("Creating message");
  6. var timeNow = new Date();
  7. var hours = timeNow.getHours();
  8. var minutes = timeNow.getMinutes();
  9. var seconds = timeNow.getSeconds();
  10. //var timeString = "" + ((minutes > 12) ? - 12 : hours);
  11. var timeString = ((minutes < 10) ? "0" : "") + minutes;
  12. timeString += ((seconds < 10) ? ":0" : ":") + seconds;
  13. var html = "<div><span class='bar-hl'>";
  14. //html += timeString;
  15. html += bheader;
  16. html += "</span><span class='bar-info'>";
  17. html += bcontent;
  18. html += "</span></div>";
  19. console.log(html);
  20. $(".bar-message > .bar-wrapper").append(html);
  21. $('.bar-message > .bar-wrapper').scrollTop($('.bar-message > .bar-wrapper')[0].scrollHeight);
  22. }
  23. $(".bar-dropdown").click(function() {
  24. console.log($(this).parent().parent().attr('id'));
  25. var _id = $(this).parent().parent().attr('id');
  26. if (parseInt($(".bar-"+ _id).css("height")) > 0) {
  27. $(".bar-dropdown", "#"+_id).css("transform", "rotate(180deg)");
  28. $(".bar-"+ _id + "> .bar-wrapper").hide();
  29. $(".bar-"+ _id).css("height", 0);
  30. $("#"+_id).css("height", 36);
  31. } else {
  32. $(".bar-dropdown", "#"+_id).css("transform", "rotate(0deg)");
  33. $(".bar-"+ _id).css("height", 200);
  34. $("#"+_id).css("height", 236);
  35. $(".bar-"+ _id + "> .bar-wrapper").show();
  36. }
  37. });
  38. // master hide all elements on screen
  39. $("#toggleGUI").click(function() {
  40. $(".window-item").toggle();
  41. });
  42. $("#showTabs").hover(
  43. function() {
  44. $("#window-tab").show();
  45. }, function() {
  46. $("#window-tab").hide();
  47. }
  48. );
  49. $("#window-tab").hover(
  50. function() {
  51. $("#window-tab").show();
  52. }, function() {
  53. $("#window-tab").hide();
  54. }
  55. );
  56. $("#offMessage").click(function() {
  57. if ($("#message").is(":visible")) {
  58. $("#message").removeClass("window-item");
  59. $("#message").hide();
  60. } else {
  61. $("#message").addClass("window-item");
  62. $("#message").show();
  63. }
  64. });
  65. $("#offOrientation").click(function() {
  66. if ($("#orientation").is(":visible")) {
  67. $("#orientation").removeClass("window-item");
  68. $("#orientation").hide();
  69. } else {
  70. $("#orientation").addClass("window-item");
  71. $("#orientation").show();
  72. }
  73. });
  74. $("#offSettings").click(function() {
  75. if ($("#settings").is(":visible")) {
  76. $("#settings").removeClass("window-item");
  77. $("#settings").hide();
  78. } else {
  79. $("#settings").addClass("window-item");
  80. $("#settings").show();
  81. }
  82. });
  83. function setMessage(bheader, bcontent) {
  84. //console.log("Creating message");
  85. var timeNow = new Date();
  86. var hours = timeNow.getHours();
  87. var minutes = timeNow.getMinutes();
  88. var seconds = timeNow.getSeconds();
  89. //var timeString = "" + ((minutes > 12) ? - 12 : hours);
  90. var timeString = ((minutes < 10) ? "0" : "") + minutes;
  91. timeString += ((seconds < 10) ? ":0" : ":") + seconds;
  92. var html = "<div><span class='bar-hl'>";
  93. //html += timeString;
  94. html += bheader;
  95. html += "</span><span class='bar-info'>";
  96. html += bcontent;
  97. html += "</span></div>";
  98. //console.log(html);
  99. $(".bar-message > .bar-wrapper").append(html);
  100. $('.bar-message > .bar-wrapper').scrollTop($('.bar-message > .bar-wrapper')[0].scrollHeight);
  101. }
  102. $('#settings-box :checkbox').click(function() {
  103. var $this = $(this);
  104. // $this will contain a reference to the checkbox
  105. if ($this.is(':checked')) {
  106. if (this.name == "wireframe") {
  107. rcl2.addWireframe();
  108. setMessage("tomo", "Add cube wireframe.");
  109. }
  110. // the checkbox was checked
  111. } else {
  112. if (this.name == "wireframe") {
  113. rcl2.removeWireframe();
  114. setMessage("tomo", "Remove cube wireframe.");
  115. }
  116. // the checkbox was unchecked
  117. }
  118. });
  119. $( "#bg-color" ).change(function() {
  120. console.log(this.value);
  121. rcl2.setBackgroundColor("#"+this.value);
  122. setMessage("tomo", "Set background color: #" + this.value);
  123. });
  124. $( document ).ready(function() {
  125. setMessage("GUI", "Initialized.");
  126. var date = new Date(parseInt( $("#start_time").val() )*1000);
  127. // Hours part from the timestamp
  128. var year = date.getUTCFullYear();
  129. // Minutes part from the timestamp
  130. var month = "0" + parseInt(date.getUTCMonth()+1);
  131. // Seconds part from the timestamp
  132. var day = "0" + date.getUTCDate();
  133. var hours = "0" + date.getUTCHours();
  134. // Minutes part from the timestamp
  135. var minutes = "0" + date.getUTCMinutes();
  136. // Seconds part from the timestamp
  137. var seconds = "0" + date.getUTCSeconds();
  138. // Will display time in 10:30:23 format
  139. var formattedTime = year + '-' + month.substr(-2) + '-' + day.substr(-2) + ' ' + hours.substr(-2) + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
  140. $("#slider-tooltip").text(formattedTime);
  141. // Handler for .ready() called.
  142. $( "#slider-range" ).slider({
  143. range: true,
  144. min: 0,
  145. max: 100,
  146. values: [ 0, 100 ],
  147. slide: function( event, ui ) {
  148. console.log(ui.values);
  149. rcl2.setMinSos(ui.values[0]/100.0);
  150. rcl2.setMaxSos(ui.values[1]/100.0);
  151. //$( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
  152. }
  153. });
  154. $("#slider").slider({
  155. min: parseInt( $("#start_time").val() ),
  156. max: parseInt( $("#end_time").val() ),
  157. slide: function( event, ui ) {
  158. console.log(ui.value);
  159. }
  160. });
  161. });