|
7 | 7 |
|
8 | 8 | <script> |
9 | 9 | (function () { |
| 10 | + var color = localStorage.getItem("__primary_color"); |
| 11 | + var __bg_color = "#20202c"; |
| 12 | + if (color) { |
| 13 | + __bg_color = color; |
| 14 | + } |
| 15 | + |
| 16 | + document.querySelector(":root").style.cssText = |
| 17 | + "--bg-color: " + __bg_color; |
| 18 | + |
10 | 19 | var __testEl = document.createElement("div"); |
11 | 20 | var __testChildEl = document.createElement("div"); |
12 | 21 | if (__testEl.append) { |
|
30 | 39 | this.appendChild(docFrag); |
31 | 40 | }; |
32 | 41 | } |
| 42 | + })(); |
33 | 43 |
|
34 | | - function startsWith(string, needle) { |
35 | | - return string.indexOf(needle) === 0; |
| 44 | + // save all touch events added by ace editor so it can be use in src/ade/touchHandler.js |
| 45 | + var __oldAddEventListener = HTMLElement.prototype.addEventListener; |
| 46 | + HTMLElement.prototype.addEventListener = function ( |
| 47 | + type, |
| 48 | + listener, |
| 49 | + useCapture, |
| 50 | + allowed, |
| 51 | + ) { |
| 52 | + if (typeof useCapture === "boolean") { |
| 53 | + allowed = useCapture; |
| 54 | + useCapture = undefined; |
36 | 55 | } |
37 | 56 |
|
38 | | - // save all touch events added by ace editor so it can be use in src/ade/touchHandler.js |
39 | | - var __oldAddEventListener = HTMLElement.prototype.addEventListener; |
40 | | - HTMLElement.prototype.addEventListener = function ( |
41 | | - type, |
42 | | - listener, |
43 | | - useCapture, |
44 | | - allowed, |
45 | | - ) { |
46 | | - if (typeof useCapture === "boolean") { |
47 | | - allowed = useCapture; |
48 | | - useCapture = undefined; |
49 | | - } |
| 57 | + if (type === "contextmenu" && !allowed) { |
| 58 | + return; |
| 59 | + } |
50 | 60 |
|
51 | | - if (type === "contextmenu" && !allowed) { |
52 | | - return; |
53 | | - } |
| 61 | + if (allowed) { |
| 62 | + __oldAddEventListener.call(this, type, listener, useCapture); |
| 63 | + return; |
| 64 | + } |
54 | 65 |
|
55 | | - if (allowed) { |
56 | | - __oldAddEventListener.call(this, type, listener, useCapture); |
57 | | - return; |
| 66 | + if ( |
| 67 | + this.classList.contains("editor-container") && |
| 68 | + type.indexOf("touch") === 0 |
| 69 | + ) { |
| 70 | + if (!this.eventListeners) { |
| 71 | + this.eventListeners = {}; |
58 | 72 | } |
59 | 73 |
|
60 | | - if ( |
61 | | - this.classList.contains("editor-container") && |
62 | | - startsWith(type, "touch") |
63 | | - ) { |
64 | | - if (!this.eventListeners) { |
65 | | - this.eventListeners = {}; |
66 | | - } |
67 | | - |
68 | | - if (!this.eventListeners[type]) { |
69 | | - this.eventListeners[type] = []; |
70 | | - } |
71 | | - this.eventListeners[type].push({ |
72 | | - listener: listener, |
73 | | - useCapture: useCapture, |
74 | | - }); |
75 | | - |
76 | | - return; |
| 74 | + if (!this.eventListeners[type]) { |
| 75 | + this.eventListeners[type] = []; |
77 | 76 | } |
78 | | - __oldAddEventListener.call(this, type, listener, useCapture); |
79 | | - }; |
80 | | - })(); |
| 77 | + this.eventListeners[type].push({ |
| 78 | + listener: listener, |
| 79 | + useCapture: useCapture, |
| 80 | + }); |
| 81 | + |
| 82 | + return; |
| 83 | + } |
| 84 | + __oldAddEventListener.call(this, type, listener, useCapture); |
| 85 | + }; |
81 | 86 | </script> |
82 | 87 |
|
83 | 88 | <script src="cordova.js"></script> |
|
98 | 103 | <script src="./js/ace/ext-static_highlight.js"></script> |
99 | 104 | <script src="./js/ace/ext-inline_autocomplete.js"></script> |
100 | 105 |
|
101 | | - <script> |
102 | | - (function () { |
103 | | - var color = localStorage.getItem("__primary_color"); |
104 | | - var __bg_color = "#20202c"; |
105 | | - if (color) { |
106 | | - __bg_color = color; |
107 | | - } |
108 | | - |
109 | | - document.querySelector(":root").style.cssText = |
110 | | - "--bg-color: " + __bg_color; |
111 | | - })(); |
112 | | - </script> |
113 | | - |
114 | | - <script></script> |
115 | | - |
116 | 106 | <style> |
117 | 107 | :root { |
118 | 108 | --test-height: 45px; |
|
162 | 152 |
|
163 | 153 | <script src="./build/main.js"></script> |
164 | 154 | <link rel="stylesheet" href="./build/main.css"> |
165 | | - |
166 | 155 | <title>Acode</title> |
167 | 156 | </head> |
168 | 157 |
|
|
0 commit comments