|
47 | 47 | save menu |
48 | 48 | </div> |
49 | 49 |
|
50 | | - <div class=menu-item> |
| 50 | + <div id=autosave class=menu-item> |
51 | 51 | <div class=menu-label> |
52 | 52 | autosave |
53 | 53 | </div> |
54 | | - <input id=timer-chk type=checkbox checked> |
55 | | - <input id=timer-value value=300 style='width:60px'> |
| 54 | + <input type=checkbox checked> |
| 55 | + <input value=300 style='width:60px'> |
56 | 56 | </div> |
57 | 57 |
|
58 | 58 | <div id=trim class=menu-item> |
|
100 | 100 | //: |
101 | 101 |
|
102 | 102 |
|
| 103 | + obj.checked = null; |
| 104 | + obj.trim = null; |
| 105 | + |
103 | 106 | Object.defineProperty(obj,'checked',{get:()=>autosave.checked,set:v=>autosave.checked=v}); |
104 | 107 |
|
105 | 108 |
|
| 109 | + |
106 | 110 | var autosave; |
107 | 111 |
|
108 | 112 |
|
|
115 | 119 | timer.onclick = null; |
116 | 120 |
|
117 | 121 |
|
| 122 | + |
| 123 | + obj.txt = {}; |
| 124 | + |
| 125 | + |
118 | 126 | //: |
119 | 127 |
|
120 | 128 |
|
|
150 | 158 | $(shadow,'.menu-icon').onclick = menu.click(savemenu,savemenu_callback); |
151 | 159 | menu.input.norm(savemenu); |
152 | 160 |
|
153 | | - timer.chk = $(savemenu,'#timer-chk'); //':scope>div:nth-of-type(2) [type=checkbox]'); |
| 161 | + //$.chkbox(savemenu,'#autosave'); |
| 162 | + |
| 163 | + timer.chk = $.chkbox(savemenu,'#autosave'); //$(savemenu,'[type]'); //':scope>div:nth-of-type(2) [type=checkbox]'); |
154 | 164 | timer.chk.onclick = timer.onclick; |
155 | | - timer.time = $(savemenu,'#timer-value'); //':scope>div:nth-of-type(2) input:not([type])'); |
| 165 | + timer.time = $(savemenu,'[value]'); //':scope>div:nth-of-type(2) input:not([type])'); |
| 166 | + |
| 167 | + |
| 168 | + obj.trim = $.chkbox(savemenu,'#trim'); |
156 | 169 |
|
157 | 170 |
|
158 | 171 | }//initdom |
|
219 | 232 | }//timer.onclick |
220 | 233 |
|
221 | 234 |
|
| 235 | + //: |
| 236 | + |
| 237 | + |
| 238 | + obj.txt.trim = function(txt){ |
| 239 | + |
| 240 | + var indent = 0; |
| 241 | + var lines = txt.split('\n'); |
| 242 | + lines = lines.map(line=>{ |
| 243 | + |
| 244 | + line = line.trimEnd(); |
| 245 | + if(line.length==0){ |
| 246 | + line = line.padStart(indent,' '); |
| 247 | + } |
| 248 | + var match = line.match(/^\s*/); |
| 249 | + indent = match ? match[0].length : indent; |
| 250 | + return line; |
| 251 | + |
| 252 | + }); |
| 253 | + txt = lines.join('\n'); |
| 254 | + return txt; |
| 255 | + |
| 256 | + }//trim |
| 257 | + |
| 258 | + |
222 | 259 | //: |
223 | 260 |
|
224 | 261 |
|
|
0 commit comments