Skip to content

Commit cea5f2a

Browse files
authored
Merge pull request #113 from easycoder/dev
Copy URL of image
2 parents 30ef6a0 + 801e187 commit cea5f2a

File tree

7 files changed

+153
-75
lines changed

7 files changed

+153
-75
lines changed

dist/easycoder-min.js

Lines changed: 71 additions & 70 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/easycoder.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3397,6 +3397,37 @@ const EasyCoder_Browser = {
33973397
}
33983398
},
33993399

3400+
Copy: {
3401+
3402+
compile: (compiler) => {
3403+
const lino = compiler.getLino();
3404+
if (compiler.nextIsSymbol()) {
3405+
const symbolRecord = compiler.getSymbolRecord();
3406+
if (symbolRecord.keyword === `input`) {
3407+
compiler.next();
3408+
compiler.addCommand({
3409+
domain: `browser`,
3410+
keyword: `copy`,
3411+
lino,
3412+
name: symbolRecord.name
3413+
});
3414+
return true;
3415+
}
3416+
}
3417+
return false;
3418+
},
3419+
3420+
run: (program) => {
3421+
const command = program[program.pc];
3422+
const targetRecord = program.getSymbolRecord(command.name);
3423+
const element = targetRecord.element[targetRecord.index];
3424+
element.select();
3425+
element.setSelectionRange(0, 99999); // For mobile devices
3426+
document.execCommand("copy");
3427+
return command.pc + 1;
3428+
}
3429+
},
3430+
34003431
Create: {
34013432

34023433
compile: (compiler) => {
@@ -5707,6 +5738,8 @@ const EasyCoder_Browser = {
57075738
return EasyCoder_Browser.Click;
57085739
case `convert`:
57095740
return EasyCoder_Browser.Convert;
5741+
case `copy`:
5742+
return EasyCoder_Browser.Copy;
57105743
case `create`:
57115744
return EasyCoder_Browser.Create;
57125745
case `disable`:

iwsy/resources/ecs/fileman.txt

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
div Uploader
1313
div Buttons
1414
div Location
15+
div URLPanel
1516
span UploadStatus
1617
progress UploadProgress
1718
input UploadFile
1819
input URL
20+
button CopyURLButton
1921
button CloseButton
2022
button NewFolderButton
2123
button UploadButton
@@ -47,7 +49,7 @@
4749

4850
create Panel in Container
4951
if Mobile set the style of Panel to `background:#ffe`
50-
else set the style of Panel to `width:100%;height:100%;background:#ffe`
52+
else set the style of Panel to `width:100%;height:100%`
5153

5254
create Tracer in Panel
5355
set attribute `id` of Tracer to `easycoder-tracer`
@@ -86,13 +88,22 @@
8688
set the style of FileListing to `width:100%;height:80%;text-align:center`
8789
create Location in FileListing
8890
set the style of Location to `width:100%;text-align:left;color:black;padding:0 0.5em`
89-
create URL in FileListing
90-
set the style of URL to `display:none;width:100%;text-align:left;font-family:sans;color:black;padding:0 0.5em`
91+
92+
create URLPanel in FileListing
93+
set the style of URLPanel to `display:none`
94+
create URL in URLPanel
95+
set the style of URL to `flex:1;text-align:left;font-family:sans;color:black;padding:0 0.5em`
96+
create CopyURLButton in URLPanel
97+
set the style of CopyURLButton to `width:8em;margin:0.2em 0.5em 0.2em 1em`
98+
set the text of CopyURLButton to `Copy URL`
99+
set attribute `title` of CopyURLButton to `Copy the URL of this image`
91100

92101
create Scroller in FileListing
93102
set the style of Scroller to `width:100%;height:100%;text-align:left;overflow-y:scroll;font-family:mono`
94103
create Image in FileListing
95104
set the style of Image to `margin:0 auto;max-width:100%;max-height:100%`
105+
106+
on click CopyURLButton copy URL
96107

97108
on click NewFolderButton
98109
begin
@@ -220,7 +231,7 @@ SelectFile:
220231
set style `display` of UploadButton to `none`
221232
set style `display` of NewFolderButton to `none`
222233
set style `display` of Location to `none`
223-
set style `display` of URL to `block`
234+
set style `display` of URLPanel to `flex`
224235

225236
set style `display` of Scroller to `none`
226237
set style `display` of Image to `block`
@@ -249,7 +260,7 @@ CloseMedia:
249260
set style `display` of NewFolderButton to `inline-block`
250261
set the content of Location to `Current path: ` cat CurrentPath
251262
set style `display` of Location to `block`
252-
set style `display` of URL to `none`
263+
set style `display` of URLPanel to `none`
253264
on click CloseButton go to Exit
254265
go to Browser
255266

iwsy/resources/img/SemoigoDawn.jpg

-171 KB
Binary file not shown.

iwsy/resources/img/flowers.jpg

-74.1 KB
Binary file not shown.

iwsy/resources/img/moon.jpg

-64.1 KB
Binary file not shown.

js/easycoder/Browser.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,37 @@ const EasyCoder_Browser = {
329329
}
330330
},
331331

332+
Copy: {
333+
334+
compile: (compiler) => {
335+
const lino = compiler.getLino();
336+
if (compiler.nextIsSymbol()) {
337+
const symbolRecord = compiler.getSymbolRecord();
338+
if (symbolRecord.keyword === `input`) {
339+
compiler.next();
340+
compiler.addCommand({
341+
domain: `browser`,
342+
keyword: `copy`,
343+
lino,
344+
name: symbolRecord.name
345+
});
346+
return true;
347+
}
348+
}
349+
return false;
350+
},
351+
352+
run: (program) => {
353+
const command = program[program.pc];
354+
const targetRecord = program.getSymbolRecord(command.name);
355+
const element = targetRecord.element[targetRecord.index];
356+
element.select();
357+
element.setSelectionRange(0, 99999); // For mobile devices
358+
document.execCommand("copy");
359+
return command.pc + 1;
360+
}
361+
},
362+
332363
Create: {
333364

334365
compile: (compiler) => {
@@ -2639,6 +2670,8 @@ const EasyCoder_Browser = {
26392670
return EasyCoder_Browser.Click;
26402671
case `convert`:
26412672
return EasyCoder_Browser.Convert;
2673+
case `copy`:
2674+
return EasyCoder_Browser.Copy;
26422675
case `create`:
26432676
return EasyCoder_Browser.Create;
26442677
case `disable`:

0 commit comments

Comments
 (0)