/
HTMLImagePreview.xys
874 lines (753 loc) · 26.8 KB
/
HTMLImagePreview.xys
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
/*#############################################################################\
HTMLImagePreview.xys
Creates an HTML page for previewing and selecting images.
[ABOUT]
Author = TheQwerty
Version = 2.2
Date = 2015-05-18 13:14z
Requires = XYplorer v15.00.0000
Source = https://github.com/XYplorer-Scripts/HTMLImagePreview
[]
\#############################################################################*/
/*******************************************************************************
** Preview Images
** Displays a preview for the specified, selected, or listed images.
*******************************************************************************/
"&Preview Images||1 : showPreview"
// ----- PARAMETERS ----------------------------------------------------------
// IN: G_ITEMS [optional]
// A CRLF-separated list of items to filter and preview.
// If omitted and more than 2 items are selected, the selection is used.
// Otherwise the list contents will be shown.
Global $G_ITEMS;
// IN: G_IMAGES [optional]
// A CRLF-separated list of images to preview.
// If omitted and more than 2 items are selected, the selection is used.
// Otherwise the list contents will be shown.
// Note that setting this variable bypasses any filtering including those
// specified by G_FILTERS_OVERRIDE and this takes precedence over G_ITEMS.
Global $G_IMAGES;
// IN: G_FILTERS_OVERRIDE [optional]
// A CRLF, semicolon (;), or pipe (|) separated list of filters to use
// instead of the configured ones.
// If omitted the configured filters or generic {:Image} file type are used.
Global $G_FILTERS_OVERRIDE;
// OUT: G_RESULTS
// A |-separated list of images the user selected in the preview.
Global $G_RESULTS = '';
// ----- END PARAMETERS ------------------------------------------------------
// Get options.
Sub '_getOptions';
Global $G_FILTERS, $G_PREVIEW_SIZE, $G_COLORS, $G_IMAGE_LIMIT;
$sep = <crlf>;
$source = '';
// Get images.
if ($G_IMAGES != '') {
// Use global image list.
$source = ' specified';
$images = ReplaceList($G_IMAGES, "| <crlf>", $sep, ' ');
$images = FormatList($images, 'det', $sep);
} else {
if ($G_ITEMS != '') {
// Use specified items.
$source = ' specified';
$items = ReplaceList($G_ITEMS, "| <crlf>", $sep, ' ');
$items = FormatList($items, 'det', $sep);
} elseif (Get('CountSelected') > 1) {
// Use current selection.
$source = ' selected';
$items = Get('SelectedItemsPathNames', $sep);
} else {
// Use list contents.
$source = ' listed';
$items = ListPane('a', '*', 1, $sep);
}
// Determine which filters to use.
if ($G_FILTERS_OVERRIDE == '') {
$filters = $G_FILTERS;
} else {
$filters = ReplaceList($G_FILTERS_OVERRIDE, '; |', <crlf>, ' ');
}
// Stored filters are CRLF-separated, convert to local $sep.
if ($sep != <crlf>) {
$filters = Replace($filters, <crlf>, $sep);
}
// Filter the list of items to just the images.
$images = FormatList($items, 'deft', $sep, $filters);
}
// End if there's nothing to see...
$imageCnt = GetToken($images, 'Count', $sep);
End $imageCnt < 1, 'No images to display.';
// Cap the number of images - otherwise building the HTML freezes XY.
if ($imageCnt > $G_IMAGE_LIMIT) {
$images = GetToken($images, $G_IMAGE_LIMIT, $sep,, 1);
$limitDiv = <<<LIMITMSG
<div id='warning'>Sorry, display has been limited to the first $G_IMAGE_LIMIT$source images (of $imageCnt).</div>
LIMITMSG;
} else {
$s = $imageCnt == 1 ? '' : 's';
$limitDiv = <<<LIMITMSG
<div>$imageCnt$source image$s.</div>
LIMITMSG;
}
// Build up the div blocks for each image.
$imageDivs = '';
$idx = 0;
foreach ($image, $images, $sep) {
$idx++;
if ($image == '') { continue; }
// Get & escape file name.
$title = ReplaceList(GetPathComponent($image, 'file'), '&', '&', '|');
$imageDivs = <<<IMAGEDIV
$imageDivs
<div class='box'>
<span class='handle'> </span>
<input class='cb' type='checkbox' name="$idx" id="$idx">
<label class='boxInner' for="$idx">
<img src="$image" />
<div class='titleBox'>$title</div>
</label>
</input>
</div>
IMAGEDIV;
}
// Split up the color options.
$bodyBGColor = GetToken($G_COLORS, 1, '|', 't');
$thumbBGColor = GetToken($G_COLORS, 2, '|', 't');
$selColor = GetToken($G_COLORS, 3, '|', 't');
// Build up the HTML document.
$html = <<<HTMLDOCUMENT
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='x-ua-compatible' content='IE=edge'></meta>
<!-- Enable responsive view on mobile devices -->
<meta name='viewport' content='width=device-width, initial-scale=1.0' />
<link href='https://cdn.rawgit.com/bevacqua/dragula/master/dist/dragula.min.css' rel='stylesheet' type='text/css' />
<style type='text/css'>
body {
margin: 0;
padding-left: 0;
padding-right: 0;
padding-top: 0;
padding-bottom: 250px;
background: $bodyBGColor;
}
.wrap {
padding-top:5px;
overflow: hidden;
margin: 10px;
}
input.cb {
position:relative;
z-index:1;
}
input.cb:checked ~ label {
background: $selColor;
}
input.cb:checked ~ label img {
opacity: 0.50;
}
.handle {
cursor:move;
background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg==);
background-repeat: no-repeat;
width:10px;
height:30px;
padding-top:5px;
padding-right:3px;
}
#warning {
padding:10px;
background: #FAA;
font-color: #A00;
}
form {
position:relative;
}
.buttons {
position:fixed;
left:0;
right:0;
bottom:0;
height:32px;
padding: 8px;
background: $bodyBGColor;
z-index:2;
}
.buttons .left {
float:left;
}
.buttons .right {
float:right;
}
#submit {
margin-left:20px;
}
.box {
float: left;
position: relative;
width: 20%;
padding-bottom: 200%;
}
.boxInner {
position: absolute;
left: 10px;
right: 10px;
top: 10px;
bottom: 10px;
overflow: hidden;
<!-- new -->
vertical-align:middle;
text-align:center;
background: $thumbBGColor;
}
.boxInner img {
max-width: 100%;
max-height: 100%;
}
.rotateCW {
-ms-transform: rotate(90deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);
transform: rotate(90deg);
}
.rotateCCW {
-ms-transform: rotate(-90deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
transform: rotate(-90deg);
}
.rotateFlip {
-ms-transform: rotate(180deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2);
transform: rotate(180deg);
}
.boxInner .titleBox {
position: absolute;
bottom: 0;
left: 0;
right: 0;
margin-bottom: -100px;
background: #000;
background: rgba(0, 0, 0, 0.5);
color: #FFF;
padding: 2px;
text-align: center;
-webkit-transition: all 0.5s ease-out;
-moz-transition: all 0.5s ease-out;
-o-transition: all 0.5s ease-out;
transition: all 0.5s ease-out;
}
body.no-touch .boxInner:hover .titleBox,
body.touch .boxInner.touchFocus .titleBox {
margin-bottom: 0;
}
@media only screen and (max-width : 480px) {
/* Smartphone view: 1 tile */
.box {
width: 100%;
padding-bottom: 60%;
}
}
@media only screen and (max-width : 650px) and (min-width : 481px) {
/* Tablet view: 2 tiles */
.box {
width: 50%;
padding-bottom: 30%;
}
}
@media only screen and (max-width : 1050px) and (min-width : 651px) {
/* Small desktop / ipad view: 3 tiles */
.box {
width: 33.3%;
padding-bottom: 20%;
}
}
@media only screen and (max-width : 1290px) and (min-width : 1051px) {
/* Medium desktop: 4 tiles */
.box {
width: 25%;
padding-bottom: 15%;
}
}
@media only screen and (min-width : 1291px) {
.box {
width: 20%;
padding-bottom: 12%;
}
}
</style>
</head>
<script>
function check(v) {
var a = document.getElementsByTagName('input');
for(var i=0,j=a.length;i<j;i++){
if (a[i].type == 'checkbox' && a[i].className == 'cb'){
a[i].checked = v;
}
}
}
function invert() {
var a = document.getElementsByTagName('input');
for(var i=0,j=a.length;i<j;i++){
if (a[i].type == 'checkbox' && a[i].className == 'cb'){
a[i].checked = !a[i].checked;
}
}
}
function checkAll() { check(true); }
function checkNone() { check(false); }
function rotate(newClass) {
var cb = document.getElementById('rotateSelection');
if (cb.checked) {
var a = document.getElementsByTagName('input');
for(var i=0,j=a.length;i<j;i++){
if (a[i].type == 'checkbox' && a[i].className == 'cb' && a[i].checked){
var ai = a[i].parentElement.getElementsByTagName('img');
if (ai.length > 0) {
ai[0].className = newClass;
}
}
}
} else {
var imgs = document.getElementsByTagName('img');
for(var i=0,j=imgs.length;i<j;i++){
imgs[i].className = newClass;
}
}
}
</script>
<body class='no-touch'>
$limitDiv
<form action='xys:' method='get'>
<div class='wrap container' id='container'>
$imageDivs
</div>
<div class='buttons'>
<span class="left">
<input type='button' value='Normal' onclick='rotate("");' />
<input type='button' value='90°' onclick='rotate("rotateCW");' />
<input type='button' value='180°' onclick='rotate("rotateFlip");' />
<input type='button' value='270°' onclick='rotate("rotateCCW");' />
<input type='checkbox' id='rotateSelection' /><label for='rotateSelection'>Selection Only</label>
</span>
<span class="right">
<input type='button' value='All' onclick='checkAll();' />
<input type='button' value='None' onclick='checkNone();' />
<input type='button' value='Invert' onclick='invert();' />
<input type='submit' value='OK' id='submit' />
</span>
</div>
</form>
<script src='https://cdn.rawgit.com/bevacqua/dragula/master/dist/dragula.min.js'></script>
<script>
if (dragula) {
dragula([container], {
moves: function (el, container, handle) {
return handle.className === 'handle';
}
});
}
// Focus submit button.
document.getElementById('submit').focus();
// Make clicking images toggle their checkbox.
var a = document.getElementsByTagName('label');
for(var i=0,j=a.length;i<j;i++){
var b = a[i].getElementsByTagName('img');
for(var k=0,l=b.length;k<l;k++){
b[k].forid = a[i].htmlFor;
b[k].onclick = function(){
var e = document.getElementById(this.forid);
e.checked = !e.checked;
}
}
}
</script>
</body>
</html>
HTMLDOCUMENT;
// Determine window size.
$width = GetToken($G_PREVIEW_SIZE, 1, 'x', 't');
$height = GetToken($G_PREVIEW_SIZE, 2, 'x', 't');
$caption = 'Select Images';
// The crap we do to get some decent rendering from WebBrowser :rolls:
// To get it to obey the x-ua-compatible the content must be saved to a file.
$htmlFile = "%tmp%\XYImages-<date yyyymmddhhnnss>.html";
if (WriteFile($htmlFile, $html, 'o') % 2 == 1) {
$result = html($htmlFile, $width, $height, $caption);
delete 1, 0, $htmlFile;
} else {
$result = html($html, $width, $height, $caption);
}
// Select selected images.
$result = UrlDecode($result);
$result = RegexReplace($result, '\?|=on&?', '|');
$result = FormatList($result, 'det', '|');
// Convert selected indexes into paths.
$results = '';
foreach ($idx, $result, '|') {
$item = GetToken($images, $idx, $sep);
if ($item != '') {
$results = $results . $item . '|';
}
}
$G_RESULTS = FormatList($results, 'det', '|');
/************************************************************ END showPreview */
"-" //--------------------------------------------------------------------------
/*******************************************************************************
** Preview & Filter Images
** Shows the preview then filters the selected images.
*******************************************************************************/
"Preview && &Filter Images : filter"
Sub 'showPreview';
Global $G_RESULTS;
if ($G_RESULTS != '') {
$vf = '';
foreach ($item, $G_RESULTS, '|') {
if ($item == '') { continue; }
$vf = $vf . '|' . Quote(GetPathComponent($item, 'File'));
Filter SubStr($vf, 1), 1;
}
}
/***************************************************************** END filter */
/*******************************************************************************
** Preview & Paper Folder Images
** Shows the preview then creates a paper folder for the selected images.
*******************************************************************************/
"Preview && P&aper Folder Images : paperFolder"
Sub 'showPreview';
Global $G_RESULTS;
if ($G_RESULTS != '') {
if (0 == Exists(<xypaper>)) {
New(<xypaper>, 'dir',, 'u');
}
$pf = InputFile(<xypaper>, 'txt', 'Save to Paper Folder');
PaperFolder($pf, $G_RESULTS, '|', 'nl');
}
/************************************************************ END paperFolder */
/*******************************************************************************
** Preivew & Preview & Preview Images
** Shows the preview then shows the preview again for the selected images.
** All the way down.
*******************************************************************************/
"Preview && Pr&eview && Preview Images : narrow"
Sub 'showPreview';
Global $G_RESULTS;
while ($G_RESULTS != '') {
Global $G_IMAGES = $G_RESULTS;
Sub 'showPreview';
}
/***************************************************************** END narrow */
/*******************************************************************************
** Preview & Select Images
** Shows the preview then selects the selected images.
*******************************************************************************/
"Preview && &Select Images : select"
Sub 'showPreview';
Global $G_RESULTS;
if ($G_RESULTS != '') {
SelectItems $G_RESULTS, 2, 1, 'n', 'a';
$cnt = Get('CountSelected');
Status 'Selected ' . $cnt . ' item' . (($cnt == 1) ? '' : 's') . '.',, 'ready';
}
/***************************************************************** END select */
/*******************************************************************************
** Preview & Spot Images
** Shows the preview then spots the selected images.
*******************************************************************************/
"Preview && Sp&ot Images : spot"
Sub 'showPreview';
Global $G_RESULTS;
if ($G_RESULTS != '') {
$vf = '';
foreach ($item, $G_RESULTS, '|') {
if ($item == '') { continue; }
$vf = $vf . '|' . GetPathComponent($item, 'File');
goto '>>' . $vf;
}
}
/***************************************************************** END filter */
/*******************************************************************************
** Preview & Zip Images
** Shows the preview then creates a Zip archive of the selected images.
*******************************************************************************/
"Preview && &Zip Images : archive"
Sub 'showPreview';
Global $G_RESULTS;
if ($G_RESULTS != '') {
$zip = InputFile(<curpath>, 'zip', 'Save to Zip Archive');
$zip = Zip_Add($zip, $G_RESULTS, '|');
goto $zip;
}
/**************************************************************** END archive */
"- : _-" //---------------------------------------------------------------------
"- : _-" //---------------------------------------------------------------------
/*******************************************************************************
** Display Current Settings
** Shows the current script configuration settings.
*******************************************************************************/
"&Display Current Settings : _showOptions"
// Get Defaults
Sub '_getDefaults';
Global $G_FILTERS, $G_PREVIEW_SIZE, $G_COLORS, $G_COLOR_TITLES, $G_IMAGE_LIMIT;
$dFilters = $G_FILTERS;
$dWidth = GetToken($G_PREVIEW_SIZE, 1, 'x', 't');
$dHeight = GetToken($G_PREVIEW_SIZE, 2, 'x', 't');
$dColors = $G_COLORS;
$dLimit = $G_IMAGE_LIMIT;
// Get Current
Sub '_getOptions';
$defaultMarker = "<tab>[DEFAULT]";
// Split window size.
$width = GetToken($G_PREVIEW_SIZE, 1, 'x', 't');
$dWidth = $width == $dWidth ? $defaultMarker : '';
$height = GetToken($G_PREVIEW_SIZE, 2, 'x', 't');
$dHeight = $height == $dHeight ? $defaultMarker : '';
// Split colors.
$colors = '';
$i = 1;
$c = GetToken($G_COLORS, 'Count', '|');
while ($i <= $c) {
$title = GetToken($G_COLOR_TITLES, $i, '|', 't');
$color = GetToken($G_COLORS, $i, '|', 't');
// Add color
if ($colors != '') {
$colors = $colors . <crlf>;
}
$colors = $colors . $title . ' Color: ' . $color;
// Add default marker.
$dColor = GetToken($dColors, $i, '|', 't');
if ($color == $dColor) {
$colors = $colors . $defaultMarker;
}
$i++;
}
// Limit
$dLimit = $G_IMAGE_LIMIT == $dLimit ? $defaultMarker : '';
// Filters
$dFilters = $G_FILTERS == $dFilters ? $defaultMarker : '';
Text <<<TEXT
Current HTML Image Preview Settings
Window Width: $width$dWidth
Window Height: $height$dHeight
$colors
Image Limit: $G_IMAGE_LIMIT$dLimit
Filters: $dFilters
$G_FILTERS
TEXT;
/*********************************************************** END _showOptions */
"- : _-" //---------------------------------------------------------------------
/*******************************************************************************
** Adjust Colors
** Allows user to configure the colors used in the preview.
*******************************************************************************/
"Adjust &Colors : _adjustColors"
// Get default value.
Sub '_getDefaults';
Global $G_COLORS;
Global $G_COLOR_TITLES;
// Get current value.
if ( IsSet($P_THEQWERTY_HTML_IMAGE_PREVIEW__COLORS)
&& '' != $P_THEQWERTY_HTML_IMAGE_PREVIEW__COLORS
)
{
$colors = $P_THEQWERTY_HTML_IMAGE_PREVIEW__COLORS;
} else {
$colors = $G_COLORS;
}
$sep = '|';
$newColors = '';
// For each color...
$i = 1;
$c = GetToken($G_COLORS, 'Count', $sep);
while ($i <= $c) {
// Get this color's info.
$title = GetToken($G_COLOR_TITLES, $i, $sep, 't');
$default = GetToken($G_COLORS , $i, $sep, 't');
$current = GetToken($colors , $i, $sep, 't');
// Prompt user.
$res = Input($i . ': ' . $title . ' Color', "Default value is $default.", $current, 's');
// Validate
$res = Trim($res, " <tab>");
if ($res == '') {
$res = $default;
}
// Build up option string.
if ($newColors != '') {
$newColors = $newColors . $sep;
}
$newColors = $newColors . $res;
$i++;
}
// Clean up value.
$newColors = Recase($newColors, 'Upper');
// Update stored value.
if ($newColors == '' || $newColors == $G_COLORS) {
unset $P_THEQWERTY_HTML_IMAGE_PREVIEW__COLORS;
Status 'Set colors to default: ' . $G_COLORS,, 'ready';
} else {
perm $P_THEQWERTY_HTML_IMAGE_PREVIEW__COLORS = $newColors;
Status 'Set colors to: ' . $newColors,, 'ready';
}
/********************************************************** END _adjustColors */
/*******************************************************************************
** Adjust Filters
** Allows user to configure the list of filters used for determining what
** files are images and should be displayed.
**
** Generally, this should be set to all images that the system can display
** within Internet Explorer.
*******************************************************************************/
"Adjust F&ilters : _adjustFilters"
// Get default value.
Sub '_getDefaults';
Global $G_FILTERS;
// Get curent value.
if ( IsSet($P_THEQWERTY_HTML_IMAGE_PREVIEW__FILTERS)
&& '' != $P_THEQWERTY_HTML_IMAGE_PREVIEW__FILTERS
)
{
$filters = $P_THEQWERTY_HTML_IMAGE_PREVIEW__FILTERS;
} else {
$filters = $G_FILTERS;
}
// Prompt user.
$filters = Input('Images Filters', 'One filter per line. Delete all to use defaults.', $filters, 'm');
// Clean up filters.
$filters = FormatList($filters, 'dents', <crlf>);
$default = FormatList($G_FILTERS, 'dents', <crlf>);
// Update stored value.
if ($filters == '' || $filters == $default) {
unset $P_THEQWERTY_HTML_IMAGE_PREVIEW__FILTERS;
Status 'Set image filters to defaults.',, 'ready';
} else {
perm $P_THEQWERTY_HTML_IMAGE_PREVIEW__FILTERS = $filters;
Status 'Set image filters.',, 'ready';
}
/********************************************************* END _adjustFilters */
/*******************************************************************************
** Adjust Maximum Image Count
** Allows user to configure the cap on the maximum number of images which
** will be shown.
*******************************************************************************/
"Adjust &Maximum Image Count : _adjustCap"
// Get default value.
Sub '_getDefaults';
Global $G_IMAGE_LIMIT;
// Get current value.
if ( IsSet($P_THEQWERTY_HTML_IMAGE_PREVIEW__IMAGE_LIMIT)
&& '' != $P_THEQWERTY_HTML_IMAGE_PREVIEW__IMAGE_LIMIT
)
{
$limit = $P_THEQWERTY_HTML_IMAGE_PREVIEW__IMAGE_LIMIT;
} else {
$limit = $G_IMAGE_LIMIT;
}
// Prompt user.
$limit = Input('Maximum Number of Images to Preview', "Default value is $G_IMAGE_LIMIT.", $limit, 's');
// Validate
$limit = RegexReplace($limit, '[^0-9]');
// Update stored value.
if ($limit == '' || $limit == $G_IMAGE_LIMIT || $limit < 1) {
unset $P_THEQWERTY_HTML_IMAGE_PREVIEW__IMAGE_LIMIT;
Status 'Set image limit to default: ' . $G_IMAGE_LIMIT,, 'ready';
} else {
perm $P_THEQWERTY_HTML_IMAGE_PREVIEW__IMAGE_LIMIT = $limit;
Status 'Set image limit to: ' . $limit,, 'ready';
}
/************************************************************* END _adjustCap */
/*******************************************************************************
** Adjust Window Size
** Allows user to configure the size of the preview window.
*******************************************************************************/
"Adjust &Window Size : _adjustSize"
// Get default value.
Sub '_getDefaults';
Global $G_PREVIEW_SIZE;
// Get current value.
if ( IsSet($P_THQWERTY_HTML_IMAGE_PREVIEW__PREVIEW_SIZE)
&& '' != $P_THQWERTY_HTML_IMAGE_PREVIEW__PREVIEW_SIZE
)
{
$size = $P_THQWERTY_HTML_IMAGE_PREVIEW__PREVIEW_SIZE;
} else {
$size = $G_PREVIEW_SIZE;
}
// Prompt user.
$size = Input('Preview Window Size', <<<MSG
Width x Height of Preview Window in pixels.
Percentages of screen are also supported.
Default value is $G_PREVIEW_SIZE.
MSG
, $size, 's');
// Validate.
$size = RegexReplace($size, '[^0-9x%]');
// Update stored value.
if ($size == '' || $size == $G_PREVIEW_SIZE || $size UnLikeI '*x*') {
unset $P_THQWERTY_HTML_IMAGE_PREVIEW__PREVIEW_SIZE;
Status 'Set preview window size to default: ' . $G_PREVIEW_SIZE,, 'ready';
} else {
perm $P_THQWERTY_HTML_IMAGE_PREVIEW__PREVIEW_SIZE = $size;
Status 'Set preview window size to: ' . $size,, 'ready';
}
/************************************************************ END _adjustSize */
"- : _-" //---------------------------------------------------------------------
/*******************************************************************************
** Reset All to Defaults
** Resets all configuration options to their defaults.
*******************************************************************************/
"&Reset All to Defaults : _resetToDefaults"
unset $P_THEQWERTY_HTML_IMAGE_PREVIEW__FILTERS;
unset $P_THEQWERTY_HTML_IMAGE_PREVIEW__COLORS;
unset $P_THQWERTY_HTML_IMAGE_PREVIEW__PREVIEW_SIZE;
unset $P_THEQWERTY_HTML_IMAGE_PREVIEW__IMAGE_LIMIT;
Status 'Set all options to their defaults.',, 'ready';
/******************************************************* END _resetToDefaults */
"_-" //-------------------------------------------------------------------------
"_-" //-------------------------------------------------------------------------
/*******************************************************************************
** _getDefaults
** Retrieves the default configuration options.
*******************************************************************************/
"_getDefaults"
Global $G_FILTERS = Get('GenericFileType', '{:Image}', <crlf>);
Global $G_PREVIEW_SIZE = '50%x50%';
Global $G_COLORS = '#EEE|#DDD|#AAF';
Global $G_COLOR_TITLES = 'Window Background|Thumb Background|Selected Image(s)';
Global $G_IMAGE_LIMIT = 512;
/*********************************************************** END _getDefaults */
/*******************************************************************************
** _getOptions
** Retrieves the current configuration options.
*******************************************************************************/
"_getOptions"
// Get defaults.
Sub '_getDefaults';
// Image Filters
if ( IsSet($P_THEQWERTY_HTML_IMAGE_PREVIEW__FILTERS)
&& '' != $P_THEQWERTY_HTML_IMAGE_PREVIEW__FILTERS
)
{
Global $G_FILTERS = $P_THEQWERTY_HTML_IMAGE_PREVIEW__FILTERS;
}
// Preview Window Size
if ( IsSet($P_THQWERTY_HTML_IMAGE_PREVIEW__PREVIEW_SIZE)
&& '' != $P_THQWERTY_HTML_IMAGE_PREVIEW__PREVIEW_SIZE
)
{
Global $G_PREVIEW_SIZE = $P_THQWERTY_HTML_IMAGE_PREVIEW__PREVIEW_SIZE;
}
// Colors
if ( IsSet($P_THEQWERTY_HTML_IMAGE_PREVIEW__COLORS)
&& '' != $P_THEQWERTY_HTML_IMAGE_PREVIEW__COLORS
)
{
Global $G_COLORS = $P_THEQWERTY_HTML_IMAGE_PREVIEW__COLORS;
}
// Image Limit
if ( IsSet($P_THEQWERTY_HTML_IMAGE_PREVIEW__IMAGE_LIMIT)
&& '' != $P_THEQWERTY_HTML_IMAGE_PREVIEW__IMAGE_LIMIT
)
{
Global $G_IMAGE_LIMIT = $P_THEQWERTY_HTML_IMAGE_PREVIEW__IMAGE_LIMIT;
}
/************************************************************ END _getOptions */