view release on metacpan or search on metacpan
socialcalc/LICENSE.txt view on Meta::CPAN
available Covered Code of the Contributors choice. The Source Code can be in a compressed
or archival form, provided the appropriate decompression or de-archiving software is
widely available for no charge.
1.12 "You" (or "Your") means an individual or a legal entity exercising rights under, and
complying with all of the terms of, this License or a future version of this License
issued under Section 6.1. For legal entities, "You" includes any entity which controls,
is controlled by, or is under common control with You. For purposes of this definition,
"control" means (a) the power, direct or indirect, to cause the direction or management
of such entity, whether by contract or otherwise, or (b) ownership of more than fifty
percent (50%) of the outstanding shares or beneficial ownership of such entity.
2. Source Code License.
2.1 The Initial Developer Grant.
The Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive
license, subject to third party intellectual property claims:
(a) under intellectual property rights (other than patent or trademark) Licensable by
Initial Developer to use, reproduce, modify, display, perform, sublicense and distribute
socialcalc/SocialCalcServersideUtilities.pm view on Meta::CPAN
elsif ($zerovalue) {
$section = 2; # use third section for zero values
}
else {
$section = 0; # use first for positive
}
}
}
# Get values for our section
my ($sectionstart, $integerdigits, $fractiondigits, $commas, $percent, $thousandssep) =
@{%{$thisformat->{sectioninfo}->[$section]}}{qw(sectionstart integerdigits fractiondigits commas percent thousandssep)};
if ($commas > 0) { # scale by thousands
for (my $i=0; $i<$commas; $i++) {
$value /= 1000;
}
}
if ($percent > 0) { # do percent scaling
for (my $i=0; $i<$percent; $i++) {
$value *= 100;
}
}
my $decimalscale = 1; # cut down to required number of decimal digits
for (my $i=0; $i<$fractiondigits; $i++) {
$decimalscale *= 10;
}
my $scaledvalue = int($value * $decimalscale + 0.5);
$scaledvalue = $scaledvalue / $decimalscale;
socialcalc/SocialCalcServersideUtilities.pm view on Meta::CPAN
#
# %format_defs
# {"#,##0.0"}->{} # elements in the hash are one hash for each format
# {operators}->[] # array of operators from parsing the format string (each a number)
# {operands}->[] # array of corresponding operators (each usually a string)
# {sectioninfo}->[] # one hash for each section of the format
# {start}
# {integerdigits}
# {fractiondigits}
# {commas}
# {percent}
# {thousandssep}
# {hasdates}
# {hascomparison} # true if any section has [<100], etc.
#
# # # # # # # # #
sub parse_format_string {
my ($format_defs, $format_string) = @_;
socialcalc/SocialCalcServersideUtilities.pm view on Meta::CPAN
if ($lastwasinteger) {
$sectioninfo->{commas}++;
}
else {
push @{$thisformat->{operators}}, $cmd_copy;
push @{$thisformat->{operands}}, $ch;
}
}
elsif ($ch eq "%") {
$lastwasinteger = 0;
$sectioninfo->{percent}++;
push @{$thisformat->{operators}}, $cmd_copy;
push @{$thisformat->{operands}}, $ch;
}
elsif ($ch eq '"') {
$lastwasinteger = 0;
$inquote = 1;
$quotestr = "";
}
elsif ($ch eq '[') {
$lastwasinteger = 0;
socialcalc/formatnumber2.js view on Meta::CPAN
}
}
sectioninfo = thisformat.sectioninfo[section]; // look at values for our section
if (sectioninfo.commas > 0) { // scale by thousands
for (i=0; i<sectioninfo.commas; i++) {
value /= 1000;
}
}
if (sectioninfo.percent > 0) { // do percent scaling
for (i=0; i<sectioninfo.percent; i++) {
value *= 100;
}
}
decimalscale = 1; // cut down to required number of decimal digits
for (i=0; i<sectioninfo.fractiondigits; i++) {
decimalscale *= 10;
}
scaledvalue = Math.floor(value * decimalscale + 0.5);
scaledvalue = scaledvalue / decimalscale;
socialcalc/formatnumber2.js view on Meta::CPAN
format_defs
["#,##0.0"]->{} - elements in the hash are one hash for each format
.operators->[] - array of operators from parsing the format string (each a number)
.operands->[] - array of corresponding operators (each usually a string)
.sectioninfo->[] - one hash for each section of the format
.start
.integerdigits
.fractiondigits
.commas
.percent
.thousandssep
.hasdates
.hascomparison - true if any section has [<100], etc.
************************* */
SocialCalc.FormatNumber.parse_format_string = function(format_defs, format_string) {
var scfn = SocialCalc.FormatNumber;
socialcalc/formatnumber2.js view on Meta::CPAN
thisformat = {operators: [], operands: [], sectioninfo: [{}]}; // create info structure for this format
format_defs[format_string] = thisformat; // add to other format definitions
section = 0; // start with section 0
sectioninfo = thisformat.sectioninfo[section]; // get reference to info for current section
sectioninfo.sectionstart = 0; // position in operands that starts this section
sectioninfo.integerdigits = 0; // number of integer-part placeholders
sectioninfo.fractiondigits = 0; // fraction placeholders
sectioninfo.commas = 0; // commas encountered, to handle scaling
sectioninfo.percent = 0; // times to scale by 100
for (chpos=0; chpos<format_string.length; chpos++) { // parse
ch = format_string.charAt(chpos); // get next char to examine
if (inquote) {
if (ch == '"') {
inquote = 0;
thisformat.operators.push(scfn.commands.copy);
thisformat.operands.push(quotestr);
continue;
}
socialcalc/formatnumber2.js view on Meta::CPAN
if (lastwasinteger) {
sectioninfo.commas++;
}
else {
thisformat.operators.push(scfn.commands.copy);
thisformat.operands.push(ch);
}
}
else if (ch=="%") {
lastwasinteger = 0;
sectioninfo.percent++;
thisformat.operators.push(scfn.commands.copy);
thisformat.operands.push(ch);
}
else if (ch=='"') {
lastwasinteger = 0;
inquote = 1;
quotestr = "";
}
else if (ch=='[') {
lastwasinteger = 0;
socialcalc/formatnumber2.js view on Meta::CPAN
lastwasinteger = 0;
}
else if (ch==";") {
section++; // start next section
thisformat.sectioninfo[section] = {}; // create a new section
sectioninfo = thisformat.sectioninfo[section]; // get reference to info for current section
sectioninfo.sectionstart = 1 + thisformat.operators.length; // remember where it starts
sectioninfo.integerdigits = 0; // number of integer-part placeholders
sectioninfo.fractiondigits = 0; // fraction placeholders
sectioninfo.commas = 0; // commas encountered, to handle scaling
sectioninfo.percent = 0; // times to scale by 100
integerpart = 1; // reset for new section
lastwasinteger = 0;
thisformat.operators.push(scfn.commands.section);
thisformat.operands.push(ch);
}
else if (ch.toLowerCase()=="g") {
ingeneral = 1;
lastwasinteger = 0;
}
else if (ch.toLowerCase()=="a") {
socialcalc/formula1.js view on Meta::CPAN
// Each object entry is an object with specific types with result type info as follows:
//
// 'type1a': '|type2a:resulta|type2b:resultb|...
// Type of t* or n* matches any of those types not listed
// Results may be a type or the numbers 1 or 2 specifying to return type1 or type2
SocialCalc.Formula.TypeLookupTable = {
unaryminus: { 'n*': '|n*:1|', 'e*': '|e*:1|', 't*': '|t*:e#VALUE!|', 'b': '|b:n|'},
unaryplus: { 'n*': '|n*:1|', 'e*': '|e*:1|', 't*': '|t*:e#VALUE!|', 'b': '|b:n|'},
unarypercent: { 'n*': '|n:n%|n*:n|', 'e*': '|e*:1|', 't*': '|t*:e#VALUE!|', 'b': '|b:n|'},
plus: {
'n%': '|n%:n%|nd:n|nt:n|ndt:n|n$:n|n:n|n*:n|b:n|e*:2|t*:e#VALUE!|',
'nd': '|n%:n|nd:nd|nt:ndt|ndt:ndt|n$:n|n:nd|n*:n|b:n|e*:2|t*:e#VALUE!|',
'nt': '|n%:n|nd:ndt|nt:nt|ndt:ndt|n$:n|n:nt|n*:n|b:n|e*:2|t*:e#VALUE!|',
'ndt': '|n%:n|nd:ndt|nt:ndt|ndt:ndt|n$:n|n:ndt|n*:n|b:n|e*:2|t*:e#VALUE!|',
'n$': '|n%:n|nd:n|nt:n|ndt:n|n$:n$|n:n$|n*:n|b:n|e*:2|t*:e#VALUE!|',
'nl': '|n%:n|nd:n|nt:n|ndt:n|n$:n|n:n|n*:n|b:n|e*:2|t*:e#VALUE!|',
'n': '|n%:n|nd:nd|nt:nt|ndt:ndt|n$:n$|n:n|n*:n|b:n|e*:2|t*:e#VALUE!|',
'b': '|n%:n%|nd:nd|nt:nt|ndt:ndt|n$:n$|n:n|n*:n|b:n|e*:2|t*:e#VALUE!|',
't*': '|n*:e#VALUE!|t*:e#VALUE!|b:e#VALUE!|e*:2|',
socialcalc/formula1.js view on Meta::CPAN
}
// Unary plus
else if (ttext == 'P') {
value1 = operand_as_number(sheet, operand);
resulttype = lookup_result_type(value1.type, value1.type, typelookup.unaryplus);
PushOperand(resulttype, value1.value);
}
// Unary % - percent, left associative
else if (ttext == '%') {
value1 = operand_as_number(sheet, operand);
resulttype = lookup_result_type(value1.type, value1.type, typelookup.unarypercent);
PushOperand(resulttype, 0.01*value1.value);
}
// & - string concatenate
else if (ttext == '&') {
if (operand.length <= 1) { // Need at least two things on the stack...
return missingOperandError;
}
value2 = operand_as_text(sheet, operand);
socialcalc/socialcalc-3.js view on Meta::CPAN
}
else if (tvalue.match(/^[-+]?\d*(?:\.)?\d*(?:[eE][-+]?\d+)?$/)) { // general number, including E
value = tvalue - 0; // try converting to number
if (isNaN(value)) { // leave alone - catches things like plain "-"
value = rawvalue + "";
}
else {
type = "n";
}
}
else if (tvalue.match(/^[-+]?\d*(?:\.)?\d*\s*%$/)) { // percent form: 15.1%
value = (tvalue.slice(0, -1) - 0) / 100; // convert and scale
type = "n%";
}
else if (tvalue.match(/^[-+]?\$\s*\d*(?:\.)?\d*\s*$/) && tvalue.match(/\d/)) { // $ format: $1.49
value = tvalue.replace(/\$/, "") - 0;
type = "n$";
}
else if (tvalue.match(/^[-+]?(\d*,\d*)+(?:\.)?\d*$/)) { // number format ignoring commas: 1,234.49
value = tvalue.replace(/,/g, "") - 0;
type = "n";
socialcalc/third-party/wikiwyg/LICENSE view on Meta::CPAN
appropriate decompression or de-archiving software is widely
available for no charge.
1.15. "You'' (or "Your") means an individual or a legal entity
exercising rights under, and complying with all of the terms of, this
License or a future version of this License issued under Section 6.1.
For legal entities, "You'' includes any entity which controls, is
controlled by, or is under common control with You. For purposes
of this definition, "control'' means (a) the power, direct or indirect,
to cause the direction or management of such entity, whether by
contract or otherwise, or (b) ownership of more than fifty percent
(50%) of the outstanding shares or beneficial ownership of such
entity.
2. Source Code License.
2.1. The Initial Developer Grant.
The Initial Developer hereby grants You a world-wide, royalty-free,
non-exclusive license, subject to third party intellectual property
claims: