├── .gitignore ├── _babelrc ├── demo_gifs ├── calc_engine_demo1.gif └── calc_engine_demo2.gif ├── lib └── ethercalc │ ├── npm_export.js │ ├── formatnumber2.js │ └── socialcalcconstants.js ├── package.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .idea/ 3 | npm-debug.log -------------------------------------------------------------------------------- /_babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015", "stage-0"] 3 | } -------------------------------------------------------------------------------- /demo_gifs/calc_engine_demo1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/selvan/calc-engine/HEAD/demo_gifs/calc_engine_demo1.gif -------------------------------------------------------------------------------- /demo_gifs/calc_engine_demo2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/selvan/calc-engine/HEAD/demo_gifs/calc_engine_demo2.gif -------------------------------------------------------------------------------- /lib/ethercalc/npm_export.js: -------------------------------------------------------------------------------- 1 | if (typeof global != 'undefined') var window = global; 2 | if (typeof SocialCalc != 'undefined' && typeof module != 'undefined') module.exports = SocialCalc; 3 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "calc-engine", 3 | "version": "0.0.2", 4 | "description": "Virtual calc engine", 5 | "repository": "https://www.github.com/selvan/calc-engine.git", 6 | "main": "dist/npm_bundle.js", 7 | "dependencies": { 8 | "babelify": "*" 9 | }, 10 | "devDependencies": { 11 | "babel-jest": "*", 12 | "browserify": "*", 13 | "envify": "*", 14 | "jest-cli": "*", 15 | "uglify-js": "*", 16 | "watchify": "*" 17 | }, 18 | "scripts": { 19 | "gen-npm-pkg": "cat lib/ethercalc/socialcalcconstants.js lib/ethercalc/socialcalc-3.js lib/ethercalc/formula1.js lib/ethercalc/formatnumber2.js lib/ethercalc/npm_export.js > dist/npm_bundle.js", 20 | "test": "BABEL_JEST_STAGE=0 jest" 21 | }, 22 | "author": "Selvan", 23 | "jest": { 24 | "rootDir": "./lib", 25 | "scriptPreprocessor": "./../node_modules/babel-jest" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## About 2 | Virtual calc/excel engine that runs in mobile (React native), web browser(Javascript) and server (Nodejs) 3 | 4 | For virtual wordprocessor engine see : https://www.github.com/selvan/wordprocessor-engine 5 | 6 | ## Demo 1 - Mobile 7 | React native UI created on top of virtual calc/excel engine 8 | 9 | ![](https://github.com/selvan/calc-engine/blob/master/demo_gifs/calc_engine_demo1.gif) 10 | 11 | ## Demo 2 - Mobile 12 | React native UI created on top of virtual calc/excel engine 13 | 14 | ![](https://github.com/selvan/calc-engine/blob/master/demo_gifs/calc_engine_demo1.gif) 15 | 16 | ## Building 17 | 18 | npm run gen-npm-pkg 19 | 20 | ## Using 21 | ### Recompute calculation 22 | let CalcEngine=require("./dist/npm_bundle.js"); 23 | let sh = new CalcEngine.Sheet(); 24 | CalcEngine.ScheduleSheetCommands(sh, "set A1 formula SUM(B1:B10)"); 25 | CalcEngine.ScheduleSheetCommands(sh, "set B1 value n 5"); 26 | CalcEngine.ScheduleSheetCommands(sh, "set B2 value n 25"); 27 | CalcEngine.ScheduleSheetCommands(sh, "set B3 formula B2*2"); 28 | CalcEngine.ScheduleSheetCommands(sh, "set B4 formula B3*5"); 29 | CalcEngine.ScheduleSheetCommands(sh, "set B5 formula B4*3"); 30 | sh.RecalcSheet(); 31 | sh.cells['A1'].datavalue; 32 | 33 | ### Merge & Unmerge 34 | CalcEngine.ScheduleSheetCommands(sh, "merge B1:C1"); 35 | CalcEngine.ScheduleSheetCommands(sh, "unmerge B1"); 36 | 37 | ### Border top and bottom 38 | CalcEngine.ScheduleSheetCommands(sh, 'set D2 bt 1px solid rgb(0,0,0)\nset D2 bb 1px solid rgb(0,0,0)'); 39 | 40 | ### Serialize 41 | var sh = new CalcEngine.Sheet(); 42 | let snapshot_sheet = sh.CreateSheetSave() 43 | 44 | ### Deserialize 45 | var sh = new CalcEngine.Sheet(); 46 | sh.ParseSheetSave(snapshot_sheet) 47 | 48 | ### Cell Style 49 | 50 | #### Style commands 51 | 52 | These style commands shall be observed by inserting console.log at CalcEngine.ExecuteSheetCommand method 53 | 54 | - Cell border 55 | 56 | set A1 bt 1px solid rgb(0,0,0) 57 | set A1 br 1px solid rgb(0,0,0) 58 | set A1 bb 1px solid rgb(0,0,0) 59 | set A1 bl 1px solid rgb(0,0,0) 60 | 61 | - Font family, style & size 62 | 63 | set A1 font italic bold 9pt arial,helvetica,sans-serif 64 | 65 | - Foreground & background color 66 | 67 | set A1 color rgb(0,221,0) 68 | set A1 bgcolor rgb(0,0,170) 69 | 70 | - Padding 71 | 72 | set A1 layout padding:4px 4px 4px 4px;vertical-align:*; 73 | 74 | - Format number (this is sample, there are many formats) 75 | 76 | set A1 nontextvalueformat #,##0 77 | 78 | - Format text (this is sample, there are many formats) 79 | 80 | set A1 textvalueformat text-plain 81 | 82 | - Align center 83 | 84 | set A1 cellformat center 85 | 86 | - Align vertical 87 | 88 | set A1 layout padding:4px 4px 4px 4px;vertical-align:middle; 89 | 90 | Credits: 91 | 92 | This virtual calc engine is based on https://ethercalc.org/ 93 | -------------------------------------------------------------------------------- /lib/ethercalc/formatnumber2.js: -------------------------------------------------------------------------------- 1 | // 2 | /* 3 | // SocialCalc Number Formatting Library 4 | // 5 | // Part of the SocialCalc package. 6 | // 7 | // (c) Copyright 2008 Socialtext, Inc. 8 | // All Rights Reserved. 9 | // 10 | // The contents of this file are subject to the Artistic License 2.0; you may not 11 | // use this file except in compliance with the License. You may obtain a copy of 12 | // the License at http://socialcalc.org/licenses/al-20/. 13 | // 14 | // Some of the other files in the SocialCalc package are licensed under 15 | // different licenses. Please note the licenses of the modules you use. 16 | // 17 | // Code History: 18 | // 19 | // Initially coded by Dan Bricklin of Software Garden, Inc., for Socialtext, Inc. 20 | // Based in part on the SocialCalc 1.1.0 code written in Perl. 21 | // The SocialCalc 1.1.0 code was: 22 | // Portions (c) Copyright 2005, 2006, 2007 Software Garden, Inc. 23 | // All Rights Reserved. 24 | // Portions (c) Copyright 2007 Socialtext, Inc. 25 | // All Rights Reserved. 26 | // The Perl SocialCalc started as modifications to the wikiCalc(R) program, version 1.0. 27 | // wikiCalc 1.0 was written by Software Garden, Inc. 28 | // Unless otherwise specified, referring to "SocialCalc" in comments refers to this 29 | // JavaScript version of the code, not the SocialCalc Perl code. 30 | // 31 | */ 32 | 33 | var SocialCalc; 34 | if (!SocialCalc) SocialCalc = {}; // May be used with other SocialCalc libraries or standalone 35 | 36 | SocialCalc.FormatNumber = {}; 37 | 38 | SocialCalc.FormatNumber.format_definitions = {}; // Parsed formats are stored here globally 39 | 40 | // Most constants that are often customized for localization are in the SocialCalc.Constants module. 41 | // If you use this module standalone, provide at least the "FormatNumber" values. 42 | // 43 | 44 | // The following values may be customized externally for further localization of the format definitions themselves, 45 | // but that would make them incompatible with other uses and is discouraged. 46 | // 47 | 48 | SocialCalc.FormatNumber.separatorchar = ","; 49 | SocialCalc.FormatNumber.decimalchar = "."; 50 | SocialCalc.FormatNumber.daynames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; 51 | SocialCalc.FormatNumber.daynames3 = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; 52 | SocialCalc.FormatNumber.monthnames3 = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; 53 | SocialCalc.FormatNumber.monthnames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", 54 | "October", "November", "December"]; 55 | 56 | SocialCalc.FormatNumber.allowedcolors = 57 | {BLACK: "#000000", BLUE: "#0000FF", CYAN: "#00FFFF", GREEN: "#00FF00", MAGENTA: "#FF00FF", 58 | RED: "#FF0000", WHITE: "#FFFFFF", YELLOW: "#FFFF00"}; 59 | 60 | SocialCalc.FormatNumber.alloweddates = 61 | {H: "h]", M: "m]", MM: "mm]", S: "s]", SS: "ss]"}; 62 | 63 | // Other constants 64 | 65 | SocialCalc.FormatNumber.commands = 66 | {copy: 1, color: 2, integer_placeholder: 3, fraction_placeholder: 4, decimal: 5, 67 | currency: 6, general:7, separator: 8, date: 9, comparison: 10, section: 11, style: 12}; 68 | 69 | SocialCalc.FormatNumber.datevalues = {julian_offset: 2415019, seconds_in_a_day: 24 * 60 * 60, seconds_in_an_hour: 60 * 60}; 70 | 71 | /* ******************* 72 | 73 | result = SocialCalc.FormatNumber.formatNumberWithFormat = function(rawvalue, format_string, currency_char) 74 | 75 | ************************* */ 76 | 77 | SocialCalc.FormatNumber.formatNumberWithFormat = function(rawvalue, format_string, currency_char) { 78 | 79 | var scc = SocialCalc.Constants; 80 | var scfn = SocialCalc.FormatNumber; 81 | 82 | var op, operandstr, fromend, cval, operandstrlc; 83 | var startval, estartval; 84 | var hrs, mins, secs, ehrs, emins, esecs, ampmstr, ymd; 85 | var minOK, mpos; 86 | var result=""; 87 | var thisformat; 88 | var section, gotcomparison, compop, compval, cpos, oppos; 89 | var sectioninfo; 90 | var i, decimalscale, scaledvalue, strvalue, strparts, integervalue, fractionvalue; 91 | var integerdigits2, integerpos, fractionpos, textcolor, textstyle, separatorchar, decimalchar; 92 | var value; // working copy to change sign, etc. 93 | 94 | if (typeof(rawvalue) == "string" && !rawvalue.length) return ""; 95 | 96 | value = rawvalue-0; // make sure a number 97 | if (!isFinite(value)) { 98 | if (typeof(rawvalue) == "string") { // if original was a string, try to format it 99 | return scfn.formatTextWithFormat(rawvalue, format_string); 100 | } 101 | else { 102 | return "NaN"; 103 | } 104 | } 105 | rawvalue = value; 106 | 107 | var negativevalue = value < 0 ? 1 : 0; // determine sign, etc. 108 | if (negativevalue) value = -value; 109 | var zerovalue = value == 0 ? 1 : 0; 110 | 111 | currency_char = currency_char || scc.FormatNumber_DefaultCurrency; 112 | 113 | scfn.parse_format_string(scfn.format_definitions, format_string); // make sure format is parsed 114 | thisformat = scfn.format_definitions[format_string]; // Get format structure 115 | 116 | if (!thisformat) throw "Format not parsed error!"; 117 | 118 | section = thisformat.sectioninfo.length - 1; // get number of sections - 1 119 | 120 | if (thisformat.hascomparison) { // has comparisons - determine which section 121 | section = 0; // set to which section we will use 122 | gotcomparison = 0; // this section has no comparison 123 | for (cpos=0; ;cpos++) { // scan for comparisons 124 | op = thisformat.operators[cpos]; 125 | operandstr = thisformat.operands[cpos]; // get next operator and operand 126 | if (!op) { // at end with no match 127 | if (gotcomparison) { // if comparison but no match 128 | format_string = "General"; // use default of General 129 | scfn.parse_format_string(scfn.format_definitions, format_string); 130 | thisformat = scfn.format_definitions[format_string]; 131 | section = 0; 132 | } 133 | break; // if no comparision, matches on this section 134 | } 135 | if (op == scfn.commands.section) { // end of section 136 | if (!gotcomparison) { // no comparison, so it's a match 137 | break; 138 | } 139 | gotcomparison = 0; 140 | section++; // check out next one 141 | continue; 142 | } 143 | if (op == scfn.commands.comparison) { // found a comparison - do we meet it? 144 | i=operandstr.indexOf(":"); 145 | compop=operandstr.substring(0,i); 146 | compval=operandstr.substring(i+1)-0; 147 | if ((compop == "<" && rawvalue < compval) || 148 | (compop == "<=" && rawvalue <= compval) || 149 | (compop == "=" && rawvalue == compval) || 150 | (compop == "<>" && rawvalue != compval) || 151 | (compop == ">=" && rawvalue >= compval) || 152 | (compop == ">" && rawvalue > compval)) { // a match 153 | break; 154 | } 155 | gotcomparison = 1; 156 | } 157 | } 158 | } 159 | else if (section > 0) { // more than one section (separated by ";") 160 | if (section == 1) { // two sections 161 | if (negativevalue) { 162 | negativevalue = 0; // sign will provided by section, not automatically 163 | section = 1; // use second section for negative values 164 | } 165 | else { 166 | section = 0; // use first for all others 167 | } 168 | } 169 | else if (section == 2 || section == 3) { // three or four sections 170 | if (negativevalue) { 171 | negativevalue = 0; // sign will provided by section, not automatically 172 | section = 1; // use second section for negative values 173 | } 174 | else if (zerovalue) { 175 | section = 2; // use third section for zero values 176 | } 177 | else { 178 | section = 0; // use first for positive 179 | } 180 | } 181 | } 182 | 183 | sectioninfo = thisformat.sectioninfo[section]; // look at values for our section 184 | 185 | if (sectioninfo.commas > 0) { // scale by thousands 186 | for (i=0; i 0) { // do percent scaling 191 | for (i=0; i=0) { // converted to scientific notation 216 | return rawvalue+""; // Just return plain converted raw value 217 | } 218 | 219 | strparts=strvalue.match(/^\+{0,1}(\d*)(?:\.(\d*)){0,1}$/); // get integer and fraction parts 220 | if (!strparts) return "NaN"; // if not a number 221 | integervalue = strparts[1]; 222 | if (!integervalue || integervalue=="0") integervalue=""; 223 | fractionvalue = strparts[2]; 224 | if (!fractionvalue) fractionvalue = ""; 225 | 226 | if (sectioninfo.hasdate) { // there are date placeholders 227 | if (rawvalue < 0) { // bad date 228 | return "??-???-?? ??:??:??"; 229 | } 230 | startval = (rawvalue-Math.floor(rawvalue)) * scfn.datevalues.seconds_in_a_day; // get date/time parts 231 | estartval = rawvalue * scfn.datevalues.seconds_in_a_day; // do elapsed time version, too 232 | hrs = Math.floor(startval / scfn.datevalues.seconds_in_an_hour); 233 | ehrs = Math.floor(estartval / scfn.datevalues.seconds_in_an_hour); 234 | startval = startval - hrs * scfn.datevalues.seconds_in_an_hour; 235 | mins = Math.floor(startval / 60); 236 | emins = Math.floor(estartval / 60); 237 | secs = startval - mins * 60; 238 | decimalscale = 1; // round appropriately depending if there is ss.0 239 | for (i=0; i= 60) { // handle round up into next second, minute, etc. 247 | secs = 0; 248 | mins++; emins++; 249 | if (mins >= 60) { 250 | mins = 0; 251 | hrs++; ehrs++; 252 | if (hrs >= 24) { 253 | hrs = 0; 254 | rawvalue++; 255 | } 256 | } 257 | } 258 | fractionvalue = (secs-Math.floor(secs))+""; // for "hh:mm:ss.000" 259 | fractionvalue = fractionvalue.substring(2); // skip "0." 260 | 261 | ymd = SocialCalc.FormatNumber.convert_date_julian_to_gregorian(Math.floor(rawvalue+scfn.datevalues.julian_offset)); 262 | 263 | minOK = 0; // says "m" can be minutes if true 264 | mspos = sectioninfo.sectionstart; // m scan position in ops 265 | for ( ; ; mspos++) { // scan for "m" and "mm" to see if any minutes fields, and am/pm 266 | op = thisformat.operators[mspos]; 267 | operandstr = thisformat.operands[mspos]; // get next operator and operand 268 | if (!op) break; // don't go past end 269 | if (op==scfn.commands.section) break; 270 | if (op==scfn.commands.date) { 271 | if ((operandstr.toLowerCase()=="am/pm" || operandstr.toLowerCase()=="a/p") && !ampmstr) { 272 | if (hrs >= 12) { 273 | hrs -= 12; 274 | ampmstr = operandstr.toLowerCase()=="a/p" ? scc.s_FormatNumber_pm1 : scc.s_FormatNumber_pm; // "P" : "PM"; 275 | } 276 | else { 277 | ampmstr = operandstr.toLowerCase()=="a/p" ? scc.s_FormatNumber_am1 : scc.s_FormatNumber_am; // "A" : "AM"; 278 | } 279 | if (operandstr.indexOf(ampmstr)<0) 280 | ampmstr = ampmstr.toLowerCase(); // have case match case in format 281 | } 282 | if (minOK && (operandstr=="m" || operandstr=="mm")) { 283 | thisformat.operands[mspos] += "in"; // turn into "min" or "mmin" 284 | } 285 | if (operandstr.charAt(0)=="h") { 286 | minOK = 1; // m following h or hh or [h] is minutes not months 287 | } 288 | else { 289 | minOK = 0; 290 | } 291 | } 292 | else if (op!=scfn.commands.copy) { // copying chars can be between h and m 293 | minOK = 0; 294 | } 295 | } 296 | minOK = 0; 297 | for (--mspos; ; mspos--) { // scan other way for s after m 298 | op = thisformat.operators[mspos]; 299 | operandstr = thisformat.operands[mspos]; // get next operator and operand 300 | if (!op) break; // don't go past end 301 | if (op==scfn.commands.section) break; 302 | if (op==scfn.commands.date) { 303 | if (minOK && (operandstr=="m" || operandstr=="mm")) { 304 | thisformat.operands[mspos] += "in"; // turn into "min" or "mmin" 305 | } 306 | if (operandstr=="ss") { 307 | minOK = 1; // m before ss is minutes not months 308 | } 309 | else { 310 | minOK = 0; 311 | } 312 | } 313 | else if (op!=scfn.commands.copy) { // copying chars can be between ss and m 314 | minOK = 0; 315 | } 316 | } 317 | } 318 | 319 | integerdigits2 = 0; // init counters, etc. 320 | integerpos = 0; 321 | fractionpos = 0; 322 | textcolor = ""; 323 | textstyle = ""; 324 | separatorchar = scc.FormatNumber_separatorchar; 325 | if (separatorchar.indexOf(" ")>=0) separatorchar = separatorchar.replace(/ /g, " "); 326 | decimalchar = scc.FormatNumber_decimalchar; 327 | if (decimalchar.indexOf(" ")>=0) decimalchar = decimalchar.replace(/ /g, " "); 328 | 329 | oppos = sectioninfo.sectionstart; 330 | 331 | while (op = thisformat.operators[oppos]) { // execute format 332 | operandstr = thisformat.operands[oppos++]; // get next operator and operand 333 | 334 | if (op == scfn.commands.copy) { // put char in result 335 | result += operandstr; 336 | } 337 | 338 | else if (op == scfn.commands.color) { // set color 339 | textcolor = operandstr; 340 | } 341 | 342 | else if (op == scfn.commands.style) { // set style 343 | textstyle = operandstr; 344 | } 345 | 346 | else if (op == scfn.commands.integer_placeholder) { // insert number part 347 | if (negativevalue) { 348 | result += "-"; 349 | negativevalue = 0; 350 | } 351 | integerdigits2++; 352 | if (integerdigits2 == 1) { // first one 353 | if (integervalue.length > sectioninfo.integerdigits) { // see if integer wider than field 354 | for (;integerpos < (integervalue.length - sectioninfo.integerdigits); integerpos++) { 355 | result += integervalue.charAt(integerpos); 356 | if (sectioninfo.thousandssep) { // see if this is a separator position 357 | fromend = integervalue.length - integerpos - 1; 358 | if (fromend > 2 && fromend % 3 == 0) { 359 | result += separatorchar; 360 | } 361 | } 362 | } 363 | } 364 | } 365 | if (integervalue.length < sectioninfo.integerdigits 366 | && integerdigits2 <= sectioninfo.integerdigits - integervalue.length) { // field is wider than value 367 | if (operandstr == "0" || operandstr == "?") { // fill with appropriate characters 368 | result += operandstr == "0" ? "0" : " "; 369 | if (sectioninfo.thousandssep) { // see if this is a separator position 370 | fromend = sectioninfo.integerdigits - integerdigits2; 371 | if (fromend > 2 && fromend % 3 == 0) { 372 | result += separatorchar; 373 | } 374 | } 375 | } 376 | } 377 | else { // normal integer digit - add it 378 | result += integervalue.charAt(integerpos); 379 | if (sectioninfo.thousandssep) { // see if this is a separator position 380 | fromend = integervalue.length - integerpos - 1; 381 | if (fromend > 2 && fromend % 3 == 0) { 382 | result += separatorchar; 383 | } 384 | } 385 | integerpos++; 386 | } 387 | } 388 | else if (op == scfn.commands.fraction_placeholder) { // add fraction part of number 389 | if (fractionpos >= fractionvalue.length) { 390 | if (operandstr == "0" || operandstr == "?") { 391 | result += operandstr == "0" ? "0" : " "; 392 | } 393 | } 394 | else { 395 | result += fractionvalue.charAt(fractionpos); 396 | } 397 | fractionpos++; 398 | } 399 | 400 | else if (op == scfn.commands.decimal) { // decimal point 401 | if (negativevalue) { 402 | result += "-"; 403 | negativevalue = 0; 404 | } 405 | result += decimalchar; 406 | } 407 | 408 | else if (op == scfn.commands.currency) { // currency symbol 409 | if (negativevalue) { 410 | result += "-"; 411 | negativevalue = 0; 412 | } 413 | result += operandstr; 414 | } 415 | 416 | else if (op == scfn.commands.general) { // insert "General" conversion 417 | 418 | // *** Cut down number of significant digits to avoid floating point artifacts: 419 | 420 | if (value!=0) { // only if non-zero 421 | var factor = Math.floor(Math.LOG10E * Math.log(value)); // get integer magnitude as a power of 10 422 | factor = Math.pow(10, 13-factor); // turn into scaling factor 423 | value = Math.floor(factor * value + 0.5)/factor; // scale positive value, round, undo scaling 424 | if (!isFinite(value)) return "NaN"; 425 | } 426 | if (negativevalue) { 427 | result += "-"; 428 | } 429 | strvalue = value+""; // convert original value to string 430 | if (strvalue.indexOf("e")>=0) { // converted to scientific notation 431 | result += strvalue; 432 | continue; 433 | } 434 | strparts=strvalue.match(/^\+{0,1}(\d*)(?:\.(\d*)){0,1}$/); // get integer and fraction parts 435 | integervalue = strparts[1]; 436 | if (!integervalue || integervalue=="0") integervalue=""; 437 | fractionvalue = strparts[2]; 438 | if (!fractionvalue) fractionvalue = ""; 439 | integerpos = 0; 440 | fractionpos = 0; 441 | if (integervalue.length) { 442 | for (;integerpos < integervalue.length; integerpos++) { 443 | result += integervalue.charAt(integerpos); 444 | if (sectioninfo.thousandssep) { // see if this is a separator position 445 | fromend = integervalue.length - integerpos - 1; 446 | if (fromend > 2 && fromend % 3 == 0) { 447 | result += separatorchar; 448 | } 449 | } 450 | } 451 | } 452 | else { 453 | result += "0"; 454 | } 455 | if (fractionvalue.length) { 456 | result += decimalchar; 457 | for (;fractionpos < fractionvalue.length; fractionpos++) { 458 | result += fractionvalue.charAt(fractionpos); 459 | } 460 | } 461 | } 462 | else if (op==scfn.commands.date) { // date placeholder 463 | operandstrlc = operandstr.toLowerCase(); 464 | if (operandstrlc=="y" || operandstrlc=="yy") { 465 | result += (ymd.year+"").substring(2); 466 | } 467 | else if (operandstrlc=="yyyy") { 468 | result += ymd.year+""; 469 | } 470 | else if (operandstrlc=="d") { 471 | result += ymd.day+""; 472 | } 473 | else if (operandstrlc=="dd") { 474 | cval = 1000 + ymd.day; 475 | result += (cval+"").substr(2); 476 | } 477 | else if (operandstrlc=="ddd") { 478 | cval = Math.floor(rawvalue+6) % 7; 479 | result += scc.s_FormatNumber_daynames3[cval]; 480 | } 481 | else if (operandstrlc=="dddd") { 482 | cval = Math.floor(rawvalue+6) % 7; 483 | result += scc.s_FormatNumber_daynames[cval]; 484 | } 485 | else if (operandstrlc=="m") { 486 | result += ymd.month+""; 487 | } 488 | else if (operandstrlc=="mm") { 489 | cval = 1000 + ymd.month; 490 | result += (cval+"").substr(2); 491 | } 492 | else if (operandstrlc=="mmm") { 493 | result += scc.s_FormatNumber_monthnames3[ymd.month-1]; 494 | } 495 | else if (operandstrlc=="mmmm") { 496 | result += scc.s_FormatNumber_monthnames[ymd.month-1]; 497 | } 498 | else if (operandstrlc=="mmmmm") { 499 | result += scc.s_FormatNumber_monthnames[ymd.month-1].charAt(0); 500 | } 501 | else if (operandstrlc=="h") { 502 | result += hrs+""; 503 | } 504 | else if (operandstrlc=="h]") { 505 | result += ehrs+""; 506 | } 507 | else if (operandstrlc=="mmin") { 508 | cval = (1000 + mins)+""; 509 | result += cval.substr(2); 510 | } 511 | else if (operandstrlc=="mm]") { 512 | if (emins < 100) { 513 | cval = (1000 + emins)+""; 514 | result += cval.substr(2); 515 | } 516 | else { 517 | result += emins+""; 518 | } 519 | } 520 | else if (operandstrlc=="min") { 521 | result += mins+""; 522 | } 523 | else if (operandstrlc=="m]") { 524 | result += emins+""; 525 | } 526 | else if (operandstrlc=="hh") { 527 | cval = (1000 + hrs)+""; 528 | result += cval.substr(2); 529 | } 530 | else if (operandstrlc=="s") { 531 | cval = Math.floor(secs); 532 | result += cval+""; 533 | } 534 | else if (operandstrlc=="ss") { 535 | cval = (1000 + Math.floor(secs))+""; 536 | result += cval.substr(2); 537 | } 538 | else if (operandstrlc=="am/pm" || operandstrlc=="a/p") { 539 | result += ampmstr; 540 | } 541 | else if (operandstrlc=="ss]") { 542 | if (esecs < 100) { 543 | cval = (1000 + Math.floor(esecs))+""; 544 | result += cval.substr(2); 545 | } 546 | else { 547 | cval = Math.floor(esecs); 548 | result += cval+""; 549 | } 550 | } 551 | } 552 | else if (op == scfn.commands.section) { // end of section 553 | break; 554 | } 555 | 556 | else if (op == scfn.commands.comparison) { // ignore 557 | continue; 558 | } 559 | 560 | else { 561 | result += "!! Parse error !!"; 562 | } 563 | } 564 | 565 | if (textcolor) { 566 | result = ''+result+''; 567 | } 568 | if (textstyle) { 569 | result = ''+result+''; 570 | } 571 | 572 | return result; 573 | 574 | }; 575 | 576 | /* ******************* 577 | 578 | result = SocialCalc.FormatNumber.formatTextWithFormat = function(rawvalue, format_string) 579 | 580 | ************************* */ 581 | 582 | SocialCalc.FormatNumber.formatTextWithFormat = function(rawvalue, format_string) { 583 | 584 | var scc = SocialCalc.Constants; 585 | var scfn = SocialCalc.FormatNumber; 586 | var value = rawvalue+""; 587 | var result = ""; 588 | var section; 589 | var sectioninfo; 590 | var oppos; 591 | var operandstr; 592 | var textcolor = ""; 593 | var textstyle = ""; 594 | 595 | scfn.parse_format_string(scfn.format_definitions, format_string); // make sure format is parsed 596 | thisformat = scfn.format_definitions[format_string]; // Get format structure 597 | 598 | if (!thisformat) throw "Format not parsed error!"; 599 | 600 | section = thisformat.sectioninfo.length - 1; // get number of sections - 1 601 | if (section == 0) { 602 | section = 0; 603 | } 604 | else if (section == 3) { 605 | section = 3; 606 | } 607 | else { 608 | return value; 609 | } 610 | 611 | sectioninfo = thisformat.sectioninfo[section]; // look at values for our section 612 | oppos = sectioninfo.sectionstart; 613 | 614 | while (op = thisformat.operators[oppos]) { // execute format 615 | operandstr = thisformat.operands[oppos++]; // get next operator and operand 616 | 617 | if (op == scfn.commands.copy) { // put char in result 618 | if (operandstr == "@") { 619 | result += value; 620 | } 621 | else { 622 | result += operandstr.replace(/ /g, " "); 623 | } 624 | } 625 | 626 | else if (op == scfn.commands.color) { // set color 627 | textcolor = operandstr; 628 | } 629 | 630 | else if (op == scfn.commands.style) { // set style 631 | textstyle = operandstr; 632 | } 633 | } 634 | 635 | if (textcolor) { 636 | result = ''+result+''; 637 | } 638 | if (textstyle) { 639 | result = ''+result+''; 640 | } 641 | 642 | return result; 643 | 644 | }; 645 | 646 | /* ******************* 647 | 648 | SocialCalc.FormatNumber.parse_format_string(format_defs, format_string) 649 | 650 | Takes a format string (e.g., "#,##0.00_);(#,##0.00)") and fills in format_defs with the parsed info 651 | 652 | format_defs 653 | ["#,##0.0"]->{} - elements in the hash are one hash for each format 654 | .operators->[] - array of operators from parsing the format string (each a number) 655 | .operands->[] - array of corresponding operators (each usually a string) 656 | .sectioninfo->[] - one hash for each section of the format 657 | .start 658 | .integerdigits 659 | .fractiondigits 660 | .commas 661 | .percent 662 | .thousandssep 663 | .hasdates 664 | .hascomparison - true if any section has [<100], etc. 665 | 666 | ************************* */ 667 | 668 | SocialCalc.FormatNumber.parse_format_string = function(format_defs, format_string) { 669 | 670 | var scfn = SocialCalc.FormatNumber; 671 | 672 | var thisformat, section, sectioninfo; 673 | var integerpart = 1; // start out in integer part 674 | var lastwasinteger; // last char was an integer placeholder 675 | var lastwasslash; // last char was a backslash - escaping following character 676 | var lastwasasterisk; // repeat next char 677 | var lastwasunderscore; // last char was _ which picks up following char for width 678 | var inquote, quotestr; // processing a quoted string 679 | var inbracket, bracketstr, bracketdata; // processing a bracketed string 680 | var ingeneral, gpos; // checks for characters "General" 681 | var ampmstr, part; // checks for characters "A/P" and "AM/PM" 682 | var indate; // keeps track of date/time placeholders 683 | var chpos; // character position being looked at 684 | var ch; // character being looked at 685 | 686 | if (format_defs[format_string]) return; // already defined - nothing to do 687 | 688 | thisformat = {operators: [], operands: [], sectioninfo: [{}]}; // create info structure for this format 689 | format_defs[format_string] = thisformat; // add to other format definitions 690 | 691 | section = 0; // start with section 0 692 | sectioninfo = thisformat.sectioninfo[section]; // get reference to info for current section 693 | sectioninfo.sectionstart = 0; // position in operands that starts this section 694 | sectioninfo.integerdigits = 0; // number of integer-part placeholders 695 | sectioninfo.fractiondigits = 0; // fraction placeholders 696 | sectioninfo.commas = 0; // commas encountered, to handle scaling 697 | sectioninfo.percent = 0; // times to scale by 100 698 | 699 | for (chpos=0; chpos=0) { 874 | indate = ch; 875 | } 876 | else { 877 | lastwasinteger = 0; 878 | thisformat.operators.push(scfn.commands.copy); 879 | thisformat.operands.push(ch); 880 | } 881 | } 882 | 883 | if (indate) { // last char was part of unsaved date placeholder 884 | thisformat.operators.push(scfn.commands.date); 885 | thisformat.operands.push(indate); 886 | sectioninfo.hasdate = 1; 887 | } 888 | 889 | return; 890 | 891 | } 892 | 893 | 894 | /* ******************* 895 | 896 | bracketdata = SocialCalc.FormatNumber.parse_format_bracket(bracketstr) 897 | 898 | Takes a bracket contents (e.g., "RED", ">10") and returns an operator and operand 899 | 900 | bracketdata->{} 901 | .operator 902 | .operand 903 | 904 | ************************* */ 905 | 906 | SocialCalc.FormatNumber.parse_format_bracket = function(bracketstr) { 907 | 908 | var scfn = SocialCalc.FormatNumber; 909 | var scc = SocialCalc.Constants; 910 | 911 | var bracketdata={}; 912 | var parts; 913 | 914 | if (bracketstr.charAt(0)=='$') { // currency 915 | bracketdata.operator = scfn.commands.currency; 916 | parts=bracketstr.match(/^\$(.+?)(\-.+?){0,1}$/); 917 | if (parts) { 918 | bracketdata.operand = parts[1] || scc.FormatNumber_defaultCurrency || '$'; 919 | } 920 | else { 921 | bracketdata.operand = bracketstr.substring(1) || scc.FormatNumber_defaultCurrency || '$'; 922 | } 923 | } 924 | else if (bracketstr=='?$') { 925 | bracketdata.operator = scfn.commands.currency; 926 | bracketdata.operand = '[?$]'; 927 | } 928 | else if (scfn.allowedcolors[bracketstr.toUpperCase()]) { 929 | bracketdata.operator = scfn.commands.color; 930 | bracketdata.operand = scfn.allowedcolors[bracketstr.toUpperCase()]; 931 | } 932 | else if (parts=bracketstr.match(/^style=([^"]*)$/)) { // [style=...] 933 | bracketdata.operator = scfn.commands.style; 934 | bracketdata.operand = parts[1]; 935 | } 936 | else if (bracketstr==",") { 937 | bracketdata.operator = scfn.commands.separator; 938 | bracketdata.operand = bracketstr; 939 | } 940 | else if (scfn.alloweddates[bracketstr.toUpperCase()]) { 941 | bracketdata.operator = scfn.commands.date; 942 | bracketdata.operand = scfn.alloweddates[bracketstr.toUpperCase()]; 943 | } 944 | else if (parts=bracketstr.match(/^[<>=]/)) { // comparison operator 945 | parts=bracketstr.match(/^([<>=]+)(.+)$/); // split operator and value 946 | bracketdata.operator = scfn.commands.comparison; 947 | bracketdata.operand = parts[1]+":"+parts[2]; 948 | } 949 | else { // unknown bracket 950 | bracketdata.operator = scfn.commands.copy; 951 | bracketdata.operand = "["+bracketstr+"]"; 952 | } 953 | 954 | return bracketdata; 955 | 956 | } 957 | 958 | /* ******************* 959 | 960 | juliandate = SocialCalc.FormatNumber.convert_date_gregorian_to_julian(year, month, day) 961 | 962 | From: http://aa.usno.navy.mil/faq/docs/JD_Formula.html 963 | Uses: Fliegel, H. F. and van Flandern, T. C. (1968). Communications of the ACM, Vol. 11, No. 10 (October, 1968). 964 | Translated from the FORTRAN 965 | 966 | I= YEAR 967 | J= MONTH 968 | K= DAY 969 | C 970 | JD= K-32075+1461*(I+4800+(J-14)/12)/4+367*(J-2-(J-14)/12*12) 971 | 2 /12-3*((I+4900+(J-14)/12)/100)/4 972 | 973 | ************************* */ 974 | 975 | SocialCalc.FormatNumber.convert_date_gregorian_to_julian = function(year, month, day) { 976 | 977 | var juliandate; 978 | 979 | juliandate = day-32075+SocialCalc.intFunc(1461*(year+4800+SocialCalc.intFunc((month-14)/12))/4); 980 | juliandate += SocialCalc.intFunc(367*(month-2-SocialCalc.intFunc((month-14)/12)*12)/12); 981 | juliandate = juliandate - SocialCalc.intFunc(3*SocialCalc.intFunc((year+4900+SocialCalc.intFunc((month-14)/12))/100)/4); 982 | 983 | return juliandate; 984 | 985 | } 986 | 987 | 988 | /* ******************* 989 | 990 | ymd = SocialCalc.FormatNumber.convert_date_julian_to_gregorian(juliandate) 991 | 992 | ymd->{} 993 | .year 994 | .month 995 | .day 996 | 997 | From: http://aa.usno.navy.mil/faq/docs/JD_Formula.html 998 | Uses: Fliegel, H. F. and van Flandern, T. C. (1968). Communications of the ACM, Vol. 11, No. 10 (October, 1968). 999 | Translated from the FORTRAN 1000 | 1001 | ************************* */ 1002 | 1003 | SocialCalc.FormatNumber.convert_date_julian_to_gregorian = function(juliandate) { 1004 | 1005 | var L, N, I, J, K; 1006 | 1007 | L = juliandate+68569; 1008 | N = Math.floor(4*L/146097); 1009 | L = L-Math.floor((146097*N+3)/4); 1010 | I = Math.floor(4000*(L+1)/1461001); 1011 | L = L-Math.floor(1461*I/4)+31; 1012 | J = Math.floor(80*L/2447); 1013 | K = L-Math.floor(2447*J/80); 1014 | L = Math.floor(J/11); 1015 | J = J+2-12*L; 1016 | I = 100*(N-49)+I+L; 1017 | 1018 | return {year:I, month:J, day:K}; 1019 | 1020 | } 1021 | 1022 | SocialCalc.intFunc = function(n) { 1023 | if (n < 0) { 1024 | return -Math.floor(-n); 1025 | } 1026 | else { 1027 | return Math.floor(n); 1028 | } 1029 | } 1030 | 1031 | -------------------------------------------------------------------------------- /lib/ethercalc/socialcalcconstants.js: -------------------------------------------------------------------------------- 1 | // 2 | /* 3 | // The module of the SocialCalc package with customizable constants, strings, etc. 4 | // This is where most of the common localizations are done. 5 | // 6 | // (c) Copyright 2008, 2009, 2010 Socialtext, Inc. 7 | // All Rights Reserved. 8 | // 9 | // The contents of this file are subject to the Artistic License 2.0; you may not 10 | // use this file except in compliance with the License. You may obtain a copy of 11 | // the License at http://socialcalc.org/licenses/al-20/. 12 | // 13 | // Some of the other files in the SocialCalc package are licensed under 14 | // different licenses. Please note the licenses of the modules you use. 15 | // 16 | // Code History: 17 | // 18 | // Initially coded by Dan Bricklin of Software Garden, Inc., for Socialtext, Inc. 19 | // Based in part on the SocialCalc 1.1.0 code written in Perl. 20 | // The SocialCalc 1.1.0 code was: 21 | // Portions (c) Copyright 2005, 2006, 2007 Software Garden, Inc. 22 | // All Rights Reserved. 23 | // Portions (c) Copyright 2007 Socialtext, Inc. 24 | // All Rights Reserved. 25 | // The Perl SocialCalc started as modifications to the wikiCalc(R) program, version 1.0. 26 | // wikiCalc 1.0 was written by Software Garden, Inc. 27 | // Unless otherwise specified, referring to "SocialCalc" in comments refers to this 28 | // JavaScript version of the code, not the SocialCalc Perl code. 29 | // 30 | */ 31 | 32 | var SocialCalc; 33 | if (!SocialCalc) SocialCalc = {}; 34 | 35 | // ************************************* 36 | // 37 | // TO LEARN HOW TO LOCALIZE OR CUSTOMIZE SOCIALCALC, PLEASE READ THIS: 38 | // 39 | // The constants are all properties of the SocialCalc.Constants object. 40 | // They are grouped here by what they are for, which module uses them, etc. 41 | // 42 | // Properties whose names start with "s_" are strings, or arrays of strings, 43 | // that are good candidates for translation from the English. 44 | // 45 | // Other properties relate to visual settings, localization parameters, etc. 46 | // 47 | // These values are not used when SocialCalc modules are first loaded. 48 | // They may be modified before the first use of the routines that use them, 49 | // e.g., before creating SocialCalc objects. 50 | // 51 | // The exceptions are: 52 | // TooltipOffsetX and TooltipOffsetY, as described with their definitions. 53 | // 54 | // SocialCalc IS NOT DESIGNED FOR USE WITH A TRANSLATION FUNCTION each time a string 55 | // is used. Instead, language translations may be done by modifying this object. 56 | // 57 | // To customize SocialCalc, you may either replace this file with a modified version 58 | // or you can overwrite the values before use. An example would be to 59 | // iterate over all the properties looking for names that start with "s_" and 60 | // use some other mechanism to obtain a localized string and replace the values 61 | // here with those translated values. 62 | // 63 | // There is also a function, SocialCalc.ConstantsSetClasses, that may be used 64 | // to easily switch SocialCalc from using explicit CSS styles for many things 65 | // to using CSS classes. See the function, below, for more information. 66 | // 67 | // ************************************* 68 | 69 | SocialCalc.Constants = { 70 | 71 | // 72 | // Main SocialCalc module, socialcalc-3.js: 73 | // 74 | 75 | //*** Common Constants 76 | 77 | textdatadefaulttype: "t", // This sets the default type for text on reading source file 78 | // It should normally be "t" 79 | 80 | //*** Common error messages 81 | 82 | s_BrowserNotSupported: "Browser not supported.", // error thrown if browser can't handle events like IE or Firefox. 83 | s_InternalError: "Internal SocialCalc error (probably an internal bug): ", // hopefully unlikely, but a test failed 84 | 85 | //*** SocialCalc.ParseSheetSave 86 | 87 | // Errors thrown on unexpected value in save file: 88 | 89 | s_pssUnknownColType: "Unknown col type item", 90 | s_pssUnknownRowType: "Unknown row type item", 91 | s_pssUnknownLineType: "Unknown line type", 92 | 93 | //*** SocialCalc.CellFromStringParts 94 | 95 | // Error thrown on unexpected value in save file: 96 | 97 | s_cfspUnknownCellType: "Unknown cell type item", 98 | 99 | //*** SocialCalc.CanonicalizeSheet 100 | 101 | doCanonicalizeSheet: true, // if true, do the canonicalization calculations 102 | 103 | //*** ExecuteSheetCommand 104 | 105 | s_escUnknownSheetCmd: "Unknown sheet command: ", 106 | s_escUnknownSetCoordCmd: "Unknown set coord command: ", 107 | s_escUnknownCmd: "Unknown command: ", 108 | 109 | //*** SocialCalc.CheckAndCalcCell 110 | 111 | s_caccCircRef: "Circular reference to ", // circular reference found during recalc 112 | 113 | //*** SocialCalc.RenderContext 114 | 115 | defaultRowNameWidth: "30", // used to set minimum width of the row header column - a string in pixels 116 | defaultAssumedRowHeight: 15, // used when guessing row heights - number 117 | defaultCellIDPrefix: "cell_", // if non-null, each cell will render with an ID starting with this 118 | 119 | // Default sheet display values 120 | 121 | defaultCellLayout: "padding:2px 2px 1px 2px;vertical-align:top;", 122 | defaultCellFontStyle: "normal normal", 123 | defaultCellFontSize: "small", 124 | defaultCellFontFamily: "Verdana,Arial,Helvetica,sans-serif", 125 | 126 | defaultPaneDividerWidth: "2", // a string 127 | defaultPaneDividerHeight: "3", // a string 128 | 129 | defaultGridCSS: "1px solid #C0C0C0;", // used as style to set each border when grid enabled (was #ECECEC) 130 | 131 | defaultCommentClass: "", // class added to cells with non-null comments when grid enabled 132 | defaultCommentStyle: "background-repeat:no-repeat;background-position:top right;background-image:url(images/sc-commentbg.gif);", // style added to cells with non-null comments when grid enabled 133 | defaultCommentNoGridClass: "", // class added to cells with non-null comments when grid not enabled 134 | defaultCommentNoGridStyle: "", // style added to cells with non-null comments when grid not enabled 135 | 136 | defaultReadonlyClass: "", // class added to readonly cells when grid enabled 137 | defaultReadonlyStyle: "background-repeat:no-repeat;background-position:top right;background-image:url(images/sc-lockbg.gif);", // style added to readonly cells when grid enabled 138 | defaultReadonlyNoGridClass: "", // class added to readonly cells when grid not enabled 139 | defaultReadonlyNoGridStyle: "", // style added to readonly cells when grid not enabled 140 | defaultReadonlyComment: "Locked cell", 141 | 142 | defaultColWidth: "80", // text 143 | defaultMinimumColWidth: 10, // numeric 144 | 145 | // For each of the following default sheet display values at least one of class and/or style are needed 146 | 147 | defaultHighlightTypeCursorClass: "", 148 | defaultHighlightTypeCursorStyle: "color:#FFF;backgroundColor:#A6A6A6;", 149 | defaultHighlightTypeRangeClass: "", 150 | defaultHighlightTypeRangeStyle: "color:#000;backgroundColor:#E5E5E5;", 151 | 152 | defaultColnameClass: "", // regular column heading letters, needs a cursor property 153 | defaultColnameStyle: "font-size:small;text-align:center;color:#FFFFFF;background-color:#808080;cursor:e-resize;", 154 | defaultSelectedColnameClass: "", // column with selected cell, needs a cursor property 155 | defaultSelectedColnameStyle: "font-size:small;text-align:center;color:#FFFFFF;background-color:#404040;cursor:e-resize;", 156 | defaultRownameClass: "", // regular row heading numbers 157 | defaultRownameStyle: "font-size:small;text-align:right;color:#FFFFFF;background-color:#808080;direction:rtl;", 158 | defaultSelectedRownameClass: "", // column with selected cell, needs a cursor property 159 | defaultSelectedRownameStyle: "font-size:small;text-align:right;color:#FFFFFF;background-color:#404040;", 160 | defaultUpperLeftClass: "", // Corner cell in upper left 161 | defaultUpperLeftStyle: "font-size:small;", 162 | defaultSkippedCellClass: "", // used if present for spanned cells peeking into a pane (at least one of class/style needed) 163 | defaultSkippedCellStyle: "font-size:small;background-color:#CCC", // used if present 164 | defaultPaneDividerClass: "", // used if present for the look of the space between panes (at least one of class/style needed) 165 | defaultPaneDividerStyle: "font-size:small;background-color:#C0C0C0;padding:0px;", // used if present 166 | defaultUnhideLeftClass: "", 167 | defaultUnhideLeftStyle: "float:right;width:9px;height:12px;cursor:pointer;background-image:url(images/sc-unhideleft.gif);padding:0;", // used if present 168 | defaultUnhideRightClass: "", 169 | defaultUnhideRightStyle: "float:left;width:9px;height:12px;cursor:pointer;background-image:url(images/sc-unhideright.gif);padding:0;", // used if present 170 | defaultUnhideTopClass: "", 171 | defaultUnhideTopStyle: "float:left;position:absolute;bottom:-4px;width:12px;height:9px;cursor:pointer;background-image:url(images/sc-unhidetop.gif);padding:0;", 172 | defaultUnhideBottomClass: "", 173 | defaultUnhideBottomStyle: "float:left;width:12px;height:9px;cursor:pointer;background-image:url(images/sc-unhidebottom.gif);padding:0;", 174 | 175 | s_rcMissingSheet: "Render Context must have a sheet object", // unlikely thrown error 176 | 177 | //*** SocialCalc.format_text_for_display 178 | 179 | defaultLinkFormatString: 'Link', // used for format "text-link"; you could make this an img tag if desired 180 | // defaultLinkFormatString: 'Link out', 181 | defaultPageLinkFormatString: 'Page', // used for format "text-link"; you could make this an img tag if desired 182 | 183 | //*** SocialCalc.format_number_for_display 184 | 185 | defaultFormatp: '#,##0.0%', 186 | defaultFormatc: '[$$]#,##0.00', 187 | defaultFormatdt: 'd-mmm-yyyy h:mm:ss', 188 | defaultFormatd: 'd-mmm-yyyy', 189 | defaultFormatt: '[h]:mm:ss', 190 | defaultDisplayTRUE: 'TRUE', // how TRUE shows when rendered 191 | defaultDisplayFALSE: 'FALSE', 192 | 193 | // 194 | // SocialCalc Table Editor module, socialcalctableeditor.js: 195 | // 196 | 197 | //*** SocialCalc.TableEditor 198 | 199 | defaultImagePrefix: "images/sc-", // URL prefix for images (e.g., "/images/sc") 200 | defaultTableEditorIDPrefix: "te_", // if present, many TableEditor elements are assigned IDs with this prefix 201 | defaultPageUpDnAmount: 15, // number of rows to move cursor on PgUp/PgDn keys (numeric) 202 | 203 | AllowCtrlS: true, // turns on Ctrl-S trapdoor for setting custom numeric formats and commands if true 204 | 205 | //*** SocialCalc.CreateTableEditor 206 | 207 | defaultTableControlThickness: 20, // the short size for the scrollbars, etc. (numeric in pixels) 208 | cteGriddivClass: "", // if present, the class for the TableEditor griddiv element 209 | 210 | //** SocialCalc.EditorGetStatuslineString -- strings shown on status line 211 | 212 | s_statusline_executing: "Executing...", 213 | s_statusline_displaying: "Displaying...", 214 | s_statusline_ordering: "Ordering...", 215 | s_statusline_calculating: "Calculating...", 216 | s_statusline_calculatingls: "Calculating... Loading Sheet...", 217 | s_statusline_doingserverfunc: "doing server function ", 218 | s_statusline_incell: " in cell ", 219 | s_statusline_calcstart: "Calculation start...", 220 | s_statusline_sum: "SUM", 221 | s_statusline_recalcneeded: '(Recalc needed)', 222 | s_statusline_circref: 'Circular reference: ', 223 | 224 | //** SocialCalc.InputBoxDisplayCellContents 225 | 226 | s_inputboxdisplaymultilinetext: "[Multi-line text: Click icon on right to edit]", 227 | 228 | //** SocialCalc.InputEcho 229 | 230 | defaultInputEchoClass: "", // if present, the class of the popup inputEcho div 231 | defaultInputEchoStyle: "filter:alpha(opacity=90);opacity:.9;backgroundColor:#FFD;border:1px solid #884;"+ 232 | "fontSize:small;padding:2px 10px 1px 2px;cursor:default;", // if present, pseudo style 233 | defaultInputEchoPromptClass: "", // if present, the class of the popup inputEcho div 234 | defaultInputEchoPromptStyle: "filter:alpha(opacity=90);opacity:.9;backgroundColor:#FFD;"+ 235 | "borderLeft:1px solid #884;borderRight:1px solid #884;borderBottom:1px solid #884;"+ 236 | "fontSize:small;fontStyle:italic;padding:2px 10px 1px 2px;cursor:default;", // if present, pseudo style 237 | 238 | //** SocialCalc.InputEchoText 239 | 240 | ietUnknownFunction: "Unknown function ", // displayed when typing "=unknown(" 241 | 242 | //** SocialCalc.CellHandles 243 | 244 | CH_radius1: 29.0, // extent of inner circle within 90px image 245 | CH_radius2: 41.0, // extent of outer circle within 90px image 246 | s_CHfillAllTooltip: "Fill Contents and Formats Down/Right", // tooltip for fill all handle 247 | s_CHfillContentsTooltip: "Fill Contents Only Down/Right", // tooltip for fill formulas handle 248 | s_CHmovePasteAllTooltip: "Move Contents and Formats", // etc. 249 | s_CHmovePasteContentsTooltip: "Move Contents Only", 250 | s_CHmoveInsertAllTooltip: "Slide Contents and Formats within Row/Col", 251 | s_CHmoveInsertContentsTooltip: "Slide Contents within Row/Col", 252 | s_CHindicatorOperationLookup: {"Fill": "Fill", "FillC": "Fill Contents", 253 | "Move": "Move", "MoveI": "Slide", 254 | "MoveC": "Move Contents", "MoveIC": "Slide Contents"}, // short form of operation to follow drag 255 | s_CHindicatorDirectionLookup: {"Down": " Down", "Right": " Right", 256 | "Horizontal": " Horizontal", "Vertical": " Vertical"}, // direction that modifies operation during drag 257 | 258 | //*** SocialCalc.TableControl 259 | 260 | defaultTCSliderThickness: 9, // length of pane slider (numeric in pixels) 261 | defaultTCButtonThickness: 20, // length of scroll +/- buttons (numeric in pixels) 262 | defaultTCThumbThickness: 15, // length of thumb (numeric in pixels) 263 | 264 | //*** SocialCalc.CreateTableControl 265 | 266 | TCmainStyle: "backgroundColor:#EEE;", // if present, pseudo style (text-align is textAlign) for main div of a table control 267 | TCmainClass: "", // if present, the CSS class of the main div for a table control 268 | TCendcapStyle: "backgroundColor:#FFF;", // backgroundColor may be used while waiting for image that may not come 269 | TCendcapClass: "", 270 | TCpanesliderStyle: "backgroundColor:#CCC;", 271 | TCpanesliderClass: "", 272 | s_panesliderTooltiph: "Drag to lock pane vertically", // tooltip for horizontal table control pane slider 273 | s_panesliderTooltipv: "Drag to lock pane horizontally", 274 | TClessbuttonStyle: "backgroundColor:#AAA;", 275 | TClessbuttonClass: "", 276 | TClessbuttonRepeatWait: 300, // in milliseconds 277 | TClessbuttonRepeatInterval: 20,//100, // in milliseconds 278 | TCmorebuttonStyle: "backgroundColor:#AAA;", 279 | TCmorebuttonClass: "", 280 | TCmorebuttonRepeatWait: 300, // in milliseconds 281 | TCmorebuttonRepeatInterval: 20,//100, // in milliseconds 282 | TCscrollareaStyle: "backgroundColor:#DDD;", 283 | TCscrollareaClass: "", 284 | TCscrollareaRepeatWait: 500, // in milliseconds 285 | TCscrollareaRepeatInterval: 100, // in milliseconds 286 | TCthumbClass: "", 287 | TCthumbStyle: "backgroundColor:#CCC;", 288 | 289 | //*** SocialCalc.TCPSDragFunctionStart 290 | 291 | TCPStrackinglineClass: "", // at least one of class/style for pane slider tracking line display in table control 292 | TCPStrackinglineStyle: "overflow:hidden;position:absolute;zIndex:100;", 293 | // if present, pseudo style (text-align is textAlign) 294 | TCPStrackinglineThickness: "2px", // narrow dimension of trackling line (string with units) 295 | 296 | 297 | //*** SocialCalc.TCTDragFunctionStart 298 | 299 | TCTDFSthumbstatusvClass: "", // at least one of class/style for vertical thumb dragging status display in table control 300 | TCTDFSthumbstatusvStyle: "height:20px;width:auto;border:3px solid #808080;overflow:hidden;"+ 301 | "backgroundColor:#FFF;fontSize:small;position:absolute;zIndex:100;", 302 | // if present, pseudo style (text-align is textAlign) 303 | TCTDFSthumbstatushClass: "", // at least one of class/style for horizontal thumb dragging status display in table control 304 | TCTDFSthumbstatushStyle: "height:20px;width:auto;border:1px solid black;padding:2px;"+ 305 | "backgroundColor:#FFF;fontSize:small;position:absolute;zIndex:100;", 306 | // if present, pseudo style (text-align is textAlign) 307 | TCTDFSthumbstatusrownumClass: "", // at least one of class/style for thumb dragging status display in table control 308 | TCTDFSthumbstatusrownumStyle: "color:#FFF;background-color:#808080;font-size:small;white-space:nowrap;padding:3px;", // if present, real style 309 | TCTDFStopOffsetv: 0, // offsets for thumbstatus display while dragging 310 | TCTDFSleftOffsetv: -80, 311 | s_TCTDFthumbstatusPrefixv: "Row ", // Text Control Drag Function text before row number 312 | TCTDFStopOffseth: -30, 313 | TCTDFSleftOffseth: 0, 314 | s_TCTDFthumbstatusPrefixh: "Col ", // Text Control Drag Function text before col number 315 | 316 | //*** SocialCalc.TooltipInfo 317 | 318 | // Note: These two values are used to set the TooltipInfo initial values when the code is first read in. 319 | // Modifying them here after loading has no effect -- you need to modify SocialCalc.TooltipInfo directly 320 | // to dynamically set them. This is different than most other constants which may be modified until use. 321 | 322 | TooltipOffsetX: 2, // offset in pixels from mouse position (to right on left side of screen, to left on right) 323 | TooltipOffsetY: 10, // offset in pixels above mouse position for lower edge 324 | 325 | //*** SocialCalc.TooltipDisplay 326 | 327 | TDpopupElementClass: "", // at least one of class/style for tooltip display 328 | TDpopupElementStyle: "border:1px solid black;padding:1px 2px 2px 2px;textAlign:center;backgroundColor:#FFF;"+ 329 | "fontSize:7pt;fontFamily:Verdana,Arial,Helvetica,sans-serif;"+ 330 | "position:absolute;width:auto;zIndex:110;", 331 | // if present, pseudo style (text-align is textAlign) 332 | 333 | 334 | // 335 | // SocialCalc Spreadsheet Control module, socialcalcspreadsheetcontrol.js: 336 | // 337 | 338 | //*** SocialCalc.SpreadsheetControl 339 | 340 | SCToolbarbackground: "background-color:#404040;", 341 | SCTabbackground: "background-color:#CCC;", 342 | SCTabselectedCSS: "font-size:small;padding:6px 30px 6px 8px;color:#FFF;background-color:#404040;cursor:default;border-right:1px solid #CCC;", 343 | SCTabplainCSS: "font-size:small;padding:6px 30px 6px 8px;color:#FFF;background-color:#808080;cursor:default;border-right:1px solid #CCC;", 344 | SCToolbartext: "font-size:x-small;font-weight:bold;color:#FFF;padding-bottom:4px;", 345 | 346 | SCFormulabarheight: 30, // in pixels, will contain a text input box 347 | 348 | SCStatuslineheight: 20, // in pixels 349 | SCStatuslineCSS: "font-size:10px;padding:3px 0px;", 350 | 351 | // Constants for default Format tab (settings) 352 | // 353 | // *** EVEN THOUGH THESE DON'T START WITH s_: *** 354 | // 355 | // These should be carefully checked for localization. Make sure you understand what they do and how they work! 356 | // The first part of "first:second|first:second|..." is what is displayed and the second is the value to be used. 357 | // The value is normally not translated -- only the displayed part. The [cancel], [break], etc., are not translated -- 358 | // they are commands to SocialCalc.SettingsControls.PopupListInitialize 359 | 360 | SCFormatNumberFormats: "[cancel]:|[break]:|%loc!Default!:|[custom]:|%loc!Automatic!:general|%loc!Auto w/ commas!:[,]General|[break]:|"+ 361 | "00:00|000:000|0000:0000|00000:00000|[break]:|%loc!Formula!:formula|%loc!Hidden!:hidden|[newcol]:"+ 362 | "1234:0|1,234:#,##0|1,234.5:#,##0.0|1,234.56:#,##0.00|1,234.567:#,##0.000|1,234.5678:#,##0.0000|"+ 363 | "[break]:|1,234%:#,##0%|1,234.5%:#,##0.0%|1,234.56%:#,##0.00%|"+ 364 | "[newcol]:|$1,234:$#,##0|$1,234.5:$#,##0.0|$1,234.56:$#,##0.00|[break]:|"+ 365 | "(1,234):#,##0_);(#,##0)|(1,234.5):#,##0.0_);(#,##0.0)|(1,234.56):#,##0.00_);(#,##0.00)|[break]:|"+ 366 | "($1,234):#,##0_);($#,##0)|($1,234.5):$#,##0.0_);($#,##0.0)|($1,234.56):$#,##0.00_);($#,##0.00)|"+ 367 | "[newcol]:|1/4/06:m/d/yy|01/04/2006:mm/dd/yyyy|2006-01-04:yyyy-mm-dd|4-Jan-06:d-mmm-yy|04-Jan-2006:dd-mmm-yyyy|January 4, 2006:mmmm d, yyyy|"+ 368 | "[break]:|1\\c23:h:mm|1\\c23 PM:h:mm AM/PM|1\\c23\\c45:h:mm:ss|01\\c23\\c45:hh:mm:ss|26\\c23 (h\\cm):[hh]:mm|69\\c45 (m\\cs):[mm]:ss|69 (s):[ss]|"+ 369 | "[newcol]:|2006-01-04 01\\c23\\c45:yyyy-mm-dd hh:mm:ss|January 4, 2006:mmmm d, yyyy hh:mm:ss|Wed:ddd|Wednesday:dddd|", 370 | SCFormatTextFormats: "[cancel]:|[break]:|%loc!Default!:|[custom]:|%loc!Automatic!:general|%loc!Plain Text!:text-plain|"+ 371 | "HTML:text-html|%loc!Wikitext!:text-wiki|%loc!Link!:text-link|%loc!Formula!:formula|%loc!Hidden!:hidden|", 372 | SCFormatPadsizes: "[cancel]:|[break]:|%loc!Default!:|[custom]:|%loc!No padding!:0px|"+ 373 | "[newcol]:|1 pixel:1px|2 pixels:2px|3 pixels:3px|4 pixels:4px|5 pixels:5px|"+ 374 | "6 pixels:6px|7 pixels:7px|8 pixels:8px|[newcol]:|9 pixels:9px|10 pixels:10px|11 pixels:11px|"+ 375 | "12 pixels:12px|13 pixels:13px|14 pixels:14px|16 pixels:16px|"+ 376 | "18 pixels:18px|[newcol]:|20 pixels:20px|22 pixels:22px|24 pixels:24px|28 pixels:28px|36 pixels:36px|", 377 | SCFormatFontsizes: "[cancel]:|[break]:|%loc!Default!:|[custom]:|X-Small:x-small|Small:small|Medium:medium|Large:large|X-Large:x-large|"+ 378 | "[newcol]:|6pt:6pt|7pt:7pt|8pt:8pt|9pt:9pt|10pt:10pt|11pt:11pt|12pt:12pt|14pt:14pt|16pt:16pt|"+ 379 | "[newcol]:|18pt:18pt|20pt:20pt|22pt:22pt|24pt:24pt|28pt:28pt|36pt:36pt|48pt:48pt|72pt:72pt|"+ 380 | "[newcol]:|8 pixels:8px|9 pixels:9px|10 pixels:10px|11 pixels:11px|"+ 381 | "12 pixels:12px|13 pixels:13px|14 pixels:14px|[newcol]:|16 pixels:16px|"+ 382 | "18 pixels:18px|20 pixels:20px|22 pixels:22px|24 pixels:24px|28 pixels:28px|36 pixels:36px|", 383 | SCFormatFontfamilies: "[cancel]:|[break]:|%loc!Default!:|[custom]:|Verdana:Verdana,Arial,Helvetica,sans-serif|"+ 384 | "Arial:arial,helvetica,sans-serif|Courier:'Courier New',Courier,monospace|", 385 | SCFormatFontlook: "[cancel]:|[break]:|%loc!Default!:|%loc!Normal!:normal normal|%loc!Bold!:normal bold|%loc!Italic!:italic normal|"+ 386 | "%loc!Bold Italic!:italic bold", 387 | SCFormatTextAlignhoriz: "[cancel]:|[break]:|%loc!Default!:|%loc!Left!:left|%loc!Center!:center|%loc!Right!:right|", 388 | SCFormatNumberAlignhoriz: "[cancel]:|[break]:|%loc!Default!:|%loc!Left!:left|%loc!Center!:center|%loc!Right!:right|", 389 | SCFormatAlignVertical: "[cancel]:|[break]:|%loc!Default!:|%loc!Top!:top|%loc!Middle!:middle|%loc!Bottom!:bottom|", 390 | SCFormatColwidth: "[cancel]:|[break]:|%loc!Default!:|[custom]:|[newcol]:|"+ 391 | "20 pixels:20|40:40|60:60|80:80|100:100|120:120|140:140|160:160|"+ 392 | "[newcol]:|180 pixels:180|200:200|220:220|240:240|260:260|280:280|300:300|", 393 | SCFormatRecalc: "[cancel]:|[break]:|%loc!Auto!:|%loc!Manual!:off|", 394 | SCFormatUserMaxCol: "[cancel]:|[break]:|%loc!Default!:|[custom]:|[newcol]:|"+ 395 | "Unlimited:0|10:10|20:20|30:30|40:40|50:50|60:60|80:80|100:100|", 396 | SCFormatUserMaxRow: "[cancel]:|[break]:|%loc!Default!:|[custom]:|[newcol]:|"+ 397 | "Unlimited:0|10:10|20:20|30:30|40:40|50:50|60:60|80:80|100:100|", 398 | 399 | //*** SocialCalc.InitializeSpreadsheetControl 400 | 401 | ISCButtonBorderNormal: "#404040", 402 | ISCButtonBorderHover: "#999", 403 | ISCButtonBorderDown: "#FFF", 404 | ISCButtonDownBackground: "#888", 405 | 406 | //*** SocialCalc.SettingsControls.PopupListInitialize 407 | 408 | s_PopupListCancel: "[Cancel]", 409 | s_PopupListCustom: "Custom", 410 | 411 | // *** 412 | // 413 | // s_loc_ constants accessed by SocialCalc.LocalizeString and SocialCalc.LocalizeSubstrings 414 | // 415 | // Used extensively by socialcalcspreadsheetcontrol.js 416 | // 417 | // *** 418 | 419 | s_loc_align_center: "Align Center", 420 | s_loc_align_left: "Align Left", 421 | s_loc_align_right: "Align Right", 422 | s_loc_alignment: "Alignment", 423 | s_loc_audit: "Audit", 424 | s_loc_audit_trail_this_session: "Audit Trail This Session", 425 | s_loc_auto: "Auto", 426 | s_loc_auto_sum: "Auto Sum", 427 | s_loc_auto_wX_commas: "Auto w/ commas", 428 | s_loc_automatic: "Automatic", 429 | s_loc_background: "Background", 430 | s_loc_bold: "Bold", 431 | s_loc_bold_XampX_italics: "Bold & Italics", 432 | s_loc_bold_italic: "Bold Italic", 433 | s_loc_borders: "Borders", 434 | s_loc_borders_off: "Borders Off", 435 | s_loc_borders_on: "Borders On", 436 | s_loc_bottom: "Bottom", 437 | s_loc_bottom_border: "Bottom Border", 438 | s_loc_cell_settings: "CELL SETTINGS", 439 | s_loc_csv_format: "CSV format", 440 | s_loc_cancel: "Cancel", 441 | s_loc_category: "Category", 442 | s_loc_center: "Center", 443 | s_loc_clear: "Clear", 444 | s_loc_clear_socialcalc_clipboard: "Clear SocialCalc Clipboard", 445 | s_loc_clipboard: "Clipboard", 446 | s_loc_color: "Color", 447 | s_loc_column_: "Column ", 448 | s_loc_comment: "Comment", 449 | s_loc_copy: "Copy", 450 | s_loc_custom: "Custom", 451 | s_loc_cut: "Cut", 452 | s_loc_default: "Default", 453 | s_loc_default_alignment: "Default Alignment", 454 | s_loc_default_column_width: "Default Column Width", 455 | s_loc_default_font: "Default Font", 456 | s_loc_default_format: "Default Format", 457 | s_loc_default_padding: "Default Padding", 458 | s_loc_delete: "Delete", 459 | s_loc_delete_column: "Delete Column", 460 | s_loc_delete_contents: "Delete Contents", 461 | s_loc_delete_row: "Delete Row", 462 | s_loc_description: "Description", 463 | s_loc_display_clipboard_in: "Display Clipboard in", 464 | s_loc_down: "Down", 465 | s_loc_edit: "Edit", 466 | s_loc_existing_names: "Existing Names", 467 | s_loc_family: "Family", 468 | s_loc_fill_down: "Fill Down", 469 | s_loc_fill_right: "Fill Right", 470 | s_loc_font: "Font", 471 | s_loc_format: "Format", 472 | s_loc_formula: "Formula", 473 | s_loc_function_list: "Function List", 474 | s_loc_functions: "Functions", 475 | s_loc_grid: "Grid", 476 | s_loc_hidden: "Hidden", 477 | s_loc_horizontal: "Horizontal", 478 | s_loc_insert_column: "Insert Column", 479 | s_loc_insert_row: "Insert Row", 480 | s_loc_italic: "Italic", 481 | s_loc_last_sort: "Last Sort", 482 | s_loc_left: "Left", 483 | s_loc_left_border: "Left Border", 484 | s_loc_link: "Link", 485 | s_loc_link_input_box: "Link Input Box", 486 | s_loc_list: "List", 487 | s_loc_load_socialcalc_clipboard_with_this: "Load SocialCalc Clipboard With This", 488 | s_loc_major_sort: "Major Sort", 489 | s_loc_manual: "Manual", 490 | s_loc_merge_cells: "Merge Cells", 491 | s_loc_middle: "Middle", 492 | s_loc_minor_sort: "Minor Sort", 493 | s_loc_move_insert: "Move Insert", 494 | s_loc_move_paste: "Move Paste", 495 | s_loc_multiXline_input_box: "Multi-line Input Box", 496 | s_loc_name: "Name", 497 | s_loc_names: "Names", 498 | s_loc_no_padding: "No padding", 499 | s_loc_normal: "Normal", 500 | s_loc_number: "Number", 501 | s_loc_number_horizontal: "Number Horizontal", 502 | s_loc_ok: "OK", 503 | s_loc_padding: "Padding", 504 | s_loc_page_name: "Page Name", 505 | s_loc_paste: "Paste", 506 | s_loc_paste_formats: "Paste Formats", 507 | s_loc_plain_text: "Plain Text", 508 | s_loc_recalc: "Recalc", 509 | s_loc_recalculation: "Recalculation", 510 | s_loc_redo: "Redo", 511 | s_loc_right: "Right", 512 | s_loc_right_border: "Right Border", 513 | s_loc_sheet_settings: "SHEET SETTINGS", 514 | s_loc_save: "Save", 515 | s_loc_save_to: "Save to", 516 | s_loc_set_cell_contents: "Set Cell Contents", 517 | s_loc_set_cells_to_sort: "Set Cells To Sort", 518 | s_loc_set_value_to: "Set Value To", 519 | s_loc_set_to_link_format: "Set to Link format", 520 | s_loc_setXclear_move_from: "Set/Clear Move From", 521 | s_loc_show_cell_settings: "Show Cell Settings", 522 | s_loc_show_sheet_settings: "Show Sheet Settings", 523 | s_loc_show_in_new_browser_window: "Show in new browser window", 524 | s_loc_size: "Size", 525 | s_loc_socialcalcXsave_format: "SocialCalc-save format", 526 | s_loc_sort: "Sort", 527 | s_loc_sort_: "Sort ", 528 | s_loc_sort_cells: "Sort Cells", 529 | s_loc_swap_colors: "Swap Colors", 530 | s_loc_tabXdelimited_format: "Tab-delimited format", 531 | s_loc_text: "Text", 532 | s_loc_text_horizontal: "Text Horizontal", 533 | s_loc_this_is_aXbrXsample: "This is a
sample", 534 | s_loc_top: "Top", 535 | s_loc_top_border: "Top Border", 536 | s_loc_undone_steps: "UNDONE STEPS", 537 | s_loc_url: "URL", 538 | s_loc_undo: "Undo", 539 | s_loc_unmerge_cells: "Unmerge Cells", 540 | s_loc_up: "Up", 541 | s_loc_value: "Value", 542 | s_loc_vertical: "Vertical", 543 | s_loc_wikitext: "Wikitext", 544 | s_loc_workspace: "Workspace", 545 | s_loc_XnewX: "[New]", 546 | s_loc_XnoneX: "[None]", 547 | s_loc_Xselect_rangeX: "[select range]", 548 | 549 | // 550 | // SocialCalc Spreadsheet Viewer module, socialcalcviewer.js: 551 | // 552 | 553 | //*** SocialCalc.SpreadsheetViewer 554 | 555 | SVStatuslineheight: 20, // in pixels 556 | SVStatuslineCSS: "font-size:10px;padding:3px 0px;", 557 | 558 | // 559 | // SocialCalc Format Number module, formatnumber2.js: 560 | // 561 | 562 | FormatNumber_separatorchar: ",", // the thousands separator character when formatting numbers for display 563 | FormatNumber_decimalchar: ".", // the decimal separator character when formatting numbers for display 564 | FormatNumber_defaultCurrency: "$", // the currency string used if none specified 565 | 566 | // The following constants are arrays of strings with the short (3 character) and full names of days and months 567 | 568 | s_FormatNumber_daynames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], 569 | s_FormatNumber_daynames3: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], 570 | s_FormatNumber_monthnames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", 571 | "October", "November", "December"], 572 | s_FormatNumber_monthnames3: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], 573 | s_FormatNumber_am: "AM", 574 | s_FormatNumber_am1: "A", 575 | s_FormatNumber_pm: "PM", 576 | s_FormatNumber_pm1: "P", 577 | 578 | // 579 | // SocialCalc Spreadsheet Formula module, formula1.js: 580 | // 581 | 582 | s_parseerrexponent: "Improperly formed number exponent", 583 | s_parseerrchar: "Unexpected character in formula", 584 | s_parseerrstring: "Improperly formed string", 585 | s_parseerrspecialvalue: "Improperly formed special value", 586 | s_parseerrtwoops: "Error in formula (two operators inappropriately in a row)", 587 | s_parseerrmissingopenparen: "Missing open parenthesis in list with comma(s). ", 588 | s_parseerrcloseparennoopen: "Closing parenthesis without open parenthesis. ", 589 | s_parseerrmissingcloseparen: "Missing close parenthesis. ", 590 | s_parseerrmissingoperand: "Missing operand. ", 591 | s_parseerrerrorinformula: "Error in formula.", 592 | s_calcerrerrorvalueinformula: "Error value in formula", 593 | s_parseerrerrorinformulabadval: "Error in formula resulting in bad value", 594 | s_formularangeresult: "Formula results in range value:", 595 | s_calcerrnumericnan: "Formula results in an bad numeric value", 596 | s_calcerrnumericoverflow: "Numeric overflow", 597 | s_sheetunavailable: "Sheet unavailable:", // when FindSheetInCache returns null 598 | s_calcerrcellrefmissing: "Cell reference missing when expected.", 599 | s_calcerrsheetnamemissing: "Sheet name missing when expected.", 600 | s_circularnameref: "Circular name reference to name", 601 | s_calcerrunknownname: "Unknown name", 602 | s_calcerrincorrectargstofunction: "Incorrect arguments to function", 603 | s_sheetfuncunknownfunction: "Unknown function", 604 | s_sheetfunclnarg: "LN argument must be greater than 0", 605 | s_sheetfunclog10arg: "LOG10 argument must be greater than 0", 606 | s_sheetfunclogsecondarg: "LOG second argument must be numeric greater than 0", 607 | s_sheetfunclogfirstarg: "LOG first argument must be greater than 0", 608 | s_sheetfuncroundsecondarg: "ROUND second argument must be numeric", 609 | s_sheetfuncddblife: "DDB life must be greater than 1", 610 | s_sheetfuncslnlife: "SLN life must be greater than 1", 611 | 612 | // Function definition text 613 | 614 | s_fdef_ABS: 'Absolute value function. ', 615 | s_fdef_ACOS: 'Trigonometric arccosine function. ', 616 | s_fdef_AND: 'True if all arguments are true. ', 617 | s_fdef_ASIN: 'Trigonometric arcsine function. ', 618 | s_fdef_ATAN: 'Trigonometric arctan function. ', 619 | s_fdef_ATAN2: 'Trigonometric arc tangent function (result is in radians). ', 620 | s_fdef_AVERAGE: 'Averages the values. ', 621 | s_fdef_CHOOSE: 'Returns the value specified by the index. The values may be ranges of cells. ', 622 | s_fdef_COLUMNS: 'Returns the number of columns in the range. ', 623 | s_fdef_COS: 'Trigonometric cosine function (value is in radians). ', 624 | s_fdef_COUNT: 'Counts the number of numeric values, not blank, text, or error. ', 625 | s_fdef_COUNTA: 'Counts the number of non-blank values. ', 626 | s_fdef_COUNTBLANK: 'Counts the number of blank values. (Note: "" is not blank.) ', 627 | s_fdef_COUNTIF: 'Counts the number of number of cells in the range that meet the criteria. The criteria may be a value ("x", 15, 1+3) or a test (>25). ', 628 | s_fdef_DATE: 'Returns the appropriate date value given numbers for year, month, and day. For example: DATE(2006,2,1) for February 1, 2006. Note: In this program, day "1" is December 31, 1899 and the year 1900 is not a leap year. Some programs use January 1, 1900, as day "1" and treat 1900 as a leap year. In both cases, though, dates on or after March 1, 1900, are the same. ', 629 | s_fdef_DAVERAGE: 'Averages the values in the specified field in records that meet the criteria. ', 630 | s_fdef_DAY: 'Returns the day of month for a date value. ', 631 | s_fdef_DCOUNT: 'Counts the number of numeric values, not blank, text, or error, in the specified field in records that meet the criteria. ', 632 | s_fdef_DCOUNTA: 'Counts the number of non-blank values in the specified field in records that meet the criteria. ', 633 | s_fdef_DDB: 'Returns the amount of depreciation at the given period of time (the default factor is 2 for double-declining balance). ', 634 | s_fdef_DEGREES: 'Converts value in radians into degrees. ', 635 | s_fdef_DGET: 'Returns the value of the specified field in the single record that meets the criteria. ', 636 | s_fdef_DMAX: 'Returns the maximum of the numeric values in the specified field in records that meet the criteria. ', 637 | s_fdef_DMIN: 'Returns the maximum of the numeric values in the specified field in records that meet the criteria. ', 638 | s_fdef_DPRODUCT: 'Returns the result of multiplying the numeric values in the specified field in records that meet the criteria. ', 639 | s_fdef_DSTDEV: 'Returns the sample standard deviation of the numeric values in the specified field in records that meet the criteria. ', 640 | s_fdef_DSTDEVP: 'Returns the standard deviation of the numeric values in the specified field in records that meet the criteria. ', 641 | s_fdef_DSUM: 'Returns the sum of the numeric values in the specified field in records that meet the criteria. ', 642 | s_fdef_DVAR: 'Returns the sample variance of the numeric values in the specified field in records that meet the criteria. ', 643 | s_fdef_DVARP: 'Returns the variance of the numeric values in the specified field in records that meet the criteria. ', 644 | s_fdef_EVEN: 'Rounds the value up in magnitude to the nearest even integer. ', 645 | s_fdef_EXACT: 'Returns "true" if the values are exactly the same, including case, type, etc. ', 646 | s_fdef_EXP: 'Returns e raised to the value power. ', 647 | s_fdef_FACT: 'Returns factorial of the value. ', 648 | s_fdef_FALSE: 'Returns the logical value "false". ', 649 | s_fdef_FIND: 'Returns the starting position within string2 of the first occurrence of string1 at or after "start". If start is omitted, 1 is assumed. ', 650 | s_fdef_FV: 'Returns the future value of repeated payments of money invested at the given rate for the specified number of periods, with optional present value (default 0) and payment type (default 0 = at end of period, 1 = beginning of period). ', 651 | s_fdef_HLOOKUP: 'Look for the matching value for the given value in the range and return the corresponding value in the cell specified by the row offset. If rangelookup is 1 (the default) and not 0, match if within numeric brackets (match<=value) instead of exact match. ', 652 | s_fdef_HOUR: 'Returns the hour portion of a time or date/time value. ', 653 | s_fdef_IF: 'Results in true-value if logical-expression is TRUE or non-zero, otherwise results in false-value. ', 654 | s_fdef_INDEX: 'Returns a cell or range reference for the specified row and column in the range. If range is 1-dimensional, then only one of rownum or colnum are needed. If range is 2-dimensional and rownum or colnum are zero, a reference to the range of just the specified column or row is returned. You can use the returned reference value in a range, e.g., sum(A1:INDEX(A2:A10,4)). ', 655 | s_fdef_INT: 'Returns the value rounded down to the nearest integer (towards -infinity). ', 656 | s_fdef_IRR: 'Returns the interest rate at which the cash flows in the range have a net present value of zero. Uses an iterative process that will return #NUM! error if it does not converge. There may be more than one possible solution. Providing the optional guess value may help in certain situations where it does not converge or finds an inappropriate solution (the default guess is 10%). ', 657 | s_fdef_ISBLANK: 'Returns "true" if the value is a reference to a blank cell. ', 658 | s_fdef_ISERR: 'Returns "true" if the value is of type "Error" but not "NA". ', 659 | s_fdef_ISERROR: 'Returns "true" if the value is of type "Error". ', 660 | s_fdef_ISLOGICAL: 'Returns "true" if the value is of type "Logical" (true/false). ', 661 | s_fdef_ISNA: 'Returns "true" if the value is the error type "NA". ', 662 | s_fdef_ISNONTEXT: 'Returns "true" if the value is not of type "Text". ', 663 | s_fdef_ISNUMBER: 'Returns "true" if the value is of type "Number" (including logical values). ', 664 | s_fdef_ISTEXT: 'Returns "true" if the value is of type "Text". ', 665 | s_fdef_LEFT: 'Returns the specified number of characters from the text value. If count is omitted, 1 is assumed. ', 666 | s_fdef_LEN: 'Returns the number of characters in the text value. ', 667 | s_fdef_LN: 'Returns the natural logarithm of the value. ', 668 | s_fdef_LOG: 'Returns the logarithm of the value using the specified base. ', 669 | s_fdef_LOG10: 'Returns the base 10 logarithm of the value. ', 670 | s_fdef_LOWER: 'Returns the text value with all uppercase characters converted to lowercase. ', 671 | s_fdef_MATCH: 'Look for the matching value for the given value in the range and return position (the first is 1) in that range. If rangelookup is 1 (the default) and not 0, match if within numeric brackets (match<=value) instead of exact match. If rangelookup is -1, act like 1 but the bracket is match>=value. ', 672 | s_fdef_MAX: 'Returns the maximum of the numeric values. ', 673 | s_fdef_MID: 'Returns the specified number of characters from the text value starting from the specified position. ', 674 | s_fdef_MIN: 'Returns the minimum of the numeric values. ', 675 | s_fdef_MINUTE: 'Returns the minute portion of a time or date/time value. ', 676 | s_fdef_MOD: 'Returns the remainder of the first value divided by the second. ', 677 | s_fdef_MONTH: 'Returns the month part of a date value. ', 678 | s_fdef_N: 'Returns the value if it is a numeric value otherwise an error. ', 679 | s_fdef_NA: 'Returns the #N/A error value which propagates through most operations. ', 680 | s_fdef_NOT: 'Returns FALSE if value is true, and TRUE if it is false. ', 681 | s_fdef_NOW: 'Returns the current date/time. ', 682 | s_fdef_NPER: 'Returns the number of periods at which payments invested each period at the given rate with optional future value (default 0) and payment type (default 0 = at end of period, 1 = beginning of period) has the given present value. ', 683 | s_fdef_NPV: 'Returns the net present value of cash flows (which may be individual values and/or ranges) at the given rate. The flows are positive if income, negative if paid out, and are assumed at the end of each period. ', 684 | s_fdef_ODD: 'Rounds the value up in magnitude to the nearest odd integer. ', 685 | s_fdef_OR: 'True if any argument is true ', 686 | s_fdef_PI: 'The value 3.1415926... ', 687 | s_fdef_PMT: 'Returns the amount of each payment that must be invested at the given rate for the specified number of periods to have the specified present value, with optional future value (default 0) and payment type (default 0 = at end of period, 1 = beginning of period). ', 688 | s_fdef_POWER: 'Returns the first value raised to the second value power. ', 689 | s_fdef_PRODUCT: 'Returns the result of multiplying the numeric values. ', 690 | s_fdef_PROPER: 'Returns the text value with the first letter of each word converted to uppercase and the others to lowercase. ', 691 | s_fdef_PV: 'Returns the present value of the given number of payments each invested at the given rate, with optional future value (default 0) and payment type (default 0 = at end of period, 1 = beginning of period). ', 692 | s_fdef_RADIANS: 'Converts value in degrees into radians. ', 693 | s_fdef_RATE: 'Returns the rate at which the given number of payments each invested at the given rate has the specified present value, with optional future value (default 0) and payment type (default 0 = at end of period, 1 = beginning of period). Uses an iterative process that will return #NUM! error if it does not converge. There may be more than one possible solution. Providing the optional guess value may help in certain situations where it does not converge or finds an inappropriate solution (the default guess is 10%). ', 694 | s_fdef_REPLACE: 'Returns text1 with the specified number of characters starting from the specified position replaced by text2. ', 695 | s_fdef_REPT: 'Returns the text repeated the specified number of times. ', 696 | s_fdef_RIGHT: 'Returns the specified number of characters from the text value starting from the end. If count is omitted, 1 is assumed. ', 697 | s_fdef_ROUND: 'Rounds the value to the specified number of decimal places. If precision is negative, then round to powers of 10. The default precision is 0 (round to integer). ', 698 | s_fdef_ROWS: 'Returns the number of rows in the range. ', 699 | s_fdef_SECOND: 'Returns the second portion of a time or date/time value (truncated to an integer). ', 700 | s_fdef_SIN: 'Trigonometric sine function (value is in radians) ', 701 | s_fdef_SLN: 'Returns the amount of depreciation at each period of time using the straight-line method. ', 702 | s_fdef_SQRT: 'Square root of the value ', 703 | s_fdef_STDEV: 'Returns the sample standard deviation of the numeric values. ', 704 | s_fdef_STDEVP: 'Returns the standard deviation of the numeric values. ', 705 | s_fdef_SUBSTITUTE: 'Returns text1 with the all occurrences of oldtext replaced by newtext. If "occurrence" is present, then only that occurrence is replaced. ', 706 | s_fdef_SUM: 'Adds the numeric values. The values to the sum function may be ranges in the form similar to A1:B5. ', 707 | s_fdef_SUMIF: 'Sums the numeric values of cells in the range that meet the criteria. The criteria may be a value ("x", 15, 1+3) or a test (>25). If range2 is present, then range1 is tested and the corresponding range2 value is summed. ', 708 | s_fdef_SYD: 'Depreciation by Sum of Year\'s Digits method. ', 709 | s_fdef_T: 'Returns the text value or else a null string. ', 710 | s_fdef_TAN: 'Trigonometric tangent function (value is in radians) ', 711 | s_fdef_TIME: 'Returns the time value given the specified hour, minute, and second. ', 712 | s_fdef_TODAY: 'Returns the current date (an integer). Note: In this program, day "1" is December 31, 1899 and the year 1900 is not a leap year. Some programs use January 1, 1900, as day "1" and treat 1900 as a leap year. In both cases, though, dates on or after March 1, 1900, are the same. ', 713 | s_fdef_TRIM: 'Returns the text value with leading, trailing, and repeated spaces removed. ', 714 | s_fdef_TRUE: 'Returns the logical value "true". ', 715 | s_fdef_TRUNC: 'Truncates the value to the specified number of decimal places. If precision is negative, truncate to powers of 10. ', 716 | s_fdef_UPPER: 'Returns the text value with all lowercase characters converted to uppercase. ', 717 | s_fdef_VALUE: 'Converts the specified text value into a numeric value. Various forms that look like numbers (including digits followed by %, forms that look like dates, etc.) are handled. This may not handle all of the forms accepted by other spreadsheets and may be locale dependent. ', 718 | s_fdef_VAR: 'Returns the sample variance of the numeric values. ', 719 | s_fdef_VARP: 'Returns the variance of the numeric values. ', 720 | s_fdef_VLOOKUP: 'Look for the matching value for the given value in the range and return the corresponding value in the cell specified by the column offset. If rangelookup is 1 (the default) and not 0, match if within numeric brackets (match>=value) instead of exact match. ', 721 | s_fdef_WEEKDAY: 'Returns the day of week specified by the date value. If type is 1 (the default), Sunday is day and Saturday is day 7. If type is 2, Monday is day 1 and Sunday is day 7. If type is 3, Monday is day 0 and Sunday is day 6. ', 722 | s_fdef_YEAR: 'Returns the year part of a date value. ', 723 | s_fdef_SUMPRODUCT: 'Sums the pairwise products of 2 or more ranges. The ranges must be of equal length.', 724 | s_fdef_CEILING: 'Rounds the given number up to the nearest integer or multiple of significance. Significance is the value to whose multiple of ten the value is to be rounded up (.01, .1, 1, 10, etc.)', 725 | s_fdef_FLOOR: 'Rounds the given number down to the nearest multiple of significance. Significance is the value to whose multiple of ten the number is to be rounded down (.01, .1, 1, 10, etc.)', 726 | 727 | s_farg_v: "value", 728 | s_farg_vn: "value1, value2, ...", 729 | s_farg_xy: "valueX, valueY", 730 | s_farg_choose: "index, value1, value2, ...", 731 | s_farg_range: "range", 732 | s_farg_rangec: "range, criteria", 733 | s_farg_date: "year, month, day", 734 | s_farg_dfunc: "databaserange, fieldname, criteriarange", 735 | s_farg_ddb: "cost, salvage, lifetime, period, [factor]", 736 | s_farg_find: "string1, string2, [start]", 737 | s_farg_fv: "rate, n, payment, [pv, [paytype]]", 738 | s_farg_hlookup: "value, range, row, [rangelookup]", 739 | s_farg_iffunc: "logical-expression, true-value, [false-value]", 740 | s_farg_index: "range, rownum, colnum", 741 | s_farg_irr: "range, [guess]", 742 | s_farg_tc: "text, count", 743 | s_farg_log: "value, base", 744 | s_farg_match: "value, range, [rangelookup]", 745 | s_farg_mid: "text, start, length", 746 | s_farg_nper: "rate, payment, pv, [fv, [paytype]]", 747 | s_farg_npv: "rate, value1, value2, ...", 748 | s_farg_pmt: "rate, n, pv, [fv, [paytype]]", 749 | s_farg_pv: "rate, n, payment, [fv, [paytype]]", 750 | s_farg_rate: "n, payment, pv, [fv, [paytype, [guess]]]", 751 | s_farg_replace: "text1, start, length, text2", 752 | s_farg_vp: "value, [precision]", 753 | s_farg_valpre: "value, precision", 754 | s_farg_csl: "cost, salvage, lifetime", 755 | s_farg_cslp: "cost, salvage, lifetime, period", 756 | s_farg_subs: "text1, oldtext, newtext, [occurrence]", 757 | s_farg_sumif: "range1, criteria, [range2]", 758 | s_farg_hms: "hour, minute, second", 759 | s_farg_txt: "text", 760 | s_farg_vlookup: "value, range, col, [rangelookup]", 761 | s_farg_weekday: "date, [type]", 762 | s_farg_dt: "date", 763 | s_farg_rangen: "range1, range2, ...", 764 | s_farg_vsig: 'value, [significance]', 765 | 766 | function_classlist: ["all", "stat", "lookup", "datetime", "financial", "test", "math", "text"], // order of function classes 767 | 768 | s_fclass_all: "All", 769 | s_fclass_stat: "Statistics", 770 | s_fclass_lookup: "Lookup", 771 | s_fclass_datetime: "Date & Time", 772 | s_fclass_financial: "Financial", 773 | s_fclass_test: "Test", 774 | s_fclass_math: "Math", 775 | s_fclass_text: "Text", 776 | 777 | lastone: null 778 | 779 | }; 780 | 781 | // Default classnames for use with SocialCalc.ConstantsSetClasses: 782 | 783 | SocialCalc.ConstantsDefaultClasses = { 784 | defaultComment: "", 785 | defaultCommentNoGrid: "", 786 | defaultHighlightTypeCursor: "", 787 | defaultHighlightTypeRange: "", 788 | defaultColname: "", 789 | defaultSelectedColname: "", 790 | defaultRowname: "", 791 | defaultSelectedRowname: "", 792 | defaultUpperLeft: "", 793 | defaultSkippedCell: "", 794 | defaultPaneDivider: "", 795 | cteGriddiv: "", // this one has no Style version with it 796 | defaultInputEcho: {classname: "", style: "filter:alpha(opacity=90);opacity:.9;"}, // so FireFox won't show warning 797 | TCmain: "", 798 | TCendcap: "", 799 | TCpaneslider: "", 800 | TClessbutton: "", 801 | TCmorebutton: "", 802 | TCscrollarea: "", 803 | TCthumb: "", 804 | TCPStrackingline: "", 805 | TCTDFSthumbstatus: "", 806 | TDpopupElement: "" 807 | }; 808 | 809 | // 810 | // SocialCalc.ConstantsSetClasses(prefix) 811 | // 812 | // This routine goes through all of the xyzClass/xyzStyle pairs and sets the Class to a default and 813 | // turns off the Style, if present. The prefix is put before each default. 814 | // The list of items to set is in SocialCalc.ConstantsDefaultClasses. The names there 815 | // correspond to the "xyz" parts. If there is a value, it is the default to set. If the 816 | // default is a null, no change is made. If the default is the null string (""), the 817 | // name of the item is used (e.g., "defaultComment" would use the classname "defaultComment"). 818 | // If the default is an object, then it expects {classname: classname, style: stylestring} - this 819 | // lets you combine both. 820 | // 821 | 822 | SocialCalc.ConstantsSetClasses = function(prefix) { 823 | 824 | var defaults = SocialCalc.ConstantsDefaultClasses; 825 | var scc = SocialCalc.Constants; 826 | var item; 827 | 828 | prefix = prefix || ""; 829 | 830 | for (item in defaults) { 831 | if (typeof defaults[item] == "string") { 832 | scc[item+"Class"] = prefix + (defaults[item] || item); 833 | if (scc[item+"Style"] !== undefined) { 834 | scc[item+"Style"] = ""; 835 | } 836 | } 837 | else if (typeof defaults[item] == "object") { 838 | scc[item+"Class"] = prefix + (defaults[item].classname || item); 839 | scc[item+"Style"] = defaults[item].style; 840 | } 841 | } 842 | } 843 | 844 | // Set the image prefix on all images. 845 | 846 | SocialCalc.ConstantsSetImagePrefix = function(imagePrefix) { 847 | 848 | var scc = SocialCalc.Constants; 849 | 850 | for (var item in scc) { 851 | if (typeof scc[item] == "string") { 852 | scc[item] = scc[item].replace(scc.defaultImagePrefix, imagePrefix); 853 | } 854 | } 855 | scc.defaultImagePrefix = imagePrefix; 856 | 857 | } 858 | 859 | --------------------------------------------------------------------------------