-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevices.html
1093 lines (1034 loc) · 983 KB
/
devices.html
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
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Devices Screen Mockup</title>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/dom-to-image-more/3.3.0/dom-to-image-more.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/tinyColorPicker/1.1.1/jqColorPicker.min.js"></script>
</head>
<body>
<div class="controlPanel">
<button id="introduction" class="btn">使用说明</button>
<button id="resetScreen" class="btn">清屏</button>
<button id="mobileOrPC" class="btn">PC端</button>
<button id="doubleOrSingle" class="btn">单屏</button>
<button id="save" title="点击保存为图片" class="btn">保存</button>
<input id="appIconCount" title="输入图标数量" type="number" placeholder="输入图标数量" />
<input id="watermark" title="清空水印输入空格" placeholder="输入水印" />
<input id="bgcolor" title="点击选择背景颜色" class="btn colorSelector" placeholder="背景颜色"></input>
<input id="fontcolor" title="点击选择字体颜色" class="btn colorSelector" placeholder="字体颜色"></input>
</div>
<div class="root_container" id="root_container">
<div class="bgmask" id="bgmask"></div>
<div class="second_container" title="点击上传背景图片"></div>
<div class="copyright"></div>
</div>
<div class="introduction" title="点击隐藏或显示">
<p>1,基于chrome浏览器的壁纸样机生成器</p>
<p>2,移动端尺寸:852X1789;PC端尺寸:2016X1260</p>
<p>3,不联网无法使用</p>
</div>
</body>
<style>
.introduction {
display:none;
position: absolute;
left: 0%;
top:15%;
width: 49%;
height: 30%;
font-family: Arial, sans-serif; /* 设置字体 */
font-size: 40px; /* 设置字体大小 */
color: rgb(255, 0, 0); /* 设置文字颜色 */
line-height: 1.6; /* 设置行高 */
margin: 20px 0; /* 上下外边距 */
padding: 10px; /* 内边距 */
border: 1px solid #ddd; /* 边框 */
border-radius: 5px; /* 边框圆角 */
background-color: #f9f9f9; /* 背景色 */
box-shadow: 7px 5px 4px rgb(29 27 27 / 43%); /* 阴影效果 */
/* max-width: 600px; */ /* 最大宽度 */
margin: auto; /* 水平居中 */
}
.bgmask {
position: absolute;
top:0;
left:0;
width:100%;
height:100%;
filter: blur(30px);
z-index: 0;
background-size:cover;
background-repeat:no-repeat;
background-position:center center;
}
.sentence {
font-size:32px;
color:#fff;
position:absolute;
top:29%;
left:9%;
font-family:fangsong;
z-index: 2;
}
#jinrishici-sentence{
min-width: 600px;
min-height:50px;
}
.controlPanel {
position:fixed;
top:0%;
/* left:0%; */
/* width:100%; */
font-size:32px;
font-weight:bolder;
background-color:#02007f4d;
box-shadow:5px 5px 5px 0px rgb(126 123 123 / 83%);
display:grid;
/* grid-template-columns: repeat(8, 200px); */
justify-content:center;
align-items:center;
height: 7%;
z-index:2;
}
.controlPanel *{
box-shadow: 5px 5px 5px 0px rgb(212 139 90 / 83%);
}
.controlPanel button {
font-size:32px;
color:#fff;
background-color: #26588d;
border:none;
padding:10px 20px;
border-radius:5px;
cursor:pointer;
transition:background-color 0.3s ease;
margin-left: 5%;
}
.controlPanel input{
font-size:32px;
margin-left:10%;
padding:10px 20px;
box-sizing: border-box;
border: 2px solid #8d8d8d;
border-radius: 4px;
background-color: rgb(71 89 108);
font-size: 28px;
color: #ffffff;
max-width:100%;
}
.controlPanel input::placeholder{
color: white;
}
.third_container {
position:relative;
display:grid;
grid-template-columns:1fr;
justify-items:center;
align-items:center;
z-index: 2;
}
.desc_top {
font-size:50px;
color: #fcfcfc;
text-align:center;
font-weight:bolder;
}
.watermark-container {
white-space:nowrap;
position:absolute;
top:50%;
left:45%;
transform: translate(-50%,-50%) rotate(-59deg);
font-size:240px;
color:rgb(255 255 255 / 0%);
width:100%;
text-align:center;
z-index: 2;
text-shadow:1px 1px 0 #fff,-1px -1px 1px #080808;
opacity:0.2;
}
.root_container {
display:grid;
position:relative;
grid-template-columns:1fr;
grid-template-rows:repeat(2,1fr);
background-color:rgb(224 223 223);
}
.copyright {
font-size:30px;
color:#f6f2f2;
text-align:center;
font-weight:bolder;
z-index:1;
}
body {
display:flex;
justify-content:center;
align-items:center;
height:100%;
margin:0;
box-sizing:border-box;
margin:0;
padding:0;
}
.second_container {
display:grid;
grid-template-columns:1fr;
column-gap: 21px;
justify-items:center;
align-items:center;
place-items: center;
z-index: 0;
}
.iphone-screen {
width:900px;
height:1600px;
border:1px solid #ccc;
border-radius:70px;
overflow:hidden;
position:relative;
background: #a7bda8;
display:flex;
justify-content:center;
align-items:flex-start;
box-shadow: 11px 12px 17px 2px rgb(59 47 47 / 67%);
background-size:cover;
background-repeat:no-repeat;
}
.dynamic-island {
position:absolute;
top: 0.5%;
left:50%;
transform:translateX(-50%);
width: 25%;
height:4%;
background:black;
border-radius:38px;
z-index: 2;
}
.status-bar {
position:absolute;
left:7px;
height:3%;
width:100%;
display:flex;
align-items:center;
padding:5px 7px 0px 7px;
justify-content:space-between;
}
.status-icons {
display:grid;
width: 15%;
grid-template-columns:repeat(3,1fr);
gap:10px;
align-items:center;
justify-content:right;
padding-right: 9%;
place-items: center;
}
.status-icon {
height:auto;
display:block;
}
.signal {
width: 100%;
}
.wifi {
width: 100%;
}
.battery {
width: 123%;
}
.status-text {
padding-left:5%;
display:inline-block;
width: 50%;
font-size: 23px;
color:white;
}
.torch,.camera {
position:absolute;
bottom:41px;
width:16%;
padding:3%;
height:auto;
border-radius:99%;
background:#5e5d5d33;
display:flex;
justify-content:center;
align-items:center;
}
.torch {
left:33px;
}
.camera {
right:33px;
}
.app-icons-container {
display:grid;
row-gap:4%;
height:100%;
width:100%;
box-sizing:border-box;
flex-wrap:wrap;
place-items: center;
padding:17% 0% 2% 0%;
grid-template-columns:repeat(4,1fr);
grid-template-rows: repeat(8,12.5%);
margin: 0 auto;
}
.app-item {
display:flex;
flex-direction:column;
align-items:center;
justify-content:center;
box-sizing:border-box;
z-index:1;
width: 100%;
}
.app-icon {
border-radius: 28%;
display:flex;
justify-content:center;
align-items:center;
z-index:1;
width: 80%;
aspect-ratio:1 / 1;
background-color:rgb(255 255 255 / 0%);
box-sizing:border-box;
overflow:hidden;
}
.app-icon img{
max-width: 100%;
max-height: 100%;
object-fit: cover;
}
.app-name {
font-size: calc(1vw);
text-align:center;
color:white;
margin-top: 4%;
display:none;
width: 170px;
white-space:nowrap;
overflow: hidden;
}
.bottom-bar {
position:absolute;
z-index:0;
bottom: 4.5%;
width:98%;
height:13%;
background-color:#ffffff4f;
border-radius:23px;
display:block;
}
.bottom-line {
position:absolute;
bottom:10px;
width:30%;
height:0.5%;
background-color:white;
filter:brightness(1) contrast(2.2);
}
.time-display {
z-index:1;
position:absolute;
top:12%;
left:50%;
transform:translateX(-50%);
width:100%;
text-align:center;
color:#fff;
text-shadow:1px 1px 2px rgba(0,0,0,0.5);
}
.time-display .date {
font-weight:bold;
text-align:center;
}
.time-display .time {
font-size:20px;
text-align:center;
font-family:serifemoji;
}
.weather {
z-index:1;
position:absolute;
width:13%;
top:12%;
left:71%;
font-size:20px;
color:white;
}
.weather svg {
display:none;
width:60%;
height:60%;
}
</style>
<script>
$(document).ready(function() {
//rotateScreen();
initScreen();
bindEvent();
inputWithDefault();
$('body').css('transform','scale(0.5)');
resetCtrlPanel();
$('.app-icons-container').focus();
console.log($('.second_container').offset())
$('html, body').animate({
scrollTop: $('.second_container').offset().top,
scrollLeft: $('.second_container').offset().left-200
}, 500);
});
function resetCtrlPanel(){
let bodyW = $('.second_container').css('width').replace('px','');
bodyW = Math.floor(Number(bodyW));
let colCount = 8;
let colWidth = Math.floor(bodyW/colCount);
$('.controlPanel').css('grid-template-columns','repeat('+colCount+', '+colWidth+'px)');
}
function DeviceConfig(type, screenWidth, screenHeight, iconsRowCount,iconCntOneRow){
this.type=type;
this.iconsRowCount=iconsRowCount;
this.screenWidth=screenWidth;
this.screenHeight=screenHeight;
this.iconCntOneRow=iconCntOneRow;
this.enlarge='scale(1.1)';
this.createdScreens={};
}
DeviceConfig.prototype.commonResizeBoard=function(rootWidth, rootHeight){
secondHeight = rootHeight-100;
$('.root_container').css('width',rootWidth);
$('.root_container,.second_container').css('height',rootHeight);
$('.second_container').css('height',secondHeight);
$('.second_container').click(function(){
uploadImg(this);
event.stopPropagation();
});
$('body,html').css('width',rootWidth);
}
DeviceConfig.prototype.commonEvent=function(){
$('#jinrishici-sentence').hover(function(event){
$(this).css('background-color','gray');
$(this).attr('contenteditable',true);
},function(){
$(this).css('background-color','');
$(this).attr('contenteditable',false);
});
$('#jinrishici-sentence').click(function(event){
event.stopPropagation();
})
}
DeviceConfig.prototype.clear=function(){
for (let key in this.createdScreens) {
this.createdScreens[key].remove();
delete this.createdScreens[key]
}
}
DeviceConfig.prototype.getVisibleScreenCount=function(){
let visibleCount = 0;
for(let key in this.createdScreens){
let screen=this.createdScreens[key];
if('none'!=screen.css('display')){
visibleCount=visibleCount+1;
}
}
return visibleCount;
}
function PC(){
DeviceConfig.call(this,'pc', 2016,1260,6,12);
}
function Mobile(){
DeviceConfig.call(this,'mobile', 852,1789,4,4);
}
PC.prototype = Object.create(DeviceConfig.prototype);
PC.prototype.constructor = PC;
PC.prototype.resizeBoard=function(){
rootWidth = Math.floor(this.screenWidth+(this.screenWidth*0.3));
rootHeight = Math.floor(this.screenHeight*2+(this.screenHeight*0.3));
this.commonResizeBoard(rootWidth, rootHeight);
}
PC.prototype.createScreens = function(){
let existScreenCount = Object.keys(this.createdScreens).length;
this.clear();
if(existScreenCount==1 || existScreenCount==0){
createHomeScreen();
createLockScreen();
}
if(existScreenCount==2){
createHomeScreen();
let $home = context.getDevice()['createdScreens']['home'];
$home[0].style.transform = this.enlarge;
}
this.screenLayout();
this.commonEvent();
$('.app-icons-container').css('grid-template-columns',this.gridColumns());
$('.app-icons-container').css('grid-template-rows',this.gridRows());
$('.app-icons-container').css('row-gap','1%');
$('.app-item').css('width','auto');
$('.app-icons-container').css('padding','3% 0 0 0');
$('.app-icons-container').css('width',this.screenWidth);
$('.app-icons-container').css('height',this.screenHeight);
$('.dynamic-island').css('display','none');
$('.bottom-bar').css('bottom','2.5%');
$('.bottom-bar').css('height','17%');
$('.watermark-container').css('transform','translate(-50%,-50%) rotate(30deg)');
$('.status-bar').css('height','4%');
$('.status-icons').css('padding-right','3%');
$('.torch,.camera').css('display','none');
$('.status-text.isp').css('padding-left','3%');
$('.status-icon').css('width',Math.floor(this.screenWidth/40));
$('.status-icons').css('width',Math.floor(this.screenWidth/15));
$('').css('','');
$('').css('','');
}
PC.prototype.screenLayout = function(){
let visibleCount = this.getVisibleScreenCount();
if(visibleCount==1 || visibleCount==0){
$('.second_container').css('grid-template-rows','1fr');
}
if(visibleCount==2){
$('.second_container').css('grid-template-columns','1fr');
$('.second_container').css('grid-template-rows','repeat(2, 1fr)');
}
}
Mobile.prototype = Object.create(DeviceConfig.prototype);
Mobile.prototype.constructor = Mobile;
Mobile.prototype.resizeBoard=function(){
rootWidth = Math.floor(this.screenWidth*2+(this.screenWidth*0.3));
rootHeight = Math.floor(this.screenHeight+(this.screenHeight*0.3));
this.commonResizeBoard(rootWidth, rootHeight);
}
Mobile.prototype.createScreens = function(){
let existScreenCount = Object.keys(this.createdScreens).length;
this.clear();
if(existScreenCount==1 || existScreenCount==0){
createHomeScreen();
createLockScreen();
}
if(existScreenCount==2){
createHomeScreen();
let $home = context.getDevice()['createdScreens']['home'];
$home[0].style.transform = this.enlarge;
}
this.screenLayout();
this.commonEvent();
$('.app-icons-container').css('grid-template-columns',this.gridColumns());
$('.app-icons-container').css('grid-template-rows',this.gridRows());
$('.app-icons-container').css('row-gap','2%');
$('.second_container').css('place-items','center');
let statuIconWidth = Math.floor(this.screenWidth/20);
$('.status-icon').css('width',statuIconWidth);
}
Mobile.prototype.screenLayout = function(){
let visibleCount = this.getVisibleScreenCount()
if(visibleCount==1 || visibleCount==0){
$('.second_container').css('grid-template-columns','1fr');
}
if(visibleCount==2){
$('.second_container').css('grid-template-columns', '1fr 1fr');
}
$('.second_container').css('grid-template-rows', '');
}
DeviceConfig.prototype.totalAppItems=function(){
let appItemWidth = Math.floor(this.screenWidth/this.iconCntOneRow);
let totalRows = (Math.floor(this.screenHeight/appItemWidth));
let totalCount = totalRows*this.iconCntOneRow;
if(this.type=='mobile'){
return totalCount-8;
}else{
return totalCount-12;
}
}
DeviceConfig.prototype.gridColumns=function(){
let columnWidth = Math.floor(this.screenWidth/this.iconCntOneRow);
return 'repeat('+this.iconCntOneRow+', '+columnWidth+'px)';
}
DeviceConfig.prototype.gridRows=function(){
let columnWidth = Math.floor(this.screenWidth/this.iconCntOneRow);
let oneRowHeight = columnWidth+columnWidth*0.1;
let rowCount = Math.floor(this.screenHeight/oneRowHeight);
return 'repeat('+rowCount+', '+oneRowHeight+'px)';
}
context={
type: 'mobile',
pc: new PC(),
mobile: new Mobile(),
getDevice:function(){
return this[this.type]
}
}
function initScreen(){
context.getDevice().resizeBoard();
context.getDevice().createScreens();
}
let screenTemplate={
'third_container':'<div class="third_container"></div>',
'watermark':'<div class="watermark-container"></div>',
'desc_top':'<div class="desc_top"></div>',
'iphone_screen':'<div title="点击选择并上传壁纸" class="iphone-screen" id="iphone-screen"></div>',
'dynamic_island':'<div title="点击隐藏" class="dynamic-island"></div>',
'time_display':'<div class="time-display"><div class="date"></div><div class="time"></div></div>',
'status_bar':'<div class="status-bar"><div class="status-text isp">中国移动</div><div class="status-icons"><div class="status-icon signal"><svg width="100%"height="100%"viewBox="0 0 1400 1200"preserveAspectRatio="xMidYMid "version="1.1"xmlns="http://www.w3.org/2000/svg"fill="#FFFFFF"><path d="M0 727.578947l188.631579 0 0 296.421053-188.631579 0 0-296.421053Z"></path><path d="M269.473684 565.894737l188.631579 0 0 458.105263-188.631579 0 0-458.105263Z"></path><path d="M565.894737 377.263158l161.684211 0 0 646.736842-161.684211 0 0-646.736842Z"></path><path d="M835.368421 188.631579l188.631579 0 0 835.368421-188.631579 0 0-835.368421Z"></path><path d="M1104.842105 0l188.631579 0 0 1024-188.631579 0 0-1024Z"></path></svg></div><div class="status-icon wifi"><svg width="100%"height="100%"viewBox="0 0 1000 1000"preserveAspectRatio="xMidYMid "version="1.1"xmlns="http://www.w3.org/2000/svg"fill="#FFFFFF"><path d="M478.03605 495.007C358.18605 507.88 270.63805 593.762 247.01905 633.34c-14.787 24.778-6.69 56.847 18.085 71.633 8.393 5.008 17.616 7.393 26.726 7.393 17.787 0 35.132-9.092 44.91-25.479 10.072-16.874 71.244-79.269 152.452-87.991 68.809-7.376 137.709 25.217 204.772 96.912 19.715 21.063 52.775 22.166 73.843 2.459 21.071-19.711 22.175-52.771 2.468-73.843-112.98-120.767-221.263-137.027-292.239-129.417z"></path><path d="M513.39305 700.749c-55.4 0-100.31 44.907-100.31 100.306s44.91 100.307 100.31 100.307c55.395 0 100.306-44.908 100.306-100.307S568.78805 700.749 513.39305 700.749zM1008.17105 350.85C840.37705 187.594 660.63005 111.217 473.93005 123.848c-108.92 7.369-220.504 46.655-322.681 113.614C72.00105 289.396 22.28105 341.825 11.11405 356.097c-17.783 22.72-13.815 55.605 8.907 73.387 9.568 7.49 20.923 11.122 32.191 11.122 15.49 0 30.817-6.865 41.107-20.017 7.055-8.749 50.226-53.609 118.01-97.563 61.02-39.57 157.938-88.2 273.119-95.15 154.619-9.298 306.324 57.237 450.861 197.862 20.684 20.125 53.752 19.669 73.873-1.012 20.122-20.682 19.671-53.757-1.011-73.876z"></path><path d="M487.43005 307.044c-197.071 9.085-329.162 149.714-353.641 177.811-18.954 21.756-16.681 54.758 5.074 73.709 9.901 8.624 22.122 12.852 34.296 12.852 14.578 0 29.085-6.07 39.416-17.926 11.998-13.775 121.8-134.792 279.667-142.069 107.595-4.936 216.103 44.011 322.504 145.547 20.882 19.924 53.945 19.151 73.861-1.728 19.924-20.873 19.148-53.944-1.726-73.862C759.02805 359.37 624.62705 300.719 487.43005 307.044z"></path></svg></div><div class="status-icon battery"><svg width="130%"height="100%"viewBox="0 0 1000 1000"preserveAspectRatio="xMidYMid "version="1.1"xmlns="http://www.w3.org/2000/svg"fill="#FFFFFF"><path d="M835.842643 307.552631c14.518668 0 27.396977 5.941316 38.619576 17.822924 11.222599 11.881608 16.833387 25.090445 16.833387 39.616276l0 247.578702c0 13.199627-5.610788 25.453718-16.833387 36.641525-11.222599 11.222599-24.100908 16.833387-38.619576 16.833387l-718.964702 0c-13.208836 0-25.419949-5.610788-36.641525-16.833387-11.222599-11.18883-16.842597-23.441898-16.842597-36.641525l0-247.578702c0-14.526855 5.619998-27.734668 16.842597-39.616276 11.222599-11.881608 23.433712-17.822924 36.641525-17.822924L835.842643 307.552631zM116.877941 349.146958c-6.608511 0-10.56359 0.700965-11.889795 1.977028-1.318018 1.318018-1.977028 5.941316-1.977028 13.867846l0 247.578702c0 6.642281 0.659009 12.582573 1.977028 17.822924 1.327228 5.281283 5.281283 7.918343 11.889795 7.918343l718.964702 0c6.600325 0 10.234085-2.63706 10.893094-7.918343 0.659009-5.239328 0.988514-11.180644 0.988514-17.822924l0-247.578702c0-7.92653-0.329505-12.548804-0.988514-13.867846-0.659009-1.276063-4.29277-1.977028-10.893094-1.977028L116.877941 349.146958zM570.432831 384.791783l0 205.984375-425.828408 0L144.604422 384.791783 570.432831 384.791783zM903.177214 420.444794c22.453385 0 37.309744 5.941316 44.569078 17.831111 7.259334 11.881608 10.893094 28.428469 10.893094 49.51267 0 21.126156-3.63376 37.960567-10.893094 50.509371-7.259334 12.582573-22.115694 18.811438-44.569078 18.811438L903.177214 420.444794z"></path></svg></div></div></div>',
'weather':'<div class="weather"id="weather"><svg id="thunderstorm"viewBox="0 0 1024 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"><path d="M777.955556 422.4H768a118.044444 118.044444 0 0 0-12.8-85.333333 115.2 115.2 0 0 0-71.111111-55.466667 108.088889 108.088889 0 0 0-76.8 4.266667L267.377778 585.955556a4.266667 4.266667 0 0 0 2.844444 7.111111h512a85.333333 85.333333 0 0 0 85.333334-93.866667 88.177778 88.177778 0 0 0-89.6-76.8z"fill="#A1C6E6"></path><path d="M420.977778 196.266667a145.066667 145.066667 0 0 0-143.644445 132.266666v25.6h-14.222222a143.644444 143.644444 0 0 0-35.555555 2.844445h-1.422223c-42.666667 9.955556-82.488889 51.2-83.911111 95.288889a100.977778 100.977778 0 0 0 71.111111 98.133333 9.955556 9.955556 0 0 0 9.955556-2.844444l312.888889-277.333334a8.533333 8.533333 0 0 0 1.422222-12.8 142.222222 142.222222 0 0 0-116.622222-61.155555z"fill="#C3D6E6"></path><path d="M658.488889 668.444444H682.666667v90.737778h-24.177778zM708.266667 615.822222h24.177777v74.524445h-24.177777z"fill="#A1C6E6"></path><path d="M379.733333 625.777778h24.177778v120.32h-24.177778zM265.955556 625.777778h24.177777v71.537778h-24.177777zM315.733333 665.6h24.177778v119.324444h-24.177778z"fill="#C3D6E6"></path><path d="M587.377778 658.488889H611.555556v169.244444h-24.177778z"fill="#A1C6E6"></path><path d="M466.488889 627.2h85.333333l-46.933333 86.755556h55.466667l-99.555556 120.888888 18.488889-83.911111h-34.133333l21.333333-123.733333z"fill="#F7B531"></path></svg><svg id="sunny"viewBox="0 0 1024 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"><path d="M511.4 512.2m-246.6 0a246.6 246.6 0 1 0 493.2 0 246.6 246.6 0 1 0-493.2 0Z"fill="#9FDAFF"></path><path d="M520.4 211.8h-16.7c-9 0-16.3-7.3-16.3-16.3V41.3c0-9 7.3-16.3 16.3-16.3h16.7c9 0 16.3 7.3 16.3 16.3v154.1c0 9-7.4 16.4-16.3 16.4zM304.1 295.3l-11.8 11.8c-6.3 6.3-16.7 6.3-23.1 0l-109-109c-6.3-6.3-6.3-16.7 0-23.1l11.8-11.8c6.3-6.3 16.7-6.3 23.1 0l109 109c6.3 6.3 6.3 16.7 0 23.1zM210.2 507.2v16.7c0 9-7.3 16.3-16.3 16.3H39.8c-9 0-16.3-7.3-16.3-16.3v-16.7c0-9 7.3-16.3 16.3-16.3h154.1c9 0 16.3 7.3 16.3 16.3zM293.7 723.5l11.8 11.8c6.3 6.3 6.3 16.7 0 23.1l-109 109c-6.3 6.3-16.7 6.3-23.1 0l-11.8-11.8c-6.3-6.3-6.3-16.7 0-23.1l109-109c6.4-6.4 16.7-6.4 23.1 0zM505.6 817.4h16.7c9 0 16.3 7.3 16.3 16.3v154.1c0 9-7.3 16.3-16.3 16.3h-16.7c-9 0-16.3-7.3-16.3-16.3V833.7c0-9 7.4-16.3 16.3-16.3zM721.9 733.9l11.8-11.8c6.3-6.3 16.7-6.3 23.1 0l109 109c6.3 6.3 6.3 16.7 0 23.1L854 865.9c-6.3 6.3-16.7 6.3-23.1 0l-109-109c-6.3-6.3-6.3-16.7 0-23zM815.8 521.9v-16.7c0-9 7.3-16.3 16.3-16.3h154.1c9 0 16.3 7.3 16.3 16.3v16.7c0 9-7.3 16.3-16.3 16.3H832.1c-9 0-16.3-7.3-16.3-16.3zM732.3 305.7l-11.8-11.8c-6.3-6.3-6.3-16.7 0-23.1l109-109c6.3-6.3 16.7-6.3 23.1 0l11.8 11.8c6.3 6.3 6.3 16.7 0 23.1l-109 109c-6.4 6.3-16.7 6.3-23.1 0z"fill="#9FDAFF"></path></svg><svg id="lsnow"viewBox="0 0 1177 1024"version="1.1"xmlns="http://www.w3.org/2000/svg"><path d="M1031.350714 366.887701h-16.427808a191.657754 191.657754 0 0 0-20.078431-138.723708 197.13369 197.13369 0 0 0-114.994653-91.265597 184.356506 184.356506 0 0 0-125.946524 9.126559L204.484404 631.557932a5.475936 5.475936 0 0 0 3.650623 10.951872h830.516934a138.723708 138.723708 0 0 0 136.898396-151.500891 142.374332 142.374332 0 0 0-144.199643-124.121212z"fill="#A1C6E6"></path><path d="M452.726828 0a233.639929 233.639929 0 0 0-231.814617 213.561497l-3.650624 41.982175h-21.903743a304.827094 304.827094 0 0 0-58.409982 3.650624h-1.825312C65.760696 273.796791 1.874778 341.333333 0.049466 412.520499a162.452763 162.452763 0 0 0 113.16934 158.802139 21.903743 21.903743 0 0 0 18.25312-3.650624L640.733958 118.645276a16.427807 16.427807 0 0 0 1.825312-20.078431A231.814617 231.814617 0 0 0 452.726828 0z"fill="#CFDBE6"></path><path d="M733.824867 949.16221l-25.554367-14.602495 25.554367-14.602496a21.903743 21.903743 0 0 0 9.12656-29.204991 21.903743 21.903743 0 0 0-31.030303-7.301248l-23.729056 14.602496v-29.204991a21.903743 21.903743 0 0 0-21.903743-21.903743 21.903743 21.903743 0 0 0-21.903743 21.903743v29.204991l-25.554367-14.602496a21.903743 21.903743 0 0 0-21.903744 36.506239l25.554368 14.602496-25.554368 14.602495a20.078431 20.078431 0 0 0-7.301247 29.204991 21.903743 21.903743 0 0 0 29.204991 9.12656l25.554367-14.602495v29.204991a21.903743 21.903743 0 0 0 21.903743 21.903743 23.729055 23.729055 0 0 0 21.903743-21.903743v-29.204991l23.729056 14.602495a23.729055 23.729055 0 0 0 31.030303-9.12656 21.903743 21.903743 0 0 0-9.12656-29.204991zM960.163548 907.180036l-14.602496-7.301248 14.602496-9.12656a12.777184 12.777184 0 0 0-12.777184-20.078431l-14.602495 7.301248v-16.427808a12.777184 12.777184 0 0 0-12.777184-12.777184 12.777184 12.777184 0 0 0-10.951871 12.777184v16.427808l-14.602496-7.301248a12.777184 12.777184 0 0 0-12.777184 20.078431l14.602496 9.12656-14.602496 7.301248a12.777184 12.777184 0 0 0-3.650623 16.427807 10.951872 10.951872 0 0 0 16.427807 5.475936l14.602496-9.12656v16.427808a12.777184 12.777184 0 0 0 10.951871 12.777183 12.777184 12.777184 0 0 0 12.777184-12.777183v-16.427808l14.602495 9.12656a10.951872 10.951872 0 0 0 16.427808-5.475936 12.777184 12.777184 0 0 0-3.650624-16.427807zM633.43271 735.600713l-10.951871-5.475936 10.951871-7.301248c5.475936-1.825312 5.475936-7.301248 3.650624-12.777183a9.12656 9.12656 0 0 0-12.777184-1.825312l-10.951871 5.475936v-12.777184a9.12656 9.12656 0 0 0-9.12656-9.12656 9.12656 9.12656 0 0 0-9.12656 9.12656v12.777184l-9.126559-5.475936a9.12656 9.12656 0 0 0-12.777184 1.825312 7.301248 7.301248 0 0 0 3.650624 12.777183l9.12656 7.301248-9.12656 5.475936a7.301248 7.301248 0 0 0-3.650624 12.777184 10.951872 10.951872 0 0 0 12.777184 3.650623l9.126559-7.301247v12.777183a9.12656 9.12656 0 0 0 9.12656 9.12656 9.12656 9.12656 0 0 0 9.12656-9.12656v-12.777183l10.951871 7.301247a10.951872 10.951872 0 0 0 12.777184-3.650623c1.825312-5.475936 1.825312-10.951872-3.650624-12.777184zM876.199199 755.679144l-16.427808-9.126559 16.427808-9.12656a14.602496 14.602496 0 0 0 5.475935-20.078431 14.602496 14.602496 0 0 0-20.078431-5.475936l-16.427807 9.126559v-20.078431a14.602496 14.602496 0 0 0-14.602496-14.602495 14.602496 14.602496 0 0 0-12.777184 14.602495v20.078431l-16.427807-10.951871a16.427807 16.427807 0 0 0-20.078431 5.475936 14.602496 14.602496 0 0 0 5.475935 20.078431l16.427808 10.951872-16.427808 9.126559a14.602496 14.602496 0 0 0-5.475935 20.078432 16.427807 16.427807 0 0 0 20.078431 5.475936l16.427807-10.951872v20.078431a14.602496 14.602496 0 1 0 29.204991 0v-20.078431l16.427808 10.951872a14.602496 14.602496 0 1 0 14.602496-25.554368z"fill="#A1C6E6"></path><path d="M418.045901 762.980392l-20.078431-12.777183 20.078431-10.951872a18.253119 18.253119 0 1 0-18.25312-32.855615l-20.078431 12.777184v-23.729056a18.253119 18.253119 0 0 0-18.253119-18.253119 16.427807 16.427807 0 0 0-18.25312 18.253119v23.729056l-21.903743-12.777184a18.253119 18.253119 0 0 0-18.25312 32.855615l21.903744 10.951872-21.903744 12.777183a20.078431 20.078431 0 0 0-7.301247 25.554367 20.078431 20.078431 0 0 0 25.554367 5.475936l21.903743-10.951871v23.729055a18.253119 18.253119 0 0 0 18.25312 18.253119 20.078431 20.078431 0 0 0 18.253119-18.253119v-23.729055l20.078431 10.951871a20.078431 20.078431 0 0 0 25.554368-5.475936 20.078431 20.078431 0 0 0-7.301248-25.554367zM240.990642 865.197861l-16.427807-9.12656 16.427807-10.951871a14.602496 14.602496 0 0 0 5.475936-20.078432 14.602496 14.602496 0 0 0-20.078431-3.650624l-16.427808 9.12656v-20.078431a14.602496 14.602496 0 0 0-14.602495-14.602496 16.427807 16.427807 0 0 0-14.602496 14.602496v20.078431L164.327541 821.390374a14.602496 14.602496 0 0 0-20.078432 3.650624 14.602496 14.602496 0 0 0 5.475936 20.078432l16.427808 10.951871-16.427808 9.12656a14.602496 14.602496 0 0 0-5.475936 20.078431 16.427807 16.427807 0 0 0 20.078432 5.475936l16.427807-10.951871v20.078431a16.427807 16.427807 0 0 0 14.602496 14.602495 14.602496 14.602496 0 0 0 14.602495-14.602495v-20.078431l16.427808 10.951871a16.427807 16.427807 0 0 0 20.078431-5.475936 14.602496 14.602496 0 0 0-5.475936-20.078431zM527.564617 909.005348l-10.951871-7.301248 10.951871-5.475936a10.951872 10.951872 0 0 0 3.650624-12.777184 9.12656 9.12656 0 0 0-12.777183-3.650623l-10.951872 7.301247v-12.777183a10.951872 10.951872 0 1 0-20.078431 0v12.777183l-10.951872-7.301247a9.12656 9.12656 0 0 0-12.777184 3.650623 10.951872 10.951872 0 0 0 3.650624 12.777184l10.951872 5.475936-10.951872 7.301248a10.951872 10.951872 0 0 0-3.650624 12.777183 12.777184 12.777184 0 0 0 12.777184 3.650624l10.951872-7.301248v12.777184a9.12656 9.12656 0 0 0 9.126559 9.12656 10.951872 10.951872 0 0 0 10.951872-9.12656v-12.777184l10.951872 7.301248a12.777184 12.777184 0 0 0 12.777183-3.650624 10.951872 10.951872 0 0 0-3.650624-12.777183z"fill="#CFDBE6"></path></svg></div>',
'sentence':'<div title="点击输入" class="sentence"><div id="jinrishici-sentence"></div><script src="https://sdk.jinrishici.com/v2/browser/jinrishici.js"charset="utf-8"><\/script></div>',
'torch':'<div class="torch"><svg width="100%"height="100%"viewBox="0 0 1000 1000"preserveAspectRatio="xMidYMid "version="1.1"xmlns="http://www.w3.org/2000/svg"fill="#FFFFFF"><path d="M876.13 511.55c-6.74 0-13.49-2.57-18.63-7.72L520.15 166.49c-4.94-4.94-7.72-11.65-7.72-18.63s2.78-13.69 7.72-18.63l42.1-42.1c30.81-30.82 80.97-30.84 111.81-0.01l262.79 262.81c30.82 30.83 30.82 80.98 0 111.8l-42.1 42.1a26.26 26.26 0 0 1-18.62 7.72zM576.06 147.86l300.07 300.07 23.47-23.47c10.27-10.27 10.27-26.99 0-37.27l-262.8-262.8c-10.28-10.28-27.02-10.26-37.28 0.01l-23.46 23.46z"></path><path d="M632.45 584.55c-6.88 0-13.61-2.7-18.63-7.72L447.15 410.16a26.322 26.322 0 0 1-6.6-26.23l73.42-244.08c2.67-8.88 9.81-15.7 18.8-17.96 8.98-2.26 18.52 0.37 25.07 6.92l337.34 337.34a26.33 26.33 0 0 1 6.92 25.07 26.336 26.336 0 0 1-17.96 18.8l-244.08 73.41c-2.51 0.76-5.07 1.12-7.61 1.12zM495.56 384.03l144.39 144.39 186.78-56.18-274.99-274.99-56.18 186.78z"></path><path d="M235.18 960c-21.12 0-40.97-8.22-55.91-23.16L87.14 844.7c-30.83-30.83-30.83-80.98 0-111.8l359.6-359.59a26.366 26.366 0 0 1 18.63-7.72c6.99 0 13.69 2.78 18.63 7.72l166.67 166.67c10.29 10.29 10.29 26.98 0 37.27L291.09 936.84C276.16 951.77 256.31 960 235.18 960z m230.19-530.79L124.41 770.16c-10.28 10.28-10.28 27 0 37.27l92.14 92.14c9.96 9.96 27.33 9.96 37.27 0l340.96-340.96-129.41-129.4z"></path><path d="M391.67 690.82c-13.49 0-26.99-5.14-37.27-15.42l-5.82-5.82c-20.55-20.55-20.55-53.99 0-74.54l42.1-42.1c20.55-20.55 53.98-20.55 74.53 0l5.84 5.84c9.94 9.94 15.43 23.18 15.43 37.26 0 14.08-5.49 27.32-15.45 37.27l-42.09 42.1c-10.28 10.27-23.78 15.41-37.27 15.41z m36.26-100.62l-42.09 42.11 5.85 5.85 42.07-42.12-5.83-5.84z"></path></svg></div>',
'camera':'<div class="camera"><svg version="1.0"xmlns="http://www.w3.org/2000/svg"width="100%"height="100%"viewBox="0 0 512.000000 512.000000"preserveAspectRatio="xMidYMid meet"><g transform="translate(0.000000,512.000000) scale(0.100000,-0.100000)"fill="#FFFFFF"stroke="none"><path d="M2049 3974 c-42 -21 -99 -72 -255 -230 -111 -112 -214 -208 -228 -214 -15 -5 -43 -10 -62 -10 l-34 0 0 55 c0 46 -4 60 -25 80 -23 24 -28 25 -179 25 -85 0 -162 -3 -171 -6 -25 -10 -45 -58 -45 -109 l0 -45 -58 0 c-115 0 -234 -54 -292 -133 -63 -86 -61 -39 -58 -1073 l3 -939 28 -56 c32 -67 109 -142 175 -172 l47 -22 1680 0 1680 0 53 29 c65 36 107 82 141 156 l26 55 3 952 c2 951 2 951 -19 1008 -26 71 -77 128 -143 163 l-51 27 -345 5 c-284 4 -349 8 -368 20 -13 8 -86 83 -163 167 -76 84 -167 176 -201 204 -113 94 -78 89 -614 89 l-470 0 -55 -26z m691 -769 c322 -68 589 -337 656 -662 25 -118 15 -322 -20 -426 -50 -150 -119 -260 -227 -363 -105 -99 -194 -152 -336 -200 -113 -38 -320 -45 -446 -15 -316 75 -562 319 -637 633 -27 113 -27 283 0 396 74 309 319 556 627 631 98 25 282 27 383 6z m841 -20 c64 -34 87 -120 49 -182 -54 -89 -187 -80 -227 14 -47 114 69 224 178 168z"/><path d="M2485 2939 c-82 -10 -167 -43 -247 -96 -335 -220 -334 -724 1 -947 167 -111 377 -130 556 -51 120 54 236 170 290 290 110 250 28 547 -195 703 -114 81 -268 119 -405 101z"/></g></svg></div>',
'app_icons_container':'<div class="app-icons-container"></div>',
'bottom_bar':'<div class="bottom-bar"></div>',
'bottom_line':'<div class="bottom-line"></div>'};
let LS_KEY={PREFIX:'wallpaper_',FONT_COLOR:'fontcolor',BG_COLOR:'bgcolor',WATERMARK:'watermark'}
let kfMap={}
function createThirdContainer(iphoneScreen,key){
let st = screenTemplate;
iphoneScreen.append(st.dynamic_island);
iphoneScreen.append(st.status_bar);
iphoneScreen.append(st.time_display);
iphoneScreen.append(st.bottom_line);
iphoneScreen.css('width',context.getDevice().screenWidth);
iphoneScreen.css('height',context.getDevice().screenHeight);
let tc = $(st.third_container);
tc.append(st.watermark);
tc.append(st.desc_top);
tc.append(iphoneScreen);
$('.second_container').append(tc);
iphoneScreen.click(function(event){
uploadImg(this, $('#bgmask'));
event.stopPropagation();
});
if(key in context.getDevice().createdScreens){
delete context.getDevice().createdScreens[key].remove();
}
context.getDevice().createdScreens[key]=tc;
return tc;
}
function saveAsImage() {
$('body').css('transform','scale(1)');
if($('div.third_container').eq(1).length){
let $home = context.getDevice().createdScreens['home'];
let $lock = context.getDevice().createdScreens['lock'];
context.getDevice().screenLayout();
doSave().then(function(success) {
$('div.third_container').eq(1).css('display','none');
context.getDevice().screenLayout();
$home[0].style.transform = this.enlarge;
$lock[0].style.transform = this.enlarge;
doSave().then(function(success) {
$('div.third_container').eq(0).css('display','none');
$('div.third_container').eq(1).css('display','grid');
context.getDevice().screenLayout();
doSave().then(function(success) {
$home[0].style.transform = 'scale(1)';
$lock[0].style.transform = 'scale(1)';
$('body').css('transform','scale(0.5)');
$('div.third_container').css('display','grid');
context.getDevice().screenLayout();
});
})
});
}else{
doSave().then(function(){
$('body').css('transform','scale(0.5)');
});
}
}
function createLockScreen(width,height){
let st = screenTemplate;
let is = $(st.iphone_screen);
let time = $(st.time_display);
currentDateTime(time);
is.append(time);
is.append(st.weather);
is.append(st.torch);
is.append(st.camera);
let tc = createThirdContainer(is,'lock',width,height);
randomWeather();
tc.find('.desc_top').html('Lock Screen');
}
function createHomeScreen(){
let st = screenTemplate;
let is = $(st.iphone_screen);
is.append(st.sentence);
is.append(st.app_icons_container);
is.append(st.bottom_bar);
let tc = createThirdContainer(is,'home');
tc.find('.desc_top').html('Home Screen');
let aic = tc.find('.app-icons-container');
batchCreateAppItems(aic);
randomRealAppIcons(4);
}
function bindEvent(){
$('#introduction').click(function(){
if($('.introduction').css('display')=='none'){
$('.introduction').css('display','block');
}else{
$('.introduction').css('display','none');
}
});
$('#doubleOrSingle').click(function(){
context.getDevice().createScreens();
let screenCount = Object.keys(context.getDevice().createdScreens).length;
if(screenCount==2){
$(this).html('单屏');
}else{
$(this).html('双屏');
}
});
$('#save').click(function(){
saveAsImage();
});
$('#resetScreen').click(function(){
resetScreen('hidden');
});
$('.colorSelector').colorPicker(plugin.input);
$('#appIconCount').on('input',function(){
this.value=Math.min(this.value, iphoneIcons.length);
if(this.value<=iphoneIcons.length){
//appIconCount(this.value);
randomRealAppIcons(this.value);
}
});
$('#appIconCount').on('wheel', function(event) {
changeAppIcons(this);
this.value=Math.min(this.value, iphoneIcons.length)
if(this.value<=iphoneIcons.length){
//appIconCount(this.value);
randomRealAppIcons(this.value);
}
});
$('#watermark').on('input',function(){
kfMap[this.id](this.value);
adjustFontSize($('.watermark-container'));
});
bindHideOrShow(['.dynamic-island']);
$('#mobileOrPC').click(function(){
context.getDevice().clear();
if(context.type=='mobile'){
context.type='pc';
$(this).html('移动端')
}else{
context.type='mobile';
$(this).html('PC端')
}
initScreen();
inputWithDefault();
})
}
function setLS(key, value){
localStorage.setItem(LS_KEY.PREFIX+key, value);
}
function getLS(key){
let value = localStorage.getItem(LS_KEY.PREFIX+key);
if(null!=value && 'null'!=value && 'undefined'!=value){
return localStorage.getItem(LS_KEY.PREFIX+key);
}else{
return '';
}
}
function keyFunction(elementId, action) {
let result = {[elementId]:function(...args) {action(elementId,...args);}};
result[elementId](getLS(elementId))
return result;
}
function inputWithDefault(){
Object.assign(kfMap, keyFunction(LS_KEY.BG_COLOR, function(){
let colorVal = arguments[1];
$('#bgmask').css('background-image','');
$('#bgmask').css('background-color',colorVal);
setLS(arguments[0], colorVal);
}), keyFunction(LS_KEY.FONT_COLOR, function(){
let colorVal = arguments[1];
$('#jinrishici-sentence').css('color',colorVal);
$('.time-display, .app-name, .isp').css('color',colorVal);
setLS(arguments[0], colorVal);
}), keyFunction(LS_KEY.WATERMARK, function(){
let watermarkVal = arguments[1];
$('.watermark-container').html(watermarkVal);
$('.copyright').html(watermarkVal);
setLS(arguments[0], watermarkVal)
adjustFontSize($('.watermark-container'));
}));
}
function adjustFontSize(element) {
// 假设有一个最大和最小字体大小
const maxFontSize = '240';
const minFontSize = '100';
// 计算内容长度或基于div的宽度和高度
const contentLength = element.html().length;
const elementWidth = context.getDevice().screenWidth;
// 简单的逻辑:内容越长,字体越小
let fontSize = maxFontSize;
if (contentLength > 2) { // 假设超过50个字符就开始减小
fontSize = Math.max(minFontSize, maxFontSize - (contentLength*25)); // 每多10个字符减少一点
}else{
fontSize=maxFontSize;
}
element.css('fontSize',fontSize+'px')
}
function bindHideOrShow(classOrIds){
for(classOrId of classOrIds){
$(classOrId).hover(function(){
$(this).attr('bgcolor',$(this).css('background-color'))
$(this).css('background-color','gray');
},function(){
$(this).css('background-color',$(this).attr('bgcolor'));
});
$(classOrId).click(function(event){
let opacity = $(this).css('opacity');
if(opacity!=0){
$(this).css('opacity',0);
$(this).attr('opacity',opacity);
}else{
$(this).css('opacity',$(this).attr('opacity'));
}
$(this).attr('opacity',opacity);
event.stopPropagation();
})
}
}
function changeAppIcons(inputEl){
let val = inputEl.value
event.preventDefault(); // 阻止默认行为(如果需要的话)
var delta = event.deltaY; // 获取滚轮滚动的垂直距离
var currentValue = parseInt(val, 10) || 1; // 获取当前值,如果为空则默认为0
// 根据滚轮滚动的方向增加或减少值
if (delta < 0) {
// 向下滚动
$(inputEl).val(currentValue + 1);
} else {
// 向上滚动
$(inputEl).val(currentValue - 1);
}
}
var plugin={};
plugin.input = {
customBG: '#222',
margin: '4px -2px 0',
doRender: 'div div',
buildCallback: function($elm) {
var colorInstance = this.color,
colorPicker = this;
$elm.prepend('<div class="cp-panel">' +
'R <input type="text" class="cp-r" /><br>' +
'G <input type="text" class="cp-g" /><br>' +
'B <input type="text" class="cp-b" /><hr>' +
'H <input type="text" class="cp-h" /><br>' +
'S <input type="text" class="cp-s" /><br>' +
'B <input type="text" class="cp-v" /><hr>' +
'<input type="text" class="cp-HEX" />' +
'</div>').on('change', 'input', function(e) {
var value = this.value,
className = this.className,
type = className.split('-')[1],
color = {};
color[type] = value;
colorInstance.setColor(type === 'HEX' ? value : color,
type === 'HEX' ? 'HEX' : /(?:r|g|b)/.test(type) ? 'rgb' : 'hsv');
colorPicker.render();
this.blur();
});
},
cssAddon: // could also be in a css file instead
'.cp-color-picker{z-index:5;box-sizing:border-box; width:30%;height:30%;}' +
'.cp-color-picker .cp-panel {width:14%;height100%;line-height: 40px; float:right;' +
'margin-top:-1px; overflow:visible}' +
'.cp-xy-slider:active {cursor:none;}.cp-xy-slider{width:75%;height:92%;}' +
'.cp-panel, .cp-panel input {color:#bbb; font-family:monospace,' +
'"Courier New",Courier,mono; font-size:20px; font-weight:bold;}' +
'.cp-panel input {float:right;width:70%; height:12px;' +
'text-align:right; line-height:12px; background:transparent;' +
'border:1px solid; border-color:#222 #666 #666 #222;}' +
'.cp-panel hr {margin:0 -2px 2px; height:1px; border:0;' +
'background:#666; border-top:1px solid #222;}' +
'.cp-panel .cp-HEX {position:absolute;width:100%;height:30%;font-size:124%;color:red; margin:1px -3px 0 -2px;}' +
'.cp-z-slider{left:-4%;width:5%;height:92%}' +
'.cp-alpha {width:75%;}',
renderCallback: function($elm, toggled) {
var colors = this.color.colors.RND,
modes = {
r: colors.rgb.r, g: colors.rgb.g, b: colors.rgb.b,
h: colors.hsv.h, s: colors.hsv.s, v: colors.hsv.v,
HEX: this.color.colors.HEX
};
$('input', '.cp-panel').each(function() {
this.value = modes[this.className.substr(3)];
});
$elm[0].value='#'+this.color.colors.HEX;
kfMap[$elm.attr('id')]('#'+this.color.colors.HEX);
}
};
function resetScreen(operation){
var screenItems = $('.iphone-screen > div');
var excludeClasses = ['status-bar'];
for(screenItem of screenItems){
if(!excludeClasses.includes(screenItem.className)){
$(screenItem).css('visibility',operation);
}
}
}
function doSave() {
return new Promise((resolve, reject) => {
domtoimage.toPng(document.getElementById('root_container'))
.then(function (dataUrl) {
const link = document.createElement('a');
link.download = 'download.png';
link.href = dataUrl;
document.body.appendChild(link); // 可能需要添加到DOM中才能触发下载
link.click();
document.body.removeChild(link); // 清理
resolve(true); // 图片下载并触发后解决Promise
})
.catch(function (error) {
reject(error); // 如果发生错误,则拒绝Promise
console.error('oops, something went wrong!', error);
});
});
}
function setBgImg(imgPaths){
$('.iphone-screen').each(function(index, element) {
if(imgPaths.length>1){
$(element).css('background-image','url("'+imgPaths[index]+'")');
}
});
}
function getRandomNum(array) {
if (array.length === 0) {
return null; // 或者抛出错误,取决于你的需求
}
const index = Math.floor(Math.random() * array.length);
return array[index];
}
function randomWeather(){
var weatherIcons = $('.weather').find('svg');
weatherIcons.css('display','none');
const index = Math.floor(Math.random() * weatherIcons.length);
$(weatherIcons[index]).css('display','block')
}
function rotateScreen(){
$('.iphone-screen').css('transform','rotate(30deg)');
}
function batchCreateAppItems(aic){
aic.empty();
var appItemHTML='';
let tais = context.getDevice().totalAppItems();
for (var i = 0; i < tais; i++) {
appItemHTML += '<div class="app-item"><div class="app-icon"></div><div class="app-name"></div></div>';
}
aic.append(appItemHTML);
}
function getRandomAppIcons(randomCount, icons){
if(!icons){
icons = iphoneIcons;
}
var sortArray = Array.from(icons);
// 对数组进行随机排序
sortArray.sort(function() {
return 0.5 - Math.random();
});
if(!randomCount){
randomCount=sortArray.length;
}
return sortArray.slice(0,randomCount);
}
function randomRenderAppIconBGColor(randomAppItems, randomCount){
sortArray = getRandomAppIcons(randomCount, iphoneIcons);
for(var i=0;i<sortArray.length;i++){
$(randomAppItems[i]).find('.app-icon').css('backgroundColor','rgb(255 255 255 / 25%)');
}
}
function randomRealAppIcons(randomCount){
let tc = context.getDevice().createdScreens['home'];
let aic = tc.find('.app-icons-container');
let appItems = aic.find('.app-item');
$('.app-icon').empty();
$('.app-name').css('display','none');
sortIphoneIcons = getRandomAppIcons(randomCount, iphoneIcons);
let multiple = context.type=='pc' ? 2 : 1;
for(let i=0;i<sortIphoneIcons.length;i++){