PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/scripts/jahova/Utilities/DebugBar/jahova.utilities.debugbar.js

https://bitbucket.org/GTL/surveyjs-builder
JavaScript | 387 lines | 252 code | 67 blank | 68 comment | 19 complexity | 08b6dd930cbc6d0b6f1ad17d619a7b3c MD5 | raw file
  1. com.jahova.utilities.Instance().DebugBar = (function()
  2. {
  3. var pInstance;
  4. function constructor()
  5. {
  6. //******************
  7. //PRIVATE ATTRIBUTES
  8. //******************
  9. var NAME = "JaHOVA Utilities : Debug Bar";
  10. var VERSION = "0v5";
  11. var PATH = "scripts/jahova/Utilities/DebugBar/jahova.utilities.debugbar.js";
  12. var ENABLED = true;
  13. var os = com.jahova.os.Instance();
  14. var debugbar = os.debugbar;
  15. var prompt = "~JaHOVA OS >>";
  16. //******************
  17. //PRIVATE METHODS
  18. //******************
  19. //******************
  20. //INITALIZATION
  21. //******************
  22. return{
  23. //PUBLIC ATTRIBUTES
  24. ConsolePagePinned: false,
  25. LogsPagePinned: false,
  26. SettingsPagePinned: false,
  27. //PUBLIC PRIVILEDGE METHODS
  28. GetName: function(){
  29. return NAME;
  30. },
  31. GetVersion: function(){
  32. return VERSION;
  33. },
  34. GetPath: function(){
  35. return PATH;
  36. },
  37. GetStatus: function(){
  38. return ENABLED;
  39. },
  40. Enable: function(){
  41. ENABLED = true;
  42. os.Elements.DebugBar.style.display = "block";
  43. },
  44. Disable: function(){
  45. ENABLED = false;
  46. os.Elements.DebugBar.style.display = "none";
  47. },
  48. Initialize: function(){
  49. window.onkeydown = os.debugbar.EvaluateShortCuts;
  50. os.debugbar.Build();
  51. },
  52. Build: function(){
  53. //Debug Bar Wrapper
  54. os.Elements.DebugBar = document.createElement("div");
  55. os.Elements.DebugBar.id = "com.jahova.debugBar";
  56. os.Elements.DebugBar.className = "ideSidebar appBaseColor";
  57. document.body.appendChild(os.Elements.DebugBar);
  58. //***********************************
  59. //
  60. // CONSOLE
  61. //
  62. //***********************************
  63. //Debug Bar Tab
  64. os.Elements.DebugBarConsoleTab = document.createElement("div");
  65. os.Elements.DebugBarConsoleTab.id = "com.jahova.debugBar.Console.Tab";
  66. os.Elements.DebugBarConsoleTab.className = "ideSidebarTabFolderView jahova_borRadR2 sidebarTabColor";
  67. os.Elements.DebugBar.appendChild(os.Elements.DebugBarConsoleTab);
  68. //Debug Bar Tab Label
  69. os.Elements.DebugBarConsoleTabLabel = document.createElement("div");
  70. os.Elements.DebugBarConsoleTabLabel.id = "com.jahova.debugBar.Console.Tab.Label";
  71. os.Elements.DebugBarConsoleTabLabel.className = "ideSidebarTabTextFolderView textColorWhite";
  72. os.Elements.DebugBarConsoleTabLabel.innerHTML = "Console";
  73. os.Elements.DebugBarConsoleTab.appendChild(os.Elements.DebugBarConsoleTabLabel);
  74. //Debug Bar Content Wrapper
  75. os.Elements.DebugBarConsole = document.createElement("div");
  76. os.Elements.DebugBarConsole.id = "com.jahova.debugBar.Console.Wrapper";
  77. os.Elements.DebugBarConsole.className = "ideSidebarPageFolderView sidebarTabColor jahova_borRadL2 jahova_borRadB2 jahova_transWp5s";
  78. //os.Elements.DebugBarConsole.style.visibility = "visible";
  79. //os.Elements.DebugBarConsole.style.width = "260px";
  80. os.Elements.DebugBarConsoleTab.appendChild(os.Elements.DebugBarConsole);
  81. //Debug Bar Content Header
  82. os.Elements.DebugBarConsoleHeader = document.createElement("div");
  83. os.Elements.DebugBarConsoleHeader.id = "com.jahova.debugBar.Console.Header";
  84. os.Elements.DebugBarConsoleHeader.className = "ideSidebarFolderHeader jahova_borRadT2 menuColor";
  85. os.Elements.DebugBarConsole.appendChild(os.Elements.DebugBarConsoleHeader);
  86. //Debug Bar Content Header Label
  87. os.Elements.DebugBarConsoleHeaderLabel = document.createElement("div");
  88. os.Elements.DebugBarConsoleHeaderLabel.id = "com.jahova.debugBar.Console.Header.Label";
  89. os.Elements.DebugBarConsoleHeaderLabel.className = "ideSidebarFolderH3";
  90. os.Elements.DebugBarConsoleHeaderLabel.innerHTML = "Terminal Window";
  91. os.Elements.DebugBarConsoleHeader.appendChild(os.Elements.DebugBarConsoleHeaderLabel);
  92. //Debug Bar Header Pin
  93. os.Elements.DebugBarConsoleHeaderPin = document.createElement("div");
  94. os.Elements.DebugBarConsoleHeaderPin.id = "com.jahova.debugBar.Console.Header.Pin";
  95. os.Elements.DebugBarConsoleHeaderPin.className = "ideSidebarPin";
  96. os.Elements.DebugBarConsoleHeaderPin.onclick = this.AnchorPage;
  97. os.Elements.DebugBarConsoleHeader.appendChild(os.Elements.DebugBarConsoleHeaderPin);
  98. //Debug Bar Icon
  99. os.Elements.DebugBarConsoleIconHeader = document.createElement("div");
  100. os.Elements.DebugBarConsoleIconHeader.id = "com.jahova.debugBar.Console.Icons";
  101. os.Elements.DebugBarConsoleIconHeader.className = "ideSidebarFolderIconHeader iconColor";
  102. os.Elements.DebugBarConsole.appendChild(os.Elements.DebugBarConsoleIconHeader);
  103. //Debug Bar Content Area
  104. os.Elements.DebugBarConsoleContent = document.createElement("div");
  105. os.Elements.DebugBarConsoleContent.id = "com.jahova.debugBar.Console.Content";
  106. os.Elements.DebugBarConsoleContent.className = "ideSidebarFolderContent jahova_borRadB2 viewContentBkgColor";
  107. os.Elements.DebugBarConsole.appendChild(os.Elements.DebugBarConsoleContent);
  108. os.console.cmdWindow.style.border = "0px";
  109. os.console.cmdWindow.style.height = "503px";
  110. os.Elements.DebugBarConsoleContent.appendChild(os.console.cmdWindow);
  111. //***********************************
  112. //
  113. // LOGS
  114. //
  115. //***********************************
  116. //Debug Bar Tab
  117. os.Elements.DebugBarLogTab = document.createElement("div");
  118. os.Elements.DebugBarLogTab.id = "com.jahova.debugBar.Log.Tab";
  119. os.Elements.DebugBarLogTab.className = "ideSidebarTabFolderView jahova_borRadR2 sidebarTabColor";
  120. os.Elements.DebugBar.appendChild(os.Elements.DebugBarLogTab);
  121. //Debug Bar Tab Label
  122. os.Elements.DebugBarLogTabLabel = document.createElement("div");
  123. os.Elements.DebugBarLogTabLabel.id = "com.jahova.debugBar.Log.TabLabel";
  124. os.Elements.DebugBarLogTabLabel.className = "ideSidebarTabTextFolderView textColorWhite";
  125. os.Elements.DebugBarLogTabLabel.innerHTML = "Logs";
  126. os.Elements.DebugBarLogTab.appendChild(os.Elements.DebugBarLogTabLabel);
  127. //Debug Bar Content Wrapper
  128. os.Elements.DebugBarLog = document.createElement("div");
  129. os.Elements.DebugBarLog.id = "com.jahova.debugBar.Log.Wrapper";
  130. os.Elements.DebugBarLog.className = "ideSidebarPageFolderView sidebarTabColor jahova_borRadL2 jahova_borRadB2 jahova_transWp5s";
  131. os.Elements.DebugBarLogTab.appendChild(os.Elements.DebugBarLog);
  132. //Debug Bar Content Header
  133. os.Elements.DebugBarLogHeader = document.createElement("div");
  134. os.Elements.DebugBarLogHeader.id = "com.jahova.debugBar.Log.Header";
  135. os.Elements.DebugBarLogHeader.className = "ideSidebarFolderHeader jahova_borRadT2 menuColor";
  136. os.Elements.DebugBarLog.appendChild(os.Elements.DebugBarLogHeader);
  137. //Debug Bar Content Header Label
  138. os.Elements.DebugBarLogHeaderLabel = document.createElement("div");
  139. os.Elements.DebugBarLogHeaderLabel.id = "com.jahova.debugBar.Log.Header.Label";
  140. os.Elements.DebugBarLogHeaderLabel.className = "ideSidebarFolderH3";
  141. os.Elements.DebugBarLogHeaderLabel.innerHTML = "JaHOVA Logs";
  142. os.Elements.DebugBarLogHeader.appendChild(os.Elements.DebugBarLogHeaderLabel);
  143. //Debug Bar Header Pin
  144. os.Elements.DebugBarLogHeaderPin = document.createElement("div");
  145. os.Elements.DebugBarLogHeaderPin.id = "com.jahova.debugBar.Log.Header.Pin";
  146. os.Elements.DebugBarLogHeaderPin.className = "ideSidebarPin";
  147. os.Elements.DebugBarLogHeaderPin.onclick = this.AnchorPage;
  148. os.Elements.DebugBarLogHeader.appendChild(os.Elements.DebugBarLogHeaderPin);
  149. //Debug Bar Icon
  150. os.Elements.DebugBarLogIconHeader = document.createElement("div");
  151. os.Elements.DebugBarLogIconHeader.id = "com.jahova.debugBar.Log.Icons";
  152. os.Elements.DebugBarLogIconHeader.className = "ideSidebarFolderIconHeader iconColor";
  153. os.Elements.DebugBarLog.appendChild(os.Elements.DebugBarLogIconHeader);
  154. //Debug Bar Content Area
  155. os.Elements.DebugBarLogContent = document.createElement("pre");
  156. os.Elements.DebugBarLogContent.id = "com.jahova.debugBar.Log.Content";
  157. os.Elements.DebugBarLogContent.className = "ideSidebarFolderContent jahova_borRadB2 viewContentBkgColor";
  158. os.Elements.DebugBarLog.appendChild(os.Elements.DebugBarLogContent);
  159. //***********************************
  160. //
  161. // SETTINGS
  162. //
  163. //***********************************
  164. //Debug Bar Tab
  165. os.Elements.DebugBarSettingsTab = document.createElement("div");
  166. os.Elements.DebugBarSettingsTab.id = "com.jahova.debugBar.Settings.Tab";
  167. os.Elements.DebugBarSettingsTab.className = "ideSidebarTabFolderView jahova_borRadR2 sidebarTabColor";
  168. os.Elements.DebugBar.appendChild(os.Elements.DebugBarSettingsTab);
  169. //Debug Bar Tab Label
  170. os.Elements.DebugBarSettingsTabLabel = document.createElement("div");
  171. os.Elements.DebugBarSettingsTabLabel.id = "com.jahova.debugBar.Settings.TabLabel";
  172. os.Elements.DebugBarSettingsTabLabel.className = "ideSidebarTabTextFolderView textColorWhite";
  173. os.Elements.DebugBarSettingsTabLabel.innerHTML = "Settings";
  174. os.Elements.DebugBarSettingsTab.appendChild(os.Elements.DebugBarSettingsTabLabel);
  175. //Debug Bar Content Wrapper
  176. os.Elements.DebugBarSettings = document.createElement("div");
  177. os.Elements.DebugBarSettings.id = "com.jahova.debugBar.Settings.Wrapper";
  178. os.Elements.DebugBarSettings.className = "ideSidebarPageFolderView sidebarTabColor jahova_borRadL2 jahova_borRadB2 jahova_transWp5s";
  179. os.Elements.DebugBarSettingsTab.appendChild(os.Elements.DebugBarSettings);
  180. //Debug Bar Content Header
  181. os.Elements.DebugBarSettingsHeader = document.createElement("div");
  182. os.Elements.DebugBarSettingsHeader.id = "com.jahova.debugBar.Settings.Header";
  183. os.Elements.DebugBarSettingsHeader.className = "ideSidebarFolderHeader jahova_borRadT2 menuColor";
  184. os.Elements.DebugBarSettings.appendChild(os.Elements.DebugBarSettingsHeader);
  185. //Debug Bar Content Header Label
  186. os.Elements.DebugBarSettingsHeaderLabel = document.createElement("div");
  187. os.Elements.DebugBarSettingsHeaderLabel.id = "com.jahova.debugBar.Settings.Header.Label";
  188. os.Elements.DebugBarSettingsHeaderLabel.className = "ideSidebarFolderH3";
  189. os.Elements.DebugBarSettingsHeaderLabel.innerHTML = "JaHOVA Settings";
  190. os.Elements.DebugBarSettingsHeader.appendChild(os.Elements.DebugBarSettingsHeaderLabel);
  191. //Debug Bar Header Pin
  192. os.Elements.DebugBarSettingsHeaderPin = document.createElement("div");
  193. os.Elements.DebugBarSettingsHeaderPin.id = "com.jahova.debugBar.Settings.Header.Pin";
  194. os.Elements.DebugBarSettingsHeaderPin.className = "ideSidebarPin";
  195. os.Elements.DebugBarSettingsHeaderPin.onclick = this.AnchorPage;
  196. os.Elements.DebugBarSettingsHeader.appendChild(os.Elements.DebugBarSettingsHeaderPin);
  197. //Debug Bar Icon
  198. os.Elements.DebugBarSettingsIconHeader = document.createElement("div");
  199. os.Elements.DebugBarSettingsIconHeader.id = "com.jahova.debugBar.Settings.Icons";
  200. os.Elements.DebugBarSettingsIconHeader.className = "ideSidebarFolderIconHeader iconColor";
  201. os.Elements.DebugBarSettings.appendChild(os.Elements.DebugBarSettingsIconHeader);
  202. //Debug Bar Content Area
  203. os.Elements.DebugBarSettingsContent = document.createElement("div");
  204. os.Elements.DebugBarSettingsContent.id = "com.jahova.debugBar.Settings.Content";
  205. os.Elements.DebugBarSettingsContent.className = "ideSidebarFolderContent jahova_borRadB2 viewContentBkgColor";
  206. os.Elements.DebugBarSettings.appendChild(os.Elements.DebugBarSettingsContent);
  207. },
  208. //******************************************
  209. //
  210. // SIDEBAR PIN FUNCTIONS
  211. //
  212. //******************************************
  213. AnchorPage: function(e){
  214. var identifier = "com.jahova.debugBar."
  215. var name = e.target.id;
  216. name = name.substring(identifier.length);
  217. name = name.substring(0, name.indexOf('.'));
  218. if(name.toUpperCase() == "CONSOLE"){
  219. os.debugbar.AnchorConsolePage(e);
  220. }
  221. else if(name.toUpperCase() == "LOG"){
  222. os.debugbar.AnchorLogsPage(e);
  223. }
  224. else if(name.toUpperCase() == "SETTINGS"){
  225. os.debugbar.AnchorSettingsPage(e);
  226. }
  227. },
  228. AnchorConsolePage: function(e){
  229. //if(e.target.classList[0] == "ideSidebarPinned"){
  230. if(os.Elements.DebugBarConsoleHeaderPin.className == "ideSidebarPinned"){
  231. os.Elements.DebugBarConsole.className = "ideSidebarPageFolderView sidebarTabColor jahova_borRadL2 jahova_borRadB2 jahova_transWp5s";
  232. os.Elements.DebugBarConsole.style.width = "";
  233. os.Elements.DebugBarConsoleHeaderPin.className = "ideSidebarPin";
  234. os.Elements.DebugBarConsoleHeaderLabel.className = "ideSidebarFolderH3";
  235. os.Elements.DebugBarConsoleContent.className = "ideSidebarFolderContent jahova_borRadB2 viewContentBkgColor";
  236. os.Elements.DebugBarConsoleHeaderLabel.innerHTML = "Terminal Window";
  237. this.ConsolePagePinned = false;
  238. }
  239. else{
  240. os.Elements.DebugBarConsole.className = "ideSidebarPageFolderViewPinned sidebarTabColor jahova_borRadL2 jahova_borRadB2";
  241. os.Elements.DebugBarConsole.style.width = "560px";
  242. os.Elements.DebugBarConsoleHeaderPin.className = "ideSidebarPinned";
  243. os.Elements.DebugBarConsoleHeaderLabel.className = "ideSidebarFolderH3Pinned";
  244. os.Elements.DebugBarConsoleContent.className = "ideSidebarFolderContentPinned jahova_borRadB2 viewContentBkgColor";
  245. os.Elements.DebugBarConsoleHeaderLabel.innerHTML = "Terminal Window";
  246. this.ConsolePagePinned = true;
  247. }
  248. },
  249. AnchorLogsPage: function(e){
  250. //if(e.target.classList[0] == "ideSidebarPinned"){
  251. if(os.Elements.DebugBarLogHeaderPin.className == "ideSidebarPinned"){
  252. os.Elements.DebugBarLog.className = "ideSidebarPageFolderView sidebarTabColor jahova_borRadL2 jahova_borRadB2 jahova_transWp5s";
  253. os.Elements.DebugBarLogHeaderPin.className = "ideSidebarPin";
  254. os.Elements.DebugBarLogHeaderLabel.className = "ideSidebarFolderH3";
  255. os.Elements.DebugBarLogContent.className = "ideSidebarFolderContent jahova_borRadB2 viewContentBkgColor";
  256. os.Elements.DebugBarLogHeaderLabel.innerHTML = "JaHOVA Logs";
  257. this.LogsPagePinned = false;
  258. }
  259. else{
  260. os.Elements.DebugBarLog.className = "ideSidebarPageFolderViewPinned sidebarTabColor jahova_borRadL2 jahova_borRadB2";
  261. os.Elements.DebugBarLogHeaderPin.className = "ideSidebarPinned";
  262. os.Elements.DebugBarLogHeaderLabel.className = "ideSidebarFolderH3Pinned";
  263. os.Elements.DebugBarLogContent.className = "ideSidebarFolderContentPinned jahova_borRadB2 viewContentBkgColor";
  264. os.Elements.DebugBarLogHeaderLabel.innerHTML = "JaHOVA Logs";
  265. this.LogsPagePinned = true;
  266. }
  267. },
  268. AnchorSettingsPage: function(e){
  269. //if(e.target.classList[0] == "ideSidebarPinned"){
  270. if(os.Elements.DebugBarSettingsHeaderPin.className == "ideSidebarPinned"){
  271. os.Elements.DebugBarSettings.className = "ideSidebarPageFolderView sidebarTabColor jahova_borRadL2 jahova_borRadB2 jahova_transWp5s";
  272. os.Elements.DebugBarSettingsHeaderPin.className = "ideSidebarPin";
  273. os.Elements.DebugBarSettingsHeaderLabel.className = "ideSidebarFolderH3";
  274. os.Elements.DebugBarSettingsContent.className = "ideSidebarFolderContent jahova_borRadB2 viewContentBkgColor";
  275. os.Elements.DebugBarSettingsHeaderLabel.innerHTML = "JaHOVA Settings";
  276. this.SettingsPagePinned = false;
  277. }
  278. else{
  279. os.Elements.DebugBarSettings.className = "ideSidebarPageFolderViewPinned sidebarTabColor jahova_borRadL2 jahova_borRadB2";
  280. os.Elements.DebugBarSettingsHeaderPin.className = "ideSidebarPinned";
  281. os.Elements.DebugBarSettingsHeaderLabel.className = "ideSidebarFolderH3Pinned";
  282. os.Elements.DebugBarSettingsContent.className = "ideSidebarFolderContentPinned jahova_borRadB2 viewContentBkgColor";
  283. os.Elements.DebugBarSettingsHeaderLabel.innerHTML = "JaHOVA Settings";
  284. this.SettingsPagePinned = true;
  285. }
  286. },
  287. EvaluateShortCuts:function(e){
  288. var keyCode = e.keyCode ? e.keyCode : e.charCode;
  289. //Ctrl Key
  290. // Short Cuts
  291. if(e.ctrlKey){
  292. //~ ` key - Hide/Show Debug Bar
  293. if (keyCode == 192)
  294. {
  295. if(os.debugbar.GetStatus()){
  296. //Disable Debug Bar
  297. os.debugbar.Disable();
  298. }
  299. else{
  300. //Enable Debug Bar
  301. os.debugbar.Enable();
  302. }
  303. }
  304. }
  305. }
  306. }
  307. }
  308. return {
  309. //OBJECT ACCESSOR
  310. Instance: function()
  311. {
  312. if(!pInstance)
  313. {
  314. //Instantiate if pInstance does not exist
  315. pInstance = constructor();
  316. }
  317. return pInstance;
  318. }
  319. }
  320. })();