Skip to content

Commit b1467a6

Browse files
save file
1 parent 4b76637 commit b1467a6

File tree

1 file changed

+42
-5
lines changed

1 file changed

+42
-5
lines changed

utils/editors/html/auto-save/v2.0/auto-save-v2.0.html

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@
4747
save menu
4848
</div>
4949

50-
<div class=menu-item>
50+
<div id=autosave class=menu-item>
5151
<div class=menu-label>
5252
autosave
5353
</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'>
5656
</div>
5757

5858
<div id=trim class=menu-item>
@@ -100,9 +100,13 @@
100100
//:
101101

102102

103+
obj.checked = null;
104+
obj.trim = null;
105+
103106
Object.defineProperty(obj,'checked',{get:()=>autosave.checked,set:v=>autosave.checked=v});
104107

105108

109+
106110
var autosave;
107111

108112

@@ -115,6 +119,10 @@
115119
timer.onclick = null;
116120

117121

122+
123+
obj.txt = {};
124+
125+
118126
//:
119127

120128

@@ -150,9 +158,14 @@
150158
$(shadow,'.menu-icon').onclick = menu.click(savemenu,savemenu_callback);
151159
menu.input.norm(savemenu);
152160

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]');
154164
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');
156169

157170

158171
}//initdom
@@ -219,6 +232,30 @@
219232
}//timer.onclick
220233

221234

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+
222259
//:
223260

224261

0 commit comments

Comments
 (0)