util.js
23.2 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
import { columeHeader_word, columeHeader_word_index, luckysheetdefaultFont } from '../controllers/constant';
import menuButton from '../controllers/menuButton';
import { isdatatype, isdatatypemulti } from '../global/datecontroll';
import { hasChinaword,isRealNum } from '../global/validate';
import Store from '../store';
import locale from '../locale/locale';
import numeral from 'numeral';
// import method from '../global/method';
/**
* Common tool methods
*/
/**
* Determine whether a string is in standard JSON format
* @param {String} str
*/
function isJsonString(str) {
try {
if (typeof JSON.parse(str) == "object") {
return true;
}
}
catch (e) { }
return false;
}
/**
* extend two objects
* @param {Object } jsonbject1
* @param {Object } jsonbject2
*/
function common_extend(jsonbject1, jsonbject2) {
let resultJsonObject = {};
for (let attr in jsonbject1) {
resultJsonObject[attr] = jsonbject1[attr];
}
for (let attr in jsonbject2) {
// undefined is equivalent to no setting
if(jsonbject2[attr] == undefined){
continue;
}
resultJsonObject[attr] = jsonbject2[attr];
}
return resultJsonObject;
};
// 替换temp中的${xxx}为指定内容 ,temp:字符串,这里指html代码,dataarry:一个对象{"xxx":"替换的内容"}
// 例:luckysheet.replaceHtml("${image}",{"image":"abc","jskdjslf":"abc"}) ==> abc
function replaceHtml(temp, dataarry) {
return temp.replace(/\$\{([\w]+)\}/g, function (s1, s2) { let s = dataarry[s2]; if (typeof (s) != "undefined") { return s; } else { return s1; } });
};
//获取数据类型
function getObjType(obj) {
let toString = Object.prototype.toString;
let map = {
'[object Boolean]': 'boolean',
'[object Number]': 'number',
'[object String]': 'string',
'[object Function]': 'function',
'[object Array]': 'array',
'[object Date]': 'date',
'[object RegExp]': 'regExp',
'[object Undefined]': 'undefined',
'[object Null]': 'null',
'[object Object]': 'object'
}
// if(obj instanceof Element){
// return 'element';
// }
return map[toString.call(obj)];
}
//获取当前日期时间
function getNowDateTime(format) {
let now = new Date();
let year = now.getFullYear(); //得到年份
let month = now.getMonth(); //得到月份
let date = now.getDate(); //得到日期
let day = now.getDay(); //得到周几
let hour = now.getHours(); //得到小时
let minu = now.getMinutes(); //得到分钟
let sec = now.getSeconds(); //得到秒
month = month + 1;
if (month < 10) month = "0" + month;
if (date < 10) date = "0" + date;
if (hour < 10) hour = "0" + hour;
if (minu < 10) minu = "0" + minu;
if (sec < 10) sec = "0" + sec;
let time = '';
//日期
if(format == 1) {
time = year + "-" + month + "-" + date;
}
//日期时间
else if(format == 2) {
time = year + "-" + month + "-" + date+ " " + hour + ":" + minu + ":" + sec;
}
return time;
}
//颜色 16进制转rgb
function hexToRgb(hex) {
let color = [], rgb = [];
hex = hex.replace(/#/, "");
if (hex.length == 3) { // 处理 "#abc" 成 "#aabbcc"
let tmp = [];
for (let i = 0; i < 3; i++) {
tmp.push(hex.charAt(i) + hex.charAt(i));
}
hex = tmp.join("");
}
for (let i = 0; i < 3; i++) {
color[i] = "0x" + hex.substr(i + 2, 2);
rgb.push(parseInt(Number(color[i])));
}
return 'rgb(' + rgb.join(",") + ')';
};
//颜色 rgb转16进制
function rgbTohex(color) {
let rgb;
if (color.indexOf("rgba") > -1) {
rgb = color.replace("rgba(", "").replace(")", "").split(',');
}
else {
rgb = color.replace("rgb(", "").replace(")", "").split(',');
}
let r = parseInt(rgb[0]);
let g = parseInt(rgb[1]);
let b = parseInt(rgb[2]);
let hex = "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
return hex;
};
//列下标 字母转数字
function ABCatNum(a) {
// abc = abc.toUpperCase();
// let abc_len = abc.length;
// if (abc_len == 0) {
// return NaN;
// }
// let abc_array = abc.split("");
// let wordlen = columeHeader_word.length;
// let ret = 0;
// for (let i = abc_len - 1; i >= 0; i--) {
// if (i == abc_len - 1) {
// ret += columeHeader_word_index[abc_array[i]];
// }
// else {
// ret += Math.pow(wordlen, abc_len - i - 1) * (columeHeader_word_index[abc_array[i]] + 1);
// }
// }
// return ret;
if(a==null || a.length==0){
return NaN;
}
var str=a.toLowerCase().split("");
var num=0;
var al = str.length;
var getCharNumber = function(charx){
return charx.charCodeAt() -96;
};
var numout = 0;
var charnum = 0;
for(var i = 0; i < al; i++){
charnum = getCharNumber(str[i]);
numout += charnum * Math.pow(26, al-i-1);
};
// console.log(a, numout-1);
if(numout==0){
return NaN;
}
return numout-1;
};
//列下标 数字转字母
function chatatABC(n) {
// let wordlen = columeHeader_word.length;
// if (index < wordlen) {
// return columeHeader_word[index];
// }
// else {
// let last = 0, pre = 0, ret = "";
// let i = 1, n = 0;
// while (index >= (wordlen / (wordlen - 1)) * (Math.pow(wordlen, i++) - 1)) {
// n = i;
// }
// let index_ab = index - (wordlen / (wordlen - 1)) * (Math.pow(wordlen, n - 1) - 1);//970
// last = index_ab + 1;
// for (let x = n; x > 0; x--) {
// let last1 = last, x1 = x;//-702=268, 3
// if (x == 1) {
// last1 = last1 % wordlen;
// if (last1 == 0) {
// last1 = 26;
// }
// return ret + columeHeader_word[last1 - 1];
// }
// last1 = Math.ceil(last1 / Math.pow(wordlen, x - 1));
// //last1 = last1 % wordlen;
// ret += columeHeader_word[last1 - 1];
// if (x > 1) {
// last = last - (last1 - 1) * wordlen;
// }
// }
// }
var orda = 'a'.charCodeAt(0);
var ordz = 'z'.charCodeAt(0);
var len = ordz - orda + 1;
var s = "";
while( n >= 0 ) {
s = String.fromCharCode(n % len + orda) + s;
n = Math.floor(n / len) - 1;
}
return s.toUpperCase();
};
function ceateABC(index) {
let wordlen = columeHeader_word.length;
if (index < wordlen) {
return columeHeader_word;
}
else {
let relist = [];
let i = 2, n = 0;
while (index < (wordlen / (wordlen - 1)) * (Math.pow(wordlen, i) - 1)) {
n = i;
i++;
}
for (let x = 0; x < n; x++) {
if (x == 0) {
relist = relist.concat(columeHeader_word);
}
else {
relist = relist.concat(createABCdim(x), index);
}
}
}
};
function createABCdim(x, count) {
let chwl = columeHeader_word.length;
if (x == 1) {
let ret = [];
let c = 0, con = true;
for (let i = 0; i < chwl; i++) {
let b = columeHeader_word[i];
for (let n = 0; n < chwl; n++) {
let bq = b + columeHeader_word[n];
ret.push(bq);
c++;
if (c > index) {
return ret;
}
}
}
}
else if (x == 2) {
let ret = [];
let c = 0, con = true;
for (let i = 0; i < chwl; i++) {
let bb = columeHeader_word[i];
for (let w = 0; w < chwl; w++) {
let aa = columeHeader_word[w];
for (let n = 0; n < chwl; n++) {
let bqa = bb + aa + columeHeader_word[n];
ret.push(bqa);
c++;
if (c > index) {
return ret;
}
}
}
}
}
};
/**
* 计算字符串字节长度
* @param {*} val 字符串
* @param {*} subLen 要截取的字符串长度
*/
function getByteLen(val,subLen) {
if(subLen === 0){
return "";
}
if (val == null) {
return 0;
}
let len = 0;
for (let i = 0; i < val.length; i++) {
let a = val.charAt(i);
if (a.match(/[^\x00-\xff]/ig) != null) {
len += 2;
}
else {
len += 1;
}
if(isRealNum(subLen) && len === ~~subLen){
return val.substring(0,i)
}
}
return len;
};
//数组去重
function ArrayUnique(dataArr) {
let result = [];
let obj = {};
if (dataArr.length > 0) {
for (let i = 0; i < dataArr.length; i++) {
let item = dataArr[i];
if (!obj[item]) {
result.push(item);
obj[item] = 1;
}
}
}
return result
}
//获取字体配置
function luckysheetfontformat(format) {
let fontarray = locale().fontarray;
if (getObjType(format) == "object") {
let font = "";
//font-style
if (format.it == "0" || format.it == null) {
font += "normal ";
}
else {
font += "italic ";
}
//font-variant
font += "normal ";
//font-weight
if (format.bl == "0" || format.bl == null) {
font += "normal ";
}
else {
font += "bold ";
}
//font-size/line-height
if (!format.fs) {
font += Store.defaultFontSize + "pt ";
}
else {
font += Math.ceil(format.fs) + "pt ";
}
if (!format.ff) {
font += fontarray[0] + ', "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';
}
else {
let fontfamily = null;
let fontjson = locale().fontjson;
if (isdatatypemulti(format.ff)["num"]) {
fontfamily = fontarray[parseInt(format.ff)];
}
else {
// fontfamily = fontarray[fontjson[format.ff]];
fontfamily = format.ff;
fontfamily = fontfamily.replace(/"/g, "").replace(/'/g, "");
if(fontfamily.indexOf(" ")>-1){
fontfamily = '"' + fontfamily + '"';
}
if(fontfamily!=null && document.fonts && !document.fonts.check("12px "+fontfamily)){
menuButton.addFontTolist(fontfamily);
}
}
if (fontfamily == null) {
fontfamily = fontarray[0];
}
font += fontfamily + ', "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif';
}
return font;
}
else {
return luckysheetdefaultFont();
}
}
//右键菜单
function showrightclickmenu($menu, x, y) {
let winH = $(window).height(), winW = $(window).width();
let menuW = $menu.width(), menuH = $menu.height();
let top = y, left = x;
if (x + menuW > winW) {
left = x - menuW;
}
if (y + menuH > winH) {
top = y - menuH;
}
if (top < 0) {
top = 0;
}
$menu.css({ "top": top, "left": left }).show();
}
//单元格编辑聚焦
function luckysheetactiveCell() {
if (!!Store.fullscreenmode) {
setTimeout(function () {
// need preventScroll:true,fix Luckysheet has been set top, and clicking the cell will trigger the scrolling problem
const input = document.getElementById('luckysheet-rich-text-editor');
input.focus({preventScroll:true});
$("#luckysheet-rich-text-editor").select();
// $("#luckysheet-rich-text-editor").focus().select();
}, 50);
}
}
//单元格编辑聚焦
function luckysheetContainerFocus() {
// $("#" + Store.container).focus({
// preventScroll: true
// });
// fix jquery error: Uncaught TypeError: ((n.event.special[g.origType] || {}).handle || g.handler).apply is not a function
// $("#" + Store.container).attr("tabindex", 0).focus();
// need preventScroll:true,fix Luckysheet has been set top, and clicking the cell will trigger the scrolling problem
document.getElementById(Store.container).focus({preventScroll:true});
}
//数字格式
function numFormat(num, type) {
if (num == null || isNaN(parseFloat(num)) || hasChinaword(num) || num == -Infinity || num == Infinity) {
return null;
}
let floatlen = 6, ismustfloat = false;
if (type == null || type == "auto") {
if (num < 1) {
floatlen = 6;
}
else {
floatlen = 1;
}
}
else {
if (isdatatype(type) == "num") {
floatlen = parseInt(type);
ismustfloat = true;
}
else {
floatlen = 6;
}
}
let format = "", value = null;
for (let i = 0; i < floatlen; i++) {
format += "0";
}
if (!ismustfloat) {
format = "[" + format + "]";
}
if (num >= 1e+21) {
value = parseFloat(numeral(num).value());
}
else {
value = parseFloat(numeral(num).format("0." + format));
}
return value;
}
function numfloatlen(n) {
if (n != null && !isNaN(parseFloat(n)) && !hasChinaword(n)) {
let value = numeral(n).value();
let lens = value.toString().split(".");
if (lens.length == 1) {
lens = 0;
}
else {
lens = lens[1].length;
}
return lens;
}
else {
return null;
}
}
//二级菜单显示位置
function mouseclickposition($menu, x, y, p) {
let winH = $(window).height(), winW = $(window).width();
let menuW = $menu.width(), menuH = $menu.height();
let top = y, left = x;
if (p == null) {
p = "lefttop";
}
if (p == "lefttop") {
$menu.css({ "top": y, "left": x }).show();
}
else if (p == "righttop") {
$menu.css({ "top": y, "left": x - menuW }).show();
}
else if (p == "leftbottom") {
$menu.css({ "bottom": winH - y - 12, "left": x }).show();
}
else if (p == "rightbottom") {
$menu.css({ "bottom": winH - y - 12, "left": x - menuW }).show();
}
}
/**
* 元素选择器
* @param {String} selector css选择器
* @param {String} context 指定父级DOM
*/
function $$(selector, context) {
context = context || document
var elements = context.querySelectorAll(selector)
return elements.length == 1
? Array.prototype.slice.call(elements)[0]
: Array.prototype.slice.call(elements)
}
/**
* 串行加载指定的脚本
* 串行加载[异步]逐个加载,每个加载完成后加载下一个
* 全部加载完成后执行回调
* @param {Array|String} scripts 指定要加载的脚本
* @param {Object} options 属性设置
* @param {Function} callback 成功后回调的函数
* @return {Array} 所有生成的脚本元素对象数组
*/
function seriesLoadScripts(scripts, options, callback) {
if (typeof (scripts) !== 'object') {
var scripts = [scripts];
}
var HEAD = document.getElementsByTagName('head')[0] || document.documentElement;
var s = [];
var last = scripts.length - 1;
//递归
var recursiveLoad = function (i) {
s[i] = document.createElement('script');
s[i].setAttribute('type', 'text/javascript');
// Attach handlers for all browsers
// 异步
s[i].onload = s[i].onreadystatechange = function () {
if (!/*@cc_on!@*/0 || this.readyState === 'loaded' || this.readyState === 'complete') {
this.onload = this.onreadystatechange = null;
this.parentNode.removeChild(this);
if (i !== last) {
recursiveLoad(i + 1);
} else if (typeof (callback) === 'function') {
callback()
};
}
}
// 同步
s[i].setAttribute('src', scripts[i]);
// 设置属性
if (typeof options === 'object') {
for (var attr in options) {
s[i].setAttribute(attr, options[attr]);
}
}
HEAD.appendChild(s[i]);
};
recursiveLoad(0);
}
/**
* 并行加载指定的脚本
* 并行加载[同步]同时加载,不管上个是否加载完成,直接加载全部
* 全部加载完成后执行回调
* @param {Array|String} scripts 指定要加载的脚本
* @param {Object} options 属性设置
* @param {Function} callback 成功后回调的函数
* @return {Array} 所有生成的脚本元素对象数组
*/
function parallelLoadScripts(scripts, options, callback) {
if (typeof (scripts) !== 'object') {
var scripts = [scripts];
}
var HEAD = document.getElementsByTagName('head')[0] || document.documentElement;
var s = [];
var loaded = 0;
for (var i = 0; i < scripts.length; i++) {
s[i] = document.createElement('script');
s[i].setAttribute('type', 'text/javascript');
// Attach handlers for all browsers
// 异步
s[i].onload = s[i].onreadystatechange = function () {
if (!/*@cc_on!@*/0 || this.readyState === 'loaded' || this.readyState === 'complete') {
loaded++;
this.onload = this.onreadystatechange = null;
this.parentNode.removeChild(this);
if (loaded === scripts.length && typeof (callback) === 'function') callback();
}
};
// 同步
s[i].setAttribute('src', scripts[i]);
// 设置属性
if (typeof options === 'object') {
for (var attr in options) {
s[i].setAttribute(attr, options[attr]);
}
}
HEAD.appendChild(s[i]);
}
}
/**
* 动态添加css
* @param {String} url 指定要加载的css地址
*/
function loadLink(url) {
var doc = document;
var link = doc.createElement("link");
link.setAttribute("rel", "stylesheet");
link.setAttribute("type", "text/css");
link.setAttribute("href", url);
var heads = doc.getElementsByTagName("head");
if (heads.length) {
heads[0].appendChild(link);
}
else {
doc.documentElement.appendChild(link);
}
}
/**
* 动态添加一组css
* @param {String} url 指定要加载的css地址
*/
function loadLinks(urls) {
if (typeof (urls) !== 'object') {
urls = [urls];
}
if (urls.length) {
urls.forEach(url => {
loadLink(url);
});
}
}
function transformRangeToAbsolute(txt1){
if(txt1 ==null ||txt1.length==0){
return null;
}
let txtArray = txt1.split(",");
let ret = "";
for(let i=0;i<txtArray.length;i++){
let txt = txtArray[i];
let txtSplit = txt.split("!"), sheetName="", rangeTxt="";
if(txtSplit.length>1){
sheetName = txtSplit[0];
rangeTxt = txtSplit[1];
}
else{
rangeTxt = txtSplit[0];
}
let rangeTxtArray = rangeTxt.split(":");
let rangeRet = "";
for(let a=0;a<rangeTxtArray.length;a++){
let t = rangeTxtArray[a];
let row = t.replace(/[^0-9]/g, "");
let col = t.replace(/[^A-Za-z]/g, "");
let rangeTT = ""
if(col!=""){
rangeTT += "$" + col;
}
if(row!=""){
rangeTT += "$" + row;
}
rangeRet+=rangeTT+":";
}
rangeRet = rangeRet.substr(0, rangeRet.length-1);
ret += sheetName + rangeRet + ",";
}
return ret.substr(0, ret.length-1);
}
function openSelfModel(id, isshowMask=true){
let $t = $("#"+id)
.find(".luckysheet-modal-dialog-content")
.css("min-width", 300)
.end(),
myh = $t.outerHeight(),
myw = $t.outerWidth();
let winw = $(window).width(), winh = $(window).height();
let scrollLeft = $(document).scrollLeft(), scrollTop = $(document).scrollTop();
$t.css({
"left": (winw + scrollLeft - myw) / 2,
"top": (winh + scrollTop - myh) / 3
}).show();
if(isshowMask){
$("#luckysheet-modal-dialog-mask").show();
}
}
/**
* 监控对象变更
* @param {*} data
*/
// const createProxy = (data,list=[]) => {
// if (typeof data === 'object' && data.toString() === '[object Object]') {
// for (let k in data) {
// if(list.includes(k)){
// if (typeof data[k] === 'object') {
// defineObjectReactive(data, k, data[k])
// } else {
// defineBasicReactive(data, k, data[k])
// }
// }
// }
// }
// }
const createProxy = (data, k, callback) => {
if(!data.hasOwnProperty(k)){
console.info('No %s in data',k);
return;
};
if (getObjType(data) === 'object') {
if (getObjType(data[k]) === 'object' || getObjType(data[k]) === 'array') {
defineObjectReactive(data, k, data[k], callback)
} else {
defineBasicReactive(data, k, data[k], callback)
}
}
}
function defineObjectReactive(obj, key, value, callback) {
// 递归
obj[key] = new Proxy(value, {
set(target, property, val, receiver) {
setTimeout(() => {
callback(target, property, val, receiver);
}, 0);
return Reflect.set(target, property, val, receiver)
}
})
}
function defineBasicReactive(obj, key, value, callback) {
Object.defineProperty(obj, key, {
enumerable: true,
configurable: false,
get() {
return value
},
set(newValue) {
if (value === newValue) return
console.log(`发现 ${key} 属性 ${value} -> ${newValue}`)
setTimeout(() => {
callback(value,newValue);
}, 0);
value = newValue
}
})
}
/**
* Remove an item in the specified array
* @param {array} array Target array
* @param {string} item What needs to be removed
*/
function arrayRemoveItem(array, item) {
array.some((curr, index, arr)=>{
if(curr === item){
arr.splice(index, 1);
return curr === item;
}
})
}
/**
* camel 形式的单词转换为 - 形式 如 fillColor -> fill-color
* @param {string} camel camel 形式
* @returns
*/
function camel2split(camel) {
return camel.replace(/([A-Z])/g, function(all, group) {
return '-' + group.toLowerCase();
});
}
export {
isJsonString,
common_extend,
replaceHtml,
getObjType,
getNowDateTime,
hexToRgb,
rgbTohex,
ABCatNum,
chatatABC,
ceateABC,
createABCdim,
getByteLen,
ArrayUnique,
luckysheetfontformat,
showrightclickmenu,
luckysheetactiveCell,
numFormat,
numfloatlen,
mouseclickposition,
$$,
seriesLoadScripts,
parallelLoadScripts,
loadLinks,
luckysheetContainerFocus,
transformRangeToAbsolute,
openSelfModel,
createProxy,
arrayRemoveItem,
camel2split
}