Skip to content

Commit bd8f355

Browse files
save file
1 parent 7fc7319 commit bd8f355

File tree

1 file changed

+192
-0
lines changed

1 file changed

+192
-0
lines changed
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
2+
3+
4+
<main-menu v2.0 style='position:relative'>
5+
6+
<template shadowrootmode=open>
7+
8+
<style>
9+
10+
#icon
11+
{padding:3px;width:20px;background:buttonface}
12+
13+
.menu
14+
{position:absolute;left:0;top:35px;}
15+
16+
</style>
17+
18+
<img id=icon class=icon src='data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAAAt1BMVEVHcEwbmPYcgfMchvQbsfkay/wbtvkbnfccefMayfwbmfYch/QchvQbtfkbmfYa1P0ddfIcivQcl/Ycj/Ubp/gcmfYdbPEbrvkazPwcmfYbqfgayfwayPwbv/sbvvobsvkazPwbqvga0fwbvPobtvocjvUbofcbpvccfPMcgPMcgvMdafAdbfEckfUbtvka0PwcfPIaxvsbwfsbvPodb/EcnPYclvYckfUbpvccjPQdd/IbofcbrPiPy8D0AAAAMHRSTlMAA/79/v7+5ycVZ3Y3h0xhu9jp8kFeF9OkVfQOrZi+Mh1z/iUJQ+/dx4fOYq7hybzs5xU1AAABIklEQVQ4y+2Ux3aDMBBFpTR6M92AwYB7S6EG/v+7MsJJnBBKVsnGdwHozT1HQgxC6MrfEkiSM+Y4khSgUxhazLDHWGF4QveAO2gyLnGQ9QS4wcDaXGJYiPGegVnU50UzUvdgTsd7AfrMaEaqXvO+sfAAHP0uzz+SmhCfR7FwB5gdpm+SyoeHEJ5P67o2tbanmRBP5/iSgFkUxaplaisIv3kAu6yqihK/RiIF0ZJtT6NTaZpS9iWwm0D/uXB7kmXZ5LOgN0O7ayvEQ57nKtssCbMqDA5i9+YulLIsVQ5MzKnwqCz6Phev3AIcxhy5K3x/A/DbG2CzIdctP9RS9PrxnTU92KOYll8bZHqs7Wk5AcY9hIx9kuyN3/xuxm5nXA+df+cNJSAgjMbiFSoAAAAASUVORK5CYII='>
19+
20+
<div class=menu style='display:none'>
21+
<div id=clear class=menu-opt>clear</div>
22+
<div id=new class=menu-opt>new</div>
23+
<div id=fork class=menu-opt>fork</div>
24+
<div class=menu-sep></div>
25+
<div id=source class=menu-opt>html editor source code</div>
26+
<div class=menu-sep></div>
27+
<div id=create-html-icon class=menu-opt>create html icon</div>
28+
</div>
29+
30+
</template>
31+
32+
33+
34+
<script>
35+
36+
(function main_menu({mod,dom,host}){
37+
38+
var obj = {
39+
version : 'v2.0',
40+
};
41+
42+
var df=true
43+
;
44+
45+
var $,editor,menu,filemod
46+
;
47+
48+
obj.initmod = function(params){
49+
50+
$ = params.$;
51+
editor = params.editor;
52+
menu = params.menu;
53+
filemod = params.filemod;
54+
55+
}//initomd
56+
57+
58+
//vars:-
59+
60+
61+
obj.init = function(){
62+
}//init
63+
64+
65+
//:
66+
67+
68+
obj.initdom = function(rootnode){
69+
70+
var shadow = host.shadowRoot;
71+
72+
var style = $(shadow,'style');
73+
$.stylesheet.copyrule('#page-inline','.icon',style);
74+
75+
menu.add.style(shadow);
76+
77+
78+
var card = $(shadow,'.menu');
79+
$(shadow,'#icon').onclick = menu.click(card,false,false,click);
80+
81+
82+
}//initdom
83+
84+
85+
//:
86+
87+
88+
function click(type,opt){
89+
90+
if(type=='opt'){
91+
click[opt.id]();
92+
}
93+
94+
}//menu
95+
96+
97+
click.clear = function(){
98+
99+
filemod.clear();
100+
editor.clear();
101+
editor.filename.clear();
102+
103+
}//clear
104+
105+
106+
click.new = function(){
107+
108+
var url = window.location.toString();
109+
var search = window.location.search;
110+
if(search){
111+
url = url.slice(0,-search.length);
112+
}
113+
114+
var win = window.open(url);
115+
return win;
116+
117+
}//new
118+
119+
120+
click.fork = function(){
121+
122+
var win = newwin();
123+
var txt = editor.getValue();
124+
win.postMessage({txt},'*');
125+
126+
}//fork
127+
128+
129+
click.trim = function(){
130+
131+
var pos = editor.getCursorPosition();
132+
var txt = editor.getValue();
133+
var lines = txt.split('\n');
134+
lines = lines.map(line=>line.trimEnd());
135+
txt = lines.join('\n');
136+
editor.setValue(txt,-1);
137+
editor.gotoLine(pos.row,pos.column);
138+
139+
}//trim
140+
141+
142+
click['create-html-icon'] = async function(){
143+
144+
var err;
145+
try{
146+
147+
var url = 'https://raw.githubusercontent.com/javascript-2020/javascript-2020.github.io/main/utils/html-editor/mods/create-html-icon/create-html-icon.html';
148+
var res = await fetch(url);
149+
150+
}
151+
catch(err2){
152+
153+
err = err2;
154+
155+
}
156+
if(err){
157+
log.error(err);
158+
return;
159+
}
160+
161+
var txt = await res.text();
162+
if(!res.ok){
163+
log.red(txt);
164+
return;
165+
}
166+
167+
editor.set(txt);
168+
169+
}//create-html-icon
170+
171+
172+
click.source = function(){
173+
174+
window.open('https://github.com/javascript-2020/javascript-2020.github.io/tree/main/utils/html-editor');
175+
176+
}//source
177+
178+
179+
180+
181+
return obj;
182+
183+
})//main_menu
184+
185+
186+
</script>
187+
188+
189+
</main-menu>
190+
191+
192+

0 commit comments

Comments
 (0)