domUtil.js
46 KB
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
class DomUtil {
//dom:"#newsContent"
constructor(dom) {
this.dom = dom
this.regxList = [ '“', '‘', '"', '\'' ]
}
$dom(dom, all) {
return document[all ? 'querySelectorAll' : 'querySelector'](dom || this.dom)
}
clearHtml() {
jqHtml('.gx-mobile #newsContent', { type: 'set', str: '' })
}
wrapNumbersInTags(html, regx) {
const container = document.createElement('div')
jqHtml(container, { type: 'set', str: html })
const textNodes = []
// Function to recursively find all text nodes
function getTextNodes(node) {
if (node.nodeType === Node.TEXT_NODE) {
textNodes.push(node)
} else {
node.childNodes.forEach(child => getTextNodes(child))
}
}
getTextNodes(container)
textNodes.forEach(textNode => {
this.wrapNumbersInTextNode(textNode, regx)
})
return jqHtml(container, { type: 'get' })
}
wrapNumbersInTextNode(textNode, regx) {
// 获取当前的文本内容
const textContent = textNode.nodeValue
// 正则表达式匹配所有数字
let numberPattern
switch (regx) {
case 'd':
numberPattern = /\d+/g
break
case '“':
numberPattern = /“([^”]+)”/g
break
case '‘':
numberPattern = /‘([^’]+)’/g
break
case '"':
numberPattern = /"([^"]+)"/g
break
case '\'':
numberPattern = /'([^']+)'/g
break
}
// 创建 DocumentFragment 来替换文本节点
const fragment = document.createDocumentFragment()
// 使用正则表达式分割文本并找到所有数字
let lastIndex = 0
let match
while ((match = numberPattern.exec(textContent)) !== null) {
// 在找到的数字之前的文本
const beforeText = textContent.slice(lastIndex, match.index)
if (beforeText) {
fragment.appendChild(document.createTextNode(beforeText))
}
// 创建包含所需数字的 span 元素
const span = document.createElement('span')
span.className = 'special-no-wrap'
span.textContent = match[0]
fragment.appendChild(span)
// 更新 lastIndex 以继续查找剩余文本中的数字
lastIndex = match.index + match[0].length
}
// 添加剩余的文本内容
const afterText = textContent.slice(lastIndex)
if (afterText) {
fragment.appendChild(document.createTextNode(afterText))
}
// 用 fragment 替换原来的文本节点
textNode.parentNode.replaceChild(fragment, textNode)
}
handleArticleStr(str, nextCallback, details, netstutas, loadlmageOnlyWifiSwitch) {
if (!str) return ''
let padding = getComputedStyle(document.querySelector('.gx-mobile')).paddingLeft
if (padding) {
padding = padding.split('px')[0]
padding = Number(padding).toFixed(3)
padding = Number(padding)
}
const contentWidth = document.querySelector('body').getBoundingClientRect().width - padding * 2
jqHtml('#newsContent', { type: 'set', str })
const audioOringin = document.querySelectorAll('#newsContent audio')
for (let i = 0; i < audioOringin.length; i++) {
const audioEl = audioOringin[i]
const audioSourceEl = audioEl.querySelector('source')
if (audioEl && audioSourceEl) {
const src = audioEl.getAttribute('src') || audioSourceEl.getAttribute('src')
if (src) {
audioEl.outerHTML = `<div class="audio-block_${getRandomNumber().uuid(10)}">${audioEl.outerHTML}</div>`
}
}
}
const audioDom = document.querySelectorAll('#newsContent [class^="audio-block"]')
const linkCardDom = document.querySelectorAll('#newsContent .linkcard')
const swiperDom = document.querySelectorAll(`#newsContent section[data-title='轮播图片']`)
const swiper2Dom = document.querySelectorAll(`#newsContent section[data-title='图片海报']`)
const leftOrRight = document.querySelectorAll(`#newsContent section[data-title='左文右图']`)
const leftOrRight2 = document.querySelectorAll(`#newsContent section[data-title='左图右文']`)
const authorDom = document.querySelectorAll(`#newsContent section[data-title='作者头像框']`)
const imgPut = document.querySelectorAll('#newsContent .edit_img_input')
const imgPut2 = document.querySelectorAll('#newsContent .imageCaption')
const imgPut3 = document.querySelectorAll('#newsContent .bjh-image-caption')
const imgPut4 = document.querySelectorAll('#newsContent .rmrb-caption-img2')
const imgPut5 = document.querySelectorAll('#newsContent .rmrb-caption-img')
const swiperText = document.querySelectorAll(`#newsContent section[data-title='文字滚动']`)
const tableDom = document.querySelectorAll(`#newsContent section[data-title='基本表格']`)
const text1Dom = document.querySelectorAll(`#newsContent section[data-title='文本框1']`)
const text2Dom = document.querySelectorAll(`#newsContent section[data-title='文本框2']`)
const text3Dom = document.querySelectorAll(`#newsContent section[data-title='文本框3']`)
const text4Dom = document.querySelectorAll(`#newsContent section[data-title='文本框4']`)
const text5Dom = document.querySelectorAll(`#newsContent section[data-title='文本框5']`)
const imageLightDom = document.querySelectorAll(`#newsContent section[data-title='图片点亮']`)
const textChangeDom = document.querySelectorAll(`#newsContent section[data-title='文字切换']>div`)
const textSplit5Dom = document.querySelectorAll(`#newsContent section[data-title='分割线-5']>div`)
const tableAllDom = document.querySelectorAll(`#newsContent table`)
// const brDom = []
const brDom = document.querySelectorAll(`#newsContent p > br`)
if (swiperDom.length > 0 || swiper2Dom.length > 0) {
nextCallback(5)
}
// 处理所有表格属性
for (let i = 0; i < tableAllDom.length; i++) {
if (tableAllDom[i]) {
tableAllDom[i].setAttribute('width', '')
}
}
// 处理图片点亮
for (let i = 0; i < imageLightDom.length; i++) {
const height = contentWidth / (339 / 190)
imageLightDom[i].style.width = `${contentWidth}px`
imageLightDom[i].style.height = `${height}px`
const divEl = imageLightDom[i].querySelector(':first-child > div > div')
const svgElTwo = imageLightDom[i].querySelector(':first-child > svg')
if (divEl) {
divEl.style.width = `${contentWidth}px`
divEl.style.height = `${height}px`
divEl.style.maxHeight = `${height}px`
}
if (svgElTwo) {
svgElTwo.style.width = `${contentWidth}px`
svgElTwo.style.height = `${height}px`
svgElTwo.style.maxHeight = `${height}px`
}
}
// 处理分割线5
for (let i = 0; i < textSplit5Dom.length; i++) {
const imgElList = textSplit5Dom[i].querySelector('img')
for (let j = 0; j < imgElList.length; j++) {
imgElList[j].src = imgElList[j].getAttribute('data-src')
? imgElList[j].getAttribute('data-src')
: imgElList[j].getAttribute('src')
imgElList[j].classList.add('not-preview-image')
imgElList[j].classList.add('local-image')
}
if (textSplit5Dom[i].querySelector('div#sign')) {
const isDark = document.querySelector('html').getAttribute('dark-mode') === 'true'
textSplit5Dom[i].querySelector('div#sign').style.background = isDark ? '#1d1d1d' : '#fff'
}
}
// 处理换行的间距
for (let i = 0; i < brDom.length; i++) {
if (brDom[i].parentNode) {
if (brDom[i].parentNode.childNodes && brDom[i].parentNode.childNodes.length === 1) {
if (brDom[i].parentNode.childNodes[0].tagName === 'BR') {
brDom[i].parentNode.remove()
}
} else if (brDom[i].parentNode && brDom[i].parentNode.childNodes) {
let isAllBr = 0
brDom[i].parentNode.childNodes.forEach(el => {
if (el.tagName === 'BR') {
isAllBr += 1
}
})
if (isAllBr === brDom[i].parentNode.childNodes.length) brDom[i].parentNode.remove()
}
}
}
// 处理文字切换
for (let i = 0; i < textChangeDom.length; i++) {
textChangeDom[i].style.width = '100%'
}
// 处理文本1
for (let i = 0; i < text1Dom.length; i++) {
let title = ''
let bgHex = ''
let borderColor = ''
let styleString = ''
let contentStyle = {}
const el = document.createElement('div')
el.classList.add('en-text-1')
const borderEl = text1Dom[i].querySelector('div#border')
const titleEl = text1Dom[i].querySelector('p#content')
if (titleEl) {
title = jqHtml(titleEl, { type: 'get' })
const inlineStyles = titleEl.style
for (let i = 0; i < inlineStyles.length; i++) {
const property = inlineStyles[i]
// 你可以选择性地过滤或直接复制所有内联样式
if (!property.startsWith('padding') && !property.includes('margin') && !property.includes('width') && !property.includes(
'height') && property !== 'line-height' && property !== 'font-size' && property !== 'font-family') {
contentStyle[property] = inlineStyles.getPropertyValue(property)
}
}
for (const property in contentStyle) {
if (contentStyle.hasOwnProperty(property)) {
styleString += `${property}: ${contentStyle[property]}; `
}
}
}
if (borderEl) {
bgHex = borderEl.style.backgroundColor
borderColor = borderEl.style.borderInlineStartColor
}
el.style.borderLeftColor = borderColor
el.style.backgroundColor = bgHex
jqHtml(el, {
type: 'set',
str: `<svg class="en-text-1-img" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="24" height="15" viewBox="0 0 24 15"><g><g transform="matrix(-1,0,0,-1,48,30)" style="opacity:0.20000000298023224;"><path d="M34,14.999999999999993L24,14.999999999999993L24,23.330379999999998L26.649259999999998,23.330379999999998C26.649259999999998,23.330379999999998,26.5212,25.54,24,26.223100000000002L24,30C24,30,33.615449999999996,28.232,34,20.79888L34,14.999999999999993Z" fill-rule="evenodd" fill="${rgbToRgba(borderColor, 1)}" fill-opacity="1"/></g><g transform="matrix(-1,0,0,-1,20,30)" style="opacity:0.20000000298023224;"><path d="M20,14.999999999999993L10,14.999999999999993L10,23.330379999999998L12.64926,23.330379999999998C12.64926,23.330379999999998,12.5212,25.54,10,26.223100000000002L10,30C10,30,19.61545,28.232,20,20.79888L20,14.999999999999993Z" fill-rule="evenodd" fill="${rgbToRgba(borderColor, 1)}" fill-opacity="1"/></g></g></svg><div class="en-text-1-title" style="${styleString}">${title}</div>`
})
text1Dom[i].before(el)
text1Dom[i].remove()
}
// 处理文本2
for (let i = 0; i < text2Dom.length; i++) {
let title = ''
let borderColor = ''
let styleString = ''
let contentStyle = {}
const el = document.createElement('div')
el.classList.add('en-text-2')
const borderEl = text2Dom[i].querySelector('div#border')
const titleEl = text2Dom[i].querySelector('div#content')
if (titleEl) {
title = jqHtml(titleEl, { type: 'get' })
const inlineStyles = titleEl.style
for (let i = 0; i < inlineStyles.length; i++) {
const property = inlineStyles[i]
// 你可以选择性地过滤或直接复制所有内联样式
if (!property.startsWith('padding') && !property.includes('margin') && !property.includes('width') && !property.includes(
'height') && property !== 'line-height' && property !== 'font-size' && property !== 'font-family') {
contentStyle[property] = inlineStyles.getPropertyValue(property)
}
}
for (const property in contentStyle) {
if (contentStyle.hasOwnProperty(property)) {
styleString += `${property}: ${contentStyle[property]}; `
}
}
}
if (borderEl) {
borderColor = borderEl.style.borderColor
}
el.style.borderColor = borderColor
jqHtml(el, { type: 'set', str: `<div class="en-text-2-title" style="${styleString}">${title}</div>` })
text2Dom[i].before(el)
text2Dom[i].remove()
}
// 处理文本3
for (let i = 0; i < text3Dom.length; i++) {
let title = ''
let content = ''
let borderColor = ''
let styleString = ''
let titleStyleStr = ''
let titleStyle = {}
let contentStyle = {}
const el = document.createElement('div')
el.classList.add('en-text-3')
const borderEl = text3Dom[i].querySelector('div#border')
const titleEl = text3Dom[i].querySelector('span#title')
const contentEl = text3Dom[i].querySelector('p#content')
if (titleEl) {
title = jqHtml(titleEl, { type: 'get' })
const inlineStyles = titleEl.style
for (let i = 0; i < inlineStyles.length; i++) {
const property = inlineStyles[i]
// 你可以选择性地过滤或直接复制所有内联样式
if (!property.startsWith('padding') && !property.includes('margin') && !property.includes('width') && !property.includes(
'height') && property !== 'line-height' && property !== 'font-size' && property !== 'font-family') {
titleStyle[property] = inlineStyles.getPropertyValue(property)
}
}
for (const property in titleStyle) {
if (titleStyle.hasOwnProperty(property)) {
titleStyleStr += `${property}: ${titleStyle[property]}; `
}
}
}
if (borderEl) {
borderColor = borderEl.style.borderColor
}
if (contentEl) {
content = jqHtml(contentEl, { type: 'get' })
const inlineStyles = contentEl.style
for (let i = 0; i < inlineStyles.length; i++) {
const property = inlineStyles[i]
// 你可以选择性地过滤或直接复制所有内联样式
if (!property.startsWith('padding') && !property.includes('margin') && !property.includes('width') && !property.includes(
'height') && property !== 'line-height' && property !== 'font-size' && property !== 'font-family') {
contentStyle[property] = inlineStyles.getPropertyValue(property)
}
}
for (const property in contentStyle) {
if (contentStyle.hasOwnProperty(property)) {
styleString += `${property}: ${contentStyle[property]}; `
}
}
}
el.style.borderColor = borderColor
jqHtml(el, {
type: 'set',
str: `<div class="en-text-3-title" style="${titleStyleStr}"><i class="en-text-3-point" style="background: ${borderColor}"></i>${title}</div><div class="en-text-3-content" style="${styleString}">${content}</div>`
})
text3Dom[i].before(el)
text3Dom[i].remove()
}
// 处理文本4
for (let i = 0; i < text4Dom.length; i++) {
let title = ''
let bgHex = ''
let styleString = ''
let contentStyle = {}
const el = document.createElement('div')
el.classList.add('en-text-4')
const borderEl = text4Dom[i].querySelector('div#border')
const titleEl = text4Dom[i].querySelector('h4#title')
if (titleEl) {
title = jqHtml(titleEl, { type: 'get' })
const inlineStyles = titleEl.style
for (let i = 0; i < inlineStyles.length; i++) {
const property = inlineStyles[i]
// 你可以选择性地过滤或直接复制所有内联样式
if (!property.startsWith('padding') && !property.includes('margin') && !property.includes('width') && !property.includes(
'height') && property !== 'line-height' && property !== 'font-size' && property !== 'font-family') {
contentStyle[property] = inlineStyles.getPropertyValue(property)
}
}
for (const property in contentStyle) {
if (contentStyle.hasOwnProperty(property)) {
styleString += `${property}: ${contentStyle[property]}; `
}
}
}
if (borderEl) {
bgHex = borderEl.style.backgroundColor
}
jqHtml(el, {
type: 'set',
str: `<div class="en-text-4-block" style="background-color: ${bgHex}"><div class="en-text-4-title" style="${styleString}">${title}</div><div class="en-text-4-end" style="background: ${bgHex}"></div></div>`
})
text4Dom[i].before(el)
text4Dom[i].remove()
}
// 处理文本5
for (let i = 0; i < text5Dom.length; i++) {
let title = ''
let titleBg = ''
let num = ''
let numBg = ''
let numColor = ''
let styleString = ''
let contentStyle = {}
const el = document.createElement('div')
el.classList.add('en-text-5')
const borderEl = text5Dom[i].querySelector('div#border')
const numEl = text5Dom[i].querySelector('div#sign')
if (numEl) {
num = numEl.textContent
numBg = numEl.style.backgroundColor
numColor = numEl.style.color
}
const titleEl = text5Dom[i].querySelector('h4#title')
if (titleEl) {
title = jqHtml(titleEl, { type: 'get' })
const inlineStyles = titleEl.style
for (let i = 0; i < inlineStyles.length; i++) {
const property = inlineStyles[i]
// 你可以选择性地过滤或直接复制所有内联样式
if (!property.startsWith('padding') && !property.includes('margin') && !property.includes('width') && !property.includes(
'height') && property !== 'line-height' && property !== 'font-size' && property !== 'font-family') {
contentStyle[property] = inlineStyles.getPropertyValue(property)
}
}
for (const property in contentStyle) {
if (contentStyle.hasOwnProperty(property)) {
styleString += `${property}: ${contentStyle[property]}; `
}
}
}
if (borderEl) {
titleBg = borderEl.style.backgroundColor
}
jqHtml(el, {
type: 'set',
str: `<div class="en-text-5-block"><div class="en-text-5-num " style="color: ${numColor}; background: ${numBg}">${num}</div><div style="${styleString}" class="en-text-5-title">${title}</div></div>`
})
text5Dom[i].before(el)
text5Dom[i].remove()
}
// 处理表格
for (let i = 0; i < tableDom.length; i++) {
let title = ''
const el = document.createElement('div')
el.classList.add('en-table')
const titleEl = tableDom[i].querySelector('span:first-child')
if (titleEl) {
title = titleEl.textContent
}
const tableHtml = jqHtml(tableDom[i].querySelector('table'), { type: 'get' })
const tableStyle = tableDom[i].querySelector('table').getAttribute('style')
jqHtml(el, {
type: 'set', str: `<div class="en-table-title ">${title}</div><table style="${tableStyle}">${tableHtml}</table>`
})
tableDom[i].before(el)
tableDom[i].remove()
}
const tableEl = document.querySelectorAll('#article table')
// 处理表格
for (let i = 0; i < tableEl.length; i++) {
const el = tableEl[i]
// 获取当前元素的 width 样式,使用 getComputedStyle 获取计算后的样式
const computedStyle = window.getComputedStyle(el)
const currentWidth = computedStyle.width
let widthValue
// 判断宽度的单位
if (currentWidth.endsWith('%')) {
// 处理百分比,获取父元素的宽度
const parentWidth = el.parentElement ? el.parentElement.clientWidth : 0
widthValue = (parseFloat(currentWidth) / 100) * parentWidth // 转换为像素值
} else {
// 处理像素值
widthValue = parseFloat(currentWidth) // 转换为浮点数
}
// 判断宽度是否大于指定的 threshold
if (widthValue > contentWidth) {
el.style.width = '100%' // 设置宽度为100%
} else {
el.style.width = computedStyle.width // 保持原来的宽度
}
}
// 处理轮播字幕
for (let i = 0; i < swiperText.length; i++) {
const el = document.createElement('div')
el.classList.add('en-scroll-text')
let text = ''
let imgSrc = ''
const textEl = swiperText[i].querySelector('tspan')
const imgEl = swiperText[i].querySelector('img')
if (textEl) {
text = textEl.textContent
// text = 'Trucks wait to load containers at a container terminal in Rizhao。Trucks wait to load containers at a container terminal in Rizhao。Trucks wait to load containers at a container terminal in Rizhao。'
}
if (imgEl) {
imgSrc = imgEl.getAttribute('src') || imgEl.getAttribute('data-src')
}
jqHtml(el, {
type: 'set',
str: `<div class="scroll-text-left"><img class="not-preview-image local-image" data-src="${imgSrc || './image/scrollText.svg'}" src="${imgSrc || './image/scrollText.svg'}" alt=""></div><div class="swiper-txet">${text}</div>`
})
swiperText[i].before(el)
swiperText[i].remove()
}
// 处理图注3
for (let i = 0; i < imgPut3.length; i++) {
const el = document.createElement('div')
el.innerText = imgPut3[i] ? imgPut3[i].textContent || '' : ''
const align = imgPut3[i].style.textAlign
if (align) {
el.style.textAlign = align
}
el.classList.add('rmrb-caption-img2')
imgPut3[i].before(el)
imgPut3[i].remove()
}
// 处理图注4
for (let i = 0; i < imgPut4.length; i++) {
const el = document.createElement('div')
el.innerText = imgPut4[i] ? imgPut4[i].textContent || '' : ''
const align = imgPut4[i].style.textAlign
if (align) {
el.style.textAlign = align
}
el.classList.add('rmrb-caption-img2')
imgPut4[i].before(el)
imgPut4[i].remove()
}
// 处理图注5
for (let i = 0; i < imgPut5.length; i++) {
const el = document.createElement('div')
el.innerText = imgPut5[i] ? imgPut5[i].textContent || '' : ''
const align = imgPut5[i].style.textAlign
if (align) {
el.style.textAlign = align
}
el.classList.add('rmrb-caption-img2')
imgPut5[i].before(el)
imgPut5[i].remove()
}
// 处理图注
for (let i = 0; i < imgPut.length; i++) {
const el = document.createElement('div')
el.innerText = imgPut[i] ? imgPut[i].textContent || '' : ''
const align = imgPut[i].style.textAlign
if (align) {
el.style.textAlign = align
}
el.classList.add('rmrb-caption-img')
imgPut[i].before(el)
imgPut[i].remove()
}
// 处理图注2
for (let i = 0; i < imgPut2.length; i++) {
const el = document.createElement('div')
el.innerText = imgPut2[i] ? imgPut2[i].querySelector('.title')
? imgPut2[i].querySelector('.title').textContent || ''
: '' : ''
const align = imgPut2[i].style.textAlign
if (align) {
el.style.textAlign = align
}
el.classList.add('rmrb-caption-img2')
imgPut2[i].before(el)
imgPut2[i].remove()
}
// 处理左文右图
for (let i = 0; i < leftOrRight.length; i++) {
const imageElList = leftOrRight[i].querySelectorAll('img')
for (let j = 0; j < imageElList.length; j++) {
imageElList[j].src = imageElList[j].getAttribute('data-src')
? imageElList[j].getAttribute('data-src')
: imageElList[j].getAttribute('src')
imageElList[j].style.objectFit = 'cover'
imageElList[j].classList.add('not-preview-image')
imageElList[j].classList.add('local-image')
}
}
for (let i = 0; i < leftOrRight2.length; i++) {
const imageElList = leftOrRight2[i].querySelectorAll('img')
for (let j = 0; j < imageElList.length; j++) {
imageElList[j].src = imageElList[j].getAttribute('data-src')
? imageElList[j].getAttribute('data-src')
: imageElList[j].getAttribute('src')
imageElList[j].style.objectFit = 'cover'
imageElList[j].classList.add('not-preview-image')
imageElList[j].classList.add('local-image')
}
}
// 处理作者头像框
for (let i = 0; i < authorDom.length; i++) {
const imageElList = authorDom[i].querySelectorAll('img')
for (let j = 0; j < imageElList.length; j++) {
imageElList[j].src = imageElList[j].getAttribute('data-src')
? imageElList[j].getAttribute('data-src')
: imageElList[j].getAttribute('src')
imageElList[j].classList.add('not-preview-image')
imageElList[j].classList.add('local-image')
}
}
// 处理轮播图
for (let i = 0; i < swiperDom.length; i++) {
const id = `rmrb-en-swiper_${i + 1}`
const el = document.createElement('div')
el.setAttribute('id', `${id}`)
el.setAttribute('class', `mobile swiper-block`)
el.style.width = `${contentWidth}px`
el.style.height = `${contentWidth / 1.3346303501945525}px`
const srcElList = swiperDom[i].querySelectorAll('g foreignObject svg')
const alEl = swiperDom[i].querySelector('g animateTransform')
const isLoop = alEl ? alEl.getAttribute('repeatCount') === 'indefinite' : false
const time = alEl ? alEl.getAttribute('dur') : 0
const urlList = []
if (srcElList) {
for (let j = 0; j < srcElList.length; j++) {
const backgroundImage = srcElList[j].style.backgroundImage
const url = backgroundImage.match(/url\("(.+)"\)/)[1]
if (j !== 0) {
urlList.push(url)
}
}
}
let html = '<div class="swiper-wrapper">'
urlList.forEach(el => {
html += `<div class="swiper-slide"><img data-src="${el}" class="not-preview-image local-image" src="${el}" alt=""></div>`
})
jqHtml(el, { type: 'set', str: html + `</div><div class="swiper-pagination"></div>` })
swiperDom[i].before(el)
swiperDom[i].remove()
nextCallback(3, {
id: `#${id}`, isLoop, length: urlList.length, time: parseInt(time)
})
}
// 处理海报轮播图
for (let i = 0; i < swiper2Dom.length; i++) {
const id = `rmrb-en-poster-swiper_${i + 1}`
const el = document.createElement('div')
el.setAttribute('id', `${id}`)
el.setAttribute('class', `mobile swiper-block`)
el.style.width = `${contentWidth}px`
el.style.height = `${contentWidth / 1.3346303501945525}px`
const srcElList = swiper2Dom[i].querySelectorAll('g foreignObject svg')
const alEl = swiper2Dom[i].querySelector('g animateTransform')
const isLoop = alEl ? alEl.getAttribute('repeatCount') === 'indefinite' : false
const time = alEl ? alEl.getAttribute('dur') : 0
const urlList = []
if (srcElList) {
for (let j = 0; j < srcElList.length; j++) {
const backgroundImage = srcElList[j].style.backgroundImage
const url = backgroundImage.match(/url\("(.+)"\)/)[1]
if (j !== 0) {
urlList.push(url)
}
}
}
let html = '<div class="swiper-wrapper">'
urlList.forEach(el => {
html += `<div class="swiper-slide"><img data-src="${el}" class="not-preview-image local-image" src="${el}" alt=""></div>`
})
jqHtml(el, { type: 'set', str: html + `</div><div class="swiper-pagination"></div>` })
swiper2Dom[i].before(el)
swiper2Dom[i].remove()
nextCallback(4, {
id: `#${id}`, isLoop, length: urlList.length, time: parseInt(time)
})
}
// 处理链接卡片
for (let i = 0; i < linkCardDom.length; i++) {
const titleEl = linkCardDom[i].querySelector('span.title') || linkCardDom[i].querySelector('span')
const title = titleEl ? titleEl.textContent : trim(linkCardDom[i].textContent || '')
const image = linkCardDom[i].querySelector('img')
const a = linkCardDom[i].querySelector('a') || linkCardDom[i].querySelector('p:last-child')
let imageUrl = image ? image.getAttribute('src') || image.getAttribute('data-src') : ''
imageUrl = checkFileType(imageUrl) === '1' ? imageUrl : ''
const hrefUrl = a
? a.getAttribute('href') || a.getAttribute('_href') || a.getAttribute('data-href') || a.textContent
: ''
const dataRmrbnativeEl = linkCardDom[i].querySelector('p.link')
const el = document.createElement('a')
el.setAttribute('class', imageUrl ? 'preview-link-card-mobile card-image' : 'preview-link-card-mobile')
el.setAttribute('data-rmrbnative', dataRmrbnativeEl ? dataRmrbnativeEl.getAttribute('data-rmrbnative') : '')
el.setAttribute('href', hrefUrl)
el.setAttribute('target', '_blank')
let linkIcon = `icon_Y_lianjie`
const isDark = document.querySelector('html').getAttribute('dark-mode') === 'true'
if (!isDark) {
linkIcon = `icon_Y_lianjie`
}
if (imageUrl) {
jqHtml(el, {
type: 'set',
str: `<div class="left"><img data-src="${imageUrl}" class="not-preview-image local-image" src="${imageUrl}" alt=""></div><div class="right"><div class="preview-link-title "><img class="not-preview-image local-image" data-src="./image/${linkIcon}.svg" src="./image/${linkIcon}.svg" alt="">${title}</div><div class="preview-link"><span>${hrefUrl || ''}</span></div></div>`
})
} else {
jqHtml(el, {
type: 'set',
str: `<div class="preview-link-title "><img class="not-preview-image local-image" src="./image/${linkIcon}.svg" data-src="./image/${linkIcon}.svg" alt="">${title}</div><div class="preview-link"><span>${hrefUrl || ''}</span></div>`
})
}
linkCardDom[i].before(el)
linkCardDom[i].remove()
}
// 处理音频
for (let i = 0; i < audioDom.length; i++) {
const dataId = `zh_audio_${i}`
let audioEl
let coverEl
let titleEl
let title = ''
let cover = ''
let audioSrc = ''
audioEl = audioDom[i].querySelector('audio source')
coverEl = audioDom[i].querySelector('.audioStyleLeftImg')
if (!audioEl) {
audioEl = audioDom[i].querySelector('audio')
}
titleEl = audioDom[i].querySelector('.audioStyleTitle')
if (titleEl) {
title = titleEl.textContent
// title = '测试库'
}
if (audioEl) {
audioSrc = audioEl.getAttribute('src')
}
if (!coverEl) {
coverEl = audioDom[i].querySelector('img.audioStyleLeftImg')
if (!coverEl) {
const imageListEl = audioDom[i].querySelectorAll('img')
imageListEl.forEach((el, index) => {
const className = el.getAttribute('class')
let hasCover = false
if (className) hasCover = !isNaN(Number(className)) && typeof Number(className) === 'number'
if (index === 0 && hasCover) coverEl = el
})
}
}
if (coverEl) {
cover = coverEl.getAttribute('src') || coverEl.getAttribute('data-src')
}
const el = document.createElement('div')
el.setAttribute('data-id', dataId)
el.setAttribute('class', cover ? 'preview-audio-player-cover' : 'preview-audio-player')
let publicImageUrl = './image/audio'
const pauseIcon = 'audioPause'
const playIcon = 'audioPlay'
const isDark = document.querySelector('html').getAttribute('dark-mode') === 'true'
if (isDark) {
publicImageUrl = './image/dark'
}
const noCoverTitle = `<div class="audio-title "><div class="audio-notice-title">${title}</div></div>`
if (cover) {
jqHtml(el, {
type: 'set',
str: `<audio src="${audioSrc}" class="audio-block hidden"></audio><div class="left"><img class="not-preview-image local-image" data-src="${cover}" src="" alt=""></div><div class="right"><div class="audio-title" data-cover="cover"><div class="audio-notice-title">${title}</div></div><div class="audio-extra"><div class="audio-time"><span class="audio-current droidSerif">00:00</span><span class="droidSerif audio-current">/</span><span class="audio-durtion droidSerif">00:00</span></div><div class="audio-extral-iocn"><div class="audio-bg"><img data-src="${publicImageUrl}/audioBg.svg" src="${publicImageUrl}/audioBg.svg" alt="" class="not-preview-image local-image" /><img class="audio-play-icon active not-preview-image local-image" data-src="${publicImageUrl}/${pauseIcon}.svg" src="${publicImageUrl}/${pauseIcon}.svg" alt=""><img class="not-preview-image audio-pause-icon local-image" src="${publicImageUrl}/${playIcon}.svg" data-src="${publicImageUrl}/${playIcon}.svg" alt=""></div></div></div></div>`
})
} else {
jqHtml(el, {
type: 'set',
str: `<audio src="${audioSrc}" class="audio-block hidden"></audio><div class="left"><img class="audio-play-icon not-preview-image local-image active mobileIcon" data-src="${publicImageUrl}/${pauseIcon}.svg" src="${publicImageUrl}/${pauseIcon}.svg" alt=""><img class="audio-pause-icon not-preview-image local-image mobileIcon" src="${publicImageUrl}/${playIcon}.svg" data-src="${publicImageUrl}/${playIcon}.svg" alt=""></div><div class="right" style="margin-top: ${title
? '0'
: `${11 / 37.5}rem`}">${title
? noCoverTitle
: ''}<div class="audio-progress-block"><div class="audio-progressed"></div></div><div class="audio-time" style="margin-top: ${title
? `${4 / 37.5}rem`
: `${8 / 37.5}rem`}"><span class="audio-current droidSerif">00:00</span><span class="audio-durtion droidSerif">00:00</span></div></div>`
})
}
if (audioSrc) {
audioDom[i].before(el)
}
audioDom[i].remove()
}
const imageDom = document.querySelectorAll('#newsContent img')
// 处理图片
const effectImage = []
for (let i = 0; i < imageDom.length; i++) {
const name = imageDom[i].getAttribute('data-name')
const classList = imageDom[i].getAttribute('class') || ''
const src = imageDom[i].getAttribute('src') || imageDom[i].getAttribute('data-src') || ''
if (/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/.test(src)) {
nextCallback(1, src)
const style = imageDom[i].style
const isInline = style && style.display ? style.display.indexOf('inline') > -1 : false
if (!classList.includes('not-preview-image') && name !== 'people' && !isInline) {
effectImage.push(imageDom[i])
} else if (imageDom[i]) {
imageDom[i].setAttribute('status', 'loading')
}
} else {
if (imageDom[i] && imageDom[i].classList && imageDom[i].classList.contains('local-image')) {
} else {
imageDom[i].remove()
}
}
}
for (let i = 0; i < effectImage.length; i++) {
const photoList = details.photoList
const src = effectImage[i].getAttribute('src') || effectImage[i].getAttribute('data-src') || ''
const isLink = effectImage[i].parentNode && effectImage[i].parentNode.tagName === 'A' && !!effectImage[i].parentNode.getAttribute(
'href')
const networkStatus = [ 2, 3, 4, 5 ]
const isDark = document.querySelector('html').getAttribute('dark-mode') === 'true'
const imageSrc = isDark ? './image/placeHoldVlogo.svg' : './image/placeholdLogo.svg'
const errorSrc = isDark ? './image/errorDark.svg' : './image/error.svg'
let className = src ? netstutas == 1 || loadlmageOnlyWifiSwitch == '2'
? 'preview-image-block loading'
: networkStatus.includes(Number(netstutas)) ? `preview-image-block loading no-network` : netstutas === 0
? 'preview-image-block loading error'
: 'preview-image-block loading no-network' : 'preview-image-block loading error'
let linkIocnHtml = ''
if (isLink) {
className = className + ' link-image'
linkIocnHtml = `<div class="preview-image-link-icon"><img class="local-image" src="./image/image_link.svg" alt=""><span>链接</span></div>`
}
const parentNode = effectImage[i].parentNode
const style = getComputedStyle(parentNode)
const isInline = style.display === 'inline'
const el = document.createElement(isInline ? 'span' : 'div')
const findRecord = photoList.find(el => {
const originSrc = src.split('?')[0]
return handleMediaSrc(el.picPath) == handleMediaSrc(originSrc)
})
const previewSrc = handleImageSrc(src, 1, details.isNewspaper, findRecord)
let width = effectImage[i].getAttribute('width') || effectImage[i].getAttribute('data-gifffer-width') || ''
let height = effectImage[i].getAttribute('height') || effectImage[i].getAttribute('data-gifffer-height') || ''
width = width ? Number(width) : 0
height = height ? Number(height) : 0
if (width) width = !isNaN(width) && typeof width === 'number' ? width : 0
if (height) height = !isNaN(width) && typeof height === 'number' ? height : 0
if (findRecord) {
width = findRecord.width || width
height = findRecord.height || height
}
width = width && isNumber(Number(width)) ? isNaN(Number(width)) ? 0 : Number(width) : 0
height = height && isNumber(Number(height)) ? isNaN(Number(height)) ? 0 : Number(height) : 0
if (width <= 0) width = 0
if (height <= 0) height = 0
const parentNodeWdith = findAncestorWithNonZeroWidth(effectImage[i])
const parentWidth = parentNodeWdith ? parentNodeWdith.getBoundingClientRect().width : contentWidth
const overMaxWidth = width > parentWidth
el.setAttribute('class', className)
el.setAttribute('status', 'loading')
height = width && height ? overMaxWidth ? parentWidth * height / width : height : 0
el.style.height = height ? `${height}px` : ''
if (!height) el.classList.add('minHeight')
jqHtml(el, {
type: 'set',
str: `<img class="image-player none image-player-${i}" src="" alt="" data-src="${previewSrc}" data-origin-src="${src}" data-image="image"><img class="preview-image-placehold local-image not-preview-image" style="width: ${height > 0 && height < 50 ? '1.6rem' : undefined}" src="${imageSrc}" alt=""><img class="preview-image-error not-preview-image local-image none" src="${errorSrc}" alt=""><span class="no-network-text">点击查看原图</span>${linkIocnHtml}`
})
try {
if (parentNode && parentNode.tagName == 'A') {
const href = parentNode.getAttribute('href')
const dataRmrbnative = parentNode.getAttribute('data-rmrbnative')
el.setAttribute('data-href', href)
el.setAttribute('data-rmrbnative', dataRmrbnative)
if (effectImage[i].parentNode.parentNode && effectImage[i].parentNode.parentNode.tagName == 'P') {
const parentNodeP = effectImage[i].parentNode.parentNode
if (parentNodeP.childNodes.length === 1) {
effectImage[i].parentNode.parentNode.before(el)
effectImage[i].parentNode.parentNode.remove()
} else {
effectImage[i].parentNode.before(el)
effectImage[i].parentNode.remove()
}
} else {
effectImage[i].parentNode.before(el)
effectImage[i].parentNode.remove()
}
} else {
effectImage[i].before(el)
effectImage[i].remove()
}
} catch (e) {
effectImage[i].before(el)
effectImage[i].remove()
}
}
// const previewImageEl = document.querySelectorAll('#newsContent .preview-image-block')
// for (let i = 0; i < previewImageEl.length; i++) {
// const el = previewImageEl[i]
// const parentNode = el.parentNode
// if (parentNode.firstChild === el) {
// el.style.setProperty('margin-top', '0', 'important')
// }
// }
const videoDom = document.querySelectorAll('#newsContent video')
const videoOutter = []
for (let i = 0; i < videoDom.length; i++) {
const parentNode = videoDom[i].parentNode
if (parentNode.getAttribute('id') === 'newContent') {
videoOutter.push(videoDom[i])
}
}
for (let i = 0; i < videoOutter.length; i++) {
const outterEl = document.createElement('p')
outterEl.setAttribute('class', 'en-video-outter-content')
outterEl.append(videoOutter[i].cloneNode())
videoOutter[i].before(outterEl)
videoOutter[i].remove()
}
const videoDomList = document.querySelectorAll('#newsContent video')
for (let i = 0; i < videoDomList.length; i++) {
let width = 0
let height = 0
const videoEl = videoDomList[i]
const videoElId = `origin-video-${i}`
if (videoEl) {
videoEl.setAttribute('id', videoElId)
videoEl.setAttribute('class', 'en-origin-video')
}
const src = videoDomList[i].getAttribute('src')
if (!src) break
if (videoEl && videoEl.style.display === 'none') break
if (videoDomList[i].getAttribute('style')) {
const style = videoDomList[i] ? videoDomList[i].getAttribute('style').split(';') : []
style.forEach(el => {
if (el.includes('width') && !el.includes('max')) {
width = el.includes('width: ') ? el.split('width: ')[1] : el.split('width:')[1]
} else if (el.includes('height') && !el.includes('max')) {
height = el.includes('height: ') ? el.split('height: ')[1] : el.split('height:')[1]
}
})
}
const videoInfoList = details.videoInfo || []
const findRecord = videoInfoList.find(el => handleMediaSrc(el.videoUrl) === handleMediaSrc(src))
if (findRecord && (!width || !height)) {
width = findRecord.resolutionWidth
height = findRecord.resolutionHeight
}
if ((!width || !height)) {
width = videoEl.getAttribute('data-vwidth') || videoEl.getAttribute('data-width')
height = videoEl.getAttribute('data-vheight') || videoEl.getAttribute('data-height')
}
width = width && isNumber(Number(width)) ? isNaN(Number(width)) ? 0 : Number(width) : 0
height = height && isNumber(Number(height)) ? isNaN(Number(height)) ? 0 : Number(height) : 0
if (width <= 0) width = 0
if (height <= 0) height = 0
const parentNode = videoDomList[i].parentNode
const parentWidth = parentNode ? parentNode.getBoundingClientRect().width : contentWidth
let styleHeight = width === 0 ? 0 : Number(parentWidth) / (width / height)
if (!styleHeight) styleHeight = 150
const id = getRandomNumber().uuid(10)
const poster = videoDomList[i].getAttribute('data-poster') || videoDomList[i].getAttribute('poster') || details.firstFrameImageUri
const el = document.createElement('div')
el.setAttribute('class', 'preview-video init')
jqHtml(el, {
type: 'set',
str: `<div id="video-player-${i}" class="video-player video-player-${i}" style="height: ${styleHeight}px" data-height="${height || '0'}" data-width="${width || '0'}" data-id="${id}"></div>`
})
const sibling = videoDomList[i].nextElementSibling || videoDomList[i].previousElementSibling
if (parentNode) {
let containsText = false
if (sibling) {
var childNodes = sibling.childNodes
for (let a = 0; a < childNodes.length; a++) {
if (childNodes[a].nodeType === Node.TEXT_NODE && childNodes[a].textContent.trim() !== '') {
containsText = true
break
}
}
}
if (parentNode.getAttribute('id') === 'newsContent' || containsText) {
videoEl.before(el)
videoEl.remove()
} else {
parentNode.before(el)
parentNode.remove()
}
}
nextCallback(2, { src, id, poster, originId: videoElId, isNewspaper: details.isNewspaper })
}
const aEl = document.querySelectorAll('#newsContent a')
for (let i = 0; i < aEl.length; i++) {
const url = aEl[i].getAttribute('href')
if (aEl[i]) {
aEl[i].setAttribute('data-href', url || '')
}
aEl[i].removeAttribute('href')
aEl[i].style.textDecoration = 'underline'
}
const olstyleEl = document.querySelectorAll('#newsContent [style*="list-style-type: decimal"] li')
for (let i = 0; i < olstyleEl.length; i++) {
olstyleEl[i].style.marginLeft = `${21 / 37.5}rem`
}
const underLineEl = document.querySelectorAll(
'#newsContent [style*="text-decoration"], [style*="text-decoration-line"]')
for (let i = 0; i < underLineEl.length; i++) {
if (underLineEl[i].style.textDecorationLine === 'underline' || underLineEl[i].style.textDecoration === 'underline') {
underLineEl[i].style.textUnderlineOffset = '4px'
}
}
const globalLineDom = document.querySelectorAll(`#newsContent .global-line`)
for (let i = 0; i < globalLineDom.length; i++) {
const parentEl = globalLineDom[i].parentNode
let color = parentEl.style.color
function getParentColor(el) {
if (el && el.getAttribute('id') === 'newsContent') {
} else if (el.style.color) {
color = el.style.color
} else {
getParentColor(el.parentNode)
}
}
if (!color) getParentColor(parentEl.parentNode)
globalLineDom[i].style.backgroundColor = color
if (parentEl.style.fontWeight > 500 || parentEl.style.fontWeight === 'bold' || parentEl.nodeName === 'STRONG') {
globalLineDom[i].style.height = `${2 / 37.5}rem`
globalLineDom[i].style.top = `${-4.5 / 37.5}rem`
} else {
globalLineDom[i].style.height = `${1 / 37.5}rem`
}
}
// const lastEle = document.querySelector('#newsContent')
// ? document.querySelector('#newsContent').lastElementChild
// : null
//
// if (lastEle && lastEle.lastChild && lastEle.lastChild.classList && lastEle.lastChild.classList.contains(
// 'preview-image-block')) {
// const el = lastEle.lastChild
// el.style.setProperty('margin-bottom', '0', 'important')
// }
// if (lastEle && lastEle.style) {
// if (lastEle.childNodes && lastEle.childNodes.length === 1) {
// if (lastEle.childNodes[0].tagName === 'BR') {
// if (lastEle.previousElementSibling) {
// lastEle.previousElementSibling.style.setProperty('margin-bottom', '0', 'important')
// }
// }
// } else {
// lastEle.style.setProperty('margin-bottom', '0', 'important')
// }
// }
let html = jqHtml(document.querySelector('#newsContent'), { type: 'get' })
jqHtml(document.querySelector('#newsContent'), { type: 'set', str: html })
}
}