", "\n").replaceAll(/<(.*)>.*?|<(.*) \/>/g, "").trim();
- if (!method_default.createHookFunction("commentUpdateBefore", r2, c2, value)) {
- if (!store_default.flowdata[r2][c2].ps.isshow) {
- $("#" + id).remove();
- }
- return;
- }
- const previousCell = $.extend(true, {}, store_default.flowdata[r2][c2]);
- $("#" + id).removeClass("luckysheet-postil-show-active");
- $("#" + id).find(".luckysheet-postil-dialog-resize").hide();
- $("#" + id).find(".arrowCanvas").css("z-index", 100);
- $("#" + id).find(".luckysheet-postil-show-main").css("z-index", 100);
- let d = editor_default.deepCopyFlowData(store_default.flowdata);
- let rc = [];
- d[r2][c2].ps.value = value;
- rc.push(r2 + "_" + c2);
- this.ref(d, rc);
- if (!d[r2][c2].ps.isshow) {
- $("#" + id).remove();
- }
- setTimeout(() => {
- method_default.createHookFunction("commentUpdateAfter", r2, c2, previousCell, d[r2][c2]);
- }, 0);
- }
- },
- ref: function(data, rc) {
- if (store_default.clearjfundo) {
- store_default.jfundo.length = 0;
- store_default.jfredo.push({
- "type": "postil",
- "data": store_default.flowdata,
- "curdata": data,
- "sheetIndex": store_default.currentSheetIndex,
- "rc": rc
- });
- }
- store_default.flowdata = data;
- editor_default.webWorkerFlowDataCache(store_default.flowdata);
- store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)].data = store_default.flowdata;
- if (server_default.allowUpdate) {
- for (let i2 = 0; i2 < rc.length; i2++) {
- let r2 = rc[i2].split("_")[0];
- let c2 = rc[i2].split("_")[1];
- server_default.saveParam("v", store_default.currentSheetIndex, store_default.flowdata[r2][c2], {"r": r2, "c": c2});
- }
- }
- setTimeout(function() {
- luckysheetrefreshgrid();
- }, 1);
- },
- positionSync: function() {
- let _this2 = this;
- $("#luckysheet-postil-showBoxs .luckysheet-postil-show").each(function(i2, e) {
- let id = $(e).attr("id");
- let r2 = id.split("luckysheet-postil-show_")[1].split("_")[0];
- let c2 = id.split("luckysheet-postil-show_")[1].split("_")[1];
- let cell = store_default.flowdata[r2][c2];
- if (cell != null && cell.ps != null) {
- _this2.buildPs(r2, c2, cell.ps);
- } else {
- $("#" + id).hide();
- }
- });
- },
- htmlEscape: function(text) {
- return text.replace(/[<>"&]/g, function(match, pos, originalText) {
- console.log(match, pos, originalText);
- switch (match) {
- case "<": {
- return "<";
- }
- case ">": {
- return ">";
- }
- case "&": {
- return "&";
- }
- case '"': {
- return """;
- }
- }
- });
- }
- };
- postil_default = luckysheetPostil;
- }
- });
-
- // src/global/border.js
- function getBorderInfoComputeRange(dataset_row_st, dataset_row_ed, dataset_col_st, dataset_col_ed, sheetIndex) {
- let borderInfoCompute = {};
- let cfg, data;
- if (sheetIndex == null) {
- cfg = store_default.config;
- data = store_default.flowdata;
- } else {
- cfg = store_default.luckysheetfile[getSheetIndex(sheetIndex)].config;
- data = store_default.luckysheetfile[getSheetIndex(sheetIndex)].data;
- }
- let borderInfo = cfg["borderInfo"];
- if (borderInfo != null && borderInfo.length > 0) {
- for (let i2 = 0; i2 < borderInfo.length; i2++) {
- let rangeType = borderInfo[i2].rangeType;
- if (rangeType == "range") {
- let borderType = borderInfo[i2].borderType;
- let borderColor = borderInfo[i2].color;
- let borderStyle = borderInfo[i2].style;
- let borderRange = borderInfo[i2].range;
- for (let j = 0; j < borderRange.length; j++) {
- let bd_r1 = borderRange[j].row[0], bd_r2 = borderRange[j].row[1];
- let bd_c1 = borderRange[j].column[0], bd_c2 = borderRange[j].column[1];
- if (bd_r1 < dataset_row_st) {
- bd_r1 = dataset_row_st;
- }
- if (bd_r2 > dataset_row_ed) {
- bd_r2 = dataset_row_ed;
- }
- if (bd_c1 < dataset_col_st) {
- bd_c1 = dataset_col_st;
- }
- if (bd_c2 > dataset_col_ed) {
- bd_c2 = dataset_col_ed;
- }
- if (borderType == "border-left") {
- for (let bd_r = bd_r1; bd_r <= bd_r2; bd_r++) {
- if (cfg["rowhidden"] != null && cfg["rowhidden"][bd_r] != null) {
- continue;
- }
- if (borderInfoCompute[bd_r + "_" + bd_c1] == null) {
- borderInfoCompute[bd_r + "_" + bd_c1] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c1].l = {"color": borderColor, "style": borderStyle};
- let bd_c_left = bd_c1 - 1;
- if (bd_c_left >= 0 && borderInfoCompute[bd_r + "_" + bd_c_left]) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c_left]) == "object" && data[bd_r][bd_c_left].mc != null) {
- let cell_left = data[bd_r][bd_c_left];
- let mc2 = cfg["merge"][cell_left.mc.r + "_" + cell_left.mc.c];
- if (mc2.c + mc2.cs - 1 == bd_c_left) {
- borderInfoCompute[bd_r + "_" + bd_c_left].r = {"color": borderColor, "style": borderStyle};
- }
- } else {
- borderInfoCompute[bd_r + "_" + bd_c_left].r = {"color": borderColor, "style": borderStyle};
- }
- }
- let mc = cfg["merge"] || {};
- for (const key in mc) {
- let {c: c2, r: r2, cs, rs} = mc[key];
- if (bd_c1 <= c2 + cs - 1 && bd_c1 > c2 && bd_r >= r2 && bd_r <= r2 + rs - 1) {
- borderInfoCompute[bd_r + "_" + bd_c1].l = null;
- }
- }
- }
- } else if (borderType == "border-right") {
- for (let bd_r = bd_r1; bd_r <= bd_r2; bd_r++) {
- if (cfg["rowhidden"] != null && cfg["rowhidden"][bd_r] != null) {
- continue;
- }
- if (borderInfoCompute[bd_r + "_" + bd_c2] == null) {
- borderInfoCompute[bd_r + "_" + bd_c2] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c2].r = {"color": borderColor, "style": borderStyle};
- let bd_c_right = bd_c2 + 1;
- if (bd_c_right < data[0].length && borderInfoCompute[bd_r + "_" + bd_c_right]) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c_right]) == "object" && data[bd_r][bd_c_right].mc != null) {
- let cell_right = data[bd_r][bd_c_right];
- let mc2 = cfg["merge"][cell_right.mc.r + "_" + cell_right.mc.c];
- if (mc2.c == bd_c_right) {
- borderInfoCompute[bd_r + "_" + bd_c_right].l = {"color": borderColor, "style": borderStyle};
- }
- } else {
- borderInfoCompute[bd_r + "_" + bd_c_right].l = {"color": borderColor, "style": borderStyle};
- }
- }
- let mc = cfg["merge"] || {};
- for (const key in mc) {
- let {c: c2, r: r2, cs, rs} = mc[key];
- if (bd_c2 < c2 + cs - 1 && bd_c2 >= c2 && bd_r >= r2 && bd_r <= r2 + rs - 1) {
- borderInfoCompute[bd_r + "_" + bd_c2].r = null;
- }
- }
- }
- } else if (borderType == "border-top") {
- if (cfg["rowhidden"] != null && cfg["rowhidden"][bd_r1] != null) {
- continue;
- }
- for (let bd_c = bd_c1; bd_c <= bd_c2; bd_c++) {
- if (borderInfoCompute[bd_r1 + "_" + bd_c] == null) {
- borderInfoCompute[bd_r1 + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r1 + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- let bd_r_top = bd_r1 - 1;
- if (bd_r_top >= 0 && borderInfoCompute[bd_r_top + "_" + bd_c]) {
- if (data[bd_r_top] != null && getObjType(data[bd_r_top][bd_c]) == "object" && data[bd_r_top][bd_c].mc != null) {
- let cell_top = data[bd_r_top][bd_c];
- let mc2 = cfg["merge"][cell_top.mc.r + "_" + cell_top.mc.c];
- if (mc2.r + mc2.rs - 1 == bd_r_top) {
- borderInfoCompute[bd_r_top + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- } else {
- borderInfoCompute[bd_r_top + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- }
- let mc = cfg["merge"] || {};
- for (const key in mc) {
- let {c: c2, r: r2, cs, rs} = mc[key];
- if (bd_r1 <= r2 + rs - 1 && bd_r1 > r2 && bd_c >= c2 && bd_c <= c2 + cs - 1) {
- borderInfoCompute[bd_r1 + "_" + bd_c].t = null;
- }
- }
- }
- } else if (borderType == "border-bottom") {
- if (cfg["rowhidden"] != null && cfg["rowhidden"][bd_r2] != null) {
- continue;
- }
- for (let bd_c = bd_c1; bd_c <= bd_c2; bd_c++) {
- if (borderInfoCompute[bd_r2 + "_" + bd_c] == null) {
- borderInfoCompute[bd_r2 + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r2 + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- let bd_r_bottom = bd_r2 + 1;
- if (bd_r_bottom < data.length && borderInfoCompute[bd_r_bottom + "_" + bd_c]) {
- if (data[bd_r_bottom] != null && getObjType(data[bd_r_bottom][bd_c]) == "object" && data[bd_r_bottom][bd_c].mc != null) {
- let cell_bottom = data[bd_r_bottom][bd_c];
- let mc2 = cfg["merge"][cell_bottom.mc.r + "_" + cell_bottom.mc.c];
- if (mc2.r == bd_r_bottom) {
- borderInfoCompute[bd_r_bottom + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- }
- } else {
- borderInfoCompute[bd_r_bottom + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- }
- }
- let mc = cfg["merge"] || {};
- for (const key in mc) {
- let {c: c2, r: r2, cs, rs} = mc[key];
- if (bd_r2 < r2 + rs - 1 && bd_r2 >= r2 && bd_c >= c2 && bd_c <= c2 + cs - 1) {
- borderInfoCompute[bd_r2 + "_" + bd_c].b = null;
- }
- }
- }
- } else if (borderType == "border-all") {
- for (let bd_r = bd_r1; bd_r <= bd_r2; bd_r++) {
- if (cfg["rowhidden"] != null && cfg["rowhidden"][bd_r] != null) {
- continue;
- }
- for (let bd_c = bd_c1; bd_c <= bd_c2; bd_c++) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c]) == "object" && data[bd_r][bd_c].mc != null) {
- let cell = data[bd_r][bd_c];
- let mc = cfg["merge"][cell.mc.r + "_" + cell.mc.c];
- if (mc.r == bd_r) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- }
- if (mc.r + mc.rs - 1 == bd_r) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- if (mc.c == bd_c) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].l = {"color": borderColor, "style": borderStyle};
- }
- if (mc.c + mc.cs - 1 == bd_c) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].r = {"color": borderColor, "style": borderStyle};
- }
- } else {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].l = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].r = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- if (bd_r == bd_r1) {
- let bd_r_top = bd_r1 - 1;
- if (bd_r_top >= 0 && borderInfoCompute[bd_r_top + "_" + bd_c]) {
- if (data[bd_r_top] != null && getObjType(data[bd_r_top][bd_c]) == "object" && data[bd_r_top][bd_c].mc != null) {
- let cell_top = data[bd_r_top][bd_c];
- let mc = cfg["merge"][cell_top.mc.r + "_" + cell_top.mc.c];
- if (mc.r + mc.rs - 1 == bd_r_top) {
- borderInfoCompute[bd_r_top + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- } else {
- borderInfoCompute[bd_r_top + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- }
- }
- if (bd_r == bd_r2) {
- let bd_r_bottom = bd_r2 + 1;
- if (bd_r_bottom < data.length && borderInfoCompute[bd_r_bottom + "_" + bd_c]) {
- if (data[bd_r_bottom] != null && getObjType(data[bd_r_bottom][bd_c]) == "object" && data[bd_r_bottom][bd_c].mc != null) {
- let cell_bottom = data[bd_r_bottom][bd_c];
- let mc = cfg["merge"][cell_bottom.mc.r + "_" + cell_bottom.mc.c];
- if (mc.r == bd_r_bottom) {
- borderInfoCompute[bd_r_bottom + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- }
- } else {
- borderInfoCompute[bd_r_bottom + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- }
- }
- }
- if (bd_c == bd_c1) {
- let bd_c_left = bd_c1 - 1;
- if (bd_c_left >= 0 && borderInfoCompute[bd_r + "_" + bd_c_left]) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c_left]) == "object" && data[bd_r][bd_c_left].mc != null) {
- let cell_left = data[bd_r][bd_c_left];
- let mc = cfg["merge"][cell_left.mc.r + "_" + cell_left.mc.c];
- if (mc.c + mc.cs - 1 == bd_c_left) {
- borderInfoCompute[bd_r + "_" + bd_c_left].r = {"color": borderColor, "style": borderStyle};
- }
- } else {
- borderInfoCompute[bd_r + "_" + bd_c_left].r = {"color": borderColor, "style": borderStyle};
- }
- }
- }
- if (bd_c == bd_c2) {
- let bd_c_right = bd_c2 + 1;
- if (bd_c_right < data[0].length && borderInfoCompute[bd_r + "_" + bd_c_right]) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c_right]) == "object" && data[bd_r][bd_c_right].mc != null) {
- let cell_right = data[bd_r][bd_c_right];
- let mc = cfg["merge"][cell_right.mc.r + "_" + cell_right.mc.c];
- if (mc.c == bd_c_right) {
- borderInfoCompute[bd_r + "_" + bd_c_right].l = {"color": borderColor, "style": borderStyle};
- }
- } else {
- borderInfoCompute[bd_r + "_" + bd_c_right].l = {"color": borderColor, "style": borderStyle};
- }
- }
- }
- }
- }
- } else if (borderType == "border-outside") {
- for (let bd_r = bd_r1; bd_r <= bd_r2; bd_r++) {
- if (cfg["rowhidden"] != null && cfg["rowhidden"][bd_r] != null) {
- continue;
- }
- for (let bd_c = bd_c1; bd_c <= bd_c2; bd_c++) {
- if (!(bd_r == bd_r1 || bd_r == bd_r2 || bd_c == bd_c1 || bd_c == bd_c2)) {
- continue;
- }
- if (bd_r == bd_r1) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- let bd_r_top = bd_r1 - 1;
- if (bd_r_top >= 0 && borderInfoCompute[bd_r_top + "_" + bd_c]) {
- if (data[bd_r_top] != null && getObjType(data[bd_r_top][bd_c]) == "object" && data[bd_r_top][bd_c].mc != null) {
- let cell_top = data[bd_r_top][bd_c];
- let mc = cfg["merge"][cell_top.mc.r + "_" + cell_top.mc.c];
- if (mc.r + mc.rs - 1 == bd_r_top) {
- borderInfoCompute[bd_r_top + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- } else {
- borderInfoCompute[bd_r_top + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- }
- }
- if (bd_r == bd_r2) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- let bd_r_bottom = bd_r2 + 1;
- if (bd_r_bottom < data.length && borderInfoCompute[bd_r_bottom + "_" + bd_c]) {
- if (data[bd_r_bottom] != null && getObjType(data[bd_r_bottom][bd_c]) == "object" && data[bd_r_bottom][bd_c].mc != null) {
- let cell_bottom = data[bd_r_bottom][bd_c];
- let mc = cfg["merge"][cell_bottom.mc.r + "_" + cell_bottom.mc.c];
- if (mc.r == bd_r_bottom) {
- borderInfoCompute[bd_r_bottom + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- }
- } else {
- borderInfoCompute[bd_r_bottom + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- }
- }
- }
- if (bd_c == bd_c1) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].l = {"color": borderColor, "style": borderStyle};
- let bd_c_left = bd_c1 - 1;
- if (bd_c_left >= 0 && borderInfoCompute[bd_r + "_" + bd_c_left]) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c_left]) == "object" && data[bd_r][bd_c_left].mc != null) {
- let cell_left = data[bd_r][bd_c_left];
- let mc = cfg["merge"][cell_left.mc.r + "_" + cell_left.mc.c];
- if (mc.c + mc.cs - 1 == bd_c_left) {
- borderInfoCompute[bd_r + "_" + bd_c_left].r = {"color": borderColor, "style": borderStyle};
- }
- } else {
- borderInfoCompute[bd_r + "_" + bd_c_left].r = {"color": borderColor, "style": borderStyle};
- }
- }
- }
- if (bd_c == bd_c2) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].r = {"color": borderColor, "style": borderStyle};
- let bd_c_right = bd_c2 + 1;
- if (bd_c_right < data[0].length && borderInfoCompute[bd_r + "_" + bd_c_right]) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c_right]) == "object" && data[bd_r][bd_c_right].mc != null) {
- let cell_right = data[bd_r][bd_c_right];
- let mc = cfg["merge"][cell_right.mc.r + "_" + cell_right.mc.c];
- if (mc.c == bd_c_right) {
- borderInfoCompute[bd_r + "_" + bd_c_right].l = {"color": borderColor, "style": borderStyle};
- }
- } else {
- borderInfoCompute[bd_r + "_" + bd_c_right].l = {"color": borderColor, "style": borderStyle};
- }
- }
- }
- }
- }
- } else if (borderType == "border-inside") {
- for (let bd_r = bd_r1; bd_r <= bd_r2; bd_r++) {
- if (cfg["rowhidden"] != null && cfg["rowhidden"][bd_r] != null) {
- continue;
- }
- for (let bd_c = bd_c1; bd_c <= bd_c2; bd_c++) {
- if (bd_r == bd_r1 && bd_c == bd_c1) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c]) == "object" && data[bd_r][bd_c].mc != null) {
- } else {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].r = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- } else if (bd_r == bd_r2 && bd_c == bd_c1) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c]) == "object" && data[bd_r][bd_c].mc != null) {
- } else {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].r = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- }
- } else if (bd_r == bd_r1 && bd_c == bd_c2) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c]) == "object" && data[bd_r][bd_c].mc != null) {
- } else {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].l = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- } else if (bd_r == bd_r2 && bd_c == bd_c2) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c]) == "object" && data[bd_r][bd_c].mc != null) {
- } else {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].l = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- }
- } else if (bd_r == bd_r1) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c]) == "object" && data[bd_r][bd_c].mc != null) {
- let cell = data[bd_r][bd_c];
- let mc = cfg["merge"][cell.mc.r + "_" + cell.mc.c];
- if (mc.c == bd_c) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].l = {"color": borderColor, "style": borderStyle};
- } else if (mc.c + mc.cs - 1 == bd_c) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].r = {"color": borderColor, "style": borderStyle};
- }
- } else {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].l = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].r = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- } else if (bd_r == bd_r2) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c]) == "object" && data[bd_r][bd_c].mc != null) {
- let cell = data[bd_r][bd_c];
- let mc = cfg["merge"][cell.mc.r + "_" + cell.mc.c];
- if (mc.c == bd_c) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].l = {"color": borderColor, "style": borderStyle};
- } else if (mc.c + mc.cs - 1 == bd_c) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].r = {"color": borderColor, "style": borderStyle};
- }
- } else {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].l = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].r = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- }
- } else if (bd_c == bd_c1) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c]) == "object" && data[bd_r][bd_c].mc != null) {
- let cell = data[bd_r][bd_c];
- let mc = cfg["merge"][cell.mc.r + "_" + cell.mc.c];
- if (mc.r == bd_r) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- } else if (mc.r + mc.rs - 1 == bd_r) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- } else {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].r = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- } else if (bd_c == bd_c2) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c]) == "object" && data[bd_r][bd_c].mc != null) {
- let cell = data[bd_r][bd_c];
- let mc = cfg["merge"][cell.mc.r + "_" + cell.mc.c];
- if (mc.r == bd_r) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- } else if (mc.r + mc.rs - 1 == bd_r) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- } else {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].l = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- } else {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c]) == "object" && data[bd_r][bd_c].mc != null) {
- let cell = data[bd_r][bd_c];
- let mc = cfg["merge"][cell.mc.r + "_" + cell.mc.c];
- if (mc.r == bd_r) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- } else if (mc.r + mc.rs - 1 == bd_r) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- if (mc.c == bd_c) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].l = {"color": borderColor, "style": borderStyle};
- } else if (mc.c + mc.cs - 1 == bd_c) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].r = {"color": borderColor, "style": borderStyle};
- }
- } else {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].l = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].r = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- }
- }
- }
- } else if (borderType == "border-horizontal") {
- for (let bd_r = bd_r1; bd_r <= bd_r2; bd_r++) {
- if (cfg["rowhidden"] != null && cfg["rowhidden"][bd_r] != null) {
- continue;
- }
- for (let bd_c = bd_c1; bd_c <= bd_c2; bd_c++) {
- if (bd_r == bd_r1) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c]) == "object" && data[bd_r][bd_c].mc != null) {
- } else {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- } else if (bd_r == bd_r2) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c]) == "object" && data[bd_r][bd_c].mc != null) {
- } else {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- }
- } else {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c]) == "object" && data[bd_r][bd_c].mc != null) {
- let cell = data[bd_r][bd_c];
- let mc = cfg["merge"][cell.mc.r + "_" + cell.mc.c];
- if (mc.r == bd_r) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- } else if (mc.r + mc.rs - 1 == bd_r) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- } else {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].t = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].b = {"color": borderColor, "style": borderStyle};
- }
- }
- }
- }
- } else if (borderType == "border-vertical") {
- for (let bd_r = bd_r1; bd_r <= bd_r2; bd_r++) {
- if (cfg["rowhidden"] != null && cfg["rowhidden"][bd_r] != null) {
- continue;
- }
- for (let bd_c = bd_c1; bd_c <= bd_c2; bd_c++) {
- if (bd_c == bd_c1) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c]) == "object" && data[bd_r][bd_c].mc != null) {
- } else {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].r = {"color": borderColor, "style": borderStyle};
- }
- } else if (bd_c == bd_c2) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c]) == "object" && data[bd_r][bd_c].mc != null) {
- } else {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].l = {"color": borderColor, "style": borderStyle};
- }
- } else {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c]) == "object" && data[bd_r][bd_c].mc != null) {
- let cell = data[bd_r][bd_c];
- let mc = cfg["merge"][cell.mc.r + "_" + cell.mc.c] || {};
- if (mc.c == bd_c) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].l = {"color": borderColor, "style": borderStyle};
- } else if (mc.c + mc.cs - 1 == bd_c) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].r = {"color": borderColor, "style": borderStyle};
- }
- } else {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- borderInfoCompute[bd_r + "_" + bd_c].l = {"color": borderColor, "style": borderStyle};
- borderInfoCompute[bd_r + "_" + bd_c].r = {"color": borderColor, "style": borderStyle};
- }
- }
- }
- }
- } else if (borderType == "border-none") {
- for (let bd_r = bd_r1; bd_r <= bd_r2; bd_r++) {
- if (cfg["rowhidden"] != null && cfg["rowhidden"][bd_r] != null) {
- continue;
- }
- for (let bd_c = bd_c1; bd_c <= bd_c2; bd_c++) {
- if (borderInfoCompute[bd_r + "_" + bd_c] != null) {
- delete borderInfoCompute[bd_r + "_" + bd_c];
- }
- if (bd_r == bd_r1) {
- let bd_r_top = bd_r1 - 1;
- if (bd_r_top >= 0 && borderInfoCompute[bd_r_top + "_" + bd_c]) {
- delete borderInfoCompute[bd_r_top + "_" + bd_c].b;
- }
- }
- if (bd_r == bd_r2) {
- let bd_r_bottom = bd_r2 + 1;
- if (bd_r_bottom < data.length && borderInfoCompute[bd_r_bottom + "_" + bd_c]) {
- delete borderInfoCompute[bd_r_bottom + "_" + bd_c].t;
- }
- }
- if (bd_c == bd_c1) {
- let bd_c_left = bd_c1 - 1;
- if (bd_c_left >= 0 && borderInfoCompute[bd_r + "_" + bd_c_left]) {
- delete borderInfoCompute[bd_r + "_" + bd_c_left].r;
- }
- }
- if (bd_c == bd_c2) {
- let bd_c_right = bd_c2 + 1;
- if (bd_c_right < data[0].length && borderInfoCompute[bd_r + "_" + bd_c_right]) {
- delete borderInfoCompute[bd_r + "_" + bd_c_right].l;
- }
- }
- }
- }
- }
- }
- } else if (rangeType == "cell") {
- let value = borderInfo[i2].value;
- let bd_r = value.row_index, bd_c = value.col_index;
- if (bd_r < dataset_row_st || bd_r > dataset_row_ed || bd_c < dataset_col_st || bd_c > dataset_col_ed) {
- continue;
- }
- if (cfg["rowhidden"] != null && cfg["rowhidden"][bd_r] != null) {
- continue;
- }
- if (value.l != null || value.r != null || value.t != null || value.b != null) {
- if (borderInfoCompute[bd_r + "_" + bd_c] == null) {
- borderInfoCompute[bd_r + "_" + bd_c] = {};
- }
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c]) == "object" && data[bd_r][bd_c].mc != null) {
- let cell = data[bd_r][bd_c];
- let mc = cfg["merge"][cell.mc.r + "_" + cell.mc.c] || {};
- if (value.l != null && bd_c == mc.c) {
- borderInfoCompute[bd_r + "_" + bd_c].l = {"color": value.l.color, "style": value.l.style};
- let bd_c_left = bd_c - 1;
- if (bd_c_left >= 0 && borderInfoCompute[bd_r + "_" + bd_c_left]) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c_left]) == "object" && data[bd_r][bd_c_left].mc != null) {
- let cell_left = data[bd_r][bd_c_left];
- let mc_l = cfg["merge"][cell_left.mc.r + "_" + cell_left.mc.c];
- if (mc_l.c + mc_l.cs - 1 == bd_c_left) {
- borderInfoCompute[bd_r + "_" + bd_c_left].r = {"color": value.l.color, "style": value.l.style};
- }
- } else {
- borderInfoCompute[bd_r + "_" + bd_c_left].r = {"color": value.l.color, "style": value.l.style};
- }
- }
- } else {
- borderInfoCompute[bd_r + "_" + bd_c].l = null;
- }
- if (value.r != null && bd_c == mc.c + mc.cs - 1) {
- borderInfoCompute[bd_r + "_" + bd_c].r = {"color": value.r.color, "style": value.r.style};
- let bd_c_right = bd_c + 1;
- if (bd_c_right < data[0].length && borderInfoCompute[bd_r + "_" + bd_c_right]) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c_right]) == "object" && data[bd_r][bd_c_right].mc != null) {
- let cell_right = data[bd_r][bd_c_right];
- let mc_r = cfg["merge"][cell_right.mc.r + "_" + cell_right.mc.c];
- if (mc_r.c == bd_c_right) {
- borderInfoCompute[bd_r + "_" + bd_c_right].l = {"color": value.r.color, "style": value.r.style};
- }
- } else {
- borderInfoCompute[bd_r + "_" + bd_c_right].l = {"color": value.r.color, "style": value.r.style};
- }
- }
- } else {
- borderInfoCompute[bd_r + "_" + bd_c].r = null;
- }
- if (value.t != null && bd_r == mc.r) {
- borderInfoCompute[bd_r + "_" + bd_c].t = {"color": value.t.color, "style": value.t.style};
- let bd_r_top = bd_r - 1;
- if (bd_r_top >= 0 && borderInfoCompute[bd_r_top + "_" + bd_c]) {
- if (data[bd_r_top] != null && getObjType(data[bd_r_top][bd_c]) == "object" && data[bd_r_top][bd_c].mc != null) {
- let cell_top = data[bd_r_top][bd_c];
- let mc_t = cfg["merge"][cell_top.mc.r + "_" + cell_top.mc.c];
- if (mc_t.r + mc_t.rs - 1 == bd_r_top) {
- borderInfoCompute[bd_r_top + "_" + bd_c].b = {"color": value.t.color, "style": value.t.style};
- }
- } else {
- borderInfoCompute[bd_r_top + "_" + bd_c].b = {"color": value.t.color, "style": value.t.style};
- }
- }
- } else {
- borderInfoCompute[bd_r + "_" + bd_c].t = null;
- }
- if (value.b != null && bd_r == mc.r + mc.rs - 1) {
- borderInfoCompute[bd_r + "_" + bd_c].b = {"color": value.b.color, "style": value.b.style};
- let bd_r_bottom = bd_r + 1;
- if (bd_r_bottom < data.length && borderInfoCompute[bd_r_bottom + "_" + bd_c]) {
- if (data[bd_r_bottom] != null && getObjType(data[bd_r_bottom][bd_c]) == "object" && data[bd_r_bottom][bd_c].mc != null) {
- let cell_bottom = data[bd_r_bottom][bd_c];
- let mc_b = cfg["merge"][cell_bottom.mc.r + "_" + cell_bottom.mc.c];
- if (mc_b.r == bd_r_bottom) {
- borderInfoCompute[bd_r_bottom + "_" + bd_c].t = {"color": value.b.color, "style": value.b.style};
- }
- } else {
- borderInfoCompute[bd_r_bottom + "_" + bd_c].t = {"color": value.b.color, "style": value.b.style};
- }
- }
- } else {
- borderInfoCompute[bd_r + "_" + bd_c].b = null;
- }
- } else {
- if (value.l != null) {
- borderInfoCompute[bd_r + "_" + bd_c].l = {"color": value.l.color, "style": value.l.style};
- let bd_c_left = bd_c - 1;
- if (bd_c_left >= 0 && borderInfoCompute[bd_r + "_" + bd_c_left]) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c_left]) == "object" && data[bd_r][bd_c_left].mc != null) {
- let cell_left = data[bd_r][bd_c_left];
- let mc_l = cfg["merge"][cell_left.mc.r + "_" + cell_left.mc.c];
- if (mc_l.c + mc_l.cs - 1 == bd_c_left) {
- borderInfoCompute[bd_r + "_" + bd_c_left].r = {"color": value.l.color, "style": value.l.style};
- }
- } else {
- borderInfoCompute[bd_r + "_" + bd_c_left].r = {"color": value.l.color, "style": value.l.style};
- }
- }
- } else {
- borderInfoCompute[bd_r + "_" + bd_c].l = null;
- }
- if (value.r != null) {
- borderInfoCompute[bd_r + "_" + bd_c].r = {"color": value.r.color, "style": value.r.style};
- let bd_c_right = bd_c + 1;
- if (bd_c_right < data[0].length && borderInfoCompute[bd_r + "_" + bd_c_right]) {
- if (data[bd_r] != null && getObjType(data[bd_r][bd_c_right]) == "object" && data[bd_r][bd_c_right].mc != null) {
- let cell_right = data[bd_r][bd_c_right];
- let mc_r = cfg["merge"][cell_right.mc.r + "_" + cell_right.mc.c];
- if (mc_r.c == bd_c_right) {
- borderInfoCompute[bd_r + "_" + bd_c_right].l = {"color": value.r.color, "style": value.r.style};
- }
- } else {
- borderInfoCompute[bd_r + "_" + bd_c_right].l = {"color": value.r.color, "style": value.r.style};
- }
- }
- } else {
- borderInfoCompute[bd_r + "_" + bd_c].r = null;
- }
- if (value.t != null) {
- borderInfoCompute[bd_r + "_" + bd_c].t = {"color": value.t.color, "style": value.t.style};
- let bd_r_top = bd_r - 1;
- if (bd_r_top >= 0 && borderInfoCompute[bd_r_top + "_" + bd_c]) {
- if (data[bd_r_top] != null && getObjType(data[bd_r_top][bd_c]) == "object" && data[bd_r_top][bd_c].mc != null) {
- let cell_top = data[bd_r_top][bd_c];
- let mc_t = cfg["merge"][cell_top.mc.r + "_" + cell_top.mc.c];
- if (mc_t.r + mc_t.rs - 1 == bd_r_top) {
- borderInfoCompute[bd_r_top + "_" + bd_c].b = {"color": value.t.color, "style": value.t.style};
- }
- } else {
- borderInfoCompute[bd_r_top + "_" + bd_c].b = {"color": value.t.color, "style": value.t.style};
- }
- }
- } else {
- borderInfoCompute[bd_r + "_" + bd_c].t = null;
- }
- if (value.b != null) {
- borderInfoCompute[bd_r + "_" + bd_c].b = {"color": value.b.color, "style": value.b.style};
- let bd_r_bottom = bd_r + 1;
- if (bd_r_bottom < data.length && borderInfoCompute[bd_r_bottom + "_" + bd_c]) {
- if (data[bd_r_bottom] != null && getObjType(data[bd_r_bottom][bd_c]) == "object" && data[bd_r_bottom][bd_c].mc != null) {
- let cell_bottom = data[bd_r_bottom][bd_c];
- let mc_b = cfg["merge"][cell_bottom.mc.r + "_" + cell_bottom.mc.c];
- if (mc_b.r == bd_r_bottom) {
- borderInfoCompute[bd_r_bottom + "_" + bd_c].t = {"color": value.b.color, "style": value.b.style};
- }
- } else {
- borderInfoCompute[bd_r_bottom + "_" + bd_c].t = {"color": value.b.color, "style": value.b.style};
- }
- }
- } else {
- borderInfoCompute[bd_r + "_" + bd_c].b = null;
- }
- }
- } else {
- delete borderInfoCompute[bd_r + "_" + bd_c];
- }
- }
- }
- }
- return borderInfoCompute;
- }
- function getBorderInfoCompute(sheetIndex) {
- let borderInfoCompute = {};
- let cfg, data;
- if (sheetIndex == null) {
- cfg = store_default.config;
- data = store_default.flowdata;
- } else {
- cfg = store_default.luckysheetfile[getSheetIndex(sheetIndex)].config;
- data = store_default.luckysheetfile[getSheetIndex(sheetIndex)].data;
- }
- borderInfoCompute = getBorderInfoComputeRange(0, data.length, 0, data[0].length, sheetIndex);
- return borderInfoCompute;
- }
- var init_border = __esm({
- "src/global/border.js"() {
- init_get();
- init_util();
- init_store();
- }
- });
-
- // src/controllers/dropCell.js
- var import_dayjs2, luckysheetDropCell, dropCell_default;
- var init_dropCell = __esm({
- "src/controllers/dropCell.js"() {
- init_location();
- init_count();
- init_border();
- init_validate();
- init_format();
- init_refresh();
- init_editor();
- init_formula();
- init_conditionformat();
- init_protection();
- init_select();
- init_get();
- init_util();
- init_store();
- init_locale();
- import_dayjs2 = __toModule(require_dayjs_min());
- luckysheetDropCell = {
- iconHtml: '
',
- typeListHtml: '',
- copyRange: {},
- applyRange: {},
- applyType: null,
- direction: null,
- chnNumChar: {"\u96F6": 0, "\u4E00": 1, "\u4E8C": 2, "\u4E09": 3, "\u56DB": 4, "\u4E94": 5, "\u516D": 6, "\u4E03": 7, "\u516B": 8, "\u4E5D": 9},
- chnNameValue: {
- "\u5341": {value: 10, secUnit: false},
- "\u767E": {value: 100, secUnit: false},
- "\u5343": {value: 1e3, secUnit: false},
- "\u4E07": {value: 1e4, secUnit: true},
- "\u4EBF": {value: 1e8, secUnit: true}
- },
- ChineseToNumber: function(chnStr) {
- let _this2 = this;
- let rtn = 0;
- let section = 0;
- let number = 0;
- let secUnit = false;
- let str = chnStr.split("");
- for (let i2 = 0; i2 < str.length; i2++) {
- let num = _this2.chnNumChar[str[i2]];
- if (typeof num != "undefined") {
- number = num;
- if (i2 == str.length - 1) {
- section += number;
- }
- } else {
- let unit = _this2.chnNameValue[str[i2]].value;
- secUnit = _this2.chnNameValue[str[i2]].secUnit;
- if (secUnit) {
- section = (section + number) * unit;
- rtn += section;
- section = 0;
- } else {
- section += number * unit;
- }
- number = 0;
- }
- }
- return rtn + section;
- },
- chnNumChar2: ["\u96F6", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D", "\u4E03", "\u516B", "\u4E5D"],
- chnUnitSection: ["", "\u4E07", "\u4EBF", "\u4E07\u4EBF", "\u4EBF\u4EBF"],
- chnUnitChar: ["", "\u5341", "\u767E", "\u5343"],
- SectionToChinese: function(section) {
- let _this2 = this;
- let strIns = "", chnStr = "";
- let unitPos = 0;
- let zero = true;
- while (section > 0) {
- let v = section % 10;
- if (v == 0) {
- if (!zero) {
- zero = true;
- chnStr = _this2.chnNumChar2[v] + chnStr;
- }
- } else {
- zero = false;
- strIns = _this2.chnNumChar2[v];
- strIns += _this2.chnUnitChar[unitPos];
- chnStr = strIns + chnStr;
- }
- unitPos++;
- section = Math.floor(section / 10);
- }
- return chnStr;
- },
- NumberToChinese: function(num) {
- let _this2 = this;
- let unitPos = 0;
- let strIns = "", chnStr = "";
- let needZero = false;
- if (num == 0) {
- return _this2.chnNumChar2[0];
- }
- while (num > 0) {
- let section = num % 1e4;
- if (needZero) {
- chnStr = _this2.chnNumChar2[0] + chnStr;
- }
- strIns = _this2.SectionToChinese(section);
- strIns += section != 0 ? _this2.chnUnitSection[unitPos] : _this2.chnUnitSection[0];
- chnStr = strIns + chnStr;
- needZero = section < 1e3 && section > 0;
- num = Math.floor(num / 1e4);
- unitPos++;
- }
- return chnStr;
- },
- isChnNumber: function(txt) {
- let _this2 = this;
- let isChnNumber = true;
- if (txt) {
- if (txt.length == 1) {
- if (txt == "\u65E5" || txt in _this2.chnNumChar) {
- isChnNumber = true;
- } else {
- isChnNumber = false;
- }
- } else {
- let str = txt.split("");
- for (let i2 = 0; i2 < str.length; i2++) {
- if (!(str[i2] in _this2.chnNumChar || str[i2] in _this2.chnNameValue)) {
- isChnNumber = false;
- break;
- }
- }
- }
- }
- return isChnNumber;
- },
- isExtendNumber: function(txt) {
- let reg = /0|([1-9]+[0-9]*)/g;
- let isExtendNumber = reg.test(txt);
- if (isExtendNumber) {
- let match = txt.match(reg);
- let matchTxt = match[match.length - 1];
- let matchIndex = txt.lastIndexOf(matchTxt);
- let beforeTxt = txt.substr(0, matchIndex);
- let afterTxt = txt.substr(matchIndex + matchTxt.length);
- return [isExtendNumber, Number(matchTxt), beforeTxt, afterTxt];
- } else {
- return [isExtendNumber];
- }
- },
- isChnWeek1: function(txt) {
- let _this2 = this;
- let isChnWeek1;
- if (txt.length == 1) {
- if (txt == "\u65E5" || _this2.ChineseToNumber(txt) < 7) {
- isChnWeek1 = true;
- } else {
- isChnWeek1 = false;
- }
- } else {
- isChnWeek1 = false;
- }
- return isChnWeek1;
- },
- isChnWeek2: function(txt) {
- let isChnWeek2;
- if (txt.length == 2) {
- if (txt == "\u5468\u4E00" || txt == "\u5468\u4E8C" || txt == "\u5468\u4E09" || txt == "\u5468\u56DB" || txt == "\u5468\u4E94" || txt == "\u5468\u516D" || txt == "\u5468\u65E5") {
- isChnWeek2 = true;
- } else {
- isChnWeek2 = false;
- }
- } else {
- isChnWeek2 = false;
- }
- return isChnWeek2;
- },
- isChnWeek3: function(txt) {
- let isChnWeek3;
- if (txt.length == 3) {
- if (txt == "\u661F\u671F\u4E00" || txt == "\u661F\u671F\u4E8C" || txt == "\u661F\u671F\u4E09" || txt == "\u661F\u671F\u56DB" || txt == "\u661F\u671F\u4E94" || txt == "\u661F\u671F\u516D" || txt == "\u661F\u671F\u65E5") {
- isChnWeek3 = true;
- } else {
- isChnWeek3 = false;
- }
- } else {
- isChnWeek3 = false;
- }
- return isChnWeek3;
- },
- createIcon: function() {
- let _this2 = this;
- let copy_r = _this2.copyRange["row"][1], copy_c = _this2.copyRange["column"][1];
- let apply_r = _this2.applyRange["row"][1], apply_c = _this2.applyRange["column"][1];
- let row_index, col_index;
- if (apply_r >= copy_r && apply_c >= copy_c) {
- row_index = apply_r;
- col_index = apply_c;
- } else {
- row_index = copy_r;
- col_index = copy_c;
- }
- let row = rowLocationByIndex(row_index)[1], row_pre = rowLocationByIndex(row_index)[0];
- let col = colLocationByIndex(col_index)[1], col_pre = colLocationByIndex(col_index)[0];
- $("#luckysheet-dropCell-icon").remove();
- $("#luckysheet-cell-main").append(_this2.iconHtml);
- $("#luckysheet-dropCell-icon").css({"left": col, "top": row});
- $("#luckysheet-dropCell-icon").mouseover(function() {
- $(this).css("background-color", "#ffe8e8");
- }).mouseleave(function() {
- $(this).css("background-color", "#f1f1f1");
- }).mousedown(function(event2) {
- $("#luckysheet-dropCell-typeList").remove();
- const _locale = locale_default();
- const locale_dropCell = _locale.dropCell;
- $("body").append(replaceHtml(_this2.typeListHtml, {
- copyCell: locale_dropCell.copyCell,
- sequence: locale_dropCell.sequence,
- onlyFormat: locale_dropCell.onlyFormat,
- noFormat: locale_dropCell.noFormat,
- day: locale_dropCell.day,
- workDay: locale_dropCell.workDay,
- month: locale_dropCell.month,
- year: locale_dropCell.year,
- chineseNumber: locale_dropCell.chineseNumber
- }));
- let typeItemHide = _this2.typeItemHide();
- if (!typeItemHide[0] && !typeItemHide[1] && !typeItemHide[2] && !typeItemHide[3] && !typeItemHide[4] && !typeItemHide[5] && !typeItemHide[6]) {
- $("#luckysheet-dropCell-typeList .luckysheet-cols-menuitem[data-type=1]").hide();
- $("#luckysheet-dropCell-typeList .luckysheet-cols-menuitem[data-type=4]").hide();
- $("#luckysheet-dropCell-typeList .luckysheet-cols-menuitem[data-type=5]").hide();
- $("#luckysheet-dropCell-typeList .luckysheet-cols-menuitem[data-type=6]").hide();
- $("#luckysheet-dropCell-typeList .luckysheet-cols-menuitem[data-type=7]").hide();
- $("#luckysheet-dropCell-typeList .luckysheet-cols-menuitem[data-type=8]").hide();
- }
- if (!typeItemHide[2]) {
- $("#luckysheet-dropCell-typeList .luckysheet-cols-menuitem[data-type=4]").hide();
- $("#luckysheet-dropCell-typeList .luckysheet-cols-menuitem[data-type=5]").hide();
- $("#luckysheet-dropCell-typeList .luckysheet-cols-menuitem[data-type=6]").hide();
- $("#luckysheet-dropCell-typeList .luckysheet-cols-menuitem[data-type=7]").hide();
- }
- if (!typeItemHide[3]) {
- $("#luckysheet-dropCell-typeList .luckysheet-cols-menuitem[data-type=8]").hide();
- }
- let left = $(this).offset().left;
- let top = $(this).offset().top + 25;
- let winH = $(window).height(), winW = $(window).width();
- let menuW = $("#luckysheet-dropCell-typeList").width(), menuH = $("#luckysheet-dropCell-typeList").height();
- if (left + menuW > winW) {
- left = left - menuW;
- }
- if (top + menuH > winH) {
- top = top - menuH - 38;
- }
- if (top < 0) {
- top = 0;
- }
- $("#luckysheet-dropCell-typeList").css({"left": left, "top": top}).show();
- $("#luckysheet-dropCell-icon").mouseleave(function() {
- $(this).css("backgroundColor", "#ffe8e8");
- });
- let type = _this2.applyType;
- $("#luckysheet-dropCell-typeList .luckysheet-cols-menuitem[data-type=" + type + "]").find("span").append('
');
- event2.stopPropagation();
- });
- $(document).off("click.dCtypeList").on("click.dCtypeList", "#luckysheet-dropCell-typeList .luckysheet-cols-menuitem", function() {
- $("#luckysheet-dropCell-typeList .fa-check").remove();
- $(this).find("span").append('
');
- let type = $(this).attr("data-type");
- _this2.applyType = type;
- _this2.update();
- $("#luckysheet-dropCell-typeList").hide();
- $("#luckysheet-dropCell-icon").css("backgroundColor", "#f1f1f1");
- $("#luckysheet-dropCell-icon").mouseleave(function() {
- $(this).css("backgroundColor", "#f1f1f1");
- });
- countfunc();
- });
- },
- typeItemHide: function() {
- let _this2 = this;
- let copyRange = _this2.copyRange;
- let str_r = copyRange["row"][0], end_r = copyRange["row"][1];
- let str_c = copyRange["column"][0], end_c = copyRange["column"][1];
- let hasNumber = false, hasExtendNumber = false, hasDate = false, hasChn = false, hasChnWeek1 = false, hasChnWeek2 = false, hasChnWeek3 = false;
- for (let r2 = str_r; r2 <= end_r; r2++) {
- for (let c2 = str_c; c2 <= end_c; c2++) {
- if (!!store_default.flowdata[r2][c2]) {
- let cell = store_default.flowdata[r2][c2];
- if (getObjType(cell) == "object" && cell["v"] != null && cell["f"] == null) {
- if (cell["ct"] != null && cell["ct"].t == "n") {
- hasNumber = true;
- } else if (cell["ct"] != null && cell["ct"].t == "d") {
- hasDate = true;
- } else if (_this2.isExtendNumber(cell["m"])[0]) {
- hasExtendNumber = true;
- } else if (_this2.isChnNumber(cell["m"]) && cell["m"] != "\u65E5") {
- hasChn = true;
- } else if (cell["m"] == "\u65E5") {
- hasChnWeek1 = true;
- } else if (_this2.isChnWeek2(cell["m"])) {
- hasChnWeek2 = true;
- } else if (_this2.isChnWeek3(cell["m"])) {
- hasChnWeek3 = true;
- }
- }
- }
- }
- }
- return [hasNumber, hasExtendNumber, hasDate, hasChn, hasChnWeek1, hasChnWeek2, hasChnWeek3];
- },
- update: function() {
- let _this2 = this;
- if (!checkProtectionLockedRangeList([_this2.applyRange], store_default.currentSheetIndex)) {
- return;
- }
- if (store_default.allowEdit === false) {
- return;
- }
- let d = editor_default.deepCopyFlowData(store_default.flowdata);
- let file = store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)];
- let cfg = $.extend(true, {}, store_default.config);
- let borderInfoCompute = getBorderInfoCompute();
- let dataVerification = $.extend(true, {}, file["dataVerification"]);
- let direction = _this2.direction;
- let type = _this2.applyType;
- let copyRange = _this2.copyRange;
- let copy_str_r = copyRange["row"][0], copy_end_r = copyRange["row"][1];
- let copy_str_c = copyRange["column"][0], copy_end_c = copyRange["column"][1];
- let copyData = _this2.getCopyData(d, copy_str_r, copy_end_r, copy_str_c, copy_end_c, direction);
- let csLen;
- if (direction == "down" || direction == "up") {
- csLen = copy_end_r - copy_str_r + 1;
- } else if (direction == "right" || direction == "left") {
- csLen = copy_end_c - copy_str_c + 1;
- }
- let applyRange = _this2.applyRange;
- let apply_str_r = applyRange["row"][0], apply_end_r = applyRange["row"][1];
- let apply_str_c = applyRange["column"][0], apply_end_c = applyRange["column"][1];
- if (direction == "down" || direction == "up") {
- let asLen = apply_end_r - apply_str_r + 1;
- for (let i2 = apply_str_c; i2 <= apply_end_c; i2++) {
- let copyD = copyData[i2 - apply_str_c];
- let applyData = _this2.getApplyData(copyD, csLen, asLen);
- if (direction == "down") {
- for (let j = apply_str_r; j <= apply_end_r; j++) {
- let cell = applyData[j - apply_str_r];
- if (cell.f != null) {
- let f = "=" + formula_default.functionCopy(cell.f, "down", j - apply_str_r + 1);
- let v = formula_default.execfunction(f, j, i2);
- formula_default.execFunctionGroup(j, i2, v[1], void 0, d);
- cell.f = v[2];
- cell.v = v[1];
- if (cell.spl != null) {
- cell.spl = v[3].data;
- } else {
- if (isRealNum(cell.v) && !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(cell.v)) {
- if (cell.v == Infinity || cell.v == -Infinity) {
- cell.m = cell.v.toString();
- } else {
- if (cell.v.toString().indexOf("e") > -1) {
- let len = cell.v.toString().split(".")[1].split("e")[0].length;
- if (len > 5) {
- len = 5;
- }
- cell.m = cell.v.toExponential(len).toString();
- } else {
- let mask;
- if (cell.ct.fa === "##0.00") {
- mask = genarate(Math.round(cell.v * 1e9) / 1e9 + ".00");
- cell.m = mask[0].toString();
- } else {
- mask = genarate(Math.round(cell.v * 1e9) / 1e9);
- cell.m = mask[0].toString();
- }
- }
- }
- cell.ct = cell.ct || {"fa": "General", "t": "n"};
- } else {
- let mask = genarate(cell.v);
- cell.m = mask[0].toString();
- cell.ct = mask[1];
- }
- }
- }
- d[j][i2] = cell;
- let bd_r = copy_str_r + (j - apply_str_r) % csLen;
- let bd_c = i2;
- if (borderInfoCompute[bd_r + "_" + bd_c]) {
- let bd_obj = {
- "rangeType": "cell",
- "value": {
- "row_index": j,
- "col_index": i2,
- "l": borderInfoCompute[bd_r + "_" + bd_c].l,
- "r": borderInfoCompute[bd_r + "_" + bd_c].r,
- "t": borderInfoCompute[bd_r + "_" + bd_c].t,
- "b": borderInfoCompute[bd_r + "_" + bd_c].b
- }
- };
- cfg["borderInfo"].push(bd_obj);
- } else if (borderInfoCompute[j + "_" + i2]) {
- let bd_obj = {
- "rangeType": "cell",
- "value": {
- "row_index": j,
- "col_index": i2,
- "l": null,
- "r": null,
- "t": null,
- "b": null
- }
- };
- cfg["borderInfo"].push(bd_obj);
- }
- if (dataVerification[bd_r + "_" + bd_c]) {
- dataVerification[j + "_" + i2] = dataVerification[bd_r + "_" + bd_c];
- }
- }
- }
- if (direction == "up") {
- for (let j = apply_end_r; j >= apply_str_r; j--) {
- let cell = applyData[apply_end_r - j];
- if (cell.f != null) {
- let f = "=" + formula_default.functionCopy(cell.f, "up", apply_end_r - j + 1);
- let v = formula_default.execfunction(f, j, i2);
- formula_default.execFunctionGroup(j, i2, v[1], void 0, d);
- cell.f = v[2];
- cell.v = v[1];
- if (cell.spl != null) {
- cell.spl = v[3].data;
- } else {
- if (isRealNum(cell.v) && !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(cell.v)) {
- if (cell.v == Infinity || cell.v == -Infinity) {
- cell.m = cell.v.toString();
- } else {
- if (cell.v.toString().indexOf("e") > -1) {
- let len = cell.v.toString().split(".")[1].split("e")[0].length;
- if (len > 5) {
- len = 5;
- }
- cell.m = cell.v.toExponential(len).toString();
- } else {
- let mask = genarate(Math.round(cell.v * 1e9) / 1e9);
- cell.m = mask[0].toString();
- }
- }
- cell.ct = {"fa": "General", "t": "n"};
- } else {
- let mask = genarate(cell.v);
- cell.m = mask[0].toString();
- cell.ct = mask[1];
- }
- }
- }
- d[j][i2] = cell;
- let bd_r = copy_end_r - (apply_end_r - j) % csLen;
- let bd_c = i2;
- if (borderInfoCompute[bd_r + "_" + bd_c]) {
- let bd_obj = {
- "rangeType": "cell",
- "value": {
- "row_index": j,
- "col_index": i2,
- "l": borderInfoCompute[bd_r + "_" + bd_c].l,
- "r": borderInfoCompute[bd_r + "_" + bd_c].r,
- "t": borderInfoCompute[bd_r + "_" + bd_c].t,
- "b": borderInfoCompute[bd_r + "_" + bd_c].b
- }
- };
- cfg["borderInfo"].push(bd_obj);
- } else if (borderInfoCompute[j + "_" + i2]) {
- let bd_obj = {
- "rangeType": "cell",
- "value": {
- "row_index": j,
- "col_index": i2,
- "l": null,
- "r": null,
- "t": null,
- "b": null
- }
- };
- cfg["borderInfo"].push(bd_obj);
- }
- if (dataVerification[bd_r + "_" + bd_c]) {
- dataVerification[j + "_" + i2] = dataVerification[bd_r + "_" + bd_c];
- }
- }
- }
- }
- } else if (direction == "right" || direction == "left") {
- let asLen = apply_end_c - apply_str_c + 1;
- for (let i2 = apply_str_r; i2 <= apply_end_r; i2++) {
- let copyD = copyData[i2 - apply_str_r];
- let applyData = _this2.getApplyData(copyD, csLen, asLen);
- if (direction == "right") {
- for (let j = apply_str_c; j <= apply_end_c; j++) {
- let cell = applyData[j - apply_str_c];
- if (cell.f != null) {
- let f = "=" + formula_default.functionCopy(cell.f, "right", j - apply_str_c + 1);
- let v = formula_default.execfunction(f, i2, j);
- formula_default.execFunctionGroup(i2, j, v[1], void 0, d);
- cell.f = v[2];
- cell.v = v[1];
- if (cell.spl != null) {
- cell.spl = v[3].data;
- } else {
- if (isRealNum(cell.v) && !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(cell.v)) {
- if (cell.v == Infinity || cell.v == -Infinity) {
- cell.m = cell.v.toString();
- } else {
- if (cell.v.toString().indexOf("e") > -1) {
- let len = cell.v.toString().split(".")[1].split("e")[0].length;
- if (len > 5) {
- len = 5;
- }
- cell.m = cell.v.toExponential(len).toString();
- } else {
- let mask = genarate(Math.round(cell.v * 1e9) / 1e9);
- cell.m = mask[0].toString();
- }
- }
- cell.ct = {"fa": "General", "t": "n"};
- } else {
- let mask = genarate(cell.v);
- cell.m = mask[0].toString();
- cell.ct = mask[1];
- }
- }
- }
- d[i2][j] = cell;
- let bd_r = i2;
- let bd_c = copy_str_c + (j - apply_str_c) % csLen;
- if (borderInfoCompute[bd_r + "_" + bd_c]) {
- let bd_obj = {
- "rangeType": "cell",
- "value": {
- "row_index": i2,
- "col_index": j,
- "l": borderInfoCompute[bd_r + "_" + bd_c].l,
- "r": borderInfoCompute[bd_r + "_" + bd_c].r,
- "t": borderInfoCompute[bd_r + "_" + bd_c].t,
- "b": borderInfoCompute[bd_r + "_" + bd_c].b
- }
- };
- cfg["borderInfo"].push(bd_obj);
- } else if (borderInfoCompute[i2 + "_" + j]) {
- let bd_obj = {
- "rangeType": "cell",
- "value": {
- "row_index": i2,
- "col_index": j,
- "l": null,
- "r": null,
- "t": null,
- "b": null
- }
- };
- cfg["borderInfo"].push(bd_obj);
- }
- if (dataVerification[bd_r + "_" + bd_c]) {
- dataVerification[i2 + "_" + j] = dataVerification[bd_r + "_" + bd_c];
- }
- }
- }
- if (direction == "left") {
- for (let j = apply_end_c; j >= apply_str_c; j--) {
- let cell = applyData[apply_end_c - j];
- if (cell.f != null) {
- let f = "=" + formula_default.functionCopy(cell.f, "left", apply_end_c - j + 1);
- let v = formula_default.execfunction(f, i2, j);
- formula_default.execFunctionGroup(i2, j, v[1], void 0, d);
- cell.f = v[2];
- cell.v = v[1];
- if (cell.spl != null) {
- cell.spl = v[3].data;
- } else {
- if (isRealNum(cell.v) && !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(cell.v)) {
- if (cell.v == Infinity || cell.v == -Infinity) {
- cell.m = cell.v.toString();
- } else {
- if (cell.v.toString().indexOf("e") > -1) {
- let len = cell.v.toString().split(".")[1].split("e")[0].length;
- if (len > 5) {
- len = 5;
- }
- cell.m = cell.v.toExponential(len).toString();
- } else {
- let mask = genarate(Math.round(cell.v * 1e9) / 1e9);
- cell.m = mask[0].toString();
- }
- }
- cell.ct = {"fa": "General", "t": "n"};
- } else {
- let mask = genarate(cell.v);
- cell.m = mask[0].toString();
- cell.ct = mask[1];
- }
- }
- }
- d[i2][j] = cell;
- let bd_r = i2;
- let bd_c = copy_end_c - (apply_end_c - j) % csLen;
- if (borderInfoCompute[bd_r + "_" + bd_c]) {
- let bd_obj = {
- "rangeType": "cell",
- "value": {
- "row_index": i2,
- "col_index": j,
- "l": borderInfoCompute[bd_r + "_" + bd_c].l,
- "r": borderInfoCompute[bd_r + "_" + bd_c].r,
- "t": borderInfoCompute[bd_r + "_" + bd_c].t,
- "b": borderInfoCompute[bd_r + "_" + bd_c].b
- }
- };
- cfg["borderInfo"].push(bd_obj);
- } else if (borderInfoCompute[i2 + "_" + j]) {
- let bd_obj = {
- "rangeType": "cell",
- "value": {
- "row_index": i2,
- "col_index": j,
- "l": null,
- "r": null,
- "t": null,
- "b": null
- }
- };
- cfg["borderInfo"].push(bd_obj);
- }
- if (dataVerification[bd_r + "_" + bd_c]) {
- dataVerification[i2 + "_" + j] = dataVerification[bd_r + "_" + bd_c];
- }
- }
- }
- }
- }
- let cdformat = $.extend(true, [], file["luckysheet_conditionformat_save"]);
- if (cdformat != null && cdformat.length > 0) {
- for (let i2 = 0; i2 < cdformat.length; i2++) {
- let cdformat_cellrange = cdformat[i2].cellrange;
- let emptyRange = [];
- for (let j = 0; j < cdformat_cellrange.length; j++) {
- let range2 = conditionformat_default.CFSplitRange(cdformat_cellrange[j], {"row": copyRange["row"], "column": copyRange["column"]}, {"row": applyRange["row"], "column": applyRange["column"]}, "operatePart");
- if (range2.length > 0) {
- emptyRange = emptyRange.concat(range2);
- }
- }
- if (emptyRange.length > 0) {
- cdformat[i2].cellrange.push(applyRange);
- }
- }
- }
- let allParam = {
- "cfg": cfg,
- "cdformat": cdformat,
- "dataVerification": dataVerification
- };
- jfrefreshgrid(d, store_default.luckysheet_select_save, allParam);
- selectHightlightShow();
- },
- getCopyData: function(d, r1, r2, c1, c2, direction) {
- let _this2 = this;
- let copyData = [];
- let a12, a2, b1, b2;
- if (direction == "down" || direction == "up") {
- a12 = c1;
- a2 = c2;
- b1 = r1;
- b2 = r2;
- } else if (direction == "right" || direction == "left") {
- a12 = r1;
- a2 = r2;
- b1 = c1;
- b2 = c2;
- }
- for (let a = a12; a <= a2; a++) {
- let obj = {};
- let arrData = [];
- let arrIndex = [];
- let text = "";
- let extendNumberBeforeStr = null;
- let extendNumberAfterStr = null;
- let isSameStr = true;
- for (let b = b1; b <= b2; b++) {
- let data;
- if (direction == "down" || direction == "up") {
- data = d[b][a];
- } else if (direction == "right" || direction == "left") {
- data = d[a][b];
- }
- let str;
- if (!!data && !!data["v"] && data["f"] == null) {
- if (!!data["ct"] && data["ct"]["t"] == "n") {
- str = "number";
- extendNumberBeforeStr = null;
- extendNumberAfterStr = null;
- } else if (!!data["ct"] && data["ct"]["t"] == "d") {
- str = "date";
- extendNumberBeforeStr = null;
- extendNumberAfterStr = null;
- } else if (_this2.isExtendNumber(data["m"])[0]) {
- str = "extendNumber";
- let isExtendNumber = _this2.isExtendNumber(data["m"]);
- if (extendNumberBeforeStr == null || extendNumberAfterStr == null) {
- isSameStr = true;
- extendNumberBeforeStr = isExtendNumber[2];
- extendNumberAfterStr = isExtendNumber[3];
- } else {
- if (isExtendNumber[2] != extendNumberBeforeStr || isExtendNumber[3] != extendNumberAfterStr) {
- isSameStr = false;
- extendNumberBeforeStr = isExtendNumber[2];
- extendNumberAfterStr = isExtendNumber[3];
- } else {
- isSameStr = true;
- }
- }
- } else if (_this2.isChnNumber(data["m"])) {
- str = "chnNumber";
- extendNumberBeforeStr = null;
- extendNumberAfterStr = null;
- } else if (_this2.isChnWeek2(data["m"])) {
- str = "chnWeek2";
- extendNumberBeforeStr = null;
- extendNumberAfterStr = null;
- } else if (_this2.isChnWeek3(data["m"])) {
- str = "chnWeek3";
- extendNumberBeforeStr = null;
- extendNumberAfterStr = null;
- } else {
- str = "other";
- extendNumberBeforeStr = null;
- extendNumberAfterStr = null;
- }
- } else {
- str = "other";
- extendNumberBeforeStr = null;
- extendNumberAfterStr = null;
- }
- if (str == "extendNumber") {
- if (b == b1) {
- if (b1 == b2) {
- text = str;
- arrData.push(data);
- arrIndex.push(b - b1 + 1);
- obj[text] = [];
- obj[text].push({"data": arrData, "index": arrIndex});
- } else {
- text = str;
- arrData.push(data);
- arrIndex.push(b - b1 + 1);
- }
- } else if (b == b2) {
- if (text == str && isSameStr) {
- arrData.push(data);
- arrIndex.push(b - b1 + 1);
- if (text in obj) {
- obj[text].push({"data": arrData, "index": arrIndex});
- } else {
- obj[text] = [];
- obj[text].push({"data": arrData, "index": arrIndex});
- }
- } else {
- if (text in obj) {
- obj[text].push({"data": arrData, "index": arrIndex});
- } else {
- obj[text] = [];
- obj[text].push({"data": arrData, "index": arrIndex});
- }
- text = str;
- arrData = [];
- arrData.push(data);
- arrIndex = [];
- arrIndex.push(b - b1 + 1);
- if (text in obj) {
- obj[text].push({"data": arrData, "index": arrIndex});
- } else {
- obj[text] = [];
- obj[text].push({"data": arrData, "index": arrIndex});
- }
- }
- } else {
- if (text == str && isSameStr) {
- arrData.push(data);
- arrIndex.push(b - b1 + 1);
- } else {
- if (text in obj) {
- obj[text].push({"data": arrData, "index": arrIndex});
- } else {
- obj[text] = [];
- obj[text].push({"data": arrData, "index": arrIndex});
- }
- text = str;
- arrData = [];
- arrData.push(data);
- arrIndex = [];
- arrIndex.push(b - b1 + 1);
- }
- }
- } else {
- if (b == b1) {
- if (b1 == b2) {
- text = str;
- arrData.push(data);
- arrIndex.push(b - b1 + 1);
- obj[text] = [];
- obj[text].push({"data": arrData, "index": arrIndex});
- } else {
- text = str;
- arrData.push(data);
- arrIndex.push(b - b1 + 1);
- }
- } else if (b == b2) {
- if (text == str) {
- arrData.push(data);
- arrIndex.push(b - b1 + 1);
- if (text in obj) {
- obj[text].push({"data": arrData, "index": arrIndex});
- } else {
- obj[text] = [];
- obj[text].push({"data": arrData, "index": arrIndex});
- }
- } else {
- if (text in obj) {
- obj[text].push({"data": arrData, "index": arrIndex});
- } else {
- obj[text] = [];
- obj[text].push({"data": arrData, "index": arrIndex});
- }
- text = str;
- arrData = [];
- arrData.push(data);
- arrIndex = [];
- arrIndex.push(b - b1 + 1);
- if (text in obj) {
- obj[text].push({"data": arrData, "index": arrIndex});
- } else {
- obj[text] = [];
- obj[text].push({"data": arrData, "index": arrIndex});
- }
- }
- } else {
- if (text == str) {
- arrData.push(data);
- arrIndex.push(b - b1 + 1);
- } else {
- if (text in obj) {
- obj[text].push({"data": arrData, "index": arrIndex});
- } else {
- obj[text] = [];
- obj[text].push({"data": arrData, "index": arrIndex});
- }
- text = str;
- arrData = [];
- arrData.push(data);
- arrIndex = [];
- arrIndex.push(b - b1 + 1);
- }
- }
- }
- }
- copyData.push(obj);
- }
- return copyData;
- },
- getApplyData: function(copyD, csLen, asLen) {
- let _this2 = this;
- let applyData = [];
- let direction = _this2.direction;
- let type = _this2.applyType;
- let num = Math.floor(asLen / csLen);
- let rsd = asLen % csLen;
- let copyD_number = copyD["number"];
- let applyD_number = [];
- if (!!copyD_number) {
- for (let i2 = 0; i2 < copyD_number.length; i2++) {
- let s = _this2.getLenS(copyD_number[i2]["index"], rsd);
- let len = copyD_number[i2]["index"].length * num + s;
- let arrData;
- if (type == "1" || type == "3") {
- arrData = _this2.getDataByType(copyD_number[i2]["data"], len, direction, type, "number");
- } else if (type == "2") {
- arrData = _this2.getDataByType(copyD_number[i2]["data"], len, direction, type);
- } else {
- arrData = _this2.getDataByType(copyD_number[i2]["data"], len, direction, "0");
- }
- let arrIndex = _this2.getDataIndex(csLen, asLen, copyD_number[i2]["index"]);
- applyD_number.push({"data": arrData, "index": arrIndex});
- }
- }
- let copyD_extendNumber = copyD["extendNumber"];
- let applyD_extendNumber = [];
- if (!!copyD_extendNumber) {
- for (let i2 = 0; i2 < copyD_extendNumber.length; i2++) {
- let s = _this2.getLenS(copyD_extendNumber[i2]["index"], rsd);
- let len = copyD_extendNumber[i2]["index"].length * num + s;
- let arrData;
- if (type == "1" || type == "3") {
- arrData = _this2.getDataByType(copyD_extendNumber[i2]["data"], len, direction, type, "extendNumber");
- } else if (type == "2") {
- arrData = _this2.getDataByType(copyD_extendNumber[i2]["data"], len, direction, type);
- } else {
- arrData = _this2.getDataByType(copyD_extendNumber[i2]["data"], len, direction, "0");
- }
- let arrIndex = _this2.getDataIndex(csLen, asLen, copyD_extendNumber[i2]["index"]);
- applyD_extendNumber.push({"data": arrData, "index": arrIndex});
- }
- }
- let copyD_date = copyD["date"];
- let applyD_date = [];
- if (!!copyD_date) {
- for (let i2 = 0; i2 < copyD_date.length; i2++) {
- let s = _this2.getLenS(copyD_date[i2]["index"], rsd);
- let len = copyD_date[i2]["index"].length * num + s;
- let arrData;
- if (type == "1" || type == "3") {
- arrData = _this2.getDataByType(copyD_date[i2]["data"], len, direction, type, "date");
- } else if (type == "8") {
- arrData = _this2.getDataByType(copyD_date[i2]["data"], len, direction, "0");
- } else {
- arrData = _this2.getDataByType(copyD_date[i2]["data"], len, direction, type);
- }
- let arrIndex = _this2.getDataIndex(csLen, asLen, copyD_date[i2]["index"]);
- applyD_date.push({"data": arrData, "index": arrIndex});
- }
- }
- let copyD_chnNumber = copyD["chnNumber"];
- let applyD_chnNumber = [];
- if (!!copyD_chnNumber) {
- for (let i2 = 0; i2 < copyD_chnNumber.length; i2++) {
- let s = _this2.getLenS(copyD_chnNumber[i2]["index"], rsd);
- let len = copyD_chnNumber[i2]["index"].length * num + s;
- let arrData;
- if (type == "1" || type == "3") {
- arrData = _this2.getDataByType(copyD_chnNumber[i2]["data"], len, direction, type, "chnNumber");
- } else if (type == "2" || type == "8") {
- arrData = _this2.getDataByType(copyD_chnNumber[i2]["data"], len, direction, type);
- } else {
- arrData = _this2.getDataByType(copyD_chnNumber[i2]["data"], len, direction, "0");
- }
- let arrIndex = _this2.getDataIndex(csLen, asLen, copyD_chnNumber[i2]["index"]);
- applyD_chnNumber.push({"data": arrData, "index": arrIndex});
- }
- }
- let copyD_chnWeek2 = copyD["chnWeek2"];
- let applyD_chnWeek2 = [];
- if (!!copyD_chnWeek2) {
- for (let i2 = 0; i2 < copyD_chnWeek2.length; i2++) {
- let s = _this2.getLenS(copyD_chnWeek2[i2]["index"], rsd);
- let len = copyD_chnWeek2[i2]["index"].length * num + s;
- let arrData;
- if (type == "1" || type == "3") {
- arrData = _this2.getDataByType(copyD_chnWeek2[i2]["data"], len, direction, type, "chnWeek2");
- } else if (type == "2") {
- arrData = _this2.getDataByType(copyD_chnWeek2[i2]["data"], len, direction, type);
- } else {
- arrData = _this2.getDataByType(copyD_chnWeek2[i2]["data"], len, direction, "0");
- }
- let arrIndex = _this2.getDataIndex(csLen, asLen, copyD_chnWeek2[i2]["index"]);
- applyD_chnWeek2.push({"data": arrData, "index": arrIndex});
- }
- }
- let copyD_chnWeek3 = copyD["chnWeek3"];
- let applyD_chnWeek3 = [];
- if (!!copyD_chnWeek3) {
- for (let i2 = 0; i2 < copyD_chnWeek3.length; i2++) {
- let s = _this2.getLenS(copyD_chnWeek3[i2]["index"], rsd);
- let len = copyD_chnWeek3[i2]["index"].length * num + s;
- let arrData;
- if (type == "1" || type == "3") {
- arrData = _this2.getDataByType(copyD_chnWeek3[i2]["data"], len, direction, type, "chnWeek3");
- } else if (type == "2") {
- arrData = _this2.getDataByType(copyD_chnWeek3[i2]["data"], len, direction, type);
- } else {
- arrData = _this2.getDataByType(copyD_chnWeek3[i2]["data"], len, direction, "0");
- }
- let arrIndex = _this2.getDataIndex(csLen, asLen, copyD_chnWeek3[i2]["index"]);
- applyD_chnWeek3.push({"data": arrData, "index": arrIndex});
- }
- }
- let copyD_other = copyD["other"];
- let applyD_other = [];
- if (!!copyD_other) {
- for (let i2 = 0; i2 < copyD_other.length; i2++) {
- let s = _this2.getLenS(copyD_other[i2]["index"], rsd);
- let len = copyD_other[i2]["index"].length * num + s;
- let arrData;
- if (type == "2" || type == "3") {
- arrData = _this2.getDataByType(copyD_other[i2]["data"], len, direction, type);
- } else {
- arrData = _this2.getDataByType(copyD_other[i2]["data"], len, direction, "0");
- }
- let arrIndex = _this2.getDataIndex(csLen, asLen, copyD_other[i2]["index"]);
- applyD_other.push({"data": arrData, "index": arrIndex});
- }
- }
- for (let x = 1; x <= asLen; x++) {
- if (applyD_number.length > 0) {
- for (let y = 0; y < applyD_number.length; y++) {
- if (x in applyD_number[y]["index"]) {
- applyData.push(applyD_number[y]["data"][applyD_number[y]["index"][x]]);
- }
- }
- }
- if (applyD_extendNumber.length > 0) {
- for (let y = 0; y < applyD_extendNumber.length; y++) {
- if (x in applyD_extendNumber[y]["index"]) {
- applyData.push(applyD_extendNumber[y]["data"][applyD_extendNumber[y]["index"][x]]);
- }
- }
- }
- if (applyD_date.length > 0) {
- for (let y = 0; y < applyD_date.length; y++) {
- if (x in applyD_date[y]["index"]) {
- applyData.push(applyD_date[y]["data"][applyD_date[y]["index"][x]]);
- }
- }
- }
- if (applyD_chnNumber.length > 0) {
- for (let y = 0; y < applyD_chnNumber.length; y++) {
- if (x in applyD_chnNumber[y]["index"]) {
- applyData.push(applyD_chnNumber[y]["data"][applyD_chnNumber[y]["index"][x]]);
- }
- }
- }
- if (applyD_chnWeek2.length > 0) {
- for (let y = 0; y < applyD_chnWeek2.length; y++) {
- if (x in applyD_chnWeek2[y]["index"]) {
- applyData.push(applyD_chnWeek2[y]["data"][applyD_chnWeek2[y]["index"][x]]);
- }
- }
- }
- if (applyD_chnWeek3.length > 0) {
- for (let y = 0; y < applyD_chnWeek3.length; y++) {
- if (x in applyD_chnWeek3[y]["index"]) {
- applyData.push(applyD_chnWeek3[y]["data"][applyD_chnWeek3[y]["index"][x]]);
- }
- }
- }
- if (applyD_other.length > 0) {
- for (let y = 0; y < applyD_other.length; y++) {
- if (x in applyD_other[y]["index"]) {
- applyData.push(applyD_other[y]["data"][applyD_other[y]["index"][x]]);
- }
- }
- }
- }
- return applyData;
- },
- getLenS: function(indexArr, rsd) {
- let s = 0;
- for (let j = 0; j < indexArr.length; j++) {
- if (indexArr[j] <= rsd) {
- s++;
- } else {
- break;
- }
- }
- return s;
- },
- getDataIndex: function(csLen, asLen, indexArr) {
- let obj = {};
- let num = Math.floor(asLen / csLen);
- let rsd = asLen % csLen;
- let sum = 0;
- if (num > 0) {
- for (let i2 = 1; i2 <= num; i2++) {
- for (let j = 0; j < indexArr.length; j++) {
- obj[indexArr[j] + (i2 - 1) * csLen] = sum;
- sum++;
- }
- }
- for (let a = 0; a < indexArr.length; a++) {
- if (indexArr[a] <= rsd) {
- obj[indexArr[a] + csLen * num] = sum;
- sum++;
- } else {
- break;
- }
- }
- } else {
- for (let a = 0; a < indexArr.length; a++) {
- if (indexArr[a] <= rsd) {
- obj[indexArr[a]] = sum;
- sum++;
- } else {
- break;
- }
- }
- }
- return obj;
- },
- getDataByType: function(data, len, direction, type, dataType) {
- let _this2 = this;
- let applyData = [];
- if (type == "0") {
- if (direction == "up" || direction == "left") {
- data.reverse();
- }
- applyData = _this2.FillCopy(data, len);
- } else if (type == "1") {
- if (dataType == "number") {
- applyData = _this2.FillSeries(data, len, direction);
- } else if (dataType == "extendNumber") {
- if (data.length == 1) {
- let step;
- if (direction == "down" || direction == "right") {
- step = 1;
- } else if (direction == "up" || direction == "left") {
- step = -1;
- }
- applyData = _this2.FillExtendNumber(data, len, step);
- } else {
- let dataNumArr = [];
- for (let i2 = 0; i2 < data.length; i2++) {
- let txt = data[i2]["m"];
- dataNumArr.push(Number(_this2.isExtendNumber(txt)[1]));
- }
- if (direction == "up" || direction == "left") {
- data.reverse();
- dataNumArr.reverse();
- }
- if (_this2.isEqualDiff(dataNumArr)) {
- let step = dataNumArr[1] - dataNumArr[0];
- applyData = _this2.FillExtendNumber(data, len, step);
- } else {
- applyData = _this2.FillCopy(data, len);
- }
- }
- } else if (dataType == "date") {
- if (data.length == 1) {
- let step;
- if (direction == "down" || direction == "right") {
- step = 1;
- } else if (direction == "up" || direction == "left") {
- step = -1;
- }
- applyData = _this2.FillDays(data, len, step);
- } else {
- if (direction == "up" || direction == "left") {
- data.reverse();
- }
- let judgeDate = _this2.judgeDate(data);
- if (judgeDate[0] && judgeDate[3]) {
- let step = (0, import_dayjs2.default)(data[1]["m"]).diff((0, import_dayjs2.default)(data[0]["m"]), "months");
- applyData = _this2.FillMonths(data, len, step);
- } else if (!judgeDate[0] && judgeDate[2]) {
- let step = (0, import_dayjs2.default)(data[1]["m"]).diff((0, import_dayjs2.default)(data[0]["m"]), "days");
- applyData = _this2.FillDays(data, len, step);
- } else {
- applyData = _this2.FillCopy(data, len);
- }
- }
- } else if (dataType == "chnNumber") {
- if (data.length == 1) {
- if (data[0]["m"] == "\u65E5" || _this2.ChineseToNumber(data[0]["m"]) < 7) {
- let step;
- if (direction == "down" || direction == "right") {
- step = 1;
- } else if (direction == "up" || direction == "left") {
- step = -1;
- }
- applyData = _this2.FillChnWeek(data, len, step);
- } else {
- let step;
- if (direction == "down" || direction == "right") {
- step = 1;
- } else if (direction == "up" || direction == "left") {
- step = -1;
- }
- applyData = _this2.FillChnNumber(data, len, step);
- }
- } else {
- let hasweek = false;
- for (let i2 = 0; i2 < data.length; i2++) {
- if (data[i2]["m"] == "\u65E5") {
- hasweek = true;
- break;
- }
- }
- let dataNumArr = [];
- let weekIndex = 0;
- for (let i2 = 0; i2 < data.length; i2++) {
- if (data[i2]["m"] == "\u65E5") {
- if (i2 == 0) {
- dataNumArr.push(0);
- } else {
- weekIndex++;
- dataNumArr.push(weekIndex * 7);
- }
- } else if (hasweek && _this2.ChineseToNumber(data[i2]["m"]) > 0 && _this2.ChineseToNumber(data[i2]["m"]) < 7) {
- dataNumArr.push(_this2.ChineseToNumber(data[i2]["m"]) + weekIndex * 7);
- } else {
- dataNumArr.push(_this2.ChineseToNumber(data[i2]["m"]));
- }
- }
- if (direction == "up" || direction == "left") {
- data.reverse();
- dataNumArr.reverse();
- }
- if (_this2.isEqualDiff(dataNumArr)) {
- if (hasweek || dataNumArr[dataNumArr.length - 1] < 6 && dataNumArr[0] > 0 || dataNumArr[0] < 6 && dataNumArr[dataNumArr.length - 1] > 0) {
- let step = dataNumArr[1] - dataNumArr[0];
- applyData = _this2.FillChnWeek(data, len, step);
- } else {
- let step = dataNumArr[1] - dataNumArr[0];
- applyData = _this2.FillChnNumber(data, len, step);
- }
- } else {
- applyData = _this2.FillCopy(data, len);
- }
- }
- } else if (dataType == "chnWeek2") {
- if (data.length == 1) {
- let step;
- if (direction == "down" || direction == "right") {
- step = 1;
- } else if (direction == "up" || direction == "left") {
- step = -1;
- }
- applyData = _this2.FillChnWeek2(data, len, step);
- } else {
- let dataNumArr = [];
- let weekIndex = 0;
- for (let i2 = 0; i2 < data.length; i2++) {
- let lastTxt = data[i2]["m"].substr(data[i2]["m"].length - 1, 1);
- if (data[i2]["m"] == "\u5468\u65E5") {
- if (i2 == 0) {
- dataNumArr.push(0);
- } else {
- weekIndex++;
- dataNumArr.push(weekIndex * 7);
- }
- } else {
- dataNumArr.push(_this2.ChineseToNumber(lastTxt) + weekIndex * 7);
- }
- }
- if (direction == "up" || direction == "left") {
- data.reverse();
- dataNumArr.reverse();
- }
- if (_this2.isEqualDiff(dataNumArr)) {
- let step = dataNumArr[1] - dataNumArr[0];
- applyData = _this2.FillChnWeek2(data, len, step);
- } else {
- applyData = _this2.FillCopy(data, len);
- }
- }
- } else if (dataType == "chnWeek3") {
- if (data.length == 1) {
- let step;
- if (direction == "down" || direction == "right") {
- step = 1;
- } else if (direction == "up" || direction == "left") {
- step = -1;
- }
- applyData = _this2.FillChnWeek3(data, len, step);
- } else {
- let dataNumArr = [];
- let weekIndex = 0;
- for (let i2 = 0; i2 < data.length; i2++) {
- let lastTxt = data[i2]["m"].substr(data[i2]["m"].length - 1, 1);
- if (data[i2]["m"] == "\u661F\u671F\u65E5") {
- if (i2 == 0) {
- dataNumArr.push(0);
- } else {
- weekIndex++;
- dataNumArr.push(weekIndex * 7);
- }
- } else {
- dataNumArr.push(_this2.ChineseToNumber(lastTxt) + weekIndex * 7);
- }
- }
- if (direction == "up" || direction == "left") {
- data.reverse();
- dataNumArr.reverse();
- }
- if (_this2.isEqualDiff(dataNumArr)) {
- let step = dataNumArr[1] - dataNumArr[0];
- applyData = _this2.FillChnWeek3(data, len, step);
- } else {
- applyData = _this2.FillCopy(data, len);
- }
- }
- } else {
- if (direction == "up" || direction == "left") {
- data.reverse();
- }
- applyData = _this2.FillCopy(data, len);
- }
- } else if (type == "2") {
- if (direction == "up" || direction == "left") {
- data.reverse();
- }
- applyData = _this2.FillOnlyFormat(data, len);
- } else if (type == "3") {
- let dataArr = _this2.getDataByType(data, len, direction, "1", dataType);
- applyData = _this2.FillWithoutFormat(dataArr);
- } else if (type == "4") {
- if (data.length == 1) {
- let step;
- if (direction == "down" || direction == "right") {
- step = 1;
- } else if (direction == "up" || direction == "left") {
- step = -1;
- }
- applyData = _this2.FillDays(data, len, step);
- } else if (data.length == 2) {
- if (direction == "up" || direction == "left") {
- data.reverse();
- }
- let step = (0, import_dayjs2.default)(data[1]["m"]).diff((0, import_dayjs2.default)(data[0]["m"]), "days");
- applyData = _this2.FillDays(data, len, step);
- } else {
- if (direction == "up" || direction == "left") {
- data.reverse();
- }
- let judgeDate = _this2.judgeDate(data);
- if (judgeDate[0] && judgeDate[3]) {
- let step = (0, import_dayjs2.default)(data[1]["m"]).diff((0, import_dayjs2.default)(data[0]["m"]), "months");
- applyData = _this2.FillMonths(data, len, step);
- } else if (!judgeDate[0] && judgeDate[2]) {
- let step = (0, import_dayjs2.default)(data[1]["m"]).diff((0, import_dayjs2.default)(data[0]["m"]), "days");
- applyData = _this2.FillDays(data, len, step);
- } else {
- applyData = _this2.FillCopy(data, len);
- }
- }
- } else if (type == "5") {
- if (data.length == 1) {
- let step;
- if (direction == "down" || direction == "right") {
- step = 1;
- } else if (direction == "up" || direction == "left") {
- step = -1;
- }
- let newLen = Math.round(len * 1.5);
- for (let i2 = 1; i2 <= newLen; i2++) {
- let d = $.extend(true, {}, data[0]);
- let day = (0, import_dayjs2.default)(d["m"]).add(i2, "days").day();
- if (day == 0 || day == 6) {
- continue;
- }
- let date = (0, import_dayjs2.default)(d["m"]).add(step * i2, "days").format("YYYY-MM-DD");
- d["m"] = date;
- d["v"] = genarate(date)[2];
- applyData.push(d);
- if (applyData.length == len) {
- break;
- }
- }
- } else if (data.length == 2) {
- if ((0, import_dayjs2.default)(data[1]["m"]).date() == (0, import_dayjs2.default)(data[0]["m"]).date() && (0, import_dayjs2.default)(data[1]["m"]).diff((0, import_dayjs2.default)(data[0]["m"]), "months") != 0) {
- if (direction == "up" || direction == "left") {
- data.reverse();
- }
- let step = (0, import_dayjs2.default)(data[1]["m"]).diff((0, import_dayjs2.default)(data[0]["m"]), "months");
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let day = (0, import_dayjs2.default)(data[data.length - 1]).add(step * i2, "months").day(), date;
- if (day == 0) {
- date = (0, import_dayjs2.default)(data[data.length - 1]).add(step * i2, "months").subtract(2, "days").format("YYYY-MM-DD");
- } else if (day == 6) {
- date = (0, import_dayjs2.default)(data[data.length - 1]).add(step * i2, "months").subtract(1, "days").format("YYYY-MM-DD");
- } else {
- date = (0, import_dayjs2.default)(data[data.length - 1]).add(step * i2, "months").format("YYYY-MM-DD");
- }
- d["m"] = date;
- d["v"] = genarate(date)[2];
- applyData.push(d);
- }
- } else {
- if (Math.abs((0, import_dayjs2.default)(data[1]["m"]).diff((0, import_dayjs2.default)(data[0]["m"]))) > 7) {
- let step_month;
- if (direction == "down" || direction == "right") {
- step_month = 1;
- } else if (direction == "up" || direction == "left") {
- step_month = -1;
- data.reverse();
- }
- let step;
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let num = Math.ceil(i2 / data.length);
- if (index2 == 0) {
- step = (0, import_dayjs2.default)(d["m"]).add(step_month * num, "months").diff((0, import_dayjs2.default)(d["m"]), "days");
- }
- let day = (0, import_dayjs2.default)(d["m"]).add(step, "days").day(), date;
- if (day == 0) {
- date = (0, import_dayjs2.default)(d["m"]).add(step, "days").subtract(2, "days").format("YYYY-MM-DD");
- } else if (day == 6) {
- date = (0, import_dayjs2.default)(d["m"]).add(step, "days").subtract(1, "days").format("YYYY-MM-DD");
- } else {
- date = (0, import_dayjs2.default)(d["m"]).add(step, "days").format("YYYY-MM-DD");
- }
- d["m"] = date;
- d["v"] = genarate(date)[2];
- applyData.push(d);
- }
- } else {
- let step_day;
- if (direction == "down" || direction == "right") {
- step_day = 7;
- } else if (direction == "up" || direction == "left") {
- step_day = -7;
- data.reverse();
- }
- let step;
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let num = Math.ceil(i2 / data.length);
- if (index2 == 0) {
- step = (0, import_dayjs2.default)(d["m"]).add(step_day * num, "days").diff((0, import_dayjs2.default)(d["m"]), "days");
- }
- let day = (0, import_dayjs2.default)(d["m"]).add(step, "days").day(), date;
- if (day == 0) {
- date = (0, import_dayjs2.default)(d["m"]).add(step, "days").subtract(2, "days").format("YYYY-MM-DD");
- } else if (day == 6) {
- date = (0, import_dayjs2.default)(d["m"]).add(step, "days").subtract(1, "days").format("YYYY-MM-DD");
- } else {
- date = (0, import_dayjs2.default)(d["m"]).add(step, "days").format("YYYY-MM-DD");
- }
- d["m"] = date;
- d["v"] = genarate(date)[2];
- applyData.push(d);
- }
- }
- }
- } else {
- let judgeDate = _this2.judgeDate(data);
- if (judgeDate[0] && judgeDate[3]) {
- if (direction == "up" || direction == "left") {
- data.reverse();
- }
- let step = (0, import_dayjs2.default)(data[1]["m"]).diff((0, import_dayjs2.default)(data[0]["m"]), "months");
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let day = (0, import_dayjs2.default)(data[data.length - 1]["m"]).add(step * i2, "months").day(), date;
- if (day == 0) {
- date = (0, import_dayjs2.default)(data[data.length - 1]["m"]).add(step * i2, "months").subtract(2, "days").format("YYYY-MM-DD");
- } else if (day == 6) {
- date = (0, import_dayjs2.default)(data[data.length - 1]["m"]).add(step * i2, "months").subtract(1, "days").format("YYYY-MM-DD");
- } else {
- date = (0, import_dayjs2.default)(data[data.length - 1]["m"]).add(step * i2, "months").format("YYYY-MM-DD");
- }
- d["m"] = date;
- d["v"] = genarate(date)[2];
- applyData.push(d);
- }
- } else if (!judgeDate[0] && judgeDate[2]) {
- if (Math.abs((0, import_dayjs2.default)(data[1]["m"]).diff((0, import_dayjs2.default)(data[0]["m"]))) > 7) {
- let step_month;
- if (direction == "down" || direction == "right") {
- step_month = 1;
- } else if (direction == "up" || direction == "left") {
- step_month = -1;
- data.reverse();
- }
- let step;
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let num = Math.ceil(i2 / data.length);
- if (index2 == 0) {
- step = (0, import_dayjs2.default)(d["m"]).add(step_month * num, "months").diff((0, import_dayjs2.default)(d["m"]), "days");
- }
- let day = (0, import_dayjs2.default)(d["m"]).add(step, "days").day(), date;
- if (day == 0) {
- date = (0, import_dayjs2.default)(d["m"]).add(step, "days").subtract(2, "days").format("YYYY-MM-DD");
- } else if (day == 6) {
- date = (0, import_dayjs2.default)(d["m"]).add(step, "days").subtract(1, "days").format("YYYY-MM-DD");
- } else {
- date = (0, import_dayjs2.default)(d["m"]).add(step, "days").format("YYYY-MM-DD");
- }
- d["m"] = date;
- d["v"] = genarate(date)[2];
- applyData.push(d);
- }
- } else {
- let step_day;
- if (direction == "down" || direction == "right") {
- step_day = 7;
- } else if (direction == "up" || direction == "left") {
- step_day = -7;
- data.reverse();
- }
- let step;
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let num = Math.ceil(i2 / data.length);
- if (index2 == 0) {
- step = (0, import_dayjs2.default)(d["m"]).add(step_day * num, "days").diff((0, import_dayjs2.default)(d["m"]), "days");
- }
- let day = (0, import_dayjs2.default)(d["m"]).add(step, "days").day(), date;
- if (day == 0) {
- date = (0, import_dayjs2.default)(d["m"]).add(step, "days").subtract(2, "days").format("YYYY-MM-DD");
- } else if (day == 6) {
- date = (0, import_dayjs2.default)(d["m"]).add(step, "days").subtract(1, "days").format("YYYY-MM-DD");
- } else {
- date = (0, import_dayjs2.default)(d["m"]).add(step, "days").format("YYYY-MM-DD");
- }
- d["m"] = date;
- d["v"] = genarate(date)[2];
- applyData.push(d);
- }
- }
- } else {
- if (direction == "up" || direction == "left") {
- data.reverse();
- }
- applyData = _this2.FillCopy(data, len);
- }
- }
- } else if (type == "6") {
- if (data.length == 1) {
- let step;
- if (direction == "down" || direction == "right") {
- step = 1;
- } else if (direction == "up" || direction == "left") {
- step = -1;
- }
- applyData = _this2.FillMonths(data, len, step);
- } else if (data.length == 2) {
- if ((0, import_dayjs2.default)(data[1]["m"]).date() == (0, import_dayjs2.default)(data[0]["m"]).date() && (0, import_dayjs2.default)(data[1]["m"]).diff((0, import_dayjs2.default)(data[0]["m"]), "months") != 0) {
- if (direction == "up" || direction == "left") {
- data.reverse();
- }
- let step = (0, import_dayjs2.default)(data[1]["m"]).diff((0, import_dayjs2.default)(data[0]["m"]), "months");
- applyData = _this2.FillMonths(data, len, step);
- } else {
- let step_month;
- if (direction == "down" || direction == "right") {
- step_month = 1;
- } else if (direction == "up" || direction == "left") {
- step_month = -1;
- data.reverse();
- }
- let step;
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let num = Math.ceil(i2 / data.length);
- if (index2 == 0) {
- step = (0, import_dayjs2.default)(d["m"]).add(step_month * num, "months").diff((0, import_dayjs2.default)(d["m"]), "days");
- }
- let date = (0, import_dayjs2.default)(d["m"]).add(step, "days").format("YYYY-MM-DD");
- d["m"] = date;
- d["v"] = genarate(date)[2];
- applyData.push(d);
- }
- }
- } else {
- let judgeDate = _this2.judgeDate(data);
- if (judgeDate[0] && judgeDate[3]) {
- if (direction == "up" || direction == "left") {
- data.reverse();
- }
- let step = (0, import_dayjs2.default)(data[1]["m"]).diff((0, import_dayjs2.default)(data[0]["m"]), "months");
- applyData = _this2.FillMonths(data, len, step);
- } else if (!judgeDate[0] && judgeDate[2]) {
- let step_month;
- if (direction == "down" || direction == "right") {
- step_month = 1;
- } else if (direction == "up" || direction == "left") {
- step_month = -1;
- data.reverse();
- }
- let step;
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let num = Math.ceil(i2 / data.length);
- if (index2 == 0) {
- step = (0, import_dayjs2.default)(d["m"]).add(step_month * num, "months").diff((0, import_dayjs2.default)(d["m"]), "days");
- }
- let date = (0, import_dayjs2.default)(d["m"]).add(step, "days").format("YYYY-MM-DD");
- d["m"] = date;
- d["v"] = genarate(date)[2];
- applyData.push(d);
- }
- } else {
- if (direction == "up" || direction == "left") {
- data.reverse();
- }
- applyData = _this2.FillCopy(data, len);
- }
- }
- } else if (type == "7") {
- if (data.length == 1) {
- let step;
- if (direction == "down" || direction == "right") {
- step = 1;
- } else if (direction == "up" || direction == "left") {
- step = -1;
- }
- applyData = _this2.FillYears(data, len, step);
- } else if (data.length == 2) {
- if ((0, import_dayjs2.default)(data[1]["m"]).date() == (0, import_dayjs2.default)(data[0]["m"]).date() && (0, import_dayjs2.default)(data[1]["m"]).month() == (0, import_dayjs2.default)(data[0]["m"]).month() && (0, import_dayjs2.default)(data[1]["m"]).diff((0, import_dayjs2.default)(data[0]["m"]), "years") != 0) {
- if (direction == "up" || direction == "left") {
- data.reverse();
- }
- let step = (0, import_dayjs2.default)(data[1]["m"]).diff((0, import_dayjs2.default)(data[0]["m"]), "years");
- applyData = _this2.FillYears(data, len, step);
- } else {
- let step_year;
- if (direction == "down" || direction == "right") {
- step_year = 1;
- } else if (direction == "up" || direction == "left") {
- step_year = -1;
- data.reverse();
- }
- let step;
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let num = Math.ceil(i2 / data.length);
- if (index2 == 0) {
- step = (0, import_dayjs2.default)(d["m"]).add(step_year * num, "years").diff((0, import_dayjs2.default)(d["m"]), "days");
- }
- let date = (0, import_dayjs2.default)(d["m"]).add(step, "days").format("YYYY-MM-DD");
- d["m"] = date;
- d["v"] = genarate(date)[2];
- applyData.push(d);
- }
- }
- } else {
- let judgeDate = _this2.judgeDate(data);
- if (judgeDate[0] && judgeDate[1] && judgeDate[4]) {
- if (direction == "up" || direction == "left") {
- data.reverse();
- }
- let step = (0, import_dayjs2.default)(data[1]["m"]).diff((0, import_dayjs2.default)(data[0]["m"]), "years");
- applyData = _this2.FillYears(data, len, step);
- } else if (judgeDate[0] && judgeDate[3] || judgeDate[2]) {
- let step_year;
- if (direction == "down" || direction == "right") {
- step_year = 1;
- } else if (direction == "up" || direction == "left") {
- step_year = -1;
- data.reverse();
- }
- let step;
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let num = Math.ceil(i2 / data.length);
- if (index2 == 0) {
- step = (0, import_dayjs2.default)(d["m"]).add(step_year * num, "years").diff((0, import_dayjs2.default)(d["m"]), "days");
- }
- let date = (0, import_dayjs2.default)(d["m"]).add(step, "days").format("YYYY-MM-DD");
- d["m"] = date;
- d["v"] = genarate(date)[2];
- applyData.push(d);
- }
- } else {
- if (direction == "up" || direction == "left") {
- data.reverse();
- }
- applyData = _this2.FillCopy(data, len);
- }
- }
- } else if (type == "8") {
- if (data.length == 1) {
- let step;
- if (direction == "down" || direction == "right") {
- step = 1;
- } else if (direction == "up" || direction == "left") {
- step = -1;
- }
- applyData = _this2.FillChnNumber(data, len, step);
- } else {
- let dataNumArr = [];
- for (let i2 = 0; i2 < data.length; i2++) {
- dataNumArr.push(_this2.ChineseToNumber(data[i2]["m"]));
- }
- if (direction == "up" || direction == "left") {
- data.reverse();
- dataNumArr.reverse();
- }
- if (_this2.isEqualDiff(dataNumArr)) {
- let step = dataNumArr[1] - dataNumArr[0];
- applyData = _this2.FillChnNumber(data, len, step);
- } else {
- applyData = _this2.FillCopy(data, len);
- }
- }
- }
- return applyData;
- },
- FillCopy: function(data, len) {
- let applyData = [];
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- applyData.push(d);
- }
- return applyData;
- },
- FillSeries: function(data, len, direction) {
- let _this2 = this;
- let applyData = [];
- let dataNumArr = [];
- for (let j = 0; j < data.length; j++) {
- dataNumArr.push(Number(data[j]["v"]));
- }
- if (data.length > 2 && _this2.isEqualRatio(dataNumArr)) {
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let num;
- if (direction == "down" || direction == "right") {
- num = Number(data[data.length - 1]["v"]) * Math.pow(Number(data[1]["v"]) / Number(data[0]["v"]), i2);
- } else if (direction == "up" || direction == "left") {
- num = Number(data[0]["v"]) / Math.pow(Number(data[1]["v"]) / Number(data[0]["v"]), i2);
- }
- d["v"] = num;
- d["m"] = update(d["ct"]["fa"], num);
- applyData.push(d);
- }
- } else {
- let xArr = _this2.getXArr(data.length);
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let y;
- if (direction == "down" || direction == "right") {
- y = _this2.forecast(data.length + i2, dataNumArr, xArr);
- } else if (direction == "up" || direction == "left") {
- y = _this2.forecast(1 - i2, dataNumArr, xArr);
- }
- d["v"] = y;
- d["m"] = update(d["ct"]["fa"], y);
- applyData.push(d);
- }
- }
- return applyData;
- },
- FillExtendNumber: function(data, len, step) {
- let _this2 = this;
- let applyData = [];
- let reg = /0|([1-9]+[0-9]*)/g;
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let last = data[data.length - 1]["m"];
- let match = last.match(reg);
- let lastTxt = match[match.length - 1];
- let num = Math.abs(Number(lastTxt) + step * i2);
- let lastIndex = last.lastIndexOf(lastTxt);
- let valueTxt = last.substr(0, lastIndex) + num.toString() + last.substr(lastIndex + lastTxt.length);
- d["v"] = valueTxt;
- d["m"] = valueTxt;
- applyData.push(d);
- }
- return applyData;
- },
- FillOnlyFormat: function(data, len) {
- let applyData = [];
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- delete d["f"];
- delete d["m"];
- delete d["v"];
- applyData.push(d);
- }
- return applyData;
- },
- FillWithoutFormat: function(dataArr) {
- let applyData = [];
- for (let i2 = 0; i2 < dataArr.length; i2++) {
- let d = $.extend(true, {}, dataArr[i2]);
- let obj;
- if (d["f"] == null) {
- obj = {"m": d["v"].toString(), "v": d["v"]};
- } else {
- obj = {"f": d["f"], "m": d["v"].toString(), "v": d["v"]};
- }
- applyData.push(obj);
- }
- return applyData;
- },
- FillDays: function(data, len, step) {
- let applyData = [];
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let date = update("yyyy-MM-dd", d["v"]);
- date = (0, import_dayjs2.default)(date).add(step * i2, "days").format("YYYY-MM-DD");
- d["v"] = genarate(date)[2];
- d["m"] = update(d["ct"]["fa"], d["v"]);
- applyData.push(d);
- }
- return applyData;
- },
- FillMonths: function(data, len, step) {
- let applyData = [];
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let date = update("yyyy-MM-dd", d["v"]);
- date = (0, import_dayjs2.default)(date).add(step * i2, "months").format("YYYY-MM-DD");
- d["v"] = genarate(date)[2];
- d["m"] = update(d["ct"]["fa"], d["v"]);
- applyData.push(d);
- }
- return applyData;
- },
- FillYears: function(data, len, step) {
- let applyData = [];
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let date = update("yyyy-MM-dd", d["v"]);
- date = (0, import_dayjs2.default)(date).add(step * i2, "years").format("YYYY-MM-DD");
- d["v"] = genarate(date)[2];
- d["m"] = update(d["ct"]["fa"], d["v"]);
- applyData.push(d);
- }
- return applyData;
- },
- FillChnWeek: function(data, len, step) {
- let _this2 = this;
- let applyData = [];
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let num;
- if (data[data.length - 1]["m"] == "\u65E5") {
- num = 7 + step * i2;
- } else {
- num = _this2.ChineseToNumber(data[data.length - 1]["m"]) + step * i2;
- }
- if (num < 0) {
- num = Math.ceil(Math.abs(num) / 7) * 7 + num;
- }
- let rsd = num % 7;
- if (rsd == 0) {
- d["m"] = "\u65E5";
- d["v"] = "\u65E5";
- } else if (rsd == 1) {
- d["m"] = "\u4E00";
- d["v"] = "\u4E00";
- } else if (rsd == 2) {
- d["m"] = "\u4E8C";
- d["v"] = "\u4E8C";
- } else if (rsd == 3) {
- d["m"] = "\u4E09";
- d["v"] = "\u4E09";
- } else if (rsd == 4) {
- d["m"] = "\u56DB";
- d["v"] = "\u56DB";
- } else if (rsd == 5) {
- d["m"] = "\u4E94";
- d["v"] = "\u4E94";
- } else if (rsd == 6) {
- d["m"] = "\u516D";
- d["v"] = "\u516D";
- }
- applyData.push(d);
- }
- return applyData;
- },
- FillChnWeek2: function(data, len, step) {
- let _this2 = this;
- let applyData = [];
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let num;
- if (data[data.length - 1]["m"] == "\u5468\u65E5") {
- num = 7 + step * i2;
- } else {
- let last = data[data.length - 1]["m"];
- let txt = last.substr(last.length - 1, 1);
- num = _this2.ChineseToNumber(txt) + step * i2;
- }
- if (num < 0) {
- num = Math.ceil(Math.abs(num) / 7) * 7 + num;
- }
- let rsd = num % 7;
- if (rsd == 0) {
- d["m"] = "\u5468\u65E5";
- d["v"] = "\u5468\u65E5";
- } else if (rsd == 1) {
- d["m"] = "\u5468\u4E00";
- d["v"] = "\u5468\u4E00";
- } else if (rsd == 2) {
- d["m"] = "\u5468\u4E8C";
- d["v"] = "\u5468\u4E8C";
- } else if (rsd == 3) {
- d["m"] = "\u5468\u4E09";
- d["v"] = "\u5468\u4E09";
- } else if (rsd == 4) {
- d["m"] = "\u5468\u56DB";
- d["v"] = "\u5468\u56DB";
- } else if (rsd == 5) {
- d["m"] = "\u5468\u4E94";
- d["v"] = "\u5468\u4E94";
- } else if (rsd == 6) {
- d["m"] = "\u5468\u516D";
- d["v"] = "\u5468\u516D";
- }
- applyData.push(d);
- }
- return applyData;
- },
- FillChnWeek3: function(data, len, step) {
- let _this2 = this;
- let applyData = [];
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let num;
- if (data[data.length - 1]["m"] == "\u661F\u671F\u65E5") {
- num = 7 + step * i2;
- } else {
- let last = data[data.length - 1]["m"];
- let txt = last.substr(last.length - 1, 1);
- num = _this2.ChineseToNumber(txt) + step * i2;
- }
- if (num < 0) {
- num = Math.ceil(Math.abs(num) / 7) * 7 + num;
- }
- let rsd = num % 7;
- if (rsd == 0) {
- d["m"] = "\u661F\u671F\u65E5";
- d["v"] = "\u661F\u671F\u65E5";
- } else if (rsd == 1) {
- d["m"] = "\u661F\u671F\u4E00";
- d["v"] = "\u661F\u671F\u4E00";
- } else if (rsd == 2) {
- d["m"] = "\u661F\u671F\u4E8C";
- d["v"] = "\u661F\u671F\u4E8C";
- } else if (rsd == 3) {
- d["m"] = "\u661F\u671F\u4E09";
- d["v"] = "\u661F\u671F\u4E09";
- } else if (rsd == 4) {
- d["m"] = "\u661F\u671F\u56DB";
- d["v"] = "\u661F\u671F\u56DB";
- } else if (rsd == 5) {
- d["m"] = "\u661F\u671F\u4E94";
- d["v"] = "\u661F\u671F\u4E94";
- } else if (rsd == 6) {
- d["m"] = "\u661F\u671F\u516D";
- d["v"] = "\u661F\u671F\u516D";
- }
- applyData.push(d);
- }
- return applyData;
- },
- FillChnNumber: function(data, len, step) {
- let _this2 = this;
- let applyData = [];
- for (let i2 = 1; i2 <= len; i2++) {
- let index2 = (i2 - 1) % data.length;
- let d = $.extend(true, {}, data[index2]);
- let num = _this2.ChineseToNumber(data[data.length - 1]["m"]) + step * i2, txt;
- if (num <= 0) {
- txt = "\u96F6";
- } else {
- txt = _this2.NumberToChinese(num);
- }
- d["v"] = txt;
- d["m"] = txt.toString();
- applyData.push(d);
- }
- return applyData;
- },
- isEqualDiff: function(arr) {
- let diff2 = true;
- let step = arr[1] - arr[0];
- for (let i2 = 1; i2 < arr.length; i2++) {
- if (arr[i2] - arr[i2 - 1] != step) {
- diff2 = false;
- break;
- }
- }
- return diff2;
- },
- isEqualRatio: function(arr) {
- let ratio = true;
- let step = arr[1] / arr[0];
- for (let i2 = 1; i2 < arr.length; i2++) {
- if (arr[i2] / arr[i2 - 1] != step) {
- ratio = false;
- break;
- }
- }
- return ratio;
- },
- getXArr: function(len) {
- let xArr = [];
- for (let i2 = 1; i2 <= len; i2++) {
- xArr.push(i2);
- }
- return xArr;
- },
- forecast: function(x, yArr, xArr) {
- function getAverage(arr) {
- let sum = 0;
- for (let i2 = 0; i2 < arr.length; i2++) {
- sum += arr[i2];
- }
- return sum / arr.length;
- }
- let ax = getAverage(xArr);
- let ay = getAverage(yArr);
- let sum_d = 0, sum_n = 0;
- for (let j = 0; j < xArr.length; j++) {
- sum_d += (xArr[j] - ax) * (yArr[j] - ay);
- sum_n += (xArr[j] - ax) * (xArr[j] - ax);
- }
- let b;
- if (sum_n == 0) {
- b = 1;
- } else {
- b = sum_d / sum_n;
- }
- let a = ay - b * ax;
- return Math.round((a + b * x) * 1e5) / 1e5;
- },
- judgeDate: function(data) {
- let isSameDay = true, isSameMonth = true, isEqualDiffDays = true, isEqualDiffMonths = true, isEqualDiffYears = true;
- let sameDay = (0, import_dayjs2.default)(data[0]["m"]).date(), sameMonth = (0, import_dayjs2.default)(data[0]["m"]).month();
- let equalDiffDays = (0, import_dayjs2.default)(data[1]["m"]).diff((0, import_dayjs2.default)(data[0]["m"]), "days");
- let equalDiffMonths = (0, import_dayjs2.default)(data[1]["m"]).diff((0, import_dayjs2.default)(data[0]["m"]), "months");
- let equalDiffYears = (0, import_dayjs2.default)(data[1]["m"]).diff((0, import_dayjs2.default)(data[0]["m"]), "years");
- for (let i2 = 1; i2 < data.length; i2++) {
- if ((0, import_dayjs2.default)(data[i2]["m"]).date() != sameDay) {
- isSameDay = false;
- }
- if ((0, import_dayjs2.default)(data[i2]["m"]).month() != sameMonth) {
- isSameMonth = false;
- }
- if ((0, import_dayjs2.default)(data[i2]["m"]).diff((0, import_dayjs2.default)(data[i2 - 1]["m"]), "days") != equalDiffDays) {
- isEqualDiffDays = false;
- }
- if ((0, import_dayjs2.default)(data[i2]["m"]).diff((0, import_dayjs2.default)(data[i2 - 1]["m"]), "months") != equalDiffMonths) {
- isEqualDiffMonths = false;
- }
- if ((0, import_dayjs2.default)(data[i2]["m"]).diff((0, import_dayjs2.default)(data[i2 - 1]["m"]), "years") != equalDiffYears) {
- isEqualDiffYears = false;
- }
- }
- if (equalDiffDays == 0) {
- isEqualDiffDays = false;
- }
- if (equalDiffMonths == 0) {
- isEqualDiffMonths = false;
- }
- if (equalDiffYears == 0) {
- isEqualDiffYears = false;
- }
- return [isSameDay, isSameMonth, isEqualDiffDays, isEqualDiffMonths, isEqualDiffYears];
- }
- };
- dropCell_default = luckysheetDropCell;
- }
- });
-
- // src/controllers/freezen.js
- var luckysheetFreezen, freezen_default;
- var init_freezen = __esm({
- "src/controllers/freezen.js"() {
- init_get();
- init_sheetSearch();
- init_select();
- init_filter();
- init_server();
- init_menuButton();
- init_postil();
- init_dropCell();
- init_location();
- init_store();
- init_locale();
- init_refresh();
- luckysheetFreezen = {
- freezenHorizontalHTML: '
',
- freezenVerticalHTML: '
',
- initialHorizontal: true,
- initialVertical: true,
- horizontalmovestate: false,
- horizontalmoveposition: null,
- verticalmovestate: false,
- verticalmoveposition: null,
- windowHeight: null,
- windowWidth: null,
- freezenhorizontaldata: null,
- freezenverticaldata: null,
- freezenRealFirstRowColumn: true,
- cutVolumn: function(arr, cutindex) {
- if (cutindex <= 0) {
- return arr;
- }
- let pre = arr.slice(0, cutindex);
- let premax = pre[pre.length - 1];
- let ret = arr.slice(cutindex);
- return ret;
- },
- cancelFreezenVertical: function(sheetIndex) {
- let _this2 = this;
- const _locale = locale_default();
- const locale_freezen = _locale.freezen;
- const freezeHTML = `
-
- `;
- $("#luckysheet-freezen-btn-horizontal").html(freezeHTML);
- $("#luckysheet-freezen-btn-vertical").html('
' + locale_freezen.freezenColumn);
- _this2.freezenverticaldata = null;
- let isvertical = $("#luckysheet-freezebar-vertical").is(":visible");
- $("#luckysheet-freezebar-vertical").hide();
- if (sheetIndex == null) {
- sheetIndex = store_default.currentSheetIndex;
- }
- let currentSheet = store_default.luckysheetfile[getSheetIndex(sheetIndex)];
- if (currentSheet.freezen != null) {
- currentSheet.freezen.vertical = null;
- }
- if (currentSheet.frozen != null && isvertical) {
- server_default.saveParam("all", sheetIndex, currentSheet.frozen, {"k": "frozen"});
- }
- },
- createFreezenVertical: function(freezenverticaldata, left) {
- let _this2 = this;
- if (_this2.initialVertical) {
- _this2.initialVertical = false;
- $("#luckysheet-grid-window-1").append(_this2.freezenVerticalHTML);
- $("#luckysheet-freezebar-vertical").find(".luckysheet-freezebar-vertical-drop").hover(function() {
- $(this).parent().addClass("luckysheet-freezebar-hover");
- }, function() {
- $(this).parent().removeClass("luckysheet-freezebar-hover");
- });
- $("#luckysheet-freezebar-vertical").find(".luckysheet-freezebar-vertical-drop").mousedown(function() {
- _this2.verticalmovestate = true;
- _this2.verticalmoveposition = $(this).position().left;
- _this2.windowWidth = $("#luckysheet-grid-window-1").width();
- $(this).parent().addClass("luckysheet-freezebar-active");
- $("#luckysheet-freezebar-vertical").find(".luckysheet-freezebar-vertical-handle").css("cursor", "-webkit-grabbing");
- });
- let gridheight = $("#luckysheet-grid-window-1").height();
- $("#luckysheet-freezebar-vertical").find(".luckysheet-freezebar-vertical-handle").css({
- "height": gridheight - 10,
- "width": "4px",
- "cursor": "-webkit-grab",
- "top": "0px"
- }).end().find(".luckysheet-freezebar-vertical-drop").css({
- "height": gridheight - 10,
- "width": "4px",
- "top": "0px",
- "cursor": "-webkit-grab"
- });
- }
- if (freezenverticaldata == null) {
- if (_this2.freezenRealFirstRowColumn) {
- let dataset_col_st = 0;
- left = store_default.visibledatacolumn[dataset_col_st] - 2 + store_default.rowHeaderWidth;
- freezenverticaldata = [
- store_default.visibledatacolumn[dataset_col_st],
- dataset_col_st + 1,
- 0,
- _this2.cutVolumn(store_default.visibledatacolumn, dataset_col_st + 1),
- left
- ];
- } else {
- let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
- let dataset_col_st = luckysheet_searcharray(store_default.visibledatacolumn, scrollLeft);
- if (dataset_col_st == -1) {
- dataset_col_st = 0;
- }
- left = store_default.visibledatacolumn[dataset_col_st] - 2 - scrollLeft + store_default.rowHeaderWidth;
- freezenverticaldata = [
- store_default.visibledatacolumn[dataset_col_st],
- dataset_col_st + 1,
- scrollLeft,
- _this2.cutVolumn(store_default.visibledatacolumn, dataset_col_st + 1),
- left
- ];
- }
- _this2.saveFreezen(null, null, freezenverticaldata, left);
- }
- _this2.freezenverticaldata = freezenverticaldata;
- const freezeHTML = `
-
- `;
- $("#luckysheet-freezen-btn-horizontal").html(freezeHTML);
- $("#luckysheet-freezebar-vertical").show().find(".luckysheet-freezebar-vertical-handle").css({"left": left}).end().find(".luckysheet-freezebar-vertical-drop").css({"left": left});
- },
- saveFreezen: function(freezenhorizontaldata, top, freezenverticaldata, left) {
- let currentSheet = store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)];
- if (currentSheet.freezen == null) {
- currentSheet.freezen = {};
- }
- if (freezenhorizontaldata != null) {
- if (currentSheet.freezen.horizontal == null) {
- currentSheet.freezen.horizontal = {};
- }
- currentSheet.freezen.horizontal.freezenhorizontaldata = freezenhorizontaldata;
- currentSheet.freezen.horizontal.top = top;
- }
- if (freezenverticaldata != null) {
- if (currentSheet.freezen.vertical == null) {
- currentSheet.freezen.vertical = {};
- }
- currentSheet.freezen.vertical.freezenverticaldata = freezenverticaldata;
- currentSheet.freezen.vertical.left = left;
- }
- if (currentSheet.frozen != null) {
- server_default.saveParam("all", store_default.currentSheetIndex, currentSheet.frozen, {"k": "frozen"});
- }
- },
- initialFreezen: function(sheetIndex) {
- let _this2 = this;
- _this2.frozenTofreezen();
- let currentSheet = store_default.luckysheetfile[getSheetIndex(sheetIndex)];
- if (currentSheet.freezen != null && currentSheet.freezen.horizontal != null && currentSheet.freezen.horizontal.freezenhorizontaldata != null) {
- _this2.createFreezenHorizontal(currentSheet.freezen.horizontal.freezenhorizontaldata, currentSheet.freezen.horizontal.top);
- } else {
- _this2.cancelFreezenHorizontal(sheetIndex);
- }
- if (currentSheet.freezen != null && currentSheet.freezen.vertical != null && currentSheet.freezen.vertical.freezenverticaldata != null) {
- _this2.createFreezenVertical(currentSheet.freezen.vertical.freezenverticaldata, currentSheet.freezen.vertical.left);
- } else {
- _this2.cancelFreezenVertical(sheetIndex);
- }
- _this2.createAssistCanvas();
- },
- changeFreezenIndex: function(originindex, type) {
- let _this2 = this;
- if (type == "v" && _this2.freezenverticaldata != null) {
- let freezen_colindex = _this2.freezenverticaldata[1];
- let offset = luckysheet_searcharray(store_default.visibledatacolumn, $("#luckysheet-cell-main").scrollLeft());
- if (originindex - offset < freezen_colindex) {
- originindex = originindex - offset;
- }
- } else if (type == "h" && _this2.freezenhorizontaldata != null) {
- let freezen_rowindex = _this2.freezenhorizontaldata[1];
- let offset = luckysheet_searcharray(store_default.visibledatarow, $("#luckysheet-cell-main").scrollTop());
- if (originindex - offset < freezen_rowindex) {
- originindex = originindex - offset;
- }
- }
- return originindex;
- },
- scrollFreezen: function() {
- let _this2 = this;
- let row;
- let row_focus = store_default.luckysheet_select_save[0]["row_focus"];
- if (row_focus == store_default.luckysheet_select_save[0]["row"][0]) {
- row = store_default.luckysheet_select_save[0]["row"][1];
- } else if (row_focus == store_default.luckysheet_select_save[0]["row"][1]) {
- row = store_default.luckysheet_select_save[0]["row"][0];
- }
- let column;
- let column_focus = store_default.luckysheet_select_save[0]["column_focus"];
- if (column_focus == store_default.luckysheet_select_save[0]["column"][0]) {
- column = store_default.luckysheet_select_save[0]["column"][1];
- } else if (column_focus == store_default.luckysheet_select_save[0]["column"][1]) {
- column = store_default.luckysheet_select_save[0]["column"][0];
- }
- if (_this2.freezenverticaldata != null) {
- let freezen_colindex = _this2.freezenverticaldata[1];
- let offset = luckysheet_searcharray(_this2.freezenverticaldata[3], $("#luckysheet-cell-main").scrollLeft());
- let top = _this2.freezenverticaldata[4];
- freezen_colindex += offset;
- if (column >= store_default.visibledatacolumn.length) {
- column = store_default.visibledatacolumn.length - 1;
- }
- if (freezen_colindex >= store_default.visibledatacolumn.length) {
- freezen_colindex = store_default.visibledatacolumn.length - 1;
- }
- let column_px = store_default.visibledatacolumn[column], freezen_px = store_default.visibledatacolumn[freezen_colindex];
- if (column_px <= freezen_px + top) {
- setTimeout(function() {
- $("#luckysheet-scrollbar-x").scrollLeft(0);
- }, 100);
- }
- }
- if (_this2.freezenhorizontaldata != null) {
- let freezen_rowindex = _this2.freezenhorizontaldata[1];
- let offset = luckysheet_searcharray(_this2.freezenhorizontaldata[3], $("#luckysheet-cell-main").scrollTop());
- let left = _this2.freezenhorizontaldata[4];
- freezen_rowindex += offset;
- if (row >= store_default.visibledatarow.length) {
- row = store_default.visibledatarow.length - 1;
- }
- if (freezen_rowindex >= store_default.visibledatarow.length) {
- freezen_rowindex = store_default.visibledatarow.length - 1;
- }
- let row_px = store_default.visibledatarow[row], freezen_px = store_default.visibledatarow[freezen_rowindex];
- if (row_px <= freezen_px + left) {
- setTimeout(function() {
- $("#luckysheet-scrollbar-y").scrollTop(0);
- }, 100);
- }
- }
- },
- cancelFreezenHorizontal: function(sheetIndex) {
- let _this2 = this;
- const freezeHTML = `
-
- `;
- $("#luckysheet-freezen-btn-horizontal").html(freezeHTML);
- _this2.freezenhorizontaldata = null;
- let ishorizontal = $("#luckysheet-freezebar-horizontal").is(":visible");
- $("#luckysheet-freezebar-horizontal").hide();
- if (sheetIndex == null) {
- sheetIndex = store_default.currentSheetIndex;
- }
- let currentSheet = store_default.luckysheetfile[getSheetIndex(sheetIndex)];
- if (currentSheet.freezen != null) {
- currentSheet.freezen.horizontal = null;
- }
- if (currentSheet.frozen != null && ishorizontal) {
- server_default.saveParam("all", sheetIndex, currentSheet.frozen, {"k": "frozen"});
- }
- },
- createFreezenHorizontal: function(freezenhorizontaldata, top) {
- let _this2 = this;
- if (_this2.initialHorizontal) {
- _this2.initialHorizontal = false;
- $("#luckysheet-grid-window-1").append(_this2.freezenHorizontalHTML);
- $("#luckysheet-freezebar-horizontal").find(".luckysheet-freezebar-horizontal-drop").hover(function() {
- $(this).parent().addClass("luckysheet-freezebar-hover");
- }, function() {
- $(this).parent().removeClass("luckysheet-freezebar-hover");
- });
- $("#luckysheet-freezebar-horizontal").find(".luckysheet-freezebar-horizontal-drop").mousedown(function() {
- _this2.horizontalmovestate = true;
- _this2.horizontalmoveposition = $(this).position().top;
- _this2.windowHeight = $("#luckysheet-grid-window-1").height();
- $(this).parent().addClass("luckysheet-freezebar-active");
- $("#luckysheet-freezebar-horizontal").find(".luckysheet-freezebar-horizontal-handle").css("cursor", "-webkit-grabbing");
- });
- let gridwidth = $("#luckysheet-grid-window-1").width();
- $("#luckysheet-freezebar-horizontal").find(".luckysheet-freezebar-horizontal-handle").css({
- "width": gridwidth - 10,
- "height": "4px",
- "cursor": "-webkit-grab",
- "left": "0px"
- }).end().find(".luckysheet-freezebar-horizontal-drop").css({
- "width": gridwidth - 10,
- "height": "4px",
- "left": "0px",
- "cursor": "-webkit-grab"
- });
- }
- if (freezenhorizontaldata == null) {
- let dataset_row_st;
- if (_this2.freezenRealFirstRowColumn) {
- dataset_row_st = 0;
- top = store_default.visibledatarow[dataset_row_st] - 2 + store_default.columnHeaderHeight;
- freezenhorizontaldata = [
- store_default.visibledatarow[dataset_row_st],
- dataset_row_st + 1,
- 0,
- _this2.cutVolumn(store_default.visibledatarow, dataset_row_st + 1),
- top
- ];
- _this2.saveFreezen(freezenhorizontaldata, top, null, null);
- setTimeout(() => {
- luckysheetFreezen.createAssistCanvas();
- luckysheetrefreshgrid();
- });
- } else {
- let scrollTop = $("#luckysheet-cell-main").scrollTop();
- dataset_row_st = luckysheet_searcharray(store_default.visibledatarow, scrollTop);
- if (dataset_row_st == -1) {
- dataset_row_st = 0;
- }
- top = store_default.visibledatarow[dataset_row_st] - 2 - scrollTop + store_default.columnHeaderHeight;
- freezenhorizontaldata = [
- store_default.visibledatarow[dataset_row_st],
- dataset_row_st + 1,
- scrollTop,
- _this2.cutVolumn(store_default.visibledatarow, dataset_row_st + 1),
- top
- ];
- _this2.saveFreezen(freezenhorizontaldata, top, null, null);
- }
- }
- _this2.freezenhorizontaldata = freezenhorizontaldata;
- const freezeHTML = `
-
- `;
- $("#luckysheet-freezen-btn-horizontal").html(freezeHTML);
- $("#luckysheet-freezebar-horizontal").show().find(".luckysheet-freezebar-horizontal-handle").css({"top": top}).end().find(".luckysheet-freezebar-horizontal-drop").css({"top": top});
- },
- createAssistCanvas: function() {
- let _this2 = this;
- _this2.removeAssistCanvas();
- if (_this2.freezenverticaldata != null || _this2.freezenhorizontaldata != null) {
- let freezen_horizon_px, freezen_horizon_ed, freezen_horizon_scrollTop;
- let freezen_vertical_px, freezen_vertical_ed, freezen_vertical_scrollTop;
- let drawWidth = store_default.luckysheetTableContentHW[0], drawHeight = store_default.luckysheetTableContentHW[1];
- if (_this2.freezenverticaldata != null && _this2.freezenhorizontaldata != null) {
- freezen_horizon_px = _this2.freezenhorizontaldata[0];
- freezen_horizon_ed = _this2.freezenhorizontaldata[1];
- freezen_horizon_scrollTop = _this2.freezenhorizontaldata[2];
- freezen_vertical_px = _this2.freezenverticaldata[0];
- freezen_vertical_ed = _this2.freezenverticaldata[1];
- freezen_vertical_scrollTop = _this2.freezenverticaldata[2];
- _this2.createCanvas("freezen_3", freezen_vertical_px - freezen_vertical_scrollTop, freezen_horizon_px - freezen_horizon_scrollTop + 1, store_default.rowHeaderWidth - 1, store_default.columnHeaderHeight - 1);
- _this2.createCanvas("freezen_4", drawWidth - freezen_vertical_px + freezen_vertical_scrollTop, freezen_horizon_px - freezen_horizon_scrollTop + 1, freezen_vertical_px - freezen_vertical_scrollTop + store_default.rowHeaderWidth - 1, store_default.columnHeaderHeight - 1);
- _this2.createCanvas("freezen_7", freezen_vertical_px - freezen_vertical_scrollTop, drawHeight - freezen_horizon_px + freezen_horizon_scrollTop - store_default.columnHeaderHeight, store_default.rowHeaderWidth - 1, freezen_horizon_px - freezen_horizon_scrollTop + store_default.columnHeaderHeight - 1);
- } else if (_this2.freezenhorizontaldata != null) {
- freezen_horizon_px = _this2.freezenhorizontaldata[0];
- freezen_horizon_ed = _this2.freezenhorizontaldata[1];
- freezen_horizon_scrollTop = _this2.freezenhorizontaldata[2];
- _this2.createCanvas("freezen_h", drawWidth, freezen_horizon_px - freezen_horizon_scrollTop + 1, store_default.rowHeaderWidth - 1, store_default.columnHeaderHeight - 1);
- } else if (_this2.freezenverticaldata != null) {
- freezen_vertical_px = _this2.freezenverticaldata[0];
- freezen_vertical_ed = _this2.freezenverticaldata[1];
- freezen_vertical_scrollTop = _this2.freezenverticaldata[2];
- _this2.createCanvas("freezen_v", freezen_vertical_px - freezen_vertical_scrollTop, drawHeight, store_default.rowHeaderWidth - 1, store_default.columnHeaderHeight - 1);
- }
- _this2.scrollAdapt();
- }
- },
- createCanvas: function(id, width, height, left, top) {
- let c2 = $("
").appendTo("#luckysheet-grid-window-1").attr({
- "id": id,
- "width": Math.ceil(width * store_default.devicePixelRatio),
- "height": Math.ceil(height * store_default.devicePixelRatio)
- }).css({
- "user-select": "none",
- "postion": "absolute",
- "left": left,
- "top": top,
- "width": width,
- "height": height,
- "z-index": 10,
- "pointer-events": "none"
- });
- },
- removeAssistCanvas: function() {
- $("#luckysheet-grid-window-1 > canvas").not($("#luckysheetTableContent")).remove();
- $("#luckysheet-cell-selected").css("z-index", 15);
- },
- scrollAdapt: function() {
- let _this2 = this;
- if (store_default.luckysheet_select_save != null && store_default.luckysheet_select_save.length > 0) {
- _this2.scrollAdaptOfselect();
- }
- if ($(".luckysheet-modal-dialog-image").length > 0 && imageCtrl.images != void 0) {
- _this2.scrollAdaptOfImage();
- }
- if ($("#luckysheet-cell-main .luckysheet-data-visualization-chart").length > 0) {
- const chart2 = store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)]["chart"];
- if (chart2 != null && chart2.length > 0) {
- _this2.scrollAdaptOfchart();
- }
- }
- if ($("#luckysheet-postil-showBoxs .luckysheet-postil-show").length > 0) {
- _this2.scrollAdaptOfpostil();
- }
- if ($("#luckysheet-dropCell-icon").length > 0) {
- _this2.scrollAdaptOfdpicon();
- }
- if ($("#luckysheet-filter-options-sheet" + store_default.currentSheetIndex + " .luckysheet-filter-options").length > 0) {
- _this2.scrollAdaptOffilteroptions();
- }
- },
- scrollAdaptOfselect: function() {
- let _this2 = this;
- if ($("#luckysheet-row-count-show").is(":visible")) {
- $("#luckysheet-row-count-show").hide();
- }
- if ($("#luckysheet-column-count-show").is(":visible")) {
- $("#luckysheet-column-count-show").hide();
- }
- $("#luckysheet-rows-h-selected").empty();
- $("#luckysheet-cols-h-selected").empty();
- let scrollTop = $("#luckysheet-cell-main").scrollTop();
- let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
- if (_this2.freezenhorizontaldata != null && _this2.freezenverticaldata != null) {
- let freezenTop = _this2.freezenhorizontaldata[0];
- let freezen_rowindex = _this2.freezenhorizontaldata[1];
- let offTop = scrollTop - _this2.freezenhorizontaldata[2];
- let freezenLeft = _this2.freezenverticaldata[0];
- let freezen_colindex = _this2.freezenverticaldata[1];
- let offLeft = scrollLeft - _this2.freezenverticaldata[2];
- for (let s = 0; s < store_default.luckysheet_select_save.length; s++) {
- let obj = $.extend(true, {}, store_default.luckysheet_select_save[s]);
- let r1 = obj.row[0], r2 = obj.row[1];
- let row = store_default.visibledatarow[r2], row_pre = r1 - 1 == -1 ? 0 : store_default.visibledatarow[r1 - 1];
- let top_move = row_pre;
- let height_move = row - row_pre - 1;
- let rangeshow = true;
- if (r1 >= freezen_rowindex) {
- if (top_move + height_move < freezenTop + offTop) {
- rangeshow = false;
- } else if (top_move < freezenTop + offTop) {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css({
- "top": freezenTop + offTop,
- "height": height_move - (freezenTop + offTop - top_move)
- });
- } else {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css({
- "top": top_move,
- "height": height_move
- });
- }
- } else if (r2 >= freezen_rowindex) {
- if (top_move + height_move < freezenTop + offTop) {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css({
- "top": top_move + offTop,
- "height": freezenTop - top_move
- });
- } else {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css({
- "top": top_move + offTop,
- "height": height_move - offTop
- });
- }
- } else {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css("top", top_move + offTop);
- }
- let c1 = obj.column[0], c2 = obj.column[1];
- let col = store_default.visibledatacolumn[c2], col_pre = c1 - 1 == -1 ? 0 : store_default.visibledatacolumn[c1 - 1];
- let left_move = col_pre;
- let width_move = col - col_pre - 1;
- if (c1 >= freezen_colindex) {
- if (left_move + width_move < freezenLeft + offLeft) {
- rangeshow = false;
- } else if (left_move < freezenLeft + offLeft) {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css({
- "left": freezenLeft + offLeft,
- "width": width_move - (freezenLeft + offLeft - left_move)
- });
- } else {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css({
- "left": left_move,
- "width": width_move
- });
- }
- } else if (c2 >= freezen_colindex) {
- if (left_move + width_move < freezenLeft + offLeft) {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css({
- "left": left_move + offLeft,
- "width": freezenLeft - left_move
- });
- } else {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css({
- "left": left_move + offLeft,
- "width": width_move - offLeft
- });
- }
- } else {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css("left", left_move + offLeft);
- }
- if (!rangeshow) {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).hide();
- }
- if (s == store_default.luckysheet_select_save.length - 1) {
- let rf = obj.row_focus == null ? r1 : obj.row_focus;
- let cf = obj.column_focus == null ? c1 : obj.column_focus;
- let row_f = store_default.visibledatarow[rf], row_pre_f = rf - 1 == -1 ? 0 : store_default.visibledatarow[rf - 1];
- let col_f = store_default.visibledatacolumn[cf], col_pre_f = cf - 1 == -1 ? 0 : store_default.visibledatacolumn[cf - 1];
- let margeset = menuButton_default.mergeborer(store_default.flowdata, rf, cf);
- if (!!margeset) {
- row_f = margeset.row[1];
- row_pre_f = margeset.row[0];
- col_f = margeset.column[1];
- col_pre_f = margeset.column[0];
- }
- let top = row_pre_f;
- let height = row_f - row_pre_f - 1;
- let left = col_pre_f;
- let width = col_f - col_pre_f - 1;
- let focuscell = true;
- if (top >= freezenTop) {
- if (top + height < freezenTop + offTop) {
- focuscell = false;
- } else if (top < freezenTop + offTop) {
- $("#luckysheet-cell-selected-focus").show().css({
- "top": freezenTop + offTop,
- "height": height - (freezenTop + offTop - top)
- });
- } else {
- $("#luckysheet-cell-selected-focus").show().css({
- "top": top,
- "height": height
- });
- }
- } else if (top + height >= freezenTop) {
- if (top + height < freezenTop + offTop) {
- $("#luckysheet-cell-selected-focus").show().css({
- "top": top + offTop,
- "height": freezenTop - top
- });
- } else {
- $("#luckysheet-cell-selected-focus").show().css({
- "top": top + offTop,
- "height": height - offTop
- });
- }
- } else {
- $("#luckysheet-cell-selected-focus").show().css("top", top + offTop);
- }
- if (left >= freezenLeft) {
- if (left + width < freezenLeft + offLeft) {
- focuscell = false;
- } else if (left < freezenLeft + offLeft) {
- $("#luckysheet-cell-selected-focus").show().css({
- "left": freezenLeft + offLeft,
- "width": width - (freezenLeft + offLeft - left)
- });
- } else {
- $("#luckysheet-cell-selected-focus").show().css({
- "left": left,
- "width": width
- });
- }
- } else if (left + width >= freezenLeft) {
- if (left + width < freezenLeft + offLeft) {
- $("#luckysheet-cell-selected-focus").show().css({
- "left": left + offLeft,
- "width": freezenLeft - left
- });
- } else {
- $("#luckysheet-cell-selected-focus").show().css({
- "left": left + offLeft,
- "width": width - offLeft
- });
- }
- } else {
- $("#luckysheet-cell-selected-focus").show().css("left", left + offLeft);
- }
- if (!focuscell) {
- $("#luckysheet-cell-selected-focus").hide();
- }
- }
- }
- } else if (_this2.freezenhorizontaldata != null) {
- let freezenTop = _this2.freezenhorizontaldata[0];
- let freezen_rowindex = _this2.freezenhorizontaldata[1];
- let offTop = scrollTop - _this2.freezenhorizontaldata[2];
- for (let s = 0; s < store_default.luckysheet_select_save.length; s++) {
- let obj = $.extend(true, {}, store_default.luckysheet_select_save[s]);
- let r1 = obj.row[0], r2 = obj.row[1];
- let row = store_default.visibledatarow[r2], row_pre = r1 - 1 == -1 ? 0 : store_default.visibledatarow[r1 - 1];
- let top_move = row_pre;
- let height_move = row - row_pre - 1;
- if (r1 >= freezen_rowindex) {
- if (top_move + height_move < freezenTop + offTop) {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).hide();
- } else if (top_move < freezenTop + offTop) {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css({
- "top": freezenTop + offTop,
- "height": height_move - (freezenTop + offTop - top_move)
- });
- } else {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css({
- "top": top_move,
- "height": height_move
- });
- }
- } else if (r2 >= freezen_rowindex) {
- if (top_move + height_move < freezenTop + offTop) {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css({
- "top": top_move + offTop,
- "height": freezenTop - top_move
- });
- } else {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css({
- "top": top_move + offTop,
- "height": height_move - offTop
- });
- }
- } else {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css("top", top_move + offTop);
- }
- if (s == store_default.luckysheet_select_save.length - 1) {
- let rf = obj.row_focus == null ? r1 : obj.row_focus;
- let cf = obj.column_focus == null ? obj.column[0] : obj.column_focus;
- let row_f = store_default.visibledatarow[rf], row_pre_f = rf - 1 == -1 ? 0 : store_default.visibledatarow[rf - 1];
- let margeset = menuButton_default.mergeborer(store_default.flowdata, rf, cf);
- if (!!margeset) {
- row_f = margeset.row[1];
- row_pre_f = margeset.row[0];
- }
- let top = row_pre_f;
- let height = row_f - row_pre_f - 1;
- if (top >= freezenTop) {
- if (top + height < freezenTop + offTop) {
- $("#luckysheet-cell-selected-focus").hide();
- } else if (top < freezenTop + offTop) {
- $("#luckysheet-cell-selected-focus").show().css({
- "top": freezenTop + offTop,
- "height": height - (freezenTop + offTop - top)
- });
- } else {
- $("#luckysheet-cell-selected-focus").show().css({
- "top": top,
- "height": height
- });
- }
- } else if (top + height >= freezenTop) {
- if (top + height < freezenTop + offTop) {
- $("#luckysheet-cell-selected-focus").show().css({
- "top": top + offTop,
- "height": freezenTop - top
- });
- } else {
- $("#luckysheet-cell-selected-focus").show().css({
- "top": top + offTop,
- "height": height - offTop
- });
- }
- } else {
- $("#luckysheet-cell-selected-focus").show().css("top", top + offTop);
- }
- }
- }
- } else if (_this2.freezenverticaldata != null) {
- let freezenLeft = _this2.freezenverticaldata[0];
- let freezen_colindex = _this2.freezenverticaldata[1];
- let offLeft = scrollLeft - _this2.freezenverticaldata[2];
- for (let s = 0; s < store_default.luckysheet_select_save.length; s++) {
- let obj = $.extend(true, {}, store_default.luckysheet_select_save[s]);
- let c1 = obj.column[0], c2 = obj.column[1];
- let col = store_default.visibledatacolumn[c2], col_pre = c1 - 1 == -1 ? 0 : store_default.visibledatacolumn[c1 - 1];
- let left_move = col_pre;
- let width_move = col - col_pre - 1;
- if (c1 >= freezen_colindex) {
- if (left_move + width_move < freezenLeft + offLeft) {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).hide();
- } else if (left_move < freezenLeft + offLeft) {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css({
- "left": freezenLeft + offLeft,
- "width": width_move - (freezenLeft + offLeft - left_move)
- });
- } else {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css({
- "left": left_move,
- "width": width_move
- });
- }
- } else if (c2 >= freezen_colindex) {
- if (left_move + width_move < freezenLeft + offLeft) {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css({
- "left": left_move + offLeft,
- "width": freezenLeft - left_move
- });
- } else {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css({
- "left": left_move + offLeft,
- "width": width_move - offLeft
- });
- }
- } else {
- $("#luckysheet-cell-selected-boxs").find(".luckysheet-cell-selected").eq(s).show().css("left", left_move + offLeft);
- }
- if (s == store_default.luckysheet_select_save.length - 1) {
- let rf = obj.row_focus == null ? obj.row[0] : obj.row_focus;
- let cf = obj.column_focus == null ? c1 : obj.column_focus;
- let col_f = store_default.visibledatacolumn[cf], col_pre_f = cf - 1 == -1 ? 0 : store_default.visibledatacolumn[cf - 1];
- let margeset = menuButton_default.mergeborer(store_default.flowdata, rf, cf);
- if (!!margeset) {
- col_f = margeset.column[1];
- col_pre_f = margeset.column[0];
- }
- let left = col_pre_f;
- let width = col_f - col_pre_f - 1;
- if (left >= freezenLeft) {
- if (left + width < freezenLeft + offLeft) {
- $("#luckysheet-cell-selected-focus").hide();
- } else if (left < freezenLeft + offLeft) {
- $("#luckysheet-cell-selected-focus").show().css({
- "left": freezenLeft + offLeft,
- "width": width - (freezenLeft + offLeft - left)
- });
- } else {
- $("#luckysheet-cell-selected-focus").show().css({
- "left": left,
- "width": width
- });
- }
- } else if (left + width >= freezenLeft) {
- if (left + width < freezenLeft + offLeft) {
- $("#luckysheet-cell-selected-focus").show().css({
- "left": left + offLeft,
- "width": freezenLeft - left
- });
- } else {
- $("#luckysheet-cell-selected-focus").show().css({
- "left": left + offLeft,
- "width": width - offLeft
- });
- }
- } else {
- $("#luckysheet-cell-selected-focus").show().css("left", left + offLeft);
- }
- }
- }
- } else {
- selectHightlightShow();
- }
- },
- scrollAdaptOfImage: function() {
- let _this2 = this;
- var images = imageCtrl.images;
- let scrollTop = $("#luckysheet-cell-main").scrollTop();
- let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
- let freezenTop = _this2.freezenhorizontaldata != null ? _this2.freezenhorizontaldata[0] - _this2.freezenhorizontaldata[2] : -1;
- let freezenLeft = _this2.freezenverticaldata != null ? _this2.freezenverticaldata[0] - _this2.freezenverticaldata[2] : -1;
- let zoomRatio = store_default.zoomRatio;
- $.each(images, function(i2) {
- let image = images[i2];
- let dialogImage = $("#" + i2);
- let x = dialogImage.position();
- let width = dialogImage.width();
- let height = dialogImage.height();
- let defaultTop = image.default.top * zoomRatio;
- let defaultLeft = image.default.left * zoomRatio;
- let isHidden = false;
- if (defaultTop >= freezenTop) {
- if (x.top < freezenTop) {
- dialogImage.css("visibility", "hidden");
- isHidden = true;
- } else {
- dialogImage.css({
- "visibility": "visible"
- });
- }
- } else {
- dialogImage.css({
- "top": defaultTop + scrollTop,
- "height": height,
- "visibility": "visible"
- });
- }
- if (!isHidden) {
- if (defaultLeft >= freezenLeft) {
- if (x.left < freezenLeft) {
- dialogImage.css("visibility", "hidden");
- } else {
- dialogImage.css({
- "visibility": "visible"
- });
- }
- } else {
- dialogImage.css({
- "left": defaultLeft + scrollLeft,
- "width": width,
- "visibility": "visible"
- });
- }
- }
- });
- },
- scrollAdaptOfchart: function() {
- let _this2 = this;
- let scrollTop = $("#luckysheet-cell-main").scrollTop();
- let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
- if (_this2.freezenhorizontaldata != null && _this2.freezenverticaldata != null) {
- let freezenTop = _this2.freezenhorizontaldata[0] - _this2.freezenhorizontaldata[2];
- let freezenLeft = _this2.freezenverticaldata[0] - _this2.freezenverticaldata[2];
- $("#luckysheet-cell-main .luckysheet-data-visualization-chart").each(function(i2, e) {
- let x = $(e).position();
- let width = $(e).width();
- let height = $(e).height();
- let $canvas_width = $(e).find("canvas").width();
- let $canvas_height = $(e).find("canvas").height();
- let height_diff = $canvas_height - height;
- let width_diff = $canvas_width - width;
- if (x.top - height_diff < freezenTop) {
- let size = freezenTop - (x.top - height_diff);
- if (size > $canvas_height + 40 + 2) {
- $(e).css("visibility", "hidden");
- } else {
- $(e).css({
- "top": freezenTop + scrollTop,
- "height": $canvas_height - size,
- "visibility": "visible"
- });
- $(e).find("canvas").css("top", -size);
- }
- } else {
- $(e).css({
- "top": x.top - height_diff + scrollTop,
- "height": $canvas_height,
- "visibility": "visible"
- });
- $(e).find("canvas").css("top", 0);
- }
- if (x.left - width_diff < freezenLeft) {
- let size = freezenLeft - (x.left - width_diff);
- if (size > $canvas_width + 20 + 2) {
- $(e).css("visibility", "hidden");
- } else {
- $(e).css({
- "left": freezenLeft + scrollLeft,
- "width": $canvas_width - size,
- "visibility": "visible"
- });
- $(e).find("canvas").css("left", -size);
- }
- } else {
- $(e).css({
- "left": x.left - width_diff + scrollLeft,
- "width": $canvas_width,
- "visibility": "visible"
- });
- $(e).find("canvas").css("left", 0);
- }
- });
- } else if (_this2.freezenhorizontaldata != null) {
- let freezenTop = _this2.freezenhorizontaldata[0] - _this2.freezenhorizontaldata[2];
- $("#luckysheet-cell-main .luckysheet-data-visualization-chart").each(function(i2, e) {
- let x = $(e).position();
- let height = $(e).height();
- let $canvas_height = $(e).find("canvas").height();
- let height_diff = $canvas_height - height;
- if (x.top - height_diff < freezenTop) {
- let size = freezenTop - (x.top - height_diff);
- if (size > $canvas_height + 40 + 2) {
- $(e).css("visibility", "hidden");
- } else {
- $(e).css({
- "top": freezenTop + scrollTop,
- "height": $canvas_height - size,
- "visibility": "visible"
- });
- $(e).find("canvas").css("top", -size);
- }
- } else {
- $(e).css({
- "top": x.top - height_diff + scrollTop,
- "height": $canvas_height,
- "visibility": "visible"
- });
- $(e).find("canvas").css("top", 0);
- }
- });
- } else if (_this2.freezenverticaldata != null) {
- let freezenLeft = _this2.freezenverticaldata[0] - _this2.freezenverticaldata[2];
- $("#luckysheet-cell-main .luckysheet-data-visualization-chart").each(function(i2, e) {
- let x = $(e).position();
- let width = $(e).width();
- let $canvas_width = $(e).find("canvas").width();
- let width_diff = $canvas_width - width;
- if (x.left - width_diff < freezenLeft) {
- let size = freezenLeft - (x.left - width_diff);
- if (size > $canvas_width + 20 + 2) {
- $(e).css("visibility", "hidden");
- } else {
- $(e).css({
- "left": freezenLeft + scrollLeft,
- "width": $canvas_width - size,
- "visibility": "visible"
- });
- $(e).find("canvas").css("left", -size);
- }
- } else {
- $(e).css({
- "left": x.left - width_diff + scrollLeft,
- "width": $canvas_width,
- "visibility": "visible"
- });
- $(e).find("canvas").css("left", 0);
- }
- });
- } else {
- $("#luckysheet-cell-main .luckysheet-data-visualization-chart").each(function(i2, e) {
- let x = $(e).position();
- let width = $(e).width();
- let height = $(e).height();
- let $canvas_width = $(e).find("canvas").width();
- let $canvas_height = $(e).find("canvas").height();
- let height_diff = $canvas_height - height;
- let width_diff = $canvas_width - width;
- $(e).css({
- "top": x.top - height_diff + scrollTop,
- "height": $canvas_height,
- "left": x.left - width_diff + scrollLeft,
- "width": $canvas_width,
- "visibility": "visible"
- });
- $(e).find("canvas").css({
- "top": 0,
- "left": 0
- });
- });
- }
- },
- scrollAdaptOfpostil: function() {
- let _this2 = this;
- let scrollTop = $("#luckysheet-cell-main").scrollTop();
- let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
- if (_this2.freezenhorizontaldata != null && _this2.freezenverticaldata != null) {
- let freezenTop = _this2.freezenhorizontaldata[0];
- let freezenLeft = _this2.freezenverticaldata[0];
- let offTop = scrollTop - _this2.freezenhorizontaldata[2];
- let offLeft = scrollLeft - _this2.freezenverticaldata[2];
- $("#luckysheet-postil-showBoxs .luckysheet-postil-show").each(function(i2, e) {
- let id = $(e).attr("id");
- let r2 = id.split("luckysheet-postil-show_")[1].split("_")[0];
- let c2 = id.split("luckysheet-postil-show_")[1].split("_")[1];
- let postil = store_default.flowdata[r2][c2].ps;
- let row = store_default.visibledatarow[r2], row_pre = r2 - 1 == -1 ? 0 : store_default.visibledatarow[r2 - 1];
- let col = store_default.visibledatacolumn[c2], col_pre = c2 - 1 == -1 ? 0 : store_default.visibledatacolumn[c2 - 1];
- let margeset = menuButton_default.mergeborer(store_default.flowdata, r2, c2);
- if (!!margeset) {
- row = margeset.row[1];
- row_pre = margeset.row[0];
- col = margeset.column[1];
- col_pre = margeset.column[0];
- }
- let toX = col;
- let toY = row_pre;
- let postil_left = postil["left"] == null ? toX + 18 : postil["left"];
- let postil_top = postil["top"] == null ? toY - 18 : postil["top"];
- let postil_width = postil["width"] == null ? postil_default.defaultWidth : postil["width"];
- let postil_height = postil["height"] == null ? postil_default.defaultHeight : postil["height"];
- if (postil_top < 0) {
- postil_top = 2;
- }
- let size = postil_default.getArrowCanvasSize(postil_left, postil_top, toX, toY);
- let show = true;
- let show2 = true;
- if (r2 >= _this2.freezenhorizontaldata[1]) {
- if (postil_top + postil_height < freezenTop) {
- $(e).show().find(".luckysheet-postil-show-main").css("top", postil_top + offTop);
- $(e).show().find(".arrowCanvas").css("top", size[1] + offTop);
- } else {
- if (postil_top < freezenTop + offTop) {
- if (postil_top + postil_height <= freezenTop + offTop) {
- show = false;
- } else {
- $(e).show().find(".luckysheet-postil-show-main").css({"top": freezenTop + offTop, "height": postil_height - (freezenTop + offTop - postil_top)});
- $(e).show().find(".formulaInputFocus").css("margin-top", -(freezenTop + offTop - postil_top));
- $(e).show().find(".arrowCanvas").hide();
- show2 = false;
- }
- } else {
- $(e).show().find(".luckysheet-postil-show-main").css({
- "top": postil_top,
- "height": postil_height
- });
- $(e).show().find(".formulaInputFocus").css("margin-top", 0);
- $(e).show().find(".arrowCanvas").css("top", size[1]);
- }
- }
- } else {
- $(e).show().find(".luckysheet-postil-show-main").css("top", postil_top + offTop);
- $(e).show().find(".arrowCanvas").css("top", size[1] + offTop);
- }
- if (c2 >= _this2.freezenverticaldata[1]) {
- if (postil_left + postil_width < freezenLeft) {
- $(e).show().find(".luckysheet-postil-show-main").css("left", postil_left + offLeft);
- $(e).show().find(".arrowCanvas").css("left", size[0] + offLeft);
- } else {
- if (postil_left < freezenLeft + offLeft) {
- if (postil_left + postil_width <= freezenLeft + offLeft) {
- show = false;
- } else {
- $(e).show().find(".luckysheet-postil-show-main").css({"left": freezenLeft + offLeft, "width": postil_width - (freezenLeft + offLeft - postil_left)});
- $(e).show().find(".formulaInputFocus").css("margin-left", -(freezenLeft + offLeft - postil_left));
- $(e).show().find(".arrowCanvas").hide();
- show2 = false;
- }
- } else {
- $(e).show().find(".luckysheet-postil-show-main").css({
- "left": postil_left,
- "width": postil_width
- });
- $(e).show().find(".formulaInputFocus").css("margin-left", 0);
- $(e).show().find(".arrowCanvas").css("left", size[0]);
- }
- }
- } else {
- $(e).show().find(".luckysheet-postil-show-main").css("left", postil_left + offLeft);
- $(e).show().find(".arrowCanvas").css("left", size[0] + offLeft);
- }
- if (!show) {
- $(e).hide();
- }
- if (show && show2) {
- $(e).show().find(".arrowCanvas").show();
- }
- });
- } else if (_this2.freezenhorizontaldata != null) {
- let freezenTop = _this2.freezenhorizontaldata[0];
- let offTop = scrollTop - _this2.freezenhorizontaldata[2];
- $("#luckysheet-postil-showBoxs .luckysheet-postil-show").each(function(i2, e) {
- let id = $(e).attr("id");
- let r2 = id.split("luckysheet-postil-show_")[1].split("_")[0];
- let c2 = id.split("luckysheet-postil-show_")[1].split("_")[1];
- let postil = store_default.flowdata[r2][c2].ps;
- let row = store_default.visibledatarow[r2], row_pre = r2 - 1 == -1 ? 0 : store_default.visibledatarow[r2 - 1];
- let col = store_default.visibledatacolumn[c2], col_pre = c2 - 1 == -1 ? 0 : store_default.visibledatacolumn[c2 - 1];
- let margeset = menuButton_default.mergeborer(store_default.flowdata, r2, c2);
- if (!!margeset) {
- row = margeset.row[1];
- row_pre = margeset.row[0];
- col = margeset.column[1];
- col_pre = margeset.column[0];
- }
- let toX = col;
- let toY = row_pre;
- let postil_left = postil["left"] == null ? toX + 18 : postil["left"];
- let postil_top = postil["top"] == null ? toY - 18 : postil["top"];
- let postil_width = postil["width"] == null ? postil_default.defaultWidth : postil["width"];
- let postil_height = postil["height"] == null ? postil_default.defaultHeight : postil["height"];
- if (postil_top < 0) {
- postil_top = 2;
- }
- let size = postil_default.getArrowCanvasSize(postil_left, postil_top, toX, toY);
- if (r2 >= _this2.freezenhorizontaldata[1]) {
- if (postil_top + postil_height < freezenTop) {
- $(e).show().find(".luckysheet-postil-show-main").css("top", postil_top + offTop);
- $(e).show().find(".arrowCanvas").css("top", size[1] + offTop);
- } else {
- if (postil_top < freezenTop + offTop) {
- if (postil_top + postil_height <= freezenTop + offTop) {
- $(e).hide();
- } else {
- $(e).show().find(".luckysheet-postil-show-main").css({"top": freezenTop + offTop, "height": postil_height - (freezenTop + offTop - postil_top)});
- $(e).show().find(".formulaInputFocus").css("margin-top", -(freezenTop + offTop - postil_top));
- $(e).show().find(".arrowCanvas").hide();
- }
- } else {
- postil_default.buildPs(r2, c2, postil);
- }
- }
- } else {
- $(e).show().find(".luckysheet-postil-show-main").css("top", postil_top + offTop);
- $(e).show().find(".arrowCanvas").css("top", size[1] + offTop);
- }
- });
- } else if (_this2.freezenverticaldata != null) {
- let freezenLeft = _this2.freezenverticaldata[0];
- let offLeft = scrollLeft - _this2.freezenverticaldata[2];
- $("#luckysheet-postil-showBoxs .luckysheet-postil-show").each(function(i2, e) {
- let id = $(e).attr("id");
- let r2 = id.split("luckysheet-postil-show_")[1].split("_")[0];
- let c2 = id.split("luckysheet-postil-show_")[1].split("_")[1];
- let postil = store_default.flowdata[r2][c2].ps;
- let row = store_default.visibledatarow[r2], row_pre = r2 - 1 == -1 ? 0 : store_default.visibledatarow[r2 - 1];
- let col = store_default.visibledatacolumn[c2], col_pre = c2 - 1 == -1 ? 0 : store_default.visibledatacolumn[c2 - 1];
- let margeset = menuButton_default.mergeborer(store_default.flowdata, r2, c2);
- if (!!margeset) {
- row = margeset.row[1];
- row_pre = margeset.row[0];
- col = margeset.column[1];
- col_pre = margeset.column[0];
- }
- let toX = col;
- let toY = row_pre;
- let postil_left = postil["left"] == null ? toX + 18 : postil["left"];
- let postil_top = postil["top"] == null ? toY - 18 : postil["top"];
- let postil_width = postil["width"] == null ? postil_default.defaultWidth : postil["width"];
- let postil_height = postil["height"] == null ? postil_default.defaultHeight : postil["height"];
- if (postil_top < 0) {
- postil_top = 2;
- }
- let size = postil_default.getArrowCanvasSize(postil_left, postil_top, toX, toY);
- if (c2 >= _this2.freezenverticaldata[1]) {
- if (postil_left + postil_width < freezenLeft) {
- $(e).show().find(".luckysheet-postil-show-main").css("left", postil_left + offLeft);
- $(e).show().find(".arrowCanvas").css("left", size[0] + offLeft);
- } else {
- if (postil_left < freezenLeft + offLeft) {
- if (postil_left + postil_width <= freezenLeft + offLeft) {
- $(e).hide();
- } else {
- $(e).show().find(".luckysheet-postil-show-main").css({"left": freezenLeft + offLeft, "width": postil_width - (freezenLeft + offLeft - postil_left)});
- $(e).show().find(".formulaInputFocus").css("margin-left", -(freezenLeft + offLeft - postil_left));
- $(e).show().find(".arrowCanvas").hide();
- }
- } else {
- postil_default.buildPs(r2, c2, postil);
- }
- }
- } else {
- $(e).show().find(".luckysheet-postil-show-main").css("left", postil_left + offLeft);
- $(e).show().find(".arrowCanvas").css("left", size[0] + offLeft);
- }
- });
- } else {
- $("#luckysheet-postil-showBoxs .luckysheet-postil-show").each(function(i2, e) {
- let id = $(e).attr("id");
- let r2 = id.split("luckysheet-postil-show_")[1].split("_")[0];
- let c2 = id.split("luckysheet-postil-show_")[1].split("_")[1];
- let postil = store_default.flowdata[r2][c2].ps;
- postil_default.buildPs(r2, c2, postil);
- });
- }
- },
- scrollAdaptOfdpicon: function() {
- let _this2 = this;
- let copy_r = dropCell_default.copyRange["row"][1], copy_c = dropCell_default.copyRange["column"][1];
- let apply_r = dropCell_default.applyRange["row"][1], apply_c = dropCell_default.applyRange["column"][1];
- let row_index, col_index;
- if (apply_r >= copy_r && apply_c >= copy_c) {
- row_index = apply_r;
- col_index = apply_c;
- } else {
- row_index = copy_r;
- col_index = copy_c;
- }
- if (_this2.freezenhorizontaldata != null && _this2.freezenverticaldata != null) {
- let freezen_rowindex = _this2.freezenhorizontaldata[1];
- let offsetRow = luckysheet_searcharray(_this2.freezenhorizontaldata[3], $("#luckysheet-cell-main").scrollTop() - _this2.freezenhorizontaldata[2]);
- let freezen_colindex = _this2.freezenverticaldata[1];
- let offsetColumn = luckysheet_searcharray(_this2.freezenverticaldata[3], $("#luckysheet-cell-main").scrollLeft() - _this2.freezenverticaldata[2]);
- if (row_index >= freezen_rowindex && col_index >= freezen_colindex) {
- if (row_index < freezen_rowindex + offsetRow - 1 || col_index < freezen_colindex + offsetColumn - 1) {
- $("#luckysheet-dropCell-icon").hide();
- } else {
- $("#luckysheet-dropCell-icon").show();
- }
- } else if (row_index >= freezen_rowindex) {
- if (row_index < freezen_rowindex + offsetRow - 1) {
- $("#luckysheet-dropCell-icon").hide();
- } else {
- let col = colLocationByIndex(col_index + offsetColumn)[1];
- $("#luckysheet-dropCell-icon").show().css("left", col);
- }
- } else if (col_index >= freezen_colindex) {
- if (col_index < freezen_colindex + offsetColumn - 1) {
- $("#luckysheet-dropCell-icon").hide();
- } else {
- let row = rowLocationByIndex(row_index + offsetRow)[1];
- $("#luckysheet-dropCell-icon").show().css("top", row);
- }
- } else {
- let row = rowLocationByIndex(row_index + offsetRow)[1], col = colLocationByIndex(col_index + offsetColumn)[1];
- $("#luckysheet-dropCell-icon").show().css({"left": col, "top": row});
- }
- } else if (_this2.freezenhorizontaldata != null) {
- let freezen_rowindex = _this2.freezenhorizontaldata[1];
- let offsetRow = luckysheet_searcharray(_this2.freezenhorizontaldata[3], $("#luckysheet-cell-main").scrollTop() - _this2.freezenhorizontaldata[2]);
- if (row_index >= freezen_rowindex) {
- if (row_index < freezen_rowindex + offsetRow - 1) {
- $("#luckysheet-dropCell-icon").hide();
- } else {
- $("#luckysheet-dropCell-icon").show();
- }
- } else {
- let row = rowLocationByIndex(row_index + offsetRow)[1];
- $("#luckysheet-dropCell-icon").show().css("top", row);
- }
- } else if (_this2.freezenverticaldata != null) {
- let freezen_colindex = _this2.freezenverticaldata[1];
- let offsetColumn = luckysheet_searcharray(_this2.freezenverticaldata[3], $("#luckysheet-cell-main").scrollLeft() - _this2.freezenverticaldata[2]);
- if (col_index >= freezen_colindex) {
- if (col_index < freezen_colindex + offsetColumn - 1) {
- $("#luckysheet-dropCell-icon").hide();
- } else {
- $("#luckysheet-dropCell-icon").show();
- }
- } else {
- let col = colLocationByIndex(col_index + offsetColumn)[1];
- $("#luckysheet-dropCell-icon").show().css("left", col);
- }
- } else {
- let row = rowLocationByIndex(row_index)[1], col = colLocationByIndex(col_index)[1];
- $("#luckysheet-dropCell-icon").show().css({"left": col, "top": row});
- }
- },
- scrollAdaptOffilteroptions: function() {
- let _this2 = this;
- if (_this2.freezenhorizontaldata != null && _this2.freezenverticaldata != null) {
- let freezen_rowindex = _this2.freezenhorizontaldata[1];
- let freezen_top = _this2.freezenhorizontaldata[0] + $("#luckysheet-cell-main").scrollTop();
- let freezen_colindex = _this2.freezenverticaldata[1];
- let offsetColumn = luckysheet_searcharray(_this2.freezenverticaldata[3], $("#luckysheet-cell-main").scrollLeft() - _this2.freezenverticaldata[2]);
- $("#luckysheet-filter-options-sheet" + store_default.currentSheetIndex + " .luckysheet-filter-options").each(function(i2, e) {
- let row_index = $(e).data("str");
- let top = row_index - 1 == -1 ? 0 : store_default.visibledatarow[row_index - 1];
- let col_index = $(e).data("cindex");
- if (row_index >= freezen_rowindex && col_index >= freezen_colindex) {
- if (top < freezen_top || col_index < freezen_colindex + offsetColumn) {
- $(e).hide();
- } else {
- $(e).show();
- }
- } else if (row_index >= freezen_rowindex) {
- if (top < freezen_top) {
- $(e).hide();
- } else {
- let left = store_default.visibledatacolumn[col_index + offsetColumn] - 20;
- $(e).show().css("left", left);
- }
- } else if (col_index >= freezen_colindex) {
- if (col_index < freezen_colindex + offsetColumn) {
- $(e).hide();
- } else {
- $(e).show().css("top", top + $("#luckysheet-cell-main").scrollTop());
- }
- } else {
- let left = store_default.visibledatacolumn[col_index + offsetColumn] - 20;
- $(e).show().css({"left": left, "top": top + $("#luckysheet-cell-main").scrollTop()});
- }
- });
- } else if (_this2.freezenhorizontaldata != null) {
- let freezen_rowindex = _this2.freezenhorizontaldata[1];
- let freezen_top = _this2.freezenhorizontaldata[0] + $("#luckysheet-cell-main").scrollTop();
- $("#luckysheet-filter-options-sheet" + store_default.currentSheetIndex + " .luckysheet-filter-options").each(function(i2, e) {
- let row_index = $(e).data("str");
- let top = row_index - 1 == -1 ? 0 : store_default.visibledatarow[row_index - 1];
- if (row_index >= freezen_rowindex) {
- if (top < freezen_top) {
- $(e).hide();
- } else {
- $(e).show();
- }
- } else {
- $(e).show().css("top", top + $("#luckysheet-cell-main").scrollTop());
- }
- });
- } else if (_this2.freezenverticaldata != null) {
- let freezen_colindex = _this2.freezenverticaldata[1];
- let offsetColumn = luckysheet_searcharray(_this2.freezenverticaldata[3], $("#luckysheet-cell-main").scrollLeft() - _this2.freezenverticaldata[2]);
- $("#luckysheet-filter-options-sheet" + store_default.currentSheetIndex + " .luckysheet-filter-options").each(function(i2, e) {
- let col_index = $(e).data("cindex");
- if (col_index >= freezen_colindex) {
- if (col_index < freezen_colindex + offsetColumn) {
- $(e).hide();
- } else {
- $(e).show();
- }
- } else {
- let left = store_default.visibledatacolumn[col_index + offsetColumn] - 20;
- $(e).show().css("left", left);
- }
- });
- } else {
- $("#luckysheet-filter-options-sheet" + store_default.currentSheetIndex).empty();
- createFilterOptions(store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)].filter_select);
- }
- },
- saveFrozen: function(operate, order, focus = {}) {
- if (order == null) {
- order = getSheetIndex(store_default.currentSheetIndex);
- }
- const select_save = store_default.luckysheet_select_save[store_default.luckysheet_select_save.length - 1];
- const row_focus = select_save["row_focus"] == null ? select_save["row"][0] : select_save["row_focus"];
- const column_focus = select_save["column_focus"] == null ? select_save["column"][0] : select_save["column_focus"];
- const range2 = {
- row_focus: focus.row_focus || row_focus,
- column_focus: focus.column_focus || column_focus
- };
- const frozen = {
- "freezenRow": {
- type: "row"
- },
- "freezenColumn": {
- type: "column"
- },
- "freezenRC": {
- type: "both"
- },
- "freezenRowRange": {
- type: "rangeRow",
- range: range2
- },
- "freezenColumnRange": {
- type: "rangeColumn",
- range: range2
- },
- "freezenRCRange": {
- type: "rangeBoth",
- range: range2
- },
- "freezenCancel": {
- type: "cancel"
- }
- };
- store_default.luckysheetfile[order]["frozen"] = frozen[operate];
- },
- frozenTofreezen: function() {
- let file = store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)];
- const frozen = file["frozen"];
- if (frozen == null) {
- return;
- }
- let freezen = null;
- if (frozen.type === "row") {
- let scrollTop = 0;
- let row_st = luckysheet_searcharray(store_default.visibledatarow, scrollTop);
- if (row_st == -1) {
- row_st = 0;
- }
- let top = store_default.visibledatarow[row_st] - 2 - scrollTop + store_default.columnHeaderHeight;
- let freezenhorizontaldata = [store_default.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(store_default.visibledatarow, row_st + 1), top];
- freezen = {
- horizontal: {
- freezenhorizontaldata,
- top
- }
- };
- } else if (frozen.type === "column") {
- let scrollLeft = 0;
- let col_st = luckysheet_searcharray(store_default.visibledatacolumn, scrollLeft);
- if (col_st == -1) {
- col_st = 0;
- }
- let left = store_default.visibledatacolumn[col_st] - 2 - scrollLeft + store_default.rowHeaderWidth;
- let freezenverticaldata = [store_default.visibledatacolumn[col_st], col_st + 1, scrollLeft, luckysheetFreezen.cutVolumn(store_default.visibledatacolumn, col_st + 1), left];
- freezen = {
- vertical: {
- freezenverticaldata,
- left
- }
- };
- } else if (frozen.type === "both") {
- let scrollTop = 0;
- let row_st = luckysheet_searcharray(store_default.visibledatarow, scrollTop);
- if (row_st == -1) {
- row_st = 0;
- }
- let top = store_default.visibledatarow[row_st] - 2 - scrollTop + store_default.columnHeaderHeight;
- let freezenhorizontaldata = [store_default.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(store_default.visibledatarow, row_st + 1), top];
- let scrollLeft = 0;
- let col_st = luckysheet_searcharray(store_default.visibledatacolumn, scrollLeft);
- if (col_st == -1) {
- col_st = 0;
- }
- let left = store_default.visibledatacolumn[col_st] - 2 - scrollLeft + store_default.rowHeaderWidth;
- let freezenverticaldata = [store_default.visibledatacolumn[col_st], col_st + 1, scrollLeft, luckysheetFreezen.cutVolumn(store_default.visibledatacolumn, col_st + 1), left];
- freezen = {
- horizontal: {
- freezenhorizontaldata,
- top
- },
- vertical: {
- freezenverticaldata,
- left
- }
- };
- } else if (frozen.type === "rangeRow") {
- let scrollTop = 0;
- let row_st = luckysheet_searcharray(store_default.visibledatarow, scrollTop);
- let row_focus = frozen.range["row_focus"];
- if (row_focus > row_st) {
- row_st = row_focus;
- }
- if (row_st == -1) {
- row_st = 0;
- }
- let top = store_default.visibledatarow[row_st] - 2 - scrollTop + store_default.columnHeaderHeight;
- let freezenhorizontaldata = [store_default.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(store_default.visibledatarow, row_st + 1), top];
- freezen = {
- horizontal: {
- freezenhorizontaldata,
- top
- }
- };
- } else if (frozen.type === "rangeColumn") {
- let scrollLeft = 0;
- let col_st = luckysheet_searcharray(store_default.visibledatacolumn, scrollLeft);
- let column_focus = frozen.range["column_focus"];
- if (column_focus > col_st) {
- col_st = column_focus;
- }
- if (col_st == -1) {
- col_st = 0;
- }
- let left = store_default.visibledatacolumn[col_st] - 2 - scrollLeft + store_default.rowHeaderWidth;
- let freezenverticaldata = [store_default.visibledatacolumn[col_st], col_st + 1, scrollLeft, luckysheetFreezen.cutVolumn(store_default.visibledatacolumn, col_st + 1), left];
- freezen = {
- vertical: {
- freezenverticaldata,
- left
- }
- };
- } else if (frozen.type === "rangeBoth") {
- let scrollTop = 0;
- let row_st = luckysheet_searcharray(store_default.visibledatarow, scrollTop);
- let row_focus = frozen.range["row_focus"];
- if (row_focus > row_st) {
- row_st = row_focus;
- }
- if (row_st == -1) {
- row_st = 0;
- }
- let top = store_default.visibledatarow[row_st] - 2 - scrollTop + store_default.columnHeaderHeight;
- let freezenhorizontaldata = [store_default.visibledatarow[row_st], row_st + 1, scrollTop, luckysheetFreezen.cutVolumn(store_default.visibledatarow, row_st + 1), top];
- let scrollLeft = 0;
- let col_st = luckysheet_searcharray(store_default.visibledatacolumn, scrollLeft);
- let column_focus = frozen.range["column_focus"];
- if (column_focus > col_st) {
- col_st = column_focus;
- }
- if (col_st == -1) {
- col_st = 0;
- }
- let left = store_default.visibledatacolumn[col_st] - 2 - scrollLeft + store_default.rowHeaderWidth;
- let freezenverticaldata = [store_default.visibledatacolumn[col_st], col_st + 1, scrollLeft, luckysheetFreezen.cutVolumn(store_default.visibledatacolumn, col_st + 1), left];
- freezen = {
- horizontal: {
- freezenhorizontaldata,
- top
- },
- vertical: {
- freezenverticaldata,
- left
- }
- };
- } else if (frozen.type === "cancel") {
- freezen = {
- horizontal: null,
- vertical: null
- };
- }
- file["freezen"] = freezen;
- }
- };
- freezen_default = luckysheetFreezen;
- }
- });
-
- // src/controllers/resize.js
- function luckysheetsizeauto(isRefreshCanvas = true) {
- if (!luckysheetConfigsetting_default.showinfobar) {
- store_default.infobarHeight = 0;
- $("#luckysheet_info_detail").hide();
- } else {
- $("#luckysheet_info_detail").show();
- store_default.infobarHeight = document.querySelector("#luckysheet_info_detail").offsetHeight;
- }
- if (!!store_default.toobarObject && !!store_default.toobarObject.toobarElements && store_default.toobarObject.toobarElements.length === 0) {
- $("#" + store_default.container).find(".luckysheet-wa-editor").hide();
- store_default.toolbarHeight = 0;
- } else {
- $("#" + store_default.container).find(".luckysheet-wa-editor").show();
- store_default.toolbarHeight = document.querySelector("#" + store_default.container + " .luckysheet-wa-editor").offsetHeight;
- }
- customSheetbarConfig();
- customStatisticBarConfig();
- const formulaEle = document.querySelector("#" + store_default.container + " .luckysheet-wa-calculate");
- if (!luckysheetConfigsetting_default.sheetFormulaBar) {
- formulaEle.style.display = "none";
- store_default.calculatebarHeight = 0;
- } else {
- formulaEle.style.display = "block";
- store_default.calculatebarHeight = formulaEle.offsetHeight;
- }
- $("#" + store_default.container).find(".luckysheet-grid-container").css("top", store_default.toolbarHeight + store_default.infobarHeight + store_default.calculatebarHeight);
- gridW = $("#" + store_default.container).width();
- if (luckysheetConfigsetting_default.showConfigWindowResize) {
- if ($("#luckysheet-modal-dialog-slider-pivot").is(":visible")) {
- gridW -= $("#luckysheet-modal-dialog-slider-pivot").outerWidth();
- } else if ($(".chartSetting").is(":visible")) {
- gridW -= $(".chartSetting").outerWidth();
- } else if ($("#luckysheet-modal-dialog-slider-alternateformat").is(":visible")) {
- gridW -= $("#luckysheet-modal-dialog-slider-alternateformat").outerWidth();
- }
- if ($("#luckysheet-modal-dialog-slider-protection").is(":visible")) {
- gridW -= $("#luckysheet-modal-dialog-slider-protection").outerWidth();
- }
- }
- const _locale = locale_default();
- const locale_toolbar = _locale.toolbar;
- let ismore = false, toolbarW = 0, morebtn = `
`, morediv = '
';
- if ($("#luckysheet-icon-morebtn-div").length == 0) {
- $("body").append(morediv);
- }
- $$("#luckysheet-icon-morebtn-div").style.visibility = "hidden";
- $("#luckysheet-icon-morebtn-div > div").each(function() {
- const $t = $(this)[0];
- const $container = $("#luckysheet-wa-editor")[0];
- $container.appendChild(document.createTextNode(" "));
- $container.appendChild($t);
- });
- $("#luckysheet-icon-morebtn").remove();
- const toobarWidths = store_default.toobarObject.toobarWidths;
- const toobarElements = store_default.toobarObject.toobarElements;
- let moreButtonIndex = 0;
- if (toobarWidths == void 0) {
- return;
- }
- for (let index2 = toobarWidths.length - 1; index2 >= 0; index2--) {
- if (toobarWidths[index2] < gridW - 90) {
- moreButtonIndex = index2;
- if (moreButtonIndex < toobarWidths.length - 1) {
- ismore = true;
- }
- break;
- }
- }
- for (let index2 = moreButtonIndex; index2 < toobarElements.length; index2++) {
- const element = toobarElements[index2];
- if (element instanceof Array) {
- for (const ele of element) {
- $("#luckysheet-icon-morebtn-div").append($(`${ele}`));
- }
- } else {
- $("#luckysheet-icon-morebtn-div").append($(`${element}`));
- }
- }
- if (ismore) {
- $("#luckysheet-wa-editor").append(morebtn);
- $("#luckysheet-icon-morebtn").click(function() {
- $$("#luckysheet-icon-morebtn-div").style.left = "";
- const containerLeft = $$(`#${store_default.container}`).getBoundingClientRect ? $$(`#${store_default.container}`).getBoundingClientRect().left : 0;
- const morebtnLeft = $$("#luckysheet-icon-morebtn-div").getBoundingClientRect().left;
- if (morebtnLeft < containerLeft) {
- $$("#luckysheet-icon-morebtn-div").style.left = containerLeft + "px";
- }
- let right = $(window).width() - $("#luckysheet-icon-morebtn").offset().left - $("#luckysheet-icon-morebtn").width() + $("body").scrollLeft();
- $$("#luckysheet-icon-morebtn-div").style.right = right < 0 ? 0 : right + "px";
- if ($$("#luckysheet-icon-morebtn-div").style.visibility === "hidden") {
- $$("#luckysheet-icon-morebtn-div").style.visibility = "visible";
- } else {
- $$("#luckysheet-icon-morebtn-div").style.visibility = "hidden";
- }
- let $txt = $(this).find(".luckysheet-toolbar-menu-button-caption");
- if ($txt.text().indexOf(locale_toolbar.toolMore) > -1) {
- const toolCloseHTML = `
-
-
- `;
- $(this).find(".luckysheet-toolbar-button-inner-box").html(toolCloseHTML);
- } else {
- const toolMoreHTML = `
-
-
- `;
- $(this).find(".luckysheet-toolbar-button-inner-box").html(toolMoreHTML);
- }
- });
- $("#luckysheet-icon-morebtn-div .luckysheet-toolbar-button-split-left").off("hover").hover(function() {
- $(this).next(".luckysheet-toolbar-button-split-right").addClass("luckysheet-toolbar-button-split-right-hover");
- }, function() {
- $(this).next(".luckysheet-toolbar-button-split-right").removeClass("luckysheet-toolbar-button-split-right-hover");
- });
- $("#luckysheet-icon-morebtn-div .luckysheet-toolbar-button-split-right").off("hover").hover(function() {
- $(this).prev(".luckysheet-toolbar-button-split-left").addClass("luckysheet-toolbar-button-hover");
- }, function() {
- $(this).prev(".luckysheet-toolbar-button-split-left").removeClass("luckysheet-toolbar-button-hover");
- });
- tooltip_default.createHoverTip("#luckysheet-icon-morebtn-div", ".luckysheet-toolbar-menu-button, .luckysheet-toolbar-button, .luckysheet-toolbar-combo-button");
- }
- $("#" + store_default.container + " .luckysheet-wa-editor .luckysheet-toolbar-button-split-left").off("hover").hover(function() {
- $(this).next(".luckysheet-toolbar-button-split-right").addClass("luckysheet-toolbar-button-split-right-hover");
- }, function() {
- $(this).next(".luckysheet-toolbar-button-split-right").removeClass("luckysheet-toolbar-button-split-right-hover");
- });
- $("#" + store_default.container + " .luckysheet-wa-editor .luckysheet-toolbar-button-split-right").off("hover").hover(function() {
- $(this).prev(".luckysheet-toolbar-button-split-left").addClass("luckysheet-toolbar-button-hover");
- }, function() {
- $(this).prev(".luckysheet-toolbar-button-split-left").removeClass("luckysheet-toolbar-button-hover");
- });
- gridH = $("#" + store_default.container).height();
- $("#" + store_default.container).find(".luckysheet").height(gridH - 2).width(gridW - 2);
- changeSheetContainerSize(gridW, gridH);
- if (isRefreshCanvas) {
- luckysheetrefreshgrid($("#luckysheet-cell-main").scrollLeft(), $("#luckysheet-cell-main").scrollTop());
- }
- sheetmanage_default.sheetArrowShowAndHide();
- sheetmanage_default.sheetBarShowAndHide();
- }
- function changeSheetContainerSize(gridW2, gridH2) {
- if (gridW2 == null) {
- gridW2 = $("#" + store_default.container).width();
- }
- if (gridH2 == null) {
- gridH2 = $("#" + store_default.container).height();
- }
- store_default.cellmainHeight = gridH2 - (store_default.infobarHeight + store_default.toolbarHeight + store_default.calculatebarHeight + store_default.columnHeaderHeight + store_default.sheetBarHeight + store_default.statisticBarHeight);
- store_default.cellmainWidth = gridW2 - store_default.rowHeaderWidth;
- $("#luckysheet-cols-h-c, #luckysheet-cell-main").width(store_default.cellmainWidth);
- $("#luckysheet-cell-main").height(store_default.cellmainHeight);
- $("#luckysheet-rows-h").height(store_default.cellmainHeight - store_default.cellMainSrollBarSize);
- $("#luckysheet-scrollbar-y").height(store_default.cellmainHeight + store_default.columnHeaderHeight - store_default.cellMainSrollBarSize - 3);
- $("#luckysheet-scrollbar-x").height(store_default.cellMainSrollBarSize);
- $("#luckysheet-scrollbar-y").width(store_default.cellMainSrollBarSize);
- $("#luckysheet-scrollbar-x").width(store_default.cellmainWidth).css("left", store_default.rowHeaderWidth - 2);
- store_default.luckysheetTableContentHW = [
- store_default.cellmainWidth + store_default.rowHeaderWidth - store_default.cellMainSrollBarSize,
- store_default.cellmainHeight + store_default.columnHeaderHeight - store_default.cellMainSrollBarSize
- ];
- $("#luckysheetTableContent, #luckysheetTableContentF").attr({
- width: Math.ceil(store_default.luckysheetTableContentHW[0] * store_default.devicePixelRatio),
- height: Math.ceil(store_default.luckysheetTableContentHW[1] * store_default.devicePixelRatio)
- }).css({width: store_default.luckysheetTableContentHW[0], height: store_default.luckysheetTableContentHW[1]});
- $("#" + store_default.container).find("#luckysheet-grid-window-1").css("bottom", store_default.sheetBarHeight);
- $("#" + store_default.container).find(".luckysheet-grid-window").css("bottom", store_default.statisticBarHeight);
- let gridwidth = $("#luckysheet-grid-window-1").width();
- $("#luckysheet-freezebar-horizontal").find(".luckysheet-freezebar-horizontal-handle").css({"width": gridwidth - 10}).end().find(".luckysheet-freezebar-horizontal-drop").css({"width": gridwidth - 10});
- let gridheight = $("#luckysheet-grid-window-1").height();
- $("#luckysheet-freezebar-vertical").find(".luckysheet-freezebar-vertical-handle").css({"height": gridheight - 10}).end().find(".luckysheet-freezebar-vertical-drop").css({"height": gridheight - 10});
- freezen_default.createAssistCanvas();
- }
- function menuToolBarWidth() {
- const showtoolbar = luckysheetConfigsetting_default.showtoolbar;
- const showtoolbarConfig = luckysheetConfigsetting_default.showtoolbarConfig;
- const toobarWidths = store_default.toobarObject.toobarWidths = [];
- const toobarElements = store_default.toobarObject.toobarElements = [];
- const toolbarConfig = store_default.toobarObject.toolbarConfig = buildBoolBarConfig();
- function buildBoolBarConfig() {
- let obj = {};
- function array2Config(arr) {
- const obj2 = {};
- let current, next;
- let index2 = 0;
- for (let i2 = 0; i2 < arr.length; i2++) {
- current = arr[i2];
- next = arr[i2 + 1];
- if (current !== "|") {
- obj2[current] = {
- ele: toolbarIdMap[current],
- index: index2++
- };
- }
- if (next === "|") {
- if (getObjType(obj2[current].ele) === "array") {
- obj2[current].ele.push(`#toolbar-separator-${camel2split(current)}`);
- } else {
- obj2[current].ele = [obj2[current].ele, `#toolbar-separator-${camel2split(current)}`];
- }
- }
- }
- return obj2;
- }
- if (getObjType(showtoolbarConfig) === "array") {
- if (!showtoolbar) {
- return obj;
- }
- return array2Config(showtoolbarConfig);
- }
- const config = defaultToolbar.reduce(function(total, curr) {
- if (curr !== "|") {
- total[curr] = true;
- }
- return total;
- }, {});
- if (!showtoolbar) {
- for (let s in config) {
- config[s] = false;
- }
- }
- if (JSON.stringify(showtoolbarConfig) !== "{}") {
- if (showtoolbarConfig.hasOwnProperty("undoRedo")) {
- config.undo = config.redo = showtoolbarConfig.undoRedo;
- }
- Object.assign(config, showtoolbarConfig);
- let current, next;
- let index2 = 0;
- for (let i2 = 0; i2 < defaultToolbar.length; i2++) {
- current = defaultToolbar[i2];
- next = defaultToolbar[i2 + 1];
- if (config[current] === false) {
- continue;
- }
- if (current !== "|" && config[current]) {
- obj[current] = {
- ele: toolbarIdMap[current],
- index: index2++
- };
- }
- if (next === "|") {
- if (getObjType(obj[current].ele) === "array") {
- obj[current].ele.push(`#toolbar-separator-${camel2split(current)}`);
- } else {
- obj[current].ele = [obj[current].ele, `#toolbar-separator-${camel2split(current)}`];
- }
- }
- }
- } else {
- obj = showtoolbar ? array2Config(defaultToolbar) : {};
- }
- return obj;
- }
- for (let s in toolbarConfig) {
- if (Object.prototype.hasOwnProperty.call(toolbarConfig, s)) {
- toobarElements.push($.extend(true, {}, toolbarConfig[s]));
- }
- }
- toobarElements.sort(sortToolbar);
- function sortToolbar(a, b) {
- if (a.index > b.index) {
- return 1;
- } else {
- return -1;
- }
- }
- toobarElements.forEach((curr, index2, arr) => {
- arr[index2] = curr.ele;
- if (index2 !== toobarElements.length - 1) {
- if (curr.ele instanceof Array) {
- toobarWidths.push($(curr.ele[0]).offset().left);
- } else {
- toobarWidths.push($(curr.ele).offset().left);
- }
- } else {
- if (curr.ele instanceof Array) {
- toobarWidths.push($(curr.ele[0]).offset().left);
- toobarWidths.push($(curr.ele[0]).offset().left + $(curr.ele[0]).outerWidth() + 5);
- } else {
- toobarWidths.push($(curr.ele).offset().left);
- toobarWidths.push($(curr.ele).offset().left + $(curr.ele).outerWidth() + 5);
- }
- }
- });
- const containerLeft = $("#" + store_default.container).offset().left;
- toobarWidths.forEach((item2, i2) => {
- toobarWidths[i2] -= containerLeft;
- });
- }
- function customSheetbarConfig() {
- if (!luckysheetConfigsetting_default.initShowsheetbarConfig) {
- luckysheetConfigsetting_default.initShowsheetbarConfig = true;
- const config2 = {
- add: true,
- menu: true,
- sheet: true
- };
- if (!luckysheetConfigsetting_default.showsheetbar) {
- for (let s in config2) {
- config2[s] = false;
- }
- }
- if (JSON.stringify(luckysheetConfigsetting_default.showsheetbarConfig) !== "{}") {
- Object.assign(config2, luckysheetConfigsetting_default.showsheetbarConfig);
- }
- luckysheetConfigsetting_default.showsheetbarConfig = config2;
- }
- const config = luckysheetConfigsetting_default.showsheetbarConfig;
- let isHide = 0;
- for (let s in config) {
- if (!config[s]) {
- switch (s) {
- case "add":
- $("#luckysheet-sheets-add").hide();
- isHide++;
- break;
- case "menu":
- $("#luckysheet-sheets-m").hide();
- isHide++;
- break;
- case "sheet":
- $("#luckysheet-sheet-container").hide();
- $("#luckysheet-sheets-leftscroll").hide();
- $("#luckysheet-sheets-rightscroll").hide();
- isHide++;
- break;
- default:
- break;
- }
- }
- }
- if (isHide === 3) {
- $("#" + store_default.container).find("#luckysheet-sheet-area").hide();
- store_default.sheetBarHeight = 0;
- } else {
- $("#" + store_default.container).find("#luckysheet-sheet-area").show();
- store_default.sheetBarHeight = 31;
- }
- }
- function customStatisticBarConfig() {
- if (!luckysheetConfigsetting_default.initStatisticBarConfig) {
- luckysheetConfigsetting_default.initStatisticBarConfig = true;
- const config2 = {
- count: true,
- view: true,
- zoom: true
- };
- if (!luckysheetConfigsetting_default.showstatisticBar) {
- for (let s in config2) {
- config2[s] = false;
- }
- }
- if (JSON.stringify(luckysheetConfigsetting_default.showstatisticBarConfig) !== "{}") {
- Object.assign(config2, luckysheetConfigsetting_default.showstatisticBarConfig);
- }
- luckysheetConfigsetting_default.showstatisticBarConfig = config2;
- }
- const config = luckysheetConfigsetting_default.showstatisticBarConfig;
- let isHide = 0;
- for (let s in config) {
- if (!config[s]) {
- switch (s) {
- case "count":
- $("#luckysheet-sta-content").hide();
- isHide++;
- break;
- case "view":
- $(".luckysheet-print-viewList").hide();
- isHide++;
- break;
- case "zoom":
- $("#luckysheet-zoom-content").hide();
- isHide++;
- break;
- default:
- break;
- }
- }
- }
- if (isHide === 3) {
- $("#" + store_default.container).find(".luckysheet-stat-area").hide();
- store_default.statisticBarHeight = 0;
- } else {
- $("#" + store_default.container).find(".luckysheet-stat-area").show();
- store_default.statisticBarHeight = 23;
- }
- }
- var gridW, gridH;
- var init_resize = __esm({
- "src/controllers/resize.js"() {
- init_luckysheetConfigsetting();
- init_freezen();
- init_refresh();
- init_store();
- init_locale();
- init_sheetmanage();
- init_tooltip();
- init_util();
- init_toolbar();
- gridW = 0;
- gridH = 0;
- }
- });
-
- // src/controllers/protection.js
- function addRangeItem(item2) {
- const _locale = locale_default();
- const local_protection = _locale.protection;
- const locale_button = _locale.button;
- let title = item2.name, sqref = item2.sqref, password = item2.password;
- let passwordTxt = "";
- if (password != null && password.length > 0) {
- passwordTxt = '
';
- }
- let rangeItemTemplate = `
-
-
-
-
-
- ${title}${passwordTxt}
-
-
- ${sqref}
-
-
-
-
-
- `;
- $("#luckysheet-protection-rangeItem-container").append(rangeItemTemplate);
- }
- function initialEvent(file) {
- const _locale = locale_default();
- const local_protection = _locale.protection;
- const locale_button = _locale.button;
- $("#luckysheet-slider-protection-ok").unbind("click").click(function() {
- let password = $("#protection-password").val();
- let sheet = $("#protection-swichProtectionState").is(":checked");
- let hint = $("#protection-hint").val();
- let file2 = updatingSheetFile, aut = {};
- if (file2 != null && file2.config != null && file2.config.authority != null) {
- aut = file2.config.authority;
- }
- let authorityData = {};
- let algorithmName = "None";
- if (password != "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022") {
- authorityData.password = password;
- authorityData.algorithmName = "None";
- authorityData.saltValue = null;
- } else if (aut != null) {
- authorityData.algorithmName = aut.algorithmName;
- authorityData.saltValue = aut.saltValue;
- authorityData.password = aut.password;
- } else {
- authorityData.algorithmName = "None";
- authorityData.saltValue = null;
- authorityData.password = "";
- }
- authorityData.hintText = hint;
- authorityData.sheet = sheet == true ? 1 : 0;
- for (let i2 = 0; i2 < authorityItemArr.length; i2++) {
- let name2 = authorityItemArr[i2];
- let checkId = "luckysheet-protection-check-" + name2;
- let authorityValue = $("#" + checkId).is(":checked");
- authorityData[name2] = authorityValue == true ? 1 : 0;
- }
- let allowRangeListTemp = JSON.parse(JSON.stringify(rangeItemListCache));
- authorityData.allowRangeList = allowRangeListTemp;
- rangeItemListCache = [];
- firstInputSheetProtectionPassword = true;
- if (file2.config == null) {
- file2.config = {};
- }
- file2.config.authority = authorityData;
- inputRangeProtectionPassword = {};
- closeProtectionModal();
- });
- $("#luckysheet-slider-protection-cancel, #luckysheet-modal-dialog-protection-close").click(function() {
- closeProtectionModal();
- });
- $("#luckysheet-slider-protection-addRange").click(function() {
- initialProtectionRangeModal();
- isAddRangeItemState = true;
- $("#luckysheet-protection-rangeItem-confirm").html(locale_button.insert);
- openSelfModel("luckysheet-protection-rangeItem-dialog");
- $("#protection-allowRangeAdd-title").val("Default" + rangeItemListCache.length);
- $("#protection-allowRangeAdd-range input").val("");
- $("#protection-allowRangeAdd-password").val("");
- $("#protection-allowRangeAdd-hint").val("");
- });
- $(document).off("click.luckysheetProtection.rangeItemUpdate").on("click.luckysheetProtection.rangeItemUpdate", "#luckysheet-protection-rangeItem-container .luckysheet-protection-rangeItem-update", function(e) {
- initialProtectionRangeModal();
- isAddRangeItemState = false;
- $("#luckysheet-protection-rangeItem-confirm").html(locale_button.update);
- openSelfModel("luckysheet-protection-rangeItem-dialog");
- let $rangeItem = $(e.target).closest(".luckysheet-protection-rangeItem");
- let $rangeItemContainer = $("#luckysheet-protection-rangeItem-container");
- let index2 = $rangeItemContainer.find("> div.luckysheet-protection-rangeItem").index($rangeItem);
- let item2 = rangeItemListCache[index2];
- updateRangeItemIndex = index2;
- $("#protection-allowRangeAdd-title").val(item2.name);
- $("#protection-allowRangeAdd-range input").val(item2.sqref);
- if (item2.algorithmName == "None") {
- $("#protection-allowRangeAdd-password").val(item2.password);
- } else {
- $("#protection-allowRangeAdd-password").val("\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022");
- }
- $("#protection-allowRangeAdd-hint").val(item2.hintText);
- });
- $(document).off("click.luckysheetProtection.rangeItemDelete").on("click.luckysheetProtection.rangeItemDelete", "#luckysheet-protection-rangeItem-container .luckysheet-protection-rangeItem-del", function(e) {
- let $rangeItem = $(e.target).closest(".luckysheet-protection-rangeItem");
- let $rangeItemContainer = $("#luckysheet-protection-rangeItem-container");
- let index2 = $rangeItemContainer.find("> div.luckysheet-protection-rangeItem").index($rangeItem);
- let item2 = rangeItemListCache[index2];
- rangeItemListCache.splice(index2, 1);
- $rangeItem.remove();
- });
- $(document).off("click.luckysheetProtection.rangeItemConfirm").on("click.luckysheetProtection.rangeItemConfirm", "#luckysheet-protection-rangeItem-confirm", function() {
- let name2 = $("#protection-allowRangeAdd-title").val(), rangeText = $("#protection-allowRangeAdd-range input").val(), password = $("#protection-allowRangeAdd-password").val(), hint = $("#protection-allowRangeAdd-hint").val();
- if (name2.length == 0) {
- alert(local_protection.rangeItemErrorTitleNull);
- return;
- }
- let range2 = dataVerificationCtrl_default.getRangeByTxt(rangeText);
- if (rangeText.length == 0) {
- alert(local_protection.rangeItemErrorRangeNull);
- return;
- }
- if (range2.length == 0) {
- alert(local_protection.rangeItemErrorRange);
- return;
- }
- rangeText = transformRangeToAbsolute(rangeText);
- if (isAddRangeItemState) {
- let item2 = {
- name: name2,
- password,
- hintText: hint,
- algorithmName: "None",
- saltValue: null,
- checkRangePasswordUrl: null,
- sqref: rangeText
- };
- addRangeItem(item2);
- rangeItemListCache.push(item2);
- } else {
- let index2 = updateRangeItemIndex;
- let item2 = rangeItemListCache[index2];
- item2.name = name2;
- item2.sqref = rangeText;
- item2.hintText = hint;
- if (password != "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022") {
- item2.password = password;
- item2.algorithmName = "None";
- }
- let $rangeItemContainer = $("#luckysheet-protection-rangeItem-container");
- let $rangeitem = $rangeItemContainer.find("> div.luckysheet-protection-rangeItem").eq(index2);
- let $name = $rangeitem.find(".luckysheet-protection-rangeItem-name");
- let passwordTxt = "";
- if (password != null && password.length > 0) {
- passwordTxt = '
';
- }
- $name.html(name2 + passwordTxt).attr("title", name2);
- let $range = $rangeitem.find(".luckysheet-protection-rangeItem-range");
- $range.html(rangeText).attr("title", rangeText);
- }
- $("#luckysheet-protection-rangeItem-dialog").hide();
- $("#luckysheet-modal-dialog-mask").hide();
- });
- $(document).off("click.luckysheetProtection.validationConfirm").on("click.luckysheetProtection.validationConfirm", "#luckysheet-protection-sheet-validation-confirm", function(e) {
- let $validation = $("#luckysheet-protection-sheet-validation");
- let aut = validationAuthority;
- if (aut == null) {
- restoreProtectionConfig(validationAuthority);
- $validation.hide();
- $("#luckysheet-modal-dialog-mask").hide();
- $("#luckysheet-modal-dialog-slider-protection").show();
- luckysheetsizeauto();
- return;
- }
- let $input = $validation.find("input");
- let password = $input.val();
- if (password == null || password.length == 0) {
- alert(local_protection.checkPasswordNullalert);
- return;
- }
- if (aut.algorithmName != null && aut.algorithmName != "None") {
- if (aut.saltValue != null && aut.saltValue.length > 0) {
- var hasher = CryptoApi.getHasher(aut.algorithmName);
- password = CryptoApi.hmac(aut.saltValue, password, hasher);
- } else {
- password = CryptoApi.hash(aut.algorithmName, password);
- }
- }
- if (password == aut.password) {
- restoreProtectionConfig(validationAuthority);
- $validation.hide();
- $("#luckysheet-modal-dialog-mask").hide();
- $("#luckysheet-modal-dialog-slider-protection").show();
- luckysheetsizeauto();
- firstInputSheetProtectionPassword = false;
- } else {
- alert(local_protection.checkPasswordWrongalert);
- }
- });
- $("#luckysheet-protection-check-selectLockedCells").change(function() {
- let $selectLockedCells = $("#luckysheet-protection-check-selectLockedCells"), $selectunLockedCells = $("#luckysheet-protection-check-selectunLockedCells");
- let selectLockedCellsChecked = $selectLockedCells.is(":checked"), selectunLockedCellsChecked = $selectunLockedCells.is(":checked");
- if (selectLockedCellsChecked) {
- $selectunLockedCells.prop("checked", true);
- }
- });
- $("#luckysheet-protection-check-selectunLockedCells").change(function() {
- let $selectLockedCells = $("#luckysheet-protection-check-selectLockedCells"), $selectunLockedCells = $("#luckysheet-protection-check-selectunLockedCells");
- let selectLockedCellsChecked = $selectLockedCells.is(":checked"), selectunLockedCellsChecked = $selectunLockedCells.is(":checked");
- if (!selectunLockedCellsChecked) {
- $selectLockedCells.prop("checked", false);
- }
- });
- $(document).off("click.luckysheetProtection.dvRange").on("click.luckysheetProtection.dvRange", "#protection-allowRangeAdd-range .fa-table", function(e) {
- $("#luckysheet-protection-rangeItem-dialog").hide();
- let dataSource = "0";
- let txt = $(this).siblings("input").val().trim();
- dataVerificationCtrl_default.rangeDialog(dataSource, txt);
- dataVerificationCtrl_default.selectRange = [];
- let range2 = dataVerificationCtrl_default.getRangeByTxt(txt);
- if (range2.length > 0) {
- for (let s = 0; s < range2.length; s++) {
- let r1 = range2[s].row[0], r2 = range2[s].row[1];
- let c1 = range2[s].column[0], c2 = range2[s].column[1];
- let row = store_default.visibledatarow[r2], row_pre = r1 - 1 == -1 ? 0 : store_default.visibledatarow[r1 - 1];
- let col = store_default.visibledatacolumn[c2], col_pre = c1 - 1 == -1 ? 0 : store_default.visibledatacolumn[c1 - 1];
- dataVerificationCtrl_default.selectRange.push({
- "left": col_pre,
- "width": col - col_pre - 1,
- "top": row_pre,
- "height": row - row_pre - 1,
- "left_move": col_pre,
- "width_move": col - col_pre - 1,
- "top_move": row_pre,
- "height_move": row - row_pre - 1,
- "row": [r1, r2],
- "column": [c1, c2],
- "row_focus": r1,
- "column_focus": c1
- });
- }
- }
- selectionCopyShow(dataVerificationCtrl_default.selectRange);
- });
- $(document).off("click.luckysheetProtection.dvRange2").on("click.luckysheetProtection.dvRange2", "#luckysheet-protection-rangeItem-dialog .show-box-item-dropdown .range .fa-table", function(e) {
- $("#luckysheet-protection-rangeItem-dialog").hide();
- let dataSource = "1";
- let txt = $(this).siblings("input").val().trim();
- dataVerificationCtrl_default.rangeDialog(dataSource, txt);
- dataVerificationCtrl_default.selectRange = [];
- let range2 = dataVerificationCtrl_default.getRangeByTxt(txt);
- if (range2.length > 0) {
- for (let s = 0; s < range2.length; s++) {
- let r1 = range2[s].row[0], r2 = range2[s].row[1];
- let c1 = range2[s].column[0], c2 = range2[s].column[1];
- let row = store_default.visibledatarow[r2], row_pre = r1 - 1 == -1 ? 0 : store_default.visibledatarow[r1 - 1];
- let col = store_default.visibledatacolumn[c2], col_pre = c1 - 1 == -1 ? 0 : store_default.visibledatacolumn[c1 - 1];
- dataVerificationCtrl_default.selectRange.push({
- "left": col_pre,
- "width": col - col_pre - 1,
- "top": row_pre,
- "height": row - row_pre - 1,
- "left_move": col_pre,
- "width_move": col - col_pre - 1,
- "top_move": row_pre,
- "height_move": row - row_pre - 1,
- "row": [r1, r2],
- "column": [c1, c2],
- "row_focus": r1,
- "column_focus": c1
- });
- }
- }
- selectionCopyShow(dataVerificationCtrl_default.selectRange);
- });
- $(document).off("click.luckysheetProtection.dvRangeConfirm").on("click.luckysheetProtection.dvRangeConfirm", "#luckysheet-dataVerificationRange-dialog-confirm", function(e) {
- let txt = $(this).parents("#luckysheet-dataVerificationRange-dialog").find("input").val();
- let $input = $("#protection-allowRangeAdd-range input"), inputValue = $input.val();
- if (inputValue.substr(inputValue.length - 1, 1) == ",") {
- $input.val(inputValue + txt);
- } else {
- $input.val(txt);
- }
- $("#luckysheet-dataVerificationRange-dialog").hide();
- $("#luckysheet-modal-dialog-mask").show();
- $("#luckysheet-protection-rangeItem-dialog").show();
- let range2 = [];
- selectionCopyShow(range2);
- });
- $(document).off("click.luckysheetProtection.dvRangeClose").on("click.dvRangeClose", "#luckysheet-dataVerificationRange-dialog-close", function(e) {
- $("#luckysheet-dataVerificationRange-dialog").hide();
- $("#luckysheet-modal-dialog-mask").show();
- $("#luckysheet-protection-rangeItem-dialog").show();
- let range2 = [];
- selectionCopyShow(range2);
- });
- $(document).on("click.luckysheetProtection.luckysheetProtection", "#luckysheet-dataVerificationRange-dialog .luckysheet-modal-dialog-title-close", function(e) {
- $("#luckysheet-dataVerificationRange-dialog").hide();
- $("#luckysheet-modal-dialog-mask").show();
- $("#luckysheet-protection-rangeItem-dialog").show();
- let range2 = [];
- selectionCopyShow(range2);
- });
- }
- function initialProtectionRangeModal(file) {
- if (isInitialProtectionAddRang) {
- return;
- }
- isInitialProtectionAddRang = true;
- let _locale = locale_default();
- let local_protection = _locale.protection;
- const locale_button = _locale.button;
- $("body").append(replaceHtml(modelHTML, {
- "id": "luckysheet-protection-rangeItem-dialog",
- "addclass": "luckysheet-protection-rangeItem-dialog",
- "title": local_protection.allowRangeTitle,
- "content": `
-
-
-
- ${local_protection.allowRangeAddTitle}
-
-
-
-
-
-
-
- ${local_protection.allowRangeAddSqrf}
-
-
-
-
-
- ${local_protection.allowRangeAddTitlePassword}
-
-
-
-
-
-
-
- ${local_protection.allowRangeAddTitleHint}
-
-
-
-
-
-
- `,
- "botton": `
${locale_button.insert}
-
${locale_button.cancel} `,
- "style": "z-index:100003"
- }));
- }
- function initialProtectionRIghtBar(file) {
- const _locale = locale_default();
- const local_protection = _locale.protection;
- const locale_button = _locale.button;
- let authorityItemHtml = "";
- for (let i2 = 0; i2 < authorityItemArr.length; i2++) {
- let name2 = authorityItemArr[i2];
- authorityItemHtml += `
-
-
- ${local_protection[name2]}
-
-
- `;
- }
- const protectionModalHtml = `
-
-
${local_protection.protectiontTitle}
-
-
-
-
- ${local_protection.swichProtectionTip}
-
-
-
-
-
-
-
- ${local_protection.authorityTitle}
-
- ${authorityItemHtml}
-
-
-
-
- ${local_protection.allowRangeTitle}
-
-
-
- ${local_protection.allowRangeAdd}
-
-
-
-
-
-
-
-
-
-
-
- ${locale_button.confirm}
-
-
-
-
- ${locale_button.cancel}
-
-
-
-
-
- `;
- $("body").append(protectionModalHtml);
- $("body").append(replaceHtml(modelHTML, {
- "id": "luckysheet-protection-sheet-validation",
- "addclass": "luckysheet-protection-sheet-validation",
- "title": local_protection.validationTitle,
- "content": `
-
-
- ${local_protection.validationTips}
-
-
-
- `,
- "botton": `
${locale_button.confirm}
-
${locale_button.cancel} `,
- "style": "z-index:100003"
- }));
- }
- function restoreProtectionConfig(aut) {
- if (aut == null) {
- aut = {};
- }
- for (let i2 = 0; i2 < authorityItemArr.length; i2++) {
- let name2 = authorityItemArr[i2];
- let checkId = "luckysheet-protection-check-" + name2;
- let authorityValue = aut[name2];
- if (authorityValue == null) {
- authorityValue = 0;
- }
- if (authorityValue == null && name2 in {selectLockedCells: 1, selectunLockedCells: 1}) {
- authorityValue = 1;
- }
- $("#" + checkId).prop("checked", authorityValue == 1 ? true : false);
- }
- if (aut.password != null && aut.password.length > 0) {
- if (aut.algorithmName == "None" || aut.algorithmName == null) {
- $("#protection-password").val(aut.password);
- } else {
- $("#protection-password").val("\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022");
- }
- } else {
- $("#protection-password").val("");
- }
- let sheet = aut.sheet;
- if (aut.sheet == null) {
- sheet = 0;
- }
- $("#protection-swichProtectionState").prop("checked", sheet == 1 ? true : false);
- let hintText = aut.hintText;
- if (hintText == null) {
- hintText = "";
- }
- $("#protection-hint").val(hintText);
- rangeItemListCache = [];
- $("#luckysheet-protection-rangeItem-container").empty();
- let allowRangeList = aut.allowRangeList;
- if (allowRangeList != null && allowRangeList.length > 0) {
- for (let i2 = 0; i2 < allowRangeList.length; i2++) {
- let item2 = allowRangeList[i2];
- addRangeItem(item2);
- rangeItemListCache.push(item2);
- }
- }
- }
- function openProtectionModal(file) {
- if (!isInitialProtection) {
- initialProtectionRIghtBar(file);
- initialEvent(file);
- isInitialProtection = true;
- }
- updatingSheetFile = file;
- if (file != null && file.config != null && file.config.authority != null) {
- let aut = file.config.authority;
- if (firstInputSheetProtectionPassword && aut.sheet == 1 && aut.password != null && aut.password.length > 0) {
- validationAuthority = aut;
- $("#luckysheet-protection-sheet-validation input").val("");
- openSelfModel("luckysheet-protection-sheet-validation");
- return;
- } else {
- restoreProtectionConfig(aut);
- }
- } else {
- $("#protection-swichProtectionState").prop("checked", true);
- $("#luckysheet-protection-check-selectLockedCells").prop("checked", true);
- $("#luckysheet-protection-check-selectunLockedCells").prop("checked", true);
- $("#luckysheet-protection-check-formatCells").prop("checked", true);
- $("#luckysheet-protection-check-formatColumns").prop("checked", true);
- $("#luckysheet-protection-check-formatRows").prop("checked", true);
- $("#luckysheet-protection-check-insertColumns").prop("checked", true);
- $("#luckysheet-protection-check-insertRows").prop("checked", true);
- $("#luckysheet-protection-check-deleteColumns").prop("checked", true);
- $("#luckysheet-protection-check-insertHyperlinks").prop("checked", true);
- $("#luckysheet-protection-check-deleteRows").prop("checked", true);
- $("#luckysheet-protection-check-sort").prop("checked", true);
- $("#luckysheet-protection-check-filter").prop("checked", true);
- $("#luckysheet-protection-check-usePivotTablereports").prop("checked", true);
- $("#luckysheet-protection-check-editObjects").prop("checked", true);
- $("#luckysheet-protection-check-editScenarios").prop("checked", true);
- clearProtectionModalEditContent();
- }
- $("#luckysheet-modal-dialog-slider-protection").show();
- luckysheetsizeauto();
- }
- function clearProtectionModalEditContent() {
- rangeItemListCache = [];
- $("#luckysheet-protection-rangeItem-container").empty();
- }
- function closeProtectionModal() {
- $("#luckysheet-protection-rangeItem-dialog").hide();
- $("#luckysheet-modal-dialog-slider-protection").hide();
- luckysheetsizeauto();
- }
- function checkProtectionLockedSqref(r2, c2, aut, local_protection, isOpenAlert = true, isLock = true) {
- let isPass = false;
- let rangeAut = aut.allowRangeList;
- if (rangeAut != null && rangeAut.length > 0) {
- let isExists = false;
- for (let i2 = 0; i2 < rangeAut.length; i2++) {
- let ra = rangeAut[i2];
- let sqref = ra.sqref;
- let range2 = dataVerificationCtrl_default.getRangeByTxt(sqref);
- if (range2.length > 0) {
- for (let s = 0; s < range2.length; s++) {
- let r1 = range2[s].row[0], r22 = range2[s].row[1];
- let c1 = range2[s].column[0], c22 = range2[s].column[1];
- if (r2 >= r1 && r2 <= r22 && c2 >= c1 && c2 <= c22) {
- isExists = true;
- break;
- }
- }
- }
- if (isExists) {
- let password = ra.password;
- if (password != null && password.length > 0 && !(sqref in inputRangeProtectionPassword)) {
- if (isOpenAlert) {
- openRangePasswordModal(ra);
- $("#luckysheet-selection-copy .luckysheet-selection-copy").hide();
- }
- return false;
- } else {
- isPass = true;
- }
- break;
- }
- }
- }
- if (!isPass && !isLock)
- isPass = true;
- if (!isPass && isOpenAlert) {
- let ht;
- if (aut.hintText != null && aut.hintText.length > 0) {
- ht = aut.hintText;
- } else {
- ht = local_protection.defaultSheetHintText;
- }
- tooltip_default.info("", ht);
- $("#luckysheet-selection-copy .luckysheet-selection-copy").hide();
- }
- return isPass;
- }
- function openRangePasswordModal(rangeAut) {
- const _locale = locale_default();
- const local_protection = _locale.protection;
- const locale_button = _locale.button;
- if (!initialRangePasswordHtml) {
- $("body").append(replaceHtml(modelHTML, {
- "id": "luckysheet-protection-range-validation",
- "addclass": "luckysheet-protection-sheet-validation",
- "title": local_protection.validationTitle,
- "content": `
-
-
- `,
- "botton": `
${locale_button.confirm}
-
${locale_button.cancel} `,
- "style": "z-index:100003"
- }));
- }
- initialRangePasswordHtml = true;
- openSelfModel("luckysheet-protection-range-validation");
- let $hint = $("#luckysheet-protection-range-validation-hint");
- if (rangeAut.hintText != null && rangeAut.hintText.length > 0) {
- $hint.html(rangeAut.hintText);
- } else {
- $hint.html(local_protection.defaultRangeHintText);
- }
- let $rangeV = $("#luckysheet-protection-range-validation");
- let $input = $rangeV.find("input");
- $input.val("");
- $("#luckysheet-protection-range-validation-confirm").off("click").on("click", function() {
- let password = $input.val();
- if (password == null || password.length == 0) {
- alert(local_protection.checkPasswordNullalert);
- return;
- }
- if (rangeAut.algorithmName != null && rangeAut.algorithmName != "None") {
- if (rangeAut.saltValue != null && rangeAut.saltValue.length > 0) {
- var hasher = CryptoApi.getHasher(rangeAut.algorithmName);
- password = CryptoApi.hmac(rangeAut.saltValue, password, hasher);
- } else {
- password = CryptoApi.hash(rangeAut.algorithmName, password);
- }
- }
- if (password == rangeAut.password) {
- inputRangeProtectionPassword[rangeAut.sqref] = 1;
- $rangeV.hide();
- $("#luckysheet-modal-dialog-mask").hide();
- alert(local_protection.checkPasswordSucceedalert);
- } else {
- alert(local_protection.checkPasswordWrongalert);
- }
- });
- }
- function checkProtectionNotEnable(sheetIndex) {
- let sheetFile = sheetmanage_default.getSheetByIndex(sheetIndex);
- if (sheetFile == null) {
- return true;
- }
- if (sheetFile.config == null || sheetFile.config.authority == null) {
- return true;
- }
- let aut = sheetFile.config.authority;
- if (aut == null || aut.sheet == null || aut.sheet == 0) {
- return true;
- }
- const _locale = locale_default();
- const local_protection = _locale.protection;
- let ht;
- if (aut.hintText != null && aut.hintText.length > 0) {
- ht = aut.hintText;
- } else {
- ht = local_protection.defaultSheetHintText;
- }
- tooltip_default.info("", ht);
- return false;
- }
- function checkProtectionLocked(r2, c2, sheetIndex, isOpenAlert = true, isLock = true) {
- let sheetFile = sheetmanage_default.getSheetByIndex(sheetIndex);
- if (sheetFile == null) {
- return true;
- }
- if (sheetFile.config == null || sheetFile.config.authority == null) {
- return true;
- }
- let data = sheetFile.data, cell = data[r2][c2], aut = sheetFile.config.authority;
- if (aut == null || aut.sheet == null || aut.sheet == 0) {
- return true;
- }
- if (cell && cell.lo === 0) {
- return true;
- }
- const _locale = locale_default();
- const local_protection = _locale.protection;
- return checkProtectionLockedSqref(r2, c2, aut, local_protection, isOpenAlert, isLock);
- }
- function checkProtectionCellHidden(r2, c2, sheetIndex) {
- let sheetFile = sheetmanage_default.getSheetByIndex(sheetIndex);
- if (!sheetFile || sheetFile.data && !sheetFile.data[r2] || sheetFile.data && !sheetFile.data[r2][c2]) {
- return true;
- }
- if (sheetFile.config == null || sheetFile.config.authority == null) {
- return true;
- }
- let data = sheetFile.data, cell = data[r2][c2], aut = sheetFile.config.authority;
- if (aut == null || aut.sheet == null || aut.sheet == 0) {
- return true;
- }
- if (cell == null || cell.hi == null || cell.hi == 0) {
- return true;
- }
- return false;
- }
- function checkProtectionLockedRangeList(rangeList, sheetIndex) {
- let sheetFile = sheetmanage_default.getSheetByIndex(sheetIndex);
- if (sheetFile == null) {
- return true;
- }
- if (sheetFile.config == null || sheetFile.config.authority == null) {
- return true;
- }
- let aut = sheetFile.config.authority;
- if (aut == null || aut.sheet == null || aut.sheet == 0) {
- return true;
- }
- if (rangeList == null || rangeList.length == 0) {
- return true;
- }
- const _locale = locale_default();
- const local_protection = _locale.protection;
- for (let s = 0; s < rangeList.length; s++) {
- let r1 = rangeList[s].row[0], r2 = rangeList[s].row[1];
- let c1 = rangeList[s].column[0], c2 = rangeList[s].column[1];
- for (let r3 = r1; r3 <= r2; r3++) {
- for (let c3 = c1; c3 <= c2; c3++) {
- const cell = sheetFile.data[r3][c3] || {};
- let isLock = cell.lo === void 0 || cell.lo === 1, isPass = checkProtectionLockedSqref(r3, c3, aut, local_protection, true, isLock);
- if (!isPass) {
- return false;
- }
- }
- }
- }
- return true;
- }
- function checkProtectionSelectLockedOrUnLockedCells(r2, c2, sheetIndex) {
- const _locale = locale_default();
- const local_protection = _locale.protection;
- let sheetFile = sheetmanage_default.getSheetByIndex(sheetIndex);
- if (sheetFile == null) {
- return true;
- }
- if (sheetFile.config == null || sheetFile.config.authority == null) {
- return true;
- }
- let data = sheetFile.data, cell = data[r2][c2], aut = sheetFile.config.authority;
- if (aut == null || aut.sheet == null || aut.sheet == 0) {
- return true;
- }
- if (cell && cell.lo === 0) {
- if (aut.selectunLockedCells == 1 || aut.selectunLockedCells == null) {
- return true;
- } else {
- return false;
- }
- } else {
- let isAllEdit = checkProtectionLockedSqref(r2, c2, aut, local_protection, false);
- if (isAllEdit) {
- if (aut.selectunLockedCells == 1 || aut.selectunLockedCells == null) {
- return true;
- } else {
- return false;
- }
- } else {
- if (aut.selectLockedCells == 1 || aut.selectLockedCells == null) {
- return true;
- } else {
- return false;
- }
- }
- }
- }
- function checkProtectionAllSelected(sheetIndex) {
- const _locale = locale_default();
- const local_protection = _locale.protection;
- let sheetFile = sheetmanage_default.getSheetByIndex(sheetIndex);
- if (sheetFile == null) {
- return true;
- }
- if (sheetFile.config == null || sheetFile.config.authority == null) {
- return true;
- }
- let aut = sheetFile.config.authority;
- if (aut == null || aut.sheet == null || aut.sheet == 0) {
- return true;
- }
- let selectunLockedCells = false;
- if (aut.selectunLockedCells == 1 || aut.selectunLockedCells == null) {
- selectunLockedCells = true;
- }
- let selectLockedCells = false;
- if (aut.selectLockedCells == 1 || aut.selectLockedCells == null) {
- selectLockedCells = true;
- }
- if (selectunLockedCells && selectLockedCells) {
- return true;
- }
- return false;
- }
- function checkProtectionFormatCells(sheetIndex) {
- let sheetFile = sheetmanage_default.getSheetByIndex(sheetIndex);
- if (sheetFile == null) {
- return true;
- }
- if (sheetFile.config == null || sheetFile.config.authority == null) {
- return true;
- }
- let aut = sheetFile.config.authority;
- if (aut == null || aut.sheet == null || aut.sheet == 0) {
- return true;
- }
- if (aut.formatCells == 1 || aut.formatCells == null) {
- return true;
- }
- const _locale = locale_default();
- const local_protection = _locale.protection;
- let ht;
- if (aut.hintText != null && aut.hintText.length > 0) {
- ht = aut.hintText;
- } else {
- ht = local_protection.defaultSheetHintText;
- }
- tooltip_default.info("", ht);
- return false;
- }
- function checkProtectionAuthorityNormal(sheetIndex, type = "formatColumns", isAlert = true) {
- let sheetFile = sheetmanage_default.getSheetByIndex(sheetIndex);
- if (sheetFile == null) {
- return true;
- }
- if (sheetFile.config == null || sheetFile.config.authority == null) {
- return true;
- }
- let aut = sheetFile.config.authority;
- if (aut == null || aut.sheet == null || aut.sheet == 0) {
- return true;
- }
- if (aut[type] == 1 || aut[type] == null) {
- return true;
- }
- if (isAlert) {
- const _locale = locale_default();
- const local_protection = _locale.protection;
- let ht;
- if (aut.hintText != null && aut.hintText.length > 0) {
- ht = aut.hintText;
- } else {
- ht = local_protection.defaultSheetHintText;
- }
- tooltip_default.info("", ht);
- }
- return false;
- }
- var isInitialProtection, isInitialProtectionAddRang, rangeItemListCache, isAddRangeItemState, updateRangeItemIndex, validationAuthority, updatingSheetFile, firstInputSheetProtectionPassword, inputRangeProtectionPassword, initialRangePasswordHtml, authorityItemArr;
- var init_protection = __esm({
- "src/controllers/protection.js"() {
- init_store();
- init_locale();
- init_constant();
- init_get();
- init_set();
- init_sheetmanage();
- init_resize();
- init_dataVerificationCtrl();
- init_util();
- init_select();
- init_tooltip();
- init_cleargridelement();
- isInitialProtection = false;
- isInitialProtectionAddRang = false;
- rangeItemListCache = [];
- isAddRangeItemState = true;
- updateRangeItemIndex = null;
- validationAuthority = null;
- updatingSheetFile = null;
- firstInputSheetProtectionPassword = true;
- inputRangeProtectionPassword = {};
- initialRangePasswordHtml = false;
- authorityItemArr = [
- "selectLockedCells",
- "selectunLockedCells",
- "formatCells",
- "formatColumns",
- "formatRows",
- "insertColumns",
- "insertRows",
- "insertHyperlinks",
- "deleteColumns",
- "deleteRows",
- "sort",
- "filter",
- "usePivotTablereports",
- "editObjects",
- "editScenarios"
- ];
- }
- });
-
- // src/global/sort.js
- function orderbydata(data, index2, isAsc) {
- if (isAsc == null) {
- isAsc = true;
- }
- let a = function(x, y) {
- let x1 = x[index2], y1 = y[index2];
- if (getObjType(x[index2]) == "object") {
- x1 = x[index2].v;
- }
- if (getObjType(y[index2]) == "object") {
- y1 = y[index2].v;
- }
- if (isRealNull(x1)) {
- return 1;
- }
- if (isRealNull(y1)) {
- return -1;
- }
- if (isdatetime(x1) && isdatetime(y1)) {
- return diff(x1, y1);
- } else if (isRealNum(x1) && isRealNum(y1)) {
- return (0, import_numeral2.default)(x1).value() - (0, import_numeral2.default)(y1).value();
- } else if (!isRealNum(x1) && !isRealNum(y1)) {
- return x1.localeCompare(y1, "zh");
- } else if (!isRealNum(x1)) {
- return 1;
- } else if (!isRealNum(y1)) {
- return -1;
- }
- };
- let d = function(x, y) {
- let x1 = x[index2], y1 = y[index2];
- if (getObjType(x[index2]) == "object") {
- x1 = x[index2].v;
- }
- if (getObjType(y[index2]) == "object") {
- y1 = y[index2].v;
- }
- if (isRealNull(x1)) {
- return 1;
- }
- if (isRealNull(y1)) {
- return -1;
- }
- if (isdatetime(x1) && isdatetime(y1)) {
- return diff(y1, x1);
- } else if (isRealNum(x1) && isRealNum(y1)) {
- return (0, import_numeral2.default)(y1).value() - (0, import_numeral2.default)(x1).value();
- } else if (!isRealNum(x1) && !isRealNum(y1)) {
- return y1.localeCompare(x1, "zh");
- } else if (!isRealNum(x1)) {
- return -1;
- } else if (!isRealNum(y1)) {
- return 1;
- }
- };
- if (isAsc) {
- return data.sort(a);
- } else {
- return data.sort(d);
- }
- }
- function orderbydata1D(data, isAsc) {
- if (isAsc == null) {
- isAsc = true;
- }
- let a = function(x, y) {
- let x1 = x, y1 = y;
- if (getObjType(x) == "object") {
- x1 = x.v;
- }
- if (getObjType(y) == "object") {
- y1 = y.v;
- }
- if (x1 == null) {
- x1 = "";
- }
- if (y1 == null) {
- y1 = "";
- }
- if (isdatetime(x1) && isdatetime(y1)) {
- return diff(x1, y1);
- } else if (isRealNum(x1) && isRealNum(y1)) {
- return (0, import_numeral2.default)(x1).value() - (0, import_numeral2.default)(y1).value();
- } else if (!isRealNum(x1) && !isRealNum(y1)) {
- return x1.localeCompare(y1, "zh");
- } else if (!isRealNum(x1)) {
- return 1;
- } else if (!isRealNum(y1)) {
- return -1;
- }
- };
- let d = function(x, y) {
- let x1 = x, y1 = y;
- if (getObjType(x) == "object") {
- x1 = x.v;
- }
- if (getObjType(y) == "object") {
- y1 = y.v;
- }
- if (x1 == null) {
- x1 = "";
- }
- if (y1 == null) {
- y1 = "";
- }
- if (isdatetime(x1) && isdatetime(y1)) {
- return diff(y1, x1);
- } else if (isRealNum(x1) && isRealNum(y1)) {
- return (0, import_numeral2.default)(y1).value() - (0, import_numeral2.default)(x1).value();
- } else if (!isRealNum(x1) && !isRealNum(y1)) {
- return y1.localeCompare(x1, "zh");
- } else if (!isRealNum(x1)) {
- return -1;
- } else if (!isRealNum(y1)) {
- return 1;
- }
- };
- if (isAsc) {
- return data.sort(a);
- } else {
- return data.sort(d);
- }
- }
- function sortSelection(isAsc) {
- if (!checkProtectionAuthorityNormal(store_default.currentSheetIndex, "sort")) {
- return;
- }
- const _locale = locale_default();
- const locale_sort = _locale.sort;
- if (store_default.luckysheet_select_save.length > 1) {
- if (isEditMode()) {
- alert(locale_sort.noRangeError);
- } else {
- tooltip_default.info(locale_sort.noRangeError, "");
- }
- return;
- }
- if (isAsc == null) {
- isAsc = true;
- }
- let d = editor_default.deepCopyFlowData(store_default.flowdata);
- let r1 = store_default.luckysheet_select_save[0].row[0], r2 = store_default.luckysheet_select_save[0].row[1];
- let c1 = store_default.luckysheet_select_save[0].column[0], c2 = store_default.luckysheet_select_save[0].column[1];
- let str, edr;
- for (let r3 = r1; r3 <= r2; r3++) {
- if (d[r3] != null && d[r3][c1] != null) {
- let cell = d[r3][c1];
- if (cell.mc != null || isRealNull(cell.v)) {
- continue;
- }
- if (str == null && /[\u4e00-\u9fa5]+/g.test(cell.v)) {
- str = r3 + 1;
- edr = r3 + 1;
- continue;
- }
- if (str == null) {
- str = r3;
- }
- edr = r3;
- }
- }
- if (str == null || str > r2) {
- return;
- }
- let hasMc = false;
- let data = [];
- for (let r3 = str; r3 <= edr; r3++) {
- let data_row = [];
- for (let c3 = c1; c3 <= c2; c3++) {
- if (d[r3][c3] != null && d[r3][c3].mc != null) {
- hasMc = true;
- break;
- }
- data_row.push(d[r3][c3]);
- }
- data.push(data_row);
- }
- if (hasMc) {
- if (isEditMode()) {
- alert(locale_sort.mergeError);
- } else {
- tooltip_default.info(locale_sort.mergeError, "");
- }
- return;
- }
- data = orderbydata(data, 0, isAsc);
- for (let r3 = str; r3 <= edr; r3++) {
- for (let c3 = c1; c3 <= c2; c3++) {
- d[r3][c3] = data[r3 - str][c3 - c1];
- }
- }
- let allParam = {};
- if (store_default.config["rowlen"] != null) {
- let cfg = $.extend(true, {}, store_default.config);
- cfg = rowlenByRange(d, str, edr, cfg);
- allParam = {
- "cfg": cfg,
- "RowlChange": true
- };
- }
- jfrefreshgrid(d, [{"row": [str, edr], "column": [c1, c2]}], allParam);
- }
- function sortColumnSeletion(colIndex, isAsc) {
- if (!checkProtectionAuthorityNormal(store_default.currentSheetIndex, "sort")) {
- return;
- }
- if (isAsc == null) {
- isAsc = true;
- }
- const _locale = locale_default();
- const locale_sort = _locale.sort;
- let d = editor_default.deepCopyFlowData(store_default.flowdata);
- let r1 = 0, r2 = d.length - 1;
- let c1 = 0, c2 = d[0].length - 1;
- let str, edr;
- for (let r3 = r1; r3 <= r2; r3++) {
- if (d[r3][colIndex] != null && d[r3][colIndex].mc != null) {
- continue;
- }
- if (d[r3][colIndex] != null && !isRealNull(d[r3][colIndex].v) && /[\u4e00-\u9fa5]+/g.test(d[r3][colIndex].v) && str == null) {
- str = r3 + 1;
- edr = r3 + 1;
- continue;
- }
- if (str == null) {
- str = r3;
- }
- if (d[r3][colIndex] != null && !isRealNull(d[r3][colIndex].v)) {
- edr = r3;
- }
- }
- if (str == null || str > r2) {
- return;
- }
- let hasMc = false;
- let data = [];
- for (let r3 = str; r3 <= edr; r3++) {
- let data_row = [];
- for (let c3 = c1; c3 <= c2; c3++) {
- if (d[r3][c3] != null && d[r3][c3].mc != null) {
- hasMc = true;
- break;
- }
- data_row.push(d[r3][c3]);
- }
- data.push(data_row);
- }
- if (hasMc) {
- if (isEditMode()) {
- alert(locale_sort.columnSortMergeError);
- } else {
- tooltip_default.info(locale_sort.columnSortMergeError, "");
- }
- return;
- }
- data = orderbydata(data, colIndex, isAsc);
- for (let r3 = str; r3 <= edr; r3++) {
- for (let c3 = c1; c3 <= c2; c3++) {
- d[r3][c3] = data[r3 - str][c3 - c1];
- }
- }
- let allParam = {};
- if (store_default.config["rowlen"] != null) {
- let cfg = $.extend(true, {}, store_default.config);
- cfg = rowlenByRange(d, str, edr, cfg);
- allParam = {
- "cfg": cfg,
- "RowlChange": true
- };
- }
- jfrefreshgrid(d, [{"row": [str, edr], "column": [c1, c2]}], allParam);
- }
- var import_numeral2;
- var init_sort = __esm({
- "src/global/sort.js"() {
- init_util();
- init_validate();
- init_datecontroll();
- init_tooltip();
- init_editor();
- init_getRowlen();
- init_refresh();
- init_protection();
- init_store();
- init_locale();
- import_numeral2 = __toModule(require_numeral());
- }
- });
-
- // src/global/array.js
- var luckysheetArray, array_default;
- var init_array = __esm({
- "src/global/array.js"() {
- init_getdata();
- luckysheetArray = {
- transpose: function(getdata, useGetcellValue = true) {
- let arr = [];
- if (getdata.length == 0) {
- return [];
- }
- if (getdata[0].length == 0) {
- return [];
- }
- for (let c2 = 0; c2 < getdata[0].length; c2++) {
- let a = [];
- for (let r2 = 0; r2 < getdata.length; r2++) {
- let value = "";
- if (getdata[r2] != null && getdata[r2][c2] != null) {
- if (useGetcellValue) {
- value = getcellvalue(r2, c2, getdata);
- } else {
- value = getdata[r2][c2];
- }
- }
- a.push(value);
- }
- arr.push(a);
- }
- return arr;
- },
- minusClear: function(p, m) {
- if (m.row[0] > p.row[1] || m.row[1] < p.row[0] || m.column[0] > p.column[1] || m.column[1] < p.column[0]) {
- return null;
- }
- if (m.row[0] == p.row[0] && m.row[1] < p.row[1] && m.column[0] > p.column[0] && m.column[1] < p.column[1]) {
- return [];
- }
- let ret = [], range2 = {row: [], column: []};
- let row1 = null, column1 = [p.column[0], p.column[1]];
- if (m.row[1] > p.row[0] && m.row[1] < p.row[1]) {
- row1 = [m.row[1] + 1, p.row[1]];
- } else if (m.row[0] > p.row[0] && m.row[0] < p.row[1]) {
- row1 = [p.row[0], m.row[0] - 1];
- }
- if (row1 != null) {
- ret.push({"row": row1, "column": column1});
- }
- let row2 = [p.row[0], p.row[1]], column2 = null;
- if (m.column[1] > p.column[0] && m.column[1] < p.column[1]) {
- column2 = [m.column[1] + 1, p.column[1]];
- } else if (m.column[0] > p.column[0] && m.column[0] < p.column[1]) {
- column2 = [p.column[0], m.column[0] - 1];
- }
- if (column2 != null) {
- ret.push({"row": row2, "column": column2});
- }
- return ret;
- }
- };
- array_default = luckysheetArray;
- }
- });
-
- // src/global/analysis.js
- var analysis, analysis_default;
- var init_analysis = __esm({
- "src/global/analysis.js"() {
- init_util();
- analysis = {
- "STDEVP": function(mean, array1d) {
- let cov = 0;
- for (let i2 = 0; i2 < array1d.length; i2++) {
- let xi = array1d[i2];
- cov += Math.pow(xi - mean, 2);
- }
- return numFormat2(Math.sqrt(cov / array1d.length));
- },
- "STDEV": function(mean, array1d) {
- let cov = 0;
- for (let i2 = 0; i2 < array1d.length; i2++) {
- let xi = array1d[i2];
- cov += Math.pow(xi - mean, 2);
- }
- return numFormat2(Math.sqrt(cov / (array1d.length - 1)));
- },
- "VARP": function(mean, array1d) {
- let cov = 0;
- for (let i2 = 0; i2 < array1d.length; i2++) {
- let xi = array1d[i2];
- cov += Math.pow(xi - mean, 2);
- }
- return numFormat2(cov / array1d.length);
- },
- "let": function(mean, array1d) {
- let cov = 0;
- for (let i2 = 0; i2 < array1d.length; i2++) {
- let xi = array1d[i2];
- cov += Math.pow(xi - mean, 2);
- }
- return numFormat2(cov / (array1d.length - 1));
- }
- };
- analysis_default = analysis;
- }
- });
-
- // src/controllers/pivotTable.js
- var import_numeral3, pivotTable, pivotTable_default;
- var init_pivotTable = __esm({
- "src/controllers/pivotTable.js"() {
- init_get();
- init_util();
- init_getdata();
- init_datecontroll();
- init_format();
- init_validate();
- init_sort();
- init_refresh();
- init_tooltip();
- init_editor();
- init_cleargridelement();
- init_array();
- init_analysis();
- init_select();
- init_sheetSearch();
- init_constant();
- init_sheetmanage();
- init_resize();
- init_server();
- init_protection();
- init_store();
- init_locale();
- import_numeral3 = __toModule(require_numeral());
- init_constant();
- pivotTable = {
- pivotDatas: null,
- pivotSheetIndex: 0,
- pivotDataSheetIndex: 0,
- celldata: null,
- origindata: null,
- getCellData: function(cursheetindex, datasheetindex, data_select_save) {
- let _this2 = this;
- let sheetIndex;
- if (cursheetindex != null) {
- sheetIndex = cursheetindex;
- } else {
- sheetIndex = store_default.currentSheetIndex;
- }
- let realIndex = getSheetIndex(sheetIndex);
- if (getObjType(store_default.luckysheetfile[realIndex].pivotTable) != "object") {
- store_default.luckysheetfile[realIndex].pivotTable = new Function("return " + store_default.luckysheetfile[realIndex].pivotTable)();
- }
- if (store_default.luckysheetfile[realIndex].pivotTable != null) {
- _this2.column = store_default.luckysheetfile[realIndex].pivotTable.column;
- _this2.row = store_default.luckysheetfile[realIndex].pivotTable.row;
- _this2.values = store_default.luckysheetfile[realIndex].pivotTable.values;
- _this2.filter = store_default.luckysheetfile[realIndex].pivotTable.filter;
- _this2.showType = store_default.luckysheetfile[realIndex].pivotTable.showType;
- _this2.filterparm = store_default.luckysheetfile[realIndex].pivotTable.filterparm;
- if (store_default.luckysheetfile[realIndex].pivotTable.drawPivotTable != null) {
- _this2.drawPivotTable = store_default.luckysheetfile[realIndex].pivotTable.drawPivotTable;
- } else {
- _this2.drawPivotTable = true;
- }
- if (store_default.luckysheetfile[realIndex].pivotTable.pivotTableBoundary != null) {
- _this2.pivotTableBoundary = store_default.luckysheetfile[realIndex].pivotTable.pivotTableBoundary;
- } else {
- _this2.pivotTableBoundary = [12, 6];
- }
- if (data_select_save != null) {
- _this2.pivot_select_save = data_select_save;
- } else {
- _this2.pivot_select_save = store_default.luckysheetfile[realIndex].pivotTable.pivot_select_save;
- }
- if (datasheetindex != null) {
- _this2.pivotDataSheetIndex = datasheetindex;
- } else {
- _this2.pivotDataSheetIndex = store_default.luckysheetfile[realIndex].pivotTable.pivotDataSheetIndex;
- }
- } else {
- _this2.column = null;
- _this2.row = null;
- _this2.values = null;
- _this2.filter = null;
- _this2.showType = null;
- _this2.filterparm = null;
- _this2.drawPivotTable = true;
- _this2.pivotTableBoundary = [12, 6];
- if (data_select_save != null) {
- _this2.pivot_select_save = data_select_save;
- } else {
- _this2.pivot_select_save = store_default.luckysheet_select_save;
- }
- if (datasheetindex != null) {
- _this2.pivotDataSheetIndex = datasheetindex;
- } else {
- _this2.pivotDataSheetIndex = sheetIndex;
- }
- }
- let pivotrealIndex = getSheetIndex(_this2.pivotDataSheetIndex);
- let otherfile = store_default.luckysheetfile[pivotrealIndex];
- if (otherfile["data"] == null) {
- otherfile["data"] = sheetmanage_default.buildGridData(otherfile);
- }
- _this2.origindata = getdatabyselectionD(otherfile.data, _this2.pivot_select_save);
- let rowhidden = {};
- if (_this2.filterparm != null) {
- for (let f in _this2.filterparm) {
- for (let h in _this2.filterparm[f]) {
- if (h === "rowhidden" && _this2.filterparm[f][h] != null) {
- rowhidden = $.extend(true, rowhidden, _this2.filterparm[f][h]);
- }
- }
- }
- }
- _this2.rowhidden = rowhidden;
- _this2.pivotSheetIndex = sheetIndex;
- let newdata = [];
- for (let i2 = 0; i2 < _this2.origindata.length; i2++) {
- if (_this2.rowhidden != null && _this2.rowhidden[i2] != null) {
- continue;
- }
- newdata.push([].concat(_this2.origindata[i2]));
- }
- _this2.celldata = newdata;
- _this2.pivot_data_type = {};
- for (let c2 = 0; c2 < _this2.celldata[1].length; c2++) {
- let type = isdatatype(_this2.celldata[1][c2]);
- _this2.pivot_data_type[c2.toString()] = type;
- }
- },
- pivot_data_type: {},
- pivot_select_save: null,
- column: null,
- row: null,
- values: null,
- filter: null,
- showType: null,
- rowhidden: null,
- selected: null,
- caljs: null,
- initial: true,
- filterparm: null,
- luckysheet_pivotTable_select_state: false,
- jgridCurrentPivotInput: null,
- movestate: false,
- moveitemposition: [],
- movesave: {},
- showvaluecolrow: function() {
- let _this2 = this;
- if ($("#luckysheet-modal-dialog-config-value .luckysheet-modal-dialog-slider-config-item").length >= 2) {
- $("#luckysheetpivottablevaluecolrowshow").show();
- if (_this2.showType == "column") {
- $("#luckysheetpivottablevaluecolrow").prop("checked", true);
- $("#luckysheetpivottablevaluecolrowshow label[for='luckysheetpivottablevaluecolrow']").addClass("ui-state-active");
- $("#luckysheetpivottablevaluecolrow1").prop("checked", false);
- $("#luckysheetpivottablevaluecolrowshow label[for='luckysheetpivottablevaluecolrow1']").removeClass("ui-state-active");
- } else {
- $("#luckysheetpivottablevaluecolrow1").prop("checked", true);
- $("#luckysheetpivottablevaluecolrowshow label[for='luckysheetpivottablevaluecolrow1']").addClass("ui-state-active");
- $("#luckysheetpivottablevaluecolrow").prop("checked", false);
- $("#luckysheetpivottablevaluecolrowshow label[for='luckysheetpivottablevaluecolrow']").removeClass("ui-state-active");
- }
- } else {
- $("#luckysheetpivottablevaluecolrowshow").hide();
- }
- },
- resetOrderby: function(obj) {
- let orderby = $("#luckysheet-modal-dialog-config-value .luckysheet-modal-dialog-slider-config-item").index(obj);
- $("#luckysheet-modal-dialog-config-row, #luckysheet-modal-dialog-config-column").find(".luckysheet-modal-dialog-slider-config-item").each(function() {
- if ($(this).data("orderby") == orderby) {
- $(this).data("orderby", "self");
- }
- });
- },
- luckysheetsliderlistclearfilter: function($filter) {
- let _this2 = this;
- let $t = $filter.parent();
- let cindex = $t.data("index");
- let rowhidden = {}, selected = {}, d = _this2.origindata, filterdata = {};
- $t.data("rowhidden", "").find(".luckysheet-slider-list-item-filtered").hide();
- _this2.setDatatojsfile("selected", {}, cindex);
- _this2.setDatatojsfile("rowhidden", null, cindex);
- let newdata = [];
- for (let i2 = 0; i2 < d.length; i2++) {
- if (rowhidden[i2] != null) {
- continue;
- }
- newdata.push([].concat(d[i2]));
- }
- _this2.celldata = newdata;
- _this2.refreshPivotTable();
- $("#luckysheet-pivotTableFilter-menu, #luckysheet-pivotTableFilter-submenu").hide();
- },
- luckysheetsliderlistitemfilter: function($filter) {
- let _this2 = this;
- const _locale = locale_default();
- const locale_filter = _locale.filter;
- let $t = $filter.parent(), toffset = $t.offset(), $menu = $("#luckysheet-pivotTableFilter-menu"), winH = $(window).height(), winW = $(window).width();
- let cindex = $t.data("index");
- let rowhidden = $t.data("rowhidden");
- if (rowhidden == null || rowhidden == "") {
- rowhidden = {};
- } else if (getObjType(rowhidden) == "string") {
- rowhidden = JSON.parse(rowhidden);
- }
- $("body .luckysheet-cols-menu").hide();
- $("#luckysheet-pivotTableFilter-menu, #luckysheet-pivotTableFilter-submenu").hide();
- $("#luckysheet-pivotTableFilter-byvalue-input").val("");
- $("#luckysheet-pivotTableFilter-bycondition").next().hide();
- $("#luckysheet-pivotTableFilter-byvalue").next().show();
- $menu.data("index", cindex);
- $("#luckysheet-pivotTableFilter-menu .luckysheet-pivotTableFilter-selected-input").hide().find("input").val();
- $("#luckysheet-pivotTableFilter-selected span").data("type", "0").data("type", null).text(locale_filter.filiterInputNone);
- let byconditiontype = $t.data("byconditiontype");
- $("#luckysheet-pivotTableFilter-selected span").data("value", $t.data("byconditionvalue")).data("type", byconditiontype).text($t.data("byconditiontext"));
- if (byconditiontype == "2") {
- let $input = $("#luckysheet-pivotTableFilter-menu .luckysheet-pivotTableFilter-selected-input2").show().find("input");
- $input.eq(0).val($t.data("byconditionvalue1"));
- $input.eq(1).val($t.data("byconditionvalue2"));
- } else if (byconditiontype == "1") {
- $("#luckysheet-pivotTableFilter-menu .luckysheet-pivotTableFilter-selected-input").eq(0).show().find("input").val($t.data("byconditionvalue1"));
- }
- const loadingObj = luckysheetlodingHTML("#luckysheet-pivotTableFilter-byvalue-select", {
- text: locale_filter.filiterMoreDataTip
- });
- $("#luckysheet-pivotTableFilter-byvalue-select").empty().append(loadingObj.el);
- let rowhiddenother = {};
- $("#luckysheet-modal-dialog-pivotTable-list .luckysheet-modal-dialog-slider-list-item").not($t.get(0)).each(function() {
- let $t2 = $(this), rh = $t2.data("rowhidden");
- if (rh == null || rh == "") {
- return true;
- }
- if (getObjType(rh) == "string") {
- rh = JSON.parse(rh);
- }
- for (let r2 in rh) {
- rowhiddenother[r2] = 0;
- }
- });
- let data = _this2.origindata;
- setTimeout(function() {
- let dvmap = {};
- let dvmap_uncheck = {};
- let vmap = {};
- let vmap_uncheck = {};
- for (let r2 = 1; r2 < data.length; r2++) {
- if (r2 in rowhiddenother) {
- continue;
- }
- if (data[r2] == null) {
- continue;
- }
- let cell = data[r2][cindex];
- if (cell != null && cell.ct != null && cell.ct.t == "d") {
- let v = update("YYYY-MM-DD", cell.v);
- let y = v.split("-")[0];
- let m = v.split("-")[1];
- let d = v.split("-")[2];
- if (!(y in dvmap)) {
- dvmap[y] = {};
- }
- if (!(m in dvmap[y])) {
- dvmap[y][m] = {};
- }
- if (!(d in dvmap[y][m])) {
- dvmap[y][m][d] = 0;
- }
- dvmap[y][m][d]++;
- if (r2 in rowhidden) {
- dvmap_uncheck[y] = 0;
- dvmap_uncheck[m] = 0;
- dvmap_uncheck[d] = 0;
- }
- } else {
- let v, m;
- if (cell == null || isRealNull(cell.v)) {
- v = null;
- m = null;
- } else {
- v = cell.v;
- m = cell.m;
- }
- if (!(v in vmap)) {
- vmap[v] = {};
- }
- if (!(m in vmap[v])) {
- vmap[v][m] = 0;
- }
- vmap[v][m]++;
- if (r2 in rowhidden) {
- vmap_uncheck[v + "#$$$#" + m] = 0;
- }
- }
- }
- let item2 = [];
- if (JSON.stringify(dvmap).length > 2) {
- for (let y in dvmap) {
- let ysum = 0;
- let monthHtml = "";
- for (let m in dvmap[y]) {
- let msum = 0;
- let dayHtml = "";
- for (let d in dvmap[y][m]) {
- let dayL = dvmap[y][m][d];
- msum += dayL;
- let mT;
- if (Number(m) < 10) {
- mT = "0" + Number(m);
- } else {
- mT = m;
- }
- let dT;
- if (Number(d) < 10) {
- dT = "0" + Number(d);
- } else {
- dT = d;
- }
- if (y in dvmap_uncheck && m in dvmap_uncheck && d in dvmap_uncheck) {
- dayHtml += '
' + d + ' ( ' + dayL + " )
";
- } else {
- dayHtml += '
' + d + ' ( ' + dayL + " )
";
- }
- }
- ysum += msum;
- let mT2;
- if (Number(m) < 10) {
- mT2 = "0" + Number(m);
- } else {
- mT2 = m;
- }
- if (y in dvmap_uncheck && m in dvmap_uncheck) {
- monthHtml += '
";
- } else {
- monthHtml += '
";
- }
- }
- let yearHtml;
- if (y in dvmap_uncheck) {
- yearHtml = '
";
- } else {
- yearHtml = '
";
- }
- item2.unshift(yearHtml);
- }
- }
- if (JSON.stringify(vmap).length > 2) {
- let vmapKeys = Object.keys(vmap);
- vmapKeys = orderbydata1D(vmapKeys, true);
- for (let i2 = 0; i2 < vmapKeys.length; i2++) {
- let v = vmapKeys[i2];
- for (let x in vmap[v]) {
- let text;
- if (v + "#$$$#" + x == "null#$$$#null") {
- text = locale_filter.valueBlank;
- } else {
- text = x;
- }
- let dataHtml;
- if (v + "#$$$#" + x in vmap_uncheck) {
- dataHtml = '
' + text + ' ( ' + vmap[v][x] + " )
";
- } else {
- dataHtml = '
' + text + ' ( ' + vmap[v][x] + " )
";
- }
- item2.push(dataHtml);
- }
- }
- }
- let containerH = winH - toffset.top - 350;
- if (containerH < 0)
- containerH = 100;
- $("#luckysheet-pivotTableFilter-byvalue-select").append("
" + item2.join("") + "
");
- loadingObj.close();
- }, 1);
- showrightclickmenu($menu, toffset.left - 250, toffset.top);
- },
- getSumTypeName: function(type) {
- let name2 = "";
- const _locale = locale_default();
- const locale_pivotTable = _locale.pivotTable;
- if (type == "SUM") {
- name2 = locale_pivotTable.valueStatisticsSUM;
- } else if (type == "COUNT") {
- name2 = locale_pivotTable.valueStatisticsCOUNT;
- } else if (type == "COUNTA") {
- name2 = locale_pivotTable.valueStatisticsCOUNTA;
- } else if (type == "COUNTUNIQUE") {
- name2 = locale_pivotTable.valueStatisticsCOUNTUNIQUE;
- } else if (type == "AVERAGE") {
- name2 = locale_pivotTable.valueStatisticsAVERAGE;
- } else if (type == "MAX") {
- name2 = locale_pivotTable.valueStatisticsMAX;
- } else if (type == "MIN") {
- name2 = locale_pivotTable.valueStatisticsMIN;
- } else if (type == "MEDIAN") {
- name2 = locale_pivotTable.valueStatisticsMEDIAN;
- } else if (type == "PRODUCT") {
- name2 = locale_pivotTable.valueStatisticsPRODUCT;
- } else if (type == "STDEV") {
- name2 = locale_pivotTable.valueStatisticsSTDEV;
- } else if (type == "STDEVP") {
- name2 = locale_pivotTable.valueStatisticsSTDEVP;
- } else if (type == "let") {
- name2 = locale_pivotTable.valueStatisticslet;
- } else if (type == "VARP") {
- name2 = locale_pivotTable.valueStatisticsVARP;
- }
- return name2;
- },
- setDatatojsfile: function(attr, value, cindex) {
- let _this2 = this;
- let index2 = getSheetIndex(_this2.pivotSheetIndex);
- if (store_default.luckysheetfile[index2]["pivotTable"] == null) {
- store_default.luckysheetfile[index2]["pivotTable"] = {};
- }
- if (cindex == null) {
- store_default.luckysheetfile[index2]["pivotTable"][attr] = value;
- _this2[attr] = value;
- } else {
- if (store_default.luckysheetfile[index2]["pivotTable"]["filterparm"] == null) {
- store_default.luckysheetfile[index2]["pivotTable"]["filterparm"] = {};
- }
- if (store_default.luckysheetfile[index2]["pivotTable"]["filterparm"][cindex.toString()] == null) {
- store_default.luckysheetfile[index2]["pivotTable"]["filterparm"][cindex.toString()] = {};
- }
- store_default.luckysheetfile[index2]["pivotTable"]["filterparm"][cindex.toString()][attr] = value;
- if (_this2["filterparm"] == null) {
- _this2["filterparm"] = {};
- }
- if (_this2["filterparm"][cindex.toString()] == null) {
- _this2["filterparm"][cindex.toString()] = {};
- }
- _this2["filterparm"][cindex.toString()][attr] = value;
- }
- },
- createPivotTable: function(e) {
- if (isEditMode() || store_default.allowEdit === false) {
- return;
- }
- let _this2 = this;
- let datasheetindex = store_default.currentSheetIndex;
- const _locale = locale_default();
- const locale_pivotTable = _locale.pivotTable;
- if (isEditMode()) {
- alert(locale_pivotTable.errorNotAllowEdit);
- return;
- }
- if (store_default.luckysheet_select_save.length > 1) {
- tooltip_default.info("", locale_pivotTable.errorNotAllowMulti);
- return;
- }
- if (store_default.luckysheet_select_save.length == 0 || store_default.luckysheet_select_save[0].row[0] == store_default.luckysheet_select_save[0].row[1] || store_default.luckysheet_select_save[0].column[0] == store_default.luckysheet_select_save[0].column[1]) {
- tooltip_default.info("", locale_pivotTable.errorSelectRange);
- return;
- }
- let select_save = $.extend(true, {}, store_default.luckysheet_select_save[0]);
- sheetmanage_default.addNewSheet(e, true);
- _this2.getCellData(store_default.currentSheetIndex, datasheetindex, select_save);
- _this2.setDatatojsfile("pivot_select_save", select_save);
- _this2.setDatatojsfile("pivotDataSheetIndex", datasheetindex);
- _this2.initialPivotManage();
- },
- changePivotTable: function(index2) {
- let _this2 = this;
- const _locale = locale_default();
- const locale_pivotTable = _locale.pivotTable;
- let pivotDataSheetIndex = store_default.luckysheetfile[getSheetIndex(index2)].pivotTable.pivotDataSheetIndex;
- let real_pivotDataSheetIndex = getSheetIndex(pivotDataSheetIndex);
- if (real_pivotDataSheetIndex == null) {
- tooltip_default.info(locale_pivotTable.errorIsDamage, "");
- return;
- }
- _this2.getCellData(index2);
- _this2.initialPivotManage(true);
- _this2.refreshPivotTable();
- },
- refreshPivotTable: function(isRefreshCanvas = true) {
- let _this2 = this;
- let redo2 = {};
- redo2["pivotTable"] = pivotTable;
- redo2["data"] = editor_default.deepCopyFlowData(store_default.flowdata);
- _this2.storePivotTableParam();
- let ret = _this2.dataHandler(_this2.column, _this2.row, _this2.values, _this2.showType, _this2.celldata);
- _this2.setDatatojsfile("pivotDatas", ret);
- let d = $.extend(true, [], sheetmanage_default.nulldata);
- let data = d;
- let addr = 0, addc = 0;
- if (ret.length == 0) {
- _this2.setDatatojsfile("drawPivotTable", true);
- _this2.setDatatojsfile("pivotTableBoundary", [12, 6]);
- } else {
- _this2.setDatatojsfile("drawPivotTable", false);
- _this2.setDatatojsfile("pivotTableBoundary", [ret.length, ret[0].length]);
- let rlen = ret.length, clen = ret[0].length;
- addr = rlen - d.length;
- addc = clen - d[0].length;
- data = datagridgrowth(d, addr + 20, addc + 10, true);
- for (let r2 = 0; r2 < rlen; r2++) {
- let x = [].concat(data[r2]);
- for (let c2 = 0; c2 < clen; c2++) {
- let value = "";
- if (ret[r2] != null && ret[r2][c2] != null) {
- value = getcellvalue(r2, c2, ret);
- }
- x[c2] = value;
- }
- data[r2] = x;
- }
- }
- redo2["type"] = "pivotTable_change";
- redo2["curdata"] = $.extend(true, [], data);
- redo2["sheetIndex"] = store_default.currentSheetIndex;
- redo2["pivotTablecur"] = _this2.getPivotTableData();
- if (store_default.clearjfundo) {
- store_default.jfundo.length = 0;
- store_default.jfredo.push(redo2);
- }
- cleargridelement();
- store_default.clearjfundo = false;
- if (addr > 0 || addc > 0) {
- jfrefreshgridall(data[0].length, data.length, data, null, store_default.luckysheet_select_save, "datachangeAll", void 0, void 0, isRefreshCanvas);
- } else {
- jfrefreshgrid(data, store_default.luckysheet_select_save, {}, null, isRefreshCanvas);
- selectHightlightShow();
- }
- store_default.clearjfundo = true;
- },
- drawPivotTable: true,
- pivotTableBoundary: [12, 6],
- pivotclick: function(row_index, col_index, index2) {
- if (index2 == null) {
- index2 = store_default.currentSheetIndex;
- }
- let file = store_default.luckysheetfile[getSheetIndex(index2)];
- if (!file.isPivotTable) {
- return;
- }
- let pivotDataSheetIndex = file.pivotTable.pivotDataSheetIndex;
- let real_pivotDataSheetIndex = getSheetIndex(pivotDataSheetIndex);
- if (real_pivotDataSheetIndex == null) {
- return;
- }
- let slider = $("#luckysheet-modal-dialog-slider-pivot");
- let isRangeClick = this.isPivotRange(row_index, col_index);
- if (isRangeClick && slider.is(":hidden")) {
- if (!checkProtectionAuthorityNormal(index2, "usePivotTablereports", false)) {
- return;
- }
- slider.show();
- luckysheetsizeauto();
- $("#luckysheet-sta-content").css("padding-right", 260);
- } else if (!isRangeClick && slider.is(":visible")) {
- slider.hide();
- luckysheetsizeauto();
- $("#luckysheet-sta-content").css("padding-right", 10);
- }
- },
- isPivotRange: function(row_index, col_index) {
- let _this2 = this;
- if (!!store_default.luckysheetcurrentisPivotTable) {
- if (row_index < _this2.pivotTableBoundary[0] && col_index < _this2.pivotTableBoundary[1]) {
- return true;
- } else {
- return false;
- }
- }
- },
- storePivotTableParam: function() {
- let _this2 = this;
- let columnarr = [], rowarr = [], filterarr = [], valuesarr = [];
- $("#luckysheet-modal-dialog-config-filter .luckysheet-modal-dialog-slider-config-item").each(function() {
- let item2 = {};
- item2["index"] = $(this).data("index");
- item2["name"] = $(this).data("name");
- item2["fullname"] = $(this).find(".luckysheet-modal-dialog-slider-config-item-txt").text();
- filterarr.push(item2);
- });
- $("#luckysheet-modal-dialog-config-row .luckysheet-modal-dialog-slider-config-item").each(function() {
- let item2 = {};
- item2["index"] = $(this).data("index");
- item2["name"] = $(this).data("name");
- item2["fullname"] = $(this).find(".luckysheet-modal-dialog-slider-config-item-txt").text();
- item2["order"] = $(this).data("order");
- item2["orderby"] = $(this).data("orderby");
- item2["stastic"] = $(this).data("stastic");
- rowarr.push(item2);
- });
- $("#luckysheet-modal-dialog-config-column .luckysheet-modal-dialog-slider-config-item").each(function() {
- let item2 = {};
- item2["index"] = $(this).data("index");
- item2["name"] = $(this).data("name");
- item2["fullname"] = $(this).find(".luckysheet-modal-dialog-slider-config-item-txt").text();
- item2["order"] = $(this).data("order");
- item2["orderby"] = $(this).data("orderby");
- item2["stastic"] = $(this).data("stastic");
- columnarr.push(item2);
- });
- $("#luckysheet-modal-dialog-config-value .luckysheet-modal-dialog-slider-config-item").each(function() {
- let item2 = {};
- item2["index"] = $(this).data("index");
- item2["name"] = $(this).data("name");
- item2["fullname"] = $(this).find(".luckysheet-modal-dialog-slider-config-item-txt").text();
- item2["sumtype"] = $(this).data("sumtype");
- item2["nameindex"] = $(this).data("nameindex");
- valuesarr.push(item2);
- });
- _this2.setDatatojsfile("column", columnarr);
- _this2.setDatatojsfile("row", rowarr);
- _this2.setDatatojsfile("filter", filterarr);
- _this2.setDatatojsfile("values", valuesarr);
- let showtype = $("#luckysheetpivottablevaluecolrow:checked, #luckysheetpivottablevaluecolrow1:checked").val();
- _this2.setDatatojsfile("showType", showtype == "0" ? "row" : "column");
- let pivotTable3 = _this2.getPivotTableData();
- delete pivotTable3.pivotDatas;
- server_default.saveParam("all", _this2.pivotSheetIndex, pivotTable3, {k: "pivotTable"});
- },
- getPivotTableData: function(dataindex) {
- if (dataindex == null) {
- dataindex = this.pivotSheetIndex;
- }
- let index2 = getSheetIndex(dataindex);
- let pivotTable3 = store_default.luckysheetfile[index2]["pivotTable"];
- if (getObjType(pivotTable3) == "object") {
- pivotTable3 = $.extend(true, {}, store_default.luckysheetfile[index2]["pivotTable"]);
- } else {
- pivotTable3 = new Function("return " + pivotTable3)();
- }
- return pivotTable3;
- },
- addValuesToTitle: function(titles, values) {
- let rowLen = titles.length * values.length, colLen = titles[0].length + 1;
- let retdata = [];
- if (titles.length == 0 && values.length > 0) {
- for (let v = 0; v < values.length; v++) {
- retdata.push(values[v].fullname);
- }
- return retdata;
- }
- if (values.length == 0 && titles.length > 0) {
- return titles;
- }
- for (let r2 = 0; r2 < rowLen; r2++) {
- retdata[r2] = new Array(colLen);
- for (let c2 = 0; c2 < colLen - 1; c2++) {
- retdata[r2][c2] = titles[Math.floor(r2 / values.length)][c2];
- }
- retdata[r2][colLen - 1] = values[r2 % values.length].fullname;
- }
- return retdata;
- },
- initialPivotManage: function(restore) {
- let _this2 = this;
- const _locale = locale_default();
- const locale_pivotTable = _locale.pivotTable;
- const locale_button = _locale.button;
- const locale_filter = _locale.filter;
- if (_this2.initial) {
- _this2.initial = false;
- $("body").append(luckysheetPivotTableHTML());
- $("#luckysheet-modal-dialog-slider-close").click(function() {
- $("#luckysheet-modal-dialog-slider-pivot").hide();
- luckysheetsizeauto();
- });
- $("body").append(replaceHtml(modelHTML, {
- id: "luckysheet-data-pivotTable-selection",
- addclass: "luckysheet-data-pivotTable-selection",
- title: locale_pivotTable.titleSelectionDataRange,
- content: '
',
- botton: '
' + locale_button.confirm + ' ' + locale_button.cancel + " "
- }));
- $("body").append(replaceHtml(filtermenuHTML(), {menuid: "pivotTableFilter"}));
- $("body").append(replaceHtml(filtersubmenuHTML(), {menuid: "pivotTableFilter"}));
- $("body").append(pivottableconfigHTML());
- $("body").append(pivottablesumHTML());
- $("#luckysheet-pivotTableFilter-orderby-asc").remove();
- $("#luckysheet-pivotTableFilter-orderby-desc").next().remove();
- $("#luckysheet-pivotTableFilter-orderby-desc").remove();
- $("#luckysheet-pivotTableFilter-orderby-color").next().remove();
- $("#luckysheet-pivotTableFilter-orderby-color").remove();
- $("#luckysheetpivottablevaluecolrow, #luckysheetpivottablevaluecolrow1").checkboxradio({
- icon: false
- }).change(function() {
- _this2.refreshPivotTable();
- });
- let hidefilersubmenu = null;
- $("#luckysheet-pivotTableFilter-menu").mouseover(function() {
- clearTimeout(hidefilersubmenu);
- hidefilersubmenu = setTimeout(function() {
- $("#luckysheet-pivotTableFilter-submenu").hide();
- }, 500);
- });
- $(document).off("click.ptFilterCheckbox1").on("click.ptFilterCheckbox1", "#luckysheet-pivotTableFilter-byvalue-select .textBox", function() {
- if ($(this).attr("data-check") == "true") {
- $(this).attr("data-check", "false");
- $(this).find("input[type='checkbox']").removeAttr("checked");
- } else {
- $(this).attr("data-check", "true");
- $(this).find("input[type='checkbox']").prop("checked", true);
- }
- });
- $(document).off("click.ptFilterCheckbox2").on("click.ptFilterCheckbox2", "#luckysheet-pivotTableFilter-byvalue-select .year", function() {
- if ($(this).attr("data-check") == "true") {
- $(this).attr("data-check", "false");
- $(this).parents(".yearBox").find(".month").attr("data-check", "false");
- $(this).parents(".yearBox").find(".day").attr("data-check", "false");
- $(this).parents(".yearBox").find("input[type='checkbox']").removeAttr("checked");
- } else {
- $(this).attr("data-check", "true");
- $(this).parents(".yearBox").find(".month").attr("data-check", "true");
- $(this).parents(".yearBox").find(".day").attr("data-check", "true");
- $(this).parents(".yearBox").find("input[type='checkbox']").prop("checked", true);
- }
- });
- $(document).off("click.ptFilterCheckbox3").on("click.ptFilterCheckbox3", "#luckysheet-pivotTableFilter-byvalue-select .month", function() {
- if ($(this).attr("data-check") == "true") {
- $(this).attr("data-check", "false");
- $(this).parents(".monthBox").find(".day").attr("data-check", "false");
- $(this).parents(".monthBox").find("input[type='checkbox']").removeAttr("checked");
- } else {
- $(this).attr("data-check", "true");
- $(this).parents(".monthBox").find(".day").attr("data-check", "true");
- $(this).parents(".monthBox").find("input[type='checkbox']").prop("checked", true);
- }
- let yearDayAllCheck = true;
- let $yearDay = $(this).parents(".yearBox").find(".day");
- $yearDay.each(function(i2, e) {
- if ($(e).attr("data-check") == "true") {
- } else {
- yearDayAllCheck = false;
- }
- });
- if (yearDayAllCheck) {
- $(this).parents(".yearBox").find(".year").attr("data-check", "true");
- $(this).parents(".yearBox").find(".year input[type='checkbox']").prop("checked", true);
- } else {
- $(this).parents(".yearBox").find(".year").attr("data-check", "false");
- $(this).parents(".yearBox").find(".year input[type='checkbox']").removeAttr("checked");
- }
- });
- $(document).off("click.ptFilterCheckbox4").on("click.ptFilterCheckbox4", "#luckysheet-pivotTableFilter-byvalue-select .day", function() {
- if ($(this).attr("data-check") == "true") {
- $(this).attr("data-check", "false");
- $(this).find("input[type='checkbox']").removeAttr("checked");
- } else {
- $(this).attr("data-check", "true");
- $(this).find("input[type='checkbox']").prop("checked", true);
- }
- let monthDayAllCheck = true;
- let $monthDay = $(this).parents(".monthBox").find(".day");
- $monthDay.each(function(i2, e) {
- if ($(e).attr("data-check") == "true") {
- } else {
- monthDayAllCheck = false;
- }
- });
- if (monthDayAllCheck) {
- $(this).parents(".monthBox").find(".month").attr("data-check", "true");
- $(this).parents(".monthBox").find(".month input[type='checkbox']").prop("checked", true);
- } else {
- $(this).parents(".monthBox").find(".month").attr("data-check", "false");
- $(this).parents(".monthBox").find(".month input[type='checkbox']").removeAttr("checked");
- }
- let yearDayAllCheck = true;
- let $yearDay = $(this).parents(".yearBox").find(".day");
- $yearDay.each(function(i2, e) {
- if ($(e).attr("data-check") == "true") {
- } else {
- yearDayAllCheck = false;
- }
- });
- if (yearDayAllCheck) {
- $(this).parents(".yearBox").find(".year").attr("data-check", "true");
- $(this).parents(".yearBox").find(".year input[type='checkbox']").prop("checked", true);
- } else {
- $(this).parents(".yearBox").find(".year").attr("data-check", "false");
- $(this).parents(".yearBox").find(".year input[type='checkbox']").removeAttr("checked");
- }
- });
- $(document).off("click.ptFilterYearDropdown").on("click.ptFilterYearDropdown", "#luckysheet-pivotTableFilter-byvalue-select .yearBox .fa-caret-right", function() {
- let $p = $(this).parents(".luckysheet-mousedown-cancel");
- if ($p.hasClass("year")) {
- $(this).parents(".yearBox").find(".monthList").slideToggle();
- }
- if ($p.hasClass("month")) {
- $(this).parents(".monthBox").find(".dayList").slideToggle();
- }
- });
- $("#luckysheet-pivotTableFilter-byvalue-btn-all").click(function() {
- $("#luckysheet-pivotTableFilter-byvalue-select .ListBox input[type='checkbox']").prop("checked", true);
- $("#luckysheet-pivotTableFilter-byvalue-select .ListBox input[type='checkbox']").parents(".luckysheet-mousedown-cancel").attr("data-check", "true");
- });
- $("#luckysheet-pivotTableFilter-byvalue-btn-contra").click(function() {
- let $input = $("#luckysheet-pivotTableFilter-byvalue-select .ListBox input[type='checkbox']");
- $input.each(function(i2, e) {
- if ($(e).is(":checked")) {
- $(e).removeAttr("checked");
- $(e).parents(".luckysheet-mousedown-cancel").attr("data-check", "false");
- } else {
- $(e).prop("checked", true);
- $(e).parents(".luckysheet-mousedown-cancel").attr("data-check", "true");
- }
- });
- let $month = $("#luckysheet-pivotTableFilter-byvalue-select .ListBox .monthBox");
- $month.each(function(index2, event2) {
- let monthDayAllCheck = true;
- let $monthDay = $(event2).find(".day input[type='checkbox']");
- $monthDay.each(function(i2, e) {
- if ($(e).is(":checked")) {
- } else {
- monthDayAllCheck = false;
- }
- });
- if (monthDayAllCheck) {
- $(event2).find(".month input[type='checkbox']").prop("checked", true);
- $(event2).attr("data-check", "true");
- } else {
- $(event2).find(".month input[type='checkbox']").removeAttr("checked");
- $(event2).attr("data-check", "false");
- }
- });
- let $year = $("#luckysheet-pivotTableFilter-byvalue-select .ListBox .yearBox");
- $year.each(function(index2, event2) {
- let yearDayAllCheck = true;
- let $yearDay = $(event2).find(".day input[type='checkbox']");
- $yearDay.each(function(i2, e) {
- if ($(e).is(":checked")) {
- } else {
- yearDayAllCheck = false;
- }
- });
- if (yearDayAllCheck) {
- $(event2).find(".year input[type='checkbox']").prop("checked", true);
- $(event2).attr("data-check", "true");
- } else {
- $(event2).find(".year input[type='checkbox']").removeAttr("checked");
- $(event2).attr("data-check", "false");
- }
- });
- });
- $("#luckysheet-pivotTableFilter-byvalue-btn-clear").click(function() {
- $("#luckysheet-pivotTableFilter-byvalue-select .ListBox input[type='checkbox']").removeAttr("checked");
- $("#luckysheet-pivotTableFilter-byvalue-select .ListBox input[type='checkbox']").parents(".luckysheet-mousedown-cancel").attr("data-check", "false");
- });
- $("#luckysheet-pivotTableFilter-byvalue-input").on("input propertychange", function() {
- let v = $(this).val().toString();
- $("#luckysheet-pivotTableFilter-byvalue-select .ListBox .luckysheet-mousedown-cancel").show();
- if (v != "") {
- let $check = $("#luckysheet-pivotTableFilter-byvalue-select .ListBox input[type='checkbox']");
- $check.each(function(i2, e) {
- let $p = $(e).parents(".luckysheet-mousedown-cancel");
- if ($p.hasClass("day")) {
- let day = $(e).siblings("label").text().toString();
- let month = $(e).parents(".monthBox").find(".month label").text().toString();
- let year = $(e).parents(".yearBox").find(".year label").text().toString();
- let itemV = year + "-" + month + "-" + day;
- if (itemV.indexOf(v) == -1) {
- $(e).parents(".day").hide();
- let $monthDay = $(e).parents(".dayList").find(".day:visible");
- if ($monthDay.length == 0) {
- $(e).parents(".monthBox").find(".month").hide();
- }
- let $yearDay = $(e).parents(".monthList").find(".day:visible");
- if ($yearDay.length == 0) {
- $(e).parents(".yearBox").find(".year").hide();
- }
- }
- }
- if ($p.hasClass("textBox")) {
- let itemV = $(e).siblings("label").text().toString();
- if (itemV.indexOf(v) == -1) {
- $(e).parents(".textBox").hide();
- }
- }
- });
- }
- });
- $("#luckysheet-pivotTableFilter-bycondition, #luckysheet-pivotTableFilter-byvalue").click(function() {
- let $t = $(this);
- $t.next().slideToggle(200);
- setTimeout(function() {
- if ($t.attr("id") == "luckysheet-pivotTableFilter-bycondition" && $("#luckysheet-pivotTableFilter-bycondition").next().is(":visible")) {
- if ($("#luckysheet-pivotTableFilter-selected span").text() != locale_filter.filiterInputNone) {
- $("#luckysheet-pivotTableFilter-byvalue").next().slideUp(200);
- }
- }
- if ($t.is($("#luckysheet-pivotTableFilter-bycondition"))) {
- if ($("#luckysheet-pivotTableFilter-bycondition").next().is(":hidden") && $("#luckysheet-pivotTableFilter-byvalue").next().is(":hidden")) {
- $("#luckysheet-pivotTableFilter-byvalue").next().slideDown(200);
- }
- }
- }, 300);
- });
- $("#luckysheet-pivotTableFilter-cancel").click(function() {
- $("#luckysheet-pivotTableFilter-menu, #luckysheet-pivotTableFilter-submenu").hide();
- });
- $("#luckysheet-pivotTableFilter-selected").click(function() {
- let $t = $(this), toffset = $t.offset(), $menu = $("#luckysheet-pivotTableFilter-submenu");
- $menu.hide();
- let winH = $(window).height(), winW = $(window).width();
- let menuW = $menu.width(), menuH = $menu.height();
- let top = toffset.top, left = toffset.left, mheight = winH - toffset.top - 20;
- if (toffset.left + menuW > winW) {
- left = toffset.left - menuW;
- }
- if (toffset.top > winH / 2) {
- top = winH - toffset.top;
- if (top < 0) {
- top = 0;
- }
- mheight = toffset.top - 20;
- }
- $menu.css({top, left, height: mheight}).show();
- clearTimeout(hidefilersubmenu);
- });
- $("#luckysheet-pivotTableFilter-submenu").mouseover(function() {
- clearTimeout(hidefilersubmenu);
- }).find(".luckysheet-cols-menuitem").click(function(e) {
- $("#luckysheet-pivotTableFilter-selected span").html($(this).find(".luckysheet-cols-menuitem-content").text()).data("value", $(this).data("value"));
- $("#luckysheet-pivotTableFilter-menu .luckysheet-pivotTableFilter-selected-input").hide();
- if ($(this).data("type") == "2") {
- $("#luckysheet-pivotTableFilter-selected span").data("type", "2");
- $("#luckysheet-pivotTableFilter-menu .luckysheet-pivotTableFilter-selected-input2").show();
- } else if ($(this).data("type") == "0") {
- $("#luckysheet-pivotTableFilter-selected span").data("type", "0");
- } else {
- $("#luckysheet-pivotTableFilter-selected span").data("type", "1");
- $("#luckysheet-pivotTableFilter-menu .luckysheet-pivotTableFilter-selected-input").eq(0).show();
- if ($(this).attr("data-value") == "dateequal" || $(this).attr("data-value") == "datelessthan" || $(this).attr("data-value") == "datemorethan") {
- $("#luckysheet-pivotTableFilter-menu .luckysheet-pivotTableFilter-selected-input input").prop("type", "date");
- } else {
- $("#luckysheet-pivotTableFilter-menu .luckysheet-pivotTableFilter-selected-input input").prop("type", "text");
- }
- }
- $("#luckysheet-pivotTableFilter-byvalue").next().slideUp();
- $("#luckysheet-pivotTableFilter-submenu").hide();
- });
- $("#luckysheet-modal-dialog-pivotTable-list").on("click", " .luckysheet-slider-list-item-filter", function(e) {
- _this2.luckysheetsliderlistitemfilter($(this));
- e.stopPropagation();
- return false;
- });
- $("#luckysheet-modal-dialog-pivotTable-list").on("click", " .luckysheet-slider-list-item-filtered", function(e) {
- _this2.luckysheetsliderlistclearfilter($(this).next());
- e.stopPropagation();
- return false;
- });
- $("#luckysheet-dialog-pivotTable-range-seleted").click(function() {
- $("#luckysheet-modal-dialog-slider-pivot").hide();
- luckysheetsizeauto();
- let $t = $("#luckysheet-data-pivotTable-selection"), myh = $t.outerHeight(), myw = $t.outerWidth();
- let winw = $(window).width(), winh = $(window).height();
- let scrollLeft = $(document).scrollLeft(), scrollTop = $(document).scrollTop();
- $("#luckysheet-data-pivotTable-selection").css({left: (winw + scrollLeft - myw) / 2, top: (winh + scrollTop - myh) / 4}).show();
- _this2.jgridCurrentPivotInput = $("#luckysheet-dialog-pivotTable-range").html();
- $("#luckysheet-pivotTable-range-selection-input").val(_this2.jgridCurrentPivotInput);
- _this2.luckysheet_pivotTable_select_state = true;
- });
- $("#luckysheet-pivotTableFilter-initial").click(function() {
- $("#luckysheet-modal-dialog-pivotTable-list .luckysheet-slider-list-item-filtered").hide();
- $("#luckysheet-modal-dialog-pivotTable-list .luckysheet-modal-dialog-slider-list-item").data("rowhidden", "");
- $("#luckysheet-pivotTableFilter-menu, #luckysheet-pivotTableFilter-submenu").hide();
- $("#luckysheet-pivotTableFilter-menu .luckysheet-pivotTableFilter-selected-input").hide().find("input").val();
- $("#luckysheet-pivotTableFilter-selected span").data("type", "0").data("type", null).text(locale_filter.filiterInputNone);
- _this2.setDatatojsfile("filterparm", null);
- _this2.celldata = _this2.origindata;
- _this2.refreshPivotTable();
- });
- $("#luckysheet-modal-dialog-config-row, #luckysheet-modal-dialog-config-column").on("click", ".luckysheet-modal-dialog-slider-config-item-icon", function(e) {
- let $t = $(e.target), $item = $t.closest(".luckysheet-modal-dialog-slider-config-item"), cindex = $item.data("index"), toffset = $item.offset();
- let order = $item.data("order"), orderby = $item.data("orderby"), stastic = $item.data("stastic");
- if (order == null) {
- order = "default";
- }
- let option = '
' + $item.find(".luckysheet-modal-dialog-slider-config-item-txt").data("name") + " ";
- $("#luckysheet-modal-dialog-config-value .luckysheet-modal-dialog-slider-config-item").each(function(i2) {
- option += '
' + $(this).find(".luckysheet-modal-dialog-slider-config-item-txt").text() + " ";
- });
- $("#luckysheet-pivotTable-config-option-orderby").empty().html(option);
- if (orderby == null) {
- orderby = "self";
- }
- if (stastic == null) {
- stastic = "1";
- }
- $("#luckysheet-pivotTable-config-option-order").val(order).data("index", cindex);
- $("#luckysheet-pivotTable-config-option-orderby").val(orderby).data("index", cindex);
- $("#luckysheet-pivotTable-config-option-stastic").val(stastic).data("index", cindex);
- mouseclickposition($("#luckysheet-pivotTable-config-option"), toffset.left + $item.outerWidth(), toffset.top - 13, "rightbottom");
- e.stopPropagation();
- return false;
- });
- $("#luckysheet-pivotTable-config-option-order,#luckysheet-pivotTable-config-option-orderby,#luckysheet-pivotTable-config-option-stastic").change(function() {
- let $t = $(this), cindex = $t.data("index");
- $("#luckysheet-modal-dialog-config-row, #luckysheet-modal-dialog-config-column").find(".luckysheet-modal-dialog-slider-config-item").each(function() {
- if ($(this).data("index") == cindex) {
- $(this).data($t.attr("id").replace("luckysheet-pivotTable-config-option-", ""), $t.val());
- }
- });
- _this2.refreshPivotTable();
- });
- $("#luckysheet-modal-dialog-config-value").on("click", ".luckysheet-modal-dialog-slider-config-item-icon", function(e) {
- let $t = $(e.target), $item = $t.closest(".luckysheet-modal-dialog-slider-config-item"), cindex = $item.data("index"), toffset = $item.offset(), sumtype = $item.data("sumtype");
- let type = _this2.pivot_data_type[cindex.toString()];
- if (sumtype == null) {
- if (type == "num") {
- sumtype = "SUM";
- } else {
- sumtype = "COUNTA";
- }
- }
- let $menu = $("#luckysheet-pivotTable-config-option-sumtype");
- $menu.find(".luckysheet-submenu-arrow").hide();
- $menu.find(".luckysheet-cols-menuitem[sumtype='" + sumtype + "'] .luckysheet-submenu-arrow").css("display", "inline");
- $menu.data("item", $item);
- mouseclickposition($menu, toffset.left + $item.outerWidth(), toffset.top - 13, "rightbottom");
- e.stopPropagation();
- return false;
- });
- $("#luckysheet-pivotTable-config-option-sumtype .luckysheet-cols-menuitem").click(function() {
- let $item = $("#luckysheet-pivotTable-config-option-sumtype").data("item");
- let sumtype = $(this).attr("sumtype");
- $item.data("sumtype", $(this).attr("sumtype"));
- let name2 = _this2.getSumTypeName(sumtype) + ":" + $item.data("name");
- $item.attr("title", name2).find(".luckysheet-modal-dialog-slider-config-item-txt").html(name2);
- $("#luckysheet-pivotTable-config-option-sumtype").hide();
- _this2.refreshPivotTable();
- });
- $("#luckysheet-modal-dialog-config-filter").on("click", ".luckysheet-modal-dialog-slider-config-item-icon", function(e) {
- let $t = $(e.target), cindex = $t.closest(".luckysheet-modal-dialog-slider-config-item").data("index");
- _this2.luckysheetsliderlistitemfilter($("#luckysheet-modal-dialog-pivotTable-list .luckysheet-modal-dialog-slider-list-item").eq(cindex).find(".luckysheet-slider-list-item-filter"));
- e.stopPropagation();
- return false;
- });
- $("#luckysheet-pivotTableFilter-confirm").click(function() {
- let $menu = $("#luckysheet-pivotTableFilter-menu");
- let cindex = $menu.data("index");
- let rowhiddenother = {};
- $("#luckysheet-modal-dialog-pivotTable-list .luckysheet-modal-dialog-slider-list-item").each(function() {
- let $t = $(this), rh = $t.data("rowhidden");
- if ($t.data("index") != cindex) {
- if (rh == null || rh == "") {
- return true;
- }
- if (getObjType(rh) == "string") {
- rh = JSON.parse(rh);
- }
- for (let r2 in rh) {
- rowhiddenother[r2] = 0;
- }
- }
- });
- let d = _this2.origindata;
- let filterdata = {};
- let rowhidden = {};
- let caljs = {};
- if ($("#luckysheet-pivotTableFilter-bycondition").next().is(":visible") && $("#luckysheet-pivotTableFilter-byvalue").next().is(":hidden") && $("#luckysheet-pivotTableFilter-selected span").data("value") != "null") {
- let $t = $("#luckysheet-pivotTableFilter-selected span");
- let type = $t.data("type"), value = $t.data("value");
- caljs["value"] = value;
- caljs["text"] = $t.text();
- if (type == "0") {
- caljs["type"] = "0";
- } else if (type == "2") {
- let $input = $("#luckysheet-pivotTableFilter-menu .luckysheet-pivotTableFilter-selected-input2 input");
- caljs["type"] = "2";
- caljs["value1"] = $input.eq(0).val();
- caljs["value2"] = $input.eq(1).val();
- } else {
- caljs["type"] = "1";
- caljs["value1"] = $("#luckysheet-pivotTableFilter-menu .luckysheet-pivotTableFilter-selected-input").eq(0).find("input").val();
- }
- for (let r2 = 1; r2 < d.length; r2++) {
- if (r2 in rowhiddenother) {
- continue;
- }
- if (d[r2] == null) {
- continue;
- }
- let cell = d[r2][cindex];
- if (value == "cellnull") {
- if (cell != null && !isRealNull(cell.v)) {
- rowhidden[r2] = 0;
- }
- } else if (value == "cellnonull") {
- if (cell == null || isRealNull(cell.v)) {
- rowhidden[r2] = 0;
- }
- } else if (value == "textinclude") {
- let value1 = caljs["value1"];
- if (cell == null || isRealNull(cell.v)) {
- rowhidden[r2] = 0;
- } else {
- if (cell.m.indexOf(value1) == -1) {
- rowhidden[r2] = 0;
- }
- }
- } else if (value == "textnotinclude") {
- let value1 = caljs["value1"];
- if (cell == null || isRealNull(cell.v)) {
- } else {
- if (cell.m.indexOf(value1) > -1) {
- rowhidden[r2] = 0;
- }
- }
- } else if (value == "textstart") {
- let value1 = caljs["value1"], valuelen = value1.length;
- if (cell == null || isRealNull(cell.v)) {
- rowhidden[r2] = 0;
- } else {
- if (cell.m.substr(0, valuelen) != value1) {
- rowhidden[r2] = 0;
- }
- }
- } else if (value == "textend") {
- let value1 = caljs["value1"], valuelen = value1.length;
- if (cell == null || isRealNull(cell.v)) {
- rowhidden[r2] = 0;
- } else {
- if (valuelen > cell.m.length || cell.m.substr(cell.m.length - valuelen, valuelen) != value1) {
- rowhidden[r2] = 0;
- }
- }
- } else if (value == "textequal") {
- let value1 = caljs["value1"];
- if (cell == null || isRealNull(cell.v)) {
- rowhidden[r2] = 0;
- } else {
- if (cell.m != value1) {
- rowhidden[r2] = 0;
- }
- }
- } else if (value == "dateequal") {
- let value1 = genarate(caljs["value1"])[2];
- if (cell == null || isRealNull(cell.v)) {
- rowhidden[r2] = 0;
- } else if (cell.ct != null && cell.ct.t == "d") {
- if (parseInt(cell.v) != value1) {
- rowhidden[r2] = 0;
- }
- } else {
- rowhidden[r2] = 0;
- }
- } else if (value == "datelessthan") {
- let value1 = genarate(caljs["value1"])[2];
- if (cell == null || isRealNull(cell.v)) {
- rowhidden[r2] = 0;
- } else if (cell.ct != null && cell.ct.t == "d") {
- if (parseInt(cell.v) >= value1) {
- rowhidden[r2] = 0;
- }
- } else {
- rowhidden[r2] = 0;
- }
- } else if (value == "datemorethan") {
- let value1 = genarate(caljs["value1"])[2];
- if (cell == null || isRealNull(cell.v)) {
- rowhidden[r2] = 0;
- } else if (cell.ct != null && cell.ct.t == "d") {
- if (parseInt(cell.v) <= value1) {
- rowhidden[r2] = 0;
- }
- } else {
- rowhidden[r2] = 0;
- }
- } else if (value == "morethan") {
- let value1 = parseFloat(caljs["value1"]);
- if (cell == null || isRealNull(cell.v)) {
- rowhidden[r2] = 0;
- } else if (cell.ct != null && cell.ct.t == "n") {
- if (cell.v <= value1) {
- rowhidden[r2] = 0;
- }
- } else {
- rowhidden[r2] = 0;
- }
- } else if (value == "moreequalthan") {
- let value1 = parseFloat(caljs["value1"]);
- if (cell == null || isRealNull(cell.v)) {
- rowhidden[r2] = 0;
- } else if (cell.ct != null && cell.ct.t == "n") {
- if (cell.v < value1) {
- rowhidden[r2] = 0;
- }
- } else {
- rowhidden[r2] = 0;
- }
- } else if (value == "lessthan") {
- let value1 = parseFloat(caljs["value1"]);
- if (cell == null || isRealNull(cell.v)) {
- rowhidden[r2] = 0;
- } else if (cell.ct != null && cell.ct.t == "n") {
- if (cell.v >= value1) {
- rowhidden[r2] = 0;
- }
- } else {
- rowhidden[r2] = 0;
- }
- } else if (value == "lessequalthan") {
- let value1 = parseFloat(caljs["value1"]);
- if (cell == null || isRealNull(cell.v)) {
- rowhidden[r2] = 0;
- } else if (cell.ct != null && cell.ct.t == "n") {
- if (cell.v > value1) {
- rowhidden[r2] = 0;
- }
- } else {
- rowhidden[r2] = 0;
- }
- } else if (value == "equal") {
- let value1 = parseFloat(caljs["value1"]);
- if (cell == null || isRealNull(cell.v)) {
- rowhidden[r2] = 0;
- } else if (cell.ct != null && cell.ct.t == "n") {
- if (cell.v != value1) {
- rowhidden[r2] = 0;
- }
- } else {
- rowhidden[r2] = 0;
- }
- } else if (value == "noequal") {
- let value1 = parseFloat(caljs["value1"]);
- if (cell == null || isRealNull(cell.v)) {
- rowhidden[r2] = 0;
- } else if (cell.ct != null && cell.ct.t == "n") {
- if (cell.v == value1) {
- rowhidden[r2] = 0;
- }
- } else {
- rowhidden[r2] = 0;
- }
- } else if (value == "include") {
- let value1 = parseFloat(caljs["value1"]), value2 = parseFloat(caljs["value2"]);
- let min, max;
- if (value1 < value2) {
- min = value1;
- max = value2;
- } else {
- max = value1;
- min = value2;
- }
- if (cell == null || isRealNull(cell.v)) {
- rowhidden[r2] = 0;
- } else if (cell.ct != null && cell.ct.t == "n") {
- if (cell.v < min || cell.v > max) {
- rowhidden[r2] = 0;
- }
- } else {
- rowhidden[r2] = 0;
- }
- } else if (value == "noinclude") {
- let value1 = parseFloat(caljs["value1"]), value2 = parseFloat(caljs["value2"]);
- let min, max;
- if (value1 < value2) {
- min = value1;
- max = value2;
- } else {
- max = value1;
- min = value2;
- }
- if (cell == null || isRealNull(cell.v)) {
- rowhidden[r2] = 0;
- } else if (cell.ct != null && cell.ct.t == "n") {
- if (cell.v >= min && cell.v <= max) {
- rowhidden[r2] = 0;
- }
- } else {
- rowhidden[r2] = 0;
- }
- }
- }
- } else {
- $("#luckysheet-pivotTableFilter-byvalue-select .ListBox input[type='checkbox']").each(function(i2, e) {
- if ($(e).is(":visible") && $(e).is(":checked")) {
- return true;
- }
- if ($(e).closest(".day").length > 0) {
- let day = $(e).siblings("label").text();
- if (Number(day) < 10) {
- day = "0" + day;
- }
- let month = $(e).closest(".monthBox").find(".month label").text().replace(locale_filter.filiterMonthText, "");
- if (Number(month) < 10) {
- month = "0" + month;
- }
- let year = $(e).closest(".yearBox").find(".year label").text().replace(locale_filter.filiterYearText, "");
- let itemV = locale_filter.filterDateFormatTip + "#$$$#" + year + "-" + month + "-" + day;
- filterdata[itemV] = "1";
- }
- if ($(e).closest(".textBox").length > 0) {
- let itemV = $(e).closest(".textBox").data("filter");
- filterdata[itemV] = "1";
- }
- });
- for (let r2 = 1; r2 < d.length; r2++) {
- if (r2 in rowhiddenother) {
- continue;
- }
- if (d[r2] == null) {
- continue;
- }
- let cell = d[r2][cindex];
- let value;
- if (cell == null || isRealNull(cell.v)) {
- value = "null#$$$#null";
- } else if (cell.ct != null && cell.ct.t == "d") {
- let fmt = update("YYYY-MM-DD", cell.v);
- value = locale_filter.filterDateFormatTip + "#$$$#" + fmt;
- } else {
- value = cell.v + "#$$$#" + cell.m;
- }
- if (value in filterdata) {
- rowhidden[r2] = 0;
- }
- }
- }
- let $top = $("#luckysheet-modal-dialog-pivotTable-list .luckysheet-modal-dialog-slider-list-item").eq(cindex);
- if ($("#luckysheet-pivotTableFilter-byvalue-select .ListBox input[type='checkbox']:visible:checked").length < $("#luckysheet-pivotTableFilter-byvalue-select .ListBox input[type='checkbox']:visible").length || $("#luckysheet-pivotTableFilter-byvalue-input").val().length > 0 || $("#luckysheet-pivotTableFilter-bycondition").next().is(":visible") && $("#luckysheet-pivotTableFilter-byvalue").next().is(":hidden") && $("#luckysheet-pivotTableFilter-selected span").data("value") != "null") {
- $top.data("rowhidden", JSON.stringify(rowhidden)).find(".luckysheet-slider-list-item-filtered").show();
- _this2.setDatatojsfile("rowhidden", rowhidden, cindex);
- if (caljs != null) {
- $top.data("byconditionvalue", caljs["value"]).data("byconditiontype", caljs["type"]).data("byconditiontext", caljs["text"]);
- if (caljs["value1"] != null) {
- $top.data("byconditionvalue1", caljs["value1"]);
- }
- if (caljs["value2"] != null) {
- $top.data("byconditionvalue2", caljs["value2"]);
- }
- _this2.setDatatojsfile("caljs", caljs, cindex);
- }
- } else {
- $top.data("rowhidden", "").find(".luckysheet-slider-list-item-filtered").hide();
- _this2.setDatatojsfile("rowhidden", null, cindex);
- }
- let newdata = [];
- for (let i2 = 0; i2 < d.length; i2++) {
- if (i2 in rowhidden || i2 in rowhiddenother) {
- continue;
- }
- newdata.push([].concat(d[i2]));
- }
- _this2.celldata = newdata;
- _this2.refreshPivotTable();
- $("#luckysheet-pivotTableFilter-menu, #luckysheet-pivotTableFilter-submenu").hide();
- cleargridelement();
- });
- $("#luckysheet-data-pivotTable-selection .luckysheet-model-close-btn, #luckysheet-data-pivotTable-selection .luckysheet-modal-dialog-title-close").click(function() {
- $("#luckysheet-modal-dialog-slider-pivot").show();
- luckysheetsizeauto();
- $("#luckysheet-cell-main .luckysheet-pivotTable-selection-set div").show();
- $("#luckysheet-data-pivotTable-selection").hide();
- sheetmanage_default.changeSheetExec(_this2.pivotSheetIndex);
- _this2.luckysheet_pivotTable_select_state = false;
- cleargridelement();
- });
- $("#luckysheet-pivotTable-selection-confirm").click(function() {
- let $input = $("#luckysheet-pivotTable-range-selection-input"), val = $input.val();
- if ($.trim(val).length == 0 || $.trim(val).toUpperCase() == _this2.jgridCurrentPivotInput.toUpperCase()) {
- $input.val(_this2.jgridCurrentPivotInput);
- $("#luckysheet-data-pivotTable-selection .luckysheet-model-close-btn").click();
- return;
- } else {
- let val1 = val.split("!");
- let sheettxt = "", rangetxt = "", sheetIndex = -1;
- if (val1.length > 1) {
- sheettxt = val1[0];
- rangetxt = val1[1];
- for (let i2 in store_default.luckysheetfile) {
- if (sheettxt == store_default.luckysheetfile[i2].name) {
- sheetIndex = store_default.luckysheetfile[i2].index;
- break;
- }
- }
- if (sheetIndex == -1) {
- sheetIndex = 0;
- }
- } else {
- let index2 = getSheetIndex(store_default.currentSheetIndex);
- sheettxt = store_default.luckysheetfile[index2].name;
- sheetIndex = store_default.luckysheetfile[index2].index;
- rangetxt = val1[0];
- }
- if (store_default.luckysheetfile[getSheetIndex(sheetIndex)].isPivotTable) {
- if (isEditMode()) {
- alert(locale_pivotTable.errorNotAllowPivotData);
- } else {
- tooltip_default.info("", locale_pivotTable.errorNotAllowPivotData);
- }
- $input.val(_this2.jgridCurrentPivotInput);
- return;
- }
- if (rangetxt.indexOf(":") == -1) {
- if (isEditMode()) {
- alert(locale_pivotTable.errorSelectionRange);
- } else {
- tooltip_default.info("", locale_pivotTable.errorSelectionRange);
- }
- $input.val(_this2.jgridCurrentPivotInput);
- return;
- }
- rangetxt = rangetxt.split(":");
- let row = [], col = [];
- row[0] = parseInt(rangetxt[0].replace(/[^0-9]/g, "")) - 1;
- row[1] = parseInt(rangetxt[1].replace(/[^0-9]/g, "")) - 1;
- if (row[0] > row[1]) {
- if (isEditMode()) {
- alert(locale_pivotTable.errorSelectionRange);
- } else {
- tooltip_default.info("", locale_pivotTable.errorSelectionRange);
- }
- $input.val(_this2.jgridCurrentPivotInput);
- return;
- }
- col[0] = ABCatNum(rangetxt[0].replace(/[^A-Za-z]/g, ""));
- col[1] = ABCatNum(rangetxt[1].replace(/[^A-Za-z]/g, ""));
- if (col[0] > col[1]) {
- if (isEditMode()) {
- alert(locale_pivotTable.errorSelectionRange);
- } else {
- tooltip_default.info(locale_pivotTable.errorSelectionRange);
- }
- $input.val(_this2.jgridCurrentPivotInput);
- return;
- }
- sheetmanage_default.changeSheetExec(_this2.pivotSheetIndex);
- _this2.setDatatojsfile("pivot_select_save", {row, column: col});
- _this2.setDatatojsfile("pivotDataSheetIndex", sheetIndex);
- _this2.getCellData(_this2.pivotSheetIndex, sheetIndex, {row, column: col});
- _this2.initialPivotManage();
- $("#luckysheet-dialog-pivotTable-range").html(val);
- $("#luckysheet-modal-dialog-slider-pivot").show();
- $("#luckysheet-data-pivotTable-selection").hide();
- _this2.luckysheet_pivotTable_select_state = false;
- _this2.refreshPivotTable();
- luckysheetsizeauto();
- cleargridelement();
- }
- });
- $("#luckysheet-modal-dialog-slider-pivot").on("mousedown", ".luckysheet-slider-list-item-name, .luckysheet-modal-dialog-slider-config-item-txt", function(e) {
- let $cur = $(e.target);
- _this2.movestate = true;
- _this2.movesave.obj = $cur.parent();
- _this2.movesave.name = $cur.data("name");
- _this2.movesave.containerid = $cur.parent().parent().attr("id");
- _this2.movesave.index = $cur.data("index");
- if ($("#luckysheet-modal-dialog-slider-pivot-move").length == 0) {
- $("body").append('
' + _this2.movesave.name + "
");
- }
- _this2.movesave.width = $("#luckysheet-modal-dialog-slider-pivot-move").outerWidth();
- _this2.movesave.height = $("#luckysheet-modal-dialog-slider-pivot-move").outerHeight();
- $("#luckysheet-modal-dialog-pivotTable-list, #luckysheet-modal-dialog-config-filter, #luckysheet-modal-dialog-config-row, #luckysheet-modal-dialog-config-column, #luckysheet-modal-dialog-config-value").css("cursor", "default");
- });
- $("#luckysheet-modal-dialog-config-filter, #luckysheet-modal-dialog-config-row, #luckysheet-modal-dialog-config-column, #luckysheet-modal-dialog-config-value").mousemove(function(e) {
- if (_this2.movestate) {
- if (_this2.moveitemposition.length == 0) {
- _this2.moveitemposition = [0];
- $(this).find(".luckysheet-modal-dialog-slider-config-item").each(function(i2) {
- let $t = $(this), h = $t.outerHeight();
- _this2.moveitemposition.push(_this2.moveitemposition[i2] + h + 2);
- });
- $(this).append('
');
- }
- $("#luckysheet-modal-dialog-slider-pivot-move").css({
- background: "#FD8585",
- color: "#fff",
- border: "1px solid #FD7070"
- });
- let x = event.pageX, y = event.pageY, $container = $(this);
- let curtop = y - $container.offset().top + $container.scrollTop();
- let position = _this2.moveitemposition;
- let row_index = luckysheet_searcharray(position, curtop);
- if (row_index == -1) {
- $("#luckysheet-modal-dialog-config-order-help").css({top: position[position.length - 1]});
- } else if (curtop - position[row_index - 1] > (position[row_index] - position[row_index - 1]) / 2) {
- $("#luckysheet-modal-dialog-config-order-help").css({top: position[row_index]});
- } else {
- $("#luckysheet-modal-dialog-config-order-help").css({top: position[row_index - 1]});
- }
- }
- }).mouseleave(function() {
- if (_this2.movestate) {
- $("#luckysheet-modal-dialog-slider-pivot-move").css({
- background: "#fff",
- color: "#000",
- border: "1px dotted #000"
- });
- _this2.moveitemposition = [];
- $("#luckysheet-modal-dialog-config-order-help").remove();
- }
- }).mouseup(function(e) {
- if (_this2.movestate) {
- let $t = $(this);
- let itemHTML;
- if (_this2.movesave.containerid == $t.attr("id")) {
- itemHTML = _this2.movesave.obj.clone();
- } else {
- let name2 = _this2.movesave.name, sumtype = "", nameindex = "";
- if ($t.attr("id") == "luckysheet-modal-dialog-config-value") {
- let type = _this2.pivot_data_type[_this2.movesave.index.toString()];
- if (type == "num") {
- name2 = locale_pivotTable.valueStatisticsSUM + ":" + name2;
- sumtype = "data-sumtype='SUM'";
- nameindex = "data-nameindex='0'";
- } else {
- name2 = locale_pivotTable.valueStatisticsCOUNTA + ":" + name2;
- sumtype = "data-sumtype='COUNTA'";
- nameindex = "data-nameindex='0'";
- }
- $("#luckysheet-modal-dialog-config-value").find(".luckysheet-modal-dialog-slider-config-item").each(function() {
- if ($(this).find(".luckysheet-modal-dialog-slider-config-item-txt").text() == name2) {
- let ni = parseFloat($(this).data("nameindex")) + 1;
- name2 = name2 + ni.toString();
- $(this).data("nameindex", ni);
- return false;
- }
- });
- }
- itemHTML = '
';
- }
- let x = event.pageX, y = event.pageY, $container = $(this);
- let curtop = y - $container.offset().top + $container.scrollTop();
- let position = _this2.moveitemposition;
- let row_index = luckysheet_searcharray(position, curtop);
- if (_this2.movesave.containerid == "luckysheet-modal-dialog-pivotTable-list" || _this2.movesave.containerid == "luckysheet-modal-dialog-config-value" && _this2.movesave.containerid != $t.attr("id")) {
- $("#luckysheet-modal-dialog-config-filter, #luckysheet-modal-dialog-config-row, #luckysheet-modal-dialog-config-column").find(".luckysheet-modal-dialog-slider-config-item").each(function() {
- if ($(this).data("index") == _this2.movesave.index) {
- $(this).remove();
- }
- });
- }
- if (row_index == -1) {
- if ($t.find(".luckysheet-modal-dialog-slider-config-item").length == 0) {
- $t.append(itemHTML);
- } else {
- $t.find(".luckysheet-modal-dialog-slider-config-item").last().after(itemHTML);
- }
- } else if (curtop - position[row_index - 1] > (position[row_index] - position[row_index - 1]) / 2) {
- $t.find(".luckysheet-modal-dialog-slider-config-item").eq(row_index - 1).after(itemHTML);
- } else {
- $t.find(".luckysheet-modal-dialog-slider-config-item").eq(row_index - 1).before(itemHTML);
- }
- if (_this2.movesave.containerid == "luckysheet-modal-dialog-pivotTable-list") {
- } else if (_this2.movesave.containerid == "luckysheet-modal-dialog-config-value" && _this2.movesave.containerid != $t.attr("id")) {
- } else {
- _this2.movesave.obj.remove();
- }
- $("#luckysheet-modal-dialog-pivotTable-list").find(".luckysheet-modal-dialog-slider-list-item").each(function() {
- let $seleted = $(this).find(".luckysheet-slider-list-item-selected");
- if ($(this).data("index") == _this2.movesave.index && $seleted.find("i").length == 0) {
- $seleted.append('
');
- }
- });
- _this2.refreshPivotTable();
- $("#luckysheet-modal-dialog-slider-pivot-move").remove();
- _this2.movestate = false;
- $("#luckysheet-modal-dialog-pivotTable-list, #luckysheet-modal-dialog-config-filter, #luckysheet-modal-dialog-config-row, #luckysheet-modal-dialog-config-column, #luckysheet-modal-dialog-config-value").css("cursor", "default");
- _this2.moveitemposition = [];
- $("#luckysheet-modal-dialog-config-order-help").remove();
- _this2.showvaluecolrow();
- e.stopPropagation();
- }
- });
- $("#luckysheet-modal-dialog-pivotTable-list").on("click", ".luckysheet-slider-list-item-selected", function() {
- let $t = $(this), $item = $t.parent(), index2 = $item.data("index"), name2 = $item.data("name");
- if ($t.find("i").length == 0) {
- $t.append('
');
- let type = _this2.pivot_data_type[index2.toString()], itemHTML;
- if (type == "num") {
- itemHTML = '
\u6C42\u548C:' + name2 + '
';
- $("#luckysheet-modal-dialog-config-value").append(itemHTML);
- } else {
- itemHTML = '
';
- let $column = $("#luckysheet-modal-dialog-config-column"), $row = $("#luckysheet-modal-dialog-config-row");
- let columnitem = $column.find(".luckysheet-modal-dialog-slider-config-item"), rowitem = $row.find(".luckysheet-modal-dialog-slider-config-item");
- if (columnitem.length < 2) {
- $column.append(itemHTML);
- } else if (rowitem.length < 2) {
- $row.append(itemHTML);
- } else {
- $column.append(itemHTML);
- }
- }
- } else {
- $t.find("i").remove();
- $("#luckysheet-modal-dialog-config-filter, #luckysheet-modal-dialog-config-row, #luckysheet-modal-dialog-config-column, #luckysheet-modal-dialog-config-value").find(".luckysheet-modal-dialog-slider-config-item").each(function() {
- if ($(this).data("index") == index2) {
- if ($(this).parent().attr("id") == "luckysheet-modal-dialog-config-value") {
- _this2.resetOrderby($(this));
- }
- $(this).remove();
- }
- });
- }
- _this2.refreshPivotTable();
- _this2.showvaluecolrow();
- });
- $("#luckysheet-dialog-pivotTable-clearitem").click(function() {
- $("#luckysheet-modal-dialog-config-filter, #luckysheet-modal-dialog-config-row, #luckysheet-modal-dialog-config-column, #luckysheet-modal-dialog-config-value").find(".luckysheet-modal-dialog-slider-config-item").each(function() {
- $(this).remove();
- });
- $("#luckysheet-modal-dialog-pivotTable-list").find(".luckysheet-modal-dialog-slider-list-item").each(function() {
- $(this).find(".luckysheet-slider-list-item-selected").find("i").remove();
- });
- _this2.refreshPivotTable();
- _this2.showvaluecolrow();
- });
- }
- if (restore == null) {
- restore = false;
- }
- if (_this2.celldata.length <= 1 && _this2.celldata[0].length <= 1) {
- if (isEditMode()) {
- alert(locale_pivotTable.errorIncreaseRange);
- } else {
- tooltip_default.info("", locale_pivotTable.errorIncreaseRange);
- }
- }
- let selecteditem = "", selecteditemIndex = 1, selecteditemtest = {}, selecteditemNullIndex = 1;
- for (let i2 = 0; i2 < _this2.celldata[0].length; i2++) {
- let name2;
- if (!!_this2.celldata[0][i2] && !!_this2.celldata[0][i2]["m"]) {
- name2 = _this2.celldata[0][i2]["m"];
- } else {
- name2 = getcellvalue(0, i2, _this2.celldata);
- }
- if (name2 != null) {
- name2 = name2.toString();
- }
- if (name2 == null || $.trim(name2.toString()).length == 0) {
- name2 = locale_pivotTable.titleColumn + " " + selecteditemNullIndex;
- }
- selecteditemNullIndex++;
- if (name2 in selecteditemtest) {
- name2 = name2 + selecteditemIndex++;
- if (name2 in selecteditemtest) {
- name2 = name2 + selecteditemIndex++;
- if (name2 in selecteditemtest) {
- name2 = name2 + selecteditemIndex++;
- }
- }
- }
- selecteditemtest[name2] = 1;
- let dataother = "", style = "";
- if (restore && _this2.filterparm != null) {
- if (_this2.filterparm[i2.toString()] != null) {
- let itemset = _this2.filterparm[i2.toString()];
- if (itemset.rowhidden != null) {
- dataother += "data-rowhidden='" + JSON.stringify(itemset.rowhidden) + "'";
- }
- if (itemset.selected != null) {
- dataother += "data-selected='" + JSON.stringify(itemset.selected) + "'";
- }
- if (itemset.caljs != null) {
- let caljsset = itemset.caljs;
- if (caljsset.value != null) {
- dataother += "data-byconditionvalue='" + caljsset.value + "'";
- }
- if (caljsset.type != null) {
- dataother += "data-byconditiontype='" + caljsset.type + "'";
- }
- if (caljsset.text != null) {
- dataother += "data-byconditiontext='" + caljsset.text + "'";
- }
- if (caljsset.value1 != null) {
- dataother += "data-byconditionvalue1='" + caljsset.value1 + "'";
- }
- if (caljsset.value2 != null) {
- dataother += "data-byconditionvalue2='" + caljsset.value2 + "'";
- }
- }
- }
- }
- if (dataother.length > 0) {
- style = "display:block;";
- }
- selecteditem += '
';
- }
- $("#luckysheet-modal-dialog-pivotTable-list").html(selecteditem);
- $("#luckysheetpivottablevaluecolrowshow").hide();
- $("#luckysheetpivottablevaluecolrow").prop("checked", true);
- $("#luckysheetpivottablevaluecolrow1").prop("checked", false);
- $("#luckysheet-modal-dialog-config-filter, #luckysheet-modal-dialog-config-row, #luckysheet-modal-dialog-config-column, #luckysheet-modal-dialog-config-value").empty();
- if (restore) {
- if (_this2.filter != null && _this2.filter.length > 0) {
- for (let i2 = 0; i2 < _this2.filter.length; i2++) {
- let item2 = _this2.filter[i2];
- let itemHTML = '
';
- $("#luckysheet-modal-dialog-config-filter").append(itemHTML);
- let $seleted = $("#luckysheet-modal-dialog-pivotTable-list .luckysheet-modal-dialog-slider-list-item").eq(item2.index).find(".luckysheet-slider-list-item-selected");
- if ($seleted.find("i").length == 0) {
- $seleted.append('
');
- }
- }
- }
- if (_this2.row != null && _this2.row.length > 0) {
- for (let i2 = 0; i2 < _this2.row.length; i2++) {
- let item2 = _this2.row[i2];
- let otherset = "";
- if (item2.order != null) {
- otherset += "data-order = '" + item2.order + "'";
- }
- if (item2.orderby != null) {
- otherset += "data-orderby = '" + item2.orderby + "'";
- }
- if (item2.order != null) {
- otherset += "data-stastic = '" + item2.stastic + "'";
- }
- let itemHTML = '
';
- $("#luckysheet-modal-dialog-config-row").append(itemHTML);
- let $seleted = $("#luckysheet-modal-dialog-pivotTable-list .luckysheet-modal-dialog-slider-list-item").eq(item2.index).find(".luckysheet-slider-list-item-selected");
- if ($seleted.find("i").length == 0) {
- $seleted.append('
');
- }
- }
- }
- if (_this2.column != null && _this2.column.length > 0) {
- for (let i2 = 0; i2 < _this2.column.length; i2++) {
- let item2 = _this2.column[i2];
- let otherset = "";
- if (item2.order != null) {
- otherset += "data-order = '" + item2.order + "'";
- }
- if (item2.orderby != null) {
- otherset += "data-orderby = '" + item2.orderby + "'";
- }
- if (item2.order != null) {
- otherset += "data-stastic = '" + item2.stastic + "'";
- }
- let itemHTML = '
';
- $("#luckysheet-modal-dialog-config-column").append(itemHTML);
- let $seleted = $("#luckysheet-modal-dialog-pivotTable-list .luckysheet-modal-dialog-slider-list-item").eq(item2.index).find(".luckysheet-slider-list-item-selected");
- if ($seleted.find("i").length == 0) {
- $seleted.append('
');
- }
- }
- }
- if (_this2.values != null && _this2.values.length > 0) {
- for (let i2 = 0; i2 < _this2.values.length; i2++) {
- let item2 = _this2.values[i2];
- let otherset = "";
- if (item2.sumtype != null) {
- otherset += "data-sumtype = '" + item2.sumtype + "'";
- }
- if (item2.nameindex != null) {
- otherset += "data-nameindex = '" + item2.nameindex + "'";
- }
- let itemHTML = '
' + _this2.getSumTypeName(item2.sumtype) + ":" + item2.name + '
';
- $("#luckysheet-modal-dialog-config-value").append(itemHTML);
- let $seleted = $("#luckysheet-modal-dialog-pivotTable-list .luckysheet-modal-dialog-slider-list-item").eq(item2.index).find(".luckysheet-slider-list-item-selected");
- if ($seleted.find("i").length == 0) {
- $seleted.append('
');
- }
- }
- if (_this2.values.length >= 2) {
- $("#luckysheetpivottablevaluecolrowshow").show();
- if (_this2.showType == "column") {
- $("#luckysheetpivottablevaluecolrow").prop("checked", true);
- $("#luckysheetpivottablevaluecolrowshow label[for='luckysheetpivottablevaluecolrow']").addClass("ui-state-active");
- $("#luckysheetpivottablevaluecolrow1").prop("checked", false);
- $("#luckysheetpivottablevaluecolrowshow label[for='luckysheetpivottablevaluecolrow1']").removeClass("ui-state-active");
- } else {
- $("#luckysheetpivottablevaluecolrow1").prop("checked", true);
- $("#luckysheetpivottablevaluecolrowshow label[for='luckysheetpivottablevaluecolrow1']").addClass("ui-state-active");
- $("#luckysheetpivottablevaluecolrow").prop("checked", false);
- $("#luckysheetpivottablevaluecolrowshow label[for='luckysheetpivottablevaluecolrow']").removeClass("ui-state-active");
- }
- }
- }
- }
- $("#luckysheet-dialog-pivotTable-range").html(getRangetxt(_this2.pivotDataSheetIndex, _this2.pivot_select_save));
- $("#luckysheet-modal-dialog-slider-pivot").show();
- luckysheetsizeauto(false);
- },
- getComposeArray: function(data) {
- if (data.length == 0) {
- return [];
- }
- let ret = [];
- for (let i2 = 0; i2 < data.length; i2++) {
- let name2 = "";
- for (let x = 0; x <= i2; x++) {
- if (!!data[x] && !!data[x]["m"]) {
- name2 += data[x]["m"];
- } else {
- name2 += getcellvalue(x, null, data);
- }
- }
- ret.push(name2);
- }
- return ret;
- },
- getnameArray: function(data, field) {
- if (data.length == 0) {
- return [];
- }
- if (field.length == 0) {
- return [];
- }
- let ret = [];
- for (let i2 = 0; i2 < field.length; i2++) {
- let c_value;
- if (!!data[field[i2].index] && !!data[field[i2].index]["m"]) {
- c_value = data[field[i2].index]["m"];
- } else {
- c_value = getcellvalue(field[i2].index, null, data);
- }
- ret.push(c_value);
- }
- return ret;
- },
- getTitleFromGroup: function(group, config, dataposition) {
- let _this2 = this;
- let orderbygroup = _this2.orderbygroup(group, config, dataposition);
- return _this2.generategrouparraymain(orderbygroup, config);
- },
- orderbygroup: function(group, config, dataposition) {
- let _this2 = this;
- let stackset = [];
- if (group.length == 0) {
- return [];
- }
- stackset = group;
- let d = null, alllength = stackset.length, alllengthInital = stackset.length, a = 0;
- while (alllength != 0) {
- d = stackset[a++];
- alllength--;
- if (d.children != null && d.children.length > 0) {
- d.children = _this2.orderbygroupchildren(d.children, config[d.index].orderby, config[d.index].order, dataposition);
- for (let i2 = 0; i2 < d.children.length; i2++) {
- stackset.push(d.children[i2]);
- alllength++;
- }
- }
- }
- return group.splice(0, alllengthInital);
- },
- orderbygroupchildren: function(childrens, orderby, order, dataposition) {
- if (childrens.length == 0) {
- return [];
- }
- let isAsc = false;
- if (order == null || order == "asc") {
- isAsc = true;
- }
- const _locale = locale_default();
- const locale_filter = _locale.filter;
- let a = function(x, y) {
- let f = null, s = null;
- if (orderby == "self" || orderby == null) {
- if (x.name == null) {
- f = locale_filter.valueBlank;
- } else {
- f = x.name.toString();
- }
- if (y.name == null) {
- s = locale_filter.valueBlank;
- } else {
- s = y.name.toString();
- }
- if (isdatetime(f) && isdatetime(s)) {
- return diff(f, s);
- }
- } else {
- f = parseFloat(dataposition[x.orderby].result);
- s = parseFloat(dataposition[y.orderby].result);
- }
- if (!isNaN(f) && !isNaN(s)) {
- return (0, import_numeral3.default)(f).value() - (0, import_numeral3.default)(s).value();
- } else if (isNaN(f) && isNaN(s)) {
- return f.localeCompare(s);
- } else if (isNaN(f)) {
- return 1;
- } else if (isNaN(s)) {
- return -1;
- }
- };
- let d = function(x, y) {
- let f = null, s = null;
- if (orderby == "self" || orderby == null) {
- if (x.name == null) {
- f = locale_filter.valueBlank;
- } else {
- f = x.name.toString();
- }
- if (y.name == null) {
- s = locale_filter.valueBlank;
- } else {
- s = y.name.toString();
- }
- if (isdatetime(f) && isdatetime(s)) {
- return diff(f, s);
- }
- } else {
- f = parseFloat(dataposition[x.orderby].result);
- s = parseFloat(dataposition[y.orderby].result);
- }
- if (!isNaN(f) && !isNaN(s)) {
- return (0, import_numeral3.default)(s).value() - (0, import_numeral3.default)(f).value();
- } else if (isNaN(f) && isNaN(s)) {
- return s.localeCompare(f);
- } else if (isNaN(f)) {
- return -1;
- } else if (isNaN(s)) {
- return 1;
- }
- };
- if (isAsc) {
- return childrens.sort(a);
- } else {
- return childrens.sort(d);
- }
- },
- generategroupaddstatic: function(arr, name2) {
- let stasticarr = [];
- const _locale = locale_default();
- const locale_pivotTable = _locale.pivotTable;
- for (let a = 0; a < arr[0].length; a++) {
- if (a == 0) {
- if (name2 == locale_pivotTable.valueSum) {
- stasticarr.push(name2);
- } else {
- stasticarr.push({name: name2, issum: true});
- }
- } else {
- stasticarr.push("");
- }
- }
- return stasticarr;
- },
- generategrouparraymain: function(group, config) {
- let _this2 = this;
- let ret = [];
- for (let i2 = 0; i2 < group.length; i2++) {
- let name2 = group[i2].name;
- let arr = _this2.generategrouparray(group[i2].children, config, 1);
- if (config[0].stastic == "1" || config[0].stastic == null) {
- arr.push(_this2.generategroupaddstatic(arr, name2));
- }
- ret = ret.concat(arr);
- }
- return ret;
- },
- generategrouparray: function(group, config, level) {
- let _this2 = this;
- let ret = [];
- for (let i2 = 0; i2 < group.length; i2++) {
- let name2 = group[i2].name;
- let arr;
- if (group[i2].children == 0 || group[i2].children.length == 0) {
- arr = [name2];
- ret.push(arr);
- } else {
- arr = _this2.generategrouparray(group[i2].children, config, level + 1);
- for (let a = 0; a < arr.length; a++) {
- arr[a].unshift(name2);
- }
- if (config[level].stastic == "1" || config[level].stastic == null) {
- arr.push(_this2.generategroupaddstatic(arr, name2));
- }
- ret = ret.concat(arr);
- }
- }
- return ret;
- },
- addStatisticsData: function(dataposition, valueobj, indicator, d_value) {
- if (dataposition[indicator] == null) {
- dataposition[indicator] = {
- data: [],
- count: 0,
- max: -Infinity,
- min: Infinity,
- counta: 0,
- countunique: 0,
- countuniquedata: {},
- sum: 0,
- digitaldata: [],
- sumtype: valueobj.sumtype,
- index: valueobj.index,
- name: valueobj.fullname,
- acc: 0
- };
- }
- if (isdatatypemulti(d_value)["num"] === true) {
- let num = numFormat2(d_value, 6);
- dataposition[indicator]["digitaldata"].push(num);
- dataposition[indicator]["count"] += 1;
- dataposition[indicator]["sum"] += num;
- if (num > dataposition[indicator]["max"]) {
- dataposition[indicator]["max"] = num;
- }
- if (num < dataposition[indicator]["min"]) {
- dataposition[indicator]["min"] = num;
- }
- let newAcc = numfloatlen(num);
- if (newAcc > dataposition[indicator]["acc"]) {
- dataposition[indicator]["acc"] = newAcc;
- }
- }
- if (d_value != "") {
- dataposition[indicator]["data"].push(d_value);
- dataposition[indicator]["counta"] += 1;
- if (!(d_value in dataposition[indicator]["countuniquedata"])) {
- dataposition[indicator]["countuniquedata"][d_value] = 1;
- dataposition[indicator]["countunique"] += 1;
- }
- }
- },
- dataHandler: function(column, row, values, showType, celldata) {
- let _this2 = this;
- const _locale = locale_default();
- const locale_filter = _locale.filter;
- const locale_pivotTable = _locale.pivotTable;
- if (showType == null) {
- showType = "column";
- }
- if (column.length == 0 && row.length == 0 && values.length == 0 || celldata.length == 0) {
- _this2.pivotDatas = [];
- return [];
- }
- let dataposition = {}, data = celldata, datarowtitle = [], datarowtitlegroup = [], datarowposition = {}, datarowposition_i = 0, datacoltitle = [], datacoltitlegroup = [], datacolposition = {}, datacolposition_i = 0;
- for (let i2 = 1; i2 < data.length; i2++) {
- let d = data[i2];
- let groupbyrowtxt = "", groupbycoltxt = "", rowtxt = "", rowtitle = [], rowtitlename = [], coltxt = "", coltitle = [], coltitlename = [];
- rowtitlename = _this2.getnameArray(d, row);
- coltitlename = _this2.getnameArray(d, column);
- rowtitle = _this2.getComposeArray(rowtitlename);
- coltitle = _this2.getComposeArray(coltitlename);
- if (rowtitle.length > 0) {
- rowtitle.unshift(locale_pivotTable.valueSum);
- }
- if (coltitle.length > 0) {
- coltitle.unshift(locale_pivotTable.valueSum);
- }
- let curentLevelobj_row = datarowposition, curentLevelarr_row = datarowtitlegroup;
- for (let r2 = 0; r2 < rowtitle.length; r2++) {
- let item2 = rowtitle[r2], name2 = r2 == 0 ? locale_pivotTable.valueSum : rowtitlename[r2 - 1];
- if (curentLevelobj_row[r2.toString()] != null && curentLevelobj_row[r2.toString()][item2] != null) {
- curentLevelarr_row = curentLevelarr_row[curentLevelobj_row[r2.toString()][item2]].children;
- } else {
- let orderby = r2 == 0 ? "self" : row[r2 - 1].orderby == "self" || row[r2 - 1].orderby == null ? item2 : showType == "column" ? item2 + values[parseInt(row[r2 - 1].orderby)].fullname : item2 + locale_pivotTable.valueSum;
- if (name2 == null) {
- name2 = locale_filter.valueBlank;
- }
- curentLevelarr_row.push({name: name2, fullname: item2, index: r2, orderby, children: []});
- if (curentLevelobj_row[r2.toString()] == null) {
- curentLevelobj_row[r2.toString()] = {};
- }
- if (curentLevelobj_row[r2.toString()][item2] == null) {
- curentLevelobj_row[r2.toString()][item2] = curentLevelarr_row.length - 1;
- }
- curentLevelarr_row = curentLevelarr_row[curentLevelarr_row.length - 1].children;
- }
- }
- let curentLevelobj_col = datacolposition, curentLevelarr_col = datacoltitlegroup;
- for (let r2 = 0; r2 < coltitle.length; r2++) {
- let item2 = coltitle[r2], name2 = r2 == 0 ? locale_pivotTable.valueSum : coltitlename[r2 - 1];
- if (curentLevelobj_col[r2.toString()] != null && curentLevelobj_col[r2.toString()][item2] != null) {
- curentLevelarr_col = curentLevelarr_col[curentLevelobj_col[r2.toString()][item2]].children;
- } else {
- let orderby = r2 == 0 ? "self" : column[r2 - 1].orderby == "self" || column[r2 - 1].orderby == null ? item2 : showType == "column" ? locale_pivotTable.valueSum + item2 : values[parseInt(column[r2 - 1].orderby)].fullname + item2;
- if (name2 == null) {
- name2 = locale_filter.valueBlank;
- }
- curentLevelarr_col.push({name: name2, fullname: item2, index: r2, orderby, children: []});
- if (curentLevelobj_col[r2.toString()] == null) {
- curentLevelobj_col[r2.toString()] = {};
- }
- if (curentLevelobj_col[r2.toString()][item2] == null) {
- curentLevelobj_col[r2.toString()][item2] = curentLevelarr_col.length - 1;
- }
- curentLevelarr_col = curentLevelarr_col[curentLevelarr_col.length - 1].children;
- }
- }
- let v_str = "";
- for (let v = 0; v < values.length; v++) {
- let d_value = getcellvalue(values[v].index, null, d);
- let coltitle_c = [].concat(coltitle), rowtitle_c = [].concat(rowtitle);
- if (showType == "column") {
- if (coltitle_c.length > 0) {
- coltitle_c.push("");
- coltitle_c = coltitle_c.join(values[v].fullname + "|||").split("|||").slice(0, coltitle_c.length - 1);
- } else {
- coltitle_c.push(values[v].fullname);
- }
- } else {
- if (rowtitle_c.length > 0) {
- rowtitle_c.push("");
- rowtitle_c = rowtitle_c.join(values[v].fullname + "|||").split("|||").slice(0, rowtitle_c.length - 1);
- } else {
- rowtitle_c.push(values[v].fullname);
- }
- }
- if (coltitle_c.length == 0) {
- coltitle_c.push("");
- }
- if (rowtitle_c.length == 0) {
- rowtitle_c.push("");
- }
- for (let r2 = 0; r2 < rowtitle_c.length; r2++) {
- for (let c2 = 0; c2 < coltitle_c.length; c2++) {
- let indicator = rowtitle_c[r2] + coltitle_c[c2];
- _this2.addStatisticsData(dataposition, values[v], indicator, d_value);
- }
- }
- }
- }
- for (let indicator in dataposition) {
- let json2 = dataposition[indicator];
- if (json2.sumtype == "SUM") {
- json2.result = json2.sum;
- } else if (json2.sumtype == "COUNT") {
- json2.result = json2.count;
- } else if (json2.sumtype == "COUNTA") {
- json2.result = json2.counta;
- } else if (json2.sumtype == "COUNTUNIQUE") {
- json2.result = json2.countunique;
- } else if (json2.sumtype == "AVERAGE") {
- json2.result = numFormat2(json2.sum / json2.count);
- } else if (json2.sumtype == "MAX") {
- json2.result = json2.max;
- } else if (json2.sumtype == "MIN") {
- json2.result = json2.min;
- } else if (json2.sumtype == "MEDIAN") {
- let numArr = json2.digitaldata.sort(function(a, b) {
- return a - b;
- });
- let numLen = numArr.length;
- let numindex = parseInt(numLen / 2);
- if (numLen % 2 == 0) {
- json2.result = (numArr[numindex - 1] + numArr[numindex]) / 2;
- } else {
- json2.result = numArr[numindex];
- }
- } else if (json2.sumtype == "PRODUCT") {
- json2.result = new Function("return " + json2.digitaldata.join("*"))();
- } else if (json2.sumtype == "STDEV") {
- let mean = json2.sum / json2.count;
- json2.result = analysis_default.STDEV(mean, json2.digitaldata);
- } else if (json2.sumtype == "STDEVP") {
- let mean = json2.sum / json2.count;
- json2.result = analysis_default.STDEVP(mean, json2.digitaldata);
- } else if (json2.sumtype == "let") {
- let mean = json2.sum / json2.count;
- json2.result = analysis_default.let(mean, json2.digitaldata);
- } else if (json2.sumtype == "VARP") {
- let mean = json2.sum / json2.count;
- json2.result = analysis_default.VARP(mean, json2.digitaldata);
- }
- let newAcc = numfloatlen(json2.result);
- if (newAcc > json2.acc) {
- json2.acc = newAcc;
- }
- json2.result = numFormat2(json2.result, json2.acc);
- }
- datarowtitle = _this2.getTitleFromGroup(datarowtitlegroup, row, dataposition);
- datacoltitle = _this2.getTitleFromGroup(datacoltitlegroup, column, dataposition);
- if (showType == "column") {
- if (datacoltitle.length > 0 && datacoltitle[0].length > 0) {
- datacoltitle = _this2.addValuesToTitle(datacoltitle, values);
- } else {
- for (let v = 0; v < values.length; v++) {
- datacoltitle.push([values[v].fullname]);
- }
- }
- } else {
- if (datarowtitle.length > 0 && datarowtitle[0].length > 0) {
- datarowtitle = _this2.addValuesToTitle(datarowtitle, values);
- } else {
- for (let v = 0; v < values.length; v++) {
- datarowtitle.push([values[v].fullname]);
- }
- }
- }
- let datacoltitle_index = datacoltitle;
- datacoltitle = array_default.transpose(datacoltitle, false);
- let valuenslen = values.length == 0 ? 0 : 1;
- let rowLen = (datacoltitle.length == 0 ? valuenslen : datacoltitle.length) + (datarowtitle.length == 0 ? valuenslen : datarowtitle.length), colLen = (datacoltitle.length == 0 ? valuenslen : datacoltitle[0].length) + (datarowtitle.length == 0 ? valuenslen : datarowtitle[0].length);
- let rowOver = datacoltitle.length, colOver = datarowtitle.length == 0 ? 0 : datarowtitle[0].length;
- let retdata = [];
- for (let r2 = 0; r2 < rowLen; r2++) {
- retdata[r2] = new Array(colLen);
- for (let c2 = 0; c2 < colLen; c2++) {
- let drt = datarowtitle[r2 - rowOver];
- if (r2 < rowOver && c2 < colOver) {
- retdata[r2][c2] = "";
- } else if (r2 < rowOver && c2 >= colOver) {
- if (datacoltitle[r2] != null) {
- if (getObjType(datacoltitle[r2][c2 - colOver]) == "object") {
- retdata[r2][c2] = datacoltitle[r2][c2 - colOver].name + locale_pivotTable.valueSum;
- } else {
- retdata[r2][c2] = datacoltitle[r2][c2 - colOver];
- }
- } else {
- retdata[r2][c2] = "";
- }
- } else if (r2 >= rowOver && c2 < colOver) {
- if (drt != null) {
- if (getObjType(drt[c2]) == "object") {
- retdata[r2][c2] = drt[c2].name + locale_pivotTable.valueSum;
- } else {
- retdata[r2][c2] = drt[c2];
- }
- } else {
- retdata[r2][c2] = "";
- }
- } else {
- let prefix = "";
- if (drt != null) {
- if (!(drt instanceof Array) || drt.length == 1) {
- if (drt instanceof Array) {
- prefix = drt[0];
- } else {
- prefix = drt;
- }
- } else {
- for (let x = 0; x < drt.length; x++) {
- if (getObjType(drt[x]) == "object") {
- prefix += drt[x].name;
- } else {
- prefix += drt[x];
- }
- }
- }
- }
- let suffix = "";
- let dct = datacoltitle_index[c2 - colOver];
- if (dct != null) {
- if (!(dct instanceof Array) || dct.length == 1) {
- if (dct instanceof Array) {
- suffix = dct[0];
- } else {
- suffix = dct;
- }
- } else {
- for (let x = 0; x < dct.length; x++) {
- if (getObjType(dct[x]) == "object") {
- suffix += dct[x].name;
- } else {
- suffix += dct[x];
- }
- }
- }
- }
- let indicator = prefix;
- if (prefix != "" && suffix != "") {
- indicator = prefix + suffix;
- } else if (prefix == "") {
- indicator = suffix;
- }
- if (dataposition[indicator] == null) {
- retdata[r2][c2] = "";
- } else {
- retdata[r2][c2] = dataposition[indicator].result;
- }
- }
- }
- }
- if (values.length == 1 && column.length > 0 && row.length > 0) {
- retdata[0][0] = values[0].fullname;
- retdata.splice(column.length, 1);
- } else if (values.length == 1 && column.length > 0) {
- let titleRow = retdata.splice(column.length, 1);
- let newRetdata = [];
- for (let r2 = 0; r2 < retdata.length; r2++) {
- let row2 = [];
- if (r2 == retdata.length - 1) {
- row2.push(titleRow[0][0]);
- } else {
- row2.push("");
- }
- for (let c2 = 0; c2 < retdata[r2].length - 1; c2++) {
- row2.push(retdata[r2][c2]);
- }
- newRetdata.push(row2);
- }
- retdata = newRetdata;
- }
- _this2.pivotDatas = retdata;
- return retdata;
- },
- drillDown: function(row_index, col_index) {
- if (!checkProtectionAuthorityNormal(store_default.currentSheetIndex, "usePivotTablereports")) {
- return;
- }
- let _this2 = this;
- let cell = _this2.pivotDatas[row_index][col_index];
- let d = $.extend(true, [], sheetmanage_default.nulldata);
- const _locale = locale_default();
- const locale_filter = _locale.filter;
- const locale_pivotTable = _locale.pivotTable;
- let selecteditemNullIndex = 1;
- for (let i2 = 0; i2 < _this2.celldata[0].length; i2++) {
- let name2;
- if (!!_this2.celldata[0][i2] && !!_this2.celldata[0][i2]["m"]) {
- name2 = _this2.celldata[0][i2]["m"];
- } else {
- name2 = getcellvalue(0, i2, _this2.celldata);
- }
- if (name2 != null) {
- name2 = name2.toString();
- }
- if (name2 == null || $.trim(name2.toString()).length == 0) {
- name2 = locale_pivotTable.titleColumn + " " + selecteditemNullIndex;
- }
- selecteditemNullIndex++;
- d[0][i2] = name2;
- }
- let obj = {};
- if (_this2.row != null && _this2.row.length > 0) {
- for (let a = 0; a < _this2.row.length; a++) {
- obj[_this2.row[a]["index"]] = _this2.pivotDatas[row_index][a];
- }
- }
- if (_this2.column != null && _this2.column.length > 0) {
- for (let b = 0; b < _this2.column.length; b++) {
- obj[_this2.column[b]["index"]] = _this2.pivotDatas[b][col_index];
- }
- }
- let rowArr = [];
- for (let j = 1; j < _this2.celldata.length; j++) {
- let isEqual = true;
- for (let x in obj) {
- let value;
- if (!!_this2.celldata[j][x] && !!_this2.celldata[j][x]["m"]) {
- value = _this2.celldata[j][x]["m"];
- } else {
- value = getcellvalue(j, x, _this2.celldata);
- }
- if (value != null) {
- value = value.toString();
- } else {
- value = locale_filter.valueBlank;
- }
- if (value != obj[x]) {
- isEqual = false;
- break;
- }
- }
- if (isEqual) {
- rowArr.push(j);
- }
- }
- for (let r2 = 0; r2 < rowArr.length; r2++) {
- for (let c2 = 0; c2 < _this2.celldata[0].length; c2++) {
- let value;
- if (!!_this2.celldata[rowArr[r2]][c2] && !!_this2.celldata[rowArr[r2]][c2]["m"]) {
- value = _this2.celldata[rowArr[r2]][c2]["m"];
- } else {
- value = getcellvalue(rowArr[r2], c2, _this2.celldata);
- }
- if (value != null) {
- value = value.toString();
- } else {
- value = "";
- }
- d[r2 + 1][c2] = value;
- }
- }
- store_default.luckysheet_select_save = [{row: [0, rowArr.length], column: [0, _this2.celldata[0].length - 1]}];
- store_default.clearjfundo = false;
- jfrefreshgrid(d, store_default.luckysheet_select_save);
- selectHightlightShow();
- store_default.clearjfundo = true;
- }
- };
- pivotTable_default = pivotTable;
- }
- });
-
- // src/controllers/sparkline.js
- var createClass, SPFormat, clipval, quartile, normalizeValue, normalizeValues, all, remove, isNumber, formatNumber, RangeMap, luckysheetSparkline, barHighlightMixin, _luckysheetSparkLineOptions, _luckysheetSparkLineTarget, sparkline_default;
- var init_sparkline = __esm({
- "src/controllers/sparkline.js"() {
- init_store();
- createClass = function() {
- let Class, args;
- Class = function() {
- this.init.apply(this, arguments);
- };
- if (arguments.length > 1) {
- if (arguments[0]) {
- Class.prototype = $.extend(new arguments[0](), arguments[arguments.length - 1]);
- Class._super = arguments[0].prototype;
- } else {
- Class.prototype = arguments[arguments.length - 1];
- }
- if (arguments.length > 2) {
- args = Array.prototype.slice.call(arguments, 1, -1);
- args.unshift(Class.prototype);
- $.extend.apply($, args);
- }
- } else {
- Class.prototype = arguments[0];
- }
- Class.prototype.cls = Class;
- return Class;
- };
- SPFormat = createClass({
- fre: /\{\{([\w.]+?)(:(.+?))?\}\}/g,
- precre: /(\w+)\.(\d+)/,
- init: function(format, fclass) {
- this.format = format;
- this.fclass = fclass;
- },
- render: function(fieldset, lookups, options) {
- let self2 = this, fields = fieldset, match, token, lookupkey, fieldvalue, prec;
- return this.format.replace(this.fre, function() {
- let lookup;
- token = arguments[1];
- lookupkey = arguments[3];
- match = self2.precre.exec(token);
- if (match) {
- prec = match[2];
- token = match[1];
- } else {
- prec = false;
- }
- fieldvalue = fields[token];
- if (fieldvalue === void 0) {
- return "";
- }
- if (lookupkey && lookups && lookups[lookupkey]) {
- lookup = lookups[lookupkey];
- if (lookup.get) {
- return lookups[lookupkey].get(fieldvalue) || fieldvalue;
- } else {
- return lookups[lookupkey][fieldvalue] || fieldvalue;
- }
- }
- if (isNumber(fieldvalue)) {
- if (options.get("numberFormatter")) {
- fieldvalue = options.get("numberFormatter")(fieldvalue);
- } else {
- fieldvalue = formatNumber(fieldvalue, prec, options.get("numberDigitGroupCount"), options.get("numberDigitGroupSep"), options.get("numberDecimalMark"));
- }
- }
- return fieldvalue;
- });
- }
- });
- $.spformat = function(format, fclass) {
- return new SPFormat(format, fclass);
- };
- clipval = function(val, min, max) {
- if (val < min) {
- return min;
- }
- if (val > max) {
- return max;
- }
- return val;
- };
- quartile = function(values, q) {
- let vl;
- if (q === 2) {
- vl = Math.floor(values.length / 2);
- return values.length % 2 ? values[vl] : (values[vl - 1] + values[vl]) / 2;
- } else {
- if (values.length % 2) {
- vl = (values.length * q + q) / 4;
- return vl % 1 ? (values[Math.floor(vl)] + values[Math.floor(vl) - 1]) / 2 : values[vl - 1];
- } else {
- vl = (values.length * q + 2) / 4;
- return vl % 1 ? (values[Math.floor(vl)] + values[Math.floor(vl) - 1]) / 2 : values[vl - 1];
- }
- }
- };
- normalizeValue = function(val) {
- let nf;
- switch (val) {
- case "undefined":
- val = void 0;
- break;
- case "null":
- val = null;
- break;
- case "true":
- val = true;
- break;
- case "false":
- val = false;
- break;
- default:
- nf = parseFloat(val);
- if (val == nf) {
- val = nf;
- }
- }
- return val;
- };
- normalizeValues = function(vals) {
- let i2, result = [];
- for (i2 = vals.length; i2--; ) {
- result[i2] = normalizeValue(vals[i2]);
- }
- return result;
- };
- all = function(val, arr, ignoreNull) {
- let i2;
- for (i2 = arr.length; i2--; ) {
- if (ignoreNull && arr[i2] === null)
- continue;
- if (arr[i2] !== val) {
- return false;
- }
- }
- return true;
- };
- remove = function(vals, filter) {
- let i2, vl, result = [];
- for (i2 = 0, vl = vals.length; i2 < vl; i2++) {
- if (vals[i2] !== filter) {
- result.push(vals[i2]);
- }
- }
- return result;
- };
- isNumber = function(num) {
- return !isNaN(parseFloat(num)) && isFinite(num);
- };
- formatNumber = function(num, prec, groupsize, groupsep, decsep) {
- let p, i2;
- num = (prec === false ? parseFloat(num).toString() : num.toFixed(prec)).split("");
- p = (p = $.inArray(".", num)) < 0 ? num.length : p;
- if (p < num.length) {
- num[p] = decsep;
- }
- for (i2 = p - groupsize; i2 > 0; i2 -= groupsize) {
- num.splice(i2, 0, groupsep);
- }
- return num.join("");
- };
- RangeMap = createClass({
- init: function(map) {
- let key, range2, rangelist = [];
- for (key in map) {
- if (map.hasOwnProperty(key) && typeof key === "string" && key.indexOf(":") > -1) {
- range2 = key.split(":");
- range2[0] = range2[0].length === 0 ? -Infinity : parseFloat(range2[0]);
- range2[1] = range2[1].length === 0 ? Infinity : parseFloat(range2[1]);
- range2[2] = map[key];
- rangelist.push(range2);
- }
- }
- this.map = map;
- this.rangelist = rangelist || false;
- },
- get: function(value) {
- let rangelist = this.rangelist, i2, range2, result;
- if ((result = this.map[value]) !== void 0) {
- return result;
- }
- if (rangelist) {
- for (i2 = rangelist.length; i2--; ) {
- range2 = rangelist[i2];
- if (range2[0] <= value && range2[1] >= value) {
- return range2[2];
- }
- }
- }
- return void 0;
- }
- });
- $.range_map = function(map) {
- return new RangeMap(map);
- };
- luckysheetSparkline = {
- defaultOption: {
- common: {
- type: "line",
- lineColor: "#2ec7c9",
- fillColor: "#CCF3F4",
- defaultPixelsPerValue: 3,
- width: "auto",
- height: "auto",
- composite: false,
- tagValuesAttribute: "values",
- tagOptionsPrefix: "spark",
- enableTagOptions: false,
- enableHighlight: true,
- highlightLighten: 1.4,
- tooltipSkipNull: true,
- tooltipPrefix: "",
- tooltipSuffix: "",
- disableHiddenCheck: false,
- numberFormatter: false,
- numberDigitGroupCount: 3,
- numberDigitGroupSep: ",",
- numberDecimalMark: ".",
- disableTooltips: true,
- disableInteraction: true,
- offsetX: 0,
- offsetY: 0
- },
- line: {
- spotColor: 0,
- highlightSpotColor: "#5f5",
- highlightLineColor: "#f22",
- spotRadius: 1.5,
- minSpotColor: 0,
- maxSpotColor: 0,
- lineWidth: 1,
- normalRangeMin: void 0,
- normalRangeMax: void 0,
- normalRangeColor: "#ccc",
- drawNormalOnTop: true,
- chartRangeMin: void 0,
- chartRangeMax: void 0,
- chartRangeMinX: void 0,
- chartRangeMaxX: void 0
- },
- bar: {
- barColor: "#fc5c5c",
- negBarColor: "#97b552",
- stackedBarColor: ["#2ec7c9", "#fc5c5c", "#5ab1ef", "#ffb980", "#d87a80", "#8d98b3", "#e5cf0d", "#97b552", "#95706d", "#dc69aa", "#07a2a4", "#9a7fd1", "#588dd5", "#f5994e", "#c05050", "#59678c", "#c9ab00", "#7eb00a", "#6f5553", "#c14089"],
- zeroColor: void 0,
- nullColor: void 0,
- zeroAxis: true,
- barWidth: 4,
- barSpacing: 1,
- chartRangeMax: void 0,
- chartRangeMin: void 0,
- chartRangeClip: false,
- colorMap: void 0
- },
- column: {
- barColor: "#fc5c5c",
- negBarColor: "#97b552",
- stackedBarColor: ["#2ec7c9", "#fc5c5c", "#5ab1ef", "#ffb980", "#d87a80", "#8d98b3", "#e5cf0d", "#97b552", "#95706d", "#dc69aa", "#07a2a4", "#9a7fd1", "#588dd5", "#f5994e", "#c05050", "#59678c", "#c9ab00", "#7eb00a", "#6f5553", "#c14089"],
- zeroColor: void 0,
- nullColor: void 0,
- zeroAxis: true,
- barWidth: 4,
- barSpacing: 1,
- chartRangeMax: void 0,
- chartRangeMin: void 0,
- chartRangeClip: false,
- colorMap: void 0
- },
- tristate: {
- barWidth: 4,
- barSpacing: 1,
- posBarColor: "#fc5c5c",
- negBarColor: "#97b552",
- zeroBarColor: "#999",
- colorMap: {}
- },
- discrete: {
- lineHeight: "auto",
- thresholdColor: "#fc5c5c",
- thresholdValue: 0,
- chartRangeMax: void 0,
- chartRangeMin: void 0,
- chartRangeClip: false
- },
- bullet: {
- targetColor: "#f33",
- targetWidth: 3,
- performanceColor: "#33f",
- rangeColors: ["#d3dafe", "#a8b6ff", "#7f94ff", "#6D87FF", "#5876FF", "#4465FF", "#2F54FF", "#1A43FF", "#0532FF"],
- base: void 0
- },
- pie: {
- offset: 0,
- sliceColors: ["#2ec7c9", "#fc5c5c", "#5ab1ef", "#ffb980", "#d87a80", "#8d98b3", "#e5cf0d", "#97b552", "#95706d", "#dc69aa", "#07a2a4", "#9a7fd1", "#588dd5", "#f5994e", "#c05050", "#59678c", "#c9ab00", "#7eb00a", "#6f5553", "#c14089"],
- borderWidth: 0,
- borderColor: "#000"
- },
- box: {
- raw: false,
- boxLineColor: "#000",
- boxFillColor: "#cdf",
- whiskerColor: "#000",
- outlierLineColor: "#5E5E5E",
- outlierFillColor: "#fff",
- medianColor: "#f00",
- showOutliers: true,
- outlierIQR: 1.5,
- spotRadius: 1.5,
- target: void 0,
- targetColor: "#4a2",
- chartRangeMax: void 0,
- chartRangeMin: void 0
- }
- },
- line: {
- type: "line",
- init: function(el, values, options, width, height) {
- this.vertices = [];
- this.regionMap = [];
- this.xvalues = [];
- this.yvalues = [];
- this.yminmax = [];
- this.hightlightSpotId = null;
- this.lastShapeId = null;
- },
- getRegion: function(el, x, y) {
- let i2, regionMap = this.regionMap;
- for (i2 = regionMap.length; i2--; ) {
- if (regionMap[i2] !== null && x >= regionMap[i2][0] && x <= regionMap[i2][1]) {
- return regionMap[i2][2];
- }
- }
- return void 0;
- },
- getCurrentRegionFields: function() {
- let currentRegion = this.currentRegion;
- return {
- isNull: this.yvalues[currentRegion] === null,
- x: this.xvalues[currentRegion],
- y: this.yvalues[currentRegion],
- color: this.options.get("lineColor"),
- fillColor: this.options.get("fillColor"),
- offset: currentRegion
- };
- },
- renderHighlight: function() {
- let currentRegion = this.currentRegion, target = this.target, vertex = this.vertices[currentRegion], options = this.options, spotRadius = options.get("spotRadius"), highlightSpotColor = options.get("highlightSpotColor"), highlightLineColor = options.get("highlightLineColor"), highlightSpot, highlightLine;
- if (!vertex) {
- return;
- }
- if (spotRadius && highlightSpotColor) {
- highlightSpot = target.drawCircle(vertex[0], vertex[1], spotRadius, void 0, highlightSpotColor);
- this.highlightSpotId = highlightSpot.id;
- target.insertAfterShape(this.lastShapeId, highlightSpot);
- }
- if (highlightLineColor) {
- highlightLine = target.drawLine(vertex[0], this.canvasTop, vertex[0], this.canvasTop + this.canvasHeight, highlightLineColor);
- this.highlightLineId = highlightLine.id;
- target.insertAfterShape(this.lastShapeId, highlightLine);
- }
- },
- removeHighlight: function() {
- let target = this.target;
- if (this.highlightSpotId) {
- target.removeShapeId(this.highlightSpotId);
- this.highlightSpotId = null;
- }
- if (this.highlightLineId) {
- target.removeShapeId(this.highlightLineId);
- this.highlightLineId = null;
- }
- },
- scanValues: function() {
- let values = this.values, valcount = values.length, xvalues = this.xvalues, yvalues = this.yvalues, yminmax = this.yminmax, i2, val, isStr, isArray, sp;
- for (i2 = 0; i2 < valcount; i2++) {
- val = values[i2];
- isStr = typeof values[i2] === "string";
- isArray = typeof values[i2] === "object" && values[i2] instanceof Array;
- sp = isStr && values[i2].split(":");
- if (isStr && sp.length === 2) {
- xvalues.push(Number(sp[0]));
- yvalues.push(Number(sp[1]));
- yminmax.push(Number(sp[1]));
- } else if (isArray) {
- xvalues.push(val[0]);
- yvalues.push(val[1]);
- yminmax.push(val[1]);
- } else {
- xvalues.push(i2);
- if (values[i2] === null || values[i2] === "null") {
- yvalues.push(null);
- } else {
- yvalues.push(Number(val));
- yminmax.push(Number(val));
- }
- }
- }
- if (this.options.get("xvalues")) {
- xvalues = this.options.get("xvalues");
- }
- this.maxy = this.maxyorg = Math.max.apply(Math, yminmax);
- this.miny = this.minyorg = Math.min.apply(Math, yminmax);
- this.maxx = Math.max.apply(Math, xvalues);
- this.minx = Math.min.apply(Math, xvalues);
- this.xvalues = xvalues;
- this.yvalues = yvalues;
- this.yminmax = yminmax;
- },
- processRangeOptions: function() {
- let options = this.options, normalRangeMin = options.get("normalRangeMin"), normalRangeMax = options.get("normalRangeMax");
- if (normalRangeMin !== void 0) {
- if (normalRangeMin < this.miny) {
- this.miny = normalRangeMin;
- }
- if (normalRangeMax > this.maxy) {
- this.maxy = normalRangeMax;
- }
- }
- if (options.get("chartRangeMin") !== void 0 && (options.get("chartRangeClip") || options.get("chartRangeMin") < this.miny)) {
- this.miny = options.get("chartRangeMin");
- }
- if (options.get("chartRangeMax") !== void 0 && (options.get("chartRangeClip") || options.get("chartRangeMax") > this.maxy)) {
- this.maxy = options.get("chartRangeMax");
- }
- if (options.get("chartRangeMinX") !== void 0 && (options.get("chartRangeClipX") || options.get("chartRangeMinX") < this.minx)) {
- this.minx = options.get("chartRangeMinX");
- }
- if (options.get("chartRangeMaxX") !== void 0 && (options.get("chartRangeClipX") || options.get("chartRangeMaxX") > this.maxx)) {
- this.maxx = options.get("chartRangeMaxX");
- }
- },
- drawNormalRange: function(canvasLeft, canvasTop, canvasHeight, canvasWidth, rangey) {
- let normalRangeMin = this.options.get("normalRangeMin"), normalRangeMax = this.options.get("normalRangeMax"), ytop = canvasTop + Math.round(canvasHeight - canvasHeight * ((normalRangeMax - this.miny) / rangey)), height = Math.round(canvasHeight * (normalRangeMax - normalRangeMin) / rangey);
- if (height == 0 && normalRangeMin == normalRangeMax) {
- height = 1;
- }
- this.target.drawRect(canvasLeft, ytop, canvasWidth, height, void 0, this.options.get("normalRangeColor")).append();
- },
- render: function(el, userValues) {
- this.vertices = [];
- this.regionMap = [];
- this.xvalues = [];
- this.yvalues = [];
- this.yminmax = [];
- this.hightlightSpotId = null;
- this.lastShapeId = null;
- this.values = userValues;
- let options = this.options, target = this.target, canvasWidth = el.mergedOptions.width, canvasHeight = el.mergedOptions.height, vertices = this.vertices, spotRadius = options.get("spotRadius"), regionMap = this.regionMap, rangex, rangey, yvallast, canvasTop, canvasLeft, vertex, path, paths, x, y, xnext, xpos, xposnext, last, next, yvalcount, lineShapes, fillShapes, plen, valueSpots, hlSpotsEnabled, color, xvalues, yvalues, i2;
- this.scanValues();
- this.processRangeOptions();
- xvalues = this.xvalues;
- yvalues = this.yvalues;
- if (!this.yminmax.length || this.yvalues.length < 2) {
- return;
- }
- canvasTop = canvasLeft = 0;
- rangex = this.maxx - this.minx === 0 ? 1 : this.maxx - this.minx;
- rangey = this.maxy - this.miny === 0 ? 1 : this.maxy - this.miny;
- yvallast = this.yvalues.length - 1;
- if (spotRadius && (canvasWidth < spotRadius * 4 || canvasHeight < spotRadius * 4)) {
- spotRadius = 0;
- }
- if (spotRadius) {
- hlSpotsEnabled = options.get("highlightSpotColor") && !options.get("disableInteraction");
- if (hlSpotsEnabled || options.get("minSpotColor") || options.get("spotColor") && yvalues[yvallast] === this.miny) {
- canvasHeight -= Math.ceil(spotRadius);
- }
- if (hlSpotsEnabled || options.get("maxSpotColor") || options.get("spotColor") && yvalues[yvallast] === this.maxy) {
- canvasHeight -= Math.ceil(spotRadius);
- canvasTop += Math.ceil(spotRadius);
- }
- if (hlSpotsEnabled || (options.get("minSpotColor") || options.get("maxSpotColor")) && (yvalues[0] === this.miny || yvalues[0] === this.maxy)) {
- canvasLeft += Math.ceil(spotRadius);
- canvasWidth -= Math.ceil(spotRadius);
- }
- if (hlSpotsEnabled || options.get("spotColor") || (options.get("minSpotColor") || options.get("maxSpotColor") && (yvalues[yvallast] === this.miny || yvalues[yvallast] === this.maxy))) {
- canvasWidth -= Math.ceil(spotRadius);
- }
- }
- canvasHeight--;
- if (options.get("normalRangeMin") !== void 0 && !options.get("drawNormalOnTop")) {
- this.drawNormalRange(canvasLeft, canvasTop, canvasHeight, canvasWidth, rangey);
- }
- path = [];
- paths = [path];
- last = next = null;
- yvalcount = yvalues.length;
- for (i2 = 0; i2 < yvalcount; i2++) {
- x = xvalues[i2];
- xnext = xvalues[i2 + 1];
- y = yvalues[i2];
- xpos = canvasLeft + Math.round((x - this.minx) * (canvasWidth / rangex));
- xposnext = i2 < yvalcount - 1 ? canvasLeft + Math.round((xnext - this.minx) * (canvasWidth / rangex)) : canvasWidth;
- next = xpos + (xposnext - xpos) / 2;
- regionMap[i2] = [last || 0, next, i2];
- last = next;
- if (y === null) {
- if (i2) {
- if (yvalues[i2 - 1] !== null) {
- path = [];
- paths.push(path);
- }
- vertices.push(null);
- }
- } else {
- if (y < this.miny) {
- y = this.miny;
- }
- if (y > this.maxy) {
- y = this.maxy;
- }
- if (!path.length) {
- path.push([xpos, canvasTop + canvasHeight]);
- }
- vertex = [xpos, canvasTop + Math.round(canvasHeight - canvasHeight * ((y - this.miny) / rangey))];
- path.push(vertex);
- vertices.push(vertex);
- }
- }
- lineShapes = [];
- fillShapes = [];
- plen = paths.length;
- for (i2 = 0; i2 < plen; i2++) {
- path = paths[i2];
- if (path.length) {
- if (options.get("fillColor")) {
- path.push([path[path.length - 1][0], canvasTop + canvasHeight]);
- fillShapes.push(path.slice(0));
- path.pop();
- }
- if (path.length > 2) {
- path[0] = [path[0][0], path[1][1]];
- }
- lineShapes.push(path);
- }
- }
- plen = fillShapes.length;
- for (i2 = 0; i2 < plen; i2++) {
- target.drawShape(fillShapes[i2], options.get("fillColor"), options.get("fillColor")).append();
- }
- plen = lineShapes.length;
- for (i2 = 0; i2 < plen; i2++) {
- target.drawShape(lineShapes[i2], options.get("lineColor"), void 0, options.get("lineWidth")).append();
- }
- if (options.get("normalRangeMin") !== void 0 && options.get("drawNormalOnTop")) {
- this.drawNormalRange(canvasLeft, canvasTop, canvasHeight, canvasWidth, rangey);
- }
- if (spotRadius && options.get("valueSpots")) {
- valueSpots = options.get("valueSpots");
- if (valueSpots.get === void 0) {
- valueSpots = new RangeMap(valueSpots);
- }
- for (i2 = 0; i2 < yvalcount; i2++) {
- color = valueSpots.get(yvalues[i2]);
- if (color) {
- target.drawCircle(canvasLeft + Math.round((xvalues[i2] - this.minx) * (canvasWidth / rangex)), canvasTop + Math.round(canvasHeight - canvasHeight * ((yvalues[i2] - this.miny) / rangey)), spotRadius, void 0, color).append();
- }
- }
- }
- if (spotRadius && options.get("spotColor") && yvalues[yvallast] !== null) {
- target.drawCircle(canvasLeft + Math.round((xvalues[xvalues.length - 1] - this.minx) * (canvasWidth / rangex)), canvasTop + Math.round(canvasHeight - canvasHeight * ((yvalues[yvallast] - this.miny) / rangey)), spotRadius, void 0, options.get("spotColor")).append();
- }
- if (this.maxy !== this.minyorg) {
- if (spotRadius && options.get("minSpotColor")) {
- x = xvalues[$.inArray(this.minyorg, yvalues)];
- target.drawCircle(canvasLeft + Math.round((x - this.minx) * (canvasWidth / rangex)), canvasTop + Math.round(canvasHeight - canvasHeight * ((this.minyorg - this.miny) / rangey)), spotRadius, void 0, options.get("minSpotColor")).append();
- }
- if (spotRadius && options.get("maxSpotColor")) {
- x = xvalues[$.inArray(this.maxyorg, yvalues)];
- target.drawCircle(canvasLeft + Math.round((x - this.minx) * (canvasWidth / rangex)), canvasTop + Math.round(canvasHeight - canvasHeight * ((this.maxyorg - this.miny) / rangey)), spotRadius, void 0, options.get("maxSpotColor")).append();
- }
- }
- }
- },
- bar: {
- type: "bar",
- init: function(el, values) {
- let options = this.options;
- let width = el.mergedOptions.height;
- let height = el.mergedOptions.width;
- this.canvasWidth = el.mergedOptions.height;
- this.canvasHeight = el.mergedOptions.width;
- let barWidth = parseInt(options.get("barWidth"), 10), barSpacing = parseInt(options.get("barSpacing"), 10), chartRangeMin = options.get("chartRangeMin"), chartRangeMax = options.get("chartRangeMax"), chartRangeClip = options.get("chartRangeClip"), stackMin = Infinity, stackMax = -Infinity, isStackString, groupMin, groupMax, stackRanges, numValues, i2, vlen, range2, zeroAxis, xaxisOffset, min, max, clipMin, clipMax, stacked, vlist, j, slen2, svals, val, yoffset, yMaxCalc, canvasHeightEf;
- this.values = values;
- for (i2 = 0, vlen = values.length; i2 < vlen; i2++) {
- val = values[i2];
- isStackString = typeof val === "string" && val.indexOf(":") > -1;
- if (isStackString || $.isArray(val)) {
- stacked = true;
- if (isStackString) {
- val = values[i2] = normalizeValues(val.split(":"));
- }
- val = remove(val, null);
- groupMin = Math.min.apply(Math, val);
- groupMax = Math.max.apply(Math, val);
- if (groupMin < stackMin) {
- stackMin = groupMin;
- }
- if (groupMax > stackMax) {
- stackMax = groupMax;
- }
- }
- }
- this.stacked = stacked;
- this.regionShapes = {};
- this.barWidth = Math.floor(width / values.length) - barSpacing;
- this.barSpacing = barSpacing;
- this.totalBarWidth = this.barWidth + barSpacing;
- this.width = width;
- if (chartRangeClip) {
- clipMin = chartRangeMin === void 0 ? -Infinity : chartRangeMin;
- clipMax = chartRangeMax === void 0 ? Infinity : chartRangeMax;
- }
- numValues = [];
- stackRanges = stacked ? [] : numValues;
- let stackTotals = [];
- let stackRangesNeg = [];
- for (i2 = 0, vlen = values.length; i2 < vlen; i2++) {
- if (stacked) {
- vlist = values[i2];
- values[i2] = svals = [];
- stackTotals[i2] = 0;
- stackRanges[i2] = stackRangesNeg[i2] = 0;
- for (j = 0, slen2 = vlist.length; j < slen2; j++) {
- val = svals[j] = chartRangeClip ? clipval(vlist[j], clipMin, clipMax) : vlist[j];
- if (val !== null) {
- if (val > 0) {
- stackTotals[i2] += val;
- }
- if (stackMin < 0 && stackMax > 0) {
- if (val < 0) {
- stackRangesNeg[i2] += Math.abs(val);
- } else {
- stackRanges[i2] += val;
- }
- } else {
- stackRanges[i2] += Math.abs(val);
- }
- numValues.push(val);
- }
- }
- } else {
- val = chartRangeClip ? clipval(values[i2], clipMin, clipMax) : values[i2];
- val = values[i2] = normalizeValue(val);
- if (val !== null) {
- numValues.push(val);
- }
- }
- }
- this.max = max = Math.max.apply(Math, numValues);
- this.min = min = Math.min.apply(Math, numValues);
- this.stackMax = stackMax = stacked ? Math.max.apply(Math, stackTotals) : max;
- this.stackMin = stackMin = stacked ? Math.min.apply(Math, numValues) : min;
- if (options.get("chartRangeMin") !== void 0 && (options.get("chartRangeClip") || options.get("chartRangeMin") < min)) {
- min = options.get("chartRangeMin");
- }
- if (options.get("chartRangeMax") !== void 0 && (options.get("chartRangeClip") || options.get("chartRangeMax") > max)) {
- max = options.get("chartRangeMax");
- }
- this.zeroAxis = zeroAxis = options.get("zeroAxis", true);
- if (min <= 0 && max >= 0 && zeroAxis) {
- xaxisOffset = 0;
- } else if (zeroAxis == false) {
- xaxisOffset = min;
- } else if (min > 0) {
- xaxisOffset = 0;
- } else {
- xaxisOffset = max;
- }
- this.xaxisOffset = xaxisOffset;
- range2 = stacked ? Math.max.apply(Math, stackRanges) + Math.max.apply(Math, stackRangesNeg) : max - xaxisOffset;
- this.canvasHeightEf = zeroAxis && min < 0 ? this.canvasHeight - 2 : this.canvasHeight - 1;
- this.isNeg = false;
- if (min < xaxisOffset) {
- yoffset = Math.floor(this.canvasHeight / 2);
- this.isNeg = true;
- if (yoffset !== Math.ceil(yoffset)) {
- this.canvasHeightEf -= 2;
- yoffset = Math.ceil(yoffset);
- }
- } else {
- yoffset = 0;
- }
- this.yoffset = yoffset;
- if ($.isArray(options.get("colorMap"))) {
- this.colorMapByIndex = options.get("colorMap");
- this.colorMapByValue = null;
- } else {
- this.colorMapByIndex = null;
- this.colorMapByValue = options.get("colorMap");
- if (this.colorMapByValue && this.colorMapByValue.get === void 0) {
- this.colorMapByValue = new RangeMap(this.colorMapByValue);
- }
- }
- this.range = range2;
- },
- getRegion: function(el, x, y) {
- let result = Math.floor(x / this.totalBarWidth);
- return result < 0 || result >= this.values.length ? void 0 : result;
- },
- getCurrentRegionFields: function() {
- let currentRegion = this.currentRegion, values = ensureArray(this.values[currentRegion]), result = [], value, i2;
- for (i2 = values.length; i2--; ) {
- value = values[i2];
- result.push({
- isNull: value === null,
- value,
- color: this.calcColor(i2, value, currentRegion),
- offset: currentRegion
- });
- }
- return result;
- },
- calcColor: function(stacknum, value, valuenum) {
- let colorMapByIndex = this.colorMapByIndex, colorMapByValue = this.colorMapByValue, options = this.options, color, newColor;
- if (this.stacked) {
- color = options.get("stackedBarColor");
- } else {
- color = value < 0 ? options.get("negBarColor") : options.get("barColor");
- }
- if (value === 0 && options.get("zeroColor") !== void 0) {
- color = options.get("zeroColor");
- }
- if (colorMapByValue && (newColor = colorMapByValue.get(value))) {
- color = newColor;
- } else if (colorMapByIndex && colorMapByIndex.length > valuenum) {
- color = colorMapByIndex[valuenum];
- }
- return $.isArray(color) ? color[stacknum % color.length] : color;
- },
- renderRegion: function(valuenum, highlight) {
- let vals = this.values[valuenum], options = this.options, xaxisOffset = this.xaxisOffset, result = [], range2 = this.range, stacked = this.stacked, target = this.target, x = valuenum * this.totalBarWidth, canvasHeightEf = this.canvasHeightEf, yoffset = this.yoffset, y, height, color, isNull, yoffsetNeg, i2, valcount, val, minPlotted, allMin;
- vals = $.isArray(vals) ? vals : [vals];
- valcount = vals.length;
- val = vals[0];
- isNull = all(null, vals);
- allMin = all(xaxisOffset, vals, true);
- if (isNull) {
- if (options.get("nullColor")) {
- color = highlight ? options.get("nullColor") : this.calcHighlightColor(options.get("nullColor"), options);
- y = yoffset > 0 ? yoffset - 1 : yoffset;
- return target.drawRect(y, x, 0, this.barWidth - 1, color, color);
- } else {
- return void 0;
- }
- }
- yoffsetNeg = yoffset;
- if (this.isNeg) {
- canvasHeightEf = Math.floor(canvasHeightEf / 2);
- }
- for (i2 = 0; i2 < valcount; i2++) {
- val = vals[i2];
- if (stacked && val === xaxisOffset) {
- if (!allMin || minPlotted) {
- continue;
- }
- minPlotted = true;
- }
- if (range2 > 0) {
- height = Math.floor(canvasHeightEf * (Math.abs(val - xaxisOffset) / range2));
- } else {
- height = canvasHeightEf;
- }
- if (val < xaxisOffset || val === xaxisOffset && yoffset === 0) {
- y = yoffsetNeg - height;
- yoffsetNeg += height;
- } else {
- if (stacked) {
- y = yoffset;
- yoffset += height;
- } else {
- y = yoffset;
- yoffset -= height;
- }
- }
- color = this.calcColor(i2, val, valuenum);
- if (highlight) {
- color = this.calcHighlightColor(color, options);
- }
- result.push(target.drawRect(y, x, height - 1, this.barWidth - 1, color, color));
- }
- if (result.length === 1) {
- return result[0];
- }
- return result;
- }
- },
- column: {
- type: "column",
- init: function(el, values) {
- let options = this.options;
- let width = el.mergedOptions.width;
- let height = el.mergedOptions.height;
- this.canvasWidth = el.mergedOptions.width;
- this.canvasHeight = el.mergedOptions.height;
- let barWidth = parseInt(options.get("barWidth"), 10), barSpacing = parseInt(options.get("barSpacing"), 10), chartRangeMin = options.get("chartRangeMin"), chartRangeMax = options.get("chartRangeMax"), chartRangeClip = options.get("chartRangeClip"), stackMin = Infinity, stackMax = -Infinity, isStackString, groupMin, groupMax, stackRanges, numValues, i2, vlen, range2, zeroAxis, xaxisOffset, min, max, clipMin, clipMax, stacked, vlist, j, slen2, svals, val, yoffset, yMaxCalc, canvasHeightEf;
- this.values = values;
- for (i2 = 0, vlen = values.length; i2 < vlen; i2++) {
- val = values[i2];
- isStackString = typeof val === "string" && val.indexOf(":") > -1;
- if (isStackString || $.isArray(val)) {
- stacked = true;
- if (isStackString) {
- val = values[i2] = normalizeValues(val.split(":"));
- }
- val = remove(val, null);
- groupMin = Math.min.apply(Math, val);
- groupMax = Math.max.apply(Math, val);
- if (groupMin < stackMin) {
- stackMin = groupMin;
- }
- if (groupMax > stackMax) {
- stackMax = groupMax;
- }
- }
- }
- this.stacked = stacked;
- this.regionShapes = {};
- this.barWidth = Math.floor(width / values.length) - barSpacing;
- this.barSpacing = barSpacing;
- this.totalBarWidth = this.barWidth + barSpacing;
- this.width = width;
- if (chartRangeClip) {
- clipMin = chartRangeMin === void 0 ? -Infinity : chartRangeMin;
- clipMax = chartRangeMax === void 0 ? Infinity : chartRangeMax;
- }
- numValues = [];
- stackRanges = stacked ? [] : numValues;
- let stackTotals = [];
- let stackRangesNeg = [];
- for (i2 = 0, vlen = values.length; i2 < vlen; i2++) {
- if (stacked) {
- vlist = values[i2];
- values[i2] = svals = [];
- stackTotals[i2] = 0;
- stackRanges[i2] = stackRangesNeg[i2] = 0;
- for (j = 0, slen2 = vlist.length; j < slen2; j++) {
- val = svals[j] = chartRangeClip ? clipval(vlist[j], clipMin, clipMax) : vlist[j];
- if (val !== null) {
- if (val > 0) {
- stackTotals[i2] += val;
- }
- if (stackMin < 0 && stackMax > 0) {
- if (val < 0) {
- stackRangesNeg[i2] += Math.abs(val);
- } else {
- stackRanges[i2] += val;
- }
- } else {
- stackRanges[i2] += Math.abs(val);
- }
- numValues.push(val);
- }
- }
- } else {
- val = chartRangeClip ? clipval(values[i2], clipMin, clipMax) : values[i2];
- val = values[i2] = normalizeValue(val);
- if (val !== null) {
- numValues.push(val);
- }
- }
- }
- this.max = max = Math.max.apply(Math, numValues);
- this.min = min = Math.min.apply(Math, numValues);
- this.stackMax = stackMax = stacked ? Math.max.apply(Math, stackTotals) : max;
- this.stackMin = stackMin = stacked ? Math.min.apply(Math, numValues) : min;
- if (options.get("chartRangeMin") !== void 0 && (options.get("chartRangeClip") || options.get("chartRangeMin") < min)) {
- min = options.get("chartRangeMin");
- }
- if (options.get("chartRangeMax") !== void 0 && (options.get("chartRangeClip") || options.get("chartRangeMax") > max)) {
- max = options.get("chartRangeMax");
- }
- this.zeroAxis = zeroAxis = options.get("zeroAxis", true);
- if (min <= 0 && max >= 0 && zeroAxis) {
- xaxisOffset = 0;
- } else if (zeroAxis == false) {
- xaxisOffset = min;
- } else if (min > 0) {
- xaxisOffset = 0;
- } else {
- xaxisOffset = max;
- }
- this.xaxisOffset = xaxisOffset;
- range2 = stacked ? Math.max.apply(Math, stackRanges) + Math.max.apply(Math, stackRangesNeg) : max - xaxisOffset;
- this.canvasHeightEf = zeroAxis && min < 0 ? this.canvasHeight - 2 : this.canvasHeight - 1;
- this.isNeg = false;
- if (min < xaxisOffset) {
- yoffset = Math.floor(this.canvasHeight / 2);
- this.isNeg = true;
- if (yoffset !== Math.ceil(yoffset)) {
- this.canvasHeightEf -= 2;
- yoffset = Math.ceil(yoffset);
- }
- } else {
- yoffset = this.canvasHeight;
- }
- this.yoffset = yoffset;
- if ($.isArray(options.get("colorMap"))) {
- this.colorMapByIndex = options.get("colorMap");
- this.colorMapByValue = null;
- } else {
- this.colorMapByIndex = null;
- this.colorMapByValue = options.get("colorMap");
- if (this.colorMapByValue && this.colorMapByValue.get === void 0) {
- this.colorMapByValue = new RangeMap(this.colorMapByValue);
- }
- }
- this.range = range2;
- },
- getRegion: function(el, x, y) {
- let result = Math.floor(x / this.totalBarWidth);
- return result < 0 || result >= this.values.length ? void 0 : result;
- },
- getCurrentRegionFields: function() {
- let currentRegion = this.currentRegion, values = ensureArray(this.values[currentRegion]), result = [], value, i2;
- for (i2 = values.length; i2--; ) {
- value = values[i2];
- result.push({
- isNull: value === null,
- value,
- color: this.calcColor(i2, value, currentRegion),
- offset: currentRegion
- });
- }
- return result;
- },
- calcColor: function(stacknum, value, valuenum) {
- let colorMapByIndex = this.colorMapByIndex, colorMapByValue = this.colorMapByValue, options = this.options, color, newColor;
- if (this.stacked) {
- color = options.get("stackedBarColor");
- } else {
- color = value < 0 ? options.get("negBarColor") : options.get("barColor");
- }
- if (value === 0 && options.get("zeroColor") !== void 0) {
- color = options.get("zeroColor");
- }
- if (colorMapByValue && (newColor = colorMapByValue.get(value))) {
- color = newColor;
- } else if (colorMapByIndex && colorMapByIndex.length > valuenum) {
- color = colorMapByIndex[valuenum];
- }
- return $.isArray(color) ? color[stacknum % color.length] : color;
- },
- renderRegion: function(valuenum, highlight) {
- let vals = this.values[valuenum], options = this.options, xaxisOffset = this.xaxisOffset, result = [], range2 = this.range, stacked = this.stacked, target = this.target, x = valuenum * this.totalBarWidth, canvasHeightEf = this.canvasHeightEf, yoffset = this.yoffset, y, height, color, isNull, yoffsetNeg, i2, valcount, val, minPlotted, allMin;
- vals = $.isArray(vals) ? vals : [vals];
- valcount = vals.length;
- val = vals[0];
- isNull = all(null, vals);
- allMin = all(xaxisOffset, vals, true);
- if (isNull) {
- if (options.get("nullColor")) {
- color = highlight ? options.get("nullColor") : this.calcHighlightColor(options.get("nullColor"), options);
- y = yoffset > 0 ? yoffset - 1 : yoffset;
- return target.drawRect(x, y, this.barWidth - 1, 0, color, color);
- } else {
- return void 0;
- }
- }
- yoffsetNeg = yoffset;
- if (this.isNeg) {
- canvasHeightEf = Math.floor(canvasHeightEf / 2);
- }
- for (i2 = 0; i2 < valcount; i2++) {
- val = vals[i2];
- if (stacked && val === xaxisOffset) {
- if (!allMin || minPlotted) {
- continue;
- }
- minPlotted = true;
- }
- if (range2 > 0) {
- height = Math.floor(canvasHeightEf * (Math.abs(val - xaxisOffset) / range2));
- } else {
- height = canvasHeightEf;
- }
- if (val < xaxisOffset || val === xaxisOffset && yoffset === 0) {
- y = yoffsetNeg;
- yoffsetNeg += height;
- } else {
- y = yoffset - height;
- yoffset -= height;
- }
- color = this.calcColor(i2, val, valuenum);
- if (highlight) {
- color = this.calcHighlightColor(color, options);
- }
- result.push(target.drawRect(x, y, this.barWidth - 1, height - 1, color, color));
- }
- if (result.length === 1) {
- return result[0];
- }
- return result;
- }
- },
- tristate: {
- type: "tristate",
- init: function(el, values) {
- let options = this.options;
- let width = el.mergedOptions.width;
- let height = el.mergedOptions.height;
- this.canvasWidth = el.mergedOptions.width;
- this.canvasHeight = el.mergedOptions.height;
- let barWidth = parseInt(options.get("barWidth"), 10), barSpacing = parseInt(options.get("barSpacing"), 10);
- this.regionShapes = {};
- this.barWidth = barWidth;
- this.barSpacing = barSpacing;
- this.totalBarWidth = barWidth + barSpacing;
- this.values = $.map(values, Number);
- this.width = width = values.length * barWidth + (values.length - 1) * barSpacing;
- if ($.isArray(options.get("colorMap"))) {
- this.colorMapByIndex = options.get("colorMap");
- this.colorMapByValue = null;
- } else {
- this.colorMapByIndex = null;
- this.colorMapByValue = options.get("colorMap");
- if (this.colorMapByValue && this.colorMapByValue.get === void 0) {
- this.colorMapByValue = new RangeMap(this.colorMapByValue);
- }
- }
- },
- getRegion: function(el, x, y) {
- return Math.floor(x / this.totalBarWidth);
- },
- getCurrentRegionFields: function() {
- let currentRegion = this.currentRegion;
- return {
- isNull: this.values[currentRegion] === void 0,
- value: this.values[currentRegion],
- color: this.calcColor(this.values[currentRegion], currentRegion),
- offset: currentRegion
- };
- },
- calcColor: function(value, valuenum) {
- let values = this.values, options = this.options, colorMapByIndex = this.colorMapByIndex, colorMapByValue = this.colorMapByValue, color, newColor;
- if (colorMapByValue && (newColor = colorMapByValue.get(value))) {
- color = newColor;
- } else if (colorMapByIndex && colorMapByIndex.length > valuenum) {
- color = colorMapByIndex[valuenum];
- } else if (values[valuenum] < 0) {
- color = options.get("negBarColor");
- } else if (values[valuenum] > 0) {
- color = options.get("posBarColor");
- } else {
- color = options.get("zeroBarColor");
- }
- return color;
- },
- renderRegion: function(valuenum, highlight) {
- let values = this.values, options = this.options, target = this.target, canvasHeight, height, halfHeight, x, y, color;
- canvasHeight = this.canvasHeight;
- halfHeight = Math.round(canvasHeight / 2);
- x = valuenum * this.totalBarWidth;
- if (values[valuenum] < 0) {
- y = halfHeight;
- height = halfHeight - 1;
- } else if (values[valuenum] > 0) {
- y = 0;
- height = halfHeight - 1;
- } else {
- y = halfHeight - 1;
- height = 2;
- }
- color = this.calcColor(values[valuenum], valuenum);
- if (color === null) {
- return;
- }
- if (highlight) {
- color = this.calcHighlightColor(color, options);
- }
- return target.drawRect(x, y, this.barWidth - 1, height - 1, color, color);
- }
- },
- discrete: {
- type: "discrete",
- init: function(el, values) {
- let options = this.options;
- let width = el.mergedOptions.width;
- let height = el.mergedOptions.height;
- this.canvasWidth = el.mergedOptions.width;
- this.canvasHeight = el.mergedOptions.height;
- this.regionShapes = {};
- this.values = values = $.map(values, Number);
- this.min = Math.min.apply(Math, values);
- this.max = Math.max.apply(Math, values);
- this.range = this.max - this.min;
- this.width = width;
- this.interval = Math.floor(width / values.length);
- this.itemWidth = width / values.length;
- if (options.get("chartRangeMin") !== void 0 && (options.get("chartRangeClip") || options.get("chartRangeMin") < this.min)) {
- this.min = options.get("chartRangeMin");
- }
- if (options.get("chartRangeMax") !== void 0 && (options.get("chartRangeClip") || options.get("chartRangeMax") > this.max)) {
- this.max = options.get("chartRangeMax");
- }
- if (this.target) {
- this.lineHeight = options.get("lineHeight") === "auto" ? Math.round(this.canvasHeight * 0.3) : options.get("lineHeight");
- }
- },
- getRegion: function(el, x, y) {
- return Math.floor(x / this.itemWidth);
- },
- getCurrentRegionFields: function() {
- let currentRegion = this.currentRegion;
- return {
- isNull: this.values[currentRegion] === void 0,
- value: this.values[currentRegion],
- offset: currentRegion
- };
- },
- renderRegion: function(valuenum, highlight) {
- let values = this.values, options = this.options, min = this.min, max = this.max, range2 = this.range, interval = this.interval, target = this.target, canvasHeight = this.canvasHeight, lineHeight = this.lineHeight, pheight = canvasHeight - lineHeight, ytop, val, color, x;
- val = clipval(values[valuenum], min, max);
- x = valuenum * interval;
- ytop = Math.round(pheight - pheight * ((val - min) / range2));
- color = options.get("thresholdColor") && val < options.get("thresholdValue") ? options.get("thresholdColor") : options.get("lineColor");
- if (highlight) {
- color = this.calcHighlightColor(color, options);
- }
- return this.target.drawRect(x, ytop, interval <= 2 ? 1 : interval - 2, lineHeight, color, color);
- }
- },
- bullet: {
- type: "bullet",
- init: function(el, values) {
- let options = this.options;
- let width = el.mergedOptions.width;
- let height = el.mergedOptions.height;
- this.canvasWidth = el.mergedOptions.width;
- this.canvasHeight = el.mergedOptions.height;
- let min, max, vals;
- this.values = values = normalizeValues(values);
- vals = values.slice();
- vals[0] = vals[0] === null ? vals[2] : vals[0];
- vals[1] = values[1] === null ? vals[2] : vals[1];
- min = Math.min.apply(Math, values);
- max = Math.max.apply(Math, values);
- if (options.get("base") === void 0) {
- min = min < 0 ? min : 0;
- } else {
- min = options.get("base");
- }
- this.min = min;
- this.max = max;
- this.range = max - min;
- this.shapes = {};
- this.valueShapes = {};
- this.regiondata = {};
- this.width = width;
- if (!values.length) {
- this.disabled = true;
- }
- },
- getRegion: function(el, x, y) {
- let shapeid = this.target.getShapeAt(el, x, y);
- return shapeid !== void 0 && this.shapes[shapeid] !== void 0 ? this.shapes[shapeid] : void 0;
- },
- getCurrentRegionFields: function() {
- let currentRegion = this.currentRegion;
- return {
- fieldkey: currentRegion.substr(0, 1),
- value: this.values[currentRegion.substr(1)],
- region: currentRegion
- };
- },
- changeHighlight: function(highlight) {
- let currentRegion = this.currentRegion, shapeid = this.valueShapes[currentRegion], shape;
- delete this.shapes[shapeid];
- switch (currentRegion.substr(0, 1)) {
- case "r":
- shape = this.renderRange(currentRegion.substr(1), highlight);
- break;
- case "p":
- shape = this.renderPerformance(highlight);
- break;
- case "t":
- shape = this.renderTarget(highlight);
- break;
- }
- this.valueShapes[currentRegion] = shape.id;
- this.shapes[shape.id] = currentRegion;
- this.target.replaceWithShape(shapeid, shape);
- },
- renderRange: function(rn, highlight) {
- let rangeval = this.values[rn], rangewidth = Math.round(this.canvasWidth * ((rangeval - this.min) / this.range)), color = this.options.get("rangeColors")[rn - 2];
- if (highlight) {
- color = this.calcHighlightColor(color, this.options);
- }
- return this.target.drawRect(0, 0, rangewidth - 1, this.canvasHeight - 1, color, color);
- },
- renderPerformance: function(highlight) {
- let perfval = this.values[1], perfwidth = Math.round(this.canvasWidth * ((perfval - this.min) / this.range)), color = this.options.get("performanceColor");
- if (highlight) {
- color = this.calcHighlightColor(color, this.options);
- }
- return this.target.drawRect(0, Math.round(this.canvasHeight * 0.3), perfwidth - 1, Math.round(this.canvasHeight * 0.4) - 1, color, color);
- },
- renderTarget: function(highlight) {
- let targetval = this.values[0], x = Math.round(this.canvasWidth * ((targetval - this.min) / this.range) - this.options.get("targetWidth") / 2), targettop = Math.round(this.canvasHeight * 0.1), targetheight = this.canvasHeight - targettop * 2, color = this.options.get("targetColor");
- if (highlight) {
- color = this.calcHighlightColor(color, this.options);
- }
- return this.target.drawRect(x, targettop, this.options.get("targetWidth") - 1, targetheight - 1, color, color);
- },
- render: function(el, userValues) {
- this.init(el, userValues);
- let vlen = this.values.length, target = this.target, i2, shape;
- for (i2 = 2; i2 < vlen; i2++) {
- shape = this.renderRange(i2).append();
- this.shapes[shape.id] = "r" + i2;
- this.valueShapes["r" + i2] = shape.id;
- }
- if (this.values[1] !== null) {
- shape = this.renderPerformance().append();
- this.shapes[shape.id] = "p1";
- this.valueShapes.p1 = shape.id;
- }
- if (this.values[0] !== null) {
- shape = this.renderTarget().append();
- this.shapes[shape.id] = "t0";
- this.valueShapes.t0 = shape.id;
- }
- }
- },
- pie: {
- type: "pie",
- init: function(el, values) {
- let options = this.options;
- let width = el.mergedOptions.width;
- let height = el.mergedOptions.height;
- this.canvasWidth = el.mergedOptions.width;
- this.canvasHeight = el.mergedOptions.height;
- let total = 0, i2;
- this.shapes = {};
- this.valueShapes = {};
- this.values = values = $.map(values, Number);
- if (options.get("width") === "auto") {
- this.width = this.height;
- }
- if (values.length > 0) {
- for (i2 = values.length; i2--; ) {
- total += values[i2];
- }
- }
- this.total = total;
- this.radius = Math.floor(Math.min(this.canvasWidth, this.canvasHeight) / 2);
- },
- getRegion: function(el, x, y) {
- let shapeid = this.target.getShapeAt(el, x, y);
- return shapeid !== void 0 && this.shapes[shapeid] !== void 0 ? this.shapes[shapeid] : void 0;
- },
- getCurrentRegionFields: function() {
- let currentRegion = this.currentRegion;
- return {
- isNull: this.values[currentRegion] === void 0,
- value: this.values[currentRegion],
- percent: this.values[currentRegion] / this.total * 100,
- color: this.options.get("sliceColors")[currentRegion % this.options.get("sliceColors").length],
- offset: currentRegion
- };
- },
- changeHighlight: function(highlight) {
- let currentRegion = this.currentRegion, newslice = this.renderSlice(currentRegion, highlight), shapeid = this.valueShapes[currentRegion];
- delete this.shapes[shapeid];
- this.target.replaceWithShape(shapeid, newslice);
- this.valueShapes[currentRegion] = newslice.id;
- this.shapes[newslice.id] = currentRegion;
- },
- renderSlice: function(valuenum, highlight) {
- let target = this.target, options = this.options, radius = this.radius, borderWidth = options.get("borderWidth"), offset = options.get("offset"), circle = 2 * Math.PI, values = this.values, total = this.total, next = offset ? 2 * Math.PI * (offset / 360) : 0, start, end, i2, vlen, color;
- vlen = values.length;
- for (i2 = 0; i2 < vlen; i2++) {
- start = next;
- end = next;
- if (total > 0) {
- end = next + circle * (values[i2] / total);
- }
- if (valuenum === i2) {
- color = options.get("sliceColors")[i2 % options.get("sliceColors").length];
- if (highlight) {
- color = this.calcHighlightColor(color, options);
- }
- return target.drawPieSlice(radius, radius, radius - borderWidth, start, end, void 0, color);
- }
- next = end;
- }
- },
- render: function(el, userValues) {
- this.init(el, userValues);
- let target = this.target, values = this.values, options = this.options, radius = this.radius, borderWidth = options.get("borderWidth"), shape, i2;
- if (borderWidth) {
- target.drawCircle(radius, radius, Math.floor(radius - borderWidth / 2), options.get("borderColor"), void 0, borderWidth).append();
- }
- for (i2 = values.length; i2--; ) {
- if (values[i2]) {
- shape = this.renderSlice(i2).append();
- this.valueShapes[i2] = shape.id;
- this.shapes[shape.id] = i2;
- }
- }
- }
- },
- box: {
- type: "box",
- init: function(el, values) {
- let options = this.options;
- let width = el.mergedOptions.width;
- let height = el.mergedOptions.height;
- this.canvasWidth = el.mergedOptions.width;
- this.canvasHeight = el.mergedOptions.height;
- this.values = $.map(values, Number);
- this.width = options.get("width") === "auto" ? "4.0em" : width;
- if (!this.values.length) {
- this.disabled = 1;
- }
- },
- getRegion: function() {
- return 1;
- },
- getCurrentRegionFields: function() {
- let result = [
- {field: "lq", value: this.quartiles[0]},
- {field: "med", value: this.quartiles[1]},
- {field: "uq", value: this.quartiles[2]}
- ];
- if (this.loutlier !== void 0) {
- result.push({field: "lo", value: this.loutlier});
- }
- if (this.routlier !== void 0) {
- result.push({field: "ro", value: this.routlier});
- }
- if (this.lwhisker !== void 0) {
- result.push({field: "lw", value: this.lwhisker});
- }
- if (this.rwhisker !== void 0) {
- result.push({field: "rw", value: this.rwhisker});
- }
- return result;
- },
- render: function(el, userValues) {
- this.init(el, userValues);
- let target = this.target, values = this.values, vlen = values.length, options = this.options, canvasWidth = this.canvasWidth, canvasHeight = this.canvasHeight, minValue = options.get("chartRangeMin") === void 0 ? Math.min.apply(Math, values) : options.get("chartRangeMin"), maxValue = options.get("chartRangeMax") === void 0 ? Math.max.apply(Math, values) : options.get("chartRangeMax"), canvasLeft = 0, lwhisker, loutlier, iqr, q1, q2, q3, rwhisker, routlier, i2, size, unitSize;
- if (options.get("raw")) {
- if (options.get("showOutliers") && values.length > 5) {
- loutlier = values[0];
- lwhisker = values[1];
- q1 = values[2];
- q2 = values[3];
- q3 = values[4];
- rwhisker = values[5];
- routlier = values[6];
- } else {
- lwhisker = values[0];
- q1 = values[1];
- q2 = values[2];
- q3 = values[3];
- rwhisker = values[4];
- }
- } else {
- values.sort(function(a, b) {
- return a - b;
- });
- q1 = quartile(values, 1);
- q2 = quartile(values, 2);
- q3 = quartile(values, 3);
- iqr = q3 - q1;
- if (options.get("showOutliers")) {
- lwhisker = rwhisker = void 0;
- for (i2 = 0; i2 < vlen; i2++) {
- if (lwhisker === void 0 && values[i2] > q1 - iqr * options.get("outlierIQR")) {
- lwhisker = values[i2];
- }
- if (values[i2] < q3 + iqr * options.get("outlierIQR")) {
- rwhisker = values[i2];
- }
- }
- loutlier = values[0];
- routlier = values[vlen - 1];
- } else {
- lwhisker = values[0];
- rwhisker = values[vlen - 1];
- }
- }
- this.quartiles = [q1, q2, q3];
- this.lwhisker = lwhisker;
- this.rwhisker = rwhisker;
- this.loutlier = loutlier;
- this.routlier = routlier;
- unitSize = canvasWidth / (maxValue - minValue + 1);
- if (options.get("showOutliers")) {
- canvasLeft = Math.ceil(options.get("spotRadius"));
- canvasWidth -= 2 * Math.ceil(options.get("spotRadius"));
- unitSize = canvasWidth / (maxValue - minValue + 1);
- if (loutlier < lwhisker) {
- target.drawCircle((loutlier - minValue) * unitSize + canvasLeft, canvasHeight / 2, options.get("spotRadius"), options.get("outlierLineColor"), options.get("outlierFillColor")).append();
- }
- if (routlier > rwhisker) {
- target.drawCircle((routlier - minValue) * unitSize + canvasLeft, canvasHeight / 2, options.get("spotRadius"), options.get("outlierLineColor"), options.get("outlierFillColor")).append();
- }
- }
- target.drawRect(Math.round((q1 - minValue) * unitSize + canvasLeft), Math.round(canvasHeight * 0.1), Math.round((q3 - q1) * unitSize), Math.round(canvasHeight * 0.8), options.get("boxLineColor"), options.get("boxFillColor")).append();
- target.drawLine(Math.round((lwhisker - minValue) * unitSize + canvasLeft), Math.round(canvasHeight / 2), Math.round((q1 - minValue) * unitSize + canvasLeft), Math.round(canvasHeight / 2), options.get("lineColor")).append();
- target.drawLine(Math.round((lwhisker - minValue) * unitSize + canvasLeft), Math.round(canvasHeight / 4), Math.round((lwhisker - minValue) * unitSize + canvasLeft), Math.round(canvasHeight - canvasHeight / 4), options.get("whiskerColor")).append();
- target.drawLine(Math.round((rwhisker - minValue) * unitSize + canvasLeft), Math.round(canvasHeight / 2), Math.round((q3 - minValue) * unitSize + canvasLeft), Math.round(canvasHeight / 2), options.get("lineColor")).append();
- target.drawLine(Math.round((rwhisker - minValue) * unitSize + canvasLeft), Math.round(canvasHeight / 4), Math.round((rwhisker - minValue) * unitSize + canvasLeft), Math.round(canvasHeight - canvasHeight / 4), options.get("whiskerColor")).append();
- target.drawLine(Math.round((q2 - minValue) * unitSize + canvasLeft), Math.round(canvasHeight * 0.1), Math.round((q2 - minValue) * unitSize + canvasLeft), Math.round(canvasHeight * 0.9), options.get("medianColor")).append();
- if (options.get("target")) {
- size = Math.ceil(options.get("spotRadius"));
- target.drawLine(Math.round((options.get("target") - minValue) * unitSize + canvasLeft), Math.round(canvasHeight / 2 - size), Math.round((options.get("target") - minValue) * unitSize + canvasLeft), Math.round(canvasHeight / 2 + size), options.get("targetColor")).append();
- target.drawLine(Math.round((options.get("target") - minValue) * unitSize + canvasLeft - size), Math.round(canvasHeight / 2), Math.round((options.get("target") - minValue) * unitSize + canvasLeft + size), Math.round(canvasHeight / 2), options.get("targetColor")).append();
- }
- }
- },
- shapeCount: 0,
- shapes: {},
- shapeseq: [],
- lastShapeId: null,
- mergedOptions: null,
- init: function(userValues, userOptions) {
- let extendedOptions, defaults2, base;
- userOptions = userOptions || {};
- let _this2 = this;
- defaults2 = this.defaultOption;
- base = defaults2.common;
- extendedOptions = defaults2[userOptions.type || base.type];
- _this2.shapeCount = 0;
- _this2.shapes = {};
- _this2.shapeseq = [];
- _this2.lastShapeId = null;
- _this2.mergedOptions = $.extend({}, base, extendedOptions, userOptions);
- _this2.mergedOptions.width = _this2.mergedOptions.width;
- _this2.mergedOptions.height = _this2.mergedOptions.height;
- _this2[_this2.mergedOptions.type].render(_this2, userValues);
- return {shapes: _this2.shapes, shapeseq: _this2.shapeseq, offsetX: _this2.mergedOptions.offsetX, offsetY: _this2.mergedOptions.offsetY, pixelWidth: _this2.mergedOptions.width, pixelHeight: _this2.mergedOptions.height};
- },
- _getContext: function(lineColor, fillColor, lineWidth) {
- let context;
- if (this.ctx != null) {
- context = this.ctx;
- } else {
- context = $("#" + this._canvasID).get(0).getContext("2d");
- }
- if (lineColor !== void 0) {
- context.strokeStyle = lineColor;
- }
- context.lineWidth = lineWidth === void 0 ? 1 : lineWidth;
- if (fillColor !== void 0) {
- context.fillStyle = fillColor;
- }
- return context;
- },
- reset: function() {
- let context = this._getContext();
- context.clearRect(0, 0, this.pixelWidth, this.pixelHeight);
- this.shapes = {};
- this.shapeseq = [];
- this.currentTargetShapeId = void 0;
- },
- _drawShape: function(shapeid, path, lineColor, fillColor, lineWidth) {
- let context = this._getContext(lineColor, fillColor, lineWidth), i2, plen;
- context.beginPath();
- context.moveTo(path[0][0] + 0.5 + this.offsetX, path[0][1] + 0.5 + this.offsetY);
- for (i2 = 1, plen = path.length; i2 < plen; i2++) {
- context.lineTo(path[i2][0] + 0.5 + this.offsetX, path[i2][1] + 0.5 + this.offsetY);
- }
- if (lineColor !== void 0) {
- context.stroke();
- }
- if (fillColor !== void 0) {
- context.fill();
- }
- if (this.targetX !== void 0 && this.targetY !== void 0 && context.isPointInPath(this.targetX + this.offsetX, this.targetY + this.offsetY)) {
- this.currentTargetShapeId = shapeid;
- }
- },
- _drawCircle: function(shapeid, x, y, radius, lineColor, fillColor, lineWidth) {
- let context = this._getContext(lineColor, fillColor, lineWidth);
- context.beginPath();
- x += this.offsetX;
- y += this.offsetY;
- context.arc(x, y, radius, 0, 2 * Math.PI, false);
- if (this.targetX !== void 0 && this.targetY !== void 0 && context.isPointInPath(this.targetX + this.offsetX, this.targetY + this.offsetY)) {
- this.currentTargetShapeId = shapeid;
- }
- if (lineColor !== void 0) {
- context.stroke();
- }
- if (fillColor !== void 0) {
- context.fill();
- }
- },
- _drawPieSlice: function(shapeid, x, y, radius, startAngle, endAngle, lineColor, fillColor) {
- let context = this._getContext(lineColor, fillColor);
- x += this.offsetX;
- y += this.offsetY;
- context.beginPath();
- context.moveTo(x, y);
- context.arc(x, y, radius, startAngle, endAngle, false);
- context.lineTo(x, y);
- context.closePath();
- if (lineColor !== void 0) {
- context.stroke();
- }
- if (fillColor) {
- context.fill();
- }
- if (this.targetX !== void 0 && this.targetY !== void 0 && context.isPointInPath(this.targetX + this.offsetX, this.targetY + this.offsetY)) {
- this.currentTargetShapeId = shapeid;
- }
- },
- _drawRect: function(shapeid, x, y, width, height, lineColor, fillColor) {
- return this._drawShape(shapeid, [[x, y], [x + width, y], [x + width, y + height], [x, y + height], [x, y]], lineColor, fillColor);
- },
- appendShape: function(shape) {
- this.shapes[shape.id] = shape;
- this.shapeseq.push(shape.id);
- this.lastShapeId = shape.id;
- return shape.id;
- },
- replaceWithShape: function(shapeid, shape) {
- let shapeseq = this.shapeseq, i2;
- this.shapes[shape.id] = shape;
- for (i2 = shapeseq.length; i2--; ) {
- if (shapeseq[i2] == shapeid) {
- shapeseq[i2] = shape.id;
- }
- }
- delete this.shapes[shapeid];
- },
- replaceWithShapes: function(shapeids, shapes) {
- let shapeseq = this.shapeseq, shapemap = {}, sid, i2, first;
- for (i2 = shapeids.length; i2--; ) {
- shapemap[shapeids[i2]] = true;
- }
- for (i2 = shapeseq.length; i2--; ) {
- sid = shapeseq[i2];
- if (shapemap[sid]) {
- shapeseq.splice(i2, 1);
- delete this.shapes[sid];
- first = i2;
- }
- }
- for (i2 = shapes.length; i2--; ) {
- shapeseq.splice(first, 0, shapes[i2].id);
- this.shapes[shapes[i2].id] = shapes[i2];
- }
- },
- insertAfterShape: function(shapeid, shape) {
- let shapeseq = this.shapeseq, i2;
- for (i2 = shapeseq.length; i2--; ) {
- if (shapeseq[i2] === shapeid) {
- shapeseq.splice(i2 + 1, 0, shape.id);
- this.shapes[shape.id] = shape;
- return;
- }
- }
- },
- removeShapeId: function(shapeid) {
- let shapeseq = this.shapeseq, i2;
- for (i2 = shapeseq.length; i2--; ) {
- if (shapeseq[i2] === shapeid) {
- shapeseq.splice(i2, 1);
- break;
- }
- }
- delete this.shapes[shapeid];
- },
- getShapeAt: function(el, x, y) {
- this.targetX = x;
- this.targetY = y;
- this.render();
- return this.currentTargetShapeId;
- },
- _canvasID: "luckysheetTableContent",
- render: function(shapeseq, shapes, offsetX, offsetY, pixelWidth, pixelHeight, canvasid, ctx) {
- if (canvasid == null) {
- canvasid = "luckysheetTableContent";
- }
- this._canvasID = canvasid;
- if (ctx != null) {
- this.ctx = ctx;
- }
- let shapeCount = shapeseq.length, context = this._getContext(), shapeid, shape, i2;
- this.offsetX = offsetX;
- this.offsetY = offsetY;
- this.pixelWidth = pixelWidth;
- this.pixelHeight = pixelHeight;
- for (i2 = 0; i2 < shapeCount; i2++) {
- shapeid = shapeseq[i2];
- shape = shapes[shapeid];
- this["_draw" + shape.type].apply(this, shape.args);
- }
- },
- drawLine: function(x1, y1, x2, y2, lineColor, lineWidth) {
- return this.drawShape([[x1, y1], [x2, y2]], lineColor, lineWidth);
- },
- drawShape: function(path, lineColor, fillColor, lineWidth) {
- return this._genShape("Shape", [path, lineColor, fillColor, lineWidth]);
- },
- drawCircle: function(x, y, radius, lineColor, fillColor, lineWidth) {
- return this._genShape("Circle", [x, y, radius, lineColor, fillColor, lineWidth]);
- },
- drawPieSlice: function(x, y, radius, startAngle, endAngle, lineColor, fillColor) {
- return this._genShape("PieSlice", [x, y, radius, startAngle, endAngle, lineColor, fillColor]);
- },
- drawRect: function(x, y, width, height, lineColor, fillColor) {
- return this._genShape("Rect", [x, y, width, height, lineColor, fillColor]);
- },
- _genShape: function(shapetype, shapeargs) {
- let id = this.shapeCount++;
- shapeargs.unshift(id);
- let shape = {id, type: shapetype, args: shapeargs};
- this.shapes[id] = shape;
- this.shapeseq.push(id);
- this.lastShapeId = id;
- return {
- append: function() {
- return shape;
- },
- get: function() {
- return id;
- }
- };
- }
- };
- barHighlightMixin = {
- changeHighlight: function(highlight) {
- let currentRegion = this.currentRegion, target = this.target, shapeids = this.regionShapes[currentRegion], newShapes;
- if (shapeids) {
- newShapes = this.renderRegion(currentRegion, highlight);
- if ($.isArray(newShapes) || $.isArray(shapeids)) {
- target.replaceWithShapes(shapeids, newShapes);
- this.regionShapes[currentRegion] = $.map(newShapes, function(newShape) {
- return newShape.id;
- });
- } else {
- target.replaceWithShape(shapeids, newShapes);
- this.regionShapes[currentRegion] = newShapes.id;
- }
- }
- },
- render: function(el, userValues) {
- this.init(el, userValues);
- let values = this.values, target = this.target, regionShapes = this.regionShapes, shapes, ids, i2, j;
- for (i2 = values.length; i2--; ) {
- shapes = this.renderRegion(i2);
- if (shapes) {
- if ($.isArray(shapes)) {
- ids = [];
- for (j = shapes.length; j--; ) {
- shapes[j].append();
- ids.push(shapes[j].id);
- }
- regionShapes[i2] = ids;
- } else {
- shapes.append();
- regionShapes[i2] = shapes.id;
- }
- } else {
- regionShapes[i2] = null;
- }
- }
- }
- };
- _luckysheetSparkLineOptions = {
- get: function(type) {
- return luckysheetSparkline.mergedOptions[type];
- }
- };
- _luckysheetSparkLineTarget = {
- drawLine: function(x1, y1, x2, y2, lineColor, lineWidth) {
- return luckysheetSparkline.drawLine(x1, y1, x2, y2, lineColor, lineWidth);
- },
- drawShape: function(path, lineColor, fillColor, lineWidth) {
- return luckysheetSparkline.drawShape(path, lineColor, fillColor, lineWidth);
- },
- drawCircle: function(x, y, radius, lineColor, fillColor, lineWidth) {
- return luckysheetSparkline.drawCircle(x, y, radius, lineColor, fillColor, lineWidth);
- },
- drawPieSlice: function(x, y, radius, startAngle, endAngle, lineColor, fillColor) {
- return luckysheetSparkline.drawPieSlice(x, y, radius, startAngle, endAngle, lineColor, fillColor);
- },
- drawRect: function(x, y, width, height, lineColor, fillColor) {
- return luckysheetSparkline.drawRect(x, y, width, height, lineColor, fillColor);
- }
- };
- for (let item2 in luckysheetSparkline) {
- if (item2 in {"line": null, "bar": null, "column": null, "tristate": null, "discrete": null, "bullet": null, "pie": null, "box": null}) {
- luckysheetSparkline[item2].options = _luckysheetSparkLineOptions;
- luckysheetSparkline[item2].target = _luckysheetSparkLineTarget;
- }
- if (item2 in {"bar": null, "column": null, "tristate": null, "discrete": null}) {
- luckysheetSparkline[item2].changeHighlight = barHighlightMixin.changeHighlight;
- luckysheetSparkline[item2].render = barHighlightMixin.render;
- }
- }
- sparkline_default = luckysheetSparkline;
- }
- });
-
- // src/global/draw.js
- function luckysheetDrawgridRowTitle(scrollHeight, drawHeight, offsetTop) {
- if (scrollHeight == null) {
- scrollHeight = $("#luckysheet-cell-main").scrollTop();
- }
- if (drawHeight == null) {
- drawHeight = store_default.luckysheetTableContentHW[1];
- }
- if (offsetTop == null) {
- offsetTop = store_default.columnHeaderHeight;
- }
- let luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d");
- luckysheetTableContent.save();
- luckysheetTableContent.scale(store_default.devicePixelRatio, store_default.devicePixelRatio);
- luckysheetTableContent.clearRect(0, offsetTop, store_default.rowHeaderWidth - 1, drawHeight);
- luckysheetTableContent.font = luckysheetdefaultFont();
- luckysheetTableContent.textBaseline = luckysheetdefaultstyle.textBaseline;
- luckysheetTableContent.fillStyle = luckysheetdefaultstyle.fillStyle;
- let dataset_row_st, dataset_row_ed;
- dataset_row_st = luckysheet_searcharray(store_default.visibledatarow, scrollHeight);
- dataset_row_ed = luckysheet_searcharray(store_default.visibledatarow, scrollHeight + drawHeight);
- if (dataset_row_st == -1) {
- dataset_row_st = 0;
- }
- if (dataset_row_ed == -1) {
- dataset_row_ed = store_default.visibledatarow.length - 1;
- }
- luckysheetTableContent.save();
- luckysheetTableContent.beginPath();
- luckysheetTableContent.rect(0, offsetTop - 1, store_default.rowHeaderWidth - 1, drawHeight - 2);
- luckysheetTableContent.clip();
- let end_r, start_r;
- let bodrder05 = 0.5;
- let preEndR;
- for (let r2 = dataset_row_st; r2 <= dataset_row_ed; r2++) {
- if (r2 == 0) {
- start_r = -scrollHeight - 1;
- } else {
- start_r = store_default.visibledatarow[r2 - 1] - scrollHeight - 1;
- }
- end_r = store_default.visibledatarow[r2] - scrollHeight;
- let firstOffset = dataset_row_st == r2 ? -2 : 0;
- let lastOffset = dataset_row_ed == r2 ? -2 : 0;
- if (!method_default.createHookFunction("rowTitleCellRenderBefore", r2 + 1, {
- r: r2,
- top: start_r + offsetTop + firstOffset,
- width: store_default.rowHeaderWidth - 1,
- height: end_r - start_r + 1 + lastOffset - firstOffset
- }, luckysheetTableContent)) {
- continue;
- }
- if (store_default.config["rowhidden"] != null && store_default.config["rowhidden"][r2] != null) {
- } else {
- luckysheetTableContent.fillStyle = "#ffffff";
- luckysheetTableContent.fillRect(0, start_r + offsetTop + firstOffset, store_default.rowHeaderWidth - 1, end_r - start_r + 1 + lastOffset - firstOffset);
- luckysheetTableContent.fillStyle = "#000000";
- luckysheetTableContent.save();
- luckysheetTableContent.scale(store_default.zoomRatio, store_default.zoomRatio);
- let textMetrics = getMeasureText(r2 + 1, luckysheetTableContent);
- let horizonAlignPos = (store_default.rowHeaderWidth - textMetrics.width) / 2;
- let verticalAlignPos = start_r + (end_r - start_r) / 2 + offsetTop;
- luckysheetTableContent.fillText(r2 + 1, horizonAlignPos / store_default.zoomRatio, verticalAlignPos / store_default.zoomRatio);
- luckysheetTableContent.restore();
- }
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(store_default.rowHeaderWidth - 2 + bodrder05, start_r + offsetTop - 2);
- luckysheetTableContent.lineTo(store_default.rowHeaderWidth - 2 + bodrder05, end_r + offsetTop - 2);
- luckysheetTableContent.lineWidth = 1;
- luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
- luckysheetTableContent.stroke();
- luckysheetTableContent.closePath();
- if (store_default.config["rowhidden"] != null && store_default.config["rowhidden"][r2] == null && store_default.config["rowhidden"][r2 + 1] != null) {
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(-1, end_r + offsetTop - 4 + bodrder05);
- luckysheetTableContent.lineTo(store_default.rowHeaderWidth - 1, end_r + offsetTop - 4 + bodrder05);
- luckysheetTableContent.closePath();
- luckysheetTableContent.stroke();
- } else if (store_default.config["rowhidden"] == null || store_default.config["rowhidden"][r2] == null) {
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(-1, end_r + offsetTop - 2 + bodrder05);
- luckysheetTableContent.lineTo(store_default.rowHeaderWidth - 1, end_r + offsetTop - 2 + bodrder05);
- luckysheetTableContent.closePath();
- luckysheetTableContent.stroke();
- }
- if (store_default.config["rowhidden"] != null && store_default.config["rowhidden"][r2 - 1] != null && preEndR != null) {
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(-1, preEndR + offsetTop + bodrder05);
- luckysheetTableContent.lineTo(store_default.rowHeaderWidth - 1, preEndR + offsetTop + bodrder05);
- luckysheetTableContent.closePath();
- luckysheetTableContent.stroke();
- }
- preEndR = end_r;
- method_default.createHookFunction("rowTitleCellRenderAfter", r2 + 1, {
- r: r2,
- top: start_r + offsetTop + firstOffset,
- width: store_default.rowHeaderWidth - 1,
- height: end_r - start_r + 1 + lastOffset - firstOffset
- }, luckysheetTableContent);
- }
- luckysheetTableContent.restore();
- luckysheetTableContent.restore();
- }
- function luckysheetDrawgridColumnTitle(scrollWidth, drawWidth, offsetLeft) {
- if (scrollWidth == null) {
- scrollWidth = $("#luckysheet-cell-main").scrollLeft();
- }
- if (drawWidth == null) {
- drawWidth = store_default.luckysheetTableContentHW[0];
- }
- if (offsetLeft == null) {
- offsetLeft = store_default.rowHeaderWidth;
- }
- let luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d");
- luckysheetTableContent.save();
- luckysheetTableContent.scale(store_default.devicePixelRatio, store_default.devicePixelRatio);
- luckysheetTableContent.clearRect(offsetLeft, 0, drawWidth, store_default.columnHeaderHeight - 1);
- luckysheetTableContent.font = luckysheetdefaultFont();
- luckysheetTableContent.textBaseline = luckysheetdefaultstyle.textBaseline;
- luckysheetTableContent.fillStyle = luckysheetdefaultstyle.fillStyle;
- let dataset_col_st, dataset_col_ed;
- dataset_col_st = luckysheet_searcharray(store_default.visibledatacolumn, scrollWidth);
- dataset_col_ed = luckysheet_searcharray(store_default.visibledatacolumn, scrollWidth + drawWidth);
- if (dataset_col_st == -1) {
- dataset_col_st = 0;
- }
- if (dataset_col_ed == -1) {
- dataset_col_ed = store_default.visibledatacolumn.length - 1;
- }
- luckysheetTableContent.save();
- luckysheetTableContent.beginPath();
- luckysheetTableContent.rect(offsetLeft - 1, 0, drawWidth, store_default.columnHeaderHeight - 1);
- luckysheetTableContent.clip();
- let end_c, start_c;
- let bodrder05 = 0.5;
- let preEndC;
- for (let c2 = dataset_col_st; c2 <= dataset_col_ed; c2++) {
- if (c2 == 0) {
- start_c = -scrollWidth;
- } else {
- start_c = store_default.visibledatacolumn[c2 - 1] - scrollWidth;
- }
- end_c = store_default.visibledatacolumn[c2] - scrollWidth;
- let abc = chatatABC(c2);
- if (!method_default.createHookFunction("columnTitleCellRenderBefore", abc, {
- c: c2,
- left: start_c + offsetLeft - 1,
- width: end_c - start_c,
- height: store_default.columnHeaderHeight - 1
- }, luckysheetTableContent)) {
- continue;
- }
- if (store_default.config["colhidden"] != null && store_default.config["colhidden"][c2] != null) {
- } else {
- luckysheetTableContent.fillStyle = "#ffffff";
- luckysheetTableContent.fillRect(start_c + offsetLeft - 1, 0, end_c - start_c, store_default.columnHeaderHeight - 1);
- luckysheetTableContent.fillStyle = "#000000";
- luckysheetTableContent.save();
- luckysheetTableContent.scale(store_default.zoomRatio, store_default.zoomRatio);
- let textMetrics = getMeasureText(abc, luckysheetTableContent);
- let horizonAlignPos = Math.round(start_c + (end_c - start_c) / 2 + offsetLeft - textMetrics.width / 2);
- let verticalAlignPos = Math.round(store_default.columnHeaderHeight / 2);
- luckysheetTableContent.fillText(abc, horizonAlignPos / store_default.zoomRatio, verticalAlignPos / store_default.zoomRatio);
- luckysheetTableContent.restore();
- }
- if (store_default.config["colhidden"] != null && store_default.config["colhidden"][c2] == null && store_default.config["colhidden"][c2 + 1] != null) {
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(end_c + offsetLeft - 4 + bodrder05, 0);
- luckysheetTableContent.lineTo(end_c + offsetLeft - 4 + bodrder05, store_default.columnHeaderHeight - 2);
- luckysheetTableContent.lineWidth = 1;
- luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
- luckysheetTableContent.closePath();
- luckysheetTableContent.stroke();
- } else if (store_default.config["colhidden"] == null || store_default.config["colhidden"][c2] == null) {
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(end_c + offsetLeft - 2 + bodrder05, 0);
- luckysheetTableContent.lineTo(end_c + offsetLeft - 2 + bodrder05, store_default.columnHeaderHeight - 2);
- luckysheetTableContent.lineWidth = 1;
- luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
- luckysheetTableContent.closePath();
- luckysheetTableContent.stroke();
- }
- if (store_default.config["colhidden"] != null && store_default.config["colhidden"][c2 - 1] != null && preEndC != null) {
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(preEndC + offsetLeft + bodrder05, 0);
- luckysheetTableContent.lineTo(preEndC + offsetLeft + bodrder05, store_default.columnHeaderHeight - 2);
- luckysheetTableContent.closePath();
- luckysheetTableContent.stroke();
- }
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(start_c + offsetLeft - 1, store_default.columnHeaderHeight - 2 + bodrder05);
- luckysheetTableContent.lineTo(end_c + offsetLeft - 1, store_default.columnHeaderHeight - 2 + bodrder05);
- luckysheetTableContent.stroke();
- luckysheetTableContent.closePath();
- preEndC = end_c;
- method_default.createHookFunction("columnTitleCellRenderAfter", abc, {
- c: c2,
- left: start_c + offsetLeft - 1,
- width: end_c - start_c,
- height: store_default.columnHeaderHeight - 1
- }, luckysheetTableContent);
- }
- luckysheetTableContent.restore();
- luckysheetTableContent.restore();
- }
- function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, offsetLeft, offsetTop, columnOffsetCell, rowOffsetCell, mycanvas) {
- if (store_default.flowdata == null) {
- return;
- }
- let sheetFile = sheetmanage_default.getSheetByIndex();
- clearTimeout(store_default.measureTextCacheTimeOut);
- if (scrollWidth == null) {
- scrollWidth = $("#luckysheet-cell-main").scrollLeft();
- }
- if (scrollHeight == null) {
- scrollHeight = $("#luckysheet-cell-main").scrollTop();
- }
- if (drawWidth == null) {
- drawWidth = store_default.luckysheetTableContentHW[0];
- }
- if (drawHeight == null) {
- drawHeight = store_default.luckysheetTableContentHW[1];
- }
- if (offsetLeft == null) {
- offsetLeft = store_default.rowHeaderWidth;
- }
- if (offsetTop == null) {
- offsetTop = store_default.columnHeaderHeight;
- }
- if (columnOffsetCell == null) {
- columnOffsetCell = 0;
- }
- if (rowOffsetCell == null) {
- rowOffsetCell = 0;
- }
- let luckysheetTableContent = null;
- if (mycanvas == null) {
- luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d");
- } else {
- if (getObjType(mycanvas) == "object") {
- try {
- luckysheetTableContent = mycanvas.get(0).getContext("2d");
- } catch (err) {
- luckysheetTableContent = mycanvas;
- }
- } else {
- luckysheetTableContent = $("#" + mycanvas).get(0).getContext("2d");
- }
- }
- luckysheetTableContent.save();
- luckysheetTableContent.scale(store_default.devicePixelRatio, store_default.devicePixelRatio);
- luckysheetTableContent.clearRect(0, 0, store_default.luckysheetTableContentHW[0], store_default.luckysheetTableContentHW[1]);
- let dataset_row_st, dataset_row_ed, dataset_col_st, dataset_col_ed;
- dataset_row_st = luckysheet_searcharray(store_default.visibledatarow, scrollHeight);
- dataset_row_ed = luckysheet_searcharray(store_default.visibledatarow, scrollHeight + drawHeight);
- if (dataset_row_st == -1) {
- dataset_row_st = 0;
- }
- dataset_row_st += rowOffsetCell;
- if (dataset_row_ed == -1) {
- dataset_row_ed = store_default.visibledatarow.length - 1;
- }
- dataset_row_ed += rowOffsetCell;
- if (dataset_row_ed >= store_default.visibledatarow.length) {
- dataset_row_ed = store_default.visibledatarow.length - 1;
- }
- dataset_col_st = luckysheet_searcharray(store_default.visibledatacolumn, scrollWidth);
- dataset_col_ed = luckysheet_searcharray(store_default.visibledatacolumn, scrollWidth + drawWidth);
- if (dataset_col_st == -1) {
- dataset_col_st = 0;
- }
- dataset_col_st += columnOffsetCell;
- if (dataset_col_ed == -1) {
- dataset_col_ed = store_default.visibledatacolumn.length - 1;
- }
- dataset_col_ed += columnOffsetCell;
- if (dataset_col_ed >= store_default.visibledatacolumn.length) {
- dataset_col_ed = store_default.visibledatacolumn.length - 1;
- }
- let fill_row_st, fill_row_ed, fill_col_st, fill_col_ed;
- if (dataset_row_st == 0) {
- fill_row_st = 0;
- } else {
- fill_row_st = store_default.visibledatarow[dataset_row_st - 1];
- }
- fill_row_ed = store_default.visibledatarow[dataset_row_ed];
- if (dataset_col_st == 0) {
- fill_col_st = 0;
- } else {
- fill_col_st = store_default.visibledatacolumn[dataset_col_st - 1];
- }
- fill_col_ed = store_default.visibledatacolumn[dataset_col_ed];
- luckysheetTableContent.fillStyle = "#ffffff";
- luckysheetTableContent.fillRect(offsetLeft - 1, offsetTop - 1, fill_col_ed - scrollWidth, fill_row_ed - scrollHeight);
- luckysheetTableContent.font = luckysheetdefaultFont();
- luckysheetTableContent.fillStyle = luckysheetdefaultstyle.fillStyle;
- let cellupdate = [];
- let mergeCache = {};
- let borderOffset = {};
- let bodrder05 = 0.5;
- method_default.createHookFunction("cellAllRenderBefore", store_default.flowdata, sheetFile, luckysheetTableContent);
- for (let r2 = dataset_row_st; r2 <= dataset_row_ed; r2++) {
- let start_r;
- if (r2 == 0) {
- start_r = -scrollHeight - 1;
- } else {
- start_r = store_default.visibledatarow[r2 - 1] - scrollHeight - 1;
- }
- let end_r = store_default.visibledatarow[r2] - scrollHeight;
- if (store_default.config["rowhidden"] != null && store_default.config["rowhidden"][r2] != null) {
- continue;
- }
- for (let c2 = dataset_col_st; c2 <= dataset_col_ed; c2++) {
- let start_c;
- if (c2 == 0) {
- start_c = -scrollWidth;
- } else {
- start_c = store_default.visibledatacolumn[c2 - 1] - scrollWidth;
- }
- let end_c = store_default.visibledatacolumn[c2] - scrollWidth;
- if (store_default.config["colhidden"] != null && store_default.config["colhidden"][c2] != null) {
- continue;
- }
- let firstcolumnlen = store_default.defaultcollen;
- if (store_default.config["columnlen"] != null && store_default.config["columnlen"][c2] != null) {
- firstcolumnlen = store_default.config["columnlen"][c2];
- }
- if (store_default.flowdata[r2] != null && store_default.flowdata[r2][c2] != null) {
- let value = store_default.flowdata[r2][c2];
- if (getObjType(value) == "object" && "mc" in value) {
- borderOffset[r2 + "_" + c2] = {
- start_r,
- start_c,
- end_r,
- end_c
- };
- if ("rs" in value["mc"]) {
- let key = "r" + r2 + "c" + c2;
- mergeCache[key] = cellupdate.length;
- } else {
- let key = "r" + value["mc"].r + "c" + value["mc"].c;
- let margeMain = cellupdate[mergeCache[key]];
- if (margeMain == null) {
- mergeCache[key] = cellupdate.length;
- cellupdate.push({
- r: r2,
- c: c2,
- start_c,
- start_r,
- end_r,
- end_c,
- firstcolumnlen
- });
- } else {
- if (margeMain.c == c2) {
- margeMain.end_r += end_r - start_r - 1;
- }
- if (margeMain.r == r2) {
- margeMain.end_c += end_c - start_c;
- margeMain.firstcolumnlen += firstcolumnlen;
- }
- }
- continue;
- }
- }
- } else {
- }
- cellupdate.push({
- r: r2,
- c: c2,
- start_r,
- start_c,
- end_r,
- end_c,
- firstcolumnlen
- });
- borderOffset[r2 + "_" + c2] = {
- start_r,
- start_c,
- end_r,
- end_c
- };
- }
- }
- let dynamicArray_compute = dynamicArrayCompute(store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)]["dynamicArray"]);
- let af_compute = alternateformat_default.getComputeMap();
- let cf_compute = conditionformat_default.getComputeMap();
- let cellOverflowMap = getCellOverflowMap(luckysheetTableContent, dataset_col_st, dataset_col_ed, dataset_row_st, dataset_row_ed);
- let mcArr = [];
- for (let cud = 0; cud < cellupdate.length; cud++) {
- let item2 = cellupdate[cud];
- let r2 = item2.r, c2 = item2.c, start_r = item2.start_r, start_c = item2.start_c, end_r = item2.end_r, end_c = item2.end_c;
- let firstcolumnlen = item2.firstcolumnlen;
- if (store_default.flowdata[r2] == null) {
- continue;
- }
- if (store_default.flowdata[r2][c2] == null) {
- nullCellRender(r2, c2, start_r, start_c, end_r, end_c, luckysheetTableContent, af_compute, cf_compute, offsetLeft, offsetTop, dynamicArray_compute, cellOverflowMap, dataset_col_st, dataset_col_ed, scrollHeight, scrollWidth, bodrder05);
- } else {
- let cell = store_default.flowdata[r2][c2];
- let value = null;
- if (typeof cell == "object" && "mc" in cell) {
- mcArr.push(cellupdate[cud]);
- } else {
- value = getRealCellValue(r2, c2);
- }
- if (value == null || value.toString().length == 0) {
- nullCellRender(r2, c2, start_r, start_c, end_r, end_c, luckysheetTableContent, af_compute, cf_compute, offsetLeft, offsetTop, dynamicArray_compute, cellOverflowMap, dataset_col_st, dataset_col_ed, scrollHeight, scrollWidth, bodrder05);
- let borderfix = menuButton_default.borderfix(store_default.flowdata, r2, c2);
- let cellsize = [
- start_c + offsetLeft + borderfix[0],
- start_r + offsetTop + borderfix[1],
- end_c - start_c - 3 + borderfix[2],
- end_r - start_r - 3 - 1 + borderfix[3]
- ];
- sparklinesRender(r2, c2, cellsize[0], cellsize[1], "luckysheetTableContent", luckysheetTableContent);
- } else {
- if (r2 + "_" + c2 in dynamicArray_compute) {
- value = dynamicArray_compute[r2 + "_" + c2].v;
- }
- cellRender(r2, c2, start_r, start_c, end_r, end_c, value, luckysheetTableContent, af_compute, cf_compute, offsetLeft, offsetTop, dynamicArray_compute, cellOverflowMap, dataset_col_st, dataset_col_ed, scrollHeight, scrollWidth, bodrder05);
- }
- }
- }
- for (let m = 0; m < mcArr.length; m++) {
- let item2 = mcArr[m];
- let r2 = item2.r, c2 = item2.c, start_r = item2.start_r, start_c = item2.start_c, end_r = item2.end_r - 1, end_c = item2.end_c - 1;
- let firstcolumnlen = item2.firstcolumnlen;
- let cell = store_default.flowdata[r2][c2];
- let value = null;
- let margeMaindata = cell["mc"];
- value = getRealCellValue(margeMaindata.r, margeMaindata.c);
- r2 = margeMaindata.r;
- c2 = margeMaindata.c;
- let mainCell = store_default.flowdata[r2][c2];
- if (c2 == 0) {
- start_c = -scrollWidth;
- } else {
- start_c = store_default.visibledatacolumn[c2 - 1] - scrollWidth;
- }
- if (r2 == 0) {
- start_r = -scrollHeight - 1;
- } else {
- start_r = store_default.visibledatarow[r2 - 1] - scrollHeight - 1;
- }
- end_r = store_default.visibledatarow[r2 + mainCell["mc"].rs - 1] - scrollHeight;
- end_c = store_default.visibledatacolumn[c2 + mainCell["mc"].cs - 1] - scrollWidth;
- if (value == null || value.toString().length == 0) {
- nullCellRender(r2, c2, start_r, start_c, end_r, end_c, luckysheetTableContent, af_compute, cf_compute, offsetLeft, offsetTop, dynamicArray_compute, cellOverflowMap, dataset_col_st, dataset_col_ed, scrollHeight, scrollWidth, bodrder05, true);
- let borderfix = menuButton_default.borderfix(store_default.flowdata, r2, c2);
- let cellsize = [
- start_c + offsetLeft + borderfix[0],
- start_r + offsetTop + borderfix[1],
- end_c - start_c - 3 + borderfix[2],
- end_r - start_r - 3 - 1 + borderfix[3]
- ];
- sparklinesRender(r2, c2, cellsize[0], cellsize[1], "luckysheetTableContent", luckysheetTableContent);
- } else {
- if (r2 + "_" + c2 in dynamicArray_compute) {
- value = dynamicArray_compute[r2 + "_" + c2].v;
- }
- cellRender(r2, c2, start_r, start_c, end_r, end_c, value, luckysheetTableContent, af_compute, cf_compute, offsetLeft, offsetTop, dynamicArray_compute, cellOverflowMap, dataset_col_st, dataset_col_ed, scrollHeight, scrollWidth, bodrder05, true);
- }
- }
- for (let r2 = dataset_row_st; r2 <= dataset_row_ed; r2++) {
- let start_r;
- if (r2 == 0) {
- start_r = -scrollHeight - 1;
- } else {
- start_r = store_default.visibledatarow[r2 - 1] - scrollHeight - 1;
- }
- let end_r = store_default.visibledatarow[r2] - scrollHeight;
- for (let c2 = dataset_col_st; c2 <= dataset_col_ed; c2++) {
- let start_c;
- if (c2 == 0) {
- start_c = -scrollWidth;
- } else {
- start_c = store_default.visibledatacolumn[c2 - 1] - scrollWidth;
- }
- let end_c = store_default.visibledatacolumn[c2] - scrollWidth;
- if (!!store_default.luckysheetcurrentisPivotTable && pivotTable_default.drawPivotTable) {
- if ((c2 == 0 || c2 == 5) && r2 <= 11) {
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(end_c - 2 + bodrder05 + offsetLeft, start_r + offsetTop);
- luckysheetTableContent.lineTo(end_c - 2 + bodrder05 + offsetLeft, end_r - 2 + bodrder05 + offsetTop);
- luckysheetTableContent.lineWidth = 1;
- luckysheetTableContent.strokeStyle = "#000000";
- luckysheetTableContent.closePath();
- luckysheetTableContent.stroke();
- }
- if ((r2 == 2 || r2 == 11) && c2 <= 5) {
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(start_c - 1 + offsetLeft, end_r - 2 + bodrder05 + offsetTop);
- luckysheetTableContent.lineTo(end_c - 2 + bodrder05 + offsetLeft, end_r - 2 + bodrder05 + offsetTop);
- luckysheetTableContent.lineWidth = 1;
- luckysheetTableContent.strokeStyle = "#000000";
- luckysheetTableContent.closePath();
- luckysheetTableContent.stroke();
- }
- if (r2 == 6 && c2 == 3) {
- luckysheetTableContent.save();
- luckysheetTableContent.font = "bold 30px Arial";
- luckysheetTableContent.fillStyle = "#626675";
- luckysheetTableContent.textAlign = "center";
- luckysheetTableContent.fillText(locale_default().pivotTable.title, start_c + (end_c - start_c) / 2 + 4 + offsetLeft, start_r + (end_r - start_r) / 2 - 1 + offsetTop);
- luckysheetTableContent.restore();
- }
- } else if (!!store_default.luckysheetcurrentisPivotTable) {
- if (c2 < pivotTable_default.pivotTableBoundary[1] && r2 < pivotTable_default.pivotTableBoundary[0]) {
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(end_c - 2 + bodrder05 + offsetLeft, start_r + offsetTop);
- luckysheetTableContent.lineTo(end_c - 2 + bodrder05 + offsetLeft, end_r - 2 + bodrder05 + offsetTop);
- luckysheetTableContent.lineWidth = 1;
- luckysheetTableContent.strokeStyle = "#000000";
- luckysheetTableContent.closePath();
- luckysheetTableContent.stroke();
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(start_c - 1 + offsetLeft, end_r - 2 + bodrder05 + offsetTop);
- luckysheetTableContent.lineTo(end_c - 2 + offsetLeft, end_r - 2 + bodrder05 + offsetTop);
- luckysheetTableContent.lineWidth = 1;
- luckysheetTableContent.strokeStyle = "#000000";
- luckysheetTableContent.closePath();
- luckysheetTableContent.stroke();
- }
- }
- }
- }
- if (store_default.config["borderInfo"] != null && store_default.config["borderInfo"].length > 0) {
- let borderLeftRender = function(style, color, start_r, start_c, end_r, end_c, offsetLeft2, offsetTop2, canvas) {
- let linetype = style;
- let m_st = start_c - 2 + bodrder05 + offsetLeft2;
- let m_ed = start_r + offsetTop2 - 1;
- let line_st = start_c - 2 + bodrder05 + offsetLeft2;
- let line_ed = end_r - 2 + bodrder05 + offsetTop2;
- canvas.save();
- menuButton_default.setLineDash(canvas, linetype, "v", m_st, m_ed, line_st, line_ed);
- canvas.strokeStyle = color;
- canvas.stroke();
- canvas.closePath();
- canvas.restore();
- };
- let borderRightRender = function(style, color, start_r, start_c, end_r, end_c, offsetLeft2, offsetTop2, canvas) {
- let linetype = style;
- let m_st = end_c - 2 + bodrder05 + offsetLeft2;
- let m_ed = start_r + offsetTop2 - 1;
- let line_st = end_c - 2 + bodrder05 + offsetLeft2;
- let line_ed = end_r - 2 + bodrder05 + offsetTop2;
- canvas.save();
- menuButton_default.setLineDash(canvas, linetype, "v", m_st, m_ed, line_st, line_ed);
- canvas.strokeStyle = color;
- canvas.stroke();
- canvas.closePath();
- canvas.restore();
- };
- let borderBottomRender = function(style, color, start_r, start_c, end_r, end_c, offsetLeft2, offsetTop2, canvas) {
- let linetype = style;
- let m_st = start_c - 2 + bodrder05 + offsetLeft2;
- let m_ed = end_r - 2 + bodrder05 + offsetTop2;
- let line_st = end_c - 2 + bodrder05 + offsetLeft2;
- let line_ed = end_r - 2 + bodrder05 + offsetTop2;
- canvas.save();
- menuButton_default.setLineDash(canvas, linetype, "h", m_st, m_ed, line_st, line_ed);
- canvas.strokeStyle = color;
- canvas.stroke();
- canvas.closePath();
- canvas.restore();
- };
- let borderTopRender = function(style, color, start_r, start_c, end_r, end_c, offsetLeft2, offsetTop2, canvas) {
- let linetype = style;
- let m_st = start_c - 2 + bodrder05 + offsetLeft2;
- let m_ed = start_r - 1 + bodrder05 + offsetTop2;
- let line_st = end_c - 2 + bodrder05 + offsetLeft2;
- let line_ed = start_r - 1 + bodrder05 + offsetTop2;
- canvas.save();
- menuButton_default.setLineDash(canvas, linetype, "h", m_st, m_ed, line_st, line_ed);
- canvas.strokeStyle = color;
- canvas.stroke();
- canvas.closePath();
- canvas.restore();
- };
- let borderInfoCompute = getBorderInfoComputeRange(dataset_row_st, dataset_row_ed, dataset_col_st, dataset_col_ed);
- for (let x in borderInfoCompute) {
- let bd_r = x.substr(0, x.indexOf("_"));
- let bd_c = x.substr(x.indexOf("_") + 1);
- if (borderOffset[bd_r + "_" + bd_c]) {
- let start_r = borderOffset[bd_r + "_" + bd_c].start_r;
- let start_c = borderOffset[bd_r + "_" + bd_c].start_c;
- let end_r = borderOffset[bd_r + "_" + bd_c].end_r;
- let end_c = borderOffset[bd_r + "_" + bd_c].end_c;
- let cellOverflow_colInObj = cellOverflow_colIn(cellOverflowMap, bd_r, bd_c, dataset_col_st, dataset_col_ed);
- let borderLeft = borderInfoCompute[x].l;
- if (borderLeft != null && (!cellOverflow_colInObj.colIn || cellOverflow_colInObj.stc == bd_c)) {
- borderLeftRender(borderLeft.style, borderLeft.color, start_r, start_c, end_r, end_c, offsetLeft, offsetTop, luckysheetTableContent);
- }
- let borderRight = borderInfoCompute[x].r;
- if (borderRight != null && (!cellOverflow_colInObj.colIn || cellOverflow_colInObj.colLast)) {
- borderRightRender(borderRight.style, borderRight.color, start_r, start_c, end_r, end_c, offsetLeft, offsetTop, luckysheetTableContent);
- }
- let borderTop = borderInfoCompute[x].t;
- if (borderTop != null) {
- borderTopRender(borderTop.style, borderTop.color, start_r, start_c, end_r, end_c, offsetLeft, offsetTop, luckysheetTableContent);
- }
- let borderBottom = borderInfoCompute[x].b;
- if (borderBottom != null) {
- borderBottomRender(borderBottom.style, borderBottom.color, start_r, start_c, end_r, end_c, offsetLeft, offsetTop, luckysheetTableContent);
- }
- }
- }
- }
- if (dataset_col_ed == store_default.visibledatacolumn.length - 1) {
- luckysheetTableContent.clearRect(fill_col_ed - scrollWidth + offsetLeft - 1, offsetTop - 1, store_default.ch_width - store_default.visibledatacolumn[dataset_col_ed], fill_row_ed - scrollHeight);
- }
- luckysheetTableContent.restore();
- store_default.measureTextCacheTimeOut = setTimeout(() => {
- store_default.measureTextCache = {};
- store_default.measureTextCellInfoCache = {};
- store_default.cellOverflowMapCache = {};
- }, 100);
- }
- function getCellOverflowMap(canvas, col_st, col_ed, row_st, row_end) {
- let map = {};
- let data = store_default.flowdata;
- for (let r2 = row_st; r2 <= row_end; r2++) {
- if (data[r2] == null) {
- continue;
- }
- if (store_default.cellOverflowMapCache[r2] != null) {
- map[r2] = store_default.cellOverflowMapCache[r2];
- continue;
- }
- let hasCellOver = false;
- for (let c2 = 0; c2 < data[r2].length; c2++) {
- let cell = data[r2][c2];
- if (store_default.config["colhidden"] != null && store_default.config["colhidden"][c2] != null) {
- continue;
- }
- if (cell != null && (!isRealNull(cell.v) || isInlineStringCell(cell)) && cell.mc == null && cell.tb == "1") {
- let horizonAlign = menuButton_default.checkstatus(data, r2, c2, "ht");
- let textMetricsObj = getCellTextInfo(cell, canvas, {
- r: r2,
- c: c2
- });
- let textMetrics = 0;
- if (textMetricsObj != null) {
- textMetrics = textMetricsObj.textWidthAll;
- }
- let start_c = c2 - 1 < 0 ? 0 : store_default.visibledatacolumn[c2 - 1];
- let end_c = store_default.visibledatacolumn[c2];
- let stc, edc;
- if (end_c - start_c < textMetrics) {
- if (horizonAlign == "0") {
- let trace_forward = cellOverflow_trace(r2, c2, c2 - 1, "forward", horizonAlign, textMetrics);
- let trace_backward = cellOverflow_trace(r2, c2, c2 + 1, "backward", horizonAlign, textMetrics);
- if (trace_forward.success) {
- stc = trace_forward.c;
- } else {
- stc = trace_forward.c + 1;
- }
- if (trace_backward.success) {
- edc = trace_backward.c;
- } else {
- edc = trace_backward.c - 1;
- }
- } else if (horizonAlign == "1") {
- let trace = cellOverflow_trace(r2, c2, c2 + 1, "backward", horizonAlign, textMetrics);
- stc = c2;
- if (trace.success) {
- edc = trace.c;
- } else {
- edc = trace.c - 1;
- }
- } else if (horizonAlign == "2") {
- let trace = cellOverflow_trace(r2, c2, c2 - 1, "forward", horizonAlign, textMetrics);
- edc = c2;
- if (trace.success) {
- stc = trace.c;
- } else {
- stc = trace.c + 1;
- }
- }
- } else {
- stc = c2;
- edc = c2;
- }
- if ((stc <= col_ed || edc >= col_st) && stc < edc) {
- let item2 = {
- r: r2,
- stc,
- edc
- };
- if (map[r2] == null) {
- map[r2] = {};
- }
- map[r2][c2] = item2;
- hasCellOver = true;
- }
- }
- }
- if (hasCellOver) {
- store_default.cellOverflowMapCache[r2] = map[r2];
- }
- }
- return map;
- }
- function cellOverflow_trace(r2, curC, traceC, traceDir, horizonAlign, textMetrics) {
- let data = store_default.flowdata;
- if (traceDir == "forward" && traceC < 0) {
- return {
- success: false,
- r: r2,
- c: traceC
- };
- }
- if (traceDir == "backward" && traceC > data[r2].length - 1) {
- return {
- success: false,
- r: r2,
- c: traceC
- };
- }
- let cell = data[r2][traceC];
- if (cell != null && (!isRealNull(cell.v) || cell.mc != null)) {
- return {
- success: false,
- r: r2,
- c: traceC
- };
- }
- let start_curC = curC - 1 < 0 ? 0 : store_default.visibledatacolumn[curC - 1];
- let end_curC = store_default.visibledatacolumn[curC];
- let w = textMetrics - (end_curC - start_curC);
- if (horizonAlign == "0") {
- start_curC -= w / 2;
- end_curC += w / 2;
- } else if (horizonAlign == "1") {
- end_curC += w;
- } else if (horizonAlign == "2") {
- start_curC -= w;
- }
- let start_traceC = traceC - 1 < 0 ? 0 : store_default.visibledatacolumn[traceC - 1];
- let end_traceC = store_default.visibledatacolumn[traceC];
- if (traceDir == "forward") {
- if (start_curC < start_traceC) {
- return cellOverflow_trace(r2, curC, traceC - 1, traceDir, horizonAlign, textMetrics);
- } else if (start_curC < end_traceC) {
- return {
- success: true,
- r: r2,
- c: traceC
- };
- } else {
- return {
- success: false,
- r: r2,
- c: traceC
- };
- }
- }
- if (traceDir == "backward") {
- if (end_curC > end_traceC) {
- return cellOverflow_trace(r2, curC, traceC + 1, traceDir, horizonAlign, textMetrics);
- } else if (end_curC > start_traceC) {
- return {
- success: true,
- r: r2,
- c: traceC
- };
- } else {
- return {
- success: false,
- r: r2,
- c: traceC
- };
- }
- }
- }
- function cellOverflow_colIn(map, r2, c2, col_st, col_ed) {
- let colIn = false, colLast = false, rowIndex, colIndex, stc, edc;
- for (let rkey in map) {
- for (let ckey in map[rkey]) {
- rowIndex = rkey;
- colIndex = ckey;
- let mapItem = map[rkey][ckey];
- stc = mapItem.stc;
- edc = mapItem.edc;
- if (rowIndex == r2) {
- if (c2 >= stc && c2 <= edc) {
- colIn = true;
- if (c2 == edc || c2 == col_ed) {
- colLast = true;
- break;
- }
- }
- }
- }
- if (colLast) {
- break;
- }
- }
- return {
- colIn,
- colLast,
- rowIndex,
- colIndex,
- stc,
- edc
- };
- }
- function cellTextRender(textInfo, ctx, option) {
- if (textInfo == null) {
- return;
- }
- let values = textInfo.values;
- let pos_x = option.pos_x, pos_y = option.pos_y;
- if (values == null) {
- return;
- }
- if (textInfo.rotate != 0 && textInfo.type != "verticalWrap") {
- ctx.save();
- ctx.translate((pos_x + textInfo.textLeftAll) / store_default.zoomRatio, (pos_y + textInfo.textTopAll) / store_default.zoomRatio);
- ctx.rotate(-textInfo.rotate * Math.PI / 180);
- ctx.translate(-(textInfo.textLeftAll + pos_x) / store_default.zoomRatio, -(pos_y + textInfo.textTopAll) / store_default.zoomRatio);
- }
- for (let i2 = 0; i2 < values.length; i2++) {
- let word = values[i2];
- if (word.inline === true && word.style != null) {
- ctx.font = word.style.fontset;
- ctx.fillStyle = word.style.fc;
- } else {
- ctx.font = word.style;
- }
- let txt = typeof word.content === "object" ? word.content.m : word.content;
- ctx.fillText(txt, (pos_x + word.left) / store_default.zoomRatio, (pos_y + word.top) / store_default.zoomRatio);
- if (word.cancelLine != null) {
- let c2 = word.cancelLine;
- ctx.beginPath();
- ctx.moveTo(Math.floor((pos_x + c2.startX) / store_default.zoomRatio) + 0.5, Math.floor((pos_y + c2.startY) / store_default.zoomRatio) + 0.5);
- ctx.lineTo(Math.floor((pos_x + c2.endX) / store_default.zoomRatio) + 0.5, Math.floor((pos_y + c2.endY) / store_default.zoomRatio) + 0.5);
- ctx.lineWidth = Math.floor(c2.fs / 9);
- ctx.strokeStyle = ctx.fillStyle;
- ctx.stroke();
- ctx.closePath();
- }
- if (word.underLine != null) {
- let underLines = word.underLine;
- for (let a = 0; a < underLines.length; a++) {
- let item2 = underLines[a];
- ctx.beginPath();
- ctx.moveTo(Math.floor((pos_x + item2.startX) / store_default.zoomRatio) + 0.5, Math.floor((pos_y + item2.startY) / store_default.zoomRatio));
- ctx.lineTo(Math.floor((pos_x + item2.endX) / store_default.zoomRatio) + 0.5, Math.floor((pos_y + item2.endY) / store_default.zoomRatio) + 0.5);
- ctx.lineWidth = Math.floor(item2.fs / 9);
- ctx.strokeStyle = ctx.fillStyle;
- ctx.stroke();
- ctx.closePath();
- }
- }
- }
- if (textInfo.rotate != 0 && textInfo.type != "verticalWrap") {
- ctx.restore();
- }
- }
- var sparklinesRender, nullCellRender, cellRender, cellOverflowRender;
- var init_draw = __esm({
- "src/global/draw.js"() {
- init_pivotTable();
- init_conditionformat();
- init_alternateformat();
- init_sparkline();
- init_menuButton();
- init_dataVerificationCtrl();
- init_constant();
- init_sheetSearch();
- init_dynamicArray();
- init_browser();
- init_validate();
- init_getRowlen();
- init_getdata();
- init_border();
- init_get();
- init_util();
- init_inlineString();
- init_method();
- init_store();
- init_locale();
- init_sheetmanage();
- sparklinesRender = function(r2, c2, offsetX, offsetY, canvasid, ctx) {
- if (store_default.flowdata[r2] == null || store_default.flowdata[r2][c2] == null) {
- return;
- }
- let sparklines = store_default.flowdata[r2][c2].spl;
- if (sparklines != null) {
- if (typeof sparklines == "string") {
- sparklines = new Function("return " + sparklines)();
- }
- if (getObjType(sparklines) == "object") {
- let temp1 = sparklines;
- let x = temp1.offsetX;
- let y = temp1.offsetY;
- x = x == null ? 0 : x;
- y = y == null ? 0 : y;
- sparkline_default.render(temp1.shapeseq, temp1.shapes, offsetX + x, offsetY + y, temp1.pixelWidth, temp1.pixelHeight, canvasid, ctx);
- } else if (getObjType(sparklines) == "array" && getObjType(sparklines[0]) == "object") {
- for (let i2 = 0; i2 < sparklines.length; i2++) {
- let temp1 = sparklines[i2];
- let x = temp1.offsetX;
- let y = temp1.offsetY;
- x = x == null ? 0 : x;
- y = y == null ? 0 : y;
- sparkline_default.render(temp1.shapeseq, temp1.shapes, offsetX + x, offsetY + y, temp1.pixelWidth, temp1.pixelHeight, canvasid, ctx);
- }
- }
- }
- };
- nullCellRender = function(r2, c2, start_r, start_c, end_r, end_c, luckysheetTableContent, af_compute, cf_compute, offsetLeft, offsetTop, dynamicArray_compute, cellOverflowMap, dataset_col_st, dataset_col_ed, scrollHeight, scrollWidth, bodrder05, isMerge) {
- let checksAF = alternateformat_default.checksAF(r2, c2, af_compute);
- let checksCF = conditionformat_default.checksCF(r2, c2, cf_compute);
- let borderfix = menuButton_default.borderfix(store_default.flowdata, r2, c2);
- let fillStyle = menuButton_default.checkstatus(store_default.flowdata, r2, c2, "bg");
- if (checksAF != null && checksAF[1] != null) {
- fillStyle = checksAF[1];
- }
- if (checksCF != null && checksCF["cellColor"] != null) {
- fillStyle = checksCF["cellColor"];
- }
- if (store_default.flowdata[r2][c2] != null && store_default.flowdata[r2][c2].tc != null) {
- fillStyle = store_default.flowdata[r2][c2].tc;
- }
- if (fillStyle == null) {
- luckysheetTableContent.fillStyle = "#FFFFFF";
- } else {
- luckysheetTableContent.fillStyle = fillStyle;
- }
- let cellsize = [
- start_c + offsetLeft + borderfix[0] + 1,
- start_r + offsetTop + borderfix[1] + 1,
- end_c - start_c + borderfix[2] - (!!isMerge ? 1 : 0) - 1,
- end_r - start_r + borderfix[3] - 1
- ];
- if (!method_default.createHookFunction("cellRenderBefore", store_default.flowdata[r2][c2], {
- r: r2,
- c: c2,
- start_r: cellsize[1],
- start_c: cellsize[0],
- end_r: cellsize[3] + cellsize[1],
- end_c: cellsize[2] + cellsize[0]
- }, sheetmanage_default.getSheetByIndex(), luckysheetTableContent)) {
- return;
- }
- luckysheetTableContent.fillRect(cellsize[0], cellsize[1], cellsize[2], cellsize[3]);
- if (r2 + "_" + c2 in dynamicArray_compute) {
- let value = dynamicArray_compute[r2 + "_" + c2].v;
- luckysheetTableContent.fillStyle = "#000000";
- let fontset = luckysheetdefaultFont();
- luckysheetTableContent.font = fontset;
- let horizonAlignPos = start_c + 4 + offsetLeft;
- let verticalFixed = browser_default.luckysheetrefreshfixed();
- let verticalAlignPos = end_r + offsetTop - 2;
- luckysheetTableContent.textBaseline = "bottom";
- luckysheetTableContent.fillText(value == null ? "" : value, horizonAlignPos, verticalAlignPos);
- }
- if (store_default.flowdata[r2][c2] != null && store_default.flowdata[r2][c2].ps != null) {
- let ps_w = 8 * store_default.zoomRatio, ps_h = 8 * store_default.zoomRatio;
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(end_c + offsetLeft - 1 - ps_w, start_r + offsetTop);
- luckysheetTableContent.lineTo(end_c + offsetLeft - 1, start_r + offsetTop);
- luckysheetTableContent.lineTo(end_c + offsetLeft - 1, start_r + offsetTop + ps_h);
- luckysheetTableContent.fillStyle = "#FC6666";
- luckysheetTableContent.fill();
- luckysheetTableContent.closePath();
- }
- let cellOverflow_colInObj = cellOverflow_colIn(cellOverflowMap, r2, c2, dataset_col_st, dataset_col_ed);
- if (cellOverflow_colInObj.colLast) {
- cellOverflowRender(cellOverflow_colInObj.rowIndex, cellOverflow_colInObj.colIndex, cellOverflow_colInObj.stc, cellOverflow_colInObj.edc, luckysheetTableContent, scrollHeight, scrollWidth, offsetLeft, offsetTop, af_compute, cf_compute);
- }
- if (!cellOverflow_colInObj.colIn || cellOverflow_colInObj.colLast) {
- if (!store_default.luckysheetcurrentisPivotTable && store_default.showGridLines) {
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(end_c + offsetLeft - 2 + bodrder05, start_r + offsetTop);
- luckysheetTableContent.lineTo(end_c + offsetLeft - 2 + bodrder05, end_r + offsetTop);
- luckysheetTableContent.lineWidth = 1;
- luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
- luckysheetTableContent.stroke();
- luckysheetTableContent.closePath();
- }
- }
- if (!store_default.luckysheetcurrentisPivotTable && store_default.showGridLines) {
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(start_c + offsetLeft - 1, end_r + offsetTop - 2 + bodrder05);
- luckysheetTableContent.lineTo(end_c + offsetLeft - 1, end_r + offsetTop - 2 + bodrder05);
- luckysheetTableContent.lineWidth = 1;
- luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
- luckysheetTableContent.stroke();
- luckysheetTableContent.closePath();
- }
- method_default.createHookFunction("cellRenderAfter", store_default.flowdata[r2][c2], {
- r: r2,
- c: c2,
- start_r: cellsize[1],
- start_c: cellsize[0],
- end_r: cellsize[3] + cellsize[1],
- end_c: cellsize[2] + cellsize[0]
- }, sheetmanage_default.getSheetByIndex(), luckysheetTableContent);
- };
- cellRender = function(r2, c2, start_r, start_c, end_r, end_c, value, luckysheetTableContent, af_compute, cf_compute, offsetLeft, offsetTop, dynamicArray_compute, cellOverflowMap, dataset_col_st, dataset_col_ed, scrollHeight, scrollWidth, bodrder05, isMerge) {
- let cell = store_default.flowdata[r2][c2];
- let cellWidth = end_c - start_c - 2;
- let cellHeight = end_r - start_r - 2;
- let space_width = 2, space_height = 2;
- let horizonAlign = menuButton_default.checkstatus(store_default.flowdata, r2, c2, "ht");
- let verticalAlign = menuButton_default.checkstatus(store_default.flowdata, r2, c2, "vt");
- let checksAF = alternateformat_default.checksAF(r2, c2, af_compute);
- let checksCF = conditionformat_default.checksCF(r2, c2, cf_compute);
- let fillStyle = menuButton_default.checkstatus(store_default.flowdata, r2, c2, "bg");
- if (checksAF != null && checksAF[1] != null) {
- fillStyle = checksAF[1];
- }
- if (checksCF != null && checksCF["cellColor"] != null) {
- fillStyle = checksCF["cellColor"];
- }
- if (fillStyle == null) {
- luckysheetTableContent.fillStyle = "#FFFFFF";
- } else {
- luckysheetTableContent.fillStyle = fillStyle;
- }
- let borderfix = menuButton_default.borderfix(store_default.flowdata, r2, c2);
- let cellsize = [
- start_c + offsetLeft + borderfix[0] + 1,
- start_r + offsetTop + borderfix[1] + 1,
- end_c - start_c + borderfix[2] - (!!isMerge ? 1 : 0) - 1,
- end_r - start_r + borderfix[3] + 1
- ];
- if (!method_default.createHookFunction("cellRenderBefore", store_default.flowdata[r2][c2], {
- r: r2,
- c: c2,
- start_r: cellsize[1],
- start_c: cellsize[0],
- end_r: cellsize[3] + cellsize[1],
- end_c: cellsize[2] + cellsize[0]
- }, sheetmanage_default.getSheetByIndex(), luckysheetTableContent)) {
- return;
- }
- luckysheetTableContent.fillRect(cellsize[0], cellsize[1], cellsize[2], cellsize[3]);
- let dataVerification = dataVerificationCtrl_default.dataVerification;
- if (dataVerification != null && dataVerification[r2 + "_" + c2] != null && !dataVerificationCtrl_default.validateCellData(value, dataVerification[r2 + "_" + c2])) {
- let dv_w = 5 * store_default.zoomRatio, dv_h = 5 * store_default.zoomRatio;
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(start_c + offsetLeft, start_r + offsetTop);
- luckysheetTableContent.lineTo(start_c + offsetLeft + dv_w, start_r + offsetTop);
- luckysheetTableContent.lineTo(start_c + offsetLeft, start_r + offsetTop + dv_h);
- luckysheetTableContent.fillStyle = "#FC6666";
- luckysheetTableContent.fill();
- luckysheetTableContent.closePath();
- }
- if (cell.ps != null) {
- let ps_w = 8 * store_default.zoomRatio, ps_h = 8 * store_default.zoomRatio;
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(end_c + offsetLeft - ps_w, start_r + offsetTop);
- luckysheetTableContent.lineTo(end_c + offsetLeft, start_r + offsetTop);
- luckysheetTableContent.lineTo(end_c + offsetLeft, start_r + offsetTop + ps_h);
- luckysheetTableContent.fillStyle = "#FC6666";
- luckysheetTableContent.fill();
- luckysheetTableContent.closePath();
- }
- if (cell.qp == 1 && isRealNum(cell.v)) {
- let ps_w = 6 * store_default.zoomRatio, ps_h = 6 * store_default.zoomRatio;
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(start_c + offsetLeft + ps_w - 1, start_r + offsetTop);
- luckysheetTableContent.lineTo(start_c + offsetLeft - 1, start_r + offsetTop);
- luckysheetTableContent.lineTo(start_c + offsetLeft - 1, start_r + offsetTop + ps_h);
- luckysheetTableContent.fillStyle = "#487f1e";
- luckysheetTableContent.fill();
- luckysheetTableContent.closePath();
- }
- let cellOverflow_bd_r_render = true;
- let cellOverflow_colInObj = cellOverflow_colIn(cellOverflowMap, r2, c2, dataset_col_st, dataset_col_ed);
- if (cell.tb == "1" && cellOverflow_colInObj.colIn) {
- if (cellOverflow_colInObj.colLast) {
- cellOverflowRender(cellOverflow_colInObj.rowIndex, cellOverflow_colInObj.colIndex, cellOverflow_colInObj.stc, cellOverflow_colInObj.edc, luckysheetTableContent, scrollHeight, scrollWidth, offsetLeft, offsetTop, af_compute, cf_compute);
- } else {
- cellOverflow_bd_r_render = false;
- }
- } else if (dataVerification != null && dataVerification[r2 + "_" + c2] != null && dataVerification[r2 + "_" + c2].type == "checkbox") {
- let pos_x = start_c + offsetLeft;
- let pos_y = start_r + offsetTop + 1;
- luckysheetTableContent.save();
- luckysheetTableContent.beginPath();
- luckysheetTableContent.rect(pos_x, pos_y, cellWidth, cellHeight);
- luckysheetTableContent.clip();
- luckysheetTableContent.scale(store_default.zoomRatio, store_default.zoomRatio);
- let measureText = getMeasureText(value, luckysheetTableContent);
- let textMetrics = measureText.width + 14;
- let oneLineTextHeight = measureText.actualBoundingBoxDescent + measureText.actualBoundingBoxAscent;
- let horizonAlignPos = pos_x + space_width;
- if (horizonAlign == "0") {
- horizonAlignPos = pos_x + cellWidth / 2 - textMetrics / 2;
- } else if (horizonAlign == "2") {
- horizonAlignPos = pos_x + cellWidth - space_width - textMetrics;
- }
- let verticalCellHeight = cellHeight > oneLineTextHeight ? cellHeight : oneLineTextHeight;
- let verticalAlignPos_text = pos_y + verticalCellHeight - space_height;
- luckysheetTableContent.textBaseline = "bottom";
- let verticalAlignPos_checkbox = verticalAlignPos_text - 13 * store_default.zoomRatio;
- if (verticalAlign == "0") {
- verticalAlignPos_text = pos_y + verticalCellHeight / 2;
- luckysheetTableContent.textBaseline = "middle";
- verticalAlignPos_checkbox = verticalAlignPos_text - 6 * store_default.zoomRatio;
- } else if (verticalAlign == "1") {
- verticalAlignPos_text = pos_y + space_height;
- luckysheetTableContent.textBaseline = "top";
- verticalAlignPos_checkbox = verticalAlignPos_text + 1 * store_default.zoomRatio;
- }
- horizonAlignPos = horizonAlignPos / store_default.zoomRatio;
- verticalAlignPos_text = verticalAlignPos_text / store_default.zoomRatio;
- verticalAlignPos_checkbox = verticalAlignPos_checkbox / store_default.zoomRatio;
- luckysheetTableContent.lineWidth = 1;
- luckysheetTableContent.strokeStyle = "#000";
- luckysheetTableContent.strokeRect(horizonAlignPos, verticalAlignPos_checkbox, 10, 10);
- if (dataVerification[r2 + "_" + c2].checked) {
- luckysheetTableContent.beginPath();
- luckysheetTableContent.lineTo(horizonAlignPos + 1, verticalAlignPos_checkbox + 6);
- luckysheetTableContent.lineTo(horizonAlignPos + 4, verticalAlignPos_checkbox + 9);
- luckysheetTableContent.lineTo(horizonAlignPos + 9, verticalAlignPos_checkbox + 2);
- luckysheetTableContent.stroke();
- luckysheetTableContent.closePath();
- }
- luckysheetTableContent.fillStyle = menuButton_default.checkstatus(store_default.flowdata, r2, c2, "fc");
- luckysheetTableContent.fillText(value == null ? "" : value, horizonAlignPos + 14, verticalAlignPos_text);
- luckysheetTableContent.restore();
- } else {
- if (checksCF != null && checksCF["dataBar"] != null && checksCF["dataBar"]["valueLen"] && checksCF["dataBar"]["valueLen"].toString() !== "NaN") {
- let x = start_c + offsetLeft + space_width;
- let y = start_r + offsetTop + space_height;
- let w = cellWidth - space_width * 2;
- let h = cellHeight - space_height * 2;
- let valueType = checksCF["dataBar"]["valueType"];
- let valueLen = checksCF["dataBar"]["valueLen"];
- let format = checksCF["dataBar"]["format"];
- if (valueType == "minus") {
- let minusLen = checksCF["dataBar"]["minusLen"];
- if (format.length > 1) {
- let my_gradient = luckysheetTableContent.createLinearGradient(x + w * minusLen * (1 - valueLen), y, x + w * minusLen, y);
- my_gradient.addColorStop(0, "#ffffff");
- my_gradient.addColorStop(1, "#ff0000");
- luckysheetTableContent.fillStyle = my_gradient;
- } else {
- luckysheetTableContent.fillStyle = "#ff0000";
- }
- luckysheetTableContent.fillRect(x + w * minusLen * (1 - valueLen), y, w * minusLen * valueLen, h);
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(x + w * minusLen * (1 - valueLen), y);
- luckysheetTableContent.lineTo(x + w * minusLen * (1 - valueLen), y + h);
- luckysheetTableContent.lineTo(x + w * minusLen, y + h);
- luckysheetTableContent.lineTo(x + w * minusLen, y);
- luckysheetTableContent.lineTo(x + w * minusLen * (1 - valueLen), y);
- luckysheetTableContent.lineWidth = 1;
- luckysheetTableContent.strokeStyle = "#ff0000";
- luckysheetTableContent.stroke();
- luckysheetTableContent.closePath();
- } else if (valueType == "plus") {
- let plusLen = checksCF["dataBar"]["plusLen"];
- if (plusLen == 1) {
- if (format.length > 1) {
- let my_gradient = luckysheetTableContent.createLinearGradient(x, y, x + w * valueLen, y);
- my_gradient.addColorStop(0, format[0]);
- my_gradient.addColorStop(1, format[1]);
- luckysheetTableContent.fillStyle = my_gradient;
- } else {
- luckysheetTableContent.fillStyle = format[0];
- }
- luckysheetTableContent.fillRect(x, y, w * valueLen, h);
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(x, y);
- luckysheetTableContent.lineTo(x, y + h);
- luckysheetTableContent.lineTo(x + w * valueLen, y + h);
- luckysheetTableContent.lineTo(x + w * valueLen, y);
- luckysheetTableContent.lineTo(x, y);
- luckysheetTableContent.lineWidth = 1;
- luckysheetTableContent.strokeStyle = format[0];
- luckysheetTableContent.stroke();
- luckysheetTableContent.closePath();
- } else {
- let minusLen = checksCF["dataBar"]["minusLen"];
- if (format.length > 1) {
- let my_gradient = luckysheetTableContent.createLinearGradient(x + w * minusLen, y, x + w * minusLen + w * plusLen * valueLen, y);
- my_gradient.addColorStop(0, format[0]);
- my_gradient.addColorStop(1, format[1]);
- luckysheetTableContent.fillStyle = my_gradient;
- } else {
- luckysheetTableContent.fillStyle = format[0];
- }
- luckysheetTableContent.fillRect(x + w * minusLen, y, w * plusLen * valueLen, h);
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(x + w * minusLen, y);
- luckysheetTableContent.lineTo(x + w * minusLen, y + h);
- luckysheetTableContent.lineTo(x + w * minusLen + w * plusLen * valueLen, y + h);
- luckysheetTableContent.lineTo(x + w * minusLen + w * plusLen * valueLen, y);
- luckysheetTableContent.lineTo(x + w * minusLen, y);
- luckysheetTableContent.lineWidth = 1;
- luckysheetTableContent.strokeStyle = format[0];
- luckysheetTableContent.stroke();
- luckysheetTableContent.closePath();
- }
- }
- }
- let pos_x = start_c + offsetLeft;
- let pos_y = start_r + offsetTop + 1;
- luckysheetTableContent.save();
- luckysheetTableContent.beginPath();
- luckysheetTableContent.rect(pos_x, pos_y, cellWidth, cellHeight);
- luckysheetTableContent.clip();
- luckysheetTableContent.scale(store_default.zoomRatio, store_default.zoomRatio);
- let textInfo = getCellTextInfo(cell, luckysheetTableContent, {
- cellWidth,
- cellHeight,
- space_width,
- space_height,
- r: r2,
- c: c2
- });
- if (checksCF != null && checksCF["icons"] != null && textInfo.type == "plain") {
- let l = checksCF["icons"]["left"];
- let t = checksCF["icons"]["top"];
- let value2 = textInfo.values[0];
- let horizonAlignPos = pos_x + value2.left;
- let verticalAlignPos = pos_y + value2.top - textInfo.textHeightAll;
- if (verticalAlign == "0") {
- verticalAlignPos = pos_y + cellHeight / 2 - textInfo.textHeightAll / 2;
- } else if (verticalAlign == "1") {
- verticalAlignPos = pos_y;
- } else if (verticalAlign == "2") {
- verticalAlignPos = verticalAlignPos - textInfo.desc;
- }
- verticalAlignPos = verticalAlignPos / store_default.zoomRatio;
- horizonAlignPos = horizonAlignPos / store_default.zoomRatio;
- luckysheetTableContent.drawImage(luckysheet_CFiconsImg, l * 42, t * 32, 32, 32, pos_x / store_default.zoomRatio, verticalAlignPos, textInfo.textHeightAll / store_default.zoomRatio, textInfo.textHeightAll / store_default.zoomRatio);
- if (horizonAlign != "0" && horizonAlign != "2") {
- horizonAlignPos = horizonAlignPos + textInfo.textHeightAll / store_default.zoomRatio;
- }
- }
- luckysheetTableContent.fillStyle = menuButton_default.checkstatus(store_default.flowdata, r2, c2, "fc");
- if (checksAF != null && checksAF[0] != null) {
- luckysheetTableContent.fillStyle = checksAF[0];
- }
- if (checksCF != null && checksCF["textColor"] != null) {
- luckysheetTableContent.fillStyle = checksCF["textColor"];
- }
- if (cell.ct && cell.ct.fa && cell.ct.fa.indexOf("[Red]") > -1 && cell.ct.t == "n" && cell.v < 0) {
- luckysheetTableContent.fillStyle = "#ff0000";
- }
- cellTextRender(textInfo, luckysheetTableContent, {
- pos_x,
- pos_y
- });
- luckysheetTableContent.restore();
- }
- if (cellOverflow_bd_r_render) {
- if (!store_default.luckysheetcurrentisPivotTable && store_default.showGridLines) {
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(end_c + offsetLeft - 2 + bodrder05, start_r + offsetTop);
- luckysheetTableContent.lineTo(end_c + offsetLeft - 2 + bodrder05, end_r + offsetTop);
- luckysheetTableContent.lineWidth = 1;
- luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
- luckysheetTableContent.stroke();
- luckysheetTableContent.closePath();
- }
- }
- if (!store_default.luckysheetcurrentisPivotTable && store_default.showGridLines) {
- luckysheetTableContent.beginPath();
- luckysheetTableContent.moveTo(start_c + offsetLeft - 1, end_r + offsetTop - 2 + bodrder05);
- luckysheetTableContent.lineTo(end_c + offsetLeft - 1, end_r + offsetTop - 2 + bodrder05);
- luckysheetTableContent.lineWidth = 1;
- luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
- luckysheetTableContent.stroke();
- luckysheetTableContent.closePath();
- }
- method_default.createHookFunction("cellRenderAfter", store_default.flowdata[r2][c2], {
- r: r2,
- c: c2,
- start_r: cellsize[1],
- start_c: cellsize[0],
- end_r: cellsize[3] + cellsize[1],
- end_c: cellsize[2] + cellsize[0]
- }, sheetmanage_default.getSheetByIndex(), luckysheetTableContent);
- };
- cellOverflowRender = function(r2, c2, stc, edc, luckysheetTableContent, scrollHeight, scrollWidth, offsetLeft, offsetTop, af_compute, cf_compute) {
- let start_r;
- if (r2 == 0) {
- start_r = -scrollHeight - 1;
- } else {
- start_r = store_default.visibledatarow[r2 - 1] - scrollHeight - 1;
- }
- let end_r = store_default.visibledatarow[r2] - scrollHeight;
- let start_c;
- if (stc == 0) {
- start_c = -scrollWidth;
- } else {
- start_c = store_default.visibledatacolumn[stc - 1] - scrollWidth;
- }
- let end_c = store_default.visibledatacolumn[edc] - scrollWidth;
- let cell = store_default.flowdata[r2][c2];
- let cellWidth = end_c - start_c - 2;
- let cellHeight = end_r - start_r - 2;
- let space_width = 2, space_height = 2;
- let pos_x = start_c + offsetLeft;
- let pos_y = start_r + offsetTop + 1;
- let fontset = luckysheetfontformat(cell);
- luckysheetTableContent.font = fontset;
- luckysheetTableContent.save();
- luckysheetTableContent.beginPath();
- luckysheetTableContent.rect(pos_x, pos_y, cellWidth, cellHeight);
- luckysheetTableContent.clip();
- luckysheetTableContent.scale(store_default.zoomRatio, store_default.zoomRatio);
- let textInfo = getCellTextInfo(cell, luckysheetTableContent, {
- cellWidth,
- cellHeight,
- space_width,
- space_height,
- r: r2,
- c: c2
- });
- let checksAF = alternateformat_default.checksAF(r2, c2, af_compute);
- let checksCF = conditionformat_default.checksCF(r2, c2, cf_compute);
- luckysheetTableContent.fillStyle = menuButton_default.checkstatus(store_default.flowdata, r2, c2, "fc");
- if (checksAF != null && checksAF[0] != null) {
- luckysheetTableContent.fillStyle = checksAF[0];
- }
- if (checksCF != null && checksCF["textColor"] != null) {
- luckysheetTableContent.fillStyle = checksCF["textColor"];
- }
- cellTextRender(textInfo, luckysheetTableContent, {
- pos_x,
- pos_y
- });
- luckysheetTableContent.restore();
- };
- }
- });
-
- // src/controllers/hyperlinkCtrl.js
- var hyperlinkCtrl, hyperlinkCtrl_default;
- var init_hyperlinkCtrl = __esm({
- "src/controllers/hyperlinkCtrl.js"() {
- init_util();
- init_getdata();
- init_refresh();
- init_location();
- init_formula();
- init_tooltip();
- init_editor();
- init_constant();
- init_select();
- init_server();
- init_sheetmanage();
- init_freezen();
- init_menuButton();
- init_get();
- init_locale();
- init_store();
- hyperlinkCtrl = {
- item: {
- linkType: "external",
- linkAddress: "",
- linkTooltip: ""
- },
- hyperlink: null,
- createDialog: function() {
- let _this2 = this;
- const _locale = locale_default();
- const hyperlinkText = _locale.insertLink;
- const toolbarText = _locale.toolbar;
- const buttonText = _locale.button;
- $("#luckysheet-modal-dialog-mask").show();
- $("#luckysheet-insertLink-dialog").remove();
- let sheetListOption = "";
- store_default.luckysheetfile.forEach((item2) => {
- sheetListOption += `
${item2.name} `;
- });
- let content = `
-
- ${hyperlinkText.linkText}\uFF1A
-
-
-
- ${hyperlinkText.linkType}\uFF1A
-
- ${hyperlinkText.external}
- ${hyperlinkText.internal}
-
-
-
-
- ${hyperlinkText.linkAddress}\uFF1A
-
-
-
-
-
- ${hyperlinkText.linkSheet}\uFF1A
-
- ${sheetListOption}
-
-
-
- ${hyperlinkText.linkCell}\uFF1A
-
-
-
-
- ${hyperlinkText.linkTooltip}\uFF1A
-
-
-
`;
- $("body").append(replaceHtml(modelHTML, {
- "id": "luckysheet-insertLink-dialog",
- "addclass": "luckysheet-insertLink-dialog",
- "title": toolbarText.insertLink,
- "content": content,
- "botton": `
${buttonText.confirm}
-
${buttonText.cancel} `,
- "style": "z-index:100003"
- }));
- let $t = $("#luckysheet-insertLink-dialog").find(".luckysheet-modal-dialog-content").css("min-width", 350).end(), myh = $t.outerHeight(), myw = $t.outerWidth();
- let winw = $(window).width(), winh = $(window).height();
- let scrollLeft = $(document).scrollLeft(), scrollTop = $(document).scrollTop();
- $("#luckysheet-insertLink-dialog").css({
- "left": (winw + scrollLeft - myw) / 2,
- "top": (winh + scrollTop - myh) / 3
- }).show();
- _this2.dataAllocation();
- },
- init: function() {
- let _this2 = this;
- const _locale = locale_default();
- const hyperlinkText = _locale.insertLink;
- $(document).off("change.linkType").on("change.linkType", "#luckysheet-insertLink-dialog-linkType", function(e) {
- let value = this.value;
- $("#luckysheet-insertLink-dialog .show-box").hide();
- $("#luckysheet-insertLink-dialog .show-box-" + value).show();
- });
- $(document).off("click.confirm").on("click.confirm", "#luckysheet-insertLink-dialog-confirm", function(e) {
- let last = store_default.luckysheet_select_save[store_default.luckysheet_select_save.length - 1];
- let rowIndex = last.row_focus || last.row[0];
- let colIndex = last.column_focus || last.column[0];
- let linkText = $("#luckysheet-insertLink-dialog-linkText").val();
- let linkType = $("#luckysheet-insertLink-dialog-linkType").val();
- let linkAddress = $("#luckysheet-insertLink-dialog-linkAddress").val();
- let linkSheet = $("#luckysheet-insertLink-dialog-linkSheet").val();
- let linkCell = $("#luckysheet-insertLink-dialog-linkCell").val();
- let linkTooltip = $("#luckysheet-insertLink-dialog-linkTooltip").val();
- if (linkType == "external") {
- if (!/^http[s]?:\/\//.test(linkAddress)) {
- linkAddress = "https://" + linkAddress;
- }
- if (!/^http[s]?:\/\/([\w\-\.]+)+[\w-]*([\w\-\.\/\?%&=]+)?$/ig.test(linkAddress)) {
- tooltip_default.info('
', hyperlinkText.tooltipInfo1);
- return;
- }
- } else {
- if (!formula_default.iscelldata(linkCell)) {
- tooltip_default.info('
', hyperlinkText.tooltipInfo2);
- return;
- }
- linkAddress = linkSheet + "!" + linkCell;
- }
- if (linkText == null || linkText.replace(/\s/g, "") == "") {
- linkText = linkAddress;
- }
- let item2 = {
- linkType,
- linkAddress,
- linkTooltip
- };
- let historyHyperlink = $.extend(true, {}, _this2.hyperlink);
- let currentHyperlink = $.extend(true, {}, _this2.hyperlink);
- currentHyperlink[rowIndex + "_" + colIndex] = item2;
- let d = editor_default.deepCopyFlowData(store_default.flowdata);
- let cell = d[rowIndex][colIndex];
- if (cell == null) {
- cell = {};
- }
- cell.fc = "rgb(0, 0, 255)";
- cell.un = 1;
- cell.v = cell.m = linkText;
- d[rowIndex][colIndex] = cell;
- _this2.ref(historyHyperlink, currentHyperlink, store_default.currentSheetIndex, d, [{row: [rowIndex, rowIndex], column: [colIndex, colIndex]}]);
- $("#luckysheet-modal-dialog-mask").hide();
- $("#luckysheet-insertLink-dialog").hide();
- });
- },
- dataAllocation: function() {
- let _this2 = this;
- let last = store_default.luckysheet_select_save[store_default.luckysheet_select_save.length - 1];
- let rowIndex = last.row_focus || last.row[0];
- let colIndex = last.column_focus || last.column[0];
- let hyperlink = _this2.hyperlink || {};
- let item2 = hyperlink[rowIndex + "_" + colIndex] || {};
- let text = getcellvalue(rowIndex, colIndex, null, "m");
- $("#luckysheet-insertLink-dialog-linkText").val(text);
- let linkType = item2.linkType || "external";
- $("#luckysheet-insertLink-dialog-linkType").val(linkType);
- $("#luckysheet-insertLink-dialog .show-box").hide();
- $("#luckysheet-insertLink-dialog .show-box-" + linkType).show();
- let linkAddress = item2.linkAddress || "";
- if (linkType == "external") {
- $("#luckysheet-insertLink-dialog-linkAddress").val(linkAddress);
- } else {
- if (formula_default.iscelldata(linkAddress)) {
- let sheettxt = linkAddress.split("!")[0];
- let rangetxt = linkAddress.split("!")[1];
- $("#luckysheet-insertLink-dialog-linkSheet").val(sheettxt);
- $("#luckysheet-insertLink-dialog-linkCell").val(rangetxt);
- }
- }
- let linkTooltip = item2.linkTooltip || "";
- $("#luckysheet-insertLink-dialog-linkTooltip").val(linkTooltip);
- },
- cellFocus: function(r2, c2) {
- let _this2 = this;
- if (_this2.hyperlink == null || _this2.hyperlink[r2 + "_" + c2] == null) {
- return;
- }
- let item2 = _this2.hyperlink[r2 + "_" + c2];
- if (item2.linkType == "external") {
- window.open(item2.linkAddress);
- } else {
- let cellrange = formula_default.getcellrange(item2.linkAddress);
- let sheetIndex = cellrange.sheetIndex;
- let range2 = [{
- row: cellrange.row,
- column: cellrange.column
- }];
- if (sheetIndex != store_default.currentSheetIndex) {
- $("#luckysheet-sheet-area div.luckysheet-sheets-item").removeClass("luckysheet-sheets-item-active");
- $("#luckysheet-sheets-item" + sheetIndex).addClass("luckysheet-sheets-item-active");
- sheetmanage_default.changeSheet(sheetIndex);
- }
- store_default.luckysheet_select_save = range2;
- selectHightlightShow(true);
- let row_pre = cellrange.row[0] - 1 == -1 ? 0 : store_default.visibledatarow[cellrange.row[0] - 1];
- let col_pre = cellrange.column[0] - 1 == -1 ? 0 : store_default.visibledatacolumn[cellrange.column[0] - 1];
- $("#luckysheet-scrollbar-x").scrollLeft(col_pre);
- $("#luckysheet-scrollbar-y").scrollTop(row_pre);
- }
- },
- overshow: function(event2) {
- let _this2 = this;
- $("#luckysheet-hyperlink-overshow").remove();
- if ($(event2.target).closest("#luckysheet-cell-main").length == 0) {
- return;
- }
- let mouse = mouseposition(event2.pageX, event2.pageY);
- let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
- let scrollTop = $("#luckysheet-cell-main").scrollTop();
- let x = mouse[0] + scrollLeft;
- let y = mouse[1] + scrollTop;
- if (freezen_default.freezenverticaldata != null && mouse[0] < freezen_default.freezenverticaldata[0] - freezen_default.freezenverticaldata[2]) {
- return;
- }
- if (freezen_default.freezenhorizontaldata != null && mouse[1] < freezen_default.freezenhorizontaldata[0] - freezen_default.freezenhorizontaldata[2]) {
- return;
- }
- let row_index = rowLocation(y)[2];
- let col_index = colLocation(x)[2];
- let margeset = menuButton_default.mergeborer(store_default.flowdata, row_index, col_index);
- if (!!margeset) {
- row_index = margeset.row[2];
- col_index = margeset.column[2];
- }
- if (_this2.hyperlink == null || _this2.hyperlink[row_index + "_" + col_index] == null) {
- return;
- }
- let item2 = _this2.hyperlink[row_index + "_" + col_index];
- let linkTooltip = item2.linkTooltip;
- if (linkTooltip == null || linkTooltip.replace(/\s/g, "") == "") {
- linkTooltip = item2.linkAddress;
- }
- let row = store_default.visibledatarow[row_index], row_pre = row_index - 1 == -1 ? 0 : store_default.visibledatarow[row_index - 1];
- let col = store_default.visibledatacolumn[col_index], col_pre = col_index - 1 == -1 ? 0 : store_default.visibledatacolumn[col_index - 1];
- if (!!margeset) {
- row = margeset.row[1];
- row_pre = margeset.row[0];
- col = margeset.column[1];
- col_pre = margeset.column[0];
- }
- let html = `
-
${linkTooltip}
-
\u5355\u51FB\u9F20\u6807\u53EF\u4EE5\u8FFD\u8E2A
-
`;
- $(html).appendTo($("#luckysheet-cell-main"));
- },
- ref: function(historyHyperlink, currentHyperlink, sheetIndex, d, range2) {
- let _this2 = this;
- if (store_default.clearjfundo) {
- store_default.jfundo.length = 0;
- let redo2 = {};
- redo2["type"] = "updateHyperlink";
- redo2["sheetIndex"] = sheetIndex;
- redo2["historyHyperlink"] = historyHyperlink;
- redo2["currentHyperlink"] = currentHyperlink;
- redo2["data"] = store_default.flowdata;
- redo2["curData"] = d;
- redo2["range"] = range2;
- store_default.jfredo.push(redo2);
- }
- _this2.hyperlink = currentHyperlink;
- store_default.luckysheetfile[getSheetIndex(sheetIndex)].hyperlink = currentHyperlink;
- store_default.flowdata = d;
- editor_default.webWorkerFlowDataCache(store_default.flowdata);
- store_default.luckysheetfile[getSheetIndex(sheetIndex)].data = store_default.flowdata;
- if (server_default.allowUpdate) {
- server_default.saveParam("all", sheetIndex, currentHyperlink, {"k": "hyperlink"});
- server_default.historyParam(store_default.flowdata, sheetIndex, range2[0]);
- }
- setTimeout(function() {
- luckysheetrefreshgrid();
- }, 1);
- }
- };
- hyperlinkCtrl_default = hyperlinkCtrl;
- }
- });
-
- // src/global/refresh.js
- function runExecFunction(range2, index2, data) {
- formula_default.execFunctionExist = [];
- for (let s = 0; s < range2.length; s++) {
- for (let r2 = range2[s].row[0]; r2 <= range2[s].row[1]; r2++) {
- for (let c2 = range2[s].column[0]; c2 <= range2[s].column[1]; c2++) {
- formula_default.execFunctionExist.push({"r": r2, "c": c2, "i": index2});
- }
- }
- }
- formula_default.execFunctionExist.reverse();
- formula_default.execFunctionGroup(null, null, null, null, data);
- formula_default.execFunctionGlobalData = null;
- }
- function jfrefreshgrid(data, range2, allParam, isRunExecFunction = true, isRefreshCanvas = true) {
- if (data == null) {
- data = store_default.flowdata;
- }
- if (range2 == null) {
- range2 = store_default.luckysheet_select_save;
- }
- range2 = JSON.parse(JSON.stringify(range2));
- clearTimeout(refreshCanvasTimeOut);
- if (allParam == null) {
- allParam = {};
- }
- let cfg = allParam["cfg"];
- let calc = allParam["calc"];
- let RowlChange = allParam["RowlChange"];
- let cdformat = allParam["cdformat"];
- let dataVerification = allParam["dataVerification"];
- let dynamicArray = allParam["dynamicArray"];
- let hyperlink = allParam["hyperlink"];
- let file = store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)];
- if (store_default.clearjfundo) {
- store_default.jfundo.length = 0;
- let curConfig;
- if (cfg == null) {
- curConfig = $.extend(true, {}, store_default.config);
- } else {
- curConfig = $.extend(true, {}, cfg);
- }
- let curCdformat;
- if (cdformat == null) {
- curCdformat = $.extend(true, [], file["luckysheet_conditionformat_save"]);
- } else {
- curCdformat = cdformat;
- }
- let curDataVerification;
- if (dataVerification == null) {
- curDataVerification = $.extend(true, {}, file["dataVerification"]);
- } else {
- curDataVerification = dataVerification;
- }
- let curDynamicArray;
- if (dynamicArray == null) {
- curDynamicArray = $.extend(true, [], file["dynamicArray"]);
- } else {
- curDynamicArray = dynamicArray;
- }
- store_default.jfredo.push({
- "type": "datachange",
- "data": store_default.flowdata,
- "curdata": data,
- "sheetIndex": store_default.currentSheetIndex,
- "config": $.extend(true, {}, store_default.config),
- "curConfig": curConfig,
- "calc": $.extend(true, [], file.calcChain),
- "curCalc": calc,
- "cdformat": $.extend(true, [], file["luckysheet_conditionformat_save"]),
- "curCdformat": curCdformat,
- "RowlChange": RowlChange,
- "dataVerification": $.extend(true, [], file["dataVerification"]),
- "curDataVerification": curDataVerification,
- "dynamicArray": $.extend(true, [], file["dynamicArray"]),
- "curDynamicArray": curDynamicArray,
- "hyperlink": hyperlink && $.extend(true, {}, file.hyperlink),
- "curHyperlink": hyperlink,
- "range": range2,
- "dataRange": [...file.luckysheet_select_save]
- });
- }
- store_default.flowdata = data;
- editor_default.webWorkerFlowDataCache(store_default.flowdata);
- file.data = store_default.flowdata;
- if (cfg != null) {
- store_default.config = cfg;
- file.config = store_default.config;
- server_default.saveParam("all", store_default.currentSheetIndex, cfg, {"k": "config"});
- if (RowlChange != null) {
- jfrefreshgrid_rhcw(store_default.flowdata.length, store_default.flowdata[0].length);
- }
- }
- if (calc != null) {
- file.calcChain = calc;
- server_default.saveParam("all", store_default.currentSheetIndex, calc, {"k": "calcChain"});
- }
- if (cdformat != null && cdformat.length !== 0) {
- file["luckysheet_conditionformat_save"] = cdformat;
- server_default.saveParam("all", store_default.currentSheetIndex, cdformat, {"k": "luckysheet_conditionformat_save"});
- }
- if (dataVerification != null && Object.keys(dataVerification).length !== 0) {
- dataVerificationCtrl_default.dataVerification = dataVerification;
- file["dataVerification"] = dataVerification;
- server_default.saveParam("all", store_default.currentSheetIndex, dataVerification, {"k": "dataVerification"});
- }
- if (dynamicArray != null) {
- file["dynamicArray"] = dynamicArray;
- server_default.saveParam("all", store_default.currentSheetIndex, dynamicArray, {"k": "dynamicArray"});
- }
- if (hyperlink != null) {
- file["hyperlink"] = hyperlink;
- hyperlinkCtrl_default.hyperlink = hyperlink;
- server_default.saveParam("all", store_default.currentSheetIndex, hyperlink, {"k": "hyperlink"});
- }
- for (let s = 0; s < range2.length; s++) {
- let r1 = range2[s].row[0];
- let c1 = range2[s].column[0];
- if (store_default.flowdata[r1][c1] != null && store_default.flowdata[r1][c1].spl != null) {
- window.luckysheetCurrentRow = r1;
- window.luckysheetCurrentColumn = c1;
- window.luckysheetCurrentFunction = store_default.flowdata[r1][c1].f;
- let fp = $.trim(formula_default.functionParserExe(store_default.flowdata[r1][c1].f));
- let sparklines = new Function("return " + fp)();
- store_default.flowdata[r1][c1].spl = sparklines;
- }
- if (server_default.allowUpdate) {
- server_default.historyParam(store_default.flowdata, store_default.currentSheetIndex, range2[s]);
- }
- if (typeof store_default.chartparam.jfrefreshchartall == "function") {
- store_default.chartparam.jfrefreshchartall(store_default.flowdata, range2[s].row[0], range2[s].row[1], range2[s].column[0], range2[s].column[1]);
- }
- }
- if (isRunExecFunction) {
- runExecFunction(range2, store_default.currentSheetIndex, data);
- }
- if (isRefreshCanvas) {
- refreshCanvasTimeOut = setTimeout(function() {
- luckysheetrefreshgrid();
- }, 1);
- }
- selectHightlightShow();
- window.luckysheet_getcelldata_cache = null;
- }
- function jfrefreshgridall(colwidth, rowheight, data, cfg, range2, ctrlType, ctrlValue, cdformat, isRefreshCanvas = true) {
- let redo2 = {}, isRunExecFunction = false;
- clearTimeout(refreshCanvasTimeOut);
- if (ctrlType == "cellRowChange") {
- redo2["type"] = "cellRowChange";
- redo2["config"] = $.extend(true, {}, store_default.config);
- redo2["curconfig"] = $.extend(true, {}, cfg);
- redo2["range"] = $.extend(true, [], store_default.luckysheet_select_save);
- redo2["currange"] = range2;
- redo2["ctrlType"] = ctrlType;
- redo2["ctrlValue"] = ctrlValue;
- let setfield = cfg["rowlen"];
- if (setfield == null) {
- setfield = {};
- }
- server_default.saveParam("cg", store_default.currentSheetIndex, setfield, {"k": "rowlen"});
- } else if (ctrlType == "resizeC") {
- redo2["type"] = "resize";
- redo2["config"] = $.extend(true, {}, store_default.config);
- redo2["curconfig"] = $.extend(true, {}, cfg);
- redo2["range"] = $.extend(true, [], store_default.luckysheet_select_save);
- redo2["currange"] = range2;
- redo2["ctrlType"] = ctrlType;
- redo2["ctrlValue"] = ctrlValue;
- let setfield = cfg["columnlen"];
- if (setfield == null) {
- setfield = {};
- }
- server_default.saveParam("cg", store_default.currentSheetIndex, setfield, {"k": "columnlen"});
- } else if (ctrlType.indexOf("extend") > -1) {
- redo2["type"] = "extend";
- redo2["config"] = $.extend(true, {}, store_default.config);
- redo2["curconfig"] = $.extend(true, {}, cfg);
- redo2["range"] = $.extend(true, [], store_default.luckysheet_select_save);
- redo2["currange"] = range2;
- redo2["ctrlType"] = ctrlType;
- redo2["ctrlValue"] = ctrlValue;
- server_default.saveParam("arc", store_default.currentSheetIndex, {"index": ctrlValue.index, "len": ctrlValue.len, "direction": ctrlValue.direction, "mc": cfg.merge}, {"rc": ctrlValue.type});
- } else if (ctrlType.indexOf("dele") > -1) {
- redo2["type"] = "dele";
- redo2["config"] = $.extend(true, {}, store_default.config);
- redo2["curconfig"] = $.extend(true, {}, cfg);
- redo2["range"] = $.extend(true, [], store_default.luckysheet_select_save);
- redo2["currange"] = range2;
- redo2["ctrlType"] = ctrlType;
- redo2["ctrlValue"] = ctrlValue;
- server_default.saveParam("drc", store_default.currentSheetIndex, {"index": ctrlValue.index, "len": ctrlValue.len, "mc": cfg.merge, "borderInfo": cfg.borderInfo}, {"rc": ctrlValue.type});
- } else {
- redo2["type"] = "datachangeAll";
- redo2["range"] = $.extend(true, [], store_default.luckysheet_select_save);
- redo2["currange"] = range2;
- redo2["ctrlType"] = ctrlType;
- redo2["ctrlValue"] = ctrlValue;
- isRunExecFunction = true;
- for (let s = 0; s < range2.length; s++) {
- server_default.historyParam(data, store_default.currentSheetIndex, range2[s]);
- }
- }
- if (store_default.clearjfundo) {
- store_default.jfundo.length = 0;
- redo2["data"] = store_default.flowdata;
- redo2["curdata"] = data;
- redo2["sheetIndex"] = store_default.currentSheetIndex;
- redo2["cdformat"] = $.extend(true, [], store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)]["luckysheet_conditionformat_save"]);
- redo2["curCdformat"] = cdformat;
- store_default.jfredo.push(redo2);
- }
- store_default.flowdata = data;
- editor_default.webWorkerFlowDataCache(data);
- store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)].data = store_default.flowdata;
- if (cfg != null) {
- store_default.config = cfg;
- store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)].config = store_default.config;
- server_default.saveParam("all", store_default.currentSheetIndex, cfg, {"k": "config"});
- }
- if (cdformat != null) {
- store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)]["luckysheet_conditionformat_save"] = cdformat;
- server_default.saveParam("all", store_default.currentSheetIndex, cdformat, {"k": "luckysheet_conditionformat_save"});
- }
- store_default.luckysheet_select_save = $.extend(true, [], range2);
- if (store_default.luckysheet_select_save.length > 0) {
- selectHightlightShow();
- }
- if (isRunExecFunction) {
- runExecFunction(range2, store_default.currentSheetIndex, data);
- }
- jfrefreshgrid_rhcw(rowheight, colwidth);
- if (isRefreshCanvas) {
- refreshCanvasTimeOut = setTimeout(function() {
- luckysheetrefreshgrid();
- }, 1);
- }
- sheetmanage_default.storeSheetParamALL();
- window.luckysheet_getcelldata_cache = null;
- }
- function jfrefreshrange(data, range2, cdformat) {
- clearTimeout(refreshCanvasTimeOut);
- if (store_default.clearjfundo) {
- store_default.jfundo.length = 0;
- store_default.jfredo.push({
- "type": "rangechange",
- "data": store_default.flowdata,
- "curdata": data,
- "range": range2,
- "sheetIndex": store_default.currentSheetIndex,
- "cdformat": $.extend(true, [], store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)]["luckysheet_conditionformat_save"]),
- "curCdformat": cdformat
- });
- }
- store_default.flowdata = data;
- editor_default.webWorkerFlowDataCache(store_default.flowdata);
- store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)].data = store_default.flowdata;
- if (cdformat != null) {
- store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)]["luckysheet_conditionformat_save"] = cdformat;
- }
- runExecFunction(range2, store_default.currentSheetIndex, data);
- refreshCanvasTimeOut = setTimeout(function() {
- luckysheetrefreshgrid();
- }, 1);
- for (let s = 0; s < range2.length; s++) {
- server_default.historyParam(store_default.flowdata, store_default.currentSheetIndex, range2[s]);
- }
- }
- function jfrefreshgrid_adRC(data, cfg, ctrlType, ctrlValue, calc, filterObj, cf, af, freezen, dataVerification, hyperlink) {
- let file = store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)];
- collaborativeEditBox();
- let mcData = [];
- for (let m in cfg["merge"]) {
- let mc = cfg["merge"][m];
- for (let r2 = mc.r; r2 <= mc.r + mc.rs - 1; r2++) {
- for (let c2 = mc.c; c2 <= mc.c + mc.cs - 1; c2++) {
- if (data[r2][c2] == null) {
- data[r2][c2] = {};
- }
- if (r2 == mc.r && c2 == mc.c) {
- data[r2][c2].mc = mc;
- } else {
- data[r2][c2].mc = {"r": mc.r, "c": mc.c};
- }
- mcData.push({"r": r2, "c": c2});
- }
- }
- }
- let funcData = [];
- if (store_default.clearjfundo) {
- store_default.jfundo.length = 0;
- store_default.jfredo.push({
- "type": ctrlType,
- "sheetIndex": store_default.currentSheetIndex,
- "data": store_default.flowdata,
- "curData": data,
- "config": $.extend(true, {}, store_default.config),
- "curConfig": cfg,
- "ctrlValue": ctrlValue,
- "mcData": mcData,
- "calc": $.extend(true, [], file.calcChain),
- "curCalc": calc,
- "funcData": funcData,
- "filterObj": {"filter_select": $.extend(true, {}, file.filter_select), "filter": $.extend(true, {}, file.filter)},
- "curFilterObj": filterObj,
- "cf": $.extend(true, [], file.luckysheet_conditionformat_save),
- "curCf": cf,
- "af": $.extend(true, [], file.luckysheet_alternateformat_save),
- "curAf": af,
- "freezen": {"freezenhorizontaldata": freezen_default.freezenhorizontaldata, "freezenverticaldata": freezen_default.freezenverticaldata},
- "curFreezen": freezen,
- "dataVerification": $.extend(true, {}, file.dataVerification),
- "curDataVerification": dataVerification,
- "hyperlink": $.extend(true, {}, file.hyperlink),
- "curHyperlink": hyperlink,
- "range": file.luckysheet_select_save,
- "dataRange": [...file.luckysheet_select_save]
- });
- }
- let index2 = ctrlValue.index, len = ctrlValue.len, rc = ctrlValue.rc;
- if (ctrlType == "addRC") {
- let direction = ctrlValue.direction, restore = ctrlValue.restore;
- let addData = [];
- if (restore) {
- if (rc == "r") {
- let st_r;
- if (direction == "lefttop") {
- st_r = index2;
- } else if (direction == "rightbottom") {
- st_r = index2 + 1;
- }
- let ed_r = st_r + len - 1;
- for (let r2 = st_r; r2 <= ed_r; r2++) {
- let row = [];
- for (let c2 = 0; c2 < data[0].length; c2++) {
- let cell = data[r2][c2];
- row.push(cell);
- }
- addData.push(row);
- }
- } else if (rc == "c") {
- let st_c;
- if (direction == "lefttop") {
- st_c = index2;
- } else if (direction == "rightbottom") {
- st_c = index2 + 1;
- }
- let ed_c = st_c + len - 1;
- for (let r2 = 0; r2 < data.length; r2++) {
- let row = [];
- for (let c2 = st_c; c2 <= ed_c; c2++) {
- let cell = data[r2][c2];
- row.push(cell);
- }
- addData.push(row);
- }
- }
- }
- server_default.saveParam("arc", store_default.currentSheetIndex, {"index": index2, "len": len, "direction": direction, "data": addData}, {"rc": rc});
- } else if (ctrlType == "delRC") {
- server_default.saveParam("drc", store_default.currentSheetIndex, {"index": index2, "len": len}, {"rc": rc});
- }
- store_default.flowdata = data;
- editor_default.webWorkerFlowDataCache(store_default.flowdata);
- file.data = data;
- store_default.config = cfg;
- file.config = store_default.config;
- server_default.saveParam("all", store_default.currentSheetIndex, cfg, {"k": "config"});
- for (let i2 = 0; i2 < mcData.length; i2++) {
- let mcData_r = mcData[i2].r, mcData_c = mcData[i2].c;
- server_default.saveParam("v", store_default.currentSheetIndex, store_default.flowdata[mcData_r][mcData_c], {"r": mcData_r, "c": mcData_c});
- }
- if (calc.length > 0) {
- for (let i2 = 0; i2 < calc.length; i2++) {
- let clc = calc[i2];
- let clc_r = clc.r, clc_c = clc.c, clc_i = clc.index, clc_funcStr = getcellFormula(clc_r, clc_c, clc_i, data);
- let clc_result = formula_default.execfunction(clc_funcStr, clc_r, clc_c, clc_i, null, true);
- clc.func = clc_result;
- if (data[clc_r][clc_c].f == clc_funcStr) {
- setcellvalue(clc_r, clc_c, data, clc_result[1]);
- }
- }
- }
- file.calcChain = calc;
- server_default.saveParam("all", store_default.currentSheetIndex, calc, {"k": "calcChain"});
- for (let i2 = 0; i2 < funcData.length; i2++) {
- let funcData_r = funcData[i2].r, funcData_c = funcData[i2].c;
- server_default.saveParam("v", store_default.currentSheetIndex, store_default.flowdata[funcData_r][funcData_c], {"r": funcData_r, "c": funcData_c});
- }
- if (filterObj != null) {
- file.filter_select = filterObj.filter_select;
- file.filter = filterObj.filter;
- } else {
- file.filter_select = null;
- file.filter = null;
- }
- createFilterOptions(file.filter_select, file.filter);
- server_default.saveParam("all", store_default.currentSheetIndex, file.filter_select, {"k": "filter_select"});
- server_default.saveParam("all", store_default.currentSheetIndex, file.filter, {"k": "filter"});
- file.luckysheet_conditionformat_save = cf;
- server_default.saveParam("all", store_default.currentSheetIndex, file.luckysheet_conditionformat_save, {"k": "luckysheet_conditionformat_save"});
- file.luckysheet_alternateformat_save = af;
- server_default.saveParam("all", store_default.currentSheetIndex, file.luckysheet_alternateformat_save, {"k": "luckysheet_alternateformat_save"});
- if (freezen != null) {
- freezen_default.freezenhorizontaldata = freezen.freezenhorizontaldata;
- freezen_default.freezenverticaldata = freezen.freezenverticaldata;
- } else {
- freezen_default.freezenhorizontaldata = null;
- freezen_default.freezenverticaldata = null;
- }
- dataVerificationCtrl_default.dataVerification = dataVerification;
- file.dataVerification = dataVerification;
- server_default.saveParam("all", store_default.currentSheetIndex, file.dataVerification, {"k": "dataVerification"});
- hyperlinkCtrl_default.hyperlink = hyperlink;
- file.hyperlink = hyperlink;
- server_default.saveParam("all", store_default.currentSheetIndex, file.hyperlink, {"k": "hyperlink"});
- jfrefreshgrid_rhcw(store_default.flowdata.length, store_default.flowdata[0].length);
- }
- function jfrefreshgrid_deleteCell(data, cfg, ctrl, calc, filterObj, cf, dataVerification, hyperlink) {
- let file = store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)];
- clearTimeout(refreshCanvasTimeOut);
- collaborativeEditBox();
- let mcData = [];
- if (JSON.stringify(cfg["merge"]) == "{}") {
- for (let r2 = 0; r2 < data.length; r2++) {
- for (let c2 = 0; c2 < data[0].length; c2++) {
- let cell = data[r2][c2];
- if (cell != null && cell.mc != null) {
- delete cell.mc;
- mcData.push({"r": r2, "c": c2});
- }
- }
- }
- } else {
- for (let m in cfg["merge"]) {
- let mc = cfg["merge"][m];
- for (let r2 = mc.r; r2 <= mc.r + mc.rs - 1; r2++) {
- for (let c2 = mc.c; c2 <= mc.c + mc.cs - 1; c2++) {
- if (data[r2][c2] == null) {
- data[r2][c2] = {};
- }
- if (r2 == mc.r && c2 == mc.c) {
- if (JSON.stringify(data[r2][c2].mc) != JSON.stringify(mc)) {
- data[r2][c2].mc = mc;
- mcData.push({"r": r2, "c": c2});
- }
- } else {
- let tempMc = {"r": mc.r, "c": mc.c};
- if (JSON.stringify(data[r2][c2].mc) != JSON.stringify(tempMc)) {
- data[r2][c2].mc = tempMc;
- mcData.push({"r": r2, "c": c2});
- }
- }
- }
- }
- }
- }
- let funcData = [];
- if (store_default.clearjfundo) {
- store_default.jfundo.length = 0;
- store_default.jfredo.push({
- "type": "deleteCell",
- "sheetIndex": store_default.currentSheetIndex,
- "ctrl": ctrl,
- "data": store_default.flowdata,
- "curData": data,
- "config": $.extend(true, {}, store_default.config),
- "curConfig": cfg,
- "mcData": mcData,
- "calc": $.extend(true, [], file.calcChain),
- "curCalc": calc,
- "funcData": funcData,
- "filterObj": {"filter_select": $.extend(true, {}, file.filter_select), "filter": $.extend(true, {}, file.filter)},
- "curFilterObj": filterObj,
- "cf": $.extend(true, [], file.luckysheet_conditionformat_save),
- "curCf": cf,
- "dataVerification": $.extend(true, {}, file.dataVerification),
- "curDataVerification": dataVerification,
- "hyperlink": $.extend(true, {}, file.hyperlink),
- "curHyperlink": hyperlink,
- "range": file.luckysheet_select_save,
- "dataRange": [...file.luckysheet_select_save]
- });
- }
- store_default.flowdata = data;
- editor_default.webWorkerFlowDataCache(store_default.flowdata);
- file.data = data;
- if (server_default.allowUpdate) {
- let type = ctrl.type, str = ctrl.str, edr = ctrl.edr, stc = ctrl.stc, edc = ctrl.edc;
- let range2;
- if (type == "moveUp") {
- range2 = {
- "row": [str, data.length - 1],
- "column": [stc, edc]
- };
- } else if (type == "moveLeft") {
- range2 = {
- "row": [str, edr],
- "column": [stc, data[0].length - 1]
- };
- }
- server_default.historyParam(store_default.flowdata, store_default.currentSheetIndex, range2);
- }
- store_default.config = cfg;
- file.config = store_default.config;
- server_default.saveParam("all", store_default.currentSheetIndex, cfg, {"k": "config"});
- for (let i2 = 0; i2 < mcData.length; i2++) {
- let mcData_r = mcData[i2].r, mcData_c = mcData[i2].c;
- server_default.saveParam("v", store_default.currentSheetIndex, store_default.flowdata[mcData_r][mcData_c], {"r": mcData_r, "c": mcData_c});
- }
- if (calc.length > 0) {
- for (let i2 = 0; i2 < calc.length; i2++) {
- let clc = calc[i2];
- let clc_r = clc.r, clc_c = clc.c, clc_i = clc.index, clc_funcStr = getcellFormula(clc_r, clc_c, clc_i, data);
- let clc_result = formula_default.execfunction(clc_funcStr, clc_r, clc_c, clc_i, null, true);
- clc.func = clc_result;
- if (data[clc_r][clc_c].f == clc_funcStr) {
- setcellvalue(clc_r, clc_c, data, clc_result[1]);
- }
- }
- }
- file.calcChain = calc;
- server_default.saveParam("all", store_default.currentSheetIndex, calc, {"k": "calcChain"});
- for (let i2 = 0; i2 < funcData.length; i2++) {
- let funcData_r = funcData[i2].r, funcData_c = funcData[i2].c;
- server_default.saveParam("v", store_default.currentSheetIndex, store_default.flowdata[funcData_r][funcData_c], {"r": funcData_r, "c": funcData_c});
- }
- if (filterObj != null) {
- file.filter_select = filterObj.filter_select;
- file.filter = filterObj.filter;
- } else {
- file.filter_select = null;
- file.filter = null;
- }
- createFilterOptions(file.filter_select, file.filter);
- server_default.saveParam("all", store_default.currentSheetIndex, file.filter_select, {"k": "filter_select"});
- server_default.saveParam("all", store_default.currentSheetIndex, file.filter, {"k": "filter"});
- file.luckysheet_conditionformat_save = cf;
- server_default.saveParam("all", store_default.currentSheetIndex, file.luckysheet_conditionformat_save, {"k": "luckysheet_conditionformat_save"});
- dataVerificationCtrl_default.dataVerification = dataVerification;
- file.dataVerification = dataVerification;
- server_default.saveParam("all", store_default.currentSheetIndex, file.dataVerification, {"k": "dataVerification"});
- hyperlinkCtrl_default.hyperlink = hyperlink;
- file.hyperlink = hyperlink;
- server_default.saveParam("all", store_default.currentSheetIndex, file.hyperlink, {"k": "hyperlink"});
- refreshCanvasTimeOut = setTimeout(function() {
- luckysheetrefreshgrid();
- }, 1);
- }
- function jfrefreshgrid_pastcut(source, target, RowlChange) {
- let execF_rc = {};
- formula_default.execFunctionExist = [];
- clearTimeout(refreshCanvasTimeOut);
- for (let r2 = source["range"].row[0]; r2 <= source["range"].row[1]; r2++) {
- for (let c2 = source["range"].column[0]; c2 <= source["range"].column[1]; c2++) {
- if (r2 + "_" + c2 + "_" + source["sheetIndex"] in execF_rc) {
- continue;
- }
- execF_rc[r2 + "_" + c2 + "_" + source["sheetIndex"]] = 0;
- formula_default.execFunctionExist.push({"r": r2, "c": c2, "i": source["sheetIndex"]});
- }
- }
- for (let r2 = target["range"].row[0]; r2 <= target["range"].row[1]; r2++) {
- for (let c2 = target["range"].column[0]; c2 <= target["range"].column[1]; c2++) {
- if (r2 + "_" + c2 + "_" + target["sheetIndex"] in execF_rc) {
- continue;
- }
- execF_rc[r2 + "_" + c2 + "_" + target["sheetIndex"]] = 0;
- formula_default.execFunctionExist.push({"r": r2, "c": c2, "i": target["sheetIndex"]});
- }
- }
- if (store_default.clearjfundo) {
- store_default.jfundo.length = 0;
- store_default.jfredo.push({
- "type": "pasteCut",
- "source": source,
- "target": target,
- "RowlChange": RowlChange
- });
- }
- let rowHeight;
- if (store_default.currentSheetIndex == source["sheetIndex"]) {
- store_default.config = source["curConfig"];
- rowHeight = source["curData"].length;
- store_default.luckysheetfile[getSheetIndex(target["sheetIndex"])]["config"] = target["curConfig"];
- } else if (store_default.currentSheetIndex == target["sheetIndex"]) {
- store_default.config = target["curConfig"];
- rowHeight = target["curData"].length;
- store_default.luckysheetfile[getSheetIndex(source["sheetIndex"])]["config"] = source["curConfig"];
- }
- if (RowlChange) {
- store_default.visibledatarow = [];
- store_default.rh_height = 0;
- for (let i2 = 0; i2 < rowHeight; i2++) {
- let rowlen = store_default.defaultrowlen;
- if (store_default.config["rowlen"] != null && store_default.config["rowlen"][i2] != null) {
- rowlen = store_default.config["rowlen"][i2];
- }
- if (store_default.config["rowhidden"] != null && store_default.config["rowhidden"][i2] != null) {
- rowlen = store_default.config["rowhidden"][i2];
- store_default.visibledatarow.push(store_default.rh_height);
- continue;
- } else {
- store_default.rh_height += rowlen + 1;
- }
- store_default.visibledatarow.push(store_default.rh_height);
- }
- store_default.rh_height += 80;
- if (store_default.currentSheetIndex == source["sheetIndex"]) {
- let rowlenArr = computeRowlenArr(target["curData"].length, target["curConfig"]);
- store_default.luckysheetfile[getSheetIndex(target["sheetIndex"])]["visibledatarow"] = rowlenArr;
- } else if (store_default.currentSheetIndex == target["sheetIndex"]) {
- let rowlenArr = computeRowlenArr(source["curData"].length, source["curConfig"]);
- store_default.luckysheetfile[getSheetIndex(source["sheetIndex"])]["visibledatarow"] = rowlenArr;
- }
- }
- if (store_default.currentSheetIndex == source["sheetIndex"]) {
- store_default.flowdata = source["curData"];
- store_default.luckysheetfile[getSheetIndex(target["sheetIndex"])]["data"] = target["curData"];
- } else if (store_default.currentSheetIndex == target["sheetIndex"]) {
- store_default.flowdata = target["curData"];
- store_default.luckysheetfile[getSheetIndex(source["sheetIndex"])]["data"] = source["curData"];
- }
- editor_default.webWorkerFlowDataCache(store_default.flowdata);
- store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)].data = store_default.flowdata;
- if (store_default.currentSheetIndex == target["sheetIndex"]) {
- store_default.luckysheet_select_save = [{"row": target["range"].row, "column": target["range"].column}];
- } else {
- store_default.luckysheet_select_save = [{"row": source["range"].row, "column": source["range"].column}];
- }
- if (store_default.luckysheet_select_save.length > 0) {
- selectHightlightShow();
- }
- store_default.luckysheetfile[getSheetIndex(source["sheetIndex"])].luckysheet_conditionformat_save = source["curCdformat"];
- store_default.luckysheetfile[getSheetIndex(target["sheetIndex"])].luckysheet_conditionformat_save = target["curCdformat"];
- if (store_default.currentSheetIndex == source["sheetIndex"]) {
- dataVerificationCtrl_default.dataVerification = source["curDataVerification"];
- } else if (store_default.currentSheetIndex == target["sheetIndex"]) {
- dataVerificationCtrl_default.dataVerification = target["curDataVerification"];
- }
- store_default.luckysheetfile[getSheetIndex(source["sheetIndex"])].dataVerification = source["curDataVerification"];
- store_default.luckysheetfile[getSheetIndex(target["sheetIndex"])].dataVerification = target["curDataVerification"];
- formula_default.execFunctionExist.reverse();
- formula_default.execFunctionGroup(null, null, null, null, target["curData"]);
- formula_default.execFunctionGlobalData = null;
- let index2 = getSheetIndex(store_default.currentSheetIndex);
- let file = store_default.luckysheetfile[index2];
- file.scrollTop = $("#luckysheet-cell-main").scrollTop();
- file.scrollLeft = $("#luckysheet-cell-main").scrollLeft();
- sheetmanage_default.showSheet();
- refreshCanvasTimeOut = setTimeout(function() {
- luckysheetrefreshgrid();
- }, 1);
- sheetmanage_default.storeSheetParamALL();
- server_default.saveParam("all", source["sheetIndex"], source["curConfig"], {"k": "config"});
- server_default.saveParam("all", target["sheetIndex"], target["curConfig"], {"k": "config"});
- server_default.historyParam(source["curData"], source["sheetIndex"], {"row": source["range"]["row"], "column": source["range"]["column"]});
- server_default.historyParam(target["curData"], target["sheetIndex"], {"row": target["range"]["row"], "column": target["range"]["column"]});
- server_default.saveParam("all", source["sheetIndex"], source["curCdformat"], {"k": "luckysheet_conditionformat_save"});
- server_default.saveParam("all", target["sheetIndex"], target["curCdformat"], {"k": "luckysheet_conditionformat_save"});
- server_default.saveParam("all", source["sheetIndex"], source["curDataVerification"], {"k": "dataVerification"});
- server_default.saveParam("all", target["sheetIndex"], target["curDataVerification"], {"k": "dataVerification"});
- }
- function jfrefreshgrid_rhcw(rowheight, colwidth, isRefreshCanvas = true) {
- rhchInit(rowheight, colwidth);
- clearTimeout(refreshCanvasTimeOut);
- sheetmanage_default.storeSheetParam();
- let calcChain = store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)].calcChain;
- if (calcChain != null && calcChain.length > 0) {
- if (store_default.config["rowlen"] == null) {
- store_default.config["rowlen"] = {};
- }
- if (store_default.config["columnlen"] == null) {
- store_default.config["columnlen"] = {};
- }
- for (let i2 = 0; i2 < calcChain.length; i2++) {
- let r2 = calcChain[i2].r, c2 = calcChain[i2].c, index2 = calcChain[i2].index;
- if (index2 == store_default.currentSheetIndex && store_default.flowdata[r2][c2] != null && store_default.flowdata[r2][c2].spl != null && (r2 in store_default.config["rowlen"] || c2 in store_default.config["columnlen"])) {
- window.luckysheetCurrentRow = r2;
- window.luckysheetCurrentColumn = c2;
- window.luckysheetCurrentFunction = store_default.flowdata[r2][c2].f;
- let fp = $.trim(formula_default.functionParserExe(store_default.flowdata[r2][c2].f));
- let sparklines = new Function("return " + fp)();
- store_default.flowdata[r2][c2].spl = sparklines;
- server_default.saveParam("v", store_default.currentSheetIndex, store_default.flowdata[r2][c2], {"r": r2, "c": c2});
- }
- }
- store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)].data = store_default.flowdata;
- }
- postil_default.positionSync();
- selectHightlightShow();
- collaborativeEditBox();
- if ($(".luckysheet-selection-copy").is(":visible")) {
- selectionCopyShow();
- }
- if ($("#luckysheet-dropCell-icon").is(":visible")) {
- $("#luckysheet-dropCell-icon").remove();
- }
- if (freezen_default.freezenhorizontaldata != null && freezen_default.freezenverticaldata != null) {
- let row_st = freezen_default.freezenhorizontaldata[1] - 1;
- let col_st = freezen_default.freezenverticaldata[1] - 1;
- let scrollTop = freezen_default.freezenhorizontaldata[2];
- let scrollLeft = freezen_default.freezenverticaldata[2];
- let top = store_default.visibledatarow[row_st] - 2 - scrollTop + store_default.columnHeaderHeight;
- let freezenhorizontaldata = [
- store_default.visibledatarow[row_st],
- row_st + 1,
- scrollTop,
- freezen_default.cutVolumn(store_default.visibledatarow, row_st + 1),
- top
- ];
- let left = store_default.visibledatacolumn[col_st] - 2 - scrollLeft + store_default.rowHeaderWidth;
- let freezenverticaldata = [
- store_default.visibledatacolumn[col_st],
- col_st + 1,
- scrollLeft,
- freezen_default.cutVolumn(store_default.visibledatacolumn, col_st + 1),
- left
- ];
- freezen_default.saveFreezen(freezenhorizontaldata, top, freezenverticaldata, left);
- freezen_default.createFreezenHorizontal(freezenhorizontaldata, top);
- freezen_default.createFreezenVertical(freezenverticaldata, left);
- freezen_default.createAssistCanvas();
- } else if (freezen_default.freezenhorizontaldata != null) {
- let row_st = freezen_default.freezenhorizontaldata[1] - 1;
- let scrollTop = freezen_default.freezenhorizontaldata[2];
- let top = store_default.visibledatarow[row_st] - 2 - scrollTop + store_default.columnHeaderHeight;
- let freezenhorizontaldata = [
- store_default.visibledatarow[row_st],
- row_st + 1,
- scrollTop,
- freezen_default.cutVolumn(store_default.visibledatarow, row_st + 1),
- top
- ];
- freezen_default.saveFreezen(freezenhorizontaldata, top, null, null);
- freezen_default.createFreezenHorizontal(freezenhorizontaldata, top);
- freezen_default.createAssistCanvas();
- } else if (freezen_default.freezenverticaldata != null) {
- let col_st = freezen_default.freezenverticaldata[1] - 1;
- let scrollLeft = freezen_default.freezenverticaldata[2];
- let left = store_default.visibledatacolumn[col_st] - 2 - scrollLeft + store_default.rowHeaderWidth;
- let freezenverticaldata = [
- store_default.visibledatacolumn[col_st],
- col_st + 1,
- scrollLeft,
- freezen_default.cutVolumn(store_default.visibledatacolumn, col_st + 1),
- left
- ];
- freezen_default.saveFreezen(null, null, freezenverticaldata, left);
- freezen_default.createFreezenVertical(freezenverticaldata, left);
- freezen_default.createAssistCanvas();
- } else {
- if ($("#luckysheet-filter-options-sheet" + store_default.currentSheetIndex + " .luckysheet-filter-options").length > 0) {
- $("#luckysheet-filter-options-sheet" + store_default.currentSheetIndex + " .luckysheet-filter-options").each(function(i2, e) {
- let str = $(e).data("str"), cindex = $(e).data("cindex");
- let left = store_default.visibledatacolumn[cindex] - 20;
- let top = str - 1 == -1 ? 0 : store_default.visibledatarow[str - 1];
- $(e).css({"left": left, "top": top});
- });
- }
- }
- if ($("#luckysheet-filter-selected-sheet" + store_default.currentSheetIndex).length > 0) {
- let luckysheet_filter_save = store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)].filter_select;
- let r1 = luckysheet_filter_save.row[0], r2 = luckysheet_filter_save.row[1];
- let c1 = luckysheet_filter_save.column[0], c2 = luckysheet_filter_save.column[1];
- let row = store_default.visibledatarow[r2], row_pre = r1 - 1 == -1 ? 0 : store_default.visibledatarow[r1 - 1];
- let col = store_default.visibledatacolumn[c2], col_pre = c1 - 1 == -1 ? 0 : store_default.visibledatacolumn[c1 - 1];
- $("#luckysheet-filter-selected-sheet" + store_default.currentSheetIndex).css({
- "left": col_pre,
- "width": col - col_pre - 1,
- "top": row_pre,
- "height": row - row_pre - 1
- });
- }
- sheetmanage_default.showSheet();
- if (isRefreshCanvas) {
- refreshCanvasTimeOut = setTimeout(function() {
- luckysheetrefreshgrid();
- }, 1);
- }
- }
- function luckysheetrefreshgrid(scrollWidth, scrollHeight) {
- formula_default.groupValuesRefresh();
- if (scrollWidth == null) {
- scrollWidth = $("#luckysheet-cell-main").scrollLeft();
- }
- if (scrollHeight == null) {
- scrollHeight = $("#luckysheet-cell-main").scrollTop();
- }
- if (freezen_default.freezenverticaldata != null || freezen_default.freezenhorizontaldata != null) {
- let freezen_horizon_px, freezen_horizon_ed, freezen_horizon_scrollTop;
- let freezen_vertical_px, freezen_vertical_ed, freezen_vertical_scrollTop;
- let drawWidth = store_default.luckysheetTableContentHW[0], drawHeight = store_default.luckysheetTableContentHW[1];
- if (freezen_default.freezenverticaldata != null && freezen_default.freezenhorizontaldata != null) {
- freezen_horizon_px = freezen_default.freezenhorizontaldata[0];
- freezen_horizon_ed = freezen_default.freezenhorizontaldata[1];
- freezen_horizon_scrollTop = freezen_default.freezenhorizontaldata[2];
- freezen_vertical_px = freezen_default.freezenverticaldata[0];
- freezen_vertical_ed = freezen_default.freezenverticaldata[1];
- freezen_vertical_scrollTop = freezen_default.freezenverticaldata[2];
- luckysheetDrawMain(freezen_vertical_scrollTop, freezen_horizon_scrollTop, freezen_vertical_px, freezen_horizon_px, 1, 1, null, null, "freezen_3");
- luckysheetDrawMain(scrollWidth + freezen_vertical_px - freezen_vertical_scrollTop, freezen_horizon_scrollTop, drawWidth - freezen_vertical_px + freezen_vertical_scrollTop, freezen_horizon_px, 1, 1, null, null, "freezen_4");
- luckysheetDrawMain(freezen_vertical_scrollTop, scrollHeight + freezen_horizon_px - freezen_horizon_scrollTop, freezen_vertical_px, drawHeight - freezen_horizon_px + freezen_horizon_scrollTop, 1, 1, null, null, "freezen_7");
- luckysheetDrawMain(scrollWidth + freezen_vertical_px - freezen_vertical_scrollTop, scrollHeight + freezen_horizon_px - freezen_horizon_scrollTop, drawWidth - freezen_vertical_px + freezen_vertical_scrollTop, drawHeight - freezen_horizon_px + freezen_horizon_scrollTop, freezen_vertical_px - freezen_vertical_scrollTop + store_default.rowHeaderWidth, freezen_horizon_px - freezen_horizon_scrollTop + store_default.columnHeaderHeight);
- luckysheetDrawgridColumnTitle(freezen_vertical_scrollTop, freezen_vertical_px, store_default.rowHeaderWidth);
- luckysheetDrawgridColumnTitle(scrollWidth + freezen_vertical_px - freezen_vertical_scrollTop, drawWidth - freezen_vertical_px + freezen_vertical_scrollTop, freezen_vertical_px - freezen_vertical_scrollTop + store_default.rowHeaderWidth);
- luckysheetDrawgridRowTitle(freezen_horizon_scrollTop, freezen_horizon_px, store_default.columnHeaderHeight);
- luckysheetDrawgridRowTitle(scrollHeight + freezen_horizon_px - freezen_horizon_scrollTop, drawHeight - freezen_horizon_px + freezen_horizon_scrollTop, freezen_horizon_px - freezen_horizon_scrollTop + store_default.columnHeaderHeight);
- } else if (freezen_default.freezenhorizontaldata != null) {
- freezen_horizon_px = freezen_default.freezenhorizontaldata[0];
- freezen_horizon_ed = freezen_default.freezenhorizontaldata[1];
- freezen_horizon_scrollTop = freezen_default.freezenhorizontaldata[2];
- luckysheetDrawMain(scrollWidth, freezen_horizon_scrollTop, drawWidth, freezen_horizon_px, 1, 1, null, null, "freezen_h");
- luckysheetDrawMain(scrollWidth, scrollHeight + freezen_horizon_px - freezen_horizon_scrollTop, drawWidth, drawHeight - freezen_horizon_px + freezen_horizon_scrollTop, null, freezen_horizon_px - freezen_horizon_scrollTop + store_default.columnHeaderHeight);
- luckysheetDrawgridColumnTitle(scrollWidth, drawWidth, null);
- luckysheetDrawgridRowTitle(freezen_horizon_scrollTop, freezen_horizon_px, store_default.columnHeaderHeight);
- luckysheetDrawgridRowTitle(scrollHeight + freezen_horizon_px - freezen_horizon_scrollTop, drawHeight - freezen_horizon_px + freezen_horizon_scrollTop, freezen_horizon_px - freezen_horizon_scrollTop + store_default.columnHeaderHeight);
- } else if (freezen_default.freezenverticaldata != null) {
- freezen_vertical_px = freezen_default.freezenverticaldata[0];
- freezen_vertical_ed = freezen_default.freezenverticaldata[1];
- freezen_vertical_scrollTop = freezen_default.freezenverticaldata[2];
- luckysheetDrawMain(freezen_vertical_scrollTop, scrollHeight, freezen_vertical_px, drawHeight, 1, 1, null, null, "freezen_v");
- luckysheetDrawMain(scrollWidth + freezen_vertical_px - freezen_vertical_scrollTop, scrollHeight, drawWidth - freezen_vertical_px + freezen_vertical_scrollTop, drawHeight, freezen_vertical_px - freezen_vertical_scrollTop + store_default.rowHeaderWidth, null);
- luckysheetDrawgridRowTitle(scrollHeight, drawHeight, null);
- luckysheetDrawgridColumnTitle(freezen_vertical_scrollTop, freezen_vertical_px, store_default.rowHeaderWidth);
- luckysheetDrawgridColumnTitle(scrollWidth + freezen_vertical_px - freezen_vertical_scrollTop, drawWidth - freezen_vertical_px + freezen_vertical_scrollTop, freezen_vertical_px - freezen_vertical_scrollTop + store_default.rowHeaderWidth);
- }
- } else {
- if ($("#luckysheetTableContent").length == 0) {
- return;
- }
- let luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d");
- luckysheetDrawMain(scrollWidth, scrollHeight);
- luckysheetDrawgridColumnTitle(scrollWidth);
- luckysheetDrawgridRowTitle(scrollHeight);
- luckysheetTableContent.clearRect(0, 0, store_default.rowHeaderWidth * store_default.devicePixelRatio - 1, store_default.columnHeaderHeight * store_default.devicePixelRatio - 1);
- }
- }
- var refreshCanvasTimeOut;
- var init_refresh = __esm({
- "src/global/refresh.js"() {
- init_rhchInit();
- init_formula();
- init_editor();
- init_setdata();
- init_getdata();
- init_getRowlen();
- init_draw();
- init_freezen();
- init_server();
- init_sheetmanage();
- init_postil();
- init_dataVerificationCtrl();
- init_hyperlinkCtrl();
- init_select();
- init_filter();
- init_get();
- init_store();
- refreshCanvasTimeOut = null;
- }
- });
-
- // src/controllers/imageUpdateCtrl.js
- function customImageUpdate(method3, url, obj) {
- return new Promise((resolve, reject) => {
- const xhr = new XMLHttpRequest() || new ActiveXObject("Microsoft.XMLHTTP");
- xhr.open(method3, url);
- xhr.send(JSON.stringify(obj));
- xhr.onreadystatechange = function() {
- if (xhr.readyState == 4) {
- if (xhr.status == 200) {
- resolve(xhr.responseText);
- } else {
- reject("error");
- }
- }
- };
- });
- }
- var init_imageUpdateCtrl = __esm({
- "src/controllers/imageUpdateCtrl.js"() {
- }
- });
-
- // src/controllers/server.js
- var import_pako, import_dayjs3, server, server_default;
- var init_server = __esm({
- "src/controllers/server.js"() {
- import_pako = __toModule(require_pako());
- init_loading();
- init_refresh();
- init_editor();
- init_constant();
- init_sheetmanage();
- init_menuButton();
- init_filter();
- init_freezen();
- init_postil();
- init_imageCtrl();
- init_dataVerificationCtrl();
- init_hyperlinkCtrl();
- init_util();
- init_get();
- init_store();
- init_select();
- init_locale();
- import_dayjs3 = __toModule(require_dayjs_min());
- init_json();
- init_luckysheetConfigsetting();
- init_imageUpdateCtrl();
- init_method();
- server = {
- gridKey: null,
- loadUrl: null,
- updateUrl: null,
- updateImageUrl: null,
- title: null,
- loadSheetUrl: null,
- retryTimer: null,
- allowUpdate: false,
- historyParam: function(data, sheetIndex, range2) {
- let _this2 = this;
- let r1 = range2.row[0], r2 = range2.row[1];
- let c1 = range2.column[0], c2 = range2.column[1];
- if (r1 == r2 && c1 == c2) {
- let v = data[r1][c1];
- _this2.saveParam("v", sheetIndex, v, {"r": r1, "c": c1});
- } else {
- let rowlen = r2 - r1 + 1;
- let collen = c2 - c1 + 1;
- let timeR = Math.floor(1e3 / collen);
- let n = Math.ceil(rowlen / timeR);
- for (let i2 = 0; i2 < n; i2++) {
- let str = r1 + timeR * i2;
- let edr;
- if (i2 == n - 1) {
- edr = r2;
- } else {
- edr = r1 + timeR * (i2 + 1) - 1;
- }
- let v = [];
- for (let r3 = str; r3 <= edr; r3++) {
- let v_row = [];
- for (let c3 = c1; c3 <= c2; c3++) {
- if (data[r3] == null) {
- v_row.push(null);
- } else {
- v_row.push(data[r3][c3]);
- }
- }
- v.push(v_row);
- }
- _this2.saveParam("rv", sheetIndex, v, {"range": {"row": [str, edr], "column": [c1, c2]}});
- if (i2 == n - 1) {
- _this2.saveParam("rv_end", sheetIndex, null);
- }
- }
- }
- },
- saveParam: function(type, index2, value, params) {
- let _this2 = this;
- if (!_this2.allowUpdate) {
- return;
- }
- if (value == void 0) {
- value = null;
- }
- let d = {};
- d.t = type;
- d.i = index2;
- d.v = value;
- if (type === "shs") {
- return;
- }
- if (type == "rv") {
- d.range = params.range;
- } else if (type == "v" || type == "fu" || type == "fm") {
- d.r = params.r;
- d.c = params.c;
- } else if (type == "fc") {
- d.op = params.op;
- d.pos = params.pos;
- } else if (type == "drc" || type == "arc" || type == "h" || type == "wh") {
- d.rc = params.rc;
- } else if (type == "c") {
- d.cid = params.cid;
- d.op = params.op;
- } else if (type == "f") {
- d.op = params.op;
- d.pos = params.pos;
- } else if (type == "s") {
- } else if (type == "sh") {
- d.op = params.op;
- if (params.cur != null) {
- d.cur = params.cur;
- }
- } else if (type == "cg") {
- d.k = params.k;
- } else if (type == "all") {
- d.k = params.k;
- }
- const customImageUpdateMethodConfig = luckysheetConfigsetting_default.imageUpdateMethodConfig;
- if (JSON.stringify(customImageUpdateMethodConfig) !== "{}") {
- if (d.k != "images") {
- let msg = import_pako.default.gzip(encodeURIComponent(JSON.stringify(d)), {to: "string"});
- if (_this2.websocket != null) {
- _this2.websocket.send(msg);
- }
- } else {
- customImageUpdate(customImageUpdateMethodConfig.method, customImageUpdateMethodConfig.url, d).then((data) => {
- console.log(data);
- }).catch((err) => {
- console.log(err);
- });
- }
- } else {
- let msg = import_pako.default.gzip(encodeURIComponent(JSON.stringify(d)), {to: "string"});
- if (_this2.websocket != null) {
- _this2.websocket.send(msg);
- }
- }
- },
- websocket: null,
- wxErrorCount: 0,
- openWebSocket: function() {
- let _this2 = this;
- if ("WebSocket" in window) {
- let wxUrl = _this2.updateUrl + "?t=111&g=" + encodeURIComponent(_this2.gridKey);
- if (_this2.updateUrl.indexOf("?") > -1) {
- wxUrl = _this2.updateUrl + "&t=111&g=" + encodeURIComponent(_this2.gridKey);
- }
- _this2.websocket = new WebSocket(wxUrl);
- _this2.websocket.onopen = function() {
- console.info(locale_default().websocket.success);
- hideloading();
- _this2.wxErrorCount = 0;
- _this2.retryTimer = setInterval(function() {
- _this2.websocket.send("rub");
- }, 6e4);
- };
- _this2.websocket.onmessage = function(result) {
- store_default.result = result;
- let data = new Function("return " + result.data)();
- method_default.createHookFunction("cooperativeMessage", data);
- console.info(data);
- let type = data.type;
- let {message, id} = data;
- if (message === "\u7528\u6237\u9000\u51FA") {
- $("#luckysheet-multipleRange-show-" + id).hide();
- store_default.cooperativeEdit.changeCollaborationSize = store_default.cooperativeEdit.changeCollaborationSize.filter((value) => {
- return value.id != id;
- });
- store_default.cooperativeEdit.checkoutData = store_default.cooperativeEdit.checkoutData.filter((value) => {
- return value.id != id;
- });
- }
- if (type == 1) {
- const oldIndex = data.data.v.index;
- const sheetToUpdate = store_default.luckysheetfile.filter((sheet) => sheet.index === oldIndex)[0];
- if (sheetToUpdate !== null) {
- setTimeout(() => {
- const index2 = data.data.i;
- sheetToUpdate.index = index2;
- store_default.currentSheetIndex = index2;
- $(`#luckysheet-sheets-item${oldIndex}`).attr("data-index", index2);
- $(`#luckysheet-sheets-item${oldIndex}`).prop("id", `luckysheet-sheets-item${index2}`);
- $(`#luckysheet-datavisual-selection-set-${oldIndex}`).prop("id", `luckysheet-datavisual-selection-set-${index2}`);
- }, 1);
- }
- } else if (type == 2) {
- let item2 = JSON.parse(data.data);
- _this2.wsUpdateMsg(item2);
- let chang_data = JSON.parse(data.data);
- if (chang_data.k == "columnlen") {
- collaborativeEditBox(chang_data.v, null);
- } else if (chang_data.k == "rowlen") {
- collaborativeEditBox(null, chang_data.v);
- }
- } else if (type == 3) {
- let id2 = data.id;
- let username = data.username;
- let item2 = JSON.parse(data.data);
- let type2 = item2.t, index2 = item2.i, value = item2.v;
- if (store_default.cooperativeEdit.changeCollaborationSize.length === 0) {
- store_default.cooperativeEdit.changeCollaborationSize.push({id: id2, v: item2.v[0], i: index2});
- }
- let flag = store_default.cooperativeEdit.changeCollaborationSize.some((value1) => {
- return value1.id == id2;
- });
- if (flag) {
- store_default.cooperativeEdit.changeCollaborationSize.forEach((val) => {
- if (val.id == id2) {
- val.v = item2.v[0] || item2.range[0];
- val.i = index2;
- }
- });
- } else {
- store_default.cooperativeEdit.changeCollaborationSize.push({id: id2, v: item2.v[0], i: index2});
- }
- if (getObjType(value) != "array" && getObjType(value) !== "object") {
- value = JSON.parse(value);
- }
- let r2 = 0;
- let c2 = 0;
- if (index2 == store_default.currentSheetIndex) {
- if (getObjType(value) === "object" && value.op === "enterEdit") {
- r2 = value.range[value.range.length - 1].row[0];
- c2 = value.range[value.range.length - 1].column[0];
- _this2.multipleRangeShow(id2, username, r2, c2, value.op);
- } else {
- r2 = value[value.length - 1].row[0];
- c2 = value[value.length - 1].column[0];
- _this2.multipleRangeShow(id2, username, r2, c2);
- }
- } else {
- if (getObjType(value) === "object" && value.op === "enterEdit") {
- r2 = value.range[value.range.length - 1].row[0];
- c2 = value.range[value.range.length - 1].column[0];
- } else {
- r2 = value[value.length - 1].row[0];
- c2 = value[value.length - 1].column[0];
- }
- }
- if (store_default.cooperativeEdit.checkoutData.length === 0) {
- if (value.op) {
- store_default.cooperativeEdit.checkoutData.push({id: id2, username, r: r2, c: c2, op: value.op, index: index2});
- } else {
- store_default.cooperativeEdit.checkoutData.push({id: id2, username, r: r2, c: c2, index: index2});
- }
- }
- let checkoutFlag = store_default.cooperativeEdit.checkoutData.some((item3) => {
- return item3.id == id2;
- });
- if (checkoutFlag) {
- store_default.cooperativeEdit.checkoutData.forEach((item3) => {
- if (item3.id == id2) {
- item3.username = username;
- item3.r = r2;
- item3.c = c2;
- item3.index = index2;
- if (value.op === "enterEdit") {
- item3.op = value.op;
- }
- }
- });
- } else {
- if (value.op === "enterEdit") {
- store_default.cooperativeEdit.checkoutData.push({id: id2, username, r: r2, c: c2, op: value.op, index: index2});
- } else {
- store_default.cooperativeEdit.checkoutData.push({id: id2, username, r: r2, c: c2, index: index2});
- }
- }
- store_default.cooperativeEdit.checkoutData.forEach((item3) => {
- if (item3.index != store_default.currentSheetIndex) {
- $("#luckysheet-multipleRange-show-" + item3.id).hide();
- item3.op == "";
- }
- });
- if ($("#luckysheet-multipleRange-show-" + id2)[0]) {
- let change_bottom = $("#luckysheet-multipleRange-show-" + id2)[0].offsetHeight - 1;
- $("#luckysheet-multipleRange-show-" + id2 + ">.username").css({"bottom": change_bottom + "px"});
- }
- } else if (type == 4) {
- let items = data.data === "" ? data.data : JSON.parse(data.data);
- for (let i2 = 0; i2 < items.length; i2++) {
- _this2.wsUpdateMsg(item[i2]);
- }
- } else if (type == 5) {
- showloading(data.data);
- } else if (type == 6) {
- hideloading();
- }
- };
- _this2.websocket.onerror = function() {
- _this2.wxErrorCount++;
- if (_this2.wxErrorCount > 3) {
- showloading(locale_default().websocket.refresh);
- } else {
- showloading(locale_default().websocket.wait);
- _this2.openWebSocket();
- }
- };
- _this2.websocket.onclose = function(e) {
- console.info(locale_default().websocket.close);
- if (e.code === 1e3) {
- clearInterval(_this2.retryTimer);
- _this2.retryTimer = null;
- } else {
- alert(locale_default().websocket.contact);
- }
- };
- } else {
- alert(locale_default().websocket.support);
- }
- },
- wsUpdateMsg: function(item2) {
- let type = item2.t, index2 = item2.i, value = item2.v;
- let file = store_default.luckysheetfile[getSheetIndex(index2)];
- if (["v", "rv", "cg", "all", "fc", "drc", "arc", "f", "fsc", "fsr", "sh", "c"].includes(type) && file == null) {
- return;
- }
- if (type == "v") {
- if (file.data == null || file.data.length == 0) {
- return;
- }
- let r2 = item2.r, c2 = item2.c;
- file.data[r2][c2] = value;
- if (index2 == store_default.currentSheetIndex) {
- store_default.flowdata = file.data;
- editor_default.webWorkerFlowDataCache(store_default.flowdata);
- if (value != null && value.ps != null) {
- postil_default.buildPs(r2, c2, value.ps);
- } else {
- postil_default.buildPs(r2, c2, null);
- }
- setTimeout(function() {
- luckysheetrefreshgrid();
- }, 1);
- }
- } else if (type == "rv") {
- if (Object.keys(item2.range).length > 0) {
- store_default.cooperativeEdit.merge_range = item2.range;
- store_default.cooperativeEdit.merge_range.v = item2.v;
- collaborativeEditBox();
- }
- if (file.data == null || file.data.length == 0) {
- return;
- }
- let r1 = item2.range.row[0], r2 = item2.range.row[1];
- let c1 = item2.range.column[0], c2 = item2.range.column[1];
- for (let r3 = r1; r3 <= r2; r3++) {
- for (let c3 = c1; c3 <= c2; c3++) {
- file.data[r3][c3] = value[r3 - r1][c3 - c1];
- }
- }
- if (index2 == store_default.currentSheetIndex) {
- store_default.flowdata = file.data;
- editor_default.webWorkerFlowDataCache(store_default.flowdata);
- for (let r3 = r1; r3 <= r2; r3++) {
- for (let c3 = c1; c3 <= c2; c3++) {
- if (value[r3 - r1][c3 - c1] != null && value[r3 - r1][c3 - c1].ps != null) {
- postil_default.buildPs(r3, c3, value[r3 - r1][c3 - c1].ps);
- } else {
- postil_default.buildPs(r3, c3, null);
- }
- }
- }
- setTimeout(function() {
- luckysheetrefreshgrid();
- }, 1);
- }
- } else if (type == "cg") {
- let k = item2.k;
- if (k == "borderInfo") {
- file["config"]["borderInfo"] = value;
- } else {
- if (!(k in file["config"])) {
- file["config"][k] = {};
- }
- if (value && typeof value == "object") {
- file["config"][k] = value;
- }
- }
- if (index2 == store_default.currentSheetIndex) {
- store_default.config = file["config"];
- if (k == "rowlen" || k == "columnlen" || k == "rowhidden") {
- jfrefreshgrid_rhcw(store_default.flowdata.length, store_default.flowdata[0].length);
- }
- setTimeout(function() {
- luckysheetrefreshgrid();
- }, 1);
- }
- } else if (type == "all") {
- let k = item2.k;
- file[k] = value;
- if (k == "name") {
- $("#luckysheet-sheet-container-c #luckysheet-sheets-item" + index2).find("span.luckysheet-sheets-item-name").html(value);
- } else if (k == "color") {
- let currentSheetItem = $("#luckysheet-sheet-container-c #luckysheet-sheets-item" + index2);
- currentSheetItem.find(".luckysheet-sheets-item-color").remove();
- if (value != null || value != "") {
- currentSheetItem.append('
');
- }
- } else if (k == "pivotTable") {
- } else if (k == "frozen") {
- freezen_default.frozenTofreezen();
- if (index2 == store_default.currentSheetIndex) {
- const _locale = locale_default();
- const locale_freezen = _locale.freezen;
- if (file["freezen"].horizontal == null) {
- $("#luckysheet-freezen-btn-horizontal").html('
' + locale_freezen.freezenRow);
- freezen_default.freezenhorizontaldata = null;
- $("#luckysheet-freezebar-horizontal").hide();
- } else {
- freezen_default.createFreezenHorizontal(file["freezen"].horizontal.freezenhorizontaldata, file["freezen"].horizontal.top);
- }
- if (file["freezen"].vertical == null) {
- $("#luckysheet-freezen-btn-vertical").html('
' + locale_freezen.freezenColumn);
- freezen_default.freezenverticaldata = null;
- $("#luckysheet-freezebar-vertical").hide();
- } else {
- freezen_default.createFreezenVertical(file["freezen"].vertical.freezenverticaldata, file["freezen"].vertical.left);
- }
- freezen_default.createAssistCanvas();
- setTimeout(function() {
- luckysheetrefreshgrid();
- }, 1);
- }
- } else if (k == "filter_select") {
- if (index2 == store_default.currentSheetIndex) {
- createFilterOptions(value);
- }
- } else if (k == "filter") {
- if (index2 == store_default.currentSheetIndex) {
- createFilterOptions(file.filter_select, value);
- }
- } else if (k == "luckysheet_conditionformat_save") {
- if (index2 == store_default.currentSheetIndex) {
- setTimeout(function() {
- luckysheetrefreshgrid();
- }, 1);
- }
- } else if (k == "luckysheet_alternateformat_save") {
- if (index2 == store_default.currentSheetIndex) {
- setTimeout(function() {
- luckysheetrefreshgrid();
- }, 1);
- }
- } else if (k == "config") {
- if (index2 == store_default.currentSheetIndex) {
- store_default.config = value;
- jfrefreshgrid_rhcw(store_default.flowdata.length, store_default.flowdata[0].length);
- }
- } else if (k == "dynamicArray") {
- if (index2 == store_default.currentSheetIndex) {
- setTimeout(function() {
- luckysheetrefreshgrid();
- }, 1);
- }
- } else if (k == "images") {
- if (index2 == store_default.currentSheetIndex) {
- imageCtrl_default.images = value;
- imageCtrl_default.allImagesShow();
- imageCtrl_default.init();
- }
- } else if (k == "dataVerification") {
- if (index2 == store_default.currentSheetIndex) {
- dataVerificationCtrl_default.dataVerification = value;
- dataVerificationCtrl_default.init();
- }
- } else if (k == "hyperlink") {
- if (index2 == store_default.currentSheetIndex) {
- hyperlinkCtrl_default.hyperlink = value;
- hyperlinkCtrl_default.init();
- }
- }
- } else if (type == "fc") {
- let op = item2.op, pos = item2.pos;
- if (getObjType(value) != "object") {
- value = new Function("return " + value)();
- }
- let r2 = value.r, c2 = value.c;
- let calcChain = file["calcChain"] == null ? [] : file["calcChain"];
- if (op == "add") {
- calcChain.push(value);
- } else if (op == "del") {
- for (let a = 0; a < calcChain.length; a++) {
- if (r2 == calcChain[a].r && c2 == calcChain[a].c && index2 == calcChain[a].index) {
- calcChain.splice(a, 1);
- }
- }
- }
- setTimeout(function() {
- luckysheetrefreshgrid();
- }, 1);
- } else if (type == "drc") {
- if (file.data == null || file.data.length == 0) {
- return;
- }
- let rc = item2.rc, st_i = value.index, len = value.len, mc = value.mc, borderInfo = value.borderInfo;
- let data = file.data;
- if (rc == "r") {
- file["row"] -= len;
- data.splice(st_i, len);
- let row = [];
- for (let c2 = 0; c2 < data[0].length; c2++) {
- row.push(null);
- }
- for (let r2 = 0; r2 < len; r2++) {
- data.push(row);
- }
- } else {
- file["column"] -= len;
- let addcol = [];
- for (let r2 = 0; r2 < len; r2++) {
- addcol.push(null);
- }
- for (let i2 = 0; i2 < data.length; i2++) {
- data[i2].splice(st_i, len);
- data[i2] = data[i2].concat(addcol);
- }
- }
- for (let x in mc) {
- let r2 = mc[x].r, c2 = mc[x].c;
- data[r2][c2].mc = mc[x];
- }
- file["config"].merge = mc;
- file["config"].borderInfo = borderInfo;
- if (index2 == store_default.currentSheetIndex) {
- store_default.flowdata = data;
- editor_default.webWorkerFlowDataCache(store_default.flowdata);
- store_default.config["merge"] = mc;
- store_default.config["borderInfo"] = borderInfo;
- setTimeout(function() {
- luckysheetrefreshgrid();
- }, 1);
- }
- } else if (type == "arc") {
- if (file.data == null || file.data.length == 0) {
- return;
- }
- let rc = item2.rc, st_i = value.index, len = value.len, addData = value.data, direction = value.direction, mc = value.mc, borderInfo = value.borderInfo;
- let data = $.extend(true, [], file.data);
- if (rc == "r") {
- file["row"] += len;
- let row = [];
- for (let c2 = 0; c2 < data[0].length; c2++) {
- row.push(null);
- }
- let arr = [];
- for (let i2 = 0; i2 < len; i2++) {
- if (addData[i2] == null) {
- arr.push(JSON.stringify(row));
- } else {
- arr.push(JSON.stringify(addData[i2]));
- }
- }
- if (direction == "lefttop") {
- if (st_i == 0) {
- new Function("data", "return data.unshift(" + arr.join(",") + ")")(data);
- } else {
- new Function("data", "return data.splice(" + st_i + ", 0, " + arr.join(",") + ")")(data);
- }
- } else {
- new Function("data", "return data.splice(" + (st_i + 1) + ", 0, " + arr.join(",") + ")")(data);
- }
- } else {
- file["column"] += len;
- for (let i2 = 0; i2 < data.length; i2++) {
- for (let j = 0; j < len; j++) {
- if (direction == "lefttop") {
- data[i2].splice(st_i, 0, addData[j]);
- } else {
- data[i2].splice(st_i + 1, 0, addData[j]);
- }
- }
- }
- }
- for (let x in mc) {
- let r2 = mc[x].r, c2 = mc[x].c;
- data[r2][c2].mc = mc[x];
- }
- file.data = data;
- file["config"].merge = mc;
- file["config"].borderInfo = borderInfo;
- if (index2 == store_default.currentSheetIndex) {
- store_default.flowdata = data;
- editor_default.webWorkerFlowDataCache(store_default.flowdata);
- store_default.config["merge"] = mc;
- store_default.config["borderInfo"] = borderInfo;
- setTimeout(function() {
- luckysheetrefreshgrid();
- }, 1);
- }
- } else if (type == "f") {
- let op = item2.op, pos = item2.pos;
- let filter = file.filter;
- if (filter == null) {
- filter = {};
- }
- if (op == "upOrAdd") {
- filter[pos] = value;
- } else if (op == "del") {
- delete filter[pos];
- }
- if (index2 == store_default.currentSheetIndex) {
- createFilterOptions(file.filter_select, filter);
- }
- } else if (type == "fsc") {
- file.filter = null;
- file.filter_select = null;
- if (index2 == store_default.currentSheetIndex) {
- $("#luckysheet-filter-selected-sheet" + store_default.currentSheetIndex + ", #luckysheet-filter-options-sheet" + store_default.currentSheetIndex).remove();
- $("#luckysheet-filter-menu, #luckysheet-filter-submenu").hide();
- }
- } else if (type == "fsr") {
- file.filter = value.filter;
- file.filter_select = value.filter_select;
- if (index2 == store_default.currentSheetIndex) {
- createFilterOptions(file.filter_select, file.filter);
- }
- } else if (type == "sha") {
- store_default.luckysheetfile.push(value);
- let colorset = "";
- if (value.color != null) {
- colorset = '
';
- }
- $("#luckysheet-sheet-container-c").append(replaceHtml(sheetHTML, {"index": value.index, "active": "", "name": value.name, "style": "", "colorset": colorset}));
- $("#luckysheet-cell-main").append('
');
- sheetmanage_default.locationSheet();
- } else if (type == "shc") {
- let copyindex = value.copyindex, name2 = value.name;
- let copyarrindex = getSheetIndex(copyindex);
- let copyjson = $.extend(true, {}, store_default.luckysheetfile[copyarrindex]);
- copyjson.index = index2;
- copyjson.name = name2;
- store_default.luckysheetfile.splice(copyarrindex + 1, 0, copyjson);
- let copyobject = $("#luckysheet-sheets-item" + copyindex);
- $("#luckysheet-sheet-container-c").append(replaceHtml(sheetHTML, {"index": copyjson.index, "active": "", "name": copyjson.name, "style": "", "colorset": ""}));
- $("#luckysheet-sheets-item" + copyjson.index).insertAfter(copyobject);
- $("#luckysheet-cell-main").append('
');
- } else if (type == "shd") {
- for (let i2 = 0; i2 < store_default.luckysheetfile.length; i2++) {
- if (store_default.luckysheetfile[i2].index == value.deleIndex) {
- if (store_default.currentSheetIndex === value.deleIndex) {
- const index3 = value.deleIndex;
- store_default.luckysheetfile[sheetmanage_default.getSheetIndex(index3)].hide = 1;
- let luckysheetcurrentSheetitem2 = $("#luckysheet-sheets-item" + index3);
- luckysheetcurrentSheetitem2.hide();
- $("#luckysheet-sheet-area div.luckysheet-sheets-item").removeClass("luckysheet-sheets-item-active");
- let indicator = luckysheetcurrentSheetitem2.nextAll(":visible");
- if (luckysheetcurrentSheetitem2.nextAll(":visible").length > 0) {
- indicator = indicator.eq(0).data("index");
- } else {
- indicator = luckysheetcurrentSheetitem2.prevAll(":visible").eq(0).data("index");
- }
- $("#luckysheet-sheets-item" + indicator).addClass("luckysheet-sheets-item-active");
- sheetmanage_default.changeSheetExec(indicator);
- }
- server.sheetDeleSave.push(store_default.luckysheetfile[i2]);
- store_default.luckysheetfile.splice(i2, 1);
- break;
- }
- }
- $("#luckysheet-sheets-item" + value.deleIndex).remove();
- $("#luckysheet-datavisual-selection-set-" + value.deleIndex).remove();
- sheetmanage_default.locationSheet();
- } else if (type == "shr") {
- for (let x in value) {
- store_default.luckysheetfile[getSheetIndex(x)].order = value[x];
- }
- } else if (type == "shre") {
- for (let i2 = 0; i2 < server.sheetDeleSave.length; i2++) {
- if (server.sheetDeleSave[i2].index == value.reIndex) {
- let datav = server.sheetDeleSave[i2];
- store_default.luckysheetfile.push(datav);
- let colorset = "";
- if (value.color != null) {
- colorset = '
';
- }
- $("#luckysheet-sheet-container-c").append(replaceHtml(sheetHTML, {"index": datav.index, "active": "", "name": datav.name, "style": "", "colorset": colorset}));
- $("#luckysheet-cell-main").append('
');
- break;
- }
- }
- } else if (type == "sh") {
- let op = item2.op, cur = item2.cur;
- if (op == "hide") {
- file.hide = 1;
- $("#luckysheet-sheets-item" + index2).hide();
- if (index2 == store_default.currentSheetIndex) {
- $("#luckysheet-sheets-item" + cur).addClass("luckysheet-sheets-item-active");
- sheetmanage_default.changeSheetExec(cur);
- }
- } else if (op == "show") {
- file.hide = 0;
- $("#luckysheet-sheets-item" + index2).show();
- }
- sheetmanage_default.locationSheet();
- } else if (type == "c") {
- let op = item2.op, cid = item2.cid;
- if (op == "add") {
- file.chart.push(value);
- luckysheet.insertChartTosheet(value.sheetIndex, value.dataSheetIndex, value.option, value.chartType, value.selfOption, value.defaultOption, value.row, value.column, value.chart_selection_color, value.chart_id, value.chart_selection_id, value.chartStyle, value.rangeConfigCheck, value.rangeRowCheck, value.rangeColCheck, value.chartMarkConfig, value.chartTitleConfig, value.winWidth, value.winHeight, value.scrollLeft1, value.scrollTop1, value.chartTheme, value.myWidth, value.myHeight, value.myLeft, value.myTop, value.myindexrank1, true);
- } else if (op == "xy" || op == "wh" || op == "update") {
- for (let i2 = 0; i2 < file.chart.length; i2++) {
- let chartjson = file.chart[i2];
- if (chartjson.chart_id == cid) {
- for (let item3 in chartjson) {
- for (let vitem in value) {
- if (item3 == vitem) {
- chartjson[item3] = value[vitem];
- }
- }
- }
- sheetmanage_default.saveChart(chartjson);
- return;
- }
- }
- } else if (op == "del") {
- for (let i2 = 0; i2 < file.chart.length; i2++) {
- let chartjson = file.chart[i2];
- if (chartjson.chart_id == cid) {
- file.chart.splice(i2, 1);
- $("#" + cid).remove();
- sheetmanage_default.delChart($("#" + cid).attr("chart_id"), $("#" + cid).attr("sheetIndex"));
- return;
- }
- }
- }
- } else if (type == "na") {
- $("#luckysheet_info_detail_input").val(value).css("width", getByteLen(value) * 10);
- }
- },
- multipleIndex: 0,
- multipleRangeShow: function(id, name2, r2, c2, value) {
- let _this2 = this;
- const fullName = name2;
- let row = store_default.visibledatarow[r2], row_pre = r2 - 1 == -1 ? 0 : store_default.visibledatarow[r2 - 1], col = store_default.visibledatacolumn[c2], col_pre = c2 - 1 == -1 ? 0 : store_default.visibledatacolumn[c2 - 1];
- let margeset = menuButton_default.mergeborer(store_default.flowdata, r2, c2);
- if (!!margeset) {
- row = margeset.row[1];
- row_pre = margeset.row[0];
- col = margeset.column[1];
- col_pre = margeset.column[0];
- }
- if (col_pre <= 0) {
- col_pre += 1;
- }
- if (row_pre <= 0) {
- row_pre += 1;
- }
- if (getByteLen(name2) > 16) {
- name2 = getByteLen(name2, 16) + "...";
- }
- if (value === "enterEdit") {
- name2 += " " + locale_default().edit.typing;
- }
- if ($("#luckysheet-multipleRange-show-" + id).length > 0) {
- $("#luckysheet-multipleRange-show-" + id).css({"position": "absolute", "left": col_pre - 1, "width": col - col_pre - 1, "top": row_pre - 1, "height": row - row_pre - 1});
- $("#luckysheet-multipleRange-show-" + id + " .username").text(name2);
- $("#luckysheet-multipleRange-show-" + id + " .username").show();
- if (store_default.cooperativeEdit.usernameTimeout["user" + id] != null) {
- clearTimeout(store_default.cooperativeEdit.usernameTimeout["user" + id]);
- }
- store_default.cooperativeEdit.usernameTimeout["user" + id] = setTimeout(() => {
- clearTimeout(store_default.cooperativeEdit.usernameTimeout["user" + id]);
- store_default.cooperativeEdit.usernameTimeout["user" + id] = null;
- }, 10 * 1e3);
- } else {
- let itemHtml = `
-
-
- ${name2}
-
-
-
-
-
-
`;
- $(itemHtml).appendTo($("#luckysheet-cell-main #luckysheet-multipleRange-show"));
- _this2.multipleIndex++;
- if (store_default.cooperativeEdit.usernameTimeout["user" + id] != null) {
- clearTimeout(store_default.cooperativeEdit.usernameTimeout["user" + id]);
- }
- store_default.cooperativeEdit.usernameTimeout["user" + id] = setTimeout(() => {
- clearTimeout(store_default.cooperativeEdit.usernameTimeout["user" + id]);
- store_default.cooperativeEdit.usernameTimeout["user" + id] = null;
- }, 10 * 1e3);
- }
- },
- sheetDeleSave: [],
- submitInterval: 1e3,
- imagesubmitInterval: 5e3,
- submitdatalimit: 50,
- submitcompresslimit: 1e3,
- checksubmit: function(data) {
- let _this2 = this;
- _this2.submitTimeout();
- clearTimeout(_this2.imageRequestTimeout);
- _this2.imageRequestTimeout = setTimeout(function() {
- _this2.imageRequest();
- }, _this2.imagesubmitInterval);
- },
- submitTimeout: function() {
- let _this2 = this;
- clearTimeout(_this2.requestTimeOut);
- if (!_this2.requestLock && (_this2.requestlast != null && _this2.requestlast.clone().add(1, "seconds").isBefore((0, import_dayjs3.default)()))) {
- _this2.request();
- }
- _this2.requestTimeOut = setTimeout(function() {
- _this2.submitTimeout();
- }, _this2.submitInterval);
- },
- requestLock: false,
- requestlast: null,
- firstchange: true,
- requestTimeOut: null,
- request: function() {
- let _this2 = this;
- let key = this.gridKey;
- let cahce_key = key + "__qkcache";
- _this2.cachelocaldata(function(cahce_key2, params) {
- if (params.length == 0) {
- return;
- }
- params = encodeURIComponent(JSON.stringify(params));
- let compressBeginLen = params.length;
- let iscommpress = false;
- _this2.requestLock = true;
- if (_this2.updateUrl != "") {
- $.post(_this2.updateUrl, {compress: iscommpress, gridKey: _this2.gridKey, data: params}, function(data) {
- let re = new Function("return " + data)();
- if (re.status) {
- $("#luckysheet_info_detail_update").html("\u6700\u8FD1\u5B58\u6863\u65F6\u95F4:" + (0, import_dayjs3.default)().format("M-D H:m:s"));
- $("#luckysheet_info_detail_save").html("\u540C\u6B65\u6210\u529F");
- _this2.clearcachelocaldata();
- } else {
- $("#luckysheet_info_detail_save").html("
\u540C\u6B65\u5931\u8D25 ");
- _this2.restorecachelocaldata();
- }
- _this2.requestlast = (0, import_dayjs3.default)();
- _this2.requestLock = false;
- });
- }
- });
- },
- imageRequestLast: null,
- imageRequestLock: false,
- imageRequestTimeout: null,
- imageRequest: function() {
- let _this2 = this;
- html2canvas($("#" + container).find(".luckysheet-grid-window").get(0), {
- onrendered: function(canvas) {
- let old = $(canvas).appendTo("body");
- old.hide();
- let newwidth = old.width();
- let newheight = old.height();
- let imageData = old.get(0).getContext("2d").getImageData(0, 0, newwidth, newheight);
- let cutW = newwidth, cutH = newheight;
- if (cutW * 0.54 > cutH) {
- cutW = cutH / 0.54;
- } else {
- cutH = cutW * 0.54;
- }
- let newCanvas = $("
").attr("width", cutW).attr("height", cutH)[0];
- newCanvas.getContext("2d").putImageData(imageData, 0, 0);
- old.attr("width", 350);
- old.attr("height", 189);
- old.get(0).getContext("2d").drawImage(newCanvas, 0, 0, 350, 189);
- let base64 = old.get(0).toDataURL("image/jpeg", 0.9);
- let curindex = luckysheet.sheetmanage.getCurSheetnoset();
- _this2.imageRequestLock = true;
- let data1 = encodeURIComponent(JSON.stringify({"t": "thumb", "img": base64, "curindex": curindex}));
- old.remove();
- if (_this2.updateImageUrl != "") {
- $.post(_this2.updateImageUrl, {compress: false, gridKey: _this2.gridKey, data: data1}, function(data) {
- let re = new Function("return " + data)();
- if (re.status) {
- imageRequestLast = (0, import_dayjs3.default)();
- } else {
- $("#luckysheet_info_detail_save").html("\u7F51\u7EDC\u4E0D\u7A33\u5B9A ");
- }
- _this2.imageRequestLock = true;
- });
- }
- }
- });
- },
- localdata: [],
- matchOpt: function(v, d) {
- for (let vitem in v) {
- if (vitem == "t" && v["t"] in {"drc": 1, "arc": 1, "sha": 1, "shc": 1, "shd": 1}) {
- return false;
- }
- if (vitem == "v") {
- continue;
- }
- if (!(vitem in d)) {
- return false;
- }
- if (d[vitem] != v[vitem]) {
- return false;
- }
- }
- return true;
- },
- deleteRepeatOpt: function(data, value) {
- let d = data;
- let _this2 = this;
- if (value instanceof Array) {
- for (let i2 = 0; i2 < value.length; i2++) {
- let vitem = value[i2];
- for (let a = 0; a < d.length; a++) {
- let ditem = data[i2];
- if (_this2.matchOpt(vitem, ditem)) {
- delete d[a];
- }
- }
- }
- } else {
- for (let a = 0; a < d.length; a++) {
- let ditem = d[a];
- if (_this2.matchOpt(value, ditem)) {
- delete d[a];
- }
- }
- }
- let ret = [];
- for (let i2 = 0; i2 < d.length; i2++) {
- if (d[i2] != null) {
- ret.push(d[i2]);
- }
- }
- return ret;
- },
- setlocaldata: function(value, func) {
- let key = this.gridKey;
- let _this2 = this;
- _this2.getlocaldata(function(data) {
- if (data == null) {
- data = [];
- }
- if (value instanceof Array) {
- data = data.concat(value);
- } else {
- data.push(value);
- }
- _this2.localdata = data;
- func(_this2.localdata);
- });
- },
- getlocaldata: function(func) {
- let key = this.gridKey;
- func(this.localdata);
- },
- clearlocaldata: function(func) {
- let key = this.gridKey;
- this.localdata = [];
- func();
- },
- cachelocaldata: function(func) {
- let key = this.gridKey;
- let _this2 = this;
- let cahce_key = key + "__qkcache";
- let updatedata = _this2.localdata;
- let uLen = updatedata.length;
- if (uLen > 1) {
- let prevData = [];
- prevData[0] = updatedata[0];
- for (let i2 = 1; i2 < uLen; i2++) {
- let value = updatedata[i2];
- let flag = true;
- for (let a = 0; a < prevData.length; a++) {
- let ditem = prevData[a];
- if (_this2.matchOpt(value, ditem)) {
- prevData.splice(a, 1, value);
- flag = false;
- break;
- }
- }
- if (flag) {
- prevData = prevData.concat(value);
- }
- }
- updatedata = prevData;
- }
- if (updatedata == null || updatedata.length == 0) {
- return;
- }
- _this2.clearlocaldata(function() {
- localforage.setItem(cahce_key, updatedata).then(function() {
- func(cahce_key, updatedata);
- });
- });
- },
- clearcachelocaldata: function(func) {
- let key = this.gridKey;
- let cahce_key = key + "__qkcache";
- localforage.removeItem(cahce_key, function(err, value) {
- if (func && typeof func == "function") {
- func();
- }
- });
- },
- restorecachelocaldata: function(func) {
- let key = this.gridKey;
- let cahce_key = key + "__qkcache";
- let _this2 = this;
- localforage.getItem(cahce_key).then(function(readValue) {
- let updatedata = readValue;
- _this2.getlocaldata(function(data) {
- if (data == null) {
- data = [];
- }
- let newdata = updatedata.concat(data);
- _this2.localdata = newdata;
- if (func instanceof Function) {
- func(_this2.localdata);
- }
- });
- });
- },
- keepHighLightBox: function() {
- store_default.cooperativeEdit.checkoutData.forEach((value) => {
- if (value.index == store_default.currentSheetIndex) {
- if (value.op === "enterEdit") {
- server.multipleRangeShow(value.id, value.username, value.r, value.c, value.op);
- } else {
- server.multipleRangeShow(value.id, value.username, value.r, value.c);
- }
- }
- });
- }
- };
- server_default = server;
- }
- });
-
- // src/global/tooltip.js
- var tooltip, tooltip_default;
- var init_tooltip = __esm({
- "src/global/tooltip.js"() {
- init_constant();
- init_browser();
- init_util();
- init_locale();
- init_server();
- tooltip = {
- info: function(title, content) {
- $("#luckysheet-modal-dialog-mask").show();
- $("#luckysheet-info").remove();
- let _locale = locale_default();
- let locale_button = _locale.button;
- $("body").append(replaceHtml(modelHTML, {
- "id": "luckysheet-info",
- "addclass": "",
- "title": title,
- "content": content,
- "botton": ' ' + locale_button.close + " ",
- "style": "z-index:100003"
- }));
- let $t = $("#luckysheet-info").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();
- $("#luckysheet-info").css({"left": (winw + scrollLeft - myw) / 2, "top": (winh + scrollTop - myh) / 3}).show();
- },
- confirm: function(title, content, func1, func2, name1, name2) {
- $("#luckysheet-modal-dialog-mask").show();
- $("#luckysheet-confirm").remove();
- const _locale = locale_default();
- const locale_button = _locale.button;
- if (name1 == null) {
- name1 = locale_button.confirm;
- }
- if (name2 == null) {
- name2 = locale_button.cancel;
- }
- $("body").append(replaceHtml(modelHTML, {
- "id": "luckysheet-confirm",
- "addclass": "",
- "style": "z-index:100003",
- "title": title,
- "content": content,
- "botton": ' ' + name1 + ' ' + name2 + " "
- }));
- let $t = $("#luckysheet-confirm").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();
- $("#luckysheet-confirm").css({"left": (winw + scrollLeft - myw) / 2, "top": (winh + scrollTop - myh) / 3}).show();
- $t.find(".luckysheet-model-conform-btn").click(function() {
- if (typeof func1 == "function") {
- func1();
- }
- server_default.keepHighLightBox();
- $("#luckysheet-confirm").hide();
- $("#luckysheet-modal-dialog-mask").hide();
- });
- $t.find(".luckysheet-model-cancel-btn").click(function() {
- if (typeof func2 == "function") {
- func2();
- }
- $("#luckysheet-confirm").hide();
- $("#luckysheet-modal-dialog-mask").hide();
- });
- },
- screenshot: function(title, content, imgurl) {
- const _locale = locale_default();
- const locale_screenshot = _locale.screenshot;
- $("#luckysheet-modal-dialog-mask").show();
- $("#luckysheet-confirm").remove();
- $("body").append(replaceHtml(modelHTML, {
- "id": "luckysheet-confirm",
- "addclass": "",
- "style": "z-index:100003",
- "title": title,
- "content": content,
- "botton": ' ' + locale_screenshot.downLoadBtn + ' ' + locale_screenshot.downLoadCopy + ' ' + locale_screenshot.downLoadClose + " "
- }));
- let $t = $("#luckysheet-confirm").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();
- $("#luckysheet-confirm").css({"left": (winw + scrollLeft - myw) / 2, "top": (winh + scrollTop - myh) / 3}).show();
- $t.find(".luckysheet-model-conform-btn").click(function() {
- if (browser_default.isIE() == "1") {
- alert(locale_screenshot.browserNotTip);
- } else {
- if (!!window.ActiveXObject || "ActiveXObject" in window) {
- if ($("#IframeReportImg").length === 0) {
- $('').appendTo("body");
- }
- if ($("#IframeReportImg").attr("src") != imgurl) {
- $("#IframeReportImg").attr("src", imgurl);
- } else {
- if ($("#IframeReportImg").src != "about:blank") {
- window.frames["IframeReportImg"].document.execCommand("SaveAs");
- }
- }
- }
- }
- });
- $t.find(".luckysheet-model-cancel-btn").click(function() {
- $("#luckysheet-confirm").hide();
- $("#luckysheet-modal-dialog-mask").hide();
- });
- $("#luckysheet-confirm .luckysheet-model-copy-btn").click(function() {
- let dt = new clipboard.DT();
- dt.setData("text/html", " ");
- if (browser_default.isIE() == "1") {
- alert(locale_screenshot.rightclickTip);
- } else {
- clipboard.write(dt);
- alert(locale_screenshot.successTip);
- }
- });
- },
- chartPointConfig: function(id, savefunc1, closefunc2) {
- $("body").append(replaceHtml(modelHTML, {
- "id": id,
- "addclass": "luckysheet-chart-point-config-c",
- "title": "\u6570\u636E\u70B9\u6279\u91CF\u8BBE\u7F6E",
- "content": luckysheetchartpointconfigHTML,
- "botton": ' \u4FDD\u5B58\u8BBE\u7F6E \u53D6\u6D88 ',
- "style": "z-index:100003;height:80%;width:80%;top:10%;left:10%;"
- }));
- $("#luckysheet-modal-dialog-mask").show();
- let winw = $(window).width(), winh = $(window).height();
- $("#" + id).find(".luckysheet-chart-point-config").css("height", winh - 160);
- $("#" + id).css({
- "height": winh - 90,
- "width": winw - 100,
- "left": 7,
- "top": 14
- }).show().find(".luckysheet-model-save-btn").click(function() {
- if (typeof savefunc1 == "function") {
- savefunc1();
- }
- $("#" + id).hide();
- $("#luckysheet-modal-dialog-mask").hide();
- });
- $("#" + id).find(".luckysheet-model-save-btn").click(function() {
- if (typeof closefunc2 == "function") {
- closefunc2();
- }
- $("#" + id).hide();
- $("#luckysheet-modal-dialog-mask").hide();
- });
- },
- sheetConfig: function() {
- },
- hoverTipshowState: false,
- hoverTipshowTimeOut: null,
- createHoverTip: function(obj, to) {
- let _this2 = this;
- $(obj).on("mouseover", to, function(e) {
- if (_this2.hoverTipshowState) {
- return;
- }
- clearTimeout(_this2.hoverTipshowTimeOut);
- _this2.hoverTipshowTimeOut = setTimeout(function() {
- let $t = $(e.currentTarget), toffset = $t.offset(), $toolup = $("#luckysheet-tooltip-up");
- let tips = $t.data("tips");
- if (tips == null || tips.length == 0) {
- tips = $t.prev().data("tips");
- if (tips == null || tips.length == 0) {
- return;
- }
- }
- if ($toolup.length == 0) {
- $("body").append(luckysheetToolHTML);
- $toolup = $("#luckysheet-tooltip-up");
- }
- $toolup.removeClass("jfk-tooltip-hide").find("div.jfk-tooltip-contentId").html(tips);
- let toolwidth = $toolup.outerWidth();
- $toolup.find("div.jfk-tooltip-arrow").css("left", toolwidth / 2);
- let toolleft = toffset.left + ($t.outerWidth() - toolwidth) / 2;
- if (toolleft < 2) {
- toolleft = 2;
- $toolup.find("div.jfk-tooltip-arrow").css("left", $t.outerWidth() / 2);
- }
- $toolup.css({"top": toffset.top + $t.outerHeight() + 1, "left": toolleft});
- }, 300);
- }).on("mouseout", to, function(e) {
- _this2.hoverTipshowState = false;
- clearTimeout(_this2.hoverTipshowTimeOut);
- $("#luckysheet-tooltip-up").addClass("jfk-tooltip-hide");
- }).on("click", to, function(e) {
- _this2.hoverTipshowState = true;
- clearTimeout(_this2.hoverTipshowTimeOut);
- $("#luckysheet-tooltip-up").addClass("jfk-tooltip-hide");
- });
- },
- popover: function(content, position, close, style, btntxt, exitsFuc) {
- let _locale = locale_default();
- let locale_button = _locale.button;
- let locale_paint = _locale.paint;
- if (btntxt == null) {
- btntxt = locale_button.close;
- }
- let htmldiv = '' + locale_paint.start + '
' + btntxt + "
";
- $("#luckysheetpopover").remove();
- $("body").append(htmldiv);
- $("#luckysheetpopover .luckysheetpopover-content").html(content);
- let w = $("#luckysheetpopover").outerWidth(), h = $("#luckysheetpopover").outerHeight();
- let pcss = {};
- if (position == "topLeft") {
- pcss.top = "20px";
- pcss.left = "20px";
- } else if (position == "topCenter") {
- pcss.top = "20px";
- pcss.left = "50%";
- pcss["margin-left"] = -w / 2;
- } else if (position == "topRight") {
- pcss.top = "20px";
- pcss.right = "20px";
- } else if (position == "midLeft") {
- pcss.top = "50%";
- pcss["margin-top"] = -h / 2;
- pcss.left = "20px";
- } else if (position == "center") {
- pcss.top = "50%";
- pcss["margin-top"] = -h / 2;
- pcss.left = "50%";
- pcss["margin-left"] = -w / 2;
- } else if (position == "midRight") {
- pcss.top = "50%";
- pcss["margin-top"] = -h / 2;
- pcss.right = "20px";
- } else if (position == "bottomLeft") {
- pcss.bottom = "20px";
- pcss.left = "20px";
- } else if (position == "bottomCenter") {
- pcss.bottom = "20px";
- pcss.left = "50%";
- pcss["margin-left"] = -w / 2;
- } else if (position == "bottomRight") {
- pcss.bottom = "20px";
- pcss.right = "20px";
- } else {
- pcss.top = "20px";
- pcss.left = "50%";
- pcss["margin-left"] = -w / 2;
- }
- if (style == "white") {
- pcss.background = "rgba(255, 255, 255, 0.65)";
- pcss.color = "#000";
- $("#luckysheetpopover .luckysheetpopover-btn").css({"border": "1px solid #000"});
- }
- setTimeout(function() {
- $("#luckysheetpopover .luckysheetpopover-content").css({"margin-left": -$("#luckysheetpopover .luckysheetpopover-btn").outerWidth() / 2});
- }, 1);
- $("#luckysheetpopover").css(pcss).fadeIn();
- $("#luckysheetpopover .luckysheetpopover-btn").click(function() {
- if (typeof exitsFuc == "function") {
- exitsFuc();
- }
- });
- if (close != null && typeof close == "number") {
- setTimeout(function() {
- $("#luckysheetpopover").fadeOut().remove();
- if (typeof exitsFuc == "function") {
- exitsFuc();
- }
- }, close);
- }
- }
- };
- tooltip_default = tooltip;
- }
- });
-
- // src/controllers/conditionformat.js
- var import_dayjs4, conditionformat, conditionformat_default;
- var init_conditionformat = __esm({
- "src/controllers/conditionformat.js"() {
- init_get();
- init_util();
- init_formula();
- init_validate();
- init_tooltip();
- init_refresh();
- init_getdata();
- init_format();
- init_constant();
- init_server();
- init_select();
- init_sheetmanage();
- init_locale();
- init_protection();
- init_store();
- import_dayjs4 = __toModule(require_dayjs_min());
- conditionformat = {
- fileClone: [],
- editorRule: null,
- ruleTypeHtml: function() {
- const conditionformat_Text = locale_default().conditionformat;
- return `
-
-
- ${conditionformat_Text.ruleTypeItem1}
-
-
-
- ${conditionformat_Text.ruleTypeItem2}
-
-
-
- ${conditionformat_Text.ruleTypeItem3}
-
-
-
- ${conditionformat_Text.ruleTypeItem4}
-
-
-
- ${conditionformat_Text.ruleTypeItem5}
-
-
-
- ${conditionformat_Text.ruleTypeItem6}
-
-
`;
- },
- textCellColorHtml: function() {
- const conditionformat_Text = locale_default().conditionformat;
- return ``;
- },
- selectRange: [],
- selectStatus: false,
- dataBarList: [
- {"format": ["#638ec6", "#ffffff"]},
- {"format": ["#63c384", "#ffffff"]},
- {"format": ["#ff555a", "#ffffff"]},
- {"format": ["#ffb628", "#ffffff"]},
- {"format": ["#008aef", "#ffffff"]},
- {"format": ["#d6007b", "#ffffff"]},
- {"format": ["#638ec6"]},
- {"format": ["#63c384"]},
- {"format": ["#ff555a"]},
- {"format": ["#ffb628"]},
- {"format": ["#008aef"]},
- {"format": ["#d6007b"]}
- ],
- colorGradationList: [
- {"format": ["rgb(99, 190, 123)", "rgb(255, 235, 132)", "rgb(248, 105, 107)"]},
- {"format": ["rgb(248, 105, 107)", "rgb(255, 235, 132)", "rgb(99, 190, 123)"]},
- {"format": ["rgb(99, 190, 123)", "rgb(252, 252, 255)", "rgb(248, 105, 107)"]},
- {"format": ["rgb(248, 105, 107)", "rgb(252, 252, 255)", "rgb(99, 190, 123)"]},
- {"format": ["rgb(90, 138, 198)", "rgb(252, 252, 255)", "rgb(248, 105, 107)"]},
- {"format": ["rgb(248, 105, 107)", "rgb(252, 252, 255)", "rgb(90, 138, 198)"]},
- {"format": ["rgb(252, 252, 255)", "rgb(248, 105, 107)"]},
- {"format": ["rgb(248, 105, 107)", "rgb(252, 252, 255)"]},
- {"format": ["rgb(99, 190, 123)", "rgb(252, 252, 255)"]},
- {"format": ["rgb(252, 252, 255)", "rgb(99, 190, 123)"]},
- {"format": ["rgb(99, 190, 123)", "rgb(255, 235, 132)"]},
- {"format": ["rgb(255, 235, 132)", "rgb(99, 190, 123)"]}
- ],
- init: function() {
- let _this2 = this;
- const conditionformat_Text = locale_default().conditionformat;
- $(document).off("change.CFchooseSheet").on("change.CFchooseSheet", "#luckysheet-administerRule-dialog .chooseSheet", function() {
- let index2 = $("#luckysheet-administerRule-dialog .chooseSheet option:selected").val();
- _this2.getConditionRuleList(index2);
- });
- $(document).off("click.CFadministerRuleItem").on("click.CFadministerRuleItem", "#luckysheet-administerRule-dialog .ruleList .listBox .item", function() {
- $(this).addClass("on").siblings().removeClass("on");
- });
- $(document).off("click.CFadministerRuleConfirm").on("click.CFadministerRuleConfirm", "#luckysheet-administerRule-dialog-confirm", function() {
- if (!checkProtectionFormatCells(store_default.currentSheetIndex)) {
- return;
- }
- let fileH = $.extend(true, [], store_default.luckysheetfile);
- let historyRules = _this2.getHistoryRules(fileH);
- let fileClone = $.extend(true, [], _this2.fileClone);
- for (let c2 = 0; c2 < fileClone.length; c2++) {
- let sheetIndex = fileClone[c2]["index"];
- store_default.luckysheetfile[getSheetIndex(sheetIndex)]["luckysheet_conditionformat_save"] = fileClone[getSheetIndex(sheetIndex)]["luckysheet_conditionformat_save"];
- }
- let fileC = $.extend(true, [], store_default.luckysheetfile);
- let currentRules = _this2.getCurrentRules(fileC);
- _this2.ref(historyRules, currentRules);
- $("#luckysheet-modal-dialog-mask").hide();
- $("#luckysheet-administerRule-dialog").hide();
- if (server_default.allowUpdate) {
- let files = $.extend(true, [], store_default.luckysheetfile);
- for (let i2 = 0; i2 < files.length; i2++) {
- server_default.saveParam("all", files[i2]["index"], files[i2]["luckysheet_conditionformat_save"], {"k": "luckysheet_conditionformat_save"});
- }
- }
- });
- $(document).off("click.CFadministerRuleClose").on("click.CFadministerRuleClose", "#luckysheet-administerRule-dialog-close", function() {
- $("#luckysheet-modal-dialog-mask").hide();
- $("#luckysheet-administerRule-dialog").hide();
- _this2.fileClone = [];
- });
- $(document).off("click.CFadministerRuleFa").on("click.CFadministerRuleFa", "#luckysheet-administerRule-dialog .item .fa-table", function() {
- $(this).parents("#luckysheet-administerRule-dialog").hide();
- let sheetIndex = $("#luckysheet-administerRule-dialog .chooseSheet select option:selected").val();
- if (sheetIndex != store_default.currentSheetIndex) {
- sheetmanage_default.changeSheetExec(sheetIndex);
- }
- let txt = $(this).siblings("input").val().trim();
- let dataItem = $(this).parents(".item").attr("data-item");
- _this2.multiRangeDialog(dataItem, txt);
- _this2.selectRange = [];
- let range2 = _this2.getRangeByTxt(txt);
- if (range2.length > 0) {
- for (let s = 0; s < range2.length; s++) {
- let r1 = range2[s].row[0], r2 = range2[s].row[1];
- let c1 = range2[s].column[0], c2 = range2[s].column[1];
- let row = store_default.visibledatarow[r2], row_pre = r1 - 1 == -1 ? 0 : store_default.visibledatarow[r1 - 1];
- let col = store_default.visibledatacolumn[c2], col_pre = c1 - 1 == -1 ? 0 : store_default.visibledatacolumn[c1 - 1];
- _this2.selectRange.push({
- "left": col_pre,
- "width": col - col_pre - 1,
- "top": row_pre,
- "height": row - row_pre - 1,
- "left_move": col_pre,
- "width_move": col - col_pre - 1,
- "top_move": row_pre,
- "height_move": row - row_pre - 1,
- "row": [r1, r2],
- "column": [c1, c2],
- "row_focus": r1,
- "column_focus": c1
- });
- }
- }
- selectionCopyShow(_this2.selectRange);
- });
- $(document).off("click.CFmultiRangeConfirm").on("click.CFmultiRangeConfirm", "#luckysheet-multiRange-dialog-confirm", function() {
- $(this).parents("#luckysheet-multiRange-dialog").hide();
- let dataItem = $(this).attr("data-item");
- let v = $(this).parents("#luckysheet-multiRange-dialog").find("input").val();
- $("#luckysheet-administerRule-dialog .item[data-item=" + dataItem + "] input").val(v);
- let sheetIndex = $("#luckysheet-administerRule-dialog .chooseSheet option:selected").val();
- _this2.fileClone[getSheetIndex(sheetIndex)]["luckysheet_conditionformat_save"][dataItem].cellrange = _this2.getRangeByTxt(v);
- $("#luckysheet-modal-dialog-mask").show();
- $("#luckysheet-administerRule-dialog").show();
- let range2 = [];
- selectionCopyShow(range2);
- });
- $(document).off("click.CFmultiRangeClose").on("click.CFmultiRangeClose", "#luckysheet-multiRange-dialog-close", function() {
- $(this).parents("#luckysheet-multiRange-dialog").hide();
- $("#luckysheet-modal-dialog-mask").show();
- $("#luckysheet-administerRule-dialog").show();
- $("#luckysheet-formula-functionrange-select").hide();
- $("#luckysheet-row-count-show").hide();
- $("#luckysheet-column-count-show").hide();
- let range2 = [];
- selectionCopyShow(range2);
- });
- $(document).off("click.CFnewConditionRule").on("click.CFnewConditionRule", "#newConditionRule", function() {
- let sheetIndex = $("#luckysheet-administerRule-dialog .chooseSheet option:selected").val();
- if (!checkProtectionFormatCells(sheetIndex)) {
- return;
- }
- if (store_default.luckysheet_select_save.length == 0) {
- if (isEditMode()) {
- alert(conditionformat_Text.pleaseSelectRange);
- } else {
- tooltip_default.info(conditionformat_Text.pleaseSelectRange, "");
- }
- return;
- }
- _this2.newConditionRuleDialog(1);
- });
- $(document).off("click.CFnewConditionRuleConfirm").on("click.CFnewConditionRuleConfirm", "#luckysheet-newConditionRule-dialog-confirm", function() {
- if (!checkProtectionFormatCells(store_default.currentSheetIndex)) {
- return;
- }
- let index2 = $("#luckysheet-newConditionRule-dialog .ruleTypeItem.on").index();
- let type1 = $("#luckysheet-newConditionRule-dialog #type1 option:selected").val();
- let type2 = $("#luckysheet-newConditionRule-dialog ." + type1 + "Box #type2 option:selected").val();
- let format, rule;
- if (index2 == 0) {
- if (type1 == "dataBar") {
- let color = $(this).parents("#luckysheet-newConditionRule-dialog").find(".dataBarBox .luckysheet-conditionformat-config-color").spectrum("get").toHexString();
- if (type2 == "gradient") {
- format = [color, "#ffffff"];
- } else if (type2 == "solid") {
- format = [color];
- }
- rule = {
- "type": "dataBar",
- "cellrange": $.extend(true, [], store_default.luckysheet_select_save),
- "format": format
- };
- } else if (type1 == "colorGradation") {
- let maxcolor = $(this).parents("#luckysheet-newConditionRule-dialog").find(".colorGradationBox .maxVal .luckysheet-conditionformat-config-color").spectrum("get").toRgbString();
- let midcolor = $(this).parents("#luckysheet-newConditionRule-dialog").find(".colorGradationBox .midVal .luckysheet-conditionformat-config-color").spectrum("get").toRgbString();
- let mincolor = $(this).parents("#luckysheet-newConditionRule-dialog").find(".colorGradationBox .minVal .luckysheet-conditionformat-config-color").spectrum("get").toRgbString();
- if (type2 == "threeColor") {
- format = [maxcolor, midcolor, mincolor];
- } else if (type2 == "twoColor") {
- format = [maxcolor, mincolor];
- }
- rule = {
- "type": "colorGradation",
- "cellrange": $.extend(true, [], store_default.luckysheet_select_save),
- "format": format
- };
- } else if (type1 == "icons") {
- let len = $(this).parents("#luckysheet-newConditionRule-dialog").find(".iconsBox .model").attr("data-len");
- let leftMin = $(this).parents("#luckysheet-newConditionRule-dialog").find(".iconsBox .model").attr("data-leftmin");
- let top = $(this).parents("#luckysheet-newConditionRule-dialog").find(".iconsBox .model").attr("data-top");
- format = {
- "len": len,
- "leftMin": leftMin,
- "top": top
- };
- rule = {
- "type": "icons",
- "cellrange": $.extend(true, [], store_default.luckysheet_select_save),
- "format": format
- };
- }
- } else {
- let conditionName = "", conditionRange = [], conditionValue = [];
- if (index2 == 1) {
- if (type1 == "number") {
- conditionName = type2;
- if (type2 == "betweenness") {
- let v1 = $("#luckysheet-newConditionRule-dialog #conditionVal input").val().trim();
- let v2 = $("#luckysheet-newConditionRule-dialog #conditionVal2 input").val().trim();
- let rangeArr1 = _this2.getRangeByTxt(v1);
- if (rangeArr1.length > 1) {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- } else if (rangeArr1.length == 1) {
- let r1 = rangeArr1[0].row[0], r2 = rangeArr1[0].row[1];
- let c1 = rangeArr1[0].column[0], c2 = rangeArr1[0].column[1];
- if (r1 == r2 && c1 == c2) {
- v1 = getcellvalue(r1, c1, store_default.flowdata);
- conditionRange[0] = {"row": rangeArr1[0].row, "column": rangeArr1[0].column};
- conditionValue.push(v1);
- } else {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- }
- } else if (rangeArr1.length == 0) {
- if (isNaN(v1) || v1 == "") {
- _this2.infoDialog(conditionformat_Text.conditionValueCanOnly, "");
- return;
- } else {
- conditionValue.push(v1);
- }
- }
- let rangeArr2 = _this2.getRangeByTxt(v2);
- if (rangeArr2.length > 1) {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- } else if (rangeArr2.length == 1) {
- let r1 = rangeArr2[0].row[0], r2 = rangeArr2[0].row[1];
- let c1 = rangeArr2[0].column[0], c2 = rangeArr2[0].column[1];
- if (r1 == r2 && c1 == c2) {
- v2 = getcellvalue(r1, c1, store_default.flowdata);
- conditionRange[1] = {"row": rangeArr2[0].row, "column": rangeArr2[0].column};
- conditionValue.push(v2);
- } else {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- }
- } else if (rangeArr2.length == 0) {
- if (isNaN(v2) || v2 == "") {
- _this2.infoDialog(conditionformat_Text.conditionValueCanOnly, "");
- return;
- } else {
- conditionValue.push(v2);
- }
- }
- } else {
- let v = $("#luckysheet-newConditionRule-dialog #conditionVal input").val().trim();
- let rangeArr = _this2.getRangeByTxt(v);
- if (rangeArr.length > 1) {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- } else if (rangeArr.length == 1) {
- let r1 = rangeArr[0].row[0], r2 = rangeArr[0].row[1];
- let c1 = rangeArr[0].column[0], c2 = rangeArr[0].column[1];
- if (r1 == r2 && c1 == c2) {
- v = getcellvalue(r1, c1, store_default.flowdata);
- conditionRange.push({"row": rangeArr[0].row, "column": rangeArr[0].column});
- conditionValue.push(v);
- } else {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- }
- } else if (rangeArr.length == 0) {
- if (isNaN(v) || v == "") {
- _this2.infoDialog(conditionformat_Text.conditionValueCanOnly, "");
- return;
- } else {
- conditionValue.push(v);
- }
- }
- }
- } else if (type1 == "text") {
- conditionName = "textContains";
- let v = $("#luckysheet-newConditionRule-dialog #conditionVal input").val().trim();
- let rangeArr = _this2.getRangeByTxt(v);
- if (rangeArr.length > 1) {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- } else if (rangeArr.length == 1) {
- let r1 = rangeArr[0].row[0], r2 = rangeArr[0].row[1];
- let c1 = rangeArr[0].column[0], c2 = rangeArr[0].column[1];
- if (r1 == r2 && c1 == c2) {
- v = getcellvalue(r1, c1, store_default.flowdata);
- conditionRange.push({"row": rangeArr[0].row, "column": rangeArr[0].column});
- conditionValue.push(v);
- } else {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- }
- } else if (rangeArr.length == 0) {
- if (v == "") {
- _this2.infoDialog(conditionformat_Text.conditionValueCanOnly, "");
- return;
- } else {
- conditionValue.push(v);
- }
- }
- } else if (type1 == "date") {
- conditionName = "occurrenceDate";
- let v = $("#luckysheet-newConditionRule-dialog #daterange-btn").val();
- if (v == "" || v == null) {
- _this2.infoDialog(conditionformat_Text.pleaseSelectADate, "");
- return;
- }
- conditionValue.push(v);
- }
- } else if (index2 == 2) {
- if (type1 == "top") {
- if ($("#luckysheet-newConditionRule-dialog #isPercent").is(":selected")) {
- conditionName = "top10%";
- } else {
- conditionName = "top10";
- }
- } else if (type1 == "last") {
- if ($("#luckysheet-newConditionRule-dialog #isPercent").is(":selected")) {
- conditionName = "last10%";
- } else {
- conditionName = "last10";
- }
- }
- let v = $("#luckysheet-newConditionRule-dialog #conditionVal input").val().trim();
- if (parseInt(v) != v || parseInt(v) < 1 || parseInt(v) > 1e3) {
- _this2.infoDialog(conditionformat_Text.pleaseEnterInteger, "");
- return;
- }
- conditionValue.push(parseInt(v));
- } else if (index2 == 3) {
- if (type1 == "AboveAverage") {
- conditionName = "AboveAverage";
- conditionValue.push("AboveAverage");
- } else if (type1 == "SubAverage") {
- conditionName = "SubAverage";
- conditionValue.push("SubAverage");
- }
- } else if (index2 == 4) {
- conditionName = "duplicateValue";
- conditionValue.push(type1);
- } else if (index2 == 5) {
- conditionName = "formula";
- let v = $("#luckysheet-newConditionRule-dialog #formulaConditionVal input").val().trim();
- if (v == "") {
- _this2.infoDialog("Condition value cannot be empty!", "");
- return;
- }
- conditionValue.push(v);
- }
- let textcolor;
- if ($("#luckysheet-newConditionRule-dialog #checkTextColor").is(":checked")) {
- textcolor = $("#luckysheet-newConditionRule-dialog #textcolorshow").spectrum("get").toHexString();
- } else {
- textcolor = null;
- }
- let cellcolor;
- if ($("#luckysheet-newConditionRule-dialog #checkCellColor").is(":checked")) {
- cellcolor = $("#luckysheet-newConditionRule-dialog #cellcolorshow").spectrum("get").toHexString();
- } else {
- cellcolor = null;
- }
- format = {
- "textColor": textcolor,
- "cellColor": cellcolor
- };
- rule = {
- "type": "default",
- "cellrange": $.extend(true, [], store_default.luckysheet_select_save),
- "format": format,
- "conditionName": conditionName,
- "conditionRange": conditionRange,
- "conditionValue": conditionValue
- };
- }
- $("#luckysheet-newConditionRule-dialog").hide();
- let source = $(this).attr("data-source");
- if (source == 0) {
- $("#luckysheet-modal-dialog-mask").hide();
- let fileH = $.extend(true, [], store_default.luckysheetfile);
- let historyRules = _this2.getHistoryRules(fileH);
- let ruleArr2 = store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)]["luckysheet_conditionformat_save"] == void 0 ? [] : store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)]["luckysheet_conditionformat_save"];
- ruleArr2.push(rule);
- store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)]["luckysheet_conditionformat_save"] = ruleArr2;
- let fileC = $.extend(true, [], store_default.luckysheetfile);
- let currentRules = _this2.getCurrentRules(fileC);
- _this2.ref(historyRules, currentRules);
- if (server_default.allowUpdate) {
- server_default.saveParam("all", store_default.currentSheetIndex, ruleArr2, {"k": "luckysheet_conditionformat_save"});
- }
- } else if (source == 1) {
- let ruleArr2 = !!_this2.fileClone[getSheetIndex(store_default.currentSheetIndex)]["luckysheet_conditionformat_save"] ? _this2.fileClone[getSheetIndex(store_default.currentSheetIndex)]["luckysheet_conditionformat_save"] : [];
- ruleArr2.push(rule);
- _this2.fileClone[getSheetIndex(store_default.currentSheetIndex)]["luckysheet_conditionformat_save"] = ruleArr2;
- _this2.administerRuleDialog();
- }
- });
- $(document).off("click.CFnewConditionRuleClose").on("click.CFnewConditionRuleClose", "#luckysheet-newConditionRule-dialog-close", function() {
- let source = $(this).attr("data-source");
- if (source == 0) {
- $("#luckysheet-modal-dialog-mask").hide();
- }
- if (source == 1) {
- $("#luckysheet-administerRule-dialog").show();
- }
- $("#luckysheet-newConditionRule-dialog").hide();
- $("#luckysheet-formula-functionrange-select").hide();
- $("#luckysheet-row-count-show").hide();
- $("#luckysheet-column-count-show").hide();
- });
- $(document).off("click.CFeditorConditionRule").on("click.CFeditorConditionRule", "#editorConditionRule", function() {
- let sheetIndex = $("#luckysheet-administerRule-dialog .chooseSheet option:selected").val();
- if (!checkProtectionFormatCells(sheetIndex)) {
- return;
- }
- let itemIndex = $("#luckysheet-administerRule-dialog .ruleList .listBox .item.on").attr("data-item");
- let rule = {
- "sheetIndex": sheetIndex,
- "itemIndex": itemIndex,
- "data": _this2.fileClone[getSheetIndex(sheetIndex)]["luckysheet_conditionformat_save"][itemIndex]
- };
- _this2.editorRule = rule;
- _this2.editorConditionRuleDialog();
- });
- $(document).off("click.CFeditorConditionRuleConfirm").on("click.CFeditorConditionRuleConfirm", "#luckysheet-editorConditionRule-dialog-confirm", function() {
- let index2 = $("#luckysheet-editorConditionRule-dialog .ruleTypeItem.on").index();
- let type1 = $("#luckysheet-editorConditionRule-dialog #type1 option:selected").val();
- let type2 = $("#luckysheet-editorConditionRule-dialog ." + type1 + "Box #type2 option:selected").val();
- let cellrange = _this2.editorRule["data"].cellrange;
- let format, rule;
- if (index2 == 0) {
- if (type1 == "dataBar") {
- let color = $(this).parents("#luckysheet-editorConditionRule-dialog").find(".dataBarBox .luckysheet-conditionformat-config-color").spectrum("get").toHexString();
- if (type2 == "gradient") {
- format = [color, "#ffffff"];
- } else if (type2 == "solid") {
- format = [color];
- }
- rule = {
- "type": "dataBar",
- "cellrange": cellrange,
- "format": format
- };
- } else if (type1 == "colorGradation") {
- let maxcolor = $(this).parents("#luckysheet-editorConditionRule-dialog").find(".colorGradationBox .maxVal .luckysheet-conditionformat-config-color").spectrum("get").toRgbString();
- let midcolor = $(this).parents("#luckysheet-editorConditionRule-dialog").find(".colorGradationBox .midVal .luckysheet-conditionformat-config-color").spectrum("get").toRgbString();
- let mincolor = $(this).parents("#luckysheet-editorConditionRule-dialog").find(".colorGradationBox .minVal .luckysheet-conditionformat-config-color").spectrum("get").toRgbString();
- if (type2 == "threeColor") {
- format = [maxcolor, midcolor, mincolor];
- } else if (type2 == "twoColor") {
- format = [maxcolor, mincolor];
- }
- rule = {
- "type": "colorGradation",
- "cellrange": cellrange,
- "format": format
- };
- } else if (type1 == "icons") {
- let len = $(this).parents("#luckysheet-editorConditionRule-dialog").find(".iconsBox .model").attr("data-len");
- let leftMin = $(this).parents("#luckysheet-editorConditionRule-dialog").find(".iconsBox .model").attr("data-leftmin");
- let top = $(this).parents("#luckysheet-editorConditionRule-dialog").find(".iconsBox .model").attr("data-top");
- format = {
- "len": len,
- "leftMin": leftMin,
- "top": top
- };
- rule = {
- "type": "icons",
- "cellrange": cellrange,
- "format": format
- };
- }
- } else {
- let conditionName = "", conditionRange = [], conditionValue = [];
- if (index2 == 1) {
- if (type1 == "number") {
- conditionName = type2;
- if (type2 == "betweenness") {
- let v1 = $("#luckysheet-editorConditionRule-dialog #conditionVal input").val().trim();
- let v2 = $("#luckysheet-editorConditionRule-dialog #conditionVal2 input").val().trim();
- let rangeArr1 = _this2.getRangeByTxt(v1);
- if (rangeArr1.length > 1) {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- } else if (rangeArr1.length == 1) {
- let r1 = rangeArr1[0].row[0], r2 = rangeArr1[0].row[1];
- let c1 = rangeArr1[0].column[0], c2 = rangeArr1[0].column[1];
- if (r1 == r2 && c1 == c2) {
- v1 = getcellvalue(r1, c1, store_default.flowdata);
- conditionRange[0] = {"row": rangeArr1[0].row, "column": rangeArr1[0].column};
- conditionValue.push(v1);
- } else {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- }
- } else if (rangeArr1.length == 0) {
- if (isNaN(v1) || v1 == "") {
- _this2.infoDialog(conditionformat_Text.conditionValueCanOnly, "");
- return;
- } else {
- conditionValue.push(v1);
- }
- }
- let rangeArr2 = _this2.getRangeByTxt(v2);
- if (rangeArr2.length > 1) {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- } else if (rangeArr2.length == 1) {
- let r1 = rangeArr2[0].row[0], r2 = rangeArr2[0].row[1];
- let c1 = rangeArr2[0].column[0], c2 = rangeArr2[0].column[1];
- if (r1 == r2 && c1 == c2) {
- v2 = getcellvalue(r1, c1, store_default.flowdata);
- conditionRange[1] = {"row": rangeArr2[0].row, "column": rangeArr2[0].column};
- conditionValue.push(v2);
- } else {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- }
- } else if (rangeArr2.length == 0) {
- if (isNaN(v2) || v2 == "") {
- _this2.infoDialog(conditionformat_Text.conditionValueCanOnly, "");
- return;
- } else {
- conditionValue.push(v2);
- }
- }
- } else {
- let v = $("#luckysheet-editorConditionRule-dialog #conditionVal input").val().trim();
- let rangeArr = _this2.getRangeByTxt(v);
- if (rangeArr.length > 1) {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- } else if (rangeArr.length == 1) {
- let r1 = rangeArr[0].row[0], r2 = rangeArr[0].row[1];
- let c1 = rangeArr[0].column[0], c2 = rangeArr[0].column[1];
- if (r1 == r2 && c1 == c2) {
- v = getcellvalue(r1, c1, store_default.flowdata);
- conditionRange.push({"row": rangeArr[0].row, "column": rangeArr[0].column});
- conditionValue.push(v);
- } else {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- }
- } else if (rangeArr.length == 0) {
- if (isNaN(v) || v == "") {
- _this2.infoDialog(conditionformat_Text.conditionValueCanOnly, "");
- return;
- } else {
- conditionValue.push(v);
- }
- }
- }
- } else if (type1 == "text") {
- conditionName = "textContains";
- let v = $("#luckysheet-editorConditionRule-dialog #conditionVal input").val().trim();
- let rangeArr = _this2.getRangeByTxt(v);
- if (rangeArr.length > 1) {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- } else if (rangeArr.length == 1) {
- let r1 = rangeArr[0].row[0], r2 = rangeArr[0].row[1];
- let c1 = rangeArr[0].column[0], c2 = rangeArr[0].column[1];
- if (r1 == r2 && c1 == c2) {
- v = getcellvalue(r1, c1, store_default.flowdata);
- conditionRange.push({"row": rangeArr[0].row, "column": rangeArr[0].column});
- conditionValue.push(v);
- } else {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- }
- } else if (rangeArr.length == 0) {
- if (isNaN(v) || v == "") {
- _this2.infoDialog(conditionformat_Text.conditionValueCanOnly, "");
- return;
- } else {
- conditionValue.push(v);
- }
- }
- } else if (type1 == "date") {
- conditionName = "occurrenceDate";
- let v = $("#luckysheet-editorConditionRule-dialog #daterange-btn").val();
- if (v == "" || v == null) {
- _this2.infoDialog(conditionformat_Text.pleaseSelectADate, "");
- return;
- }
- conditionValue.push(v);
- }
- } else if (index2 == 2) {
- if (type1 == "top") {
- if ($("#luckysheet-editorConditionRule-dialog #isPercent").is(":selected")) {
- conditionName = "top10%";
- } else {
- conditionName = "top10";
- }
- } else if (type1 == "last") {
- if ($("#luckysheet-editorConditionRule-dialog #isPercent").is(":selected")) {
- conditionName = "last10%";
- } else {
- conditionName = "last10";
- }
- }
- let v = $("#luckysheet-editorConditionRule-dialog #conditionVal input").val().trim();
- if (parseInt(v) != v || parseInt(v) < 1 || parseInt(v) > 1e3) {
- _this2.infoDialog(conditionformat_Text.pleaseEnterInteger, "");
- return;
- }
- conditionValue.push(v);
- } else if (index2 == 3) {
- if (type1 == "AboveAverage") {
- conditionName = "AboveAverage";
- conditionValue.push("AboveAverage");
- } else if (type1 == "SubAverage") {
- conditionName = "SubAverage";
- conditionValue.push("SubAverage");
- }
- } else if (index2 == 4) {
- conditionName = "duplicateValue";
- conditionValue.push(type1);
- } else if (index2 == 5) {
- conditionName = "formula";
- let v = $("#luckysheet-editorConditionRule-dialog #formulaConditionVal input").val().trim();
- console.log(v);
- if (v == "") {
- _this2.infoDialog("Condition value cannot be empty!", "");
- return;
- }
- conditionValue.push(v);
- }
- let textcolor;
- if ($("#luckysheet-editorConditionRule-dialog #checkTextColor").is(":checked")) {
- textcolor = $("#luckysheet-editorConditionRule-dialog #textcolorshow").spectrum("get").toHexString();
- } else {
- textcolor = null;
- }
- let cellcolor;
- if ($("#luckysheet-editorConditionRule-dialog #checkCellColor").is(":checked")) {
- cellcolor = $("#luckysheet-editorConditionRule-dialog #cellcolorshow").spectrum("get").toHexString();
- } else {
- cellcolor = null;
- }
- format = {
- "textColor": textcolor,
- "cellColor": cellcolor
- };
- rule = {
- "type": "default",
- "cellrange": cellrange,
- "format": format,
- "conditionName": conditionName,
- "conditionRange": conditionRange,
- "conditionValue": conditionValue
- };
- }
- let sheetIndex = _this2.editorRule["sheetIndex"];
- let itemIndex = _this2.editorRule["itemIndex"];
- _this2.fileClone[getSheetIndex(sheetIndex)]["luckysheet_conditionformat_save"][itemIndex] = rule;
- $("#luckysheet-editorConditionRule-dialog").hide();
- _this2.administerRuleDialog();
- });
- $(document).off("click.CFeditorConditionRuleClose").on("click.CFeditorConditionRuleClose", "#luckysheet-editorConditionRule-dialog-close", function() {
- $("#luckysheet-editorConditionRule-dialog").hide();
- $("#luckysheet-administerRule-dialog").show();
- $("#luckysheet-formula-functionrange-select").hide();
- $("#luckysheet-row-count-show").hide();
- $("#luckysheet-column-count-show").hide();
- });
- $(document).off("click.CFnewEditorRuleItem").on("click.CFnewEditorRuleItem", ".luckysheet-newEditorRule-dialog .ruleTypeItem", function() {
- $(this).addClass("on").siblings().removeClass("on");
- let index2 = $(this).index();
- $(this).parents(".luckysheet-newEditorRule-dialog").find(".ruleExplainBox").html(_this2.getRuleExplain(index2));
- _this2.colorSelectInit();
- });
- $(document).off("change.CFnewEditorRuleType1").on("change.CFnewEditorRuleType1", ".luckysheet-newEditorRule-dialog #type1", function() {
- let optionVal = $(this).find("option:selected").val();
- if (optionVal == "dataBar" || optionVal == "colorGradation" || optionVal == "icons" || optionVal == "number" || optionVal == "text" || optionVal == "date") {
- $(this).parents(".luckysheet-newEditorRule-dialog").find("." + optionVal + "Box").show().siblings().hide();
- }
- if (optionVal == "date") {
- _this2.daterangeInit($(this).parents(".luckysheet-newEditorRule-dialog").attr("id"));
- }
- });
- $(document).off("change.CFnewEditorRuleType2").on("change.CFnewEditorRuleType2", ".luckysheet-newEditorRule-dialog #type2", function() {
- let type1 = $(this).parents(".luckysheet-newEditorRule-dialog").find("#type1 option:selected").val();
- if (type1 == "colorGradation") {
- let type2 = $(this).find("option:selected").val();
- if (type2 == "threeColor") {
- $(this).parents(".luckysheet-newEditorRule-dialog").find(".midVal").show();
- } else {
- $(this).parents(".luckysheet-newEditorRule-dialog").find(".midVal").hide();
- }
- } else if (type1 == "number") {
- let type2 = $(this).find("option:selected").val();
- if (type2 == "betweenness") {
- $(this).parents(".luckysheet-newEditorRule-dialog").find(".txt").show();
- $(this).parents(".luckysheet-newEditorRule-dialog").find("#conditionVal2").show();
- } else {
- $(this).parents(".luckysheet-newEditorRule-dialog").find(".txt").hide();
- $(this).parents(".luckysheet-newEditorRule-dialog").find("#conditionVal2").hide();
- }
- }
- });
- $(document).off("click.CFiconsShowbox").on("click.CFiconsShowbox", ".luckysheet-newEditorRule-dialog .iconsBox .showbox", function() {
- $(this).parents(".iconsBox").find("ul").toggle();
- });
- $(document).off("click.CFiconsLi").on("click.CFiconsLi", ".luckysheet-newEditorRule-dialog .iconsBox li", function() {
- let len = $(this).find("div").attr("data-len");
- let leftmin = $(this).find("div").attr("data-leftmin");
- let top = $(this).find("div").attr("data-top");
- let title = $(this).find("div").attr("title");
- let position = $(this).find("div").css("background-position");
- $(this).parents(".iconsBox").find(".showbox .model").css("background-position", position);
- $(this).parents(".iconsBox").find(".showbox .model").attr("data-len", len);
- $(this).parents(".iconsBox").find(".showbox .model").attr("data-leftmin", leftmin);
- $(this).parents(".iconsBox").find(".showbox .model").attr("data-top", top);
- $(this).parents(".iconsBox").find(".showbox .model").attr("title", title);
- $(this).parents("ul").hide();
- });
- $(document).off("click.CFdeleteConditionRule").on("click.CFdeleteConditionRule", "#deleteConditionRule", function() {
- let sheetIndex = $("#luckysheet-administerRule-dialog .chooseSheet option:selected").val();
- if (!checkProtectionFormatCells(sheetIndex)) {
- return;
- }
- let itemIndex = $("#luckysheet-administerRule-dialog .ruleList .listBox .item.on").attr("data-item");
- _this2.fileClone[getSheetIndex(sheetIndex)]["luckysheet_conditionformat_save"].splice(itemIndex, 1);
- _this2.administerRuleDialog();
- });
- $(document).off("click.CFdefault").on("click.CFdefault", "#luckysheet-conditionformat-dialog-confirm", function() {
- if (!checkProtectionFormatCells(store_default.currentSheetIndex)) {
- return;
- }
- let conditionName = $("#luckysheet-conditionformat-dialog .box").attr("data-itemvalue");
- let conditionRange = [];
- let conditionValue = [];
- if (conditionName == "greaterThan" || conditionName == "lessThan" || conditionName == "equal" || conditionName == "textContains") {
- let v = $("#luckysheet-conditionformat-dialog #conditionVal").val().trim();
- let rangeArr = _this2.getRangeByTxt(v);
- if (rangeArr.length > 1) {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- } else if (rangeArr.length == 1) {
- let r1 = rangeArr[0].row[0], r2 = rangeArr[0].row[1];
- let c1 = rangeArr[0].column[0], c2 = rangeArr[0].column[1];
- if (r1 == r2 && c1 == c2) {
- v = getcellvalue(r1, c1, store_default.flowdata);
- conditionRange.push({"row": rangeArr[0].row, "column": rangeArr[0].column});
- conditionValue.push(v);
- } else {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- }
- } else if (rangeArr.length == 0) {
- if (isNaN(v) || v == "") {
- _this2.infoDialog(conditionformat_Text.conditionValueCanOnly, "");
- return;
- } else {
- conditionValue.push(v);
- }
- }
- } else if (conditionName == "betweenness") {
- let v1 = $("#luckysheet-conditionformat-dialog #conditionVal").val().trim();
- let v2 = $("#luckysheet-conditionformat-dialog #conditionVal2").val().trim();
- let rangeArr1 = _this2.getRangeByTxt(v1);
- if (rangeArr1.length > 1) {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- } else if (rangeArr1.length == 1) {
- let r1 = rangeArr1[0].row[0], r2 = rangeArr1[0].row[1];
- let c1 = rangeArr1[0].column[0], c2 = rangeArr1[0].column[1];
- if (r1 == r2 && c1 == c2) {
- v1 = getcellvalue(r1, c1, store_default.flowdata);
- conditionRange[0] = {"row": rangeArr1[0].row, "column": rangeArr1[0].column};
- conditionValue.push(v1);
- } else {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- }
- } else if (rangeArr1.length == 0) {
- if (isNaN(v1) || v1 == "") {
- _this2.infoDialog(conditionformat_Text.conditionValueCanOnly, "");
- return;
- } else {
- conditionValue.push(v1);
- }
- }
- let rangeArr2 = _this2.getRangeByTxt(v2);
- if (rangeArr2.length > 1) {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- } else if (rangeArr2.length == 1) {
- let r1 = rangeArr2[0].row[0], r2 = rangeArr2[0].row[1];
- let c1 = rangeArr2[0].column[0], c2 = rangeArr2[0].column[1];
- if (r1 == r2 && c1 == c2) {
- v2 = getcellvalue(r1, c1, store_default.flowdata);
- conditionRange[1] = {"row": rangeArr2[0].row, "column": rangeArr2[0].column};
- conditionValue.push(v2);
- } else {
- _this2.infoDialog(conditionformat_Text.onlySingleCell, "");
- return;
- }
- } else if (rangeArr2.length == 0) {
- if (isNaN(v2) || v2 == "") {
- _this2.infoDialog(conditionformat_Text.conditionValueCanOnly, "");
- return;
- } else {
- conditionValue.push(v2);
- }
- }
- } else if (conditionName == "occurrenceDate") {
- let v = $("#luckysheet-conditionformat-dialog #daterange-btn").val();
- if (v == "" || v == null) {
- _this2.infoDialog(conditionformat_Text.pleaseSelectADate, "");
- return;
- }
- conditionValue.push(v);
- } else if (conditionName == "duplicateValue") {
- conditionValue.push($("#luckysheet-conditionformat-dialog #conditionVal option:selected").val());
- } else if (conditionName == "top10" || conditionName == "top10%" || conditionName == "last10" || conditionName == "last10%") {
- let v = $("#luckysheet-conditionformat-dialog #conditionVal").val().trim();
- if (parseInt(v) != v || parseInt(v) < 1 || parseInt(v) > 1e3) {
- _this2.infoDialog(conditionformat_Text.pleaseEnterInteger, "");
- return;
- }
- conditionValue.push(v);
- } else if (conditionName == "AboveAverage") {
- conditionValue.push("AboveAverage");
- } else if (conditionName == "SubAverage") {
- conditionValue.push("SubAverage");
- }
- let textcolor;
- if ($("#checkTextColor").is(":checked")) {
- textcolor = $("#textcolorshow").spectrum("get").toHexString();
- } else {
- textcolor = null;
- }
- let cellcolor;
- if ($("#checkCellColor").is(":checked")) {
- cellcolor = $("#cellcolorshow").spectrum("get").toHexString();
- } else {
- cellcolor = null;
- }
- let fileH = $.extend(true, [], store_default.luckysheetfile);
- let historyRules = _this2.getHistoryRules(fileH);
- let rule = {
- "type": "default",
- "cellrange": $.extend(true, [], store_default.luckysheet_select_save),
- "format": {
- "textColor": textcolor,
- "cellColor": cellcolor
- },
- "conditionName": conditionName,
- "conditionRange": conditionRange,
- "conditionValue": conditionValue
- };
- let ruleArr2 = store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)]["luckysheet_conditionformat_save"] == void 0 ? [] : store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)]["luckysheet_conditionformat_save"];
- ruleArr2.push(rule);
- store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)]["luckysheet_conditionformat_save"] = ruleArr2;
- let fileC = $.extend(true, [], store_default.luckysheetfile);
- let currentRules = _this2.getCurrentRules(fileC);
- _this2.ref(historyRules, currentRules);
- $("#luckysheet-modal-dialog-mask").hide();
- $("#luckysheet-conditionformat-dialog").hide();
- if (server_default.allowUpdate) {
- server_default.saveParam("all", store_default.currentSheetIndex, ruleArr2, {"k": "luckysheet_conditionformat_save"});
- }
- });
- $(document).off("click.CFicons").on("click.CFicons", "#luckysheet-CFicons-dialog .item", function() {
- $("#luckysheet-modal-dialog-mask").hide();
- $("#luckysheet-CFicons-dialog").hide();
- if (store_default.luckysheet_select_save.length > 0) {
- let cellrange = $.extend(true, [], store_default.luckysheet_select_save);
- let format = {
- "len": $(this).attr("data-len"),
- "leftMin": $(this).attr("data-leftMin"),
- "top": $(this).attr("data-top")
- };
- _this2.updateItem("icons", cellrange, format);
- }
- });
- $(document).on("click", ".range .fa-table", function() {
- let id = $(this).parents(".luckysheet-modal-dialog").attr("id");
- $("#" + id).hide();
- let source;
- if (id == "luckysheet-conditionformat-dialog") {
- let $id = $(this).siblings("input").attr("id");
- if ($id == "conditionVal") {
- source = "0_1";
- } else {
- source = "0_2";
- }
- } else if (id == "luckysheet-newConditionRule-dialog") {
- let $id = $(this).parents(".range").attr("id");
- if ($id == "formulaConditionVal") {
- source = "1_0";
- } else if ($id == "conditionVal") {
- source = "1_1";
- } else {
- source = "1_2";
- }
- } else if (id == "luckysheet-editorConditionRule-dialog") {
- let $id = $(this).parents(".range").attr("id");
- if ($id == "formulaConditionVal") {
- source = "2_0";
- } else if ($id == "conditionVal") {
- source = "2_1";
- } else {
- source = "2_2";
- }
- }
- let v = $(this).siblings("input").val();
- _this2.singleRangeDialog(source, v);
- selectionCopyShow(_this2.getRangeByTxt(v));
- });
- $(document).on("click", "#luckysheet-singleRange-dialog-confirm", function() {
- $("#luckysheet-modal-dialog-mask").show();
- $(this).parents("#luckysheet-singleRange-dialog").hide();
- let source = $(this).attr("data-source");
- let v = $(this).parents("#luckysheet-singleRange-dialog").find("input").val();
- if (source == "0_1") {
- $("#luckysheet-conditionformat-dialog").show();
- $("#luckysheet-conditionformat-dialog #conditionVal").val(v);
- } else if (source == "0_2") {
- $("#luckysheet-conditionformat-dialog").show();
- $("#luckysheet-conditionformat-dialog #conditionVal2").val(v);
- } else if (source == "1_0") {
- $("#luckysheet-newConditionRule-dialog").show();
- $("#luckysheet-newConditionRule-dialog #formulaConditionVal input").val(v);
- } else if (source == "1_1") {
- $("#luckysheet-newConditionRule-dialog").show();
- $("#luckysheet-newConditionRule-dialog #conditionVal input").val(v);
- } else if (source == "1_2") {
- $("#luckysheet-newConditionRule-dialog").show();
- $("#luckysheet-newConditionRule-dialog #conditionVal2 input").val(v);
- } else if (source == "2_0") {
- $("#luckysheet-editorConditionRule-dialog").show();
- $("#luckysheet-editorConditionRule-dialog #formulaConditionVal input").val(v);
- } else if (source == "2_1") {
- $("#luckysheet-editorConditionRule-dialog").show();
- $("#luckysheet-editorConditionRule-dialog #conditionVal input").val(v);
- } else if (source == "2_2") {
- $("#luckysheet-editorConditionRule-dialog").show();
- $("#luckysheet-editorConditionRule-dialog #conditionVal2 input").val(v);
- }
- let range2 = [];
- selectionCopyShow(range2);
- });
- $(document).on("click", "#luckysheet-singleRange-dialog-close", function() {
- $("#luckysheet-modal-dialog-mask").show();
- $(this).parents("#luckysheet-singleRange-dialog").hide();
- let source = $(this).attr("data-source");
- if (source == "0_1" || source == "0_2") {
- $("#luckysheet-conditionformat-dialog").show();
- } else if (source == "1_0" || source == "1_1" || source == "1_2") {
- $("#luckysheet-newConditionRule-dialog").show();
- } else if (source == "2_0" || source == "2_1" || source == "2_2") {
- $("#luckysheet-editorConditionRule-dialog").show();
- }
- let range2 = [];
- selectionCopyShow(range2);
- });
- $(document).on("click", ".luckysheet-modal-dialog-title-close", function() {
- let id = $(this).parents(".luckysheet-modal-dialog").attr("id");
- if (id == "luckysheet-newConditionRule-dialog") {
- let source = $("#" + id).find("#luckysheet-newConditionRule-dialog-close").attr("data-source");
- if (source == 1) {
- $("#luckysheet-administerRule-dialog").show();
- }
- }
- if (id == "luckysheet-editorConditionRule-dialog") {
- $("#luckysheet-administerRule-dialog").show();
- }
- if (id == "luckysheet-singleRange-dialog") {
- $("#luckysheet-modal-dialog-mask").show();
- let source = $(this).parents("#luckysheet-singleRange-dialog").find("#luckysheet-singleRange-dialog-confirm").attr("data-source");
- if (source == "0_1" || source == "0_2") {
- $("#luckysheet-conditionformat-dialog").show();
- } else if (source == "1_1" || source == "1_2") {
- $("#luckysheet-newConditionRule-dialog").show();
- } else if (source == "2_1" || source == "2_2") {
- $("#luckysheet-editorConditionRule-dialog").show();
- }
- let range2 = [];
- selectionCopyShow(range2);
- }
- if (id == "luckysheet-multiRange-dialog") {
- $("#luckysheet-modal-dialog-mask").show();
- $("#luckysheet-administerRule-dialog").show();
- let range2 = [];
- selectionCopyShow(range2);
- }
- if (id == "luckysheet-conditionformat-info-dialog") {
- $("#luckysheet-modal-dialog-mask").show();
- }
- });
- $(document).on("click", "#luckysheet-conditionformat-info-dialog-close", function() {
- $(this).parents("#luckysheet-conditionformat-info-dialog").hide();
- });
- },
- singleRangeDialog: function(source, value) {
- $("#luckysheet-modal-dialog-mask").hide();
- $("#luckysheet-singleRange-dialog").remove();
- const conditionformat_Text = locale_default().conditionformat;
- $("body").append(replaceHtml(modelHTML, {
- "id": "luckysheet-singleRange-dialog",
- "addclass": "luckysheet-singleRange-dialog",
- "title": conditionformat_Text.selectCell,
- "content": ` `,
- "botton": `${conditionformat_Text.confirm}
- ${conditionformat_Text.cancel} `,
- "style": "z-index:100003"
- }));
- let $t = $("#luckysheet-singleRange-dialog").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();
- $("#luckysheet-singleRange-dialog").css({
- "left": (winw + scrollLeft - myw) / 2,
- "top": (winh + scrollTop - myh) / 3
- }).show();
- },
- multiRangeDialog: function(dataItem, value) {
- let _this2 = this;
- $("#luckysheet-modal-dialog-mask").hide();
- $("#luckysheet-multiRange-dialog").remove();
- const conditionformat_Text = locale_default().conditionformat;
- $("body").append(replaceHtml(modelHTML, {
- "id": "luckysheet-multiRange-dialog",
- "addclass": "luckysheet-multiRange-dialog",
- "title": conditionformat_Text.selectRange,
- "content": ` `,
- "botton": `${conditionformat_Text.confirm}
- ${conditionformat_Text.cancel} `,
- "style": "z-index:100003"
- }));
- let $t = $("#luckysheet-multiRange-dialog").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();
- $("#luckysheet-multiRange-dialog").css({
- "left": (winw + scrollLeft - myw) / 2,
- "top": (winh + scrollTop - myh) / 3
- }).show();
- selectionCopyShow(_this2.getRangeByTxt(value));
- },
- getTxtByRange: function(range2) {
- if (range2.length > 0) {
- let txt = [];
- for (let s = 0; s < range2.length; s++) {
- let r1 = range2[s].row[0], r2 = range2[s].row[1];
- let c1 = range2[s].column[0], c2 = range2[s].column[1];
- txt.push(getRangetxt(store_default.currentSheetIndex, {"row": [r1, r2], "column": [c1, c2]}, store_default.currentSheetIndex));
- }
- return txt.join(",");
- }
- },
- getRangeByTxt: function(txt) {
- let range2 = [];
- txt = txt.toString();
- if (txt.indexOf(",") != -1) {
- let arr = txt.split(",");
- for (let i2 = 0; i2 < arr.length; i2++) {
- if (formula_default.iscelldata(arr[i2])) {
- range2.push(formula_default.getcellrange(arr[i2]));
- } else {
- range2 = [];
- break;
- }
- }
- } else {
- if (formula_default.iscelldata(txt)) {
- range2.push(formula_default.getcellrange(txt));
- }
- }
- return range2;
- },
- colorSelectInit: function() {
- const conditionformat_Text = locale_default().conditionformat;
- $(".luckysheet-conditionformat-config-color").spectrum({
- showPalette: true,
- showPaletteOnly: true,
- preferredFormat: "hex",
- clickoutFiresChange: false,
- showInitial: true,
- showInput: true,
- hideAfterPaletteSelect: true,
- showSelectionPalette: true,
- maxPaletteSize: 8,
- maxSelectionSize: 8,
- cancelText: conditionformat_Text.cancel,
- chooseText: conditionformat_Text.confirmColor,
- togglePaletteMoreText: "\u81EA\u5B9A\u4E49",
- togglePaletteLessText: "\u6536\u8D77",
- togglePaletteOnly: true,
- clearText: conditionformat_Text.clearColorSelect,
- noColorSelectedText: "\u6CA1\u6709\u989C\u8272\u88AB\u9009\u62E9",
- localStorageKey: "spectrum.textcolor" + server_default.gridKey,
- palette: [
- ["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
- ["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
- ["#f4cccc", "#fce5cd", "#fff2cc", "#d9ead3", "#d0e0e3", "#cfe2f3", "#d9d2e9", "#ead1dc"],
- ["#ea9999", "#f9cb9c", "#ffe599", "#b6d7a8", "#a2c4c9", "#9fc5e8", "#b4a7d6", "#d5a6bd"],
- ["#e06666", "#f6b26b", "#ffd966", "#93c47d", "#76a5af", "#6fa8dc", "#8e7cc3", "#c27ba0"],
- ["#c00", "#e69138", "#f1c232", "#6aa84f", "#45818e", "#3d85c6", "#674ea7", "#a64d79"],
- ["#900", "#b45f06", "#bf9000", "#38761d", "#134f5c", "#0b5394", "#351c75", "#741b47"],
- ["#600", "#783f04", "#7f6000", "#274e13", "#0c343d", "#073763", "#20124d", "#4c1130"]
- ],
- change: function(color) {
- if (color != null) {
- color = color.toHexString();
- }
- }
- });
- },
- conditionformatDialog: function(title, content) {
- let _this2 = this;
- $("#luckysheet-modal-dialog-mask").show();
- $("#luckysheet-conditionformat-dialog").remove();
- const conditionformat_Text = locale_default().conditionformat;
- $("body").append(replaceHtml(modelHTML, {
- "id": "luckysheet-conditionformat-dialog",
- "addclass": "luckysheet-conditionformat-dialog",
- "title": title,
- "content": content,
- "botton": `${conditionformat_Text.confirm}
- ${conditionformat_Text.cancel} `,
- "style": "z-index:9999"
- }));
- let $t = $("#luckysheet-conditionformat-dialog").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();
- $("#luckysheet-conditionformat-dialog").css({
- "left": (winw + scrollLeft - myw) / 2,
- "top": (winh + scrollTop - myh) / 3
- }).show();
- _this2.init();
- _this2.colorSelectInit();
- if (title == locale_default().conditionformat.conditionformat_occurrenceDate) {
- _this2.daterangeInit("luckysheet-conditionformat-dialog");
- }
- },
- CFiconsDialog: function() {
- $("#luckysheet-modal-dialog-mask").show();
- $("#luckysheet-CFicons-dialog").remove();
- const conditionformat_Text = locale_default().conditionformat;
- let content = `
-
${conditionformat_Text.pleaseSelectIcon}
-
${conditionformat_Text.direction}
-
-
${conditionformat_Text.shape}
-
-
${conditionformat_Text.mark}
-
-
${conditionformat_Text.grade}
-
-
`;
- $("body").append(replaceHtml(modelHTML, {
- "id": "luckysheet-CFicons-dialog",
- "addclass": "luckysheet-CFicons-dialog",
- "title": conditionformat_Text.icons,
- "content": content,
- "botton": `${conditionformat_Text.close} `,
- "style": "z-index:100003"
- }));
- let $t = $("#luckysheet-CFicons-dialog").find(".luckysheet-modal-dialog-content").css("min-width", 400).end(), myh = $t.outerHeight(), myw = $t.outerWidth();
- let winw = $(window).width(), winh = $(window).height();
- let scrollLeft = $(document).scrollLeft(), scrollTop = $(document).scrollTop();
- $("#luckysheet-CFicons-dialog").css({
- "left": (winw + scrollLeft - myw) / 2,
- "top": (winh + scrollTop - myh) / 3
- }).show();
- },
- administerRuleDialog: function() {
- $("#luckysheet-modal-dialog-mask").show();
- $("#luckysheet-administerRule-dialog").remove();
- const conditionformat_Text = locale_default().conditionformat;
- let opHtml = "";
- for (let j = 0; j < store_default.luckysheetfile.length; j++) {
- if (store_default.luckysheetfile[j].status == "1") {
- opHtml += `
- ${conditionformat_Text.currentSheet}\uFF1A${store_default.luckysheetfile[j]["name"]}
- `;
- } else {
- opHtml += `
- ${conditionformat_Text.sheet}\uFF1A${store_default.luckysheetfile[j]["name"]}
- `;
- }
- }
- let content = `
- ${conditionformat_Text.showRules}\uFF1A
- ${opHtml}
-
-
-
- ${conditionformat_Text.newRule}
- ${conditionformat_Text.editRule}
- ${conditionformat_Text.deleteRule}
-
-
-
- ${conditionformat_Text.rule}
- ${conditionformat_Text.format}
- ${conditionformat_Text.applyRange}
-
-
-
-
`;
- $("body").append(replaceHtml(modelHTML, {
- "id": "luckysheet-administerRule-dialog",
- "addclass": "luckysheet-administerRule-dialog",
- "title": conditionformat_Text.conditionformatManageRules,
- "content": content,
- "botton": `${conditionformat_Text.confirm}
- ${conditionformat_Text.close} `,
- "style": "z-index:100003"
- }));
- let $t = $("#luckysheet-administerRule-dialog").find(".luckysheet-modal-dialog-content").css("min-width", 400).end(), myh = $t.outerHeight(), myw = $t.outerWidth();
- let winw = $(window).width(), winh = $(window).height();
- let scrollLeft = $(document).scrollLeft(), scrollTop = $(document).scrollTop();
- $("#luckysheet-administerRule-dialog").css({
- "left": (winw + scrollLeft - myw) / 2,
- "top": (winh + scrollTop - myh) / 3
- }).show();
- let index2 = $("#luckysheet-administerRule-dialog .chooseSheet option:selected").val();
- this.getConditionRuleList(index2);
- },
- getConditionRuleList: function(index2) {
- let _this2 = this;
- $("#luckysheet-administerRule-dialog .ruleList .listBox").empty();
- let ruleArr2 = _this2.fileClone[getSheetIndex(index2)].luckysheet_conditionformat_save;
- if (ruleArr2 != null && ruleArr2.length > 0) {
- const conditionformat_Text = locale_default().conditionformat;
- for (let i2 = 0; i2 < ruleArr2.length; i2++) {
- let type = ruleArr2[i2]["type"];
- let format = ruleArr2[i2]["format"];
- let cellrange = ruleArr2[i2]["cellrange"];
- let ruleName;
- let formatHtml = "";
- if (type == "dataBar") {
- ruleName = conditionformat_Text.dataBar;
- formatHtml = ' ';
- } else if (type == "colorGradation") {
- ruleName = conditionformat_Text.colorGradation;
- formatHtml = ' ';
- } else if (type == "icons") {
- ruleName = conditionformat_Text.icons;
- formatHtml = ' ';
- } else {
- ruleName = _this2.getConditionRuleName(ruleArr2[i2].conditionName, ruleArr2[i2].conditionRange, ruleArr2[i2].conditionValue);
- if (format["textColor"] != null) {
- formatHtml += ' ';
- }
- if (format["cellColor"] != null) {
- formatHtml += ' ';
- }
- }
- let rangeTxtArr = [];
- for (let s = 0; s < cellrange.length; s++) {
- let r1 = cellrange[s].row[0], r2 = cellrange[s].row[1];
- let c1 = cellrange[s].column[0], c2 = cellrange[s].column[1];
- rangeTxtArr.push(chatatABC(c1) + (r1 + 1) + ":" + chatatABC(c2) + (r2 + 1));
- }
- let itemHtml = '' + ruleName + '
' + formatHtml + '
';
- $("#luckysheet-administerRule-dialog .ruleList .listBox").prepend(itemHtml);
- }
- $("#luckysheet-administerRule-dialog .ruleList .listBox .item canvas").each(function(i2) {
- let x = $(this).closest(".item").attr("data-item");
- let type = ruleArr2[x]["type"];
- let format = ruleArr2[x]["format"];
- let can = $(this).get(0).getContext("2d");
- if (type == "dataBar") {
- if (format.length == 2) {
- let my_gradient = can.createLinearGradient(0, 0, 46, 0);
- my_gradient.addColorStop(0, format[0]);
- my_gradient.addColorStop(1, format[1]);
- can.fillStyle = my_gradient;
- can.fillRect(0, 0, 46, 18);
- can.beginPath();
- can.moveTo(0, 0);
- can.lineTo(0, 18);
- can.lineTo(46, 18);
- can.lineTo(46, 0);
- can.lineTo(0, 0);
- can.lineWidth = store_default.devicePixelRatio;
- can.strokeStyle = format[0];
- can.stroke();
- can.closePath();
- } else if (format.length == 1) {
- can.fillStyle = format[0];
- can.fillRect(0, 0, 46, 18);
- can.beginPath();
- can.moveTo(0, 0);
- can.lineTo(0, 18);
- can.lineTo(46, 18);
- can.lineTo(46, 0);
- can.lineTo(0, 0);
- can.lineWidth = store_default.devicePixelRatio;
- can.strokeStyle = format[0];
- can.stroke();
- can.closePath();
- }
- } else if (type == "colorGradation") {
- let my_gradient = can.createLinearGradient(0, 0, 46, 0);
- if (format.length == 3) {
- my_gradient.addColorStop(0, format[0]);
- my_gradient.addColorStop(0.5, format[1]);
- my_gradient.addColorStop(1, format[2]);
- } else if (format.length == 2) {
- my_gradient.addColorStop(0, format[0]);
- my_gradient.addColorStop(1, format[1]);
- }
- can.fillStyle = my_gradient;
- can.fillRect(0, 0, 46, 18);
- } else if (type == "icons") {
- let len = format["len"];
- let l = format["leftMin"];
- let t = format["top"];
- let w1 = 32 * len + 10 * (len - 1);
- let h1 = 32;
- let w2 = 46;
- let h2 = 46 * 32 / w1;
- if (l == "0") {
- can.drawImage(luckysheet_CFiconsImg, 0, t * 32, w1, h1, 0, (18 - h2) / 2, w2, h2);
- } else if (l == "5") {
- can.drawImage(luckysheet_CFiconsImg, 210, t * 32, w1, h1, 0, (18 - h2) / 2, w2, h2);
- }
- }
- });
- $("#luckysheet-administerRule-dialog .ruleList .listBox .item").eq(0).addClass("on");
- }
- },
- getConditionRuleName: function(conditionName, conditionRange, conditionValue) {
- let v;
- if (conditionRange[0] != null) {
- v = chatatABC(conditionRange[0]["column"][0]) + (conditionRange[0]["row"][0] + 1);
- } else {
- v = conditionValue[0];
- }
- const conditionformat_Text = locale_default().conditionformat;
- if (conditionName == "greaterThan") {
- return conditionformat_Text.cellValue + " > " + v;
- } else if (conditionName == "lessThan") {
- return conditionformat_Text.cellValue + " < " + v;
- } else if (conditionName == "betweenness") {
- let v2;
- if (conditionRange[1] != null) {
- v2 = chatatABC(conditionRange[1]["column"][0]) + (conditionRange[1]["row"][0] + 1);
- } else {
- v2 = conditionValue[1];
- }
- return conditionformat_Text.cellValue + " " + conditionformat_Text.between + " " + v + " " + conditionformat_Text.in + " " + v2 + " " + conditionformat_Text.between2;
- } else if (conditionName == "equal") {
- return conditionformat_Text.cellValue + " = " + v;
- } else if (conditionName == "textContains") {
- return conditionformat_Text.cellValue + conditionformat_Text.contain + " =" + v;
- } else if (conditionName == "occurrenceDate") {
- return conditionValue;
- } else if (conditionName == "duplicateValue") {
- if (conditionValue == "0") {
- return conditionformat_Text.duplicateValue;
- }
- if (conditionValue == "1") {
- return conditionformat_Text.uniqueValue;
- }
- } else if (conditionName == "top10") {
- return conditionformat_Text.top + " " + v + " " + conditionformat_Text.oneself;
- } else if (conditionName == "top10%") {
- return conditionformat_Text.top + " " + v + "% " + conditionformat_Text.oneself;
- } else if (conditionName == "last10") {
- return conditionformat_Text.last + " " + v + " " + conditionformat_Text.oneself;
- } else if (conditionName == "last10%") {
- return conditionformat_Text.last + " " + v + "% " + conditionformat_Text.oneself;
- } else if (conditionName == "AboveAverage") {
- return conditionformat_Text.aboveAverage;
- } else if (conditionName == "SubAverage") {
- return conditionformat_Text.belowAverage;
- } else if (conditionName == "formula") {
- if (v.slice(0, 1) != "=") {
- v = "=" + v;
- }
- return conditionformat_Text.formula + ": " + v;
- }
- },
- newConditionRuleDialog: function(source) {
- let _this2 = this;
- const conditionformat_Text = locale_default().conditionformat;
- let ruleExplainHtml = _this2.getRuleExplain(0);
- $("#luckysheet-modal-dialog-mask").show();
- $("#luckysheet-administerRule-dialog").hide();
- $("#luckysheet-newConditionRule-dialog").remove();
- let content = '' + conditionformat_Text.chooseRuleType + "\uFF1A
" + _this2.ruleTypeHtml() + '
' + conditionformat_Text.editRuleDescription + '\uFF1A
' + ruleExplainHtml + "
";
- $("body").append(replaceHtml(modelHTML, {
- "id": "luckysheet-newConditionRule-dialog",
- "addclass": "luckysheet-newEditorRule-dialog",
- "title": conditionformat_Text.newFormatRule,
- "content": content,
- "botton": `${conditionformat_Text.confirm}
- ${conditionformat_Text.cancel} `,
- "style": "z-index:100003"
- }));
- let $t = $("#luckysheet-newConditionRule-dialog").find(".luckysheet-modal-dialog-content").css("min-width", 400).end(), myh = $t.outerHeight(), myw = $t.outerWidth();
- let winw = $(window).width(), winh = $(window).height();
- let scrollLeft = $(document).scrollLeft(), scrollTop = $(document).scrollTop();
- $("#luckysheet-newConditionRule-dialog").css({
- "left": (winw + scrollLeft - myw) / 2,
- "top": (winh + scrollTop - myh) / 3
- }).show();
- $("#luckysheet-newConditionRule-dialog .ruleTypeBox .ruleTypeItem:eq(0)").addClass("on").siblings().removeClass("on");
- _this2.colorSelectInit();
- },
- editorConditionRuleDialog: function() {
- let _this2 = this;
- const conditionformat_Text = locale_default().conditionformat;
- let rule = _this2.editorRule.data;
- if (rule == null) {
- return;
- }
- let ruleType = rule["type"], ruleFormat = rule["format"], conditionName = rule["conditionName"];
- let index2, type1;
- if (ruleType == "dataBar" || ruleType == "colorGradation" || ruleType == "icons") {
- index2 = 0;
- type1 = ruleType;
- } else {
- if (conditionName == "greaterThan" || conditionName == "lessThan" || conditionName == "betweenness" || conditionName == "equal" || conditionName == "textContains" || conditionName == "occurrenceDate") {
- index2 = 1;
- if (conditionName == "greaterThan" || conditionName == "lessThan" || conditionName == "betweenness" || conditionName == "equal") {
- type1 = "number";
- } else if (conditionName == "textContains") {
- type1 = "text";
- } else if (conditionName == "occurrenceDate") {
- type1 = "date";
- }
- } else if (conditionName == "top10" || conditionName == "top10%" || conditionName == "last10" || conditionName == "last10%") {
- index2 = 2;
- if (conditionName == "top10" || conditionName == "top10%") {
- type1 = "top";
- } else if (conditionName == "last10" || conditionName == "last10%") {
- type1 = "last";
- }
- } else if (conditionName == "AboveAverage" || conditionName == "SubAverage") {
- index2 = 3;
- type1 = conditionName;
- } else if (conditionName == "duplicateValue") {
- index2 = 4;
- type1 = rule["conditionValue"];
- } else if (conditionName == "formula") {
- index2 = 5;
- }
- }
- let ruleExplainHtml = _this2.getRuleExplain(index2);
- $("#luckysheet-modal-dialog-mask").show();
- $("#luckysheet-administerRule-dialog").hide();
- $("#luckysheet-editorConditionRule-dialog").remove();
- let content = '' + conditionformat_Text.chooseRuleType + "\uFF1A
" + _this2.ruleTypeHtml() + '
' + conditionformat_Text.editRuleDescription + '\uFF1A
' + ruleExplainHtml + "
";
- $("body").append(replaceHtml(modelHTML, {
- "id": "luckysheet-editorConditionRule-dialog",
- "addclass": "luckysheet-newEditorRule-dialog",
- "title": conditionformat_Text.editFormatRule,
- "content": content,
- "botton": `${conditionformat_Text.confirm}
- ${conditionformat_Text.cancel} `,
- "style": "z-index:100003"
- }));
- let $t = $("#luckysheet-editorConditionRule-dialog").find(".luckysheet-modal-dialog-content").css("min-width", 400).end(), myh = $t.outerHeight(), myw = $t.outerWidth();
- let winw = $(window).width(), winh = $(window).height();
- let scrollLeft = $(document).scrollLeft(), scrollTop = $(document).scrollTop();
- $("#luckysheet-editorConditionRule-dialog").css({
- "left": (winw + scrollLeft - myw) / 2,
- "top": (winh + scrollTop - myh) / 3
- }).show();
- _this2.colorSelectInit();
- $("#luckysheet-editorConditionRule-dialog .ruleTypeBox .ruleTypeItem:eq(" + index2 + ")").addClass("on").siblings().removeClass("on");
- $("#luckysheet-editorConditionRule-dialog #type1").val(type1);
- if (type1 == "dataBar" || type1 == "colorGradation" || type1 == "icons" || type1 == "number" || type1 == "text" || type1 == "date") {
- $("#luckysheet-editorConditionRule-dialog ." + type1 + "Box").show();
- $("#luckysheet-editorConditionRule-dialog ." + type1 + "Box").siblings().hide();
- }
- if (type1 == "date") {
- _this2.daterangeInit("luckysheet-editorConditionRule-dialog");
- }
- if (ruleType == "dataBar" || ruleType == "colorGradation" || ruleType == "icons") {
- if (type1 == "dataBar") {
- if (ruleFormat.length == 2) {
- $("#luckysheet-editorConditionRule-dialog .dataBarBox #type2").val("gradient");
- } else if (ruleFormat.length == 1) {
- $("#luckysheet-editorConditionRule-dialog .dataBarBox #type2").val("solid");
- }
- $("#luckysheet-editorConditionRule-dialog .dataBarBox .luckysheet-conditionformat-config-color").spectrum("set", ruleFormat[0]);
- } else if (type1 == "colorGradation") {
- if (ruleFormat.length == 3) {
- $("#luckysheet-editorConditionRule-dialog .colorGradationBox #type2").val("threeColor");
- $("#luckysheet-editorConditionRule-dialog .colorGradationBox .midVal").show();
- $("#luckysheet-editorConditionRule-dialog .colorGradationBox .maxVal .luckysheet-conditionformat-config-color").spectrum("set", ruleFormat[0]);
- $("#luckysheet-editorConditionRule-dialog .colorGradationBox .midVal .luckysheet-conditionformat-config-color").spectrum("set", ruleFormat[1]);
- $("#luckysheet-editorConditionRule-dialog .colorGradationBox .minVal .luckysheet-conditionformat-config-color").spectrum("set", ruleFormat[2]);
- } else if (ruleFormat.length == 2) {
- $("#luckysheet-editorConditionRule-dialog .colorGradationBox #type2").val("twoColor");
- $("#luckysheet-editorConditionRule-dialog .colorGradationBox .midVal").hide();
- $("#luckysheet-editorConditionRule-dialog .colorGradationBox .maxVal .luckysheet-conditionformat-config-color").spectrum("set", ruleFormat[0]);
- $("#luckysheet-editorConditionRule-dialog .colorGradationBox .minVal .luckysheet-conditionformat-config-color").spectrum("set", ruleFormat[1]);
- }
- } else if (type1 == "icons") {
- let len = ruleFormat["len"];
- let l = ruleFormat["leftMin"];
- let t = ruleFormat["top"];
- $("#luckysheet-editorConditionRule-dialog .iconsBox li").each(function(i2, e) {
- if ($(e).find("div").attr("data-len") == len && $(e).find("div").attr("data-leftmin") == l && $(e).find("div").attr("data-top") == t) {
- $("#luckysheet-editorConditionRule-dialog .iconsBox .showbox .model").css("background-position", $(e).find("div").css("background-position"));
- $("#luckysheet-editorConditionRule-dialog .iconsBox .showbox .model").attr("data-len", $(e).find("div").attr("data-len"));
- $("#luckysheet-editorConditionRule-dialog .iconsBox .showbox .model").attr("data-leftmin", $(e).find("div").attr("data-leftmin"));
- $("#luckysheet-editorConditionRule-dialog .iconsBox .showbox .model").attr("data-top", $(e).find("div").attr("data-leftmin"));
- $("#luckysheet-editorConditionRule-dialog .iconsBox .showbox .model").attr("title", $(e).find("div").attr("title"));
- return true;
- }
- });
- }
- } else {
- if (type1 == "number") {
- $("#luckysheet-editorConditionRule-dialog .numberBox #type2").val(conditionName);
- let val1;
- if (rule.conditionRange[0] != null) {
- val1 = getRangetxt(store_default.currentSheetIndex, {"row": rule.conditionRange[0]["row"], "column": rule.conditionRange[0]["column"]}, store_default.currentSheetIndex);
- } else {
- val1 = rule.conditionValue[0];
- }
- $("#luckysheet-editorConditionRule-dialog .numberBox #conditionVal input").val(val1);
- if (conditionName == "betweenness") {
- $("#luckysheet-editorConditionRule-dialog .numberBox .txt").show();
- $("#luckysheet-editorConditionRule-dialog .numberBox #conditionVal2").show();
- let val2;
- if (rule.conditionRange[1] != null) {
- val2 = getRangetxt(store_default.currentSheetIndex, {"row": rule.conditionRange[1]["row"], "column": rule.conditionRange[1]["column"]}, store_default.currentSheetIndex);
- } else {
- val2 = rule.conditionValue[1];
- }
- $("#luckysheet-editorConditionRule-dialog .numberBox #conditionVal2 input").val(val2);
- } else {
- $("#luckysheet-editorConditionRule-dialog .numberBox .txt").hide();
- $("#luckysheet-editorConditionRule-dialog .numberBox #conditionVal2").hide();
- }
- } else if (type1 == "text") {
- let val1;
- if (rule.conditionRange[0] != null) {
- val1 = getRangetxt(store_default.currentSheetIndex, {"row": rule.conditionRange[0]["row"], "column": rule.conditionRange[0]["column"]}, store_default.currentSheetIndex);
- } else {
- val1 = rule.conditionValue[0];
- }
- $("#luckysheet-editorConditionRule-dialog .textBox #conditionVal input").val(val1);
- } else if (type1 == "date") {
- _this2.daterangeInit("luckysheet-editorConditionRule-dialog");
- let val1 = rule.conditionValue[0];
- $("#luckysheet-editorConditionRule-dialog .dateBox #daterange-btn").val(val1);
- } else if (type1 == "top" || type1 == "last") {
- let val1 = rule.conditionValue[0];
- if (conditionName == "top10%" || conditionName == "last10%") {
- $("#luckysheet-editorConditionRule-dialog #isPercent").attr("checked", "checked");
- }
- } else {
- if (conditionName == "formula") {
- let val1 = rule.conditionValue[0];
- $("#luckysheet-editorConditionRule-dialog #formulaConditionVal input").val(val1);
- }
- }
- $("#luckysheet-editorConditionRule-dialog #textcolorshow").spectrum("set", ruleFormat.textColor);
- $("#luckysheet-editorConditionRule-dialog #cellcolorshow").spectrum("set", ruleFormat.cellColor);
- }
- },
- infoDialog: function(title, content) {
- $("#luckysheet-modal-dialog-mask").show();
- $("#luckysheet-conditionformat-info-dialog").remove();
- $("body").append(replaceHtml(modelHTML, {
- "id": "luckysheet-conditionformat-info-dialog",
- "addclass": "",
- "title": title,
- "content": content,
- "botton": `${locale_default().conditionformat.close} `,
- "style": "z-index:100003"
- }));
- let $t = $("#luckysheet-conditionformat-info-dialog").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();
- $("#luckysheet-conditionformat-info-dialog").css({
- "left": (winw + scrollLeft - myw) / 2,
- "top": (winh + scrollTop - myh) / 3
- }).show();
- },
- getRuleExplain: function(index2) {
- const conditionformat_Text = locale_default().conditionformat;
- let textCellColorHtml = this.textCellColorHtml();
- let ruleExplainHtml;
- switch (index2) {
- case 0:
- ruleExplainHtml = `${conditionformat_Text.ruleTypeItem1}\uFF1A
-
- ${conditionformat_Text.formatStyle}\uFF1A
-
- ${conditionformat_Text.dataBar}
- ${conditionformat_Text.colorGradation}
- ${conditionformat_Text.icons}
-
-
-
-
-
- ${conditionformat_Text.fillType}\uFF1A
-
- ${conditionformat_Text.gradient}
- ${conditionformat_Text.solid}
-
-
-
- ${conditionformat_Text.color}\uFF1A
-
-
-
-
-
- ${conditionformat_Text.fillType}\uFF1A
-
- ${conditionformat_Text.tricolor}
- ${conditionformat_Text.twocolor}
-
-
-
- ${conditionformat_Text.maxValue}\uFF1A
-
-
-
- ${conditionformat_Text.medianValue}\uFF1A
-
-
-
- ${conditionformat_Text.minValue}\uFF1A
-
-
-
-
-
${conditionformat_Text.fillType}\uFF1A
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
`;
- break;
- case 1:
- ruleExplainHtml = `${conditionformat_Text.ruleTypeItem2_title}\uFF1A
-
-
- ${conditionformat_Text.cellValue}
- ${conditionformat_Text.specificText}
- ${conditionformat_Text.occurrence}
-
-
-
-
- ${conditionformat_Text.greaterThan}
- ${conditionformat_Text.lessThan}
- ${conditionformat_Text.between}
- ${conditionformat_Text.equal}
-
-
-
-
-
-
${conditionformat_Text.in}
-
-
-
-
-
-
-
- ${conditionformat_Text.contain}
-
-
-
-
-
-
-
-
-
- ${conditionformat_Text.setFormat}:
${textCellColorHtml}`;
- break;
- case 2:
- ruleExplainHtml = `${conditionformat_Text.ruleTypeItem3_title}\uFF1A
-
-
- ${conditionformat_Text.top}
- ${conditionformat_Text.last}
-
-
-
-
-
-
${conditionformat_Text.selectRange_percent}
-
- ${conditionformat_Text.setFormat}\uFF1A
${textCellColorHtml}`;
- break;
- case 3:
- ruleExplainHtml = `${conditionformat_Text.ruleTypeItem4_title}\uFF1A
-
-
- ${conditionformat_Text.above}
- ${conditionformat_Text.below}
-
- ${conditionformat_Text.selectRange_average}
-
- ${conditionformat_Text.setFormat}\uFF1A
${textCellColorHtml}`;
- break;
- case 4:
- ruleExplainHtml = `${conditionformat_Text.all}\uFF1A
-
-
- ${conditionformat_Text.duplicateValue}
- ${conditionformat_Text.uniqueValue}
-
- ${conditionformat_Text.selectRange_value}
-
- ${conditionformat_Text.setFormat}\uFF1A
${textCellColorHtml}`;
- break;
- case 5:
- ruleExplainHtml = `${conditionformat_Text.ruleTypeItem2_title}\uFF1A
-
- ${conditionformat_Text.setFormat}:
${textCellColorHtml}`;
- break;
- }
- return ruleExplainHtml;
- },
- daterangeInit: function(id) {
- const conditionformat_Text = locale_default().conditionformat;
- const regexSingleDate = /^\d{4}-\d{2}-\d{2}$/;
- const regexStartEndDate = /^\d{4}-\d{2}-\d{2} to \d{4}-\d{2}-\d{2}$/;
- $(".ranges_1 ul").remove();
- const daterangeBtn = $("#" + id).find("#daterange-btn");
- daterangeBtn.flatpickr({
- mode: "range",
- onChange: (data, label) => {
- const [start, end] = data;
- let format1 = [
- conditionformat_Text.yesterday,
- conditionformat_Text.today
- ];
- let format2 = [
- conditionformat_Text.lastWeek,
- conditionformat_Text.thisWeek,
- conditionformat_Text.lastMonth,
- conditionformat_Text.thisMonth,
- conditionformat_Text.lastYear,
- conditionformat_Text.thisYear,
- conditionformat_Text.last7days,
- conditionformat_Text.last30days
- ];
- if (label == conditionformat_Text.all) {
- daterangeBtn.val("");
- } else if (format1.indexOf(label) > -1) {
- daterangeBtn.val((0, import_dayjs4.default)(start).format("YYYY/MM/DD"));
- } else if (format2.indexOf(label) > -1) {
- daterangeBtn.val((0, import_dayjs4.default)(start).format("YYYY/MM/DD") + "-" + (0, import_dayjs4.default)(end).format("YYYY/MM/DD"));
- }
- const isValidSingleFormat = regexSingleDate.test(label);
- const isValidStartEndFormat = regexStartEndDate.test(label);
- if (isValidSingleFormat) {
- daterangeBtn.val((0, import_dayjs4.default)(start).format("YYYY/MM/DD"));
- } else if (isValidStartEndFormat) {
- daterangeBtn.val((0, import_dayjs4.default)(start).format("YYYY/MM/DD") + "-" + (0, import_dayjs4.default)(end).format("YYYY/MM/DD"));
- }
- }
- });
- },
- CFSplitRange: function(range1, range2, range3, type) {
- let range4 = [];
- let offset_r = range3["row"][0] - range2["row"][0];
- let offset_c = range3["column"][0] - range2["column"][0];
- let r1 = range1["row"][0], r2 = range1["row"][1];
- let c1 = range1["column"][0], c2 = range1["column"][1];
- if (r1 >= range2["row"][0] && r2 <= range2["row"][1] && c1 >= range2["column"][0] && c2 <= range2["column"][1]) {
- if (type == "allPart") {
- range4 = [
- {"row": [r1 + offset_r, r2 + offset_r], "column": [c1 + offset_c, c2 + offset_c]}
- ];
- } else if (type == "restPart") {
- range4 = [];
- } else if (type == "operatePart") {
- range4 = [
- {"row": [r1 + offset_r, r2 + offset_r], "column": [c1 + offset_c, c2 + offset_c]}
- ];
- }
- } else if (r1 >= range2["row"][0] && r1 <= range2["row"][1] && c1 >= range2["column"][0] && c2 <= range2["column"][1]) {
- if (type == "allPart") {
- range4 = [
- {"row": [range2["row"][1] + 1, r2], "column": [c1, c2]},
- {"row": [r1 + offset_r, range2["row"][1] + offset_r], "column": [c1 + offset_c, c2 + offset_c]}
- ];
- } else if (type == "restPart") {
- range4 = [
- {"row": [range2["row"][1] + 1, r2], "column": [c1, c2]}
- ];
- } else if (type == "operatePart") {
- range4 = [
- {"row": [r1 + offset_r, range2["row"][1] + offset_r], "column": [c1 + offset_c, c2 + offset_c]}
- ];
- }
- } else if (r2 >= range2["row"][0] && r2 <= range2["row"][1] && c1 >= range2["column"][0] && c2 <= range2["column"][1]) {
- if (type == "allPart") {
- range4 = [
- {"row": [r1, range2["row"][0] - 1], "column": [c1, c2]},
- {"row": [range2["row"][0] + offset_r, r2 + offset_r], "column": [c1 + offset_c, c2 + offset_c]}
- ];
- } else if (type == "restPart") {
- range4 = [
- {"row": [r1, range2["row"][0] - 1], "column": [c1, c2]}
- ];
- } else if (type == "operatePart") {
- range4 = [
- {"row": [range2["row"][0] + offset_r, r2 + offset_r], "column": [c1 + offset_c, c2 + offset_c]}
- ];
- }
- } else if (r1 < range2["row"][0] && r2 > range2["row"][1] && c1 >= range2["column"][0] && c2 <= range2["column"][1]) {
- if (type == "allPart") {
- range4 = [
- {"row": [r1, range2["row"][0] - 1], "column": [c1, c2]},
- {"row": [range2["row"][1] + 1, r2], "column": [c1, c2]},
- {"row": [range2["row"][0] + offset_r, range2["row"][1] + offset_r], "column": [c1 + offset_c, c2 + offset_c]}
- ];
- } else if (type == "restPart") {
- range4 = [
- {"row": [r1, range2["row"][0] - 1], "column": [c1, c2]},
- {"row": [range2["row"][1] + 1, r2], "column": [c1, c2]}
- ];
- } else if (type == "operatePart") {
- range4 = [
- {"row": [range2["row"][0] + offset_r, range2["row"][1] + offset_r], "column": [c1 + offset_c, c2 + offset_c]}
- ];
- }
- } else if (c1 >= range2["column"][0] && c1 <= range2["column"][1] && r1 >= range2["row"][0] && r2 <= range2["row"][1]) {
- if (type == "allPart") {
- range4 = [
- {"row": [r1, r2], "column": [range2["column"][1] + 1, c2]},
- {"row": [r1 + offset_r, r2 + offset_r], "column": [c1 + offset_c, range2["column"][1] + offset_c]}
- ];
- } else if (type == "restPart") {
- range4 = [
- {"row": [r1, r2], "column": [range2["column"][1] + 1, c2]}
- ];
- } else if (type == "operatePart") {
- range4 = [
- {"row": [r1 + offset_r, r2 + offset_r], "column": [c1 + offset_c, range2["column"][1] + offset_c]}
- ];
- }
- } else if (c2 >= range2["column"][0] && c2 <= range2["column"][1] && r1 >= range2["row"][0] && r2 <= range2["row"][1]) {
- if (type == "allPart") {
- range4 = [
- {"row": [r1, r2], "column": [c1, range2["column"][0] - 1]},
- {"row": [r1 + offset_r, r2 + offset_r], "column": [range2["column"][0] + offset_c, c2 + offset_c]}
- ];
- } else if (type == "restPart") {
- range4 = [
- {"row": [r1, r2], "column": [c1, range2["column"][0] - 1]}
- ];
- } else if (type == "operatePart") {
- range4 = [
- {"row": [r1 + offset_r, r2 + offset_r], "column": [range2["column"][0] + offset_c, c2 + offset_c]}
- ];
- }
- } else if (c1 < range2["column"][0] && c2 > range2["column"][1] && r1 >= range2["row"][0] && r2 <= range2["row"][1]) {
- if (type == "allPart") {
- range4 = [
- {"row": [r1, r2], "column": [c1, range2["column"][0] - 1]},
- {"row": [r1, r2], "column": [range2["column"][1] + 1, c2]},
- {"row": [r1 + offset_r, r2 + offset_r], "column": [range2["column"][0] + offset_c, range2["column"][1] + offset_c]}
- ];
- } else if (type == "restPart") {
- range4 = [
- {"row": [r1, r2], "column": [c1, range2["column"][0] - 1]},
- {"row": [r1, r2], "column": [range2["column"][1] + 1, c2]}
- ];
- } else if (type == "operatePart") {
- range4 = [
- {"row": [r1 + offset_r, r2 + offset_r], "column": [range2["column"][0] + offset_c, range2["column"][1] + offset_c]}
- ];
- }
- } else if (r1 >= range2["row"][0] && r1 <= range2["row"][1] && c1 >= range2["column"][0] && c1 <= range2["column"][1]) {
- if (type == "allPart") {
- range4 = [
- {"row": [r1, range2["row"][1]], "column": [range2["column"][1] + 1, c2]},
- {"row": [range2["row"][1] + 1, r2], "column": [c1, c2]},
- {"row": [r1 + offset_r, range2["row"][1] + offset_r], "column": [c1 + offset_c, range2["column"][1] + offset_c]}
- ];
- } else if (type == "restPart") {
- range4 = [
- {"row": [r1, range2["row"][1]], "column": [range2["column"][1] + 1, c2]},
- {"row": [range2["row"][1] + 1, r2], "column": [c1, c2]}
- ];
- } else if (type == "operatePart") {
- range4 = [
- {"row": [r1 + offset_r, range2["row"][1] + offset_r], "column": [c1 + offset_c, range2["column"][1] + offset_c]}
- ];
- }
- } else if (r1 >= range2["row"][0] && r1 <= range2["row"][1] && c2 >= range2["column"][0] && c2 <= range2["column"][1]) {
- if (type == "allPart") {
- range4 = [
- {"row": [r1, range2["row"][1]], "column": [c1, range2["column"][0] - 1]},
- {"row": [range2["row"][1] + 1, r2], "column": [c1, c2]},
- {"row": [r1 + offset_r, range2["row"][1] + offset_r], "column": [range2["column"][0] + offset_c, c2 + offset_c]}
- ];
- } else if (type == "restPart") {
- range4 = [
- {"row": [r1, range2["row"][1]], "column": [c1, range2["column"][0] - 1]},
- {"row": [range2["row"][1] + 1, r2], "column": [c1, c2]}
- ];
- } else if (type == "operatePart") {
- range4 = [
- {"row": [r1 + offset_r, range2["row"][1] + offset_r], "column": [range2["column"][0] + offset_c, c2 + offset_c]}
- ];
- }
- } else if (r2 >= range2["row"][0] && r2 <= range2["row"][1] && c1 >= range2["column"][0] && c1 <= range2["column"][1]) {
- if (type == "allPart") {
- range4 = [
- {"row": [r1, range2["row"][0] - 1], "column": [c1, c2]},
- {"row": [range2["row"][0], r2], "column": [range2["column"][1] + 1, c2]},
- {"row": [range2["row"][0] + offset_r, r2 + offset_r], "column": [c1 + offset_c, range2["column"][1] + offset_c]}
- ];
- } else if (type == "restPart") {
- range4 = [
- {"row": [r1, range2["row"][0] - 1], "column": [c1, c2]},
- {"row": [range2["row"][0], r2], "column": [range2["column"][1] + 1, c2]}
- ];
- } else if (type == "operatePart") {
- range4 = [
- {"row": [range2["row"][0] + offset_r, r2 + offset_r], "column": [c1 + offset_c, range2["column"][1] + offset_c]}
- ];
- }
- } else if (r2 >= range2["row"][0] && r2 <= range2["row"][1] && c2 >= range2["column"][0] && c2 <= range2["column"][1]) {
- if (type == "allPart") {
- range4 = [
- {"row": [r1, range2["row"][0] - 1], "column": [c1, c2]},
- {"row": [range2["row"][0], r2], "column": [c1, range2["column"][0] - 1]},
- {"row": [range2["row"][0] + offset_r, r2 + offset_r], "column": [range2["column"][0] + offset_c, c2 + offset_c]}
- ];
- } else if (type == "restPart") {
- range4 = [
- {"row": [r1, range2["row"][0] - 1], "column": [c1, c2]},
- {"row": [range2["row"][0], r2], "column": [c1, range2["column"][0] - 1]}
- ];
- } else if (type == "operatePart") {
- range4 = [
- {"row": [range2["row"][0] + offset_r, r2 + offset_r], "column": [range2["column"][0] + offset_c, c2 + offset_c]}
- ];
- }
- } else if (r1 < range2["row"][0] && r2 > range2["row"][1] && c1 >= range2["column"][0] && c1 <= range2["column"][1]) {
- if (type == "allPart") {
- range4 = [
- {"row": [r1, range2["row"][0] - 1], "column": [c1, c2]},
- {"row": [range2["row"][0], range2["row"][1]], "column": [range2["column"][1] + 1, c2]},
- {"row": [range2["row"][1] + 1, r2], "column": [c1, c2]},
- {"row": [range2["row"][0] + offset_r, range2["row"][1] + offset_r], "column": [c1 + offset_c, range2["column"][1] + offset_c]}
- ];
- } else if (type == "restPart") {
- range4 = [
- {"row": [r1, range2["row"][0] - 1], "column": [c1, c2]},
- {"row": [range2["row"][0], range2["row"][1]], "column": [range2["column"][1] + 1, c2]},
- {"row": [range2["row"][1] + 1, r2], "column": [c1, c2]}
- ];
- } else if (type == "operatePart") {
- range4 = [
- {"row": [range2["row"][0] + offset_r, range2["row"][1] + offset_r], "column": [c1 + offset_c, range2["column"][1] + offset_c]}
- ];
- }
- } else if (r1 < range2["row"][0] && r2 > range2["row"][1] && c2 >= range2["column"][0] && c2 <= range2["column"][1]) {
- if (type == "allPart") {
- range4 = [
- {"row": [r1, range2["row"][0] - 1], "column": [c1, c2]},
- {"row": [range2["row"][0], range2["row"][1]], "column": [c1, range2["column"][0] - 1]},
- {"row": [range2["row"][1] + 1, r2], "column": [c1, c2]},
- {"row": [range2["row"][0] + offset_r, range2["row"][1] + offset_r], "column": [range2["column"][0] + offset_c, c2 + offset_c]}
- ];
- } else if (type == "restPart") {
- range4 = [
- {"row": [r1, range2["row"][0] - 1], "column": [c1, c2]},
- {"row": [range2["row"][0], range2["row"][1]], "column": [c1, range2["column"][0] - 1]},
- {"row": [range2["row"][1] + 1, r2], "column": [c1, c2]}
- ];
- } else if (type == "operatePart") {
- range4 = [
- {"row": [range2["row"][0] + offset_r, range2["row"][1] + offset_r], "column": [range2["column"][0] + offset_c, c2 + offset_c]}
- ];
- }
- } else if (c1 < range2["column"][0] && c2 > range2["column"][1] && r1 >= range2["row"][0] && r1 <= range2["row"][1]) {
- if (type == "allPart") {
- range4 = [
- {"row": [r1, range2["row"][1]], "column": [c1, range2["column"][0] - 1]},
- {"row": [r1, range2["row"][1]], "column": [range2["column"][1] + 1, c2]},
- {"row": [range2["row"][1] + 1, r2], "column": [c1, c2]},
- {"row": [r1 + offset_r, range2["row"][1] + offset_r], "column": [range2["column"][0] + offset_c, range2["column"][1] + offset_c]}
- ];
- } else if (type == "restPart") {
- range4 = [
- {"row": [r1, range2["row"][1]], "column": [c1, range2["column"][0] - 1]},
- {"row": [r1, range2["row"][1]], "column": [range2["column"][1] + 1, c2]},
- {"row": [range2["row"][1] + 1, r2], "column": [c1, c2]}
- ];
- } else if (type == "operatePart") {
- range4 = [
- {"row": [r1 + offset_r, range2["row"][1] + offset_r], "column": [range2["column"][0] + offset_c, range2["column"][1] + offset_c]}
- ];
- }
- } else if (c1 < range2["column"][0] && c2 > range2["column"][1] && r2 >= range2["row"][0] && r2 <= range2["row"][1]) {
- if (type == "allPart") {
- range4 = [
- {"row": [r1, range2["row"][0] - 1], "column": [c1, c2]},
- {"row": [range2["row"][0], r2], "column": [c1, range2["column"][0] - 1]},
- {"row": [range2["row"][0], r2], "column": [range2["column"][1] + 1, c2]},
- {"row": [range2["row"][0] + offset_r, r2 + offset_r], "column": [range2["column"][0] + offset_c, range2["column"][1] + offset_c]}
- ];
- } else if (type == "restPart") {
- range4 = [
- {"row": [r1, range2["row"][0] - 1], "column": [c1, c2]},
- {"row": [range2["row"][0], r2], "column": [c1, range2["column"][0] - 1]},
- {"row": [range2["row"][0], r2], "column": [range2["column"][1] + 1, c2]}
- ];
- } else if (type == "operatePart") {
- range4 = [
- {"row": [range2["row"][0] + offset_r, r2 + offset_r], "column": [range2["column"][0] + offset_c, range2["column"][1] + offset_c]}
- ];
- }
- } else if (r1 < range2["row"][0] && r2 > range2["row"][1] && c1 < range2["column"][0] && c2 > range2["column"][1]) {
- if (type == "allPart") {
- range4 = [
- {"row": [r1, range2["row"][0] - 1], "column": [c1, c2]},
- {"row": [range2["row"][0], range2["row"][1]], "column": [c1, range2["column"][0] - 1]},
- {"row": [range2["row"][0], range2["row"][1]], "column": [range2["column"][1] + 1, c2]},
- {"row": [range2["row"][1] + 1, r2], "column": [c1, c2]},
- {"row": [range2["row"][0] + offset_r, range2["row"][1] + offset_r], "column": [range2["column"][0] + offset_c, range2["column"][1] + offset_c]}
- ];
- } else if (type == "restPart") {
- range4 = [
- {"row": [r1, range2["row"][0] - 1], "column": [c1, c2]},
- {"row": [range2["row"][0], range2["row"][1]], "column": [c1, range2["column"][0] - 1]},
- {"row": [range2["row"][0], range2["row"][1]], "column": [range2["column"][1] + 1, c2]},
- {"row": [range2["row"][1] + 1, r2], "column": [c1, c2]}
- ];
- } else if (type == "operatePart") {
- range4 = [
- {"row": [range2["row"][0] + offset_r, range2["row"][1] + offset_r], "column": [range2["column"][0] + offset_c, range2["column"][1] + offset_c]}
- ];
- }
- } else {
- if (type == "allPart") {
- range4 = [
- {"row": [r1, r2], "column": [c1, c2]}
- ];
- } else if (type == "restPart") {
- range4 = [
- {"row": [r1, r2], "column": [c1, c2]}
- ];
- } else if (type == "operatePart") {
- range4 = [];
- }
- }
- return range4;
- },
- getcolorGradation: function(color1, color2, value1, value2, value) {
- let rgb1 = color1.split(",");
- let r1 = parseInt(rgb1[0].split("(")[1]);
- let g1 = parseInt(rgb1[1]);
- let b1 = parseInt(rgb1[2].split(")")[0]);
- let rgb2 = color2.split(",");
- let r2 = parseInt(rgb2[0].split("(")[1]);
- let g2 = parseInt(rgb2[1]);
- let b2 = parseInt(rgb2[2].split(")")[0]);
- let r3 = Math.round(r1 - (r1 - r2) / (value1 - value2) * (value1 - value));
- let g = Math.round(g1 - (g1 - g2) / (value1 - value2) * (value1 - value));
- let b = Math.round(b1 - (b1 - b2) / (value1 - value2) * (value1 - value));
- return "rgb(" + r3 + ", " + g + ", " + b + ")";
- },
- getCFPartRange: function(sheetIndex, range1, range2) {
- let ruleArr2 = [];
- let cf = store_default.luckysheetfile[getSheetIndex(sheetIndex)].luckysheet_conditionformat_save;
- if (cf != null && cf.length > 0) {
- label:
- for (let i2 = 0; i2 < cf.length; i2++) {
- let cellrange = cf[i2].cellrange;
- for (let j = 0; j < cellrange.length; j++) {
- let r1 = cellrange[j].row[0], r2 = cellrange[j].row[1];
- let c1 = cellrange[j].column[0], c2 = cellrange[j].column[1];
- for (let s = 0; s < range.length; s++) {
- if (range[s].row[0] >= r1 && range[s].row[0] <= r2 || range[s].row[1] >= r1 && range[s].row[1] <= r2 || range[s].column[0] >= c1 && range[s].column[0] <= c2 || range[s].column[1] >= c1 && range[s].column[1] <= c2) {
- ruleArr2.push(cf[i2]);
- continue label;
- }
- }
- }
- }
- }
- return ruleArr2;
- },
- checksCF: function(r2, c2, computeMap2) {
- if (computeMap2 != null && r2 + "_" + c2 in computeMap2) {
- return computeMap2[r2 + "_" + c2];
- } else {
- return null;
- }
- },
- getComputeMap: function(sheetIndex) {
- let index2 = getSheetIndex(store_default.currentSheetIndex);
- if (sheetIndex != null) {
- index2 = getSheetIndex(sheetIndex);
- }
- let ruleArr2 = store_default.luckysheetfile[index2]["luckysheet_conditionformat_save"];
- let data = store_default.luckysheetfile[index2]["data"];
- if (data == null) {
- return null;
- }
- let computeMap2 = this.compute(ruleArr2, data);
- return computeMap2;
- },
- compute: function(ruleArr2, d) {
- let _this2 = this;
- if (ruleArr2 == null) {
- ruleArr2 = [];
- }
- let computeMap2 = {};
- if (ruleArr2.length > 0) {
- for (let i2 = 0; i2 < ruleArr2.length; i2++) {
- let type = ruleArr2[i2]["type"];
- let cellrange = ruleArr2[i2]["cellrange"];
- let format = ruleArr2[i2]["format"];
- if (type == "dataBar") {
- let max = null, min = null;
- for (let s = 0; s < cellrange.length; s++) {
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- if (d[r2] == null || d[r2][c2] == null) {
- continue;
- }
- let cell = d[r2][c2];
- if (getObjType(cell) == "object" && cell["ct"] != null && cell["ct"].t == "n" && cell.v != null) {
- if (max == null || parseInt(cell.v) > max) {
- max = parseInt(cell.v);
- }
- if (min == null || parseInt(cell.v) < min) {
- min = parseInt(cell.v);
- }
- }
- }
- }
- }
- if (max != null && min != null) {
- if (min < 0) {
- let plusLen = Math.round(max / (max - min) * 10) / 10;
- let minusLen = Math.round(Math.abs(min) / (max - min) * 10) / 10;
- for (let s = 0; s < cellrange.length; s++) {
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- if (d[r2] == null || d[r2][c2] == null) {
- continue;
- }
- let cell = d[r2][c2];
- if (getObjType(cell) == "object" && cell["ct"] != null && cell["ct"].t == "n" && cell.v != null) {
- if (parseInt(cell.v) < 0) {
- let valueLen = Math.round(Math.abs(parseInt(cell.v)) / Math.abs(min) * 100) / 100;
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["dataBar"] = {"valueType": "minus", "minusLen": minusLen, "valueLen": valueLen, "format": format};
- } else {
- computeMap2[r2 + "_" + c2] = {"dataBar": {"valueType": "minus", "minusLen": minusLen, "valueLen": valueLen, "format": format}};
- }
- }
- if (parseInt(cell.v) > 0) {
- let valueLen = Math.round(parseInt(cell.v) / max * 100) / 100;
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["dataBar"] = {"valueType": "plus", "plusLen": plusLen, "minusLen": minusLen, "valueLen": valueLen, "format": format};
- } else {
- computeMap2[r2 + "_" + c2] = {"dataBar": {"valueType": "plus", "plusLen": plusLen, "minusLen": minusLen, "valueLen": valueLen, "format": format}};
- }
- }
- }
- }
- }
- }
- } else {
- let plusLen = 1;
- for (let s = 0; s < cellrange.length; s++) {
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- if (d[r2] == null || d[r2][c2] == null) {
- continue;
- }
- let cell = d[r2][c2];
- if (getObjType(cell) == "object" && cell["ct"] != null && cell["ct"].t == "n" && cell.v != null) {
- let valueLen;
- if (max == 0) {
- valueLen = 1;
- } else {
- valueLen = Math.round(parseInt(cell.v) / max * 100) / 100;
- }
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["dataBar"] = {"valueType": "plus", "plusLen": plusLen, "valueLen": valueLen, "format": format};
- } else {
- computeMap2[r2 + "_" + c2] = {"dataBar": {"valueType": "plus", "plusLen": plusLen, "valueLen": valueLen, "format": format}};
- }
- }
- }
- }
- }
- }
- }
- } else if (type == "colorGradation") {
- let max = null, min = null, sum = 0, count = 0;
- for (let s = 0; s < cellrange.length; s++) {
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- if (d[r2] == null || d[r2][c2] == null) {
- continue;
- }
- let cell = d[r2][c2];
- if (getObjType(cell) == "object" && cell["ct"] != null && cell["ct"].t == "n" && cell.v != null) {
- count++;
- sum += parseInt(cell.v);
- if (max == null || parseInt(cell.v) > max) {
- max = parseInt(cell.v);
- }
- if (min == null || parseInt(cell.v) < min) {
- min = parseInt(cell.v);
- }
- }
- }
- }
- }
- if (max != null && min != null) {
- if (format.length == 3) {
- let avg = Math.floor(sum / count);
- for (let s = 0; s < cellrange.length; s++) {
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- if (d[r2] == null || d[r2][c2] == null) {
- continue;
- }
- let cell = d[r2][c2];
- if (getObjType(cell) == "object" && cell["ct"] != null && cell["ct"].t == "n" && cell.v != null) {
- if (parseInt(cell.v) == min) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["cellColor"] = format[2];
- } else {
- computeMap2[r2 + "_" + c2] = {"cellColor": format[2]};
- }
- } else if (parseInt(cell.v) > min && parseInt(cell.v) < avg) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["cellColor"] = _this2.getcolorGradation(format[2], format[1], min, avg, parseInt(cell.v));
- } else {
- computeMap2[r2 + "_" + c2] = {"cellColor": _this2.getcolorGradation(format[2], format[1], min, avg, parseInt(cell.v))};
- }
- } else if (parseInt(cell.v) == avg) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["cellColor"] = format[1];
- } else {
- computeMap2[r2 + "_" + c2] = {"cellColor": format[1]};
- }
- } else if (parseInt(cell.v) > avg && parseInt(cell.v) < max) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["cellColor"] = _this2.getcolorGradation(format[1], format[0], avg, max, parseInt(cell.v));
- } else {
- computeMap2[r2 + "_" + c2] = {"cellColor": _this2.getcolorGradation(format[1], format[0], avg, max, parseInt(cell.v))};
- }
- } else if (parseInt(cell.v) == max) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["cellColor"] = format[0];
- } else {
- computeMap2[r2 + "_" + c2] = {"cellColor": format[0]};
- }
- }
- }
- }
- }
- }
- } else if (format.length == 2) {
- for (let s = 0; s < cellrange.length; s++) {
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- if (d[r2] == null || d[r2][c2] == null) {
- continue;
- }
- let cell = d[r2][c2];
- if (getObjType(cell) == "object" && cell["ct"] != null && cell["ct"].t == "n" && cell.v != null) {
- if (parseInt(cell.v) == min) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["cellColor"] = format[1];
- } else {
- computeMap2[r2 + "_" + c2] = {"cellColor": format[1]};
- }
- } else if (parseInt(cell.v) > min && parseInt(cell.v) < max) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["cellColor"] = _this2.getcolorGradation(format[1], format[0], min, max, parseInt(cell.v));
- } else {
- computeMap2[r2 + "_" + c2] = {"cellColor": _this2.getcolorGradation(format[1], format[0], min, max, parseInt(cell.v))};
- }
- } else if (parseInt(cell.v) == max) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["cellColor"] = format[0];
- } else {
- computeMap2[r2 + "_" + c2] = {"cellColor": format[0]};
- }
- }
- }
- }
- }
- }
- }
- }
- } else if (type == "icons") {
- let len = parseInt(format["len"]);
- let leftMin = parseInt(format["leftMin"]);
- let top = parseInt(format["top"]);
- let max = null, min = null;
- for (let s = 0; s < cellrange.length; s++) {
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- if (d[r2] == null || d[r2][c2] == null) {
- continue;
- }
- let cell = d[r2][c2];
- if (getObjType(cell) == "object" && cell["ct"] != null && cell["ct"].t == "n" && cell.v != null) {
- if (max == null || parseInt(cell.v) > max) {
- max = parseInt(cell.v);
- }
- if (min == null || parseInt(cell.v) < min) {
- min = parseInt(cell.v);
- }
- }
- }
- }
- }
- if (max != null && min != null) {
- let a = Math.floor((max - min + 1) / len);
- let b = (max - min + 1) % len;
- if (len == 3) {
- let v1, v2, v3;
- if (b == 2) {
- v1 = [min, min + a];
- v2 = [min + a + 1, min + a * 2];
- v3 = [min + a * 2 + 1, max];
- } else {
- v1 = [min, min + a - 1];
- v2 = [min + a, min + a * 2 - 1];
- v3 = [min + a * 2, max];
- }
- for (let s = 0; s < cellrange.length; s++) {
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- if (d[r2] == null || d[r2][c2] == null) {
- continue;
- }
- let cell = d[r2][c2];
- if (getObjType(cell) == "object" && cell["ct"] != null && cell["ct"].t == "n" && cell.v != null) {
- if (parseInt(cell.v) >= v1[0] && parseInt(cell.v) <= v1[1]) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["icons"] = {"left": leftMin + 2, "top": top};
- } else {
- computeMap2[r2 + "_" + c2] = {"icons": {"left": leftMin + 2, "top": top}};
- }
- } else if (parseInt(cell.v) >= v2[0] && parseInt(cell.v) <= v2[1]) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["icons"] = {"left": leftMin + 1, "top": top};
- } else {
- computeMap2[r2 + "_" + c2] = {"icons": {"left": leftMin + 1, "top": top}};
- }
- } else if (parseInt(cell.v) >= v3[0] && parseInt(cell.v) <= v3[1]) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["icons"] = {"left": leftMin, "top": top};
- } else {
- computeMap2[r2 + "_" + c2] = {"icons": {"left": leftMin, "top": top}};
- }
- }
- }
- }
- }
- }
- } else if (len == 4) {
- let v1, v2, v3, v4;
- if (b == 2) {
- v1 = [min, min + a];
- v2 = [min + a + 1, min + a * 2];
- v3 = [min + a * 2 + 1, min + a * 3];
- v4 = [min + a * 3 + 1, max];
- } else if (b == 3) {
- v1 = [min, min + a];
- v2 = [min + a + 1, min + a * 2];
- v3 = [min + a * 2 + 1, min + a * 3 + 1];
- v4 = [min + a * 3 + 2, max];
- } else {
- v1 = [min, min + a - 1];
- v2 = [min + a, min + a * 2 - 1];
- v3 = [min + a * 2, min + a * 3 - 1];
- v4 = [min + a * 3, max];
- }
- for (let s = 0; s < cellrange.length; s++) {
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- if (d[r2] == null || d[r2][c2] == null) {
- continue;
- }
- let cell = d[r2][c2];
- if (getObjType(cell) == "object" && cell["ct"] != null && cell["ct"].t == "n" && cell.v != null) {
- if (parseInt(cell.v) >= v1[0] && parseInt(cell.v) <= v1[1]) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["icons"] = {"left": leftMin + 3, "top": top};
- } else {
- computeMap2[r2 + "_" + c2] = {"icons": {"left": leftMin + 3, "top": top}};
- }
- } else if (parseInt(cell.v) >= v2[0] && parseInt(cell.v) <= v2[1]) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["icons"] = {"left": leftMin + 2, "top": top};
- } else {
- computeMap2[r2 + "_" + c2] = {"icons": {"left": leftMin + 2, "top": top}};
- }
- } else if (parseInt(cell.v) >= v3[0] && parseInt(cell.v) <= v3[1]) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["icons"] = {"left": leftMin + 1, "top": top};
- } else {
- computeMap2[r2 + "_" + c2] = {"icons": {"left": leftMin + 1, "top": top}};
- }
- } else if (parseInt(cell.v) >= v4[0] && parseInt(cell.v) <= v4[1]) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["icons"] = {"left": leftMin, "top": top};
- } else {
- computeMap2[r2 + "_" + c2] = {"icons": {"left": leftMin, "top": top}};
- }
- }
- }
- }
- }
- }
- } else if (len == 5) {
- let v1, v2, v3, v4, v5;
- if (b == 2) {
- v1 = [min, min + a];
- v2 = [min + a + 1, min + a * 2];
- v3 = [min + a * 2 + 1, min + a * 3];
- v4 = [min + a * 3 + 1, min + a * 4];
- v5 = [min + a * 4 + 1, max];
- } else if (b == 3) {
- v1 = [min, min + a];
- v2 = [min + a + 1, min + a * 2];
- v3 = [min + a * 2 + 1, min + a * 3 + 1];
- v4 = [min + a * 3 + 2, min + a * 4 + 1];
- v5 = [min + a * 4 + 2, max];
- } else if (b == 4) {
- v1 = [min, min + a];
- v2 = [min + a + 1, min + a * 2 + 1];
- v3 = [min + a * 2 + 2, min + a * 3 + 1];
- v4 = [min + a * 3 + 2, min + a * 4 + 2];
- v5 = [min + a * 4 + 3, max];
- } else {
- v1 = [min, min + a - 1];
- v2 = [min + a, min + a * 2 - 1];
- v3 = [min + a * 2, min + a * 3 - 1];
- v4 = [min + a * 3, min + a * 4 - 1];
- v5 = [min + a * 4, max];
- }
- for (let s = 0; s < cellrange.length; s++) {
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- if (d[r2] == null || d[r2][c2] == null) {
- continue;
- }
- let cell = d[r2][c2];
- if (getObjType(cell) == "object" && cell["ct"] != null && cell["ct"].t == "n" && cell.v != null) {
- if (parseInt(cell.v) >= v1[0] && parseInt(cell.v) <= v1[1]) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["icons"] = {"left": leftMin + 4, "top": top};
- } else {
- computeMap2[r2 + "_" + c2] = {"icons": {"left": leftMin + 4, "top": top}};
- }
- } else if (parseInt(cell.v) >= v2[0] && parseInt(cell.v) <= v2[1]) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["icons"] = {"left": leftMin + 3, "top": top};
- } else {
- computeMap2[r2 + "_" + c2] = {"icons": {"left": leftMin + 3, "top": top}};
- }
- } else if (parseInt(cell.v) >= v3[0] && parseInt(cell.v) <= v3[1]) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["icons"] = {"left": leftMin + 2, "top": top};
- } else {
- computeMap2[r2 + "_" + c2] = {"icons": {"left": leftMin + 2, "top": top}};
- }
- } else if (parseInt(cell.v) >= v4[0] && parseInt(cell.v) <= v4[1]) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["icons"] = {"left": leftMin + 1, "top": top};
- } else {
- computeMap2[r2 + "_" + c2] = {"icons": {"left": leftMin + 1, "top": top}};
- }
- } else if (parseInt(cell.v) >= v5[0] && parseInt(cell.v) <= v5[1]) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["icons"] = {"left": leftMin, "top": top};
- } else {
- computeMap2[r2 + "_" + c2] = {"icons": {"left": leftMin, "top": top}};
- }
- }
- }
- }
- }
- }
- }
- }
- } else {
- let conditionName = ruleArr2[i2].conditionName, conditionValue0 = ruleArr2[i2].conditionValue[0], conditionValue1 = ruleArr2[i2].conditionValue[1], textColor = format.textColor, cellColor = format.cellColor;
- for (let s = 0; s < cellrange.length; s++) {
- if (conditionName == "greaterThan" || conditionName == "lessThan" || conditionName == "equal" || conditionName == "textContains") {
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- if (d[r2] == null || d[r2][c2] == null) {
- continue;
- }
- let cell = d[r2][c2];
- if (getObjType(cell) != "object" || isRealNull(cell.v)) {
- continue;
- }
- if (conditionName == "greaterThan" && cell.v > conditionValue0) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["textColor"] = textColor;
- computeMap2[r2 + "_" + c2]["cellColor"] = cellColor;
- } else {
- computeMap2[r2 + "_" + c2] = {"textColor": textColor, "cellColor": cellColor};
- }
- } else if (conditionName == "lessThan" && cell.v < conditionValue0) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["textColor"] = textColor;
- computeMap2[r2 + "_" + c2]["cellColor"] = cellColor;
- } else {
- computeMap2[r2 + "_" + c2] = {"textColor": textColor, "cellColor": cellColor};
- }
- } else if (conditionName == "equal" && cell.v == conditionValue0) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["textColor"] = textColor;
- computeMap2[r2 + "_" + c2]["cellColor"] = cellColor;
- } else {
- computeMap2[r2 + "_" + c2] = {"textColor": textColor, "cellColor": cellColor};
- }
- } else if (conditionName == "textContains" && cell.v.toString().indexOf(conditionValue0) != -1) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["textColor"] = textColor;
- computeMap2[r2 + "_" + c2]["cellColor"] = cellColor;
- } else {
- computeMap2[r2 + "_" + c2] = {"textColor": textColor, "cellColor": cellColor};
- }
- }
- }
- }
- } else if (conditionName == "betweenness") {
- let vBig, vSmall;
- if (conditionValue0 > conditionValue1) {
- vBig = conditionValue0;
- vSmall = conditionValue1;
- } else {
- vBig = conditionValue1;
- vSmall = conditionValue0;
- }
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- if (d[r2] == null || d[r2][c2] == null) {
- continue;
- }
- let cell = d[r2][c2];
- if (getObjType(cell) != "object" || isRealNull(cell.v)) {
- continue;
- }
- if (cell.v >= vSmall && cell.v <= vBig) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["textColor"] = textColor;
- computeMap2[r2 + "_" + c2]["cellColor"] = cellColor;
- } else {
- computeMap2[r2 + "_" + c2] = {"textColor": textColor, "cellColor": cellColor};
- }
- }
- }
- }
- } else if (conditionName == "occurrenceDate") {
- let dBig, dSmall;
- if (conditionValue0.toString().indexOf("-") == -1) {
- dBig = genarate(conditionValue0)[2];
- dSmall = genarate(conditionValue0)[2];
- } else {
- let str = conditionValue0.toString().split("-");
- dBig = genarate(str[1].trim())[2];
- dSmall = genarate(str[0].trim())[2];
- }
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- if (d[r2] == null || d[r2][c2] == null) {
- continue;
- }
- if (d[r2][c2].ct != null && d[r2][c2].ct.t == "d") {
- let cellVal = getcellvalue(r2, c2, d);
- if (cellVal >= dSmall && cellVal <= dBig) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["textColor"] = textColor;
- computeMap2[r2 + "_" + c2]["cellColor"] = cellColor;
- } else {
- computeMap2[r2 + "_" + c2] = {"textColor": textColor, "cellColor": cellColor};
- }
- }
- }
- }
- }
- } else if (conditionName == "duplicateValue") {
- let dmap = {};
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- let item2 = getcellvalue(r2, c2, d);
- if (!(item2 in dmap)) {
- dmap[item2] = [];
- }
- dmap[item2].push({"r": r2, "c": c2});
- }
- }
- if (conditionValue0 == "0") {
- for (let x in dmap) {
- if (x != "null" && x != "undefined" && dmap[x].length > 1) {
- for (let j = 0; j < dmap[x].length; j++) {
- if (dmap[x][j].r + "_" + dmap[x][j].c in computeMap2) {
- computeMap2[dmap[x][j].r + "_" + dmap[x][j].c]["textColor"] = textColor;
- computeMap2[dmap[x][j].r + "_" + dmap[x][j].c]["cellColor"] = cellColor;
- } else {
- computeMap2[dmap[x][j].r + "_" + dmap[x][j].c] = {"textColor": textColor, "cellColor": cellColor};
- }
- }
- }
- }
- }
- if (conditionValue0 == "1") {
- for (let x in dmap) {
- if (x != "null" && x != "undefined" && dmap[x].length == 1) {
- if (dmap[x][0].r + "_" + dmap[x][0].c in computeMap2) {
- computeMap2[dmap[x][0].r + "_" + dmap[x][0].c]["textColor"] = textColor;
- computeMap2[dmap[x][0].r + "_" + dmap[x][0].c]["cellColor"] = cellColor;
- } else {
- computeMap2[dmap[x][0].r + "_" + dmap[x][0].c] = {"textColor": textColor, "cellColor": cellColor};
- }
- }
- }
- }
- } else if (conditionName == "top10" || conditionName == "top10%" || conditionName == "last10" || conditionName == "last10%" || conditionName == "AboveAverage" || conditionName == "SubAverage") {
- let dArr = [];
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- if (d[r2] == null || d[r2][c2] == null) {
- continue;
- }
- if (d[r2][c2].ct != null && d[r2][c2].ct.t == "n") {
- dArr.push(getcellvalue(r2, c2, d));
- }
- }
- }
- if (conditionName == "top10" || conditionName == "top10%" || conditionName == "last10" || conditionName == "last10%") {
- for (let j = 0; j < dArr.length; j++) {
- for (let k = 0; k < dArr.length - 1 - j; k++) {
- if (dArr[k] < dArr[k + 1]) {
- let temp = dArr[k];
- dArr[k] = dArr[k + 1];
- dArr[k + 1] = temp;
- }
- }
- }
- let cArr;
- if (conditionName == "top10") {
- cArr = dArr.slice(0, conditionValue0);
- } else if (conditionName == "top10%") {
- cArr = dArr.slice(0, Math.floor(conditionValue0 * dArr.length / 100));
- } else if (conditionName == "last10") {
- cArr = dArr.slice(dArr.length - conditionValue0, dArr.length);
- } else if (conditionName == "last10%") {
- cArr = dArr.slice(dArr.length - Math.floor(conditionValue0 * dArr.length / 100), dArr.length);
- }
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- if (d[r2] == null || d[r2][c2] == null) {
- continue;
- }
- let cellVal = getcellvalue(r2, c2, d);
- if (cArr.indexOf(cellVal) != -1) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["textColor"] = textColor;
- computeMap2[r2 + "_" + c2]["cellColor"] = cellColor;
- } else {
- computeMap2[r2 + "_" + c2] = {"textColor": textColor, "cellColor": cellColor};
- }
- }
- }
- }
- } else if (conditionName == "AboveAverage" || conditionName == "SubAverage") {
- let sum = 0;
- for (let j = 0; j < dArr.length; j++) {
- sum += dArr[j];
- }
- let averageNum = sum / dArr.length;
- if (conditionName == "AboveAverage") {
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- if (d[r2] == null || d[r2][c2] == null) {
- continue;
- }
- let cellVal = getcellvalue(r2, c2, d);
- if (cellVal > averageNum) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["textColor"] = textColor;
- computeMap2[r2 + "_" + c2]["cellColor"] = cellColor;
- } else {
- computeMap2[r2 + "_" + c2] = {"textColor": textColor, "cellColor": cellColor};
- }
- }
- }
- }
- } else if (conditionName == "SubAverage") {
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- if (d[r2] == null || d[r2][c2] == null) {
- continue;
- }
- let cellVal = getcellvalue(r2, c2, d);
- if (cellVal < averageNum) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["textColor"] = textColor;
- computeMap2[r2 + "_" + c2]["cellColor"] = cellColor;
- } else {
- computeMap2[r2 + "_" + c2] = {"textColor": textColor, "cellColor": cellColor};
- }
- }
- }
- }
- }
- }
- } else if (conditionName == "regExp") {
- let re = new RegExp(conditionValue0);
- if (conditionValue1 == void 0) {
- conditionValue1 = 1;
- }
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- if (d[r2] == null || d[r2][c2] == null) {
- continue;
- }
- let cell = d[r2][c2];
- if (getObjType(cell) != "object" || isRealNull(cell.v)) {
- continue;
- }
- let ret = re.test(cell.v);
- if (conditionValue1 == 1 && ret || conditionValue1 == 0 && !ret) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["textColor"] = textColor;
- computeMap2[r2 + "_" + c2]["cellColor"] = cellColor;
- } else {
- computeMap2[r2 + "_" + c2] = {"textColor": textColor, "cellColor": cellColor};
- }
- }
- }
- }
- } else if (conditionName == "sort") {
- for (let r2 = cellrange[s].row[0]; r2 <= cellrange[s].row[1]; r2++) {
- for (let c2 = cellrange[s].column[0]; c2 <= cellrange[s].column[1]; c2++) {
- if (d[r2] == null || d[r2][c2] == null) {
- continue;
- }
- let cell = d[r2][c2];
- if (r2 < 1) {
- continue;
- }
- let cellAbove = d[r2 - 1][c2];
- if (cellAbove == void 0) {
- continue;
- }
- if (getObjType(cell) != "object" || isRealNull(cell.v)) {
- continue;
- }
- if ($.inArray(conditionValue0, [0, "asc", "0"]) > -1 && cell.v > cellAbove.v || $.inArray(conditionValue0, [1, "1", "desc"]) > -1 && cell.v < cellAbove.v) {
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["textColor"] = textColor;
- computeMap2[r2 + "_" + c2]["cellColor"] = cellColor;
- } else {
- computeMap2[r2 + "_" + c2] = {"textColor": textColor, "cellColor": cellColor};
- }
- }
- }
- }
- } else if (conditionName == "formula") {
- let str = cellrange[s].row[0], edr = cellrange[s].row[1], stc = cellrange[s].column[0], edc = cellrange[s].column[1];
- let formulaTxt = conditionValue0;
- if (conditionValue0.toString().slice(0, 1) != "=") {
- formulaTxt = "=" + conditionValue0;
- }
- for (let r2 = str; r2 <= edr; r2++) {
- for (let c2 = stc; c2 <= edc; c2++) {
- let func = formulaTxt;
- let offsetRow = r2 - str;
- let offsetCol = c2 - stc;
- if (offsetRow > 0) {
- func = "=" + formula_default.functionCopy(func, "down", offsetRow);
- }
- if (offsetCol > 0) {
- func = "=" + formula_default.functionCopy(func, "right", offsetCol);
- }
- let funcV = formula_default.execfunction(func);
- let v = funcV[1];
- if (typeof v != "boolean") {
- v = !!Number(v);
- }
- if (!v) {
- continue;
- }
- if (r2 + "_" + c2 in computeMap2) {
- computeMap2[r2 + "_" + c2]["textColor"] = textColor;
- computeMap2[r2 + "_" + c2]["cellColor"] = cellColor;
- } else {
- computeMap2[r2 + "_" + c2] = {"textColor": textColor, "cellColor": cellColor};
- }
- }
- }
- }
- }
- }
- }
- }
- store_default.conditionFormatCells = computeMap2;
- return computeMap2;
- },
- updateItem: function(type, cellrange, format) {
- if (!checkProtectionFormatCells(store_default.currentSheetIndex)) {
- return;
- }
- let _this2 = this;
- let index2 = getSheetIndex(store_default.currentSheetIndex);
- let fileH = $.extend(true, [], store_default.luckysheetfile);
- let historyRules = _this2.getHistoryRules(fileH);
- let ruleArr2;
- if (type == "delSheet") {
- ruleArr2 = [];
- } else {
- let rule = {
- "type": type,
- "cellrange": cellrange,
- "format": format
- };
- ruleArr2 = store_default.luckysheetfile[index2]["luckysheet_conditionformat_save"] == null ? [] : store_default.luckysheetfile[index2]["luckysheet_conditionformat_save"];
- ruleArr2.push(rule);
- }
- store_default.luckysheetfile[index2]["luckysheet_conditionformat_save"] = ruleArr2;
- let fileC = $.extend(true, [], store_default.luckysheetfile);
- let currentRules = _this2.getCurrentRules(fileC);
- _this2.ref(historyRules, currentRules);
- if (server_default.allowUpdate) {
- server_default.saveParam("all", store_default.currentSheetIndex, ruleArr2, {"k": "luckysheet_conditionformat_save"});
- }
- },
- getHistoryRules: function(fileH) {
- let historyRules = [];
- for (let h = 0; h < fileH.length; h++) {
- historyRules.push({"sheetIndex": fileH[h]["index"], "luckysheet_conditionformat_save": fileH[h]["luckysheet_conditionformat_save"]});
- }
- return historyRules;
- },
- getCurrentRules: function(fileC) {
- let currentRules = [];
- for (let c2 = 0; c2 < fileC.length; c2++) {
- currentRules.push({"sheetIndex": fileC[c2]["index"], "luckysheet_conditionformat_save": fileC[c2]["luckysheet_conditionformat_save"]});
- }
- return currentRules;
- },
- ref: function(historyRules, currentRules) {
- if (store_default.clearjfundo) {
- store_default.jfundo.length = 0;
- let redo2 = {};
- redo2["type"] = "updateCF";
- redo2["data"] = {"historyRules": historyRules, "currentRules": currentRules};
- store_default.jfredo.push(redo2);
- }
- setTimeout(function() {
- luckysheetrefreshgrid();
- }, 1);
- }
- };
- conditionformat_default = conditionformat;
- }
- });
-
- // src/controllers/selection.js
- var selection, selection_default;
- var init_selection = __esm({
- "src/controllers/selection.js"() {
- init_select();
- init_menuButton();
- init_conditionformat();
- init_protection();
- init_editor();
- init_tooltip();
- init_formula();
- init_border();
- init_getdata();
- init_getRowlen();
- init_validate();
- init_refresh();
- init_format();
- init_get();
- init_util();
- init_store();
- init_locale();
- init_imageCtrl();
- selection = {
- clearcopy: function(e) {
- let clipboardData = window.clipboardData;
- if (!clipboardData) {
- if (!!e) {
- clipboardData = e.originalEvent.clipboardData;
- }
- }
- let cpdata = " ";
- store_default.luckysheet_selection_range = [];
- selectionCopyShow();
- if (!clipboardData) {
- let textarea = $("#luckysheet-copy-content").css("visibility", "hidden");
- textarea.val(cpdata);
- textarea.focus();
- textarea.select();
- setTimeout(function() {
- textarea.blur().css("visibility", "visible");
- }, 10);
- } else {
- clipboardData.setData("Text", cpdata);
- return false;
- }
- },
- getHtmlBorderStyle: function(type, color) {
- let style = "";
- let borderType = {
- 0: "none",
- 1: "Thin",
- 2: "Hair",
- 3: "Dotted",
- 4: "Dashed",
- 5: "DashDot",
- 6: "DashDotDot",
- 7: "Double",
- 8: "Medium",
- 9: "MediumDashed",
- 10: "MediumDashDot",
- 11: "MediumDashDotDot",
- 12: "SlantedDashDot",
- 13: "Thick"
- };
- type = borderType[type.toString()];
- if (type.indexOf("Medium") > -1) {
- style += "1pt ";
- } else if (type == "Thick") {
- style += "1.5pt ";
- } else {
- style += "0.5pt ";
- }
- if (type == "Hair") {
- style += "double ";
- } else if (type.indexOf("DashDotDot") > -1) {
- style += "dotted ";
- } else if (type.indexOf("DashDot") > -1) {
- style += "dashed ";
- } else if (type.indexOf("Dotted") > -1) {
- style += "dotted ";
- } else if (type.indexOf("Dashed") > -1) {
- style += "dashed ";
- } else {
- style += "solid ";
- }
- return style + color + ";";
- },
- copy: function(e) {
- let clipboardData = window.clipboardData;
- if (!clipboardData) {
- clipboardData = e.originalEvent.clipboardData;
- }
- store_default.luckysheet_selection_range = [];
- let rowIndexArr = [], colIndexArr = [];
- let copyRange = [], RowlChange = false, HasMC = false;
- for (let s = 0; s < store_default.luckysheet_select_save.length; s++) {
- let range2 = store_default.luckysheet_select_save[s];
- let r1 = range2.row[0], r2 = range2.row[1];
- let c1 = range2.column[0], c2 = range2.column[1];
- for (let copyR = r1; copyR <= r2; copyR++) {
- if (store_default.config["rowhidden"] != null && store_default.config["rowhidden"][copyR] != null) {
- continue;
- }
- if (!rowIndexArr.includes(copyR)) {
- rowIndexArr.push(copyR);
- }
- if (store_default.config["rowlen"] != null && copyR in store_default.config["rowlen"]) {
- RowlChange = true;
- }
- for (let copyC = c1; copyC <= c2; copyC++) {
- if (store_default.config["colhidden"] != null && store_default.config["colhidden"][copyC] != null) {
- continue;
- }
- if (!colIndexArr.includes(copyC)) {
- colIndexArr.push(copyC);
- }
- let cell = store_default.flowdata[copyR][copyC];
- if (getObjType(cell) == "object" && "mc" in cell && cell.mc.rs != null) {
- HasMC = true;
- }
- }
- }
- store_default.luckysheet_selection_range.push({row: range2.row, column: range2.column});
- copyRange.push({row: range2.row, column: range2.column});
- }
- selectionCopyShow();
- store_default.luckysheet_copy_save = {
- dataSheetIndex: store_default.currentSheetIndex,
- copyRange,
- RowlChange,
- HasMC
- };
- let _this2 = this;
- let borderInfoCompute;
- if (store_default.config["borderInfo"] && store_default.config["borderInfo"].length > 0) {
- borderInfoCompute = getBorderInfoCompute();
- }
- let cpdata = "", d = editor_default.deepCopyFlowData(store_default.flowdata);
- let colgroup = "";
- for (let i2 = 0; i2 < rowIndexArr.length; i2++) {
- let r2 = rowIndexArr[i2];
- if (store_default.config["rowhidden"] != null && store_default.config["rowhidden"][r2] != null) {
- continue;
- }
- if (store_default.config == null || store_default.config["rowlen"] == null || store_default.config["rowlen"][r2.toString()] == null) {
- cpdata += '';
- } else {
- cpdata += ` `;
- }
- for (let j = 0; j < colIndexArr.length; j++) {
- let c2 = colIndexArr[j];
- if (r2 == rowIndexArr[0]) {
- if (store_default.config == null || store_default.config["columnlen"] == null || store_default.config["columnlen"][c2.toString()] == null) {
- colgroup += ' ';
- } else {
- colgroup += ' ';
- }
- }
- if (store_default.config["colhidden"] != null && store_default.config["colhidden"][c2] != null) {
- continue;
- }
- let column = '';
- if (d[r2] != null && d[r2][c2] != null) {
- let style = "", span = "";
- let reg = /^(w|W)((0?)|(0\.0+))$/;
- let c_value;
- if (d[r2][c2].ct != null && d[r2][c2].ct.fa != null && d[r2][c2].ct.fa.match(reg)) {
- c_value = getcellvalue(r2, c2, d);
- } else {
- c_value = getcellvalue(r2, c2, d, "m");
- }
- style += menuButton_default.getStyleByCell(d, r2, c2);
- if (getObjType(d[r2][c2]) == "object" && "mc" in d[r2][c2]) {
- if ("rs" in d[r2][c2]["mc"]) {
- span = 'rowspan="' + d[r2][c2]["mc"].rs + '" colspan="' + d[r2][c2]["mc"].cs + '"';
- if (borderInfoCompute && borderInfoCompute[r2 + "_" + c2]) {
- let bl_obj = {color: {}, style: {}}, br_obj = {color: {}, style: {}}, bt_obj = {color: {}, style: {}}, bb_obj = {color: {}, style: {}};
- for (let bd_r = r2; bd_r < r2 + d[r2][c2]["mc"].rs; bd_r++) {
- for (let bd_c = c2; bd_c < c2 + d[r2][c2]["mc"].cs; bd_c++) {
- if (bd_r == r2 && borderInfoCompute[bd_r + "_" + bd_c] && borderInfoCompute[bd_r + "_" + bd_c].t) {
- let linetype = borderInfoCompute[bd_r + "_" + bd_c].t.style;
- let bcolor = borderInfoCompute[bd_r + "_" + bd_c].t.color;
- if (bt_obj["style"][linetype] == null) {
- bt_obj["style"][linetype] = 1;
- } else {
- bt_obj["style"][linetype] = bt_obj["style"][linetype] + 1;
- }
- if (bt_obj["color"][bcolor] == null) {
- bt_obj["color"][bcolor] = 1;
- } else {
- bt_obj["color"][bcolor] = bt_obj["color"][bcolor] + 1;
- }
- }
- if (bd_r == r2 + d[r2][c2]["mc"].rs - 1 && borderInfoCompute[bd_r + "_" + bd_c] && borderInfoCompute[bd_r + "_" + bd_c].b) {
- let linetype = borderInfoCompute[bd_r + "_" + bd_c].b.style;
- let bcolor = borderInfoCompute[bd_r + "_" + bd_c].b.color;
- if (bb_obj["style"][linetype] == null) {
- bb_obj["style"][linetype] = 1;
- } else {
- bb_obj["style"][linetype] = bb_obj["style"][linetype] + 1;
- }
- if (bb_obj["color"][bcolor] == null) {
- bb_obj["color"][bcolor] = 1;
- } else {
- bb_obj["color"][bcolor] = bb_obj["color"][bcolor] + 1;
- }
- }
- if (bd_c == c2 && borderInfoCompute[bd_r + "_" + bd_c] && borderInfoCompute[bd_r + "_" + bd_c].l) {
- let linetype = borderInfoCompute[r2 + "_" + c2].l.style;
- let bcolor = borderInfoCompute[bd_r + "_" + bd_c].l.color;
- if (bl_obj["style"][linetype] == null) {
- bl_obj["style"][linetype] = 1;
- } else {
- bl_obj["style"][linetype] = bl_obj["style"][linetype] + 1;
- }
- if (bl_obj["color"][bcolor] == null) {
- bl_obj["color"][bcolor] = 1;
- } else {
- bl_obj["color"][bcolor] = bl_obj["color"][bcolor] + 1;
- }
- }
- if (bd_c == c2 + d[r2][c2]["mc"].cs - 1 && borderInfoCompute[bd_r + "_" + bd_c] && borderInfoCompute[bd_r + "_" + bd_c].r) {
- let linetype = borderInfoCompute[bd_r + "_" + bd_c].r.style;
- let bcolor = borderInfoCompute[bd_r + "_" + bd_c].r.color;
- if (br_obj["style"][linetype] == null) {
- br_obj["style"][linetype] = 1;
- } else {
- br_obj["style"][linetype] = br_obj["style"][linetype] + 1;
- }
- if (br_obj["color"][bcolor] == null) {
- br_obj["color"][bcolor] = 1;
- } else {
- br_obj["color"][bcolor] = br_obj["color"][bcolor] + 1;
- }
- }
- }
- }
- let rowlen = d[r2][c2]["mc"].rs, collen = d[r2][c2]["mc"].cs;
- if (JSON.stringify(bl_obj).length > 23) {
- let bl_color = null, bl_style = null;
- for (let x in bl_obj.color) {
- if (bl_obj.color[x] >= rowlen / 2) {
- bl_color = x;
- }
- }
- for (let x in bl_obj.style) {
- if (bl_obj.style[x] >= rowlen / 2) {
- bl_style = x;
- }
- }
- if (bl_color != null && bl_style != null) {
- style += "border-left:" + _this2.getHtmlBorderStyle(bl_style, bl_color);
- }
- }
- if (JSON.stringify(br_obj).length > 23) {
- let br_color = null, br_style = null;
- for (let x in br_obj.color) {
- if (br_obj.color[x] >= rowlen / 2) {
- br_color = x;
- }
- }
- for (let x in br_obj.style) {
- if (br_obj.style[x] >= rowlen / 2) {
- br_style = x;
- }
- }
- if (br_color != null && br_style != null) {
- style += "border-right:" + _this2.getHtmlBorderStyle(br_style, br_color);
- }
- }
- if (JSON.stringify(bt_obj).length > 23) {
- let bt_color = null, bt_style = null;
- for (let x in bt_obj.color) {
- if (bt_obj.color[x] >= collen / 2) {
- bt_color = x;
- }
- }
- for (let x in bt_obj.style) {
- if (bt_obj.style[x] >= collen / 2) {
- bt_style = x;
- }
- }
- if (bt_color != null && bt_style != null) {
- style += "border-top:" + _this2.getHtmlBorderStyle(bt_style, bt_color);
- }
- }
- if (JSON.stringify(bb_obj).length > 23) {
- let bb_color = null, bb_style = null;
- for (let x in bb_obj.color) {
- if (bb_obj.color[x] >= collen / 2) {
- bb_color = x;
- }
- }
- for (let x in bb_obj.style) {
- if (bb_obj.style[x] >= collen / 2) {
- bb_style = x;
- }
- }
- if (bb_color != null && bb_style != null) {
- style += "border-bottom:" + _this2.getHtmlBorderStyle(bb_style, bb_color);
- }
- }
- }
- } else {
- continue;
- }
- } else {
- if (borderInfoCompute && borderInfoCompute[r2 + "_" + c2]) {
- if (borderInfoCompute[r2 + "_" + c2].l) {
- let linetype = borderInfoCompute[r2 + "_" + c2].l.style;
- let bcolor = borderInfoCompute[r2 + "_" + c2].l.color;
- style += "border-left:" + _this2.getHtmlBorderStyle(linetype, bcolor);
- }
- if (borderInfoCompute[r2 + "_" + c2].r) {
- let linetype = borderInfoCompute[r2 + "_" + c2].r.style;
- let bcolor = borderInfoCompute[r2 + "_" + c2].r.color;
- style += "border-right:" + _this2.getHtmlBorderStyle(linetype, bcolor);
- }
- if (borderInfoCompute[r2 + "_" + c2].b) {
- let linetype = borderInfoCompute[r2 + "_" + c2].b.style;
- let bcolor = borderInfoCompute[r2 + "_" + c2].b.color;
- style += "border-bottom:" + _this2.getHtmlBorderStyle(linetype, bcolor);
- }
- if (borderInfoCompute[r2 + "_" + c2].t) {
- let linetype = borderInfoCompute[r2 + "_" + c2].t.style;
- let bcolor = borderInfoCompute[r2 + "_" + c2].t.color;
- style += "border-top:" + _this2.getHtmlBorderStyle(linetype, bcolor);
- }
- }
- }
- column = replaceHtml(column, {style, span});
- if (c_value == null) {
- c_value = getcellvalue(r2, c2, d);
- }
- if (c_value == null && d[r2][c2] && d[r2][c2].ct && d[r2][c2].ct.t == "inlineStr") {
- c_value = d[r2][c2].ct.s.map((val) => {
- const brDom = $(' ');
- const splitValue = val.v.split("\r\n");
- return splitValue.map((item2) => {
- if (!item2) {
- return "";
- }
- const font = $(" ");
- val.fs && font.css("font-size", `${val.fs}pt`);
- val.bl && font.css("font-weight", "bold");
- val.it && font.css("font-style", "italic");
- val.un && font.css("text-decoration", "underline");
- val.fc && font.css("color", val.fc);
- if (val.cl) {
- font.append(`${item2} `);
- } else {
- font.text(item2);
- }
- return font[0].outerHTML;
- }).join(brDom[0].outerHTML);
- }).join("");
- }
- if (c_value == null) {
- c_value = "";
- }
- column += c_value;
- } else {
- let style = "";
- if (borderInfoCompute && borderInfoCompute[r2 + "_" + c2]) {
- if (borderInfoCompute[r2 + "_" + c2].l) {
- let linetype = borderInfoCompute[r2 + "_" + c2].l.style;
- let bcolor = borderInfoCompute[r2 + "_" + c2].l.color;
- style += "border-left:" + _this2.getHtmlBorderStyle(linetype, bcolor);
- }
- if (borderInfoCompute[r2 + "_" + c2].r) {
- let linetype = borderInfoCompute[r2 + "_" + c2].r.style;
- let bcolor = borderInfoCompute[r2 + "_" + c2].r.color;
- style += "border-right:" + _this2.getHtmlBorderStyle(linetype, bcolor);
- }
- if (borderInfoCompute[r2 + "_" + c2].b) {
- let linetype = borderInfoCompute[r2 + "_" + c2].b.style;
- let bcolor = borderInfoCompute[r2 + "_" + c2].b.color;
- style += "border-bottom:" + _this2.getHtmlBorderStyle(linetype, bcolor);
- }
- if (borderInfoCompute[r2 + "_" + c2].t) {
- let linetype = borderInfoCompute[r2 + "_" + c2].t.style;
- let bcolor = borderInfoCompute[r2 + "_" + c2].t.color;
- style += "border-top:" + _this2.getHtmlBorderStyle(linetype, bcolor);
- }
- }
- column += "";
- column = replaceHtml(column, {style, span: ""});
- column += "";
- }
- column += " ";
- cpdata += column;
- }
- cpdata += " ";
- }
- cpdata = `${colgroup} ` + cpdata + "
";
- store_default.iscopyself = true;
- if (!clipboardData) {
- let textarea = $("#luckysheet-copy-content");
- textarea.html(cpdata);
- textarea.focus();
- textarea.select();
- document.execCommand("selectAll");
- document.execCommand("Copy");
- setTimeout(function() {
- $("#luckysheet-copy-content").blur();
- }, 10);
- } else {
- clipboardData.setData("Text", cpdata);
- return false;
- }
- },
- copybyformat: function(e, txt) {
- let clipboardData = window.clipboardData;
- if (!clipboardData) {
- clipboardData = e.originalEvent && e.originalEvent.clipboardData;
- }
- store_default.luckysheet_selection_range = [
- {row: store_default.luckysheet_select_save[0].row, column: store_default.luckysheet_select_save[0].column}
- ];
- selectionCopyShow();
- let cpdata = txt;
- store_default.iscopyself = true;
- if (!clipboardData) {
- let textarea = $("#luckysheet-copy-content");
- textarea.text(cpdata);
- textarea.focus();
- textarea.select();
- document.execCommand("selectAll");
- document.execCommand("Copy");
- setTimeout(function() {
- textarea.blur();
- }, 10);
- } else {
- clipboardData.setData("Text", cpdata);
- return false;
- }
- },
- isPasteAction: false,
- paste: function(e, triggerType) {
- let _this2 = this;
- if (store_default.allowEdit === false) {
- return;
- }
- const _locale = locale_default();
- const local_drag = _locale.drag;
- let textarea = $("#luckysheet-copy-content");
- textarea.focus();
- textarea.select();
- setTimeout(function() {
- let data = textarea.html();
- if (data.indexOf("luckysheet_copy_action_table") > -1 && store_default.luckysheet_copy_save["copyRange"] != null && store_default.luckysheet_copy_save["copyRange"].length > 0) {
- if (store_default.luckysheet_paste_iscut) {
- store_default.luckysheet_paste_iscut = false;
- _this2.pasteHandlerOfCutPaste(store_default.luckysheet_copy_save);
- _this2.clearcopy(e);
- } else {
- _this2.pasteHandlerOfCopyPaste(store_default.luckysheet_copy_save);
- }
- } else if (data.indexOf("luckysheet_copy_action_image") > -1) {
- imageCtrl_default.pasteImgItem();
- } else if (triggerType != "btn") {
- _this2.pasteHandler(data);
- } else {
- if (isEditMode()) {
- alert(local_drag.pasteMustKeybordAlert);
- } else {
- tooltip_default.info(local_drag.pasteMustKeybordAlertHTMLTitle, local_drag.pasteMustKeybordAlertHTML);
- }
- }
- }, 10);
- },
- pasteHandler: function(data, borderInfo) {
- if (!checkProtectionLockedRangeList(store_default.luckysheet_select_save, store_default.currentSheetIndex)) {
- return;
- }
- if (store_default.allowEdit === false) {
- return;
- }
- const _locale = locale_default();
- const locale_paste = _locale.paste;
- if (store_default.luckysheet_select_save.length > 1) {
- if (isEditMode()) {
- alert(locale_paste.errorNotAllowMulti);
- } else {
- tooltip_default.info(` ${locale_paste.warning}`, locale_paste.errorNotAllowMulti);
- }
- }
- if (typeof data == "object") {
- if (data.length == 0) {
- return;
- }
- let cfg = $.extend(true, {}, store_default.config);
- if (cfg["merge"] == null) {
- cfg["merge"] = {};
- }
- if (JSON.stringify(borderInfo).length > 2 && cfg["borderInfo"] == null) {
- cfg["borderInfo"] = [];
- }
- let copyh = data.length, copyc = data[0].length;
- let minh = store_default.luckysheet_select_save[0].row[0], maxh = minh + copyh - 1;
- let minc = store_default.luckysheet_select_save[0].column[0], maxc = minc + copyc - 1;
- let has_PartMC = false;
- if (cfg["merge"] != null) {
- has_PartMC = hasPartMC(cfg, minh, maxh, minc, maxc);
- }
- if (has_PartMC) {
- if (isEditMode()) {
- alert(locale_paste.errorNotAllowMerged);
- } else {
- tooltip_default.info(` ${locale_paste.warning}`, locale_paste.errorNotAllowMerged);
- }
- return;
- }
- let d = editor_default.deepCopyFlowData(store_default.flowdata);
- let rowMaxLength = d.length;
- let cellMaxLength = d[0].length;
- let addr = maxh - rowMaxLength + 1, addc = maxc - cellMaxLength + 1;
- if (addr > 0 || addc > 0) {
- d = datagridgrowth([].concat(d), addr, addc, true);
- }
- if (cfg["rowlen"] == null) {
- cfg["rowlen"] = {};
- }
- let RowlChange = false;
- let offsetMC = {};
- for (let h = minh; h <= maxh; h++) {
- let x = [].concat(d[h]);
- let currentRowLen = store_default.defaultrowlen;
- if (cfg["rowlen"][h] != null) {
- currentRowLen = cfg["rowlen"][h];
- }
- for (let c2 = minc; c2 <= maxc; c2++) {
- if (getObjType(x[c2]) == "object" && "mc" in x[c2]) {
- if ("rs" in x[c2].mc) {
- delete cfg["merge"][x[c2]["mc"].r + "_" + x[c2]["mc"].c];
- }
- delete x[c2].mc;
- }
- let value = null;
- if (data[h - minh] != null && data[h - minh][c2 - minc] != null) {
- value = data[h - minh][c2 - minc];
- }
- x[c2] = $.extend(true, {}, value);
- if (value != null && "mc" in x[c2]) {
- if (x[c2]["mc"].rs != null) {
- x[c2]["mc"].r = h;
- x[c2]["mc"].c = c2;
- cfg["merge"][x[c2]["mc"].r + "_" + x[c2]["mc"].c] = x[c2]["mc"];
- offsetMC[value["mc"].r + "_" + value["mc"].c] = [x[c2]["mc"].r, x[c2]["mc"].c];
- } else {
- x[c2] = {
- mc: {
- r: offsetMC[value["mc"].r + "_" + value["mc"].c][0],
- c: offsetMC[value["mc"].r + "_" + value["mc"].c][1]
- }
- };
- }
- }
- if (borderInfo[h - minh + "_" + (c2 - minc)]) {
- let bd_obj = {
- rangeType: "cell",
- value: {
- row_index: h,
- col_index: c2,
- l: borderInfo[h - minh + "_" + (c2 - minc)].l,
- r: borderInfo[h - minh + "_" + (c2 - minc)].r,
- t: borderInfo[h - minh + "_" + (c2 - minc)].t,
- b: borderInfo[h - minh + "_" + (c2 - minc)].b
- }
- };
- cfg["borderInfo"].push(bd_obj);
- }
- let fontset = luckysheetfontformat(x[c2]);
- let oneLineTextHeight = menuButton_default.getTextSize("\u7530", fontset)[1];
- if (oneLineTextHeight > currentRowLen) {
- currentRowLen = oneLineTextHeight;
- RowlChange = true;
- }
- }
- d[h] = x;
- if (currentRowLen != store_default.defaultrowlen) {
- cfg["rowlen"][h] = currentRowLen;
- }
- }
- store_default.luckysheet_select_save = [{row: [minh, maxh], column: [minc, maxc]}];
- if (addr > 0 || addc > 0 || RowlChange) {
- let allParam = {
- cfg,
- RowlChange: true
- };
- jfrefreshgrid(d, store_default.luckysheet_select_save, allParam);
- } else {
- let allParam = {
- cfg
- };
- jfrefreshgrid(d, store_default.luckysheet_select_save, allParam);
- selectHightlightShow();
- }
- } else {
- data = data.replace(/\r/g, "");
- let dataChe = [];
- let che = data.split("\n"), colchelen = che[0].split(" ").length;
- for (let i2 = 0; i2 < che.length; i2++) {
- if (che[i2].split(" ").length < colchelen) {
- continue;
- }
- dataChe.push(che[i2].split(" "));
- }
- let d = editor_default.deepCopyFlowData(store_default.flowdata);
- let last = store_default.luckysheet_select_save[store_default.luckysheet_select_save.length - 1];
- let curR = last["row"] == null ? 0 : last["row"][0];
- let curC = last["column"] == null ? 0 : last["column"][0];
- let rlen = dataChe.length, clen = dataChe[0].length;
- let has_PartMC = false;
- if (store_default.config["merge"] != null) {
- has_PartMC = hasPartMC(store_default.config, curR, curR + rlen - 1, curC, curC + clen - 1);
- }
- if (has_PartMC) {
- if (isEditMode()) {
- alert(locale_paste.errorNotAllowMerged);
- } else {
- tooltip_default.info(` ${locale_paste.warning}`, locale_paste.errorNotAllowMerged);
- }
- return;
- }
- let addr = curR + rlen - d.length, addc = curC + clen - d[0].length;
- if (addr > 0 || addc > 0) {
- d = datagridgrowth([].concat(d), addr, addc, true);
- }
- for (let r2 = 0; r2 < rlen; r2++) {
- let x = [].concat(d[r2 + curR]);
- for (let c2 = 0; c2 < clen; c2++) {
- let originCell = x[c2 + curC];
- let value = dataChe[r2][c2];
- if (isRealNum(value)) {
- if (originCell && originCell.ct && originCell.ct.fa === "@") {
- value = String(value);
- } else {
- value = parseFloat(value);
- }
- }
- if (originCell instanceof Object) {
- originCell.v = value;
- if (originCell.ct != null && originCell.ct.fa != null) {
- originCell.m = update(originCell["ct"]["fa"], value);
- } else {
- originCell.m = value;
- }
- if (originCell.f != null && originCell.f.length > 0) {
- originCell.f = "";
- formula_default.delFunctionGroup(r2 + curR, c2 + curC, store_default.currentSheetIndex);
- }
- } else {
- let cell = {};
- let mask = genarate(value);
- cell.v = mask[2];
- cell.ct = mask[1];
- cell.m = mask[0];
- x[c2 + curC] = cell;
- }
- }
- d[r2 + curR] = x;
- }
- last["row"] = [curR, curR + rlen - 1];
- last["column"] = [curC, curC + clen - 1];
- if (addr > 0 || addc > 0) {
- let allParam = {
- RowlChange: true
- };
- jfrefreshgrid(d, store_default.luckysheet_select_save, allParam);
- } else {
- jfrefreshgrid(d, store_default.luckysheet_select_save);
- selectHightlightShow();
- }
- }
- },
- pasteHandlerOfCutPaste: function(copyRange) {
- if (!checkProtectionLockedRangeList(store_default.luckysheet_select_save, store_default.currentSheetIndex)) {
- return;
- }
- if (store_default.allowEdit === false) {
- return;
- }
- const _locale = locale_default();
- const locale_paste = _locale.paste;
- let cfg = $.extend(true, {}, store_default.config);
- if (cfg["merge"] == null) {
- cfg["merge"] = {};
- }
- let copyHasMC = copyRange["HasMC"];
- let copyRowlChange = copyRange["RowlChange"];
- let copySheetIndex = copyRange["dataSheetIndex"];
- let c_r1 = copyRange["copyRange"][0].row[0], c_r2 = copyRange["copyRange"][0].row[1], c_c1 = copyRange["copyRange"][0].column[0], c_c2 = copyRange["copyRange"][0].column[1];
- let copyData = $.extend(true, [], getdatabyselection({row: [c_r1, c_r2], column: [c_c1, c_c2]}, copySheetIndex));
- let copyh = copyData.length, copyc = copyData[0].length;
- let last = store_default.luckysheet_select_save[store_default.luckysheet_select_save.length - 1];
- let minh = last["row_focus"], maxh = minh + copyh - 1;
- let minc = last["column_focus"], maxc = minc + copyc - 1;
- let has_PartMC = false;
- if (cfg["merge"] != null) {
- has_PartMC = hasPartMC(cfg, minh, maxh, minc, maxc);
- }
- if (has_PartMC) {
- if (isEditMode()) {
- alert(locale_paste.errorNotAllowMerged);
- } else {
- tooltip_default.info(` ${locale_paste.warning}`, locale_paste.errorNotAllowMerged);
- }
- return;
- }
- let d = editor_default.deepCopyFlowData(store_default.flowdata);
- let rowMaxLength = d.length;
- let cellMaxLength = d[0].length;
- let addr = copyh + minh - rowMaxLength, addc = copyc + minc - cellMaxLength;
- if (addr > 0 || addc > 0) {
- d = datagridgrowth([].concat(d), addr, addc, true);
- }
- let borderInfoCompute = getBorderInfoCompute(copySheetIndex);
- let c_dataVerification = $.extend(true, {}, store_default.luckysheetfile[getSheetIndex(copySheetIndex)]["dataVerification"]);
- let dataVerification = $.extend(true, {}, store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)]["dataVerification"]);
- if (store_default.currentSheetIndex == copySheetIndex) {
- for (let i2 = c_r1; i2 <= c_r2; i2++) {
- for (let j = c_c1; j <= c_c2; j++) {
- let cell = d[i2][j];
- if (getObjType(cell) == "object" && "mc" in cell) {
- if ("rs" in cell["mc"]) {
- delete cfg["merge"][cell["mc"].r + "_" + cell["mc"].c];
- }
- delete cell["mc"];
- }
- d[i2][j] = null;
- delete dataVerification[i2 + "_" + j];
- }
- }
- if (cfg["borderInfo"] && cfg["borderInfo"].length > 0) {
- let source_borderInfo = [];
- for (let i2 = 0; i2 < cfg["borderInfo"].length; i2++) {
- let bd_rangeType = cfg["borderInfo"][i2].rangeType;
- if (bd_rangeType == "range") {
- let bd_range = cfg["borderInfo"][i2].range;
- let bd_emptyRange = [];
- for (let j = 0; j < bd_range.length; j++) {
- bd_emptyRange = bd_emptyRange.concat(conditionformat_default.CFSplitRange(bd_range[j], {row: [c_r1, c_r2], column: [c_c1, c_c2]}, {row: [minh, maxh], column: [minc, maxc]}, "restPart"));
- }
- cfg["borderInfo"][i2].range = bd_emptyRange;
- source_borderInfo.push(cfg["borderInfo"][i2]);
- } else if (bd_rangeType == "cell") {
- let bd_r = cfg["borderInfo"][i2].value.row_index;
- let bd_c = cfg["borderInfo"][i2].value.col_index;
- if (!(bd_r >= c_r1 && bd_r <= c_r2 && bd_c >= c_c1 && bd_c <= c_c2)) {
- source_borderInfo.push(cfg["borderInfo"][i2]);
- }
- }
- }
- cfg["borderInfo"] = source_borderInfo;
- }
- }
- let offsetMC = {};
- for (let h = minh; h <= maxh; h++) {
- let x = [].concat(d[h]);
- for (let c2 = minc; c2 <= maxc; c2++) {
- if (borderInfoCompute[c_r1 + h - minh + "_" + (c_c1 + c2 - minc)]) {
- let bd_obj = {
- rangeType: "cell",
- value: {
- row_index: h,
- col_index: c2,
- l: borderInfoCompute[c_r1 + h - minh + "_" + (c_c1 + c2 - minc)].l,
- r: borderInfoCompute[c_r1 + h - minh + "_" + (c_c1 + c2 - minc)].r,
- t: borderInfoCompute[c_r1 + h - minh + "_" + (c_c1 + c2 - minc)].t,
- b: borderInfoCompute[c_r1 + h - minh + "_" + (c_c1 + c2 - minc)].b
- }
- };
- if (cfg["borderInfo"] == null) {
- cfg["borderInfo"] = [];
- }
- cfg["borderInfo"].push(bd_obj);
- } else if (borderInfoCompute[h + "_" + c2]) {
- let bd_obj = {
- rangeType: "cell",
- value: {
- row_index: h,
- col_index: c2,
- l: null,
- r: null,
- t: null,
- b: null
- }
- };
- if (cfg["borderInfo"] == null) {
- cfg["borderInfo"] = [];
- }
- cfg["borderInfo"].push(bd_obj);
- }
- if (c_dataVerification[c_r1 + h - minh + "_" + (c_c1 + c2 - minc)]) {
- dataVerification[h + "_" + c2] = c_dataVerification[c_r1 + h - minh + "_" + (c_c1 + c2 - minc)];
- }
- if (getObjType(x[c2]) == "object" && "mc" in x[c2]) {
- if ("rs" in x[c2].mc) {
- delete cfg["merge"][x[c2]["mc"].r + "_" + x[c2]["mc"].c];
- }
- delete x[c2].mc;
- }
- let value = null;
- if (copyData[h - minh] != null && copyData[h - minh][c2 - minc] != null) {
- value = copyData[h - minh][c2 - minc];
- }
- x[c2] = $.extend(true, {}, value);
- if (value != null && copyHasMC && "mc" in x[c2]) {
- if (x[c2]["mc"].rs != null) {
- x[c2]["mc"].r = h;
- x[c2]["mc"].c = c2;
- cfg["merge"][x[c2]["mc"].r + "_" + x[c2]["mc"].c] = x[c2]["mc"];
- offsetMC[value["mc"].r + "_" + value["mc"].c] = [x[c2]["mc"].r, x[c2]["mc"].c];
- } else {
- x[c2] = {
- mc: {
- r: offsetMC[value["mc"].r + "_" + value["mc"].c][0],
- c: offsetMC[value["mc"].r + "_" + value["mc"].c][1]
- }
- };
- }
- }
- }
- d[h] = x;
- }
- last["row"] = [minh, maxh];
- last["column"] = [minc, maxc];
- if (copyRowlChange) {
- if (store_default.currentSheetIndex != copySheetIndex) {
- cfg = rowlenByRange(d, minh, maxh, cfg);
- } else {
- cfg = rowlenByRange(d, c_r1, c_r2, cfg);
- cfg = rowlenByRange(d, minh, maxh, cfg);
- }
- }
- let source, target;
- if (store_default.currentSheetIndex != copySheetIndex) {
- let sourceData = $.extend(true, [], store_default.luckysheetfile[getSheetIndex(copySheetIndex)]["data"]);
- let sourceConfig = $.extend(true, {}, store_default.luckysheetfile[getSheetIndex(copySheetIndex)]["config"]);
- let sourceCurData = $.extend(true, [], sourceData);
- let sourceCurConfig = $.extend(true, {}, sourceConfig);
- if (sourceCurConfig["merge"] == null) {
- sourceCurConfig["merge"] = {};
- }
- for (let source_r = c_r1; source_r <= c_r2; source_r++) {
- for (let source_c = c_c1; source_c <= c_c2; source_c++) {
- let cell = sourceCurData[source_r][source_c];
- if (getObjType(cell) == "object" && "mc" in cell) {
- if ("rs" in cell["mc"]) {
- delete sourceCurConfig["merge"][cell["mc"].r + "_" + cell["mc"].c];
- }
- delete cell["mc"];
- }
- sourceCurData[source_r][source_c] = null;
- }
- }
- if (copyRowlChange) {
- sourceCurConfig = rowlenByRange(sourceCurData, c_r1, c_r2, sourceCurConfig);
- }
- if (sourceCurConfig["borderInfo"] && sourceCurConfig["borderInfo"].length > 0) {
- let source_borderInfo = [];
- for (let i2 = 0; i2 < sourceCurConfig["borderInfo"].length; i2++) {
- let bd_rangeType = sourceCurConfig["borderInfo"][i2].rangeType;
- if (bd_rangeType == "range") {
- let bd_range = sourceCurConfig["borderInfo"][i2].range;
- let bd_emptyRange = [];
- for (let j = 0; j < bd_range.length; j++) {
- bd_emptyRange = bd_emptyRange.concat(conditionformat_default.CFSplitRange(bd_range[j], {row: [c_r1, c_r2], column: [c_c1, c_c2]}, {row: [minh, maxh], column: [minc, maxc]}, "restPart"));
- }
- sourceCurConfig["borderInfo"][i2].range = bd_emptyRange;
- source_borderInfo.push(sourceCurConfig["borderInfo"][i2]);
- } else if (bd_rangeType == "cell") {
- let bd_r = sourceCurConfig["borderInfo"][i2].value.row_index;
- let bd_c = sourceCurConfig["borderInfo"][i2].value.col_index;
- if (!(bd_r >= c_r1 && bd_r <= c_r2 && bd_c >= c_c1 && bd_c <= c_c2)) {
- source_borderInfo.push(sourceCurConfig["borderInfo"][i2]);
- }
- }
- }
- sourceCurConfig["borderInfo"] = source_borderInfo;
- }
- let source_cdformat = $.extend(true, [], store_default.luckysheetfile[getSheetIndex(copySheetIndex)]["luckysheet_conditionformat_save"]);
- let source_curCdformat = $.extend(true, [], source_cdformat);
- let ruleArr2 = [];
- if (source_curCdformat != null && source_curCdformat.length > 0) {
- for (let i2 = 0; i2 < source_curCdformat.length; i2++) {
- let source_curCdformat_cellrange = source_curCdformat[i2].cellrange;
- let emptyRange = [];
- let emptyRange2 = [];
- for (let j = 0; j < source_curCdformat_cellrange.length; j++) {
- let range2 = conditionformat_default.CFSplitRange(source_curCdformat_cellrange[j], {row: [c_r1, c_r2], column: [c_c1, c_c2]}, {row: [minh, maxh], column: [minc, maxc]}, "restPart");
- emptyRange = emptyRange.concat(range2);
- let range22 = conditionformat_default.CFSplitRange(source_curCdformat_cellrange[j], {row: [c_r1, c_r2], column: [c_c1, c_c2]}, {row: [minh, maxh], column: [minc, maxc]}, "operatePart");
- if (range22.length > 0) {
- emptyRange2 = emptyRange2.concat(range22);
- }
- }
- source_curCdformat[i2].cellrange = emptyRange;
- if (emptyRange2.length > 0) {
- let ruleObj = $.extend(true, {}, source_curCdformat[i2]);
- ruleObj.cellrange = emptyRange2;
- ruleArr2.push(ruleObj);
- }
- }
- }
- let target_cdformat = $.extend(true, [], store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)]["luckysheet_conditionformat_save"]);
- let target_curCdformat = $.extend(true, [], target_cdformat);
- if (ruleArr2.length > 0) {
- target_curCdformat = target_curCdformat.concat(ruleArr2);
- }
- for (let i2 = c_r1; i2 <= c_r2; i2++) {
- for (let j = c_c1; j <= c_c2; j++) {
- delete c_dataVerification[i2 + "_" + j];
- }
- }
- source = {
- sheetIndex: copySheetIndex,
- data: sourceData,
- curData: sourceCurData,
- config: sourceConfig,
- curConfig: sourceCurConfig,
- cdformat: source_cdformat,
- curCdformat: source_curCdformat,
- dataVerification: $.extend(true, {}, store_default.luckysheetfile[getSheetIndex(copySheetIndex)]["dataVerification"]),
- curDataVerification: c_dataVerification,
- range: {
- row: [c_r1, c_r2],
- column: [c_c1, c_c2]
- }
- };
- target = {
- sheetIndex: store_default.currentSheetIndex,
- data: store_default.flowdata,
- curData: d,
- config: $.extend(true, {}, store_default.config),
- curConfig: cfg,
- cdformat: target_cdformat,
- curCdformat: target_curCdformat,
- dataVerification: $.extend(true, {}, store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)]["dataVerification"]),
- curDataVerification: dataVerification,
- range: {
- row: [minh, maxh],
- column: [minc, maxc]
- }
- };
- } else {
- let cdformat = $.extend(true, [], store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)]["luckysheet_conditionformat_save"]);
- let curCdformat = $.extend(true, [], cdformat);
- if (curCdformat != null && curCdformat.length > 0) {
- for (let i2 = 0; i2 < curCdformat.length; i2++) {
- let cellrange = curCdformat[i2].cellrange;
- let emptyRange = [];
- for (let j = 0; j < cellrange.length; j++) {
- let range2 = conditionformat_default.CFSplitRange(cellrange[j], {row: [c_r1, c_r2], column: [c_c1, c_c2]}, {row: [minh, maxh], column: [minc, maxc]}, "allPart");
- emptyRange = emptyRange.concat(range2);
- }
- curCdformat[i2].cellrange = emptyRange;
- }
- }
- source = {
- sheetIndex: store_default.currentSheetIndex,
- data: store_default.flowdata,
- curData: d,
- config: $.extend(true, {}, store_default.config),
- curConfig: cfg,
- cdformat,
- curCdformat,
- dataVerification: $.extend(true, {}, store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)]["dataVerification"]),
- curDataVerification: dataVerification,
- range: {
- row: [c_r1, c_r2],
- column: [c_c1, c_c2]
- }
- };
- target = {
- sheetIndex: store_default.currentSheetIndex,
- data: store_default.flowdata,
- curData: d,
- config: $.extend(true, {}, store_default.config),
- curConfig: cfg,
- cdformat,
- curCdformat,
- dataVerification: $.extend(true, {}, store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)]["dataVerification"]),
- curDataVerification: dataVerification,
- range: {
- row: [minh, maxh],
- column: [minc, maxc]
- }
- };
- }
- if (addr > 0 || addc > 0) {
- jfrefreshgrid_pastcut(source, target, true);
- } else {
- jfrefreshgrid_pastcut(source, target, copyRowlChange);
- }
- },
- pasteHandlerOfCopyPaste: function(copyRange) {
- if (!checkProtectionLockedRangeList(store_default.luckysheet_select_save, store_default.currentSheetIndex)) {
- return;
- }
- const _locale = locale_default();
- const locale_paste = _locale.paste;
- let cfg = $.extend(true, {}, store_default.config);
- if (cfg["merge"] == null) {
- cfg["merge"] = {};
- }
- let copyHasMC = copyRange["HasMC"];
- let copyRowlChange = copyRange["RowlChange"];
- let copySheetIndex = copyRange["dataSheetIndex"];
- let c_r1 = copyRange["copyRange"][0].row[0], c_r2 = copyRange["copyRange"][0].row[1], c_c1 = copyRange["copyRange"][0].column[0], c_c2 = copyRange["copyRange"][0].column[1];
- let arr = [], isSameRow = false;
- for (let i2 = 0; i2 < copyRange["copyRange"].length; i2++) {
- let arrData = getdatabyselection({row: copyRange["copyRange"][i2].row, column: copyRange["copyRange"][i2].column}, copySheetIndex);
- if (copyRange["copyRange"].length > 1) {
- if (c_r1 == copyRange["copyRange"][1].row[0] && c_r2 == copyRange["copyRange"][1].row[1]) {
- arrData = arrData[0].map(function(col, a) {
- return arrData.map(function(row) {
- return row[a];
- });
- });
- arr = arr.concat(arrData);
- isSameRow = true;
- } else if (c_c1 == copyRange["copyRange"][1].column[0] && c_c2 == copyRange["copyRange"][1].column[1]) {
- arr = arr.concat(arrData);
- }
- } else {
- arr = arrData;
- }
- }
- if (isSameRow) {
- arr = arr[0].map(function(col, b) {
- return arr.map(function(row) {
- return row[b];
- });
- });
- }
- let copyData = $.extend(true, [], arr);
- if (copyRange["copyRange"].length > 1) {
- for (let i2 = 0; i2 < copyData.length; i2++) {
- for (let j = 0; j < copyData[i2].length; j++) {
- if (copyData[i2][j] != null && copyData[i2][j].f != null) {
- delete copyData[i2][j].f;
- delete copyData[i2][j].spl;
- }
- }
- }
- }
- let copyh = copyData.length, copyc = copyData[0].length;
- let last = store_default.luckysheet_select_save[store_default.luckysheet_select_save.length - 1];
- let minh = last["row"][0], maxh = last["row"][1];
- let minc = last["column"][0], maxc = last["column"][1];
- let mh = (maxh - minh + 1) % copyh;
- let mc = (maxc - minc + 1) % copyc;
- if (mh != 0 || mc != 0) {
- maxh = minh + copyh - 1;
- maxc = minc + copyc - 1;
- }
- let has_PartMC = false;
- if (cfg["merge"] != null) {
- has_PartMC = hasPartMC(cfg, minh, maxh, minc, maxc);
- }
- if (has_PartMC) {
- if (isEditMode()) {
- alert(locale_paste.errorNotAllowMerged);
- } else {
- tooltip_default.info(` ${locale_paste.warning}`, locale_paste.errorNotAllowMerged);
- }
- return;
- }
- let timesH = (maxh - minh + 1) / copyh;
- let timesC = (maxc - minc + 1) / copyc;
- let d = editor_default.deepCopyFlowData(store_default.flowdata);
- let rowMaxLength = d.length;
- let cellMaxLength = d[0].length;
- let addr = copyh + minh - rowMaxLength, addc = copyc + minc - cellMaxLength;
- if (addr > 0 || addc > 0) {
- d = datagridgrowth([].concat(d), addr, addc, true);
- }
- let borderInfoCompute = getBorderInfoCompute(copySheetIndex);
- let c_dataVerification = $.extend(true, {}, store_default.luckysheetfile[getSheetIndex(copySheetIndex)].dataVerification);
- let dataVerification = null;
- let mth = 0, mtc = 0, maxcellCahe = 0, maxrowCache = 0;
- for (let th = 1; th <= timesH; th++) {
- for (let tc = 1; tc <= timesC; tc++) {
- mth = minh + (th - 1) * copyh;
- mtc = minc + (tc - 1) * copyc;
- maxrowCache = minh + th * copyh;
- maxcellCahe = minc + tc * copyc;
- let offsetRow = mth - c_r1;
- let offsetCol = mtc - c_c1;
- let offsetMC = {};
- for (let h = mth; h < maxrowCache; h++) {
- let x = [].concat(d[h]);
- for (let c2 = mtc; c2 < maxcellCahe; c2++) {
- if (borderInfoCompute[c_r1 + h - mth + "_" + (c_c1 + c2 - mtc)]) {
- let bd_obj = {
- rangeType: "cell",
- value: {
- row_index: h,
- col_index: c2,
- l: borderInfoCompute[c_r1 + h - mth + "_" + (c_c1 + c2 - mtc)].l,
- r: borderInfoCompute[c_r1 + h - mth + "_" + (c_c1 + c2 - mtc)].r,
- t: borderInfoCompute[c_r1 + h - mth + "_" + (c_c1 + c2 - mtc)].t,
- b: borderInfoCompute[c_r1 + h - mth + "_" + (c_c1 + c2 - mtc)].b
- }
- };
- if (cfg["borderInfo"] == null) {
- cfg["borderInfo"] = [];
- }
- cfg["borderInfo"].push(bd_obj);
- } else if (borderInfoCompute[h + "_" + c2]) {
- let bd_obj = {
- rangeType: "cell",
- value: {
- row_index: h,
- col_index: c2,
- l: null,
- r: null,
- t: null,
- b: null
- }
- };
- if (cfg["borderInfo"] == null) {
- cfg["borderInfo"] = [];
- }
- cfg["borderInfo"].push(bd_obj);
- }
- if (c_dataVerification[c_r1 + h - mth + "_" + (c_c1 + c2 - mtc)]) {
- if (dataVerification == null) {
- dataVerification = $.extend(true, {}, store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)].dataVerification);
- }
- dataVerification[h + "_" + c2] = c_dataVerification[c_r1 + h - mth + "_" + (c_c1 + c2 - mtc)];
- }
- if (getObjType(x[c2]) == "object" && "mc" in x[c2]) {
- if ("rs" in x[c2].mc) {
- delete cfg["merge"][x[c2]["mc"].r + "_" + x[c2]["mc"].c];
- }
- delete x[c2].mc;
- }
- let value = null;
- if (copyData[h - mth] != null && copyData[h - mth][c2 - mtc] != null) {
- value = $.extend(true, {}, copyData[h - mth][c2 - mtc]);
- }
- if (value != null && value.f != null) {
- let func = value.f;
- if (offsetRow > 0) {
- func = "=" + formula_default.functionCopy(func, "down", offsetRow);
- }
- if (offsetRow < 0) {
- func = "=" + formula_default.functionCopy(func, "up", Math.abs(offsetRow));
- }
- if (offsetCol > 0) {
- func = "=" + formula_default.functionCopy(func, "right", offsetCol);
- }
- if (offsetCol < 0) {
- func = "=" + formula_default.functionCopy(func, "left", Math.abs(offsetCol));
- }
- let funcV = formula_default.execfunction(func, h, c2, void 0, true);
- if (value.spl != null) {
- value.f = funcV[2];
- value.v = funcV[1];
- value.spl = funcV[3].data;
- } else {
- value.f = funcV[2];
- value.v = funcV[1];
- if (value.ct != null && value.ct["fa"] != null) {
- value.m = update(value.ct["fa"], funcV[1]);
- }
- }
- }
- x[c2] = $.extend(true, {}, value);
- if (value != null && copyHasMC && "mc" in x[c2]) {
- if (x[c2]["mc"].rs != null) {
- x[c2]["mc"].r = h;
- x[c2]["mc"].c = c2;
- cfg["merge"][x[c2]["mc"].r + "_" + x[c2]["mc"].c] = x[c2]["mc"];
- offsetMC[value["mc"].r + "_" + value["mc"].c] = [x[c2]["mc"].r, x[c2]["mc"].c];
- } else {
- x[c2] = {
- mc: {
- r: offsetMC[value["mc"].r + "_" + value["mc"].c][0],
- c: offsetMC[value["mc"].r + "_" + value["mc"].c][1]
- }
- };
- }
- }
- }
- d[h] = x;
- }
- }
- }
- let cdformat = null;
- if (copyRange["copyRange"].length == 1) {
- let c_file = store_default.luckysheetfile[getSheetIndex(copySheetIndex)];
- let a_file = store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)];
- let ruleArr_cf = $.extend(true, [], c_file["luckysheet_conditionformat_save"]);
- if (ruleArr_cf != null && ruleArr_cf.length > 0) {
- cdformat = $.extend(true, [], a_file["luckysheet_conditionformat_save"]);
- for (let i2 = 0; i2 < ruleArr_cf.length; i2++) {
- let cf_range = ruleArr_cf[i2].cellrange;
- let emptyRange = [];
- for (let th = 1; th <= timesH; th++) {
- for (let tc = 1; tc <= timesC; tc++) {
- mth = minh + (th - 1) * copyh;
- mtc = minc + (tc - 1) * copyc;
- maxrowCache = minh + th * copyh;
- maxcellCahe = minc + tc * copyc;
- for (let j = 0; j < cf_range.length; j++) {
- let range2 = conditionformat_default.CFSplitRange(cf_range[j], {row: [c_r1, c_r2], column: [c_c1, c_c2]}, {row: [mth, maxrowCache - 1], column: [mtc, maxcellCahe - 1]}, "operatePart");
- if (range2.length > 0) {
- emptyRange = emptyRange.concat(range2);
- }
- }
- }
- }
- if (emptyRange.length > 0) {
- ruleArr_cf[i2].cellrange = emptyRange;
- cdformat.push(ruleArr_cf[i2]);
- }
- }
- }
- }
- last["row"] = [minh, maxh];
- last["column"] = [minc, maxc];
- if (copyRowlChange || addr > 0 || addc > 0) {
- cfg = rowlenByRange(d, minh, maxh, cfg);
- let allParam = {
- cfg,
- RowlChange: true,
- cdformat,
- dataVerification
- };
- jfrefreshgrid(d, store_default.luckysheet_select_save, allParam);
- } else {
- let allParam = {
- cfg,
- cdformat,
- dataVerification
- };
- jfrefreshgrid(d, store_default.luckysheet_select_save, allParam);
- selectHightlightShow();
- }
- },
- pasteHandlerOfPaintModel: function(copyRange) {
- if (!checkProtectionLockedRangeList(store_default.luckysheet_select_save, store_default.currentSheetIndex)) {
- return;
- }
- const _locale = locale_default();
- const locale_paste = _locale.paste;
- let cfg = $.extend(true, {}, store_default.config);
- if (cfg["merge"] == null) {
- cfg["merge"] = {};
- }
- let copyHasMC = copyRange["HasMC"];
- let copyRowlChange = copyRange["RowlChange"];
- let copySheetIndex = copyRange["dataSheetIndex"];
- let c_r1 = copyRange["copyRange"][0].row[0], c_r2 = copyRange["copyRange"][0].row[1], c_c1 = copyRange["copyRange"][0].column[0], c_c2 = copyRange["copyRange"][0].column[1];
- let copyData = $.extend(true, [], getdatabyselection({row: [c_r1, c_r2], column: [c_c1, c_c2]}, copySheetIndex));
- let last = store_default.luckysheet_select_save[store_default.luckysheet_select_save.length - 1];
- let minh = last["row"][0], maxh = last["row"][1];
- let minc = last["column"][0], maxc = last["column"][1];
- let copyh = copyData.length, copyc = copyData[0].length;
- if (minh == maxh && minc == maxc) {
- let has_PartMC = false;
- if (cfg["merge"] != null) {
- has_PartMC = hasPartMC(cfg, minh, minh + copyh - 1, minc, minc + copyc - 1);
- }
- if (has_PartMC) {
- if (isEditMode()) {
- alert(locale_paste.errorNotAllowMerged);
- } else {
- tooltip_default.info(` ${locale_paste.warning}`, locale_paste.errorNotAllowMerged);
- }
- return;
- }
- maxh = minh + copyh - 1;
- maxc = minc + copyc - 1;
- }
- let timesH = Math.ceil((maxh - minh + 1) / copyh);
- let timesC = Math.ceil((maxc - minc + 1) / copyc);
- let d = editor_default.deepCopyFlowData(store_default.flowdata);
- let cellMaxLength = d[0].length;
- let rowMaxLength = d.length;
- let borderInfoCompute = getBorderInfoCompute(copySheetIndex);
- let c_dataVerification = $.extend(true, {}, store_default.luckysheetfile[getSheetIndex(copySheetIndex)].dataVerification);
- let dataVerification = null;
- let mth = 0, mtc = 0, maxcellCahe = 0, maxrowCache = 0;
- for (let th = 1; th <= timesH; th++) {
- for (let tc = 1; tc <= timesC; tc++) {
- mth = minh + (th - 1) * copyh;
- mtc = minc + (tc - 1) * copyc;
- maxrowCache = minh + th * copyh > rowMaxLength ? rowMaxLength : minh + th * copyh;
- if (maxrowCache > maxh + 1) {
- maxrowCache = maxh + 1;
- }
- maxcellCahe = minc + tc * copyc > cellMaxLength ? cellMaxLength : minc + tc * copyc;
- if (maxcellCahe > maxc + 1) {
- maxcellCahe = maxc + 1;
- }
- let offsetMC = {};
- for (let h = mth; h < maxrowCache; h++) {
- let x = [].concat(d[h]);
- for (let c2 = mtc; c2 < maxcellCahe; c2++) {
- if (borderInfoCompute[c_r1 + h - mth + "_" + (c_c1 + c2 - mtc)]) {
- let bd_obj = {
- rangeType: "cell",
- value: {
- row_index: h,
- col_index: c2,
- l: borderInfoCompute[c_r1 + h - mth + "_" + (c_c1 + c2 - mtc)].l,
- r: borderInfoCompute[c_r1 + h - mth + "_" + (c_c1 + c2 - mtc)].r,
- t: borderInfoCompute[c_r1 + h - mth + "_" + (c_c1 + c2 - mtc)].t,
- b: borderInfoCompute[c_r1 + h - mth + "_" + (c_c1 + c2 - mtc)].b
- }
- };
- if (cfg["borderInfo"] == null) {
- cfg["borderInfo"] = [];
- }
- cfg["borderInfo"].push(bd_obj);
- } else if (borderInfoCompute[h + "_" + c2]) {
- let bd_obj = {
- rangeType: "cell",
- value: {
- row_index: h,
- col_index: c2,
- l: null,
- r: null,
- t: null,
- b: null
- }
- };
- if (cfg["borderInfo"] == null) {
- cfg["borderInfo"] = [];
- }
- cfg["borderInfo"].push(bd_obj);
- }
- if (c_dataVerification[c_r1 + h - mth + "_" + (c_c1 + c2 - mtc)]) {
- if (dataVerification == null) {
- dataVerification = $.extend(true, {}, store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)].dataVerification);
- }
- dataVerification[h + "_" + c2] = c_dataVerification[c_r1 + h - mth + "_" + (c_c1 + c2 - mtc)];
- }
- if (getObjType(x[c2]) == "object" && "mc" in x[c2]) {
- if ("rs" in x[c2].mc) {
- delete cfg["merge"][x[c2]["mc"].r + "_" + x[c2]["mc"].c];
- }
- delete x[c2].mc;
- }
- let value = null;
- if (copyData[h - mth] != null && copyData[h - mth][c2 - mtc] != null) {
- value = copyData[h - mth][c2 - mtc];
- }
- if (value != null) {
- delete value["v"];
- delete value["m"];
- delete value["f"];
- delete value["spl"];
- if (value.ct && value.ct.t == "inlineStr") {
- delete value.ct;
- }
- if (getObjType(x[c2]) == "object") {
- if (x[c2].ct && x[c2].ct.t === "inlineStr") {
- delete value["ct"];
- } else {
- let format = [
- "bg",
- "fc",
- "ct",
- "ht",
- "vt",
- "bl",
- "it",
- "cl",
- "un",
- "fs",
- "ff",
- "tb"
- ];
- format.forEach((item2) => {
- Reflect.deleteProperty(x[c2], item2);
- });
- }
- } else {
- x[c2] = {v: x[c2]};
- }
- x[c2] = $.extend(true, x[c2], value);
- if (x[c2].ct && x[c2].ct.t === "inlineStr") {
- x[c2].ct.s.forEach((item2) => item2 = $.extend(true, item2, value));
- }
- if (copyHasMC && "mc" in x[c2]) {
- if (x[c2]["mc"].rs != null) {
- x[c2]["mc"].r = h;
- if (x[c2]["mc"].rs + h >= maxrowCache) {
- x[c2]["mc"].rs = maxrowCache - h;
- }
- x[c2]["mc"].c = c2;
- if (x[c2]["mc"].cs + c2 >= maxcellCahe) {
- x[c2]["mc"].cs = maxcellCahe - c2;
- }
- cfg["merge"][x[c2]["mc"].r + "_" + x[c2]["mc"].c] = x[c2]["mc"];
- offsetMC[value["mc"].r + "_" + value["mc"].c] = [x[c2]["mc"].r, x[c2]["mc"].c];
- } else {
- x[c2] = {
- mc: {
- r: offsetMC[value["mc"].r + "_" + value["mc"].c][0],
- c: offsetMC[value["mc"].r + "_" + value["mc"].c][1]
- }
- };
- }
- }
- if (x[c2].v != null) {
- if (value["ct"] != null && value["ct"]["fa"] != null) {
- let mask = update(value["ct"]["fa"], x[c2].v);
- x[c2].m = mask;
- }
- }
- }
- }
- d[h] = x;
- }
- }
- }
- let cdformat = null;
- let ruleArr2 = $.extend(true, [], store_default.luckysheetfile[getSheetIndex(copySheetIndex)]["luckysheet_conditionformat_save"]);
- if (ruleArr2 != null && ruleArr2.length > 0) {
- cdformat = $.extend(true, [], store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)]["luckysheet_conditionformat_save"]);
- for (let i2 = 0; i2 < ruleArr2.length; i2++) {
- let cdformat_cellrange = ruleArr2[i2].cellrange;
- let emptyRange = [];
- for (let j = 0; j < cdformat_cellrange.length; j++) {
- let range2 = conditionformat_default.CFSplitRange(cdformat_cellrange[j], {row: [c_r1, c_r2], column: [c_c1, c_c2]}, {row: [minh, maxh], column: [minc, maxc]}, "operatePart");
- if (range2.length > 0) {
- emptyRange = emptyRange.concat(range2);
- }
- }
- if (emptyRange.length > 0) {
- ruleArr2[i2].cellrange = [{row: [minh, maxh], column: [minc, maxc]}];
- cdformat.push(ruleArr2[i2]);
- }
- }
- }
- last["row"] = [minh, maxh];
- last["column"] = [minc, maxc];
- if (copyRowlChange) {
- cfg = rowlenByRange(d, minh, maxh, cfg);
- let allParam = {
- cfg,
- RowlChange: true,
- cdformat,
- dataVerification
- };
- jfrefreshgrid(d, store_default.luckysheet_select_save, allParam);
- } else {
- if (maxh >= d.length) {
- maxh = d.length - 1;
- }
- cfg = rowlenByRange(d, minh, maxh, cfg);
- let allParam = {
- cfg,
- RowlChange: true,
- cdformat,
- dataVerification
- };
- jfrefreshgrid(d, store_default.luckysheet_select_save, allParam);
- selectHightlightShow();
- }
- },
- matchcopy: function(data1, data2) {
- let data1cache = [], data2cache = [], data1len, data2len;
- if (typeof data1 == "object") {
- data1cache = data1;
- } else {
- data1cache = data1.split("\n");
- for (let i2 = 0; i2 < data1cache.length; i2++) {
- data1cache[i2] = data1cache[i2].split(" ");
- }
- }
- data1len = data1cache.length;
- if (typeof data2 == "object") {
- data2cache = data2;
- } else {
- data2cache = data2.split("\n");
- for (let i2 = 0; i2 < data2cache.length; i2++) {
- data2cache[i2] = data2cache[i2].split(" ");
- }
- }
- data2len = data2cache.length;
- if (data1len != data2len) {
- return false;
- }
- for (let r1 = 0; r1 < data1len; r1++) {
- if (store_default.config["rowhidden"] != null && store_default.config["rowhidden"][r1] != null) {
- continue;
- }
- for (let r2 = 0; r2 < data2len; r2++) {
- if (data1cache[r1].length != data2cache[r2].length) {
- return false;
- }
- }
- }
- for (let r2 = 0; r2 < data1len; r2++) {
- if (store_default.config["rowhidden"] != null && store_default.config["rowhidden"][r2] != null) {
- continue;
- }
- for (let c2 = 0; c2 < data1cache[0].length; c2++) {
- if (getcellvalue(r2, c2, data1cache) != getcellvalue(r2, c2, data2cache)) {
- return false;
- }
- }
- }
- return true;
- }
- };
- selection_default = selection;
- }
- });
-
- // src/global/cleargridelement.js
- function cleargridelement(event2) {
- $("#luckysheet-cols-h-hover").hide();
- $("#luckysheet-rightclick-menu").hide();
- $("#luckysheet-cell-selected-boxs .luckysheet-cell-selected").hide();
- $("#luckysheet-cols-h-selected .luckysheet-cols-h-selected").hide();
- $("#luckysheet-rows-h-selected .luckysheet-rows-h-selected").hide();
- $("#luckysheet-cell-selected-focus").hide();
- $("#luckysheet-rows-h-hover").hide();
- $("#luckysheet-selection-copy .luckysheet-selection-copy").hide();
- $("#luckysheet-cols-menu-btn").hide();
- $("#luckysheet-row-count-show, #luckysheet-column-count-show").hide();
- if (!event2) {
- selection_default.clearcopy(event2);
- }
- if ($("#luckysheet-dropCell-icon").is(":visible")) {
- if (event2) {
- $("#luckysheet-dropCell-icon").remove();
- }
- }
- if (menuButton_default.luckysheetPaintModelOn && !event2) {
- menuButton_default.cancelPaintModel();
- }
- }
- var init_cleargridelement = __esm({
- "src/global/cleargridelement.js"() {
- init_selection();
- init_menuButton();
- }
- });
-
- // src/global/createdom.js
- function luckysheetcreatedom(colwidth, rowheight, data, menu, title) {
- let gh = gridHTML();
- gh = replaceHtml(gh, {"logotitle": title});
- gh = replaceHtml(gh, {"menu": menuToolBar()});
- let flowHTML = flow;
- if (store_default.config == null) {
- store_default.config = {};
- }
- rhchInit(rowheight, colwidth);
- const _locale = locale_default();
- const locale_info = _locale.info;
- let addControll = '' + locale_info.add + ' ' + locale_info.row + ' (' + locale_info.addLast + ") ";
- let backControll = ' ' + locale_info.backTop + " ";
- let pageInfo = replaceHtml(locale_info.pageInfo, {
- total: luckysheetConfigsetting_default.total ? luckysheetConfigsetting_default.total : "",
- totalPage: luckysheetConfigsetting_default.pageInfo.totalPage ? luckysheetConfigsetting_default.pageInfo.totalPage : "",
- currentPage: luckysheetConfigsetting_default.pageInfo.currentPage ? luckysheetConfigsetting_default.pageInfo.currentPage : ""
- });
- let pageControll = ' ' + pageInfo + ' \u4E0B\u4E00\u9875 ';
- let pageControll2 = ' ' + pageInfo + " ";
- let bottomControll = "";
- if (luckysheetConfigsetting_default.enableAddRow) {
- bottomControll += addControll;
- }
- if (luckysheetConfigsetting_default.enablePage) {
- if (parseInt(luckysheetConfigsetting_default.pageInfo.totalPage) == 1) {
- bottomControll += pageControll2;
- } else {
- bottomControll += pageControll;
- }
- }
- if (luckysheetConfigsetting_default.enableAddBackTop) {
- bottomControll += backControll;
- }
- let flowstr = replaceHtml('", {"height": store_default.rh_height, "width": store_default.ch_width - 1});
- let colsheader = replaceHtml(columnHeaderHTML, {"width": store_default.ch_width, "index": 0, "column": ""});
- flowHTML = replaceHtml(flowHTML, {"width": store_default.ch_width, "flow": flowstr, "index": 0});
- gh = replaceHtml(gh, {"flow": flowHTML, "rowHeader": "", "columnHeader": colsheader, "functionButton": luckysheetConfigsetting_default.functionButton});
- $("#" + store_default.container).append(gh);
- $("#luckysheet-scrollbar-x div").width(store_default.ch_width);
- $("#luckysheet-scrollbar-y div").height(store_default.rh_height + store_default.columnHeaderHeight - store_default.cellMainSrollBarSize - 3);
- $("body").append(maskHTML);
- $("body").append(colsmenuHTML);
- $("body").append(rightclickHTML());
- $("body").append(inputHTML);
- $("body").append(replaceHtml(filtermenuHTML(), {"menuid": "filter"}));
- $("body").append(replaceHtml(filtersubmenuHTML(), {"menuid": "filter"}));
- $("body").append(sheetconfigHTML());
- $("#luckysheet-rows-h").width(store_default.rowHeaderWidth - 1.5);
- $("#luckysheet-cols-h-c").height(store_default.columnHeaderHeight - 1.5);
- $("#luckysheet-left-top").css({width: store_default.rowHeaderWidth - 1.5, height: store_default.columnHeaderHeight - 1.5});
- $("#luckysheet_info_detail_input").val(luckysheetConfigsetting_default.title);
- }
- var init_createdom = __esm({
- "src/global/createdom.js"() {
- init_constant();
- init_luckysheetConfigsetting();
- init_postil();
- init_getdata();
- init_editor();
- init_rhchInit();
- init_util();
- init_store();
- init_locale();
- }
- });
-
- // src/utils/chartUtil.js
- function generateRandomKey(prefix) {
- if (prefix == null) {
- prefix = "chart";
- }
- var userAgent = window.navigator.userAgent.replace(/[^a-zA-Z0-9]/g, "").split("");
- var mid = "";
- for (var i2 = 0; i2 < 12; i2++) {
- mid += userAgent[Math.round(Math.random() * (userAgent.length - 1))];
- }
- var time = new Date().getTime();
- return prefix + "_" + mid + "_" + time;
- }
- function replaceHtml2(temp, dataarry) {
- return temp.replace(/\$\{([\w]+)\}/g, function(s1, s2) {
- var s = dataarry[s2];
- if (typeof s != "undefined") {
- return s;
- } else {
- return s1;
- }
- });
- }
- var init_chartUtil = __esm({
- "src/utils/chartUtil.js"() {
- }
- });
-
- // src/global/func_methods.js
- var import_dayjs5, error2, func_methods, func_methods_default;
- var init_func_methods = __esm({
- "src/global/func_methods.js"() {
- init_util();
- init_validate();
- init_format();
- init_formula();
- import_dayjs5 = __toModule(require_dayjs_min());
- error2 = {
- v: "#VALUE!",
- n: "#NAME?",
- na: "#N/A",
- r: "#REF!",
- d: "#DIV/0!",
- nm: "#NUM!",
- nl: "#NULL!",
- sp: "#SPILL!"
- };
- func_methods = {
- getCellDataArr: function(rangeObj, nullCellType, isNeglectNullCell) {
- let dataArr = [];
- if (rangeObj.data == null) {
- if (!isNeglectNullCell) {
- if (nullCellType === "number") {
- dataArr.push(0);
- } else if (nullCellType === "text") {
- dataArr.push("");
- }
- }
- } else {
- if (getObjType(rangeObj.data) === "array") {
- for (let i2 = 0; i2 < rangeObj.data.length; i2++) {
- for (let j = 0; j < rangeObj.data[i2].length; j++) {
- let cell = rangeObj.data[i2][j];
- let value = cell;
- if (getObjType(cell) === "object") {
- value = cell.v;
- }
- if (value == null) {
- if (!isNeglectNullCell) {
- if (nullCellType === "number") {
- value = 0;
- } else if (nullCellType === "text") {
- value = "";
- }
- dataArr.push(value);
- }
- } else {
- dataArr.push(value);
- }
- }
- }
- } else {
- if (isRealNull(rangeObj.data.v)) {
- if (!isNeglectNullCell) {
- if (nullCellType == "number") {
- dataArr.push(0);
- } else if (nullCellType == "text") {
- dataArr.push("");
- }
- }
- } else {
- dataArr.push(rangeObj.data.v);
- }
- }
- }
- return dataArr;
- },
- getCellDataDyadicArr: function(rangeObj, nullCellType) {
- let dataArr = [];
- if (rangeObj.data == null) {
- let rowArr = [];
- if (nullCellType == "number") {
- rowArr.push(0);
- } else if (nullCellType == "text") {
- rowArr.push("");
- }
- dataArr.push(rowArr);
- } else {
- if (getObjType(rangeObj.data) == "array") {
- for (let i2 = 0; i2 < rangeObj.data.length; i2++) {
- let rowArr = [];
- for (let j = 0; j < rangeObj.data[i2].length; j++) {
- let cell = rangeObj.data[i2][j];
- let value = cell;
- if (getObjType(cell) === "object") {
- value = cell.v;
- }
- if (value == null) {
- if (nullCellType === "number") {
- value = 0;
- } else if (nullCellType === "text") {
- value = "";
- }
- }
- rowArr.push(value);
- }
- dataArr.push(rowArr);
- }
- } else {
- let rowArr = [];
- let value = rangeObj.data.v;
- if (isRealNull(value)) {
- if (nullCellType == "number") {
- value = 0;
- } else if (nullCellType == "text") {
- value = "";
- }
- }
- rowArr.push(value);
- dataArr.push(rowArr);
- }
- }
- return dataArr;
- },
- getDataArr: function(arr, isNeglectNaN) {
- let dataArr = [];
- if (isNeglectNaN == null) {
- isNeglectNaN = false;
- }
- if (getObjType(arr[0]) == "array") {
- for (let i2 = 0; i2 < arr.length; i2++) {
- for (let j = 0; j < arr[i2].length; j++) {
- if (isNeglectNaN && !isRealNum(arr[i2][j])) {
- continue;
- }
- dataArr.push(arr[i2][j]);
- }
- }
- } else {
- for (let i2 = 0; i2 < arr.length; i2++) {
- if (isNeglectNaN && !isRealNum(arr[i2])) {
- continue;
- }
- dataArr.push(arr[i2]);
- }
- }
- return dataArr;
- },
- getDataDyadicArr: function(arr) {
- let dataArr = [];
- if (getObjType(arr[0]) == "array") {
- for (let i2 = 0; i2 < arr.length; i2++) {
- let rowArr = [];
- for (let j = 0; j < arr[i2].length; j++) {
- rowArr.push(arr[i2][j]);
- }
- dataArr.push(rowArr);
- }
- } else {
- let rowArr = [];
- for (let i2 = 0; i2 < arr.length; i2++) {
- rowArr.push(arr[i2]);
- }
- dataArr.push(rowArr);
- }
- return dataArr;
- },
- isDyadicArr: function(arr) {
- let isDyadic = true;
- if (arr.length > 1) {
- let collen = arr[0].length;
- for (let i2 = 1; i2 < arr.length; i2++) {
- if (arr[i2].length != collen) {
- isDyadic = false;
- break;
- }
- }
- }
- return isDyadic;
- },
- getFirstValue: function(data, nullCellType) {
- let _this2 = this;
- if (nullCellType == null) {
- nullCellType = "number";
- }
- let value;
- if (getObjType(data) == "array") {
- if (getObjType(data[0]) == "array") {
- if (!_this2.isDyadicArr(data)) {
- return error2.v;
- }
- value = data[0][0];
- } else {
- value = data[0];
- }
- } else if (getObjType(data) == "object" && data.startCell != null) {
- if (data.data == null) {
- if (nullCellType == "number") {
- value = 0;
- } else if (nullCellType == "text") {
- value = "";
- }
- } else {
- let cell_r = window.luckysheetCurrentRow;
- let cell_c = window.luckysheetCurrentColumn;
- if (data.rowl == 1 && data.coll == 1) {
- value = data.data;
- if (value == null || isRealNull(value.v)) {
- if (nullCellType == "number") {
- value = 0;
- } else if (nullCellType == "text") {
- value = "";
- }
- } else {
- value = value.v;
- }
- } else {
- if (data.data[0][0].mc != null && data.data[0][0].mc.rs == data.rowl && data.data[0][0].mc.cs == data.coll) {
- value = data.data[0][0];
- if (value == null || isRealNull(value.v)) {
- if (nullCellType == "number") {
- value = 0;
- } else if (nullCellType == "text") {
- value = "";
- }
- } else {
- value = value.v;
- }
- } else if (data.rowl == 1 || data.coll == 1) {
- let cellrange = formula_default.getcellrange(data.startCell);
- let str = cellrange.row[0], edr = str + data.rowl - 1, stc = cellrange.column[0], edc = stc + data.coll - 1;
- if (data.rowl == 1) {
- if (cell_c < stc || cell_c > edc) {
- return error2.v;
- }
- value = data.data[0][cell_c - stc];
- } else if (data.coll == 1) {
- if (cell_r < str || cell_r > edr) {
- return error2.v;
- }
- value = data.data[cell_r - str][0];
- }
- if (value == null || isRealNull(value.v) || value.mc != null) {
- if (nullCellType == "number") {
- value = 0;
- } else if (nullCellType == "text") {
- value = "";
- }
- } else {
- value = value.v;
- }
- } else {
- return error2.v;
- }
- }
- }
- } else {
- value = data;
- }
- return value;
- },
- getCellBoolen: function(data) {
- let _this2 = this;
- let cumulative = _this2.getFirstValue(data);
- if (valueIsError(cumulative)) {
- return cumulative;
- }
- if (getObjType(cumulative) == "boolean") {
- } else if (getObjType(cumulative) == "string" && (cumulative.toLowerCase() == "true" || cumulative.toLowerCase() == "false")) {
- if (cumulative.toLowerCase() == "true") {
- cumulative = true;
- } else if (cumulative.toLowerCase() == "false") {
- cumulative = false;
- }
- } else if (isRealNum(cumulative)) {
- cumulative = parseFloat(cumulative);
- cumulative = cumulative == 0 ? false : true;
- } else {
- return error2.v;
- }
- return cumulative;
- },
- getCellDate: function(data) {
- let _this2 = this;
- let date_text;
- if (getObjType(data) == "array") {
- if (getObjType(data[0]) == "array") {
- if (!_this2.isDyadicArr(data)) {
- return error2.v;
- }
- date_text = data[0][0];
- } else {
- date_text = data[0];
- }
- } else if (getObjType(data) == "object" && data.startCell != null) {
- if (data.data == null || getObjType(data.data) == "array" || isRealNull(data.data.v)) {
- return error2.v;
- }
- date_text = data.data.v;
- if (data.data.ct != null && data.data.ct.t == "d") {
- date_text = update("YYYY-MM-DD h:mm:ss", date_text);
- }
- } else {
- date_text = data;
- }
- return date_text;
- },
- getCellrangeDate: function(data) {
- let _this2 = this;
- let date = [];
- if (getObjType(data) == "array") {
- if (getObjType(data[0]) == "array" && !_this2.isDyadicArr(data)) {
- return error2.v;
- }
- date = date.concat(_this2.getDataArr(data, false));
- } else if (getObjType(data) == "object" && data.startCell != null) {
- if (data.data == null) {
- date.push(0);
- } else {
- if (getObjType(data.data) == "array") {
- for (let i2 = 0; i2 < data.data.length; i2++) {
- for (let j = 0; j < data.data[i2].length; j++) {
- if (data.data[i2][j] != null && !isRealNull(data.data[i2][j].v)) {
- let value = data.data[i2][j].v;
- if (data.data[i2][j].ct != null && data.data[i2][j].ct.t == "d") {
- value = update("YYYY-MM-DD h:mm:ss", value);
- }
- date.push(value);
- } else {
- date.push(0);
- }
- }
- }
- } else {
- let value = data.data.v;
- if (data.data.ct != null && data.data.ct.t == "d") {
- value = update("YYYY-MM-DD h:mm:ss", value);
- }
- date.push(value);
- }
- }
- } else {
- date.push(data);
- }
- return date;
- },
- getRegExpStr: function(str) {
- return str.replace("~*", "\\*").replace("~?", "\\?").replace(".", "\\.").replace("*", ".*").replace("?", ".");
- },
- factorial: function(num) {
- if (num == 0 || num == 1) {
- return 1;
- } else {
- return num * this.factorial(num - 1);
- }
- },
- factorialDouble: function(num) {
- if (num <= 0) {
- return 1;
- } else {
- return num * this.factorialDouble(num - 2);
- }
- },
- variance: function(num_arr) {
- let sum = 0, count = 0;
- for (let i2 = 0; i2 < num_arr.length; i2++) {
- let number = num_arr[i2];
- sum += number;
- count++;
- }
- let avg = sum / count;
- let sum_variance = 0;
- for (let j = 0; j < num_arr.length; j++) {
- let number = num_arr[j];
- sum_variance += (number - avg) * (number - avg);
- }
- return sum_variance / count;
- },
- variance_s: function(num_arr) {
- let sum = 0, count = 0;
- for (let i2 = 0; i2 < num_arr.length; i2++) {
- let number = num_arr[i2];
- sum += number;
- count++;
- }
- let avg = sum / count;
- let sum_variance = 0;
- for (let j = 0; j < num_arr.length; j++) {
- let number = num_arr[j];
- sum_variance += (number - avg) * (number - avg);
- }
- return sum_variance / (count - 1);
- },
- standardDeviation: function(num_arr) {
- let sum = 0, count = 0;
- for (let i2 = 0; i2 < num_arr.length; i2++) {
- let number = num_arr[i2];
- sum += number;
- count++;
- }
- let avg = sum / count;
- let sum_variance = 0;
- for (let j = 0; j < num_arr.length; j++) {
- let number = num_arr[j];
- sum_variance += (number - avg) * (number - avg);
- }
- return Math.sqrt(sum_variance / count);
- },
- standardDeviation_s: function(num_arr) {
- let sum = 0, count = 0;
- for (let i2 = 0; i2 < num_arr.length; i2++) {
- let number = num_arr[i2];
- sum += number;
- count++;
- }
- let avg = sum / count;
- let sum_variance = 0;
- for (let j = 0; j < num_arr.length; j++) {
- let number = num_arr[j];
- sum_variance += (number - avg) * (number - avg);
- }
- return Math.sqrt(sum_variance / (count - 1));
- },
- isLeapYear: function(year) {
- return new Date(year, 1, 29).getMonth() === 1;
- },
- feb29Between: function(date1, date2) {
- let _this2 = this;
- let year1 = (0, import_dayjs5.default)(date1).year();
- let mar1year1 = (0, import_dayjs5.default)().set({"year": year1, "month": 2, "date": 1});
- if (_this2.isLeapYear(year1) && (0, import_dayjs5.default)(date1) < (0, import_dayjs5.default)(mar1year1) && (0, import_dayjs5.default)(date2) >= (0, import_dayjs5.default)(mar1year1)) {
- return true;
- }
- let year2 = (0, import_dayjs5.default)(date2).year();
- let mar1year2 = (0, import_dayjs5.default)().set({"year": year2, "month": 2, "date": 1});
- return _this2.isLeapYear(year2) && (0, import_dayjs5.default)(date2) >= (0, import_dayjs5.default)(mar1year2) && (0, import_dayjs5.default)(date1) < (0, import_dayjs5.default)(mar1year2);
- },
- findResultIndex: function(database, criterias) {
- let matches = {};
- for (let i2 = 1; i2 < database[0].length; ++i2) {
- matches[i2] = true;
- }
- let maxCriteriaLength = criterias[0].length;
- for (i = 1; i < criterias.length; ++i) {
- if (criterias[i].length > maxCriteriaLength) {
- maxCriteriaLength = criterias[i].length;
- }
- }
- for (let k = 1; k < database.length; ++k) {
- for (let l = 1; l < database[k].length; ++l) {
- let currentCriteriaResult = false;
- let hasMatchingCriteria = false;
- for (let j = 0; j < criterias.length; ++j) {
- let criteria = criterias[j];
- if (criteria.length < maxCriteriaLength) {
- continue;
- }
- let criteriaField = criteria[0];
- if (database[k][0] !== criteriaField) {
- continue;
- }
- hasMatchingCriteria = true;
- for (let p = 1; p < criteria.length; ++p) {
- currentCriteriaResult = currentCriteriaResult || new Function("return " + database[k][l] + criteria[p])();
- }
- }
- if (hasMatchingCriteria) {
- matches[l] = matches[l] && currentCriteriaResult;
- }
- }
- }
- let result = [];
- for (let n = 0; n < database[0].length; ++n) {
- if (matches[n]) {
- result.push(n - 1);
- }
- }
- return result;
- },
- findField: function(database, title) {
- let index2 = null;
- for (let i2 = 0; i2 < database.length; i2++) {
- if (database[i2][0] == title) {
- index2 = i2;
- break;
- }
- }
- if (index2 == null) {
- return error2.v;
- }
- return index2;
- },
- rest: function(array, idx) {
- idx = idx || 1;
- if (!array || typeof array.slice !== "function") {
- return array;
- }
- return array.slice(idx);
- },
- compact: function(array) {
- if (!array) {
- return array;
- }
- let result = [];
- for (let i2 = 0; i2 < array.length; ++i2) {
- if (!array[i2]) {
- continue;
- }
- result.push(array[i2]);
- }
- return result;
- }
- };
- func_methods_default = func_methods;
- }
- });
-
- // src/function/matrix_methods.js
- function inverse(els) {
- var M = matrix.sylvester_matrix.create(els);
- return M.inverse().elements;
- }
- var matrix, init;
- var init_matrix_methods = __esm({
- "src/function/matrix_methods.js"() {
- matrix = {};
- init = function init2(matrix2) {
- var sylvester_matrix = function() {
- };
- sylvester_matrix.precision = 1e-6;
- sylvester_matrix.create = function(elements) {
- var M = new sylvester_matrix();
- return M.setElements(elements);
- };
- var $M = sylvester_matrix.create;
- sylvester_matrix.I = function(n) {
- var els = [], i2 = n, j;
- while (i2--) {
- j = n;
- els[i2] = [];
- while (j--) {
- els[i2][j] = i2 === j ? 1 : 0;
- }
- }
- return sylvester_matrix.create(els);
- };
- sylvester_matrix.prototype = {
- e: function(i2, j) {
- if (i2 < 1 || i2 > this.elements.length || j < 1 || j > this.elements[0].length) {
- return null;
- }
- return this.elements[i2 - 1][j - 1];
- },
- dimensions: function() {
- var cols = this.elements.length === 0 ? 0 : this.elements[0].length;
- return {rows: this.elements.length, cols};
- },
- rows: function() {
- return this.elements.length;
- },
- cols: function() {
- if (this.elements.length === 0) {
- return 0;
- }
- return this.elements[0].length;
- },
- eql: function(matrix3) {
- var M = matrix3.elements || matrix3;
- if (!M[0] || typeof M[0][0] === "undefined") {
- M = sylvester_matrix.create(M).elements;
- }
- if (this.elements.length === 0 || M.length === 0) {
- return this.elements.length === M.length;
- }
- if (this.elements.length !== M.length) {
- return false;
- }
- if (this.elements[0].length !== M[0].length) {
- return false;
- }
- var i2 = this.elements.length, nj = this.elements[0].length, j;
- while (i2--) {
- j = nj;
- while (j--) {
- if (Math.abs(this.elements[i2][j] - M[i2][j]) > sylvester_matrix.precision) {
- return false;
- }
- }
- }
- return true;
- },
- dup: function() {
- return sylvester_matrix.create(this.elements);
- },
- map: function(fn, context) {
- if (this.elements.length === 0) {
- return sylvester_matrix.create([]);
- }
- var els = [], i2 = this.elements.length, nj = this.elements[0].length, j;
- while (i2--) {
- j = nj;
- els[i2] = [];
- while (j--) {
- els[i2][j] = fn.call(context, this.elements[i2][j], i2 + 1, j + 1);
- }
- }
- return sylvester_matrix.create(els);
- },
- isSameSizeAs: function(matrix3) {
- var M = matrix3.elements || matrix3;
- if (typeof M[0][0] === "undefined") {
- M = sylvester_matrix.create(M).elements;
- }
- if (this.elements.length === 0) {
- return M.length === 0;
- }
- return this.elements.length === M.length && this.elements[0].length === M[0].length;
- },
- add: function(matrix3) {
- if (this.elements.length === 0)
- return this.map(function(x) {
- return x;
- });
- var M = matrix3.elements || matrix3;
- if (typeof M[0][0] === "undefined") {
- M = sylvester_matrix.create(M).elements;
- }
- if (!this.isSameSizeAs(M)) {
- return null;
- }
- return this.map(function(x, i2, j) {
- return x + M[i2 - 1][j - 1];
- });
- },
- subtract: function(matrix3) {
- if (this.elements.length === 0)
- return this.map(function(x) {
- return x;
- });
- var M = matrix3.elements || matrix3;
- if (typeof M[0][0] === "undefined") {
- M = sylvester_matrix.create(M).elements;
- }
- if (!this.isSameSizeAs(M)) {
- return null;
- }
- return this.map(function(x, i2, j) {
- return x - M[i2 - 1][j - 1];
- });
- },
- canMultiplyFromLeft: function(matrix3) {
- if (this.elements.length === 0) {
- return false;
- }
- var M = matrix3.elements || matrix3;
- if (typeof M[0][0] === "undefined") {
- M = sylvester_matrix.create(M).elements;
- }
- return this.elements[0].length === M.length;
- },
- multiply: function(matrix3) {
- if (this.elements.length === 0) {
- return null;
- }
- if (!matrix3.elements) {
- return this.map(function(x) {
- return x * matrix3;
- });
- }
- var returnVector = matrix3.modulus ? true : false;
- var M = matrix3.elements || matrix3;
- if (typeof M[0][0] === "undefined") {
- M = sylvester_matrix.create(M).elements;
- }
- if (!this.canMultiplyFromLeft(M)) {
- return null;
- }
- var i2 = this.elements.length, nj = M[0].length, j;
- var cols = this.elements[0].length, c2, elements = [], sum;
- while (i2--) {
- j = nj;
- elements[i2] = [];
- while (j--) {
- c2 = cols;
- sum = 0;
- while (c2--) {
- sum += this.elements[i2][c2] * M[c2][j];
- }
- elements[i2][j] = sum;
- }
- }
- var M = sylvester_matrix.create(elements);
- return returnVector ? M.col(1) : M;
- },
- minor: function(a, b, c2, d) {
- if (this.elements.length === 0) {
- return null;
- }
- var elements = [], ni = c2, i2, nj, j;
- var rows = this.elements.length, cols = this.elements[0].length;
- while (ni--) {
- i2 = c2 - ni - 1;
- elements[i2] = [];
- nj = d;
- while (nj--) {
- j = d - nj - 1;
- elements[i2][j] = this.elements[(a + i2 - 1) % rows][(b + j - 1) % cols];
- }
- }
- return sylvester_matrix.create(elements);
- },
- transpose: function() {
- if (this.elements.length === 0)
- return sylvester_matrix.create([]);
- var rows = this.elements.length, i2, cols = this.elements[0].length, j;
- var elements = [], i2 = cols;
- while (i2--) {
- j = rows;
- elements[i2] = [];
- while (j--) {
- elements[i2][j] = this.elements[j][i2];
- }
- }
- return sylvester_matrix.create(elements);
- },
- isSquare: function() {
- var cols = this.elements.length === 0 ? 0 : this.elements[0].length;
- return this.elements.length === cols;
- },
- max: function() {
- if (this.elements.length === 0) {
- return null;
- }
- var m = 0, i2 = this.elements.length, nj = this.elements[0].length, j;
- while (i2--) {
- j = nj;
- while (j--) {
- if (Math.abs(this.elements[i2][j]) > Math.abs(m)) {
- m = this.elements[i2][j];
- }
- }
- }
- return m;
- },
- indexOf: function(x) {
- if (this.elements.length === 0) {
- return null;
- }
- var index2 = null, ni = this.elements.length, i2, nj = this.elements[0].length, j;
- for (i2 = 0; i2 < ni; i2++) {
- for (j = 0; j < nj; j++) {
- if (this.elements[i2][j] === x) {
- return {i: i2 + 1, j: j + 1};
- }
- }
- }
- return null;
- },
- diagonal: function() {
- if (!this.isSquare) {
- return null;
- }
- var els = [], n = this.elements.length;
- for (var i2 = 0; i2 < n; i2++) {
- els.push(this.elements[i2][i2]);
- }
- return sylvester_matrix.create(els);
- },
- toRightTriangular: function() {
- if (this.elements.length === 0)
- return sylvester_matrix.create([]);
- var M = this.dup(), els;
- var n = this.elements.length, i2, j, np = this.elements[0].length, p;
- for (i2 = 0; i2 < n; i2++) {
- if (M.elements[i2][i2] === 0) {
- for (j = i2 + 1; j < n; j++) {
- if (M.elements[j][i2] !== 0) {
- els = [];
- for (p = 0; p < np; p++) {
- els.push(M.elements[i2][p] + M.elements[j][p]);
- }
- M.elements[i2] = els;
- break;
- }
- }
- }
- if (M.elements[i2][i2] !== 0) {
- for (j = i2 + 1; j < n; j++) {
- var multiplier = M.elements[j][i2] / M.elements[i2][i2];
- els = [];
- for (p = 0; p < np; p++) {
- els.push(p <= i2 ? 0 : M.elements[j][p] - M.elements[i2][p] * multiplier);
- }
- M.elements[j] = els;
- }
- }
- }
- return M;
- },
- determinant: function() {
- if (this.elements.length === 0) {
- return 1;
- }
- if (!this.isSquare()) {
- return null;
- }
- var M = this.toRightTriangular();
- var det = M.elements[0][0], n = M.elements.length;
- for (var i2 = 1; i2 < n; i2++) {
- det = det * M.elements[i2][i2];
- }
- return det;
- },
- isSingular: function() {
- return this.isSquare() && this.determinant() === 0;
- },
- trace: function() {
- if (this.elements.length === 0) {
- return 0;
- }
- if (!this.isSquare()) {
- return null;
- }
- var tr = this.elements[0][0], n = this.elements.length;
- for (var i2 = 1; i2 < n; i2++) {
- tr += this.elements[i2][i2];
- }
- return tr;
- },
- rank: function() {
- if (this.elements.length === 0) {
- return 0;
- }
- var M = this.toRightTriangular(), rank = 0;
- var i2 = this.elements.length, nj = this.elements[0].length, j;
- while (i2--) {
- j = nj;
- while (j--) {
- if (Math.abs(M.elements[i2][j]) > sylvester_matrix.precision) {
- rank++;
- break;
- }
- }
- }
- return rank;
- },
- augment: function(matrix3) {
- if (this.elements.length === 0) {
- return this.dup();
- }
- var M = matrix3.elements || matrix3;
- if (typeof M[0][0] === "undefined") {
- M = sylvester_matrix.create(M).elements;
- }
- var T = this.dup(), cols = T.elements[0].length;
- var i2 = T.elements.length, nj = M[0].length, j;
- if (i2 !== M.length) {
- return null;
- }
- while (i2--) {
- j = nj;
- while (j--) {
- T.elements[i2][cols + j] = M[i2][j];
- }
- }
- return T;
- },
- inverse: function() {
- if (this.elements.length === 0) {
- return null;
- }
- if (!this.isSquare() || this.isSingular()) {
- return null;
- }
- var n = this.elements.length, i2 = n, j;
- var M = this.augment(sylvester_matrix.I(n)).toRightTriangular();
- var np = M.elements[0].length, p, els, divisor;
- var inverse_elements = [], new_element;
- while (i2--) {
- els = [];
- inverse_elements[i2] = [];
- divisor = M.elements[i2][i2];
- for (p = 0; p < np; p++) {
- new_element = M.elements[i2][p] / divisor;
- els.push(new_element);
- if (p >= n) {
- inverse_elements[i2].push(new_element);
- }
- }
- M.elements[i2] = els;
- j = i2;
- while (j--) {
- els = [];
- for (p = 0; p < np; p++) {
- els.push(M.elements[j][p] - M.elements[i2][p] * M.elements[j][i2]);
- }
- M.elements[j] = els;
- }
- }
- return sylvester_matrix.create(inverse_elements);
- },
- round: function() {
- return this.map(function(x) {
- return Math.round(x);
- });
- },
- snapTo: function(x) {
- return this.map(function(p) {
- return Math.abs(p - x) <= sylvester_matrix.precision ? x : p;
- });
- },
- setElements: function(els) {
- var i2, j, elements = els.elements || els;
- if (elements[0] && typeof elements[0][0] !== "undefined") {
- i2 = elements.length;
- this.elements = [];
- while (i2--) {
- j = elements[i2].length;
- this.elements[i2] = [];
- while (j--) {
- this.elements[i2][j] = elements[i2][j];
- }
- }
- return this;
- }
- var n = elements.length;
- this.elements = [];
- for (i2 = 0; i2 < n; i2++) {
- this.elements.push([elements[i2]]);
- }
- return this;
- }
- };
- matrix2.sylvester_matrix = sylvester_matrix;
- };
- init(matrix);
- }
- });
-
- // src/function/func.js
- function luckysheet_compareWith() {
- let sp = arguments[1];
- let data_fp = arguments[0];
- let fp;
- if (getObjType(data_fp) == "object" && data_fp.startCell != null) {
- if (sp == "&") {
- fp = func_methods_default.getCellDataDyadicArr(data_fp, "text");
- } else {
- fp = func_methods_default.getCellDataDyadicArr(data_fp, "number");
- }
- if (fp.length == 1 && fp[0].length == 1) {
- fp = fp[0][0];
- }
- } else {
- fp = data_fp;
- }
- let data_tp = arguments[2];
- let tp;
- if (getObjType(data_tp) == "object" && data_tp.startCell != null) {
- if (sp == "&") {
- tp = func_methods_default.getCellDataDyadicArr(data_tp, "text");
- } else {
- tp = func_methods_default.getCellDataDyadicArr(data_tp, "number");
- }
- if (tp.length == 1 && tp[0].length == 1) {
- tp = tp[0][0];
- }
- } else {
- tp = data_tp;
- }
- if (valueIsError(fp)) {
- return fp;
- }
- if (valueIsError(tp)) {
- return tp;
- }
- if (getObjType(fp) == "array" && getObjType(fp[0]) == "array" && !func_methods_default.isDyadicArr(fp)) {
- return error.v;
- }
- if (getObjType(tp) == "array" && getObjType(tp[0]) == "array" && !func_methods_default.isDyadicArr(tp)) {
- return error.v;
- }
- if (sp == "<>") {
- sp = "!=";
- }
- if (sp == "=") {
- sp = "==";
- }
- if (fp == null && tp == null) {
- return "#INVERSE!";
- } else if (fp == "#INVERSE!") {
- fp = 0;
- if (sp == "-") {
- sp = "+";
- } else if (sp == "+") {
- sp = "-";
- }
- } else if (sp == "-" && fp == null) {
- fp = 0;
- } else if (sp == "/" && (tp == 0 || tp == null)) {
- return error.d;
- }
- function booleanOperation(a, operator, b) {
- if (isRealNum(a)) {
- a = parseFloat(a);
- }
- if (isRealNum(b)) {
- b = parseFloat(b);
- }
- if (operator == "==") {
- if (a == b) {
- return true;
- } else {
- return false;
- }
- } else if (operator == "!=") {
- if (a != b) {
- return true;
- } else {
- return false;
- }
- } else if (operator == ">=") {
- if (a >= b) {
- return true;
- } else {
- return false;
- }
- } else if (operator == "<=") {
- if (a <= b) {
- return true;
- } else {
- return false;
- }
- } else if (operator == ">") {
- if (a > b) {
- return true;
- } else {
- return false;
- }
- } else if (operator == "<") {
- if (a < b) {
- return true;
- } else {
- return false;
- }
- }
- }
- function booleanToNum(v) {
- if (v == null) {
- return v;
- }
- if (v.toString().toLowerCase() == "true") {
- return 1;
- }
- if (v.toString().toLowerCase() == "false") {
- return 0;
- }
- return v;
- }
- if (sp == "*") {
- if (getObjType(fp) == "array" && getObjType(tp) == "array") {
- let result = [];
- if (getObjType(fp[0]) == "array" && getObjType(tp[0]) == "array") {
- if (fp.length == tp.length && fp[0].length == tp[0].length) {
- for (let m = 0; m < fp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < fp[m].length; n++) {
- fp[m][n] = booleanToNum(fp[m][n]);
- tp[m][n] = booleanToNum(tp[m][n]);
- let value;
- if (isRealNum(fp[m][n]) && isRealNum(tp[m][n])) {
- value = luckysheet_calcADPMM(fp[m][n], sp, tp[m][n]);
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else if (fp[0].length == tp.length) {
- let rowlen = fp.length;
- let collen = tp[0].length;
- for (let m = 0; m < rowlen; m++) {
- let rowArr = [];
- for (let n = 0; n < collen; n++) {
- let value = 0;
- for (let p = 0; p < fp[0].length; p++) {
- fp[m][p] = booleanToNum(fp[m][p]);
- tp[p][n] = booleanToNum(tp[p][n]);
- if (isRealNum(fp[m][p]) && isRealNum(tp[p][n])) {
- value += luckysheet_calcADPMM(fp[m][p], sp, tp[p][n]);
- } else {
- value += error.v;
- }
- }
- if (value.toString() == "NaN") {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else if (fp.length == tp[0].length) {
- let rowlen = tp.length;
- let collen = fp[0].length;
- for (let m = 0; m < rowlen; m++) {
- let rowArr = [];
- for (let n = 0; n < collen; n++) {
- let value = 0;
- for (let p = 0; p < tp[0].length; p++) {
- fp[p][n] = booleanToNum(fp[p][n]);
- tp[m][p] = booleanToNum(tp[m][p]);
- if (isRealNum(tp[m][p]) && isRealNum(fp[p][n])) {
- value += luckysheet_calcADPMM(fp[p][n], sp, tp[m][p]);
- } else {
- value += error.v;
- }
- }
- if (value.toString() == "NaN") {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else {
- return error.na;
- }
- } else if (getObjType(fp[0]) == "array") {
- if (fp[0].length == tp.length) {
- for (let m = 0; m < fp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < fp[m].length; n++) {
- fp[m][n] = booleanToNum(fp[m][n]);
- tp[n] = booleanToNum(tp[n]);
- let value;
- if (isRealNum(fp[m][n]) && isRealNum(tp[n])) {
- value = luckysheet_calcADPMM(fp[m][n], sp, tp[n]);
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else if (fp[0].length == 1) {
- let rowlen = fp.length;
- let collen = tp.length;
- for (let m = 0; m < rowlen; m++) {
- let rowArr = [];
- for (let n = 0; n < collen; n++) {
- fp[m][0] = booleanToNum(fp[m][0]);
- tp[n] = booleanToNum(tp[n]);
- let value;
- if (isRealNum(fp[m][0]) && isRealNum(tp[n])) {
- value = luckysheet_calcADPMM(fp[m][0], sp, tp[n]);
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else {
- return error.na;
- }
- } else if (getObjType(tp[0]) == "array") {
- if (tp[0].length == fp.length) {
- for (let m = 0; m < tp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < tp[m].length; n++) {
- fp[n] = booleanToNum(fp[n]);
- tp[m][n] = booleanToNum(tp[m][n]);
- let value;
- if (isRealNum(fp[n]) && isRealNum(tp[m][n])) {
- value = luckysheet_calcADPMM(fp[n], sp, tp[m][n]);
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else if (tp[0].length == 1) {
- let rowlen = tp.length;
- let collen = fp.length;
- for (let m = 0; m < rowlen; m++) {
- let rowArr = [];
- for (let n = 0; n < collen; n++) {
- fp[n] = booleanToNum(fp[n]);
- tp[m][0] = booleanToNum(tp[m][0]);
- let value;
- if (isRealNum(fp[n]) && isRealNum(tp[m][0])) {
- value = luckysheet_calcADPMM(fp[n], sp, tp[m][0]);
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else {
- return error.na;
- }
- } else {
- if (fp.length != tp.length) {
- return error.na;
- }
- for (let n = 0; n < fp.length; n++) {
- fp[n] = booleanToNum(fp[n]);
- tp[n] = booleanToNum(tp[n]);
- let value;
- if (isRealNum(fp[n]) && isRealNum(tp[n])) {
- value = luckysheet_calcADPMM(fp[n], sp, tp[n]);
- } else {
- value = error.v;
- }
- result.push(value);
- }
- }
- return result;
- } else if (getObjType(fp) == "array") {
- tp = booleanToNum(tp);
- let result = [];
- if (getObjType(fp[0]) == "array") {
- for (let m = 0; m < fp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < fp[m].length; n++) {
- fp[m][n] = booleanToNum(fp[m][n]);
- let value;
- if (isRealNum(fp[m][n]) && isRealNum(tp)) {
- value = luckysheet_calcADPMM(fp[m][n], sp, tp);
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else {
- for (let n = 0; n < fp.length; n++) {
- fp[n] = booleanToNum(fp[n]);
- let value;
- if (isRealNum(fp[n]) && isRealNum(tp)) {
- value = luckysheet_calcADPMM(fp[n], sp, tp);
- } else {
- value = error.v;
- }
- result.push(value);
- }
- }
- return result;
- } else if (getObjType(tp) == "array") {
- fp = booleanToNum(fp);
- let result = [];
- if (getObjType(tp[0]) == "array") {
- for (let m = 0; m < tp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < tp[m].length; n++) {
- tp[m][n] = booleanToNum(tp[m][n]);
- let value;
- if (isRealNum(fp) && isRealNum(tp[m][n])) {
- value = luckysheet_calcADPMM(fp, sp, tp[m][n]);
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else {
- for (let n = 0; n < tp.length; n++) {
- tp[n] = booleanToNum(tp[n]);
- let value;
- if (isRealNum(fp) && isRealNum(tp[n])) {
- value = luckysheet_calcADPMM(fp, sp, tp[n]);
- } else {
- value = error.v;
- }
- result.push(value);
- }
- }
- return result;
- } else {
- fp = booleanToNum(fp);
- tp = booleanToNum(tp);
- let result;
- if (isRealNum(fp) && isRealNum(tp)) {
- result = luckysheet_calcADPMM(fp, sp, tp);
- } else {
- result = error.v;
- }
- return result;
- }
- } else if (sp == "/") {
- if (getObjType(fp) == "array" && getObjType(tp) == "array") {
- let result = [];
- if (getObjType(fp[0]) == "array" && getObjType(tp[0]) == "array") {
- if (fp.length == tp.length && fp[0].length == tp[0].length) {
- for (let m = 0; m < fp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < fp[m].length; n++) {
- fp[m][n] = booleanToNum(fp[m][n]);
- tp[m][n] = booleanToNum(tp[m][n]);
- let value;
- if (isRealNum(fp[m][n]) && isRealNum(tp[m][n])) {
- if (parseFloat(tp[m][n]) == 0) {
- value = error.d;
- } else {
- value = luckysheet_calcADPMM(fp[m][n], sp, tp[m][n]);
- }
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else if (fp[0].length == tp.length) {
- let tp_inverse = inverse(tp);
- let rowlen = fp.length;
- let collen = tp_inverse[0].length;
- for (let m = 0; m < rowlen; m++) {
- let rowArr = [];
- for (let n = 0; n < collen; n++) {
- let value = 0;
- for (let p = 0; p < fp[0].length; p++) {
- fp[m][p] = booleanToNum(fp[m][p]);
- tp_inverse[p][n] = booleanToNum(tp_inverse[p][n]);
- if (isRealNum(fp[m][p]) && isRealNum(tp_inverse[p][n])) {
- value += luckysheet_calcADPMM(fp[m][p], "*", tp_inverse[p][n]);
- } else {
- value += error.v;
- }
- }
- if (value.toString() == "NaN") {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else {
- return error.na;
- }
- } else if (getObjType(fp[0]) == "array") {
- if (fp[0].length == tp.length) {
- for (let m = 0; m < fp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < fp[m].length; n++) {
- fp[m][n] = booleanToNum(fp[m][n]);
- tp[n] = booleanToNum(tp[n]);
- let value;
- if (isRealNum(fp[m][n]) && isRealNum(tp[n])) {
- if (parseFloat(tp[n]) == 0) {
- value = error.d;
- } else {
- value = luckysheet_calcADPMM(fp[m][n], sp, tp[n]);
- }
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else if (fp[0].length == 1) {
- let rowlen = fp.length;
- let collen = tp.length;
- for (let m = 0; m < rowlen; m++) {
- let rowArr = [];
- for (let n = 0; n < collen; n++) {
- fp[m][0] = booleanToNum(fp[m][0]);
- tp[n] = booleanToNum(tp[n]);
- let value;
- if (isRealNum(fp[m][0]) && isRealNum(tp[n])) {
- if (parseFloat(tp[n]) == 0) {
- value = error.d;
- } else {
- value = luckysheet_calcADPMM(fp[m][0], sp, tp[n]);
- }
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else {
- return error.na;
- }
- } else if (getObjType(tp[0]) == "array") {
- if (tp[0].length == fp.length) {
- for (let m = 0; m < tp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < tp[m].length; n++) {
- fp[n] = booleanToNum(fp[n]);
- tp[m][n] = booleanToNum(tp[m][n]);
- let value;
- if (isRealNum(fp[n]) && isRealNum(tp[m][n])) {
- if (parseFloat(tp[m][n]) == 0) {
- value = error.d;
- } else {
- value = luckysheet_calcADPMM(fp[n], sp, tp[m][n]);
- }
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else if (tp[0].length == 1) {
- let rowlen = tp.length;
- let collen = fp.length;
- for (let m = 0; m < rowlen; m++) {
- let rowArr = [];
- for (let n = 0; n < collen; n++) {
- fp[n] = booleanToNum(fp[n]);
- tp[m][0] = booleanToNum(tp[m][0]);
- let value;
- if (isRealNum(fp[n]) && isRealNum(tp[m][0])) {
- if (parseFloat(tp[m][0]) == 0) {
- value = error.d;
- } else {
- value = luckysheet_calcADPMM(fp[n], sp, tp[m][0]);
- }
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else {
- return error.na;
- }
- } else {
- if (fp.length != tp.length) {
- return error.na;
- }
- for (let n = 0; n < fp.length; n++) {
- fp[n] = booleanToNum(fp[n]);
- tp[n] = booleanToNum(tp[n]);
- let value;
- if (isRealNum(fp[n]) && isRealNum(tp[n])) {
- if (parseFloat(tp[n]) == 0) {
- value = error.d;
- } else {
- value = luckysheet_calcADPMM(fp[n], sp, tp[n]);
- }
- } else {
- value = error.v;
- }
- result.push(value);
- }
- }
- return result;
- } else if (getObjType(fp) == "array") {
- tp = booleanToNum(tp);
- let result = [];
- if (getObjType(fp[0]) == "array") {
- for (let m = 0; m < fp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < fp[m].length; n++) {
- fp[m][n] = booleanToNum(fp[m][n]);
- let value;
- if (isRealNum(fp[m][n]) && isRealNum(tp)) {
- if (parseFloat(tp) == 0) {
- value = error.d;
- } else {
- value = luckysheet_calcADPMM(fp[m][n], sp, tp);
- }
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else {
- for (let n = 0; n < fp.length; n++) {
- fp[n] = booleanToNum(fp[n]);
- let value;
- if (isRealNum(fp[n]) && isRealNum(tp)) {
- if (parseFloat(tp) == 0) {
- value = error.d;
- } else {
- value = luckysheet_calcADPMM(fp[n], sp, tp);
- }
- } else {
- value = error.v;
- }
- result.push(value);
- }
- }
- return result;
- } else if (getObjType(tp) == "array") {
- fp = booleanToNum(fp);
- let result = [];
- if (getObjType(tp[0]) == "array") {
- for (let m = 0; m < tp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < tp[m].length; n++) {
- tp[m][n] = booleanToNum(tp[m][n]);
- let value;
- if (isRealNum(fp) && isRealNum(tp[m][n])) {
- if (parseFloat(tp[m][n]) == 0) {
- value = error.d;
- } else {
- value = luckysheet_calcADPMM(fp, sp, tp[m][n]);
- }
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else {
- for (let n = 0; n < tp.length; n++) {
- tp[n] = booleanToNum(tp[n]);
- let value;
- if (isRealNum(fp) && isRealNum(tp[n])) {
- if (parseFloat(tp[n]) == 0) {
- value = error.d;
- } else {
- value = luckysheet_calcADPMM(fp, sp, tp[n]);
- }
- } else {
- value = error.v;
- }
- result.push(value);
- }
- }
- return result;
- } else {
- fp = booleanToNum(fp);
- tp = booleanToNum(tp);
- let result;
- if (isRealNum(fp) && isRealNum(tp)) {
- if (parseFloat(tp) == 0) {
- result = error.d;
- } else {
- result = luckysheet_calcADPMM(fp, sp, tp);
- }
- } else {
- result = error.v;
- }
- return result;
- }
- } else if (sp == "+" || sp == "-" || sp == "%") {
- if (getObjType(fp) == "array" && getObjType(tp) == "array") {
- let result = [];
- if (getObjType(fp[0]) == "array" && getObjType(tp[0]) == "array") {
- if (fp.length != tp.length && fp[0].length != tp[0].length) {
- return error.na;
- }
- for (let m = 0; m < fp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < fp[m].length; n++) {
- fp[m][n] = booleanToNum(fp[m][n]);
- tp[m][n] = booleanToNum(tp[m][n]);
- let value;
- if (isRealNum(fp[m][n]) && isRealNum(tp[m][n])) {
- if (sp == "%" && parseFloat(tp[m][n]) == 0) {
- value = error.d;
- } else {
- value = luckysheet_calcADPMM(fp[m][n], sp, tp[m][n]);
- }
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else if (getObjType(fp[0]) == "array") {
- if (fp[0].length != tp.length) {
- return error.na;
- }
- for (let m = 0; m < fp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < fp[m].length; n++) {
- fp[m][n] = booleanToNum(fp[m][n]);
- tp[n] = booleanToNum(tp[n]);
- let value;
- if (isRealNum(fp[m][n]) && isRealNum(tp[n])) {
- if (sp == "%" && parseFloat(tp[n]) == 0) {
- value = error.d;
- } else {
- value = luckysheet_calcADPMM(fp[m][n], sp, tp[n]);
- }
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else if (getObjType(tp[0]) == "array") {
- if (tp[0].length != fp.length) {
- return error.na;
- }
- for (let m = 0; m < tp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < tp[m].length; n++) {
- fp[n] = booleanToNum(fp[n]);
- tp[m][n] = booleanToNum(tp[m][n]);
- let value;
- if (isRealNum(fp[n]) && isRealNum(tp[m][n])) {
- if (sp == "%" && parseFloat(tp[m][n]) == 0) {
- value = error.d;
- } else {
- value = luckysheet_calcADPMM(fp[n], sp, tp[m][n]);
- }
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else {
- if (fp.length != tp.length) {
- return error.na;
- }
- for (let n = 0; n < fp.length; n++) {
- fp[n] = booleanToNum(fp[n]);
- tp[n] = booleanToNum(tp[n]);
- let value;
- if (isRealNum(fp[n]) && isRealNum(tp[n])) {
- if (sp == "%" && parseFloat(tp[n]) == 0) {
- value = error.d;
- } else {
- value = luckysheet_calcADPMM(fp[n], sp, tp[n]);
- }
- } else {
- value = error.v;
- }
- result.push(value);
- }
- }
- return result;
- } else if (getObjType(fp) == "array") {
- tp = booleanToNum(tp);
- let result = [];
- if (getObjType(fp[0]) == "array") {
- for (let m = 0; m < fp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < fp[m].length; n++) {
- fp[m][n] = booleanToNum(fp[m][n]);
- let value;
- if (isRealNum(fp[m][n]) && isRealNum(tp)) {
- if (sp == "%" && parseFloat(tp) == 0) {
- value = error.d;
- } else {
- value = luckysheet_calcADPMM(fp[m][n], sp, tp);
- }
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else {
- for (let n = 0; n < fp.length; n++) {
- fp[n] = booleanToNum(fp[n]);
- let value;
- if (isRealNum(fp[n]) && isRealNum(tp)) {
- if (sp == "%" && parseFloat(tp) == 0) {
- value = error.d;
- } else {
- value = luckysheet_calcADPMM(fp[n], sp, tp);
- }
- } else {
- value = error.v;
- }
- result.push(value);
- }
- }
- return result;
- } else if (getObjType(tp) == "array") {
- fp = booleanToNum(fp);
- let result = [];
- if (getObjType(tp[0]) == "array") {
- for (let m = 0; m < tp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < tp[m].length; n++) {
- tp[m][n] = booleanToNum(tp[m][n]);
- let value;
- if (isRealNum(fp) && isRealNum(tp[m][n])) {
- if (sp == "%" && parseFloat(tp[m][n]) == 0) {
- value = error.d;
- } else {
- value = luckysheet_calcADPMM(fp, sp, tp[m][n]);
- }
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else {
- for (let n = 0; n < tp.length; n++) {
- tp[n] = booleanToNum(tp[n]);
- let value;
- if (isRealNum(fp) && isRealNum(tp[n])) {
- if (sp == "%" && parseFloat(tp[n]) == 0) {
- value = error.d;
- } else {
- value = luckysheet_calcADPMM(fp, sp, tp[n]);
- }
- } else {
- value = error.v;
- }
- result.push(value);
- }
- }
- return result;
- } else {
- fp = booleanToNum(fp);
- tp = booleanToNum(tp);
- let result;
- if (isRealNum(fp) && isRealNum(tp)) {
- if (sp == "%" && parseFloat(tp) == 0) {
- result = error.d;
- } else {
- result = luckysheet_calcADPMM(fp, sp, tp);
- }
- } else {
- result = error.v;
- }
- return result;
- }
- } else if (sp == "==" || sp == "!=" || sp == ">=" || sp == "<=" || sp == ">" || sp == "<") {
- if (getObjType(fp) == "array" && getObjType(tp) == "array") {
- let result = [];
- if (getObjType(fp[0]) == "array" && getObjType(tp[0]) == "array") {
- if (fp.length != tp.length && fp[0].length != tp[0].length) {
- return error.na;
- }
- for (let m = 0; m < fp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < fp[m].length; n++) {
- let value = booleanOperation(fp[m][n], sp, tp[m][n]);
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else if (getObjType(fp[0]) == "array") {
- if (fp[0].length != tp.length) {
- return error.na;
- }
- for (let m = 0; m < fp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < fp[m].length; n++) {
- let value = booleanOperation(fp[m][n], sp, tp[n]);
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else if (getObjType(tp[0]) == "array") {
- if (tp[0].length != fp.length) {
- return error.na;
- }
- for (let m = 0; m < tp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < tp[m].length; n++) {
- let value = booleanOperation(fp[n], sp, tp[m][n]);
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else {
- if (fp.length != tp.length) {
- return error.na;
- }
- for (let n = 0; n < fp.length; n++) {
- let value = booleanOperation(fp[n], sp, tp[n]);
- result.push(value);
- }
- }
- return result;
- } else if (getObjType(fp) == "array") {
- let result = [];
- if (getObjType(fp[0]) == "array") {
- for (let m = 0; m < fp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < fp[m].length; n++) {
- let value = booleanOperation(fp[m][n], sp, tp);
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else {
- for (let n = 0; n < fp.length; n++) {
- let value = booleanOperation(fp[n], sp, tp);
- result.push(value);
- }
- }
- return result;
- } else if (getObjType(tp) == "array") {
- let result = [];
- if (getObjType(tp[0]) == "array") {
- for (let m = 0; m < tp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < tp[m].length; n++) {
- let value = booleanOperation(fp, sp, tp[m][n]);
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else {
- for (let n = 0; n < tp.length; n++) {
- let value = booleanOperation(fp, sp, tp[n]);
- result.push(value);
- }
- }
- return result;
- } else {
- return booleanOperation(fp, sp, tp);
- }
- } else if (sp == "&") {
- if (getObjType(fp) == "array" && getObjType(tp) == "array") {
- let result = [];
- if (getObjType(fp[0]) == "array" && getObjType(tp[0]) == "array") {
- if (fp.length != tp.length && fp[0].length != tp[0].length) {
- return error.na;
- }
- for (let m = 0; m < fp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < fp[m].length; n++) {
- rowArr.push(fp[m][n] + "" + tp[m][n]);
- }
- result.push(rowArr);
- }
- } else if (getObjType(fp[0]) == "array") {
- if (fp[0].length != tp.length) {
- return error.na;
- }
- for (let m = 0; m < fp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < fp[m].length; n++) {
- rowArr.push(fp[m][n] + "" + tp[n]);
- }
- result.push(rowArr);
- }
- } else if (getObjType(tp[0]) == "array") {
- if (tp[0].length != fp.length) {
- return error.na;
- }
- for (let m = 0; m < tp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < tp[m].length; n++) {
- rowArr.push(fp[n] + "" + tp[m][n]);
- }
- result.push(rowArr);
- }
- } else {
- if (fp.length != tp.length) {
- return error.na;
- }
- for (let n = 0; n < fp.length; n++) {
- result.push(fp[n] + "" + tp[n]);
- }
- }
- return result;
- } else if (getObjType(fp) == "array") {
- let result = [];
- if (getObjType(fp[0]) == "array") {
- for (let m = 0; m < fp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < fp[m].length; n++) {
- rowArr.push(fp[m][n] + "" + tp);
- }
- result.push(rowArr);
- }
- } else {
- for (let n = 0; n < fp.length; n++) {
- result.push(fp[n] + "" + tp);
- }
- }
- return result;
- } else if (getObjType(tp) == "array") {
- let result = [];
- if (getObjType(tp[0]) == "array") {
- for (let m = 0; m < tp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < tp[m].length; n++) {
- rowArr.push(fp + "" + tp[m][n]);
- }
- result.push(rowArr);
- }
- } else {
- for (let n = 0; n < tp.length; n++) {
- result.push(fp + "" + tp[n]);
- }
- }
- return result;
- } else {
- return fp + "" + tp;
- }
- } else if (sp == "^") {
- if (getObjType(fp) == "array" && getObjType(tp) == "array") {
- let result = [];
- if (getObjType(fp[0]) == "array" && getObjType(tp[0]) == "array") {
- if (fp.length != tp.length && fp[0].length != tp[0].length) {
- return error.na;
- }
- for (let m = 0; m < fp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < fp[m].length; n++) {
- fp[m][n] = booleanToNum(fp[m][n]);
- tp[m][n] = booleanToNum(tp[m][n]);
- let value;
- if (isRealNum(fp[m][n]) && isRealNum(tp[m][n])) {
- value = Math.pow(parseFloat(fp[m][n]), parseFloat(tp[m][n]));
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else if (getObjType(fp[0]) == "array") {
- if (fp[0].length != tp.length) {
- return error.na;
- }
- for (let m = 0; m < fp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < fp[m].length; n++) {
- fp[m][n] = booleanToNum(fp[m][n]);
- tp[n] = booleanToNum(tp[n]);
- let value;
- if (isRealNum(fp[m][n]) && isRealNum(tp[n])) {
- value = Math.pow(parseFloat(fp[m][n]), parseFloat(tp[n]));
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else if (getObjType(tp[0]) == "array") {
- if (tp[0].length != fp.length) {
- return error.na;
- }
- for (let m = 0; m < tp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < tp[m].length; n++) {
- fp[n] = booleanToNum(fp[n]);
- tp[m][n] = booleanToNum(tp[m][n]);
- let value;
- if (isRealNum(fp[n]) && isRealNum(tp[m][n])) {
- value = Math.pow(parseFloat(fp[n]), parseFloat(tp[m][n]));
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else {
- if (fp.length != tp.length) {
- return error.na;
- }
- for (let n = 0; n < fp.length; n++) {
- fp[n] = booleanToNum(fp[n]);
- tp[n] = booleanToNum(tp[n]);
- let value;
- if (isRealNum(fp[n]) && isRealNum(tp[n])) {
- value = Math.pow(parseFloat(fp[n]), parseFloat(tp[n]));
- } else {
- value = error.v;
- }
- result.push(value);
- }
- }
- return result;
- } else if (getObjType(fp) == "array") {
- tp = booleanToNum(tp);
- let result = [];
- if (getObjType(fp[0]) == "array") {
- for (let m = 0; m < fp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < fp[m].length; n++) {
- fp[m][n] = booleanToNum(fp[m][n]);
- let value;
- if (isRealNum(fp[m][n]) && isRealNum(tp)) {
- value = Math.pow(parseFloat(fp[m][n]), parseFloat(tp));
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else {
- for (let n = 0; n < fp.length; n++) {
- fp[n] = booleanToNum(fp[n]);
- let value;
- if (isRealNum(fp[n]) && isRealNum(tp)) {
- value = Math.pow(parseFloat(fp[n]), parseFloat(tp));
- } else {
- value = error.v;
- }
- result.push(value);
- }
- }
- return result;
- } else if (getObjType(tp) == "array") {
- fp = booleanToNum(fp);
- let result = [];
- if (getObjType(tp[0]) == "array") {
- for (let m = 0; m < tp.length; m++) {
- let rowArr = [];
- for (let n = 0; n < tp[m].length; n++) {
- tp[m][n] = booleanToNum(tp[m][n]);
- let value;
- if (isRealNum(fp) && isRealNum(tp[m][n])) {
- value = Math.pow(parseFloat(fp), parseFloat(tp[m][n]));
- } else {
- value = error.v;
- }
- rowArr.push(value);
- }
- result.push(rowArr);
- }
- } else {
- for (let n = 0; n < tp.length; n++) {
- tp[n] = booleanToNum(tp[n]);
- let value;
- if (isRealNum(fp) && isRealNum(tp[n])) {
- value = Math.pow(parseFloat(fp), parseFloat(tp[n]));
- } else {
- value = error.v;
- }
- result.push(value);
- }
- }
- return result;
- } else {
- fp = booleanToNum(fp);
- tp = booleanToNum(tp);
- let result;
- if (isRealNum(fp) && isRealNum(tp)) {
- result = Math.pow(parseFloat(fp), parseFloat(tp));
- } else {
- result = error.v;
- }
- return result;
- }
- }
- }
- function luckysheet_getarraydata() {
- let fp = arguments[0];
- fp = fp.replace("{", "").replace("}", "").replace(/\"/g, "");
- let arr = [];
- if (fp.indexOf(";") > -1) {
- arr = fp.split(";");
- for (let i2 = 0; i2 < arr.length; i2++) {
- arr[i2] = arr[i2].split(",");
- }
- } else {
- arr = fp.split(",");
- }
- return arr;
- }
- function luckysheet_calcADPMM(fp, sp, tp) {
- let value;
- if (sp == "+") {
- value = (0, import_numeral4.default)(fp).add(tp).value();
- } else if (sp == "-") {
- value = (0, import_numeral4.default)(fp).subtract(tp).value();
- } else if (sp == "%") {
- value = new Function("return " + parseFloat(fp) + sp + "(" + parseFloat(tp) + ")")();
- } else if (sp == "/") {
- value = (0, import_numeral4.default)(fp).divide(tp).value();
- } else if (sp == "*") {
- value = (0, import_numeral4.default)(fp).multiply(tp).value();
- }
- return value;
- }
- function luckysheet_getcelldata(txt) {
- if (window.luckysheet_getcelldata_cache == null) {
- window.luckysheet_getcelldata_cache = {};
- }
- if (txt in window.luckysheet_getcelldata_cache) {
- return window.luckysheet_getcelldata_cache[txt];
- }
- let luckysheetfile = getluckysheetfile();
- let val = txt.split("!");
- let sheettxt = "", rangetxt = "", sheetIndex = -1, sheetdata = null;
- if (val.length > 1) {
- sheettxt = val[0].replace(/''/g, "'");
- rangetxt = val[1];
- if (sheettxt.substr(0, 1) == "'" && sheettxt.substr(sheettxt.length - 1, 1) == "'") {
- sheettxt = sheettxt.substring(1, sheettxt.length - 1);
- }
- for (let i2 in luckysheetfile) {
- if (sheettxt == luckysheetfile[i2].name) {
- sheetIndex = luckysheetfile[i2].index;
- sheetdata = luckysheetfile[i2].data;
- break;
- }
- }
- if (sheetIndex == -1) {
- sheetIndex = 0;
- }
- } else {
- let index2 = getSheetIndex(store_default.calculateSheetIndex);
- sheettxt = luckysheetfile[index2].name;
- sheetIndex = luckysheetfile[index2].index;
- sheetdata = luckysheetfile[index2].data;
- rangetxt = val[0];
- }
- if (rangetxt.indexOf(":") == -1) {
- let row = parseInt(rangetxt.replace(/[^0-9]/g, "")) - 1;
- let col = ABCatNum(rangetxt.replace(/[^A-Za-z]/g, ""));
- if (!isNaN(row) && !isNaN(col)) {
- let ret = getdatabyselectionD(sheetdata, {
- "row": [row, row],
- "column": [col, col]
- })[0][0];
- if (formula_default.execFunctionGlobalData != null) {
- let ef = formula_default.execFunctionGlobalData[row + "_" + col + "_" + sheetIndex];
- if (ef != null) {
- ret = ef;
- }
- }
- let rowl = 1;
- let coll = 1;
- let retAll = {
- "sheetName": sheettxt,
- "startCell": rangetxt,
- "rowl": rowl,
- "coll": coll,
- "data": ret
- };
- window.luckysheet_getcelldata_cache[txt] = retAll;
- return retAll;
- } else {
- return [];
- }
- } else {
- rangetxt = rangetxt.split(":");
- let row = [], col = [];
- row[0] = parseInt(rangetxt[0].replace(/[^0-9]/g, "")) - 1;
- row[1] = parseInt(rangetxt[1].replace(/[^0-9]/g, "")) - 1;
- if (isNaN(row[0])) {
- row[0] = 0;
- }
- if (isNaN(row[1])) {
- row[1] = sheetdata.length - 1;
- }
- if (row[0] > row[1]) {
- tooltip_default.info("\u9009\u62E9\u5931\u8D25", "\u8F93\u5165\u8303\u56F4\u9519\u8BEF\uFF01");
- return [];
- }
- col[0] = ABCatNum(rangetxt[0].replace(/[^A-Za-z]/g, ""));
- col[1] = ABCatNum(rangetxt[1].replace(/[^A-Za-z]/g, ""));
- if (isNaN(col[0])) {
- col[0] = 0;
- }
- if (isNaN(col[1])) {
- col[1] = sheetdata[0].length - 1;
- }
- if (col[0] > col[1]) {
- tooltip_default.info("\u9009\u62E9\u5931\u8D25", "\u8F93\u5165\u8303\u56F4\u9519\u8BEF\uFF01");
- return [];
- }
- let ret = getdatabyselectionD(sheetdata, {
- "row": row,
- "column": col
- });
- if (formula_default.execFunctionGlobalData != null) {
- for (let r2 = row[0]; r2 <= row[1]; r2++) {
- for (let c2 = col[0]; c2 <= col[1]; c2++) {
- let ef = formula_default.execFunctionGlobalData[r2 + "_" + c2 + "_" + sheetIndex];
- if (ef != null) {
- ret[r2 - row[0]][c2 - col[0]] = ef;
- }
- }
- }
- }
- let rowl = row[1] - row[0] + 1;
- let coll = col[1] - col[0] + 1;
- let retAll = {
- "sheetName": sheettxt,
- "startCell": rangetxt[0],
- "rowl": rowl,
- "coll": coll,
- "data": ret
- };
- window.luckysheet_getcelldata_cache[txt] = retAll;
- return retAll;
- }
- }
- function luckysheet_parseData(value) {
- if (typeof value === "object") {
- if (value == null) {
- return "";
- } else if (Array.isArray(value)) {
- let v = genarate(value[0]);
- return v[2];
- } else {
- if (Array.isArray(value.data)) {
- return error.v;
- } else {
- if (value.data.v === void 0) {
- return "";
- } else {
- return value.data.v;
- }
- }
- }
- } else if (!formula_default.isCompareOperator(value).flag) {
- let v = genarate(value);
- return v[2];
- } else if (typeof value === "string" || typeof value === "number") {
- return value;
- }
- return error.v;
- }
- function luckysheet_getValue() {
- let args = arguments[0];
- for (let i2 = 0; i2 < args.length; i2++) {
- let value = args[i2];
- if (typeof value === "object") {
- if (value == null) {
- value = "";
- } else if (Array.isArray(value)) {
- let v = genarate(value[0]);
- value = v[2];
- } else {
- if (Array.isArray(value.data)) {
- value = value.data;
- } else {
- if (value.data.v === void 0) {
- value = "";
- } else {
- value = value.data.v;
- }
- }
- }
- } else if (!formula_default.isCompareOperator(value).flag) {
- let v = genarate(value);
- value = v[2];
- }
- args[i2] = value;
- }
- }
- function luckysheet_indirect_check() {
- let cellTxt = arguments[0];
- if (cellTxt == null || cellTxt.length == 0) {
- return null;
- }
- return cellTxt;
- }
- function luckysheet_indirect_check_return(txt) {
- return txt;
- }
- function luckysheet_offset_check() {
- if (!(getObjType(arguments[0]) == "object" && arguments[0].startCell != null)) {
- return formula_default.error.v;
- }
- var reference = arguments[0].startCell;
- var rows = func_methods_default.getFirstValue(arguments[1]);
- if (valueIsError(rows)) {
- return rows;
- }
- if (!isRealNum(rows)) {
- return formula_default.error.v;
- }
- rows = parseInt(rows);
- var cols = func_methods_default.getFirstValue(arguments[2]);
- if (valueIsError(cols)) {
- return cols;
- }
- if (!isRealNum(cols)) {
- return formula_default.error.v;
- }
- cols = parseInt(cols);
- var height = arguments[0].rowl;
- if (arguments.length >= 4) {
- height = func_methods_default.getFirstValue(arguments[3]);
- if (valueIsError(height)) {
- return height;
- }
- if (!isRealNum(height)) {
- return formula_default.error.v;
- }
- height = parseInt(height);
- }
- var width = arguments[0].coll;
- if (arguments.length == 5) {
- width = func_methods_default.getFirstValue(arguments[4]);
- if (valueIsError(width)) {
- return width;
- }
- if (!isRealNum(width)) {
- return formula_default.error.v;
- }
- width = parseInt(width);
- }
- if (height < 1 || width < 1) {
- return formula_default.error.r;
- }
- var cellrange = formula_default.getcellrange(reference);
- var cellRow0 = cellrange["row"][0];
- var cellCol0 = cellrange["column"][0];
- cellRow0 += rows;
- cellCol0 += cols;
- var cellRow1 = cellRow0 + height - 1;
- var cellCol1 = cellCol0 + width - 1;
- if (cellRow0 < 0 || cellRow1 >= store_default.flowdata.length || cellCol0 < 0 || cellCol1 >= store_default.flowdata[0].length) {
- return formula_default.error.r;
- }
- return getRangetxt(store_default.calculateSheetIndex, {
- row: [cellRow0, cellRow1],
- column: [cellCol0, cellCol1]
- });
- }
- function luckysheet_getSpecialReference(isCellFirst, param1, param2) {
- let functionRange, rangeTxt;
- if (isCellFirst) {
- rangeTxt = param1;
- functionRange = param2;
- } else {
- functionRange = param1;
- rangeTxt = param2;
- }
- if (functionRange.startCell.indexOf(":") > -1 || rangeTxt.indexOf(":") > -1) {
- return error.v;
- }
- if (isCellFirst) {
- return luckysheet_getcelldata(rangeTxt + ":" + functionRange.startCell);
- } else {
- let rangeT = rangeTxt, sheetName = "";
- if (rangeTxt.indexOf("!") > -1) {
- let rangetxtArr = rangeTxt.split("!");
- sheetName = rangetxtArr[0] + "!";
- rangeT = rangetxtArr[1];
- }
- return luckysheet_getcelldata(sheetName + functionRange.startCell + ":" + rangeT);
- }
- }
- var import_numeral4;
- var init_func = __esm({
- "src/function/func.js"() {
- init_func_methods();
- init_formula();
- init_tooltip();
- init_validate();
- init_getdata();
- init_format();
- init_matrix_methods();
- init_get();
- init_util();
- init_store();
- import_numeral4 = __toModule(require_numeral());
- }
- });
-
- // src/expendPlugins/chart/plugin.js
- function chart(options, config, isDemo2) {
- const data = options.data;
- loadLinks(dependLinks);
- seriesLoadScripts(dependScripts, null, function() {
- const store = new Vuex.Store();
- console.info("chartmix::", chartmix.default);
- Vue.use(chartmix.default, {store});
- let outDom = document.getElementsByTagName("body")[0];
- chartmix.default.initChart(outDom, store_default.lang);
- $(".chartSetting").css({
- top: "1px",
- bottom: "1px",
- position: "absolute",
- right: "0px",
- width: "350px",
- background: "#fff",
- border: "1px solid #E5E5E5",
- "z-index": 1004,
- "box-shadow": "0px 2px 4px rgba(0,0,0,0.2)",
- "-webkit-box-shadow": "0px 2px 4px rgba(0,0,0,0.2)",
- "-moz-box-shadow": "0px 2px 4px rgba(0,0,0,0.2)",
- "-moz-user-select": "none",
- "-khtml-user-select": "none",
- "-webkit-user-select": "none",
- "-ms-user-select": "none",
- "user-select": "none",
- "padding-left": "30px",
- display: "none"
- });
- store_default.createChart = chartmix.default.createChart;
- store_default.highlightChart = chartmix.default.highlightChart;
- store_default.deleteChart = chartmix.default.deleteChart;
- store_default.resizeChart = chartmix.default.resizeChart;
- store_default.changeChartRange = chartmix.default.changeChartRange;
- store_default.changeChartCellData = chartmix.default.changeChartCellData;
- store_default.getChartJson = chartmix.default.getChartJson;
- store_default.chart_selection = chart_selection();
- store_default.chartparam.jfrefreshchartall = jfrefreshchartall;
- store_default.chartparam.changeChartCellData = chartmix.default.changeChartCellData;
- store_default.chartparam.renderChart = chartmix.default.renderChart;
- store_default.chartparam.getChartJson = chartmix.default.getChartJson;
- store_default.chartparam.insertToStore = chartmix.default.insertToStore;
- for (let i2 = 0; i2 < data.length; i2++) {
- renderCharts(data[i2].chart, isDemo2);
- }
- for (let i2 = 0; i2 < data.length; i2++) {
- if (data[i2].status == "1") {
- renderChartShow(data[i2].index);
- }
- }
- arrayRemoveItem(store_default.asyncLoad, "chart");
- });
- }
- function renderCharts(chartLists, isDemo2) {
- if (chartLists == void 0) {
- return;
- }
- for (let i2 = 0; i2 < chartLists.length; i2++) {
- let chart2 = chartLists[i2];
- if (isDemo2) {
- store_default.chartparam.insertToStore({chart_id: chart2.chart_id, chartOptions: chart2.chartOptions});
- }
- let chart_id = chart2.chart_id;
- let chart_id_c = chart_id + "_c";
- let modelChartShowHTML = '';
- let $t;
- if ($(`.luckysheet-cell-main #${chart_id_c}`).length === 0) {
- $t = $(replaceHtml2(modelChartShowHTML, {
- id: chart_id_c,
- addclass: "luckysheet-data-visualization-chart",
- title: "\u56FE\u8868\u751F\u6210",
- content: ""
- })).appendTo($(".luckysheet-cell-main"));
- }
- if (!$t)
- return;
- setChartMoveableEffect($t);
- $(`#${chart_id_c}`).children(".luckysheet-modal-dialog-content")[0].id = chart_id;
- let container2 = document.getElementById(chart_id_c);
- let chart_json;
- chart_json = store_default.chartparam.getChartJson(chart2.chart_id);
- store_default.chartparam.renderChart({chart_id: chart2.chart_id, chartOptions: chart_json});
- store_default.currentChart = chart_json;
- showNeedRangeShow(chart_id);
- $(`#${chart_id}_c .luckysheet-modal-controll-del`).click(function(e) {
- delChart(chart_id);
- });
- $(`#${chart_id}_c .luckysheet-modal-controll-update`).click(function(e) {
- showChartSettingComponent();
- });
- $(`#${chart_id}_c`).mouseup(function(e) {
- const w = $(this).css("width");
- const h = $(this).css("height");
- const t = $(this).css("top");
- const l = $(this).css("left");
- let sheetFile = store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)];
- if (!sheetFile.chart) {
- sheetFile.chart = [];
- }
- sheetFile.chart.forEach((item2) => {
- if (item2.chart_id === chart_id) {
- item2.width = parseFloat(w);
- item2.height = parseFloat(h);
- item2.left = parseFloat(l);
- item2.top = parseFloat(t);
- }
- });
- });
- $t.children(".luckysheet-modal-dialog-content").mousedown(function(e) {
- if (!store_default.chartparam.luckysheetCurrentChartMaxState) {
- showNeedRangeShow(chart_id);
- }
- e.stopPropagation();
- });
- $t.mousedown(function(e) {
- if (!store_default.chartparam.luckysheetCurrentChartMaxState) {
- showNeedRangeShow(chart_id);
- setluckysheet_scroll_status(true);
- if (!$(e.target).is(".luckysheet-modal-dialog-controll") && !$(e.target).is(".luckysheet-modal-controll-btn") && !$(e.target).is("i")) {
- store_default.chartparam.luckysheetCurrentChartMoveTimeout = setTimeout(function() {
- store_default.chartparam.luckysheetCurrentChartMove = true;
- }, 100);
- }
- var toffset = store_default.chartparam.luckysheetCurrentChartMoveObj.offset();
- var tpsition = store_default.chartparam.luckysheetCurrentChartMoveObj.position();
- store_default.chartparam.luckysheetCurrentChartMoveXy = [
- e.pageX - toffset.left,
- e.pageY - toffset.top,
- tpsition.left,
- tpsition.top,
- $("#luckysheet-scrollbar-x").scrollLeft(),
- $("#luckysheet-scrollbar-y").scrollTop()
- ];
- store_default.chartparam.luckysheetCurrentChartMoveWinH = $("#luckysheet-cell-main")[0].scrollHeight;
- store_default.chartparam.luckysheetCurrentChartMoveWinW = $("#luckysheet-cell-main")[0].scrollWidth;
- if (!$(e.target).hasClass("luckysheet-mousedown-cancel") && $(e.target).filter("[class*='sp-palette']").length == 0 && $(e.target).filter("[class*='sp-thumb']").length == 0 && $(e.target).filter("[class*='sp-']").length == 0) {
- $("#luckysheet-rightclick-menu").hide();
- $("#luckysheet-cols-h-hover").hide();
- $("#luckysheet-cols-menu-btn").hide();
- $("#luckysheet-rightclick-menu").hide();
- $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu, #luckysheet-user-menu").hide();
- $("body > .luckysheet-filter-menu, body > .luckysheet-filter-submenu, body > .luckysheet-cols-menu").hide();
- }
- e.stopPropagation();
- }
- }).find(".luckysheet-modal-dialog-resize-item").mousedown(function(e) {
- if (store_default.chartparam.luckysheetCurrentChartActive) {
- store_default.chartparam.luckysheetCurrentChartResize = $(this).data("type");
- var mouse = mouseposition(e.pageX, e.pageY), scrollLeft = $("#luckysheet-scrollbar-x").scrollLeft(), scrollTop = $("#luckysheet-scrollbar-y").scrollTop();
- var x = mouse[0] + scrollLeft;
- var y = mouse[1] + scrollTop;
- var position = store_default.chartparam.luckysheetCurrentChartResizeObj.position();
- store_default.chartparam.luckysheetCurrentChartResizeXy = [
- x,
- y,
- $t.width(),
- $t.height(),
- position.left + scrollLeft,
- position.top + scrollTop,
- scrollLeft,
- scrollTop
- ];
- store_default.chartparam.luckysheetCurrentChartResizeWinH = $("#luckysheet-cell-main")[0].scrollHeight;
- store_default.chartparam.luckysheetCurrentChartResizeWinW = $("#luckysheet-cell-main")[0].scrollWidth;
- store_default.chartparam.luckysheetCurrentChart = chart_id;
- e.stopPropagation();
- }
- });
- let width = chart2.width;
- let height = chart2.height;
- let left = chart2.left;
- let top = chart2.top;
- container2.style.width = width + "px";
- container2.style.height = height + "px";
- container2.style.position = "absolute";
- container2.style.background = "#fff";
- container2.style.left = left + "px";
- container2.style.top = top + "px";
- container2.style.zIndex = store_default.zIndex ? store_default.zIndex : 15;
- store_default.zIndex++;
- }
- }
- function jfrefreshchartall(flowdata1, r_st, r_ed, c_st, c_ed) {
- const sheetInfo = store_default.luckysheetfile.find((item2) => item2.index == store_default.currentSheetIndex);
- const charts = sheetInfo.chart;
- charts && charts.forEach((item2) => {
- var getcelldata = luckysheet_getcelldata(sheetInfo.name + "!" + item2.chartOptions.rangeTxt);
- if (typeof getcelldata === "object" && getcelldata.length != 0 && getcelldata.data.length != null) {
- var chartData = getcelldata.data;
- store_default.chartparam.changeChartCellData(item2.chart_id, chartData);
- }
- });
- }
- function chart_selection() {
- return {
- create: function() {
- var chart_json = store_default.currentChart;
- if (chart_json.rangeArray.length > 1) {
- return;
- }
- $("#luckysheet-chart-rangeShow").empty();
- $("#luckysheet-cell-selected-boxs").hide();
- $("#luckysheet-cell-selected-focus").hide();
- $("#luckysheet-rows-h-selected").empty();
- $("#luckysheet-cols-h-selected").empty();
- $("#luckysheet-row-count-show").hide();
- $("#luckysheet-column-count-show").hide();
- var st_r = chart_json.rangeArray[0].row[0];
- var st_c = chart_json.rangeArray[0].column[0];
- var rangeSplitArray = chart_json.rangeSplitArray;
- var rangeRowCheck = chart_json.rangeRowCheck;
- if (rangeRowCheck.exits) {
- var chart_rowtitle_html = getRangeShowHtml("rowtitle", rangeSplitArray.rowtitle.row[0] + st_r, rangeSplitArray.rowtitle.row[1] + st_r, rangeSplitArray.rowtitle.column[0] + st_c, rangeSplitArray.rowtitle.column[1] + st_c);
- } else {
- var chart_rowtitle_html = "";
- }
- var rangeColCheck = chart_json.rangeColCheck;
- if (rangeColCheck.exits) {
- var chart_coltitle_html = getRangeShowHtml("coltitle", rangeSplitArray.coltitle.row[0] + st_r, rangeSplitArray.coltitle.row[1] + st_r, rangeSplitArray.coltitle.column[0] + st_c, rangeSplitArray.coltitle.column[1] + st_c);
- } else {
- var chart_coltitle_html = "";
- }
- var chart_content_html = getRangeShowHtml("content", rangeSplitArray.content.row[0] + st_r, rangeSplitArray.content.row[1] + st_r, rangeSplitArray.content.column[0] + st_c, rangeSplitArray.content.column[1] + st_c);
- $("#luckysheet-chart-rangeShow").append(chart_rowtitle_html + chart_coltitle_html + chart_content_html);
- function getRangeShowHtml(type, r1, r2, c1, c2) {
- var visibledatarow = getvisibledatarow();
- var visibledatacolumn = getvisibledatacolumn();
- var row = visibledatarow[r2], row_pre = r1 - 1 == -1 ? 0 : visibledatarow[r1 - 1];
- var col = visibledatacolumn[c2], col_pre = c1 - 1 == -1 ? 0 : visibledatacolumn[c1 - 1];
- if (type == "rowtitle") {
- var color = "#C65151";
- }
- if (type == "coltitle") {
- var color = "#9667C0";
- }
- if (type == "content") {
- var color = "#4970D1";
- }
- var html = '';
- return html;
- }
- },
- rangeMove: false,
- rangeMovexy: null,
- rangeMoveIndex: null,
- rangeMoveObj: null,
- rangeMoveDraging: function(event2, sheetBarHeight, statisticBarHeight) {
- var chart_json = store_default.currentChart;
- var st_r = chart_json.rangeArray[0].row[0];
- var st_c = chart_json.rangeArray[0].column[0];
- var rangeRowCheck = chart_json.rangeRowCheck;
- var rangeColCheck = chart_json.rangeColCheck;
- var rangeSplitArray = chart_json.rangeSplitArray;
- var mouse = mouseposition(event2.pageX, event2.pageY);
- var scrollLeft = $("#luckysheet-cell-main").scrollLeft();
- var scrollTop = $("#luckysheet-cell-main").scrollTop();
- var x = mouse[0] + scrollLeft;
- var y = mouse[1] + scrollTop;
- var winH = $(window).height() + scrollTop - sheetBarHeight - statisticBarHeight, winW = $(window).width() + scrollLeft;
- var rowLocation2 = _rowLocation(y), row_index = rowLocation2[2];
- var colLocation2 = _colLocation(x), col_index = colLocation2[2];
- var visibledatarow = getvisibledatarow();
- var visibledatacolumn = getvisibledatacolumn();
- var $id = store_default.chart_selection.rangeMoveObj.attr("id");
- if ($id == "luckysheet-chart-rangeShow-content") {
- var row_s = store_default.chart_selection.rangeMoveIndex[0] - store_default.chart_selection.rangeMovexy[0] + row_index;
- if (rangeRowCheck.exits) {
- if (row_s < st_r + rangeRowCheck.range[1] + 1 || y < 0) {
- row_s = st_r + rangeRowCheck.range[1] + 1;
- }
- } else {
- if (row_s < 0 || y < 0) {
- row_s = 0;
- }
- }
- var row_e = rangeSplitArray.content.row[1] - rangeSplitArray.content.row[0] + row_s;
- if (row_e >= visibledatarow.length - 1 || y > winH) {
- row_s = visibledatarow.length - 1 - rangeSplitArray.content.row[1] + rangeSplitArray.content.row[0];
- row_e = visibledatarow.length - 1;
- }
- var col_s = store_default.chart_selection.rangeMoveIndex[1] - store_default.chart_selection.rangeMovexy[1] + col_index;
- if (rangeColCheck.exits) {
- if (col_s < st_c + rangeColCheck.range[1] + 1 || x < 0) {
- col_s = st_c + rangeColCheck.range[1] + 1;
- }
- } else {
- if (col_s < 0 || x < 0) {
- col_s = 0;
- }
- }
- var col_e = rangeSplitArray.content.column[1] - rangeSplitArray.content.column[0] + col_s;
- if (col_e >= visibledatacolumn.length - 1 || x > winW) {
- col_s = visibledatacolumn.length - 1 - rangeSplitArray.content.column[1] + rangeSplitArray.content.column[0];
- col_e = visibledatacolumn.length - 1;
- }
- if (rangeRowCheck.exits && rangeColCheck.exits) {
- chart_json.rangeArray = [{row: [st_r, row_e], column: [st_c, col_e]}];
- chart_json.rangeSplitArray.range = {
- row: [st_r, row_e],
- column: [st_c, col_e]
- };
- chart_json.rangeSplitArray.content = {
- row: [row_s - st_r, row_e - st_r],
- column: [col_s - st_c, col_e - st_c]
- };
- chart_json.rangeSplitArray.rowtitle = {
- row: chart_json.rangeSplitArray.rowtitle.row,
- column: [col_s - st_c, col_e - st_c]
- };
- chart_json.rangeSplitArray.coltitle = {
- row: [row_s - st_r, row_e - st_r],
- column: chart_json.rangeSplitArray.coltitle.column
- };
- } else if (rangeRowCheck.exits) {
- chart_json.rangeArray = [{row: [st_r, row_e], column: [col_s, col_e]}];
- chart_json.rangeSplitArray.range = {
- row: [st_r, row_e],
- column: [col_s, col_e]
- };
- chart_json.rangeSplitArray.content = {
- row: [row_s - st_r, row_e - st_r],
- column: chart_json.rangeSplitArray.content.column
- };
- } else if (rangeColCheck.exits) {
- chart_json.rangeArray = [{row: [row_s, row_e], column: [st_c, col_e]}];
- chart_json.rangeSplitArray.range = {
- row: [row_s, row_e],
- column: [st_c, col_e]
- };
- chart_json.rangeSplitArray.content = {
- row: chart_json.rangeSplitArray.content.row,
- column: [col_s - st_c, col_e - st_c]
- };
- } else {
- chart_json.rangeArray = [{row: [row_s, row_e], column: [col_s, col_e]}];
- chart_json.rangeSplitArray.range = {
- row: [row_s, row_e],
- column: [col_s, col_e]
- };
- }
- } else if ($id == "luckysheet-chart-rangeShow-rowtitle") {
- var col_s = store_default.chart_selection.rangeMoveIndex[1] - store_default.chart_selection.rangeMovexy[1] + col_index;
- if (rangeColCheck.exits) {
- if (col_s < st_c + rangeColCheck.range[1] + 1 || x < 0) {
- col_s = st_c + rangeColCheck.range[1] + 1;
- }
- } else {
- if (col_s < 0 || x < 0) {
- col_s = 0;
- }
- }
- var col_e = rangeSplitArray.rowtitle.column[1] - rangeSplitArray.rowtitle.column[0] + col_s;
- if (col_e >= visibledatacolumn.length - 1 || x > winW) {
- col_s = visibledatacolumn.length - 1 - rangeSplitArray.rowtitle.column[1] + rangeSplitArray.rowtitle.column[0];
- col_e = visibledatacolumn.length - 1;
- }
- if (rangeColCheck.exits) {
- chart_json.rangeArray = [{row: chart_json.rangeArray[0].row, column: [st_c, col_e]}];
- chart_json.rangeSplitArray.range = {
- row: chart_json.rangeArray[0].row,
- column: [st_c, col_e]
- };
- chart_json.rangeSplitArray.rowtitle = {
- row: chart_json.rangeSplitArray.rowtitle.row,
- column: [col_s - st_c, col_e - st_c]
- };
- chart_json.rangeSplitArray.content = {
- row: chart_json.rangeSplitArray.content.row,
- column: [col_s - st_c, col_e - st_c]
- };
- } else {
- chart_json.rangeArray = [{row: chart_json.rangeArray[0].row, column: [col_s, col_e]}];
- chart_json.rangeSplitArray.range = {
- row: chart_json.rangeArray[0].row,
- column: [col_s, col_e]
- };
- }
- } else if ($id == "luckysheet-chart-rangeShow-coltitle") {
- var row_s = store_default.chart_selection.rangeMoveIndex[0] - store_default.chart_selection.rangeMovexy[0] + row_index;
- if (rangeRowCheck.exits) {
- if (row_s < st_r + rangeRowCheck.range[1] + 1 || y < 0) {
- row_s = st_r + rangeRowCheck.range[1] + 1;
- }
- } else {
- if (row_s < 0 || y < 0) {
- row_s = 0;
- }
- }
- var row_e = rangeSplitArray.coltitle.row[1] - rangeSplitArray.coltitle.row[0] + row_s;
- if (row_e >= visibledatarow.length - 1 || y > winH) {
- row_s = visibledatarow.length - 1 - rangeSplitArray.coltitle.row[1] + rangeSplitArray.coltitle.row[0];
- row_e = visibledatarow.length - 1;
- }
- if (rangeRowCheck.exits) {
- chart_json.rangeArray = [{row: [st_r, row_e], column: chart_json.rangeArray[0].column}];
- chart_json.rangeSplitArray.range = {
- row: [st_r, row_e],
- column: chart_json.rangeArray[0].column
- };
- chart_json.rangeSplitArray.coltitle = {
- row: [row_s - st_r, row_e - st_r],
- column: chart_json.rangeSplitArray.coltitle.column
- };
- chart_json.rangeSplitArray.content = {
- row: [row_s - st_r, row_e - st_r],
- column: chart_json.rangeSplitArray.content.column
- };
- } else {
- chart_json.rangeArray = [{row: [row_s, row_e], column: chart_json.rangeArray[0].column}];
- chart_json.rangeSplitArray.range = {
- row: [row_s, row_e],
- column: chart_json.rangeArray[0].column
- };
- }
- }
- store_default.chart_selection.create();
- },
- rangeMoveDragged: function() {
- store_default.chart_selection.rangeMove = false;
- var updateJson = store_default.currentChart;
- updateJson.rangeTxt = getRangetxt(store_default.currentSheetIndex, updateJson.rangeArray[0], store_default.currentSheetIndex);
- updateJson.chartData = getdatabyselection(updateJson.rangeArray[0], store_default.currentSheetIndex);
- store_default.changeChartRange(updateJson.chart_id, updateJson.chartData, updateJson.rangeArray, updateJson.rangeTxt);
- },
- rangeResize: false,
- rangeResizexy: null,
- rangeResizeIndex: null,
- rangeResizeObj: null,
- rangeResizeDraging: function(event2, sheetBarHeight, statisticBarHeight) {
- var chart_json = store_default.currentChart;
- var st_r = chart_json.rangeArray[0].row[0];
- var st_c = chart_json.rangeArray[0].column[0];
- var rangeRowCheck = chart_json.rangeRowCheck;
- var rangeColCheck = chart_json.rangeColCheck;
- var rangeSplitArray = chart_json.rangeSplitArray;
- var mouse = mouseposition(event2.pageX, event2.pageY);
- var scrollLeft = $("#luckysheet-cell-main").scrollLeft();
- var scrollTop = $("#luckysheet-cell-main").scrollTop();
- var x = mouse[0] + scrollLeft;
- var y = mouse[1] + scrollTop;
- var winH = $(window).height() + scrollTop - sheetBarHeight - statisticBarHeight, winW = $(window).width() + scrollLeft;
- var rowLocation2 = _rowLocation(y), row_index = rowLocation2[2];
- var colLocation2 = _colLocation(x), col_index = colLocation2[2];
- var visibledatarow = getvisibledatarow();
- var visibledatacolumn = getvisibledatacolumn();
- var $id = store_default.chart_selection.rangeResizeObj.attr("id");
- if ($id == "luckysheet-chart-rangeShow-content") {
- var r1, r2, c1, c2;
- if (store_default.chart_selection.rangeResize == "lt") {
- r1 = store_default.chart_selection.rangeResizeIndex.row[0];
- c1 = store_default.chart_selection.rangeResizeIndex.column[0];
- r2 = store_default.chart_selection.rangeResizeIndex.row[1];
- c2 = store_default.chart_selection.rangeResizeIndex.column[1];
- } else if (store_default.chart_selection.rangeResize == "lb") {
- r1 = store_default.chart_selection.rangeResizeIndex.row[1];
- c1 = store_default.chart_selection.rangeResizeIndex.column[0];
- r2 = store_default.chart_selection.rangeResizeIndex.row[0];
- c2 = store_default.chart_selection.rangeResizeIndex.column[1];
- } else if (store_default.chart_selection.rangeResize == "rt") {
- r1 = store_default.chart_selection.rangeResizeIndex.row[0];
- c1 = store_default.chart_selection.rangeResizeIndex.column[1];
- r2 = store_default.chart_selection.rangeResizeIndex.row[1];
- c2 = store_default.chart_selection.rangeResizeIndex.column[0];
- } else if (store_default.chart_selection.rangeResize == "rb") {
- r1 = store_default.chart_selection.rangeResizeIndex.row[1];
- c1 = store_default.chart_selection.rangeResizeIndex.column[1];
- r2 = store_default.chart_selection.rangeResizeIndex.row[0];
- c2 = store_default.chart_selection.rangeResizeIndex.column[0];
- }
- if (rangeRowCheck.exits) {
- var row_s = r1 - store_default.chart_selection.rangeResizexy[0] + row_index;
- if (row_s < st_r + rangeRowCheck.range[1] + 1 || y < 0) {
- row_s = st_r + rangeRowCheck.range[1] + 1;
- } else if (row_s >= visibledatarow.length - 1 || y > winH) {
- row_s = visibledatarow.length - 1;
- }
- } else {
- var row_s = st_r - store_default.chart_selection.rangeResizexy[0] + row_index;
- if (row_s < 0 || y < 0) {
- row_s = 0;
- } else if (row_s >= visibledatarow.length - 1 || y > winH) {
- row_s = visibledatarow.length - 1;
- }
- }
- if (rangeColCheck.exits) {
- var col_s = c1 - store_default.chart_selection.rangeResizexy[1] + col_index;
- if (col_s < st_c + rangeColCheck.range[1] + 1 || x < 0) {
- col_s = st_c + rangeColCheck.range[1] + 1;
- } else if (col_s >= visibledatacolumn.length - 1 || x > winW) {
- col_s = visibledatacolumn.length - 1;
- }
- } else {
- var col_s = st_c - store_default.chart_selection.rangeResizexy[1] + col_index;
- if (col_s < 0 || x < 0) {
- col_s = 0;
- } else if (col_s >= visibledatacolumn.length - 1 || x > winW) {
- col_s = visibledatacolumn.length - 1;
- }
- }
- var obj_r1, obj_r2, obj_c1, obj_c2;
- if (row_s > r2) {
- obj_r1 = r2;
- obj_r2 = row_s;
- } else {
- obj_r1 = row_s;
- obj_r2 = r2;
- }
- if (col_s > c2) {
- obj_c1 = c2;
- obj_c2 = col_s;
- } else {
- obj_c1 = col_s;
- obj_c2 = c2;
- }
- if (!rangeRowCheck.exits && !rangeColCheck.exits) {
- chart_json.rangeArray = [{row: [obj_r1, obj_r2], column: [obj_c1, obj_c2]}];
- chart_json.rangeSplitArray.range = {
- row: [obj_r1, obj_r2],
- column: [obj_c1, obj_c2]
- };
- } else {
- chart_json.rangeArray = [{row: [st_r, obj_r2], column: [st_c, obj_c2]}];
- chart_json.rangeSplitArray.range = {
- row: [st_r, obj_r2],
- column: [st_c, obj_c2]
- };
- chart_json.rangeSplitArray.content = {
- row: [obj_r1 - st_r, obj_r2 - st_r],
- column: [obj_c1 - st_c, obj_c2 - st_c]
- };
- if (rangeRowCheck.exits) {
- chart_json.rangeSplitArray.rowtitle = {
- row: chart_json.rangeSplitArray.rowtitle.row,
- column: [obj_c1 - st_c, obj_c2 - st_c]
- };
- }
- if (rangeColCheck.exits) {
- chart_json.rangeSplitArray.coltitle = {
- row: [obj_r1 - st_r, obj_r2 - st_r],
- column: chart_json.rangeSplitArray.coltitle.column
- };
- }
- }
- } else if ($id == "luckysheet-chart-rangeShow-rowtitle") {
- var c1, c2;
- if (store_default.chart_selection.rangeResize == "lt" || store_default.chart_selection.rangeResize == "lb") {
- c1 = store_default.chart_selection.rangeResizeIndex.column[0];
- c2 = store_default.chart_selection.rangeResizeIndex.column[1];
- } else if (store_default.chart_selection.rangeResize == "rt" || store_default.chart_selection.rangeResize == "rb") {
- c1 = store_default.chart_selection.rangeResizeIndex.column[1];
- c2 = store_default.chart_selection.rangeResizeIndex.column[0];
- }
- if (rangeColCheck.exits) {
- var col_s = c1 - store_default.chart_selection.rangeResizexy[1] + col_index;
- if (col_s < st_c + rangeColCheck.range[1] + 1 || x < 0) {
- col_s = st_c + rangeColCheck.range[1] + 1;
- } else if (col_s >= visibledatacolumn.length - 1 || x > winW) {
- col_s = visibledatacolumn.length - 1;
- }
- } else {
- var col_s = st_c - store_default.chart_selection.rangeResizexy[1] + col_index;
- if (col_s < 0 || x < 0) {
- col_s = 0;
- } else if (col_s >= visibledatacolumn.length - 1 || x > winW) {
- col_s = visibledatacolumn.length - 1;
- }
- }
- var obj_c1, obj_c2;
- if (col_s > c2) {
- obj_c1 = c2;
- obj_c2 = col_s;
- } else {
- obj_c1 = col_s;
- obj_c2 = c2;
- }
- if (!rangeColCheck.exits) {
- chart_json.rangeArray = [{row: chart_json.rangeArray[0].row, column: [obj_c1, obj_c2]}];
- chart_json.rangeSplitArray.range = {
- row: chart_json.rangeArray[0].row,
- column: [obj_c1, obj_c2]
- };
- } else {
- chart_json.rangeArray = [{row: chart_json.rangeArray[0].row, column: [st_c, obj_c2]}];
- chart_json.rangeSplitArray.range = {
- row: chart_json.rangeArray[0].row,
- column: [st_c, obj_c2]
- };
- chart_json.rangeSplitArray.rowtitle = {
- row: chart_json.rangeSplitArray.rowtitle.row,
- column: [obj_c1 - st_c, obj_c2 - st_c]
- };
- chart_json.rangeSplitArray.content = {
- row: chart_json.rangeSplitArray.content.row,
- column: [obj_c1 - st_c, obj_c2 - st_c]
- };
- }
- } else if ($id == "luckysheet-chart-rangeShow-coltitle") {
- var r1, r2;
- if (store_default.chart_selection.rangeResize == "lt" || store_default.chart_selection.rangeResize == "rt") {
- r1 = store_default.chart_selection.rangeResizeIndex.row[0];
- r2 = store_default.chart_selection.rangeResizeIndex.row[1];
- } else if (store_default.chart_selection.rangeResize == "lb" || store_default.chart_selection.rangeResize == "rb") {
- r1 = store_default.chart_selection.rangeResizeIndex.row[1];
- r2 = store_default.chart_selection.rangeResizeIndex.row[0];
- }
- if (rangeRowCheck.exits) {
- var row_s = r1 - store_default.chart_selection.rangeResizexy[0] + row_index;
- if (row_s < st_r + rangeRowCheck.range[1] + 1 || y < 0) {
- row_s = st_r + rangeRowCheck.range[1] + 1;
- } else if (row_s >= visibledatarow.length - 1 || y > winH) {
- row_s = visibledatarow.length - 1;
- }
- } else {
- var row_s = st_r - store_default.chart_selection.rangeResizexy[0] + row_index;
- if (row_s < 0 || y < 0) {
- row_s = 0;
- } else if (row_s >= visibledatarow.length - 1 || y > winH) {
- row_s = visibledatarow.length - 1;
- }
- }
- var obj_r1, obj_r2;
- if (row_s > r2) {
- obj_r1 = r2;
- obj_r2 = row_s;
- } else {
- obj_r1 = row_s;
- obj_r2 = r2;
- }
- if (!rangeRowCheck.exits) {
- chart_json.rangeArray = [{row: [obj_r1, obj_r2], column: chart_json.rangeArray[0].column}];
- chart_json.rangeSplitArray.range = {
- row: [obj_r1, obj_r2],
- column: chart_json.rangeArray[0].column
- };
- } else {
- chart_json.rangeArray = [{row: [st_r, obj_r2], column: chart_json.rangeArray[0].column}];
- chart_json.rangeSplitArray.range = {
- row: [st_r, obj_r2],
- column: chart_json.rangeArray[0].column
- };
- chart_json.rangeSplitArray.coltitle = {
- row: [obj_r1 - st_r, obj_r2 - st_r],
- column: chart_json.rangeSplitArray.coltitle.column
- };
- chart_json.rangeSplitArray.content = {
- row: [obj_r1 - st_r, obj_r2 - st_r],
- column: chart_json.rangeSplitArray.content.column
- };
- }
- }
- store_default.chart_selection.create();
- },
- rangeResizeDragged: function() {
- store_default.chart_selection.rangeResize = null;
- var updateJson = store_default.currentChart;
- updateJson.rangeTxt = getRangetxt(store_default.currentSheetIndex, updateJson.rangeArray[0], store_default.currentSheetIndex);
- updateJson.chartData = getdatabyselection(updateJson.rangeArray[0], store_default.currentSheetIndex);
- store_default.changeChartRange(updateJson.chart_id, updateJson.chartData, updateJson.rangeArray, updateJson.rangeTxt);
- }
- };
- }
- function createLuckyChart(width, height, left, top) {
- var jfgird_select_save = luckysheet.getluckysheet_select_save();
- if (jfgird_select_save.length == 1 && jfgird_select_save[0].row[0] == jfgird_select_save[0].row[1] && jfgird_select_save[0].column[0] == jfgird_select_save[0].column[1]) {
- luckysheetMoveHighlightRange2("right", "rangeOfSelect");
- luckysheetMoveHighlightRange2("down", "rangeOfSelect");
- jfgird_select_save = luckysheet.getluckysheet_select_save();
- }
- var shiftpositon_row = -1;
- var row_ed = jfgird_select_save[0]["row"][1] - jfgird_select_save[0]["row"][0];
- for (var r2 = jfgird_select_save[0]["row"][0]; r2 <= jfgird_select_save[0]["row"][1]; r2++) {
- for (var c2 = jfgird_select_save[0]["column"][0]; c2 <= jfgird_select_save[0]["column"][1]; c2++) {
- var value = getcellvalue(r2, c2, luckysheet.flowdata());
- if (value != null && value.toString().length > 0) {
- shiftpositon_row = r2;
- break;
- }
- }
- if (shiftpositon_row !== -1) {
- break;
- }
- }
- if (shiftpositon_row == -1) {
- shiftpositon_row = 0;
- }
- jfgird_select_save[0]["row"] = [shiftpositon_row, shiftpositon_row];
- jfgird_select_save[0].row_focus = shiftpositon_row;
- luckysheet.setluckysheet_select_save(jfgird_select_save);
- store_default.luckysheet_shiftpositon = $.extend(true, {}, jfgird_select_save[0]);
- luckysheetMoveEndCell("down", "range", false, row_ed);
- jfgird_select_save = luckysheet.getluckysheet_select_save();
- var shiftpositon_col = -1;
- var column_ed = jfgird_select_save[0]["column"][1] - jfgird_select_save[0]["column"][0];
- for (var c2 = jfgird_select_save[0]["column"][0]; c2 <= jfgird_select_save[0]["column"][1]; c2++) {
- for (var r2 = jfgird_select_save[0]["row"][0]; r2 <= jfgird_select_save[0]["row"][1]; r2++) {
- var value = getcellvalue(r2, c2, luckysheet.flowdata());
- if (value != null && value.toString().length > 0) {
- shiftpositon_col = c2;
- break;
- }
- }
- if (shiftpositon_col !== -1) {
- break;
- }
- }
- if (shiftpositon_col == -1) {
- shiftpositon_col = 0;
- }
- jfgird_select_save[0]["column"] = [shiftpositon_col, shiftpositon_col];
- jfgird_select_save[0].column_focus = shiftpositon_col;
- luckysheet.setluckysheet_select_save(jfgird_select_save);
- store_default.luckysheet_shiftpositon = $.extend(true, {}, jfgird_select_save[0]);
- luckysheetMoveEndCell("right", "range", false, column_ed);
- jfgird_select_save = luckysheet.getluckysheet_select_save();
- var rangeArray = $.extend(true, [], jfgird_select_save);
- var rangeTxt = getRangetxt(store_default.currentSheetIndex, rangeArray[0], store_default.currentSheetIndex);
- let chartData = getdatabyselection();
- console.dir(chartData);
- let chart_id = generateRandomKey("chart");
- let chart_id_c = chart_id + "_c";
- let modelChartShowHTML = '';
- let $t = $(replaceHtml2(modelChartShowHTML, {
- id: chart_id_c,
- addclass: "luckysheet-data-visualization-chart",
- title: "\u56FE\u8868\u751F\u6210",
- content: ""
- })).appendTo($(".luckysheet-cell-main"));
- let container2 = document.getElementById(chart_id_c);
- let {render, chart_json} = store_default.createChart($(`#${chart_id_c}`).children(".luckysheet-modal-dialog-content")[0], chartData, chart_id, rangeArray, rangeTxt);
- width = width ? width : 400;
- height = height ? height : 250;
- left = left ? left : 0;
- top = top ? top : 0;
- container2.style.width = width + "px";
- container2.style.height = height + "px";
- container2.style.position = "absolute";
- container2.style.background = "#fff";
- container2.style.left = left + "px";
- container2.style.top = top + "px";
- render.style.width = "100%";
- render.style.height = "100%";
- container2.style.zIndex = store_default.zIndex ? store_default.zIndex : 15;
- store_default.zIndex++;
- let sheetFile = store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)];
- if (!sheetFile.chart) {
- sheetFile.chart = [];
- }
- sheetFile.chart.push({
- chart_id,
- width,
- height,
- left,
- top,
- chartOptions: chart_json.chartOptions,
- sheetIndex: sheetFile.index
- });
- showNeedRangeShow(chart_id);
- $(`#${chart_id}_c .luckysheet-modal-controll-del`).click(function(e) {
- delChart(chart_id);
- });
- setChartMoveableEffect($t);
- $(`#${chart_id}_c .luckysheet-modal-controll-update`).click(function(e) {
- showChartSettingComponent();
- });
- $t.children(".luckysheet-modal-dialog-content").mousedown(function(e) {
- if (!store_default.chartparam.luckysheetCurrentChartMaxState) {
- showNeedRangeShow(chart_id);
- }
- e.stopPropagation();
- });
- $t.mousedown(function(e) {
- if (!store_default.chartparam.luckysheetCurrentChartMaxState) {
- showNeedRangeShow(chart_id);
- setluckysheet_scroll_status(true);
- if (!$(e.target).is(".luckysheet-modal-dialog-controll") && !$(e.target).is(".luckysheet-modal-controll-btn") && !$(e.target).is("i")) {
- store_default.chartparam.luckysheetCurrentChartMoveTimeout = setTimeout(function() {
- store_default.chartparam.luckysheetCurrentChartMove = true;
- }, 100);
- }
- var toffset = store_default.chartparam.luckysheetCurrentChartMoveObj.offset();
- var tpsition = store_default.chartparam.luckysheetCurrentChartMoveObj.position();
- store_default.chartparam.luckysheetCurrentChartMoveXy = [
- e.pageX - toffset.left,
- e.pageY - toffset.top,
- tpsition.left,
- tpsition.top,
- $("#luckysheet-scrollbar-x").scrollLeft(),
- $("#luckysheet-scrollbar-y").scrollTop()
- ];
- store_default.chartparam.luckysheetCurrentChartMoveWinH = $("#luckysheet-cell-main")[0].scrollHeight;
- store_default.chartparam.luckysheetCurrentChartMoveWinW = $("#luckysheet-cell-main")[0].scrollWidth;
- if (!$(e.target).hasClass("luckysheet-mousedown-cancel") && $(e.target).filter("[class*='sp-palette']").length == 0 && $(e.target).filter("[class*='sp-thumb']").length == 0 && $(e.target).filter("[class*='sp-']").length == 0) {
- $("#luckysheet-rightclick-menu").hide();
- $("#luckysheet-cols-h-hover").hide();
- $("#luckysheet-cols-menu-btn").hide();
- $("#luckysheet-rightclick-menu").hide();
- $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu, #luckysheet-user-menu").hide();
- $("body > .luckysheet-filter-menu, body > .luckysheet-filter-submenu, body > .luckysheet-cols-menu").hide();
- }
- e.stopPropagation();
- }
- }).find(".luckysheet-modal-dialog-resize-item").mousedown(function(e) {
- if (store_default.chartparam.luckysheetCurrentChartActive) {
- store_default.chartparam.luckysheetCurrentChartResize = $(this).data("type");
- var mouse = mouseposition(e.pageX, e.pageY), scrollLeft = $("#luckysheet-scrollbar-x").scrollLeft(), scrollTop = $("#luckysheet-scrollbar-y").scrollTop();
- var x = mouse[0] + scrollLeft;
- var y = mouse[1] + scrollTop;
- var position = store_default.chartparam.luckysheetCurrentChartResizeObj.position();
- store_default.chartparam.luckysheetCurrentChartResizeXy = [
- x,
- y,
- $t.width(),
- $t.height(),
- position.left + scrollLeft,
- position.top + scrollTop,
- scrollLeft,
- scrollTop
- ];
- store_default.chartparam.luckysheetCurrentChartResizeWinH = $("#luckysheet-cell-main")[0].scrollHeight;
- store_default.chartparam.luckysheetCurrentChartResizeWinW = $("#luckysheet-cell-main")[0].scrollWidth;
- store_default.chartparam.luckysheetCurrentChart = chart_id;
- e.stopPropagation();
- }
- });
- $(`#${chart_id}_c`).mouseup(function(e) {
- const w = $(this).css("width");
- const h = $(this).css("height");
- const t = $(this).css("top");
- const l = $(this).css("left");
- let sheetFile2 = store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)];
- if (!sheetFile2.chart) {
- sheetFile2.chart = [];
- }
- sheetFile2.chart.forEach((item2) => {
- if (item2.chart_id === chart_id) {
- item2.width = parseFloat(w);
- item2.height = parseFloat(h);
- item2.left = parseFloat(l);
- item2.top = parseFloat(t);
- }
- });
- });
- }
- function setChartMoveableEffect($container) {
- $container.find(".luckysheet-modal-dialog-content").hover(function() {
- $container.removeClass("chart-moveable");
- }, function() {
- $container.addClass("chart-moveable");
- });
- $container.hover(function() {
- $container.addClass("chart-moveable");
- }, function() {
- $container.removeClass("chart-moveable");
- });
- }
- function delChart(chart_id) {
- $(`.luckysheet-cell-main #${chart_id}_c`).remove();
- hideAllNeedRangeShow();
- let sheetFile = store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)];
- let index2 = sheetFile.chart.findIndex((item2) => item2.chart_id == chart_id);
- sheetFile.chart.splice(index2, 1);
- store_default.deleteChart(chart_id);
- }
- function showNeedRangeShow(chart_id) {
- let chartLists = store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)].chart;
- for (let chartId in chartLists) {
- chartLists[chartId].needRangeShow = false;
- if (chartLists[chartId].chart_id == chart_id) {
- chartLists[chartId].needRangeShow = true;
- store_default.currentChart = store_default.getChartJson(chart_id);
- }
- }
- selectRangeBorderShow(chart_id);
- }
- function hideAllNeedRangeShow() {
- let chartLists = store_default.luckysheetfile[getSheetIndex(store_default.currentSheetIndex)].chart;
- for (let chartId in chartLists) {
- chartLists[chartId].needRangeShow = false;
- }
- selectRangeBorderHide();
- }
- function selectRangeBorderShow(chart_id) {
- let $t = $("#" + chart_id + "_c");
- store_default.chart_selection.create();
- store_default.chartparam.luckysheetCurrentChartActive = true;
- store_default.chartparam.luckysheetCurrentChartMoveObj = $t;
- store_default.chartparam.luckysheetCurrentChartResizeObj = $t;
- store_default.chartparam.luckysheetCurrentChart = chart_id;
- $("#luckysheet-cell-main").find(".luckysheet-modal-dialog-chart .luckysheet-modal-dialog-resize").hide();
- $("#luckysheet-cell-main").find(".luckysheet-modal-dialog-chart .luckysheet-modal-dialog-controll").hide();
- $t.css("z-index", store_default.chartparam.luckysheetCurrentChartZIndexRank++);
- $t.find(".luckysheet-modal-dialog-resize").show();
- $t.find(".luckysheet-modal-dialog-controll").show();
- if (($(".chartSetting").is(":visible") || store_default.chartparam.luckysheet_chart_redo_click) && chart_id != store_default.chartparam.luckysheetCurrentChart) {
- $("body .luckysheet-cols-menu").hide();
- }
- store_default.currentChart = store_default.highlightChart(chart_id);
- }
- function selectRangeBorderHide(settingShow) {
- $("#luckysheet-cell-main .luckysheet-modal-dialog-chart .luckysheet-modal-dialog-resize, #luckysheet-cell-main .luckysheet-modal-dialog-chart .luckysheet-modal-dialog-controll").hide();
- $("#luckysheet-cell-main").find(".luckysheet-datavisual-selection-set div").remove();
- store_default.chartparam.luckysheetCurrentChartActive = false;
- $("#luckysheet-chart-rangeShow").empty();
- if (!settingShow && $(".chartSetting").is(":visible") && !isEditMode()) {
- hideChartSettingComponent();
- }
- }
- function showChartSettingComponent(refresh2, chart_id) {
- if (!$(".chartSetting").is(":visible")) {
- $(".chartSetting").show();
- $("#luckysheet-cell-main").find(".luckysheet-datavisual-selection-set div").show();
- store_default.chartparam.luckysheetCurrentChartActive = true;
- setTimeout(function() {
- luckysheetsizeauto();
- }, 0);
- }
- }
- function hideChartSettingComponent(refresh2) {
- if ($(".chartSetting").is(":visible")) {
- $(".chartSetting").hide();
- $("#luckysheet-cell-main .luckysheet-modal-dialog-chart .luckysheet-modal-dialog-resize, #luckysheet-cell-main .luckysheet-modal-dialog-chart .luckysheet-modal-dialog-controll").hide();
- $("#luckysheet-cell-main").find(".luckysheet-datavisual-selection-set div").remove();
- store_default.chartparam.luckysheetCurrentChartActive = false;
- if (!isEditMode() && !refresh2) {
- setTimeout(function() {
- luckysheetsizeauto();
- }, 0);
- }
- }
- }
- function renderChartShow(index2) {
- selectRangeBorderHide("true");
- const luckysheetfile = store_default.luckysheetfile;
- luckysheetfile.forEach((file) => {
- if (file.index == index2) {
- const chartLists = file.chart || [];
- chartLists.forEach((chart2) => {
- chart2.isShow = true;
- $("#" + chart2.chart_id + "_c").show();
- store_default.resizeChart(chart2.chart_id);
- if (chart2.needRangeShow == true) {
- store_default.currentChart = store_default.getChartJson(chart2.chart_id);
- selectRangeBorderShow(chart2.chart_id);
- }
- });
- } else {
- const chartLists = file.chart || [];
- chartLists.forEach((chart2) => {
- chart2.isShow = false;
- $("#" + chart2.chart_id + "_c").hide();
- });
- }
- });
- }
- var _rowLocation, _colLocation, dependScripts, dependLinks;
- var init_plugin = __esm({
- "src/expendPlugins/chart/plugin.js"() {
- init_util();
- init_chartUtil();
- init_getdata();
- init_store();
- init_formula();
- init_func();
- init_get();
- init_location();
- init_set();
- init_sheetMove();
- init_validate();
- init_resize();
- init_store();
- _rowLocation = rowLocation;
- _colLocation = colLocation;
- dependScripts = [
- "https://unpkg.com/vue@2.6.11/dist/vue.min.js",
- "https://unpkg.com/vuex@3.4.0/dist/vuex.min.js",
- "https://unpkg.com/element-ui@2.13.2/lib/index.js",
- "https://unpkg.com/echarts@4.8.0/dist/echarts.min.js",
- "xlsx/expendPlugins/chart/chartmix.umd.min.js"
- ];
- dependLinks = [
- "https://unpkg.com/element-ui@2.13.2/lib/theme-chalk/index.css",
- "xlsx/expendPlugins/chart/chartmix.css"
- ];
- }
- });
-
- // src/controllers/zoom.js
- function zoomChange(ratio) {
- if (store_default.flowdata == null || store_default.flowdata.length == 0) {
- return;
- }
- clearTimeout(luckysheetZoomTimeout);
- luckysheetZoomTimeout = setTimeout(() => {
- if (store_default.clearjfundo) {
- store_default.jfredo.push({
- "type": "zoomChange",
- "zoomRatio": store_default.zoomRatio,
- "curZoomRatio": ratio,
- "sheetIndex": store_default.currentSheetIndex
- });
- }
- currentWheelZoom = null;
- store_default.zoomRatio = ratio;
- let currentSheet = sheetmanage_default.getSheetByIndex();
- postil_default.buildAllPs(currentSheet.data);
- imageCtrl_default.images = currentSheet.images;
- imageCtrl_default.allImagesShow();
- imageCtrl_default.init();
- if (currentSheet.config == null) {
- currentSheet.config = {};
- }
- if (currentSheet.config.sheetViewZoom == null) {
- currentSheet.config.sheetViewZoom = {};
- }
- let type = currentSheet.config.curentsheetView;
- if (type == null) {
- type = "viewNormal";
- }
- currentSheet.config.sheetViewZoom[type + "ZoomScale"] = ratio;
- server_default.saveParam("all", store_default.currentSheetIndex, store_default.zoomRatio, {"k": "zoomRatio"});
- server_default.saveParam("cg", store_default.currentSheetIndex, currentSheet.config["sheetViewZoom"], {"k": "sheetViewZoom"});
- zoomRefreshView();
- }, 100);
- }
- function zoomRefreshView() {
- jfrefreshgrid_rhcw(store_default.flowdata.length, store_default.flowdata[0].length);
- changeSheetContainerSize();
- }
- function zoomInitial() {
- const ZOOM_WHEEL_STEP = 0.02;
- const ZOOM_STEP = 0.1;
- const MAX_ZOOM_RATIO = 4;
- const MIN_ZOOM_RATIO = 0.1;
- $("#luckysheet-zoom-minus").click(function() {
- let currentRatio;
- if (store_default.zoomRatio == null) {
- currentRatio = store_default.zoomRatio = 1;
- } else {
- currentRatio = Math.ceil(store_default.zoomRatio * 10) / 10;
- }
- currentRatio = currentRatio - ZOOM_STEP;
- if (currentRatio == store_default.zoomRatio) {
- currentRatio = currentRatio - ZOOM_STEP;
- }
- if (currentRatio <= MIN_ZOOM_RATIO) {
- currentRatio = MIN_ZOOM_RATIO;
- }
- zoomChange(currentRatio);
- zoomNumberDomBind(currentRatio);
- });
- $("#luckysheet-zoom-plus").click(function() {
- let currentRatio;
- if (store_default.zoomRatio == null) {
- currentRatio = store_default.zoomRatio = 1;
- } else {
- currentRatio = Math.floor(store_default.zoomRatio * 10) / 10;
- }
- currentRatio = currentRatio + ZOOM_STEP;
- if (currentRatio == store_default.zoomRatio) {
- currentRatio = currentRatio + ZOOM_STEP;
- }
- if (currentRatio >= MAX_ZOOM_RATIO) {
- currentRatio = MAX_ZOOM_RATIO;
- }
- zoomChange(currentRatio);
- zoomNumberDomBind(currentRatio);
- });
- $("#luckysheet-zoom-slider").mousedown(function(e) {
- let xoffset = $(this).offset().left, pageX = e.pageX;
- let currentRatio = positionToRatio(pageX - xoffset);
- zoomChange(currentRatio);
- zoomNumberDomBind(currentRatio);
- });
- $("#luckysheet-zoom-cursor").mousedown(function(e) {
- let curentX = e.pageX, cursorLeft = parseFloat($("#luckysheet-zoom-cursor").css("left"));
- $("#luckysheet-zoom-cursor").css("transition", "none");
- $(document).off("mousemove.zoomCursor").on("mousemove.zoomCursor", function(event2) {
- let moveX = event2.pageX;
- let offsetX = moveX - curentX;
- let pos = cursorLeft + offsetX;
- let currentRatio = positionToRatio(pos);
- if (currentRatio > MAX_ZOOM_RATIO) {
- currentRatio = MAX_ZOOM_RATIO;
- pos = 100;
- }
- if (currentRatio < MIN_ZOOM_RATIO) {
- currentRatio = MIN_ZOOM_RATIO;
- pos = 0;
- }
- zoomChange(currentRatio);
- let r2 = Math.round(currentRatio * 100) + "%";
- $("#luckysheet-zoom-ratioText").html(r2);
- $("#luckysheet-zoom-cursor").css("left", pos - 4);
- });
- $(document).off("mouseup.zoomCursor").on("mouseup.zoomCursor", function(event2) {
- $(document).off(".zoomCursor");
- $("#luckysheet-zoom-cursor").css("transition", "all 0.3s");
- });
- e.stopPropagation();
- }).click(function(e) {
- e.stopPropagation();
- });
- $("#luckysheet-zoom-ratioText").click(function() {
- zoomChange(1);
- zoomNumberDomBind(1);
- });
- zoomNumberDomBind(store_default.zoomRatio);
- currentWheelZoom = null;
- document.addEventListener("wheel", function(ev) {
- if (!ev.ctrlKey || !ev.deltaY) {
- return;
- }
- if (currentWheelZoom === null) {
- currentWheelZoom = store_default.zoomRatio || 1;
- }
- currentWheelZoom += ev.deltaY < 0 ? ZOOM_WHEEL_STEP : -ZOOM_WHEEL_STEP;
- if (currentWheelZoom >= MAX_ZOOM_RATIO) {
- currentWheelZoom = MAX_ZOOM_RATIO;
- } else if (currentWheelZoom < MIN_ZOOM_RATIO) {
- currentWheelZoom = MIN_ZOOM_RATIO;
- }
- zoomChange(currentWheelZoom);
- zoomNumberDomBind(currentWheelZoom);
- ev.preventDefault();
- ev.stopPropagation();
- }, {capture: true, passive: false});
- document.addEventListener("keydown", function(ev) {
- if (!ev.ctrlKey) {
- return;
- }
- let handled = false;
- let zoom = store_default.zoomRatio || 1;
- if (ev.key === "-" || ev.which === 189) {
- zoom -= ZOOM_STEP;
- handled = true;
- } else if (ev.key === "+" || ev.which === 187) {
- zoom += ZOOM_STEP;
- handled = true;
- } else if (ev.key === "0" || ev.which === 48) {
- zoom = 1;
- handled = true;
- }
- if (handled) {
- ev.preventDefault();
- if (zoom >= MAX_ZOOM_RATIO) {
- zoom = MAX_ZOOM_RATIO;
- } else if (zoom < MIN_ZOOM_RATIO) {
- zoom = MIN_ZOOM_RATIO;
- }
- zoomChange(zoom);
- zoomNumberDomBind(zoom);
- }
- }, {capture: true});
- }
- function positionToRatio(pos) {
- let ratio = 1;
- if (pos < 50) {
- ratio = Math.round((pos * 1.8 / 100 + 0.1) * 100) / 100;
- } else if (pos > 50) {
- ratio = Math.round(((pos - 50) * 6 / 100 + 1) * 100) / 100;
- }
- return ratio;
- }
- function zoomSlierDomBind(ratio) {
- let domPos = 50;
- if (ratio < 1) {
- domPos = Math.round((ratio - 0.1) * 100 / 0.18) / 10;
- } else if (ratio > 1) {
- domPos = Math.round((ratio - 1) * 100 / 0.6) / 10 + 50;
- }
- $("#luckysheet-zoom-cursor").css("left", domPos - 4);
- }
- function zoomNumberDomBind(ratio) {
- let r2 = Math.round(ratio * 100) + "%";
- $("#luckysheet-zoom-ratioText").html(r2);
- zoomSlierDomBind(ratio);
- }
- var luckysheetZoomTimeout, currentWheelZoom;
- var init_zoom = __esm({
- "src/controllers/zoom.js"() {
- init_store();
- init_locale();
- init_util();
- init_sheetmanage();
- init_resize();
- init_refresh();
- init_server();
- init_postil();
- init_imageCtrl();
- luckysheetZoomTimeout = null;
- currentWheelZoom = null;
- }
- });
-
- // src/controllers/sheetmanage.js
- var sheetmanage, sheetmanage_default;
- var init_sheetmanage = __esm({
- "src/controllers/sheetmanage.js"() {
- init_validate();
- init_cleargridelement();
- init_getdata();
- init_setdata();
- init_createdom();
- init_tooltip();
- init_formula();
- init_refresh();
- init_rhchInit();
- init_editor();
- init_extend();
- init_validate();
- init_util();
- init_constant();
- init_server();
- init_luckysheetConfigsetting();
- init_pivotTable();
- init_resize();
- init_postil();
- init_imageCtrl();
- init_dataVerificationCtrl();
- init_hyperlinkCtrl();
- init_freezen();
- init_filter();
- init_select();
- init_store();
- init_locale();
- init_plugin();
- init_resize();
- init_zoom();
- init_menuButton();
- init_method();
- init_protection();
- init_formula();
- sheetmanage = {
- generateRandomSheetIndex: function(prefix) {
- if (prefix == null) {
- prefix = "Sheet";
- }
- let userAgent = window.navigator.userAgent.replace(/[^a-zA-Z0-9]/g, "").split("");
- let mid = "";
- for (let i2 = 0; i2 < 12; i2++) {
- mid += userAgent[Math.round(Math.random() * (userAgent.length - 1))];
- }
- let time = new Date().getTime();
- return prefix + "_" + mid + "_" + time;
- },
- generateRandomSheetName: function(file, isPivotTable) {
- let index2 = file.length;
- const locale_pivotTable = locale_default().pivotTable;
- const title = locale_pivotTable.title;
- for (let i2 = 0; i2 < file.length; i2++) {
- if (file[i2].name.indexOf("Sheet") > -1 || file[i2].name.indexOf(title) > -1) {
- let suffix = parseFloat(file[i2].name.replace("Sheet", "").replace(title, ""));
- if (suffix != "NaN" && Math.ceil(suffix) > index2) {
- index2 = Math.ceil(suffix);
- }
- }
- }
- if (isPivotTable) {
- return title + (index2 + 1);
- } else {
- return "Sheet" + (index2 + 1);
- }
- },
- generateCopySheetName: function(file, name2) {
- let _locale = locale_default();
- let locale_info = _locale.info;
- let copyWord = "(" + locale_info.copy;
- const copy_i = name2.toString().indexOf(copyWord);
- if (~copy_i) {
- name2 = name2.toString().substring(0, copy_i);
- }
- let index2 = "";
- let nameCopy = name2 + copyWord;
- const sheetNames = [];
- for (let i2 = 0; i2 < file.length; i2++) {
- let fileName = file[i2].name.toString();
- sheetNames.push(fileName);
- let st_i = fileName.indexOf(nameCopy);
- if (st_i === 0) {
- index2 = index2 || 2;
- let ed_i = fileName.indexOf(")", st_i + nameCopy.length);
- let num = fileName.substring(st_i + nameCopy.length, ed_i);
- if (isRealNum(num)) {
- if (parseInt(num) >= index2) {
- index2 = parseInt(num) + 1;
- }
- }
- }
- }
- let sheetCopyName;
- do {
- let postfix = copyWord + index2 + ")";
- const lengthLimit = 31 - postfix.length;
- sheetCopyName = name2;
- if (sheetCopyName.length > lengthLimit) {
- sheetCopyName = sheetCopyName.slice(0, lengthLimit - 1) + "\u2026";
- }
- sheetCopyName = sheetCopyName + postfix;
- } while (~sheetNames.indexOf(sheetCopyName) && (index2 = (index2 || 1) + 1));
- return sheetCopyName;
- },
- getSheetByIndex: function(index2) {
- let _this2 = this;
- if (index2 == null) {
- index2 = store_default.currentSheetIndex;
- }
- let i2 = _this2.getSheetIndex(index2);
- return store_default.luckysheetfile[i2];
- },
- getSheetByName: function(name2) {
- let _this2 = this;
- if (name2 == null) {
- return null;
- }
- for (let i2 = 0; i2 < store_default.luckysheetfile.length; i2++) {
- let file = store_default.luckysheetfile[i2];
- if (file.name == name2) {
- return file;
- }
- }
- return null;
- },
- getCurSheetnoset: function() {
- let curindex = 0;
- for (let i2 = 0; i2 < store_default.luckysheetfile.length; i2++) {
- if (store_default.luckysheetfile[i2].status == 1) {
- curindex = store_default.luckysheetfile[i2].index;
- break;
- }
- }
- return curindex;
- },
- getCurSheet: function() {
- if (store_default.luckysheetfile.length) {
- let hasActive = false, indexs = [];
- store_default.luckysheetfile.forEach((item2) => {
- if (typeof item2.index === "undefined") {
- item2.index = this.generateRandomSheetIndex();
- }
- if (indexs.includes(item2.index)) {
- item2.index = this.generateRandomSheetIndex();
- } else {
- indexs.push(item2.index);
- }
- if (typeof item2.status === "undefined") {
- item2.status = 0;
- }
- if (item2.status == 1) {
- if (hasActive) {
- item2.status = 0;
- } else {
- hasActive = true;
- }
- }
- });
- if (!hasActive) {
- store_default.luckysheetfile[0].status = 1;
- }
- }
- store_default.currentSheetIndex = store_default.luckysheetfile[0].index;
- for (let i2 = 0; i2 < store_default.luckysheetfile.length; i2++) {
- if (store_default.luckysheetfile[i2].status == 1) {
- store_default.currentSheetIndex = store_default.luckysheetfile[i2].index;
- break;
- }
- }
- return store_default.currentSheetIndex;
- },
- getCustomSheet() {
- if (!this.Luckysheet_custom_sheet)
- return {};
- return JSON.parse(JSON.stringify(this.Luckysheet_custom_sheet));
- },
- setCustomSheet(luckysheet_custom_sheet) {
- this.Luckysheet_custom_sheet = luckysheet_custom_sheet;
- },
- addNewSheet: function(e, isPivotTable) {
- if (isEditMode() || store_default.allowEdit === false) {
- return;
- }
- if (!method_default.createHookFunction("sheetCreateBefore")) {
- return;
- }
- let _this2 = this;
- let order = store_default.luckysheetfile.length;
- let index2 = _this2.generateRandomSheetIndex();
- let sheetname = _this2.generateRandomSheetName(store_default.luckysheetfile, isPivotTable);
- $("#luckysheet-sheet-container-c").append(replaceHtml(sheetHTML, {index: index2, active: "", name: sheetname, style: "", colorset: ""}));
- let sheetconfig = {};
- let sheet_defaullt_config = this.getCustomSheet();
- if (JSON.stringify(sheet_defaullt_config) != "{}" && sheet_defaullt_config != null && sheetconfig != void 0) {
- sheetconfig = sheet_defaullt_config;
- sheetconfig.index = index2;
- sheetconfig.order = order;
- sheetconfig.name = sheetname;
- } else {
- sheetconfig = {
- name: sheetname,
- color: "",
- status: "0",
- order,
- index: index2,
- celldata: [],
- row: store_default.defaultrowNum,
- column: store_default.defaultcolumnNum,
- config: {},
- pivotTable: null,
- isPivotTable: !!isPivotTable
- };
- }
- store_default.luckysheetfile.push(sheetconfig);
- $("#luckysheet-sheet-area div.luckysheet-sheets-item").removeClass("luckysheet-sheets-item-active");
- $("#luckysheet-sheets-item" + index2).addClass("luckysheet-sheets-item-active");
- $("#luckysheet-cell-main").append('
');
- cleargridelement(e);
- server_default.saveParam("sha", null, $.extend(true, {}, sheetconfig));
- if (store_default.clearjfundo) {
- store_default.jfundo.length = 0;
- let redo2 = {};
- redo2["type"] = "addSheet";
- redo2["sheetconfig"] = $.extend(true, {}, sheetconfig);
- redo2["index"] = index2;
- redo2["currentSheetIndex"] = store_default.currentSheetIndex;
- store_default.jfredo.push(redo2);
- }
- _this2.changeSheetExec(index2, isPivotTable, true);
- },
- setSheetHide: function(index2, isDelete) {
- let _this2 = this;
- let currentIdx = _this2.getSheetIndex(index2);
- if (!isDelete && !method_default.createHookFunction("sheetHideBefore", {sheet: store_default.luckysheetfile[currentIdx]})) {
- return;
- }
- store_default.luckysheetfile[currentIdx].hide = 1;
- let luckysheetcurrentSheetitem2 = $("#luckysheet-sheets-item" + index2);
- luckysheetcurrentSheetitem2.hide();
- $("#luckysheet-sheet-area div.luckysheet-sheets-item").removeClass("luckysheet-sheets-item-active");
- let indicator;
- if (luckysheetConfigsetting_default.showsheetbarConfig.sheet) {
- indicator = luckysheetcurrentSheetitem2.nextAll(":visible");
- if (luckysheetcurrentSheetitem2.nextAll(":visible").length > 0) {
- indicator = indicator.eq(0).data("index");
- } else {
- indicator = luckysheetcurrentSheetitem2.prevAll(":visible").eq(0).data("index");
- }
- } else {
- let nextActiveIdx, showSheetIdxs = [];
- store_default.luckysheetfile.forEach((ele, index3) => {
- if (ele.hide !== 1)
- showSheetIdxs.push(index3);
- });
- let len = showSheetIdxs.length;
- if (len === 1) {
- nextActiveIdx = showSheetIdxs[0];
- } else {
- nextActiveIdx = showSheetIdxs[len - 1] > currentIdx ? showSheetIdxs.find((e) => e > currentIdx) : showSheetIdxs[len - 1];
- }
- indicator = store_default.luckysheetfile[nextActiveIdx].index;
- }
- $("#luckysheet-sheets-item" + indicator).addClass("luckysheet-sheets-item-active");
- _this2.changeSheetExec(indicator);
- _this2.locationSheet();
- server_default.saveParam("sh", luckysheetcurrentSheetitem2.data("index"), 1, {op: "hide", cur: indicator});
- if (!isDelete) {
- method_default.createHookFunction("sheetHideAfter", {sheet: store_default.luckysheetfile[currentIdx]});
- }
- },
- setSheetShow: function(index2) {
- let _this2 = this;
- const file = store_default.luckysheetfile[_this2.getSheetIndex(index2)];
- if (!method_default.createHookFunction("sheetShowBefore", {sheet: file})) {
- return;
- }
- file.hide = 0;
- _this2.changeSheetExec(index2);
- server_default.saveParam("sh", index2, 0, {op: "show", cur: null});
- method_default.createHookFunction("sheetShowAfter", {sheet: file});
- },
- sheetMaxIndex: 0,
- ordersheet: function(property) {
- return function(a, b) {
- let value1 = a[property];
- let value2 = b[property];
- return value1 - value2;
- };
- },
- getCurrentOrder: function() {
- let orders = {};
- $("#luckysheet-sheet-area div.luckysheet-sheets-item").each(function(a) {
- let index2 = $(this).data("index");
- for (let i2 = 0; i2 < store_default.luckysheetfile.length; i2++) {
- if (store_default.luckysheetfile[i2].index == index2) {
- orders[index2.toString()] = a;
- break;
- }
- }
- });
- return orders;
- },
- reOrderAllSheet: function() {
- let orders = {};
- $("#luckysheet-sheet-area div.luckysheet-sheets-item").each(function(a) {
- let index2 = $(this).data("index");
- for (let i2 = 0; i2 < store_default.luckysheetfile.length; i2++) {
- if (store_default.luckysheetfile[i2].index == index2) {
- store_default.luckysheetfile[i2].order = a;
- orders[index2.toString()] = a;
- break;
- }
- }
- });
- server_default.saveParam("shr", null, orders);
- store_default.luckysheetfile.sort((x, y) => {
- let order_x = x.order;
- let order_y = y.order;
- if (order_x != null && order_y != null) {
- return order_x - order_y;
- } else if (order_x != null) {
- return -1;
- } else if (order_y != null) {
- return 1;
- } else {
- return 1;
- }
- });
- },
- createSheet: function() {
- let _this2 = this;
- let btn = [];
- store_default.luckysheetfile.sort(_this2.ordersheet("order"));
- for (let i2 = 0; i2 < store_default.luckysheetfile.length; i2++) {
- let display = "";
- let sheetIndex = store_default.luckysheetfile[i2].index;
- let colorset = "";
- if (store_default.luckysheetfile[i2].color != null) {
- colorset = '
';
- }
- if (store_default.currentSheetIndex == sheetIndex) {
- btn.push(replaceHtml(sheetHTML, {
- index: sheetIndex,
- active: "luckysheet-sheets-item-active",
- name: store_default.luckysheetfile[i2].name,
- style: "",
- colorset
- }));
- } else {
- if (store_default.luckysheetfile[i2].hide == 1) {
- btn.push(replaceHtml(sheetHTML, {
- index: sheetIndex,
- active: "",
- name: store_default.luckysheetfile[i2].name,
- style: "display:none;",
- colorset
- }));
- } else {
- btn.push(replaceHtml(sheetHTML, {
- index: sheetIndex,
- active: "",
- name: store_default.luckysheetfile[i2].name,
- style: "",
- colorset
- }));
- }
- display = "style='display:none;'";
- }
- $("#luckysheet-cell-main").append("
');
- }
- $("#luckysheet-sheet-container-c").append(btn.join(""));
- _this2.locationSheet();
- },
- locationSheet: function() {
- let $c = $("#luckysheet-sheet-container-c"), winW = $("#" + store_default.container).width();
- let $cursheet = $("#luckysheet-sheet-container-c > div.luckysheet-sheets-item-active").eq(0);
- let scrollLeftpx = 0;
- let c_width = 0;
- $("#luckysheet-sheet-container-c > div.luckysheet-sheets-item:visible").each(function() {
- if ($(this).hasClass("luckysheet-sheets-item-active")) {
- scrollLeftpx = c_width;
- }
- c_width += $(this).outerWidth();
- });
- setTimeout(function() {
- $c.scrollLeft(scrollLeftpx - 10);
- if (luckysheetConfigsetting_default.showsheetbarConfig.sheet) {
- if (c_width >= winW * 0.7) {
- $("#luckysheet-sheet-area .luckysheet-sheets-scroll").css("display", "inline-block");
- $("#luckysheet-sheet-container .docs-sheet-fade-left").show();
- } else {
- $("#luckysheet-sheet-area .luckysheet-sheets-scroll").css("display", "none");
- $("#luckysheet-sheet-container .docs-sheet-fade-left").hide();
- }
- }
- }, 1);
- },
- copySheet: function(copyindex, e) {
- if (isEditMode() || store_default.allowEdit === false) {
- return;
- }
- let _this2 = this;
- let order = store_default.luckysheetfile.length;
- let index2 = _this2.generateRandomSheetIndex();
- let copyarrindex = _this2.getSheetIndex(copyindex);
- let copyjson = $.extend(true, {}, store_default.luckysheetfile[copyarrindex]);
- copyjson.order = order;
- copyjson.index = index2;
- copyjson.name = _this2.generateCopySheetName(store_default.luckysheetfile, copyjson.name);
- if (!method_default.createHookFunction("sheetCopyBefore", {
- targetSheet: store_default.luckysheetfile[copyarrindex],
- copySheet: copyjson
- })) {
- return;
- }
- let colorset = "";
- if (copyjson.color != null) {
- colorset = '
';
- }
- let copyobject = $("#luckysheet-sheets-item" + copyindex);
- $("#luckysheet-sheet-container-c").append(replaceHtml(sheetHTML, {
- index: copyjson.index,
- active: "",
- name: copyjson.name,
- order: copyjson.order,
- style: "",
- colorset
- }));
- $("#luckysheet-sheets-item" + copyjson.index).insertAfter(copyobject);
- store_default.luckysheetfile.splice(copyarrindex + 1, 0, copyjson);
- $("#luckysheet-sheet-area div.luckysheet-sheets-item").removeClass("luckysheet-sheets-item-active");
- $("#luckysheet-sheets-item" + index2).addClass("luckysheet-sheets-item-active");
- $("#luckysheet-cell-main").append('
');
- cleargridelement(e);
- server_default.saveParam("shc", index2, {copyindex, name: copyjson.name});
- _this2.changeSheetExec(index2, void 0, void 0, true);
- _this2.reOrderAllSheet();
- if (store_default.clearjfundo) {
- store_default.jfredo.push({
- type: "copySheet",
- copyindex,
- index: copyjson.index,
- sheetIndex: copyjson.index
- });
- } else if (store_default.jfredo.length > 0) {
- let jfredostr = store_default.jfredo[store_default.jfredo.length - 1];
- if (jfredostr.type == "copySheet") {
- jfredostr.index = copyjson.index;
- jfredostr.sheetIndex = copyjson.index;
- }
- }
- },
- hasSheet: function(index2) {
- if (index2 == null) {
- return false;
- }
- index2 = this.getSheetIndex(index2);
- if (index2 == null) {
- return false;
- } else {
- return true;
- }
- },
- createSheetbydata: function(data, isrenew, isBefore = true) {
- let _this2 = this;
- let colorset = "";
- if (data.color != null) {
- colorset = '
';
- }
- $("#luckysheet-sheet-container-c").append(replaceHtml(sheetHTML, {
- index: data.index,
- active: "",
- name: data.name,
- order: data.order,
- style: "",
- colorset
- }));
- if (isBefore) {
- let previndex = data.order;
- if (previndex >= store_default.luckysheetfile.length) {
- previndex = store_default.luckysheetfile.length - 1;
- $("#luckysheet-sheets-item" + data.index).insertAfter($("#luckysheet-sheets-item" + store_default.luckysheetfile[previndex].index));
- } else {
- $("#luckysheet-sheets-item" + data.index).insertBefore($("#luckysheet-sheets-item" + store_default.luckysheetfile[previndex].index));
- }
- }
- store_default.luckysheetfile.push(data);
- $("#luckysheet-sheet-area div.luckysheet-sheets-item").removeClass("luckysheet-sheets-item-active");
- $("#luckysheet-sheets-item" + data.index).addClass("luckysheet-sheets-item-active");
- $("#luckysheet-cell-main").append('
');
- cleargridelement();
- if (isrenew != null) {
- server_default.saveParam("shre", null, {reIndex: data.index});
- data.hide = 0;
- server_default.saveParam("sh", data.index, 0, {op: "show", cur: null});
- } else {
- server_default.saveParam("sha", null, data);
- }
- _this2.changeSheetExec(data.index, data.isPivotTable, true);
- _this2.reOrderAllSheet();
- },
- deleteSheet: function(index2) {
- let _this2 = this;
- if (store_default.allowEdit === false) {
- return;
- }
- let arrIndex = _this2.getSheetIndex(index2);
- const file = store_default.luckysheetfile[arrIndex];
- if (!method_default.createHookFunction("sheetDeleteBefore", {sheet: file})) {
- return;
- }
- _this2.setSheetHide(index2, true);
- $("#luckysheet-sheets-item" + index2).remove();
- $("#luckysheet-datavisual-selection-set-" + index2).remove();
- let removedsheet = store_default.luckysheetfile.splice(arrIndex, 1);
- _this2.reOrderAllSheet();
- server_default.saveParam("shd", null, {deleIndex: index2});
- if (store_default.clearjfundo) {
- removedsheet[0].type = "deleteSheet";
- store_default.jfredo.push(removedsheet[0]);
- }
- method_default.createHookFunction("sheetDeleteAfter", {sheet: file});
- },
- nulldata: null,
- getGridData: function(d) {
- let ret = [];
- for (let r2 = 0; r2 < d.length; r2++) {
- for (let c2 = 0; c2 < d[0].length; c2++) {
- if (d[r2][c2] == null) {
- continue;
- }
- ret.push({r: r2, c: c2, v: d[r2][c2]});
- }
- }
- return ret;
- },
- buildGridData: function(file) {
- let row = file.row == null ? store_default.defaultrowNum : file.row, column = file.column == null ? store_default.defaultcolumnNum : file.column, data = file.data && file.data.length > 0 ? file.data : datagridgrowth([], row, column), celldata = file.celldata;
- if (file.data && file.data.length > 0) {
- for (let i2 = 0; i2 < data.length; i2++) {
- for (let j = 0; j < data[0].length; j++) {
- setcellvalue(i2, j, data, data[i2][j]);
- }
- }
- } else {
- if (celldata && celldata.length > 0) {
- for (let i2 = 0; i2 < celldata.length; i2++) {
- let item2 = celldata[i2];
- let r2 = item2.r;
- let c2 = item2.c;
- let v = item2.v;
- if (r2 >= data.length) {
- data = datagridgrowth(data, r2 - data.length + 1, 0);
- }
- if (c2 >= data[0].length) {
- data = datagridgrowth(data, 0, c2 - data[0].length + 1);
- }
- setcellvalue(r2, c2, data, v);
- }
- }
- }
- luckysheetConfigsetting_default.autoFormatw = false;
- luckysheetConfigsetting_default.accuracy = void 0;
- return data;
- },
- cutGridData: function(d) {
- let rowindex = 0;
- for (let r2 = d.length - 1; r2 >= 0; r2--) {
- let isnull = true;
- for (let c2 = 0; c2 < d[0].length; c2++) {
- let value = getcellvalue(r2, c2);
- if (value != null && $.trim(value).length > 0) {
- isnull = false;
- break;
- }
- }
- if (!isnull) {
- break;
- } else {
- rowindex = r2;
- }
- }
- return d.slice(0, rowindex);
- },
- addGridData: function(celldata, row, column) {
- let data = datagridgrowth([], row, column);
- if (celldata != null) {
- for (let i2 = 0; i2 < celldata.length; i2++) {
- let item2 = celldata[i2];
- let r2 = item2.r;
- let c2 = item2.c;
- let v = item2.v;
- if (r2 >= data.length) {
- data = datagridgrowth(data, r2 - data.length + 1, 0);
- }
- if (c2 >= data[0].length) {
- data = datagridgrowth(data, 0, c2 - data[0].length + 1);
- }
- setcellvalue(r2, c2, data, v);
- }
- }
- return data;
- },
- sheetParamRestore: function(file, data) {
- store_default.luckysheet_select_save = file["luckysheet_select_save"];
- if (store_default.luckysheet_select_save == null || store_default.luckysheet_select_save.length == 0) {
- if (data[0] != null && data[0][0] != null && data[0][0].mc != null) {
- store_default.luckysheet_select_save = [
- {
- row: [0, data[0][0].mc.rs - 1],
- column: [0, data[0][0].mc.cs - 1]
- }
- ];
- } else {
- store_default.luckysheet_select_save = [
- {
- row: [0, 0],
- column: [0, 0]
- }
- ];
- }
- }
- store_default.luckysheet_selection_range = file["luckysheet_selection_range"] == null ? [] : file["luckysheet_selection_range"];
- store_default.config = file["config"] == null ? {} : file["config"];
- store_default.zoomRatio = file["zoomRatio"] == null ? 1 : file["zoomRatio"];
- if (file["defaultRowHeight"] != null) {
- store_default.defaultrowlen = parseFloat(file["defaultRowHeight"]);
- } else {
- store_default.defaultrowlen = luckysheetConfigsetting_default["defaultRowHeight"];
- }
- if (file["defaultColWidth"] != null) {
- store_default.defaultcollen = parseFloat(file["defaultColWidth"]);
- } else {
- store_default.defaultcollen = luckysheetConfigsetting_default["defaultColWidth"];
- }
- if (file["showGridLines"] != null) {
- let showGridLines2 = file["showGridLines"];
- if (showGridLines2 == 0 || showGridLines2 == false) {
- store_default.showGridLines = false;
- } else {
- store_default.showGridLines = true;
- }
- } else {
- store_default.showGridLines = true;
- }
- },
- initialjfFile: function(menu, title) {
- let _this2 = this;
- _this2.getCurSheet();
- let file = store_default.luckysheetfile[_this2.getSheetIndex(store_default.currentSheetIndex)];
- _this2.nulldata = datagridgrowth([], store_default.defaultrowNum, store_default.defaultcolumnNum);
- let data = _this2.buildGridData(file);
- let select_save = [];
- file.jfgird_select_save = file.jfgird_select_save || [];
- file.jfgird_select_save.forEach((item2) => select_save.push({row: item2.row, column: item2.column}));
- file.luckysheet_select_save = select_save;
- this.sheetParamRestore(file, data);
- let r2 = store_default.luckysheet_select_save[0].row[1], c2 = store_default.luckysheet_select_save[0].column[1];
- if (store_default.luckysheet_select_save.length > 1) {
- for (let i2 = 0; i2 < store_default.luckysheet_select_save.length; i2++) {
- if (store_default.luckysheet_select_save[i2].row[1] > r2) {
- r2 = store_default.luckysheet_select_save[i2].row[1];
- }
- if (store_default.luckysheet_select_save[i2].column[1] > c2) {
- c2 = store_default.luckysheet_select_save[i2].column[1];
- }
- }
- }
- menuButton_default.fontInitial(store_default.fontList);
- file.data = data;
- let rowheight = data.length;
- if (r2 > rowheight - 1) {
- rowheight = r2 + 1;
- }
- let colwidth = data[0].length;
- if (c2 > colwidth - 1) {
- colwidth = c2 + 1;
- }
- if (typeof luckysheetConfigsetting_default.beforeCreateDom == "function") {
- luckysheetConfigsetting_default.beforeCreateDom(luckysheet);
- }
- if (typeof luckysheetConfigsetting_default.workbookCreateBefore == "function") {
- luckysheetConfigsetting_default.workbookCreateBefore(luckysheet);
- }
- luckysheetcreatedom(colwidth, rowheight, data, menu, title);
- setTimeout(function() {
- tooltip_default.createHoverTip("#luckysheet_info_detail", ".luckysheet_info_detail_back, .luckysheet_info_detail_input, .luckysheet_info_detail_update");
- tooltip_default.createHoverTip("#luckysheet-wa-editor", ".luckysheet-toolbar-menu-button, .luckysheet-toolbar-button, .luckysheet-toolbar-combo-button");
- store_default.luckysheetTableContentHW = [
- $("#luckysheet-cell-main").width() + store_default.rowHeaderWidth - store_default.cellMainSrollBarSize,
- $("#luckysheet-cell-main").height() + store_default.columnHeaderHeight - store_default.cellMainSrollBarSize
- ];
- $("#luckysheetTableContent, #luckysheetTableContentF").attr({
- width: Math.ceil(store_default.luckysheetTableContentHW[0] * store_default.devicePixelRatio),
- height: Math.ceil(store_default.luckysheetTableContentHW[1] * store_default.devicePixelRatio)
- }).css({
- width: store_default.luckysheetTableContentHW[0],
- height: store_default.luckysheetTableContentHW[1]
- }).get(0).getContext("2d");
- let locale_info = locale_default().info;
- let key = server_default.gridKey;
- let cahce_key = key + "__qkcache";
- let ini = function() {
- file["load"] = "1";
- _this2.createSheet();
- let execF = function() {
- _this2.mergeCalculation(file["index"]);
- _this2.setSheetParam(false);
- _this2.storeSheetParam();
- _this2.restoreselect();
- _this2.CacheNotLoadControll = [];
- _this2.restoreCache();
- formula_default.execFunctionGroupForce(luckysheetConfigsetting_default.forceCalculation);
- _this2.restoreSheetAll(store_default.currentSheetIndex);
- $("#luckysheet_info_detail_save").html(locale_info.detailSave);
- if (!!file.isPivotTable) {
- store_default.luckysheetcurrentisPivotTable = true;
- } else {
- store_default.luckysheetcurrentisPivotTable = false;
- $("#luckysheet-modal-dialog-slider-pivot").hide();
- }
- menuToolBarWidth();
- luckysheetsizeauto();
- if (file["scrollLeft"] != null && file["scrollLeft"] > 0) {
- $("#luckysheet-scrollbar-x").scrollLeft(file["scrollLeft"]);
- } else {
- $("#luckysheet-scrollbar-x").scrollLeft(0);
- }
- if (file["scrollTop"] != null && file["scrollTop"] > 0) {
- $("#luckysheet-scrollbar-y").scrollTop(file["scrollTop"]);
- } else {
- $("#luckysheet-scrollbar-y").scrollTop(0);
- }
- arrayRemoveItem(store_default.asyncLoad, "core");
- if (luckysheetConfigsetting_default.pointEdit) {
- setTimeout(function() {
- store_default.loadingObj.close();
- }, 0);
- } else {
- setTimeout(function() {
- store_default.loadingObj.close();
- }, 500);
- }
- };
- let loadSheetUrl = server_default.loadSheetUrl;
- if (loadSheetUrl == "") {
- _this2.loadOtherFile(file);
- execF();
- } else {
- let sheetindexset = _this2.checkLoadSheetIndex(file);
- let sheetindex = [];
- for (let i2 = 0; i2 < sheetindexset.length; i2++) {
- let item2 = sheetindexset[i2];
- if (item2 == file["index"]) {
- continue;
- }
- sheetindex.push(item2);
- }
- if (sheetindex.length === 0) {
- execF();
- return;
- }
- $.post(loadSheetUrl, {gridKey: server_default.gridKey, index: sheetindex.join(",")}, function(d) {
- let dataset = new Function("return " + d)();
- for (let item2 in dataset) {
- if (item2 == file["index"]) {
- continue;
- }
- let otherfile = store_default.luckysheetfile[_this2.getSheetIndex(item2)];
- if (otherfile["load"] == null || otherfile["load"] == "0") {
- otherfile.celldata = dataset[item2.toString()];
- otherfile["data"] = _this2.buildGridData(otherfile);
- otherfile["load"] = "1";
- }
- }
- execF();
- });
- }
- };
- try {
- localforage.getItem(cahce_key).then(function(readValue) {
- if (readValue != null) {
- _this2.CacheNotLoadControll = readValue;
- }
- server_default.clearcachelocaldata(function() {
- ini();
- });
- });
- } catch (e) {
- ini();
- console.log("\u7F13\u5B58\u64CD\u4F5C\u5931\u8D25");
- }
- }, 1);
- },
- storeSheetParam: function() {
- let index2 = this.getSheetIndex(store_default.currentSheetIndex);
- let file = store_default.luckysheetfile[index2];
- file["config"] = store_default.config;
- file["visibledatarow"] = store_default.visibledatarow;
- file["visibledatacolumn"] = store_default.visibledatacolumn;
- file["ch_width"] = store_default.ch_width;
- file["rh_height"] = store_default.rh_height;
- file["luckysheet_select_save"] = $.extend(true, [], store_default.luckysheet_select_save);
- file["luckysheet_selection_range"] = $.extend(true, [], store_default.luckysheet_selection_range);
- if ($("#luckysheet-scrollbar-x")[0].scrollWidth > $("#luckysheet-scrollbar-x")[0].offsetWidth) {
- file["scrollLeft"] = $("#luckysheet-scrollbar-x").scrollLeft();
- }
- if ($("#luckysheet-scrollbar-y")[0].scrollHeight > $("#luckysheet-scrollbar-y")[0].offsetHeight) {
- file["scrollTop"] = $("#luckysheet-scrollbar-y").scrollTop();
- }
- file["zoomRatio"] = store_default.zoomRatio;
- },
- setSheetParam: function(isload = true) {
- let index2 = this.getSheetIndex(store_default.currentSheetIndex);
- let file = store_default.luckysheetfile[index2];
- store_default.flowdata = file["data"];
- editor_default.webWorkerFlowDataCache(store_default.flowdata);
- formula_default.execFunctionGlobalData = null;
- window.luckysheet_getcelldata_cache = null;
- this.sheetParamRestore(file, store_default.flowdata);
- if (file["freezen"] == null) {
- freezen_default.freezenhorizontaldata = null;
- freezen_default.freezenverticaldata = null;
- } else {
- freezen_default.freezenhorizontaldata = file["freezen"].horizontal == null ? null : file["freezen"].horizontal.freezenhorizontaldata;
- freezen_default.freezenverticaldata = file["freezen"].vertical == null ? null : file["freezen"].vertical.freezenverticaldata;
- }
- if (isload) {
- rhchInit(store_default.flowdata.length, store_default.flowdata[0].length);
- }
- postil_default.buildAllPs(store_default.flowdata);
- imageCtrl_default.currentImgId = null;
- imageCtrl_default.images = file.images;
- imageCtrl_default.allImagesShow();
- imageCtrl_default.init();
- dataVerificationCtrl_default.dataVerification = file.dataVerification;
- dataVerificationCtrl_default.init();
- hyperlinkCtrl_default.hyperlink = file.hyperlink;
- hyperlinkCtrl_default.init();
- createFilterOptions(file["filter_select"], file["filter"]);
- },
- restoreselect: function() {
- let index2 = this.getSheetIndex(store_default.currentSheetIndex);
- let file = store_default.luckysheetfile[index2];
- selectHightlightShow(true);
- selectionCopyShow();
- if (file["scrollLeft"] != null && file["scrollLeft"] > 0) {
- $("#luckysheet-scrollbar-x").scrollLeft(file["scrollLeft"]);
- } else {
- $("#luckysheet-scrollbar-x").scrollLeft(0);
- }
- if (file["scrollTop"] != null && file["scrollTop"] > 0) {
- $("#luckysheet-scrollbar-y").scrollTop(file["scrollTop"]);
- } else {
- $("#luckysheet-scrollbar-y").scrollTop(0);
- }
- },
- storeSheetParamALL: function() {
- let _this2 = this;
- _this2.storeSheetParam();
- let index2 = _this2.getSheetIndex(store_default.currentSheetIndex);
- store_default.luckysheetfile[index2]["data"] = store_default.flowdata;
- store_default.luckysheetfile[index2]["config"] = $.extend(true, {}, store_default.config);
- },
- mergeCalculationSheet: {},
- mergeCalculation: function(index2) {
- let file = store_default.luckysheetfile[this.getSheetIndex(index2)];
- let config = file.config, data = file.data;
- if (config == null) {
- return;
- }
- let mergeConfig = config.merge;
- if (mergeConfig == null || index2 in this.mergeCalculationSheet || file["autoCalculationMerge"] === false) {
- return;
- }
- this.mergeCalculationSheet[index2] = 1;
- for (let x in mergeConfig) {
- let r2 = parseInt(x.substr(0, x.indexOf("_")));
- let c2 = parseInt(x.substr(x.indexOf("_") + 1));
- let mcInfo = mergeConfig[x];
- if (data[r2][c2] == null) {
- data[r2][c2] = {};
- }
- data[r2][c2]["mc"] = {
- r: r2,
- c: c2,
- rs: mcInfo.rs,
- cs: mcInfo.cs
- };
- for (let ir = r2; ir < r2 + mcInfo.rs; ir++) {
- for (let ic = c2; ic < c2 + mcInfo.cs; ic++) {
- if (ir == r2 && ic == c2) {
- continue;
- }
- if (data[ir][ic] == null) {
- data[ir][ic] = {};
- }
- data[ir][ic]["mc"] = {
- r: r2,
- c: c2
- };
- }
- }
- }
- },
- loadOtherFile: function(file) {
- let _this2 = this;
- for (let i2 = 0; i2 < store_default.luckysheetfile.length; i2++) {
- let otherfile = store_default.luckysheetfile[i2];
- if (otherfile.index == file.index) {
- continue;
- }
- if (otherfile["load"] == null || otherfile["load"] == "0") {
- otherfile["data"] = _this2.buildGridData(otherfile);
- otherfile["load"] = "1";
- }
- }
- },
- changeSheet: function(index2, isPivotInitial2, isNewSheet, isCopySheet) {
- if (isEditMode()) {
- return;
- }
- let _this2 = this;
- if (index2 == store_default.currentSheetIndex) {
- return;
- }
- if (server_default.allowUpdate) {
- $("#luckysheet-cell-main #luckysheet-multipleRange-show").empty();
- server_default.multipleIndex = 0;
- }
- let file = store_default.luckysheetfile[_this2.getSheetIndex(index2)];
- if (isNewSheet) {
- method_default.createHookFunction("sheetCreateAfter", {sheet: file});
- }
- if (isCopySheet) {
- method_default.createHookFunction("sheetCopyAfter", {sheet: file});
- }
- method_default.createHookFunction("sheetActivate", index2, isPivotInitial2, isNewSheet);
- $("#luckysheet-filter-selected-sheet" + store_default.currentSheetIndex + ", #luckysheet-filter-options-sheet" + store_default.currentSheetIndex).hide();
- $("#luckysheet-filter-selected-sheet" + index2 + ", #luckysheet-filter-options-sheet" + index2).show();
- window.luckysheetCurrentIndex = index2;
- _this2.storeSheetParamALL();
- _this2.setCurSheet(index2);
- if (!!file.isPivotTable) {
- store_default.luckysheetcurrentisPivotTable = true;
- if (!isPivotInitial2) {
- pivotTable_default.changePivotTable(index2);
- }
- } else {
- store_default.luckysheetcurrentisPivotTable = false;
- $("#luckysheet-modal-dialog-slider-pivot").hide();
- luckysheetsizeauto(false);
- this.refreshAllPivotTable(store_default.currentSheetIndex);
- }
- let load = file["load"];
- if (load != null) {
- let data = _this2.buildGridData(file);
- file.data = data;
- _this2.mergeCalculation(index2);
- _this2.setSheetParam(true);
- _this2.showSheet();
- setTimeout(function() {
- formula_default.execFunctionGroupForce(true);
- luckysheetrefreshgrid();
- server_default.saveParam("shs", null, store_default.currentSheetIndex);
- }, 1);
- } else {
- let loadSheetUrl = server_default.loadSheetUrl;
- if (loadSheetUrl == "" || store_default.luckysheetcurrentisPivotTable || !!isNewSheet) {
- let data = _this2.buildGridData(file);
- file["data"] = data;
- file["load"] = "1";
- _this2.mergeCalculation(index2);
- _this2.setSheetParam();
- _this2.showSheet();
- setTimeout(function() {
- _this2.restoreCache();
- formula_default.execFunctionGroupForce(luckysheetConfigsetting_default.forceCalculation);
- _this2.restoreSheetAll(store_default.currentSheetIndex);
- luckysheetrefreshgrid();
- }, 1);
- server_default.saveParam("shs", null, store_default.currentSheetIndex);
- } else {
- $("#luckysheet-grid-window-1").append(luckysheetlodingHTML());
- let sheetindex = _this2.checkLoadSheetIndex(file);
- $.post(loadSheetUrl, {gridKey: server_default.gridKey, index: sheetindex.join(",")}, function(d) {
- let dataset = new Function("return " + d)();
- file.celldata = dataset[index2.toString()];
- let data = _this2.buildGridData(file);
- setTimeout(function() {
- store_default.loadingObj.close();
- }, 500);
- for (let item2 in dataset) {
- if (item2 == index2) {
- continue;
- }
- let otherfile = store_default.luckysheetfile[_this2.getSheetIndex(item2)];
- if (otherfile["load"] == null || otherfile["load"] == "0") {
- otherfile.celldata = dataset[item2.toString()];
- otherfile["data"] = _this2.buildGridData(otherfile);
- otherfile["load"] = "1";
- }
- }
- file["data"] = data;
- file["load"] = "1";
- _this2.mergeCalculation(index2);
- _this2.setSheetParam();
- _this2.showSheet();
- setTimeout(function() {
- _this2.restoreCache();
- formula_default.execFunctionGroupForce(luckysheetConfigsetting_default.forceCalculation);
- _this2.restoreSheetAll(store_default.currentSheetIndex);
- luckysheetrefreshgrid();
- }, 1);
- server_default.saveParam("shs", null, store_default.currentSheetIndex);
- });
- }
- }
- $("#luckysheet-cell-main .luckysheet-datavisual-selection-set").hide();
- $("#luckysheet-datavisual-selection-set-" + index2).show();
- formula_default.hideButton();
- renderChartShow(index2);
- freezen_default.initialFreezen(index2);
- _this2.restoreselect();
- initialEvent(file);
- },
- refreshAllPivotTable: function(index2) {
- store_default.luckysheetfile.forEach((file) => {
- if (file.isPivotTable) {
- this.refreshPivotTableByFile(file);
- }
- });
- },
- refreshPivotTableByFile: function(file) {
- let pivotTableConfig = file.pivotTable;
- let column = pivotTableConfig.column;
- let row = pivotTableConfig.row;
- let values = pivotTableConfig.values;
- let showType = pivotTableConfig.showType;
- let filterparm = pivotTableConfig.filterparm;
- let pivotDataSheetIndex = pivotTableConfig.pivotDataSheetIndex;
- let pivotrealIndex = this.getSheetIndex(pivotDataSheetIndex);
- let otherfile = store_default.luckysheetfile[pivotrealIndex];
- if (otherfile["data"] == null) {
- otherfile["data"] = this.buildGridData(otherfile);
- }
- const origindata = getdatabyselectionD(otherfile.data, pivotTableConfig.pivot_select_save);
- let rowhidden = {};
- if (filterparm != null) {
- for (let f in filterparm) {
- for (let h in filterparm[f]) {
- if (h === "rowhidden" && _this.filterparm[f][h] != null) {
- rowhidden = $.extend(true, rowhidden, filterparm[f][h]);
- }
- }
- }
- }
- let newdata = [];
- for (let i2 = 0; i2 < origindata.length; i2++) {
- if (rowhidden != null && rowhidden[i2] != null) {
- continue;
- }
- newdata.push([].concat(origindata[i2]));
- }
- let ret = pivotTable_default.dataHandler(column, row, values, showType, newdata);
- pivotTableConfig.pivotDatas = ret;
- let d = $.extend(true, [], this.nulldata);
- let data = d;
- let addr = 0, addc = 0;
- let rlen = ret.length, clen = ret[0].length;
- addr = rlen - d.length;
- addc = clen - d[0].length;
- data = datagridgrowth(d, addr + 20, addc + 10, true);
- for (let r2 = 0; r2 < rlen; r2++) {
- for (let c2 = 0; c2 < clen; c2++) {
- let value = "";
- if (ret[r2] != null && ret[r2][c2] != null) {
- value = getcellvalue(r2, c2, ret);
- setcellvalue(r2, c2, data, value);
- }
- }
- }
- file.data = data;
- },
- checkLoadSheetIndexToDataIndex: {},
- checkLoadSheetIndex: function(file) {
- let calchain = formula_default.getAllFunctionGroup();
- let chart2 = file.chart;
- let pivotTable3 = file.pivotTable;
- let ret = [], cache = {};
- if (file.index in this.checkLoadSheetIndexToDataIndex) {
- return [];
- }
- ret.push(file.index);
- cache[file.index.toString()] = 1;
- this.checkLoadSheetIndexToDataIndex[file.index] = 1;
- if (calchain != null) {
- let dataIndexList = {};
- for (let i2 = 0; i2 < calchain.length; i2++) {
- let f = calchain[i2];
- let dataindex = f.index;
- let formulaTxt = getcellFormula(f.r, f.c, dataindex);
- if (formulaTxt == null) {
- let file2 = store_default.luckysheetfile[this.getSheetIndex(dataindex)];
- file2.data = this.buildGridData(file2);
- formulaTxt = getcellFormula(f.r, f.c, dataindex);
- if (formulaTxt == null) {
- continue;
- }
- }
- if (formulaTxt.indexOf("!") == -1) {
- formula_default.addToSheetIndexList(formulaTxt, dataindex);
- } else if (formula_default.formulaContainSheetList != null && formula_default.formulaContainSheetList[formulaTxt] != null) {
- for (let dataSheetIndex in formula_default.formulaContainSheetList[formulaTxt]) {
- dataIndexList[dataSheetIndex] = 1;
- }
- } else {
- formula_default.functionParser(formulaTxt, (str) => {
- formula_default.addToCellList(formulaTxt, str);
- if (str.indexOf("!") > -1) {
- let name2 = str.substr(0, str.indexOf("!"));
- let sheet = this.getSheetByName(name2);
- if (sheet != null) {
- let dataSheetIndex = sheet.index;
- dataIndexList[dataSheetIndex] = 1;
- formula_default.addToSheetIndexList(formulaTxt, dataSheetIndex);
- }
- }
- });
- if (formula_default.formulaContainSheetList[formulaTxt] == null) {
- formula_default.addToSheetIndexList(formulaTxt, dataindex);
- }
- }
- if (dataindex == null) {
- continue;
- }
- }
- for (let index2 in dataIndexList) {
- let dataindex = index2;
- if (cache[dataindex.toString()] == null) {
- ret.push(dataindex);
- cache[dataindex.toString()] = 1;
- this.checkLoadSheetIndexToDataIndex[dataindex] = 1;
- }
- }
- }
- if (chart2 != null) {
- for (let i2 = 0; i2 < chart2.length; i2++) {
- let cc = chart2[i2];
- let dataindex = cc.dataSheetIndex;
- if (dataindex == null) {
- continue;
- }
- if (cache[dataindex.toString()] == null) {
- ret.push(dataindex);
- cache[dataindex.toString()] = 1;
- }
- }
- }
- if (pivotTable3 != null) {
- let dataindex = pivotTable3.pivotDataSheetIndex;
- if (dataindex != null && cache[dataindex.toString()] == null) {
- ret.push(dataindex);
- cache[dataindex.toString()] = 1;
- }
- }
- return ret;
- },
- showSheet: function() {
- $("#luckysheet-cell-flow_0").css({width: store_default.ch_width, top: "-1px"});
- $("#luckysheet-sheettable_0").css({width: store_default.ch_width - 1, height: store_default.rh_height});
- $("#luckysheetrowHeader_0").css("height", store_default.rh_height);
- $("#luckysheet-cols-h-cells_0").css("width", store_default.ch_width);
- $("#luckysheet-scrollbar-x div").width(store_default.ch_width);
- $("#luckysheet-scrollbar-y div").height(store_default.rh_height + store_default.columnHeaderHeight - store_default.cellMainSrollBarSize - 3);
- let index2 = this.getSheetIndex(store_default.currentSheetIndex);
- let file = store_default.luckysheetfile[index2];
- store_default.scrollRefreshSwitch = false;
- if (file["scrollLeft"] != null && file["scrollLeft"] > 0) {
- $("#luckysheet-scrollbar-x").scrollLeft(file["scrollLeft"] * store_default.zoomRatio);
- } else {
- $("#luckysheet-scrollbar-x").scrollLeft(0);
- }
- if (file["scrollTop"] != null && file["scrollTop"] > 0) {
- $("#luckysheet-scrollbar-y").scrollTop(file["scrollTop"] * store_default.zoomRatio);
- } else {
- $("#luckysheet-scrollbar-y").scrollTop(0);
- }
- setTimeout(() => {
- store_default.scrollRefreshSwitch = true;
- }, 0);
- zoomNumberDomBind(store_default.zoomRatio);
- },
- setCurSheet: function(index2) {
- for (let i2 = 0; i2 < store_default.luckysheetfile.length; i2++) {
- if (store_default.luckysheetfile[i2]["index"] == index2) {
- store_default.luckysheetfile[i2].status = 1;
- } else {
- store_default.luckysheetfile[i2].status = 0;
- }
- }
- store_default.currentSheetIndex = index2;
- },
- getSheetIndex: function(index2) {
- for (let i2 = 0; i2 < store_default.luckysheetfile.length; i2++) {
- if (store_default.luckysheetfile[i2]["index"] == index2) {
- return i2;
- }
- }
- return null;
- },
- changeSheetExec: function(index2, isPivotInitial2, isNewSheet, isCopySheet) {
- let $sheet = $("#luckysheet-sheets-item" + index2);
- window.luckysheet_getcelldata_cache = null;
- $("#luckysheet-sheet-area div.luckysheet-sheets-item").removeClass("luckysheet-sheets-item-active");
- $sheet.addClass("luckysheet-sheets-item-active").show();
- cleargridelement();
- this.changeSheet(index2, isPivotInitial2, isNewSheet, isCopySheet);
- $("#luckysheet-sheet-list, #luckysheet-rightclick-sheet-menu").hide();
- if (formula_default.rangestart) {
- formula_default.createRangeHightlight();
- }
- this.sheetBarShowAndHide(index2);
- },
- sheetArrowShowAndHide() {
- const $wrap = $("#luckysheet-sheet-container-c");
- if (!$wrap.length)
- return;
- var sw = $wrap[0].scrollWidth;
- var w = Math.ceil($wrap.width());
- if (sw > w) {
- if (luckysheetConfigsetting_default.showsheetbarConfig.sheet) {
- $("#luckysheet-sheet-area .luckysheet-sheets-scroll").css("display", "inline-block");
- $("#luckysheet-sheet-container .docs-sheet-fade-left").show();
- }
- } else {
- $("#luckysheet-sheet-area .luckysheet-sheets-scroll").css("display", "none");
- $("#luckysheet-sheet-container .docs-sheet-fade-left").hide();
- }
- },
- sheetBarShowAndHide(index2) {
- let $c = $("#luckysheet-sheet-container-c");
- if (index2 != null) {
- let $sheet = $("#luckysheet-sheets-item" + index2);
- $c.scrollLeft($sheet.offset().left);
- }
- let c_width = $c.width(), c_srollwidth = $c[0].scrollWidth, scrollLeft = $c.scrollLeft();
- if (scrollLeft <= 0) {
- $("#luckysheet-sheet-container .docs-sheet-fade-left").hide();
- } else {
- $("#luckysheet-sheet-container .docs-sheet-fade-left").show();
- }
- if (c_width + scrollLeft >= c_srollwidth) {
- $("#luckysheet-sheet-container .docs-sheet-fade-right").hide();
- } else {
- $("#luckysheet-sheet-container .docs-sheet-fade-right").show();
- }
- },
- delChart: function(chart_id, sheetIndex) {
- let index2 = this.getSheetIndex(sheetIndex);
- let file = store_default.luckysheetfile[index2];
- if (file.chart == null) {
- file.chart = [];
- } else {
- for (let i2 = 0; i2 < file.chart.length; i2++) {
- if (file.chart[i2].chart_id == chart_id) {
- store_default.luckysheetfile[index2].chart.splice(i2, 1);
- break;
- }
- }
- }
- },
- saveChart: function(json2) {
- let index2 = this.getSheetIndex(json2.sheetIndex);
- let file = store_default.luckysheetfile[index2];
- if (file.chart == null) {
- file.chart = [];
- file.chart.push(json2);
- } else {
- for (let i2 = 0; i2 < file.chart.length; i2++) {
- if (file.chart[i2].chart_id == json2.chart_id) {
- let old = $.extend(true, {}, file.chart[i2]);
- file.chart[i2] = $.extend(true, {}, old, json2);
- return;
- }
- }
- file.chart.push(json2);
- }
- },
- getChart: function(sheetIndex, chart_id) {
- let index2 = this.getSheetIndex(sheetIndex);
- let file = store_default.luckysheetfile[index2];
- if (file.chart == null) {
- return null;
- } else {
- for (let i2 = 0; i2 < file.chart.length; i2++) {
- if (file.chart[i2].chart_id == chart_id) {
- return file.chart[i2];
- }
- }
- return null;
- }
- },
- getRangetxt: function(sheetIndex, range2, currentIndex) {
- let sheettxt = "";
- if (currentIndex == null) {
- currentIndex = store_default.currentSheetIndex;
- }
- if (sheetIndex != currentIndex) {
- sheettxt = store_default.luckysheetfile[this.getSheetIndex(sheetIndex)].name + "!";
- }
- let row0 = range2["row"][0], row1 = range2["row"][1];
- let column0 = range2["column"][0], column1 = range2["column"][1];
- if (row0 == null && row1 == null) {
- return sheettxt + chatatABC(column0) + ":" + chatatABC(column1);
- } else if (column0 == null && column1 == null) {
- return sheettxt + (row0 + 1) + ":" + (row1 + 1);
- } else {
- if (column0 == column1 && row0 == row1) {
- return sheettxt + chatatABC(column0) + (row0 + 1);
- } else {
- return sheettxt + chatatABC(column0) + (row0 + 1) + ":" + chatatABC(column1) + (row1 + 1);
- }
- }
- },
- getSheetName: function(sheetIndex) {
- if (sheetIndex == null) {
- sheetIndex = store_default.currentSheetIndex;
- }
- return store_default.luckysheetfile[this.getSheetIndex(sheetIndex)].name;
- },
- getSheetMerge: function() {
- if (store_default.config.merge == null) {
- return null;
- }
- return store_default.config.merge;
- },
- getSheetData: function(sheetIndex) {
- if (sheetIndex == null) {
- sheetIndex = store_default.currentSheetIndex;
- }
- return store_default.luckysheetfile[this.getSheetIndex(sheetIndex)].data;
- },
- getSheetConfig: function(sheetIndex) {
- let _this2 = this;
- if (sheetIndex == null) {
- sheetIndex = store_default.currentSheetIndex;
- }
- let config = store_default.luckysheetfile[_this2.getSheetIndex(sheetIndex)].config;
- if (config == null) {
- store_default.luckysheetfile[_this2.getSheetIndex(sheetIndex)].config = {};
- }
- return store_default.luckysheetfile[_this2.getSheetIndex(sheetIndex)].config;
- },
- restoreFilter: function(sheetIndex) {
- let index2 = this.getSheetIndex(sheetIndex);
- let file = store_default.luckysheetfile[index2];
- if (getObjType(file.filter_select) == "string") {
- file.filter_select = JSON.parse(file.filter_select);
- }
- if (file.filter_select == null || file.filter_select.row == null || file.filter_select.column == null) {
- return;
- }
- createFilterOptions(file.filter_select);
- if (getObjType(file.filter) != "object") {
- if (file.filter != null && getObjType(file.filter) == "string") {
- file.filter = JSON.parse(file.filter);
- }
- }
- let rowhidden = {};
- if (file.config != null && file.config.rowhidden != null) {
- rowhidden = file.config.rowhidden;
- }
- $("#luckysheet-filter-options-sheet" + sheetIndex + " .luckysheet-filter-options").each(function(i2) {
- if (file.filter == null) {
- return false;
- }
- let $top = $(this);
- let item2 = file.filter[i2];
- if (item2 == null) {
- return true;
- }
- if (getObjType(item2) != "object") {
- item2 = JSON.parse(item2);
- }
- labelFilterOptionState($top, item2.optionstate, item2.rowhidden, item2.caljs, false, item2.st_r, item2.ed_r, item2.cindex, item2.st_c, item2.ed_c);
- rowhidden = $.extend(true, rowhidden, item2.rowhidden);
- });
- if (file.config == null) {
- file.config = {};
- }
- file.config["rowhidden"] = rowhidden;
- store_default.config = file.config;
- jfrefreshgrid_rhcw(store_default.flowdata.length, store_default.flowdata[0].length, false);
- },
- restorePivot: function(sheetIndex) {
- let index2 = this.getSheetIndex(sheetIndex);
- let file = store_default.luckysheetfile[index2];
- if (!file.isPivotTable) {
- return;
- }
- pivotTable_default.getCellData(sheetIndex);
- pivotTable_default.initialPivotManage(true);
- pivotTable_default.refreshPivotTable(false);
- },
- restoreSheetAll: function(sheetIndex) {
- let _this2 = this;
- _this2.restorePivot(sheetIndex);
- _this2.restoreFilter(sheetIndex);
- _this2.restoreFreezen(sheetIndex);
- },
- restoreFreezen: function(sheetIndex) {
- freezen_default.initialFreezen(sheetIndex);
- },
- restoreCache: function() {
- let _this2 = this;
- let data = _this2.CacheNotLoadControll;
- _this2.CacheNotLoadControll = [];
- if (data.length == 0) {
- return;
- }
- for (let i2 = 0; i2 < data.length; i2++) {
- let item2 = data[i2];
- _this2.execCache(item2);
- }
- },
- CacheNotLoadControll: [],
- execCache: function(item2) {
- let _this2 = this;
- let type = item2.t;
- let index2 = item2.i;
- let value = item2.v;
- let file = store_default.luckysheetfile[_this2.getSheetIndex(index2)];
- if (type == "sha") {
- store_default.luckysheetfile.push(value);
- } else if (type == "shc") {
- let copyjson = $.extend(true, {}, store_default.luckysheetfile[_this2.getSheetIndex(value.copyindex)]);
- copyjson.index = index2;
- store_default.luckysheetfile.push(copyjson);
- } else if (type == "shd") {
- store_default.luckysheetfile.splice(value.deleIndex, 1);
- } else if (type == "shr") {
- for (let pos in value) {
- store_default.luckysheetfile[_this2.getSheetIndex(pos)].order = value[pos];
- }
- }
- if ((file == null || file.load != "1") && !(type in {sha: 0, shc: 0, shd: 0, shr: 0})) {
- _this2.CacheNotLoadControll.push(item2);
- return;
- }
- if (type == "v") {
- let r2 = item2.r, c2 = item2.c, v = item2.v;
- let data = _this2.getSheetData(index2);
- file.data[r2][c2] = v;
- } else if (type == "fc") {
- let op = item2.op, pos = item2.pos;
- if (getObjType(value) != "object") {
- value = new Function("return " + value)();
- }
- let r2 = value.r, c2 = value.c;
- if (op == "del") {
- formula_default.delFunctionGroup(r2, c2, index2);
- } else {
- formula_default.insertUpdateFunctionGroup(r2, c2, index2);
- }
- } else if (type == "cg") {
- let v = value, k = item2.k;
- let config1 = _this2.getSheetConfig(index2);
- if (!(k in config1)) {
- config1[k] = {};
- }
- for (let key in v) {
- config1[k][key] = v[key];
- }
- store_default.config = config1;
- } else if (type == "f") {
- let v = value, op = item2.op, pos = item2.pos;
- let filter = file.filter;
- if (filter == null) {
- filter = {};
- }
- if (op == "upOrAdd") {
- filter[pos] = v;
- } else if (op == "del") {
- delete filter[pos];
- }
- } else if (type == "fsc") {
- file.filter = null;
- file.filter_select = null;
- } else if (type == "fsr") {
- let v = value;
- file.filter = v.filter;
- file.filter_select = v.filter_select;
- } else if (type == "sh") {
- let op = item2.op, cur = item2.cur, v = value;
- if (op == "hide") {
- file.status = 0;
- store_default.luckysheetfile[_this2.getSheetIndex(cur)].status = 1;
- } else if (op == "show") {
- for (let i2 = 0; i2 < store_default.luckysheetfile.length; i2++) {
- store_default.luckysheetfile[i2].status = 0;
- }
- file.status = 1;
- }
- } else if (type == "all") {
- let k = item2.k, s = item2.s;
- if (s && getObjType(value) != "object") {
- file[k] = JSON.stringify(value);
- } else {
- file[k] = value;
- }
- } else if (type == "c") {
- let op = item2.op, cid = item2.cid;
- if (op == "add") {
- file.chart.push(value);
- } else if (op == "xy" || op == "wh" || op == "update") {
- for (let i2 = 0; i2 < file.chart.length; i2++) {
- if (file.chart[i2].chart_id == cid) {
- for (let item3 in file.chart[i2]) {
- for (let vitem in value) {
- if (item3 == vitem) {
- file.chart[i2][item3] = value[vitem];
- }
- }
- }
- return;
- }
- }
- } else if (op == "del") {
- for (let i2 = 0; i2 < file.chart.length; i2++) {
- if (file.chart[i2].chart_id == cid) {
- file.chart.splice(i2, 1);
- return;
- }
- }
- }
- } else if (type == "drc") {
- let rc = item2.rc, index3 = value.index, len = value.len;
- let celldata = file.celldata;
- if (rc == "r") {
- for (let i2 = 0; celldata.length == 0; i2++) {
- let cell = celldata[i2];
- if (cell.r >= index3 && cell.r < index3 + len) {
- delete celldata[i2];
- } else if (cell.r >= index3 + len) {
- cell.r -= len;
- }
- }
- file.row -= len;
- } else {
- for (let i2 = 0; celldata.length == 0; i2++) {
- let cell = celldata[i2];
- if (cell.c >= index3 && cell.c < index3 + len) {
- delete celldata[i2];
- } else if (cell.c >= index3 + len) {
- cell.c -= len;
- }
- }
- file.column -= len;
- }
- let ret = [];
- for (let i2 = 0; i2 < celldata.length; i2++) {
- if (celldata[i2] != null) {
- ret.push(celldata[i2]);
- }
- }
- file.celldata = ret;
- let mtype, mst, med;
- if (rc == "r") {
- mtype = "row";
- } else {
- mtype = "column";
- }
- mst = index3;
- med = index3 + len - 1;
- luckysheetdeletetable(mtype, mst, med, true);
- } else if (type == "arc") {
- let rc = item2.rc, index3 = value.index, len = value.len;
- let celldata = file.celldata;
- if (rc == "r") {
- for (let i2 = 0; i2 < celldata.length; i2++) {
- let cell = celldata[i2];
- if (cell.r > index3) {
- cell.r += len;
- }
- }
- file.row += len;
- } else {
- for (let i2 = 0; i2 < celldata.length; i2++) {
- let cell = celldata[i2];
- if (cell.c > index3) {
- cell.c += len;
- }
- }
- file.column += len;
- }
- let mtype;
- if (rc == "r") {
- mtype = "row";
- } else {
- mtype = "column";
- }
- luckysheetextendtable(mtype, index3, len, true);
- } else if (type == "na") {
- server_default.saveParam("na", null, value);
- } else if (type == "thumb") {
- setTimeout(function() {
- _this2.imageRequest();
- }, 2e3);
- }
- }
- };
- sheetmanage_default = sheetmanage;
- }
- });
-
- // src/global/formula.js
- var luckysheetformula, formula_default;
- var init_formula = __esm({
- "src/global/formula.js"() {
- init_util();
- init_get();
- init_set();
- init_constant();
- init_sheetmanage();
- init_menuButton();
- init_server();
- init_freezen();
- init_protection();
- init_dataVerificationCtrl();
- init_select();
- init_validate();
- init_datecontroll();
- init_getRowlen();
- init_getdata();
- init_setdata();
- init_format();
- init_editor();
- init_tooltip();
- init_location();
- init_cursorPos();
- init_refresh();
- init_inlineString();
- init_func();
- init_store();
- init_locale();
- init_json();
- init_method();
- luckysheetformula = {
- error: {
- v: "#VALUE!",
- n: "#NAME?",
- na: "#N/A",
- r: "#REF!",
- d: "#DIV/0!",
- nm: "#NUM!",
- nl: "#NULL!",
- sp: "#SPILL!"
- },
- errorInfo: function(err) {
- return err;
- },
- errorParamCheck: function(thisp, data, i2) {
- let type, require2;
- let _locale = locale_default();
- let locale_formulaMore = _locale.formulaMore;
- if (i2 < thisp.length) {
- type = thisp[i2].type;
- require2 = thisp[i2].require;
- } else {
- type = thisp[thisp.length - 1].type;
- require2 = thisp[thisp.length - 1].require;
- }
- if (require2 == "o" && (data == null || data == "")) {
- return [true, locale_formulaMore.tipSuccessText];
- }
- if (type.indexOf("all") > -1) {
- return [true, locale_formulaMore.tipSuccessText];
- } else {
- if (type.indexOf("range") > -1 && (getObjType(data) == "object" || getObjType(data) == "array")) {
- return [true, locale_formulaMore.tipSuccessText];
- }
- if (type.indexOf("number") > -1 && (isRealNum(data) || getObjType(data) == "boolean")) {
- return [true, locale_formulaMore.tipSuccessText];
- }
- if (type.indexOf("string") > -1 && getObjType(data) == "string") {
- return [true, locale_formulaMore.tipSuccessText];
- }
- if (type.indexOf("date") > -1 && isdatetime(data)) {
- return [true, locale_formulaMore.tipSuccessText];
- }
- return [false, locale_formulaMore.tipParamErrorText];
- }
- },
- getPureValueByData: function(data) {
- if (data.length == 0) {
- return [];
- }
- let output = [];
- if (getObjType(data) == "array") {
- if (getObjType(data[0]) == "array") {
- for (let r2 = 0; r2 < data.length; r2++) {
- let row = [];
- for (let c2 = 0; c2 < data[0].length; c2++) {
- let cell = data[r2][c2];
- if (getObjType(cell) == "object") {
- row.push(cell.v);
- } else {
- row.push(cell);
- }
- }
- output.push(row);
- }
- } else {
- for (let i2 = 0; i2 < data.length; i2++) {
- let cell = data[i2];
- if (getObjType(cell) == "object") {
- output.push(cell.v);
- } else {
- output.push(cell);
- }
- }
- }
- } else {
- let cell = data;
- if (getObjType(cell) == "object") {
- output.push(cell.v);
- } else {
- output.push(cell);
- }
- }
- return output;
- },
- readCellDataToOneArray: function(rangeValue) {
- let _this2 = this;
- if (rangeValue == null) {
- return [];
- }
- if (getObjType(rangeValue) != "object") {
- return [rangeValue];
- }
- let dataformat = [];
- let data = [];
- if (rangeValue != null && rangeValue.data != null) {
- data = rangeValue.data;
- } else if (rangeValue != null && !isRealNull(rangeValue.v)) {
- return [rangeValue.v];
- } else {
- return [];
- }
- if (getObjType(data) == "array") {
- data = _this2.getPureValueByData(data);
- } else if (getObjType(data) == "object") {
- data = data.v;
- return [data];
- } else {
- if (/\{.*?\}/.test(data)) {
- data = data.replace(/\{/g, "[").replace(/\}/g, "]");
- }
- data = new Function("return " + data)();
- }
- if (getObjType(data[0]) == "array") {
- for (let i2 = 0; i2 < data.length; i2++) {
- dataformat = dataformat.concat(data[i2]);
- }
- } else {
- dataformat = data;
- }
- return dataformat;
- },
- getValueByFuncData: function(value, arg) {
- if (value == null) {
- return null;
- }
- let _this2 = this;
- if (getObjType(value) == "array") {
- if (arg == "avg") {
- return luckysheet_function.AVERAGE.f.apply(luckysheet_function.AVERAGE, value);
- } else if (arg == "sum") {
- return luckysheet_function.SUM.f.apply(luckysheet_function.SUM, value);
- } else {
- if (getObjType(value[0]) == "object") {
- return luckysheet.mask.getValueByFormat(value[0]);
- } else {
- return value[0];
- }
- }
- } else if (getObjType(value) == "object") {
- return luckysheet.mask.getValueByFormat(value);
- } else {
- return value;
- }
- },
- sparklinesColorMap: function(args, len) {
- let _this2 = this;
- let colorLists = null;
- if (len == null) {
- len = 5;
- }
- let index2 = 0;
- if (args.length > len) {
- for (let i2 = len; i2 < args.length; i2++) {
- let colorMap = args[i2];
- let colorListArray = _this2.readCellDataToOneArray(colorMap);
- for (let a = 0; a < colorListArray.length; a++) {
- let ca = colorListArray[a];
- if (ca.indexOf(":") > -1) {
- if (!colorLists) {
- colorLists = {};
- }
- let calist = ca.split(":");
- if (calist.length == 2) {
- colorLists[calist[0]] = calist[1];
- } else if (calist.length > 1) {
- colorLists[calist[0] + ":" + calist[1]] = calist[2];
- }
- } else {
- if (!colorLists) {
- colorLists = [];
- }
- colorLists.push(ca);
- }
- }
- index2++;
- }
- }
- return colorLists;
- },
- colorList: [
- "#2ec7c9",
- "#fc5c5c",
- "#5ab1ef",
- "#ffb980",
- "#d87a80",
- "#8d98b3",
- "#e5cf0d",
- "#97b552",
- "#95706d",
- "#dc69aa",
- "#07a2a4",
- "#9a7fd1",
- "#588dd5",
- "#f5994e",
- "#c05050",
- "#59678c",
- "#c9ab00",
- "#7eb00a",
- "#6f5553",
- "#c14089"
- ],
- classlist: {
- province: {
- 11: "\u5317\u4EAC",
- 12: "\u5929\u6D25",
- 13: "\u6CB3\u5317",
- 14: "\u5C71\u897F",
- 15: "\u5185\u8499\u53E4",
- 21: "\u8FBD\u5B81",
- 22: "\u5409\u6797",
- 23: "\u9ED1\u9F99\u6C5F",
- 31: "\u4E0A\u6D77",
- 32: "\u6C5F\u82CF",
- 33: "\u6D59\u6C5F",
- 34: "\u5B89\u5FBD",
- 35: "\u798F\u5EFA",
- 36: "\u6C5F\u897F",
- 37: "\u5C71\u4E1C",
- 41: "\u6CB3\u5357",
- 42: "\u6E56\u5317",
- 43: "\u6E56\u5357",
- 44: "\u5E7F\u4E1C",
- 45: "\u5E7F\u897F",
- 46: "\u6D77\u5357",
- 50: "\u91CD\u5E86",
- 51: "\u56DB\u5DDD",
- 52: "\u8D35\u5DDE",
- 53: "\u4E91\u5357",
- 54: "\u897F\u85CF",
- 61: "\u9655\u897F",
- 62: "\u7518\u8083",
- 63: "\u9752\u6D77",
- 64: "\u5B81\u590F",
- 65: "\u65B0\u7586",
- 71: "\u53F0\u6E7E",
- 81: "\u9999\u6E2F",
- 82: "\u6FB3\u95E8",
- 91: "\u56FD\u5916"
- }
- },
- oldvalue: null,
- dontupdate: function() {
- let _this2 = this;
- store_default.luckysheetCellUpdate.length = 0;
- $("#luckysheet-functionbox-cell, #luckysheet-rich-text-editor").html(_this2.oldvalue);
- _this2.cancelNormalSelected();
- if (_this2.rangetosheet != store_default.currentSheetIndex) {
- sheetmanage_default.changeSheetExec(_this2.rangetosheet);
- }
- },
- xssDeal: function(str) {
- if (typeof str !== "string")
- return str;
- return str.replace(/