/usr/share/DisplayCAL/report/jsapi-packages.js is in dispcalgui 3.1.0.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 | /* ############################## */
/* ##### jsapi Distribution ##### */
/* ############################## */
/*
2006 Florian Hoech
Function.prototype.apply.js
adds apply method for functions in browsers without native implementation
*/
if (!Function.prototype.apply) {
Function.prototype.apply = function(o, args) {
o = o ? Object(o) : window;
o.__apply__ = this;
for (var i = 0, sargs = []; i < args.length; i ++) sargs[i] = "args[" + i + "]";
var result = eval("o.__apply__(" + sargs.join(",") + ");");
o.__apply__ = null;
return result
}
};
/* ##### Array.prototype.pop.js ##### */
/*
2006 Ash Searle
http://hexmen.com/blog/2006/12/push-and-pop/
*/
if (!Array.prototype.pop) Array.prototype.pop = function() {
// Removes the last element from an array and returns that element. This method changes the length of the array.
var n = this.length >>> 0, value;
if (n) {
value = this[--n];
delete this[n]
};
this.length = n;
return value
};
if (!Array.pop) Array.pop = function(object) {
return Array.prototype.pop.apply(object)
};
/* ##### Array.prototype.shift.js ##### */
/*
2006 Florian Hoech
Array.prototype.shift.js
adds shift method for arrays in browsers without native or incorrect implementation
*/
if (!Array.prototype.shift) Array.prototype.shift = function() {
// Removes the first element from an array and returns that element. This method changes the length of the array.
var n = this.length >>> 0, value = this[0];
for (var i = 1; i < n; i ++) this[i - 1] = this[i];
delete this[n];
this.length = n - 1 >>> 0;
return value
};
if (!Array.shift) Array.shift = function(object) {
return Array.prototype.shift.apply(object)
};
/* ##### Array.prototype.unshift.js ##### */
/*
2006 Florian Hoech
Array.prototype.unshift.js
adds unshift method for arrays in browsers without native or incorrect implementation
*/
if (!Array.prototype.unshift) Array.prototype.unshift = function() {
// Adds one or more elements to the beginning of an array and returns the new length of the array.
var n = this.length >>> 0;
for (var i = (n - 1) >>> 0; i >= 0; i --) this[i + arguments.length] = this[i];
for (var i = arguments.length - 1; i >= 0; i --) {
this[i] = arguments[i];
n = n + 1 >>> 0
};
this.length = n;
return n
};
/* ##### Array.prototype.push.js ##### */
/*
2006 Ash Searle
http://hexmen.com/blog/2006/12/push-and-pop/
*/
if (!Array.prototype.push || [].push(0) == 0) Array.prototype.push = function() {
var n = this.length >>> 0;
for (var i = 0; i < arguments.length; i++) {
this[n] = arguments[i];
n = n + 1 >>> 0
};
this.length = n;
return n
};
/* ##### Array.prototype.splice.js ##### */
/*
2006 Florian Hoech
Array.prototype.splice.js
adds splice method for arrays in browsers without native or incorrect implementation
*/
if (!Array.prototype.splice || [0].splice(0, 1) === 0) Array.prototype.splice = function(index, howMany) {
/*
Changes the content of an array, adding new elements while removing old elements.
Returns an array containing the removed elements. If only one element is removed, an array of one element is returned.
Returns undefined if no arguments are passed.
*/
if (arguments.length == 0) return index;
if (typeof index != "number") index = 0;
if (index < 0) index = Math.max(0, this.length + index);
if (index > this.length) {
if (arguments.length > 2) index = this.length;
else return []
};
if (arguments.length < 2) howMany = this.length - index;
howMany = (typeof howMany == "number") ? Math.max(0, howMany) : 0;
var removedElements = this.slice(index, index + howMany);
var elementsToMove = this.slice(index + howMany);
this.length = index;
for (var i = 2; i < arguments.length; i ++) this[this.length] = arguments[i];
for (var i = 0; i < elementsToMove.length; i ++) this[this.length] = elementsToMove[i];
return removedElements
};
/* ##### Number.prototype.toFixed.js ##### */
/*
2006 Florian Hoech
Number.prototype.toFixed.js
*/
if (!Number.prototype.toFixed) {
Number.prototype.toFixed = function(ln) {
if (!ln) ln = 0;
var i, n = Math.pow(10, ln),
n = (Math.round(this * n) / n) + "";
if (ln && (i = n.indexOf(".")) < 0) {
i = n.length;
n += "."
};
while (n.substr(i).length < ln + 1) n += "0";
return n
}
};
/* ##### Array.prototype.indexOf.js ##### */
/*
http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:indexOf
Summary
Returns the first index at which a given element can be found in the array, or -1 if it is not present.
Method of Array
Implemented in: JavaScript 1.6 (Gecko 1.8b2 and later)
ECMAScript Edition: none
Syntax
var index = array.indexOf(searchElement[, fromIndex]);
Parameters
searchElement
Element to locate in the array.
fromIndex
The index at which to begin the search. Defaults to 0, i.e. the whole array will be searched. If the index is greater than or equal to the length of the array, -1 is returned, i.e. the array will not be searched. If negative, it is taken as the offset from the end of the array. Note that even when the index is negative, the array is still searched from front to back. If the calculated index is less than 0, the whole array will be searched.
Description
indexOf compares searchElement to elements of the Array using strict equality (the same method used by the ===, or triple-equals, operator).
Compatibility
indexOf is a JavaScript extension to the ECMA-262 standard; as such it may not be present in other implementations of the standard. You can work around this by inserting the following code at the beginning of your scripts, allowing use of indexOf in ECMA-262 implementations which do not natively support it. This algorithm is exactly the one used in Firefox and SpiderMonkey.
Again, note that this implementation aims for absolute compatibility with indexOf in Firefox and the SpiderMonkey JavaScript engine, including in cases where the index passed to indexOf is not an integer value. If you intend to use this in real-world applications, you may not need all of the code to calculate from.
Example: Using indexOf
The following example uses indexOf to locate values in an array.
var array = [2, 5, 9];
var index = array.indexOf(2);
// index is 0
index = array.indexOf(7);
// index is -1
Example: Finding all the occurrences of an element
The following example uses indexOf to find all the indices of an element in a given array, using push to add them to another array as they are found.
var indices = [];
var idx = array.indexOf(element)
while (idx != -1)
{
indices.push(idx);
idx = array.indexOf(element, idx + 1);
}
*/
// NOTE: semicolons added where necessary to make compatible with JavaScript compressors
if (!Array.prototype.indexOf)
{
Array.prototype.indexOf = function(elt /*, from*/)
{
var len = this.length;
var from = Number(arguments[1]) || 0;
from = (from < 0)
? Math.ceil(from)
: Math.floor(from);
if (from < 0)
from += len;
for (; from < len; from++)
{
if (/* from in this && */ /* Not compatible with IE/Mac */
this[from] === elt)
return from
};
return -1
}
};
/* ##### jsapi.js ##### */
/*
<jsapi>
<author>2006 Florian Hoech</author>
<file>jsapi.js</file>
</jsapi>
*/
jsapi = function() {
return new jsapi.jsapi(arguments);
};
jsapi.constants = {
OBJECTTYPES: {
OBJECT: 0,
ARRAY: 1,
BOOLEAN: 2,
DATE: 3,
FUNCTION: 4,
NUMBER: 5,
REGEXP: 6,
STRING: 7
}
};
jsapi.extend = function(object, _this) {
jsapi.jsapi.prototype.extend(object, _this)
};
jsapi.jsapi = function() {
var objectType;
if (!jsapi.initialized) {
for (var propertyName in jsapi.dom) if (typeof jsapi.dom[propertyName] == "function" && !jsapi.dom[propertyName]._args) jsapi.dom[propertyName]._args = [jsapi.dom.isNode];
for (var propertyName in jsapi.regexp) if (typeof jsapi.regexp[propertyName] == "function") jsapi.regexp[propertyName]._args = [function(argument) {
return argument.constructor == RegExp;
}];
for (var propertyName in jsapi.string) if (typeof jsapi.string[propertyName] == "function") jsapi.string[propertyName]._args = [function(argument) {
return typeof argument == "string" || argument.constructor == String;
}];
for (var propertyName in jsapi) jsapi.extend(jsapi[propertyName], jsapi[propertyName]);
var arrayMethodNames = [
"every",
"filter",
"forEach",
"indexOf",
"join",
"lastIndexOf",
"map",
"slice",
"some",
/* Mutator methods */
"pop",
"push",
"reverse",
"shift",
"sort",
"splice",
"unshift"
];
for (var i = 0; i < arrayMethodNames.length; i ++) {
(function (arrayMethodName) {
jsapi.jsapi.prototype[arrayMethodName] = function () {
var result = Array.prototype[arrayMethodName].apply(this, arguments);
return typeof result == "object" ? jsapi(result) : (result != null || arrayMethodName == "pop" || arrayMethodName == "shift" ? result : this);
}
})(arrayMethodNames[i]);
};
jsapi.initialized = true;
};
if (this.length == null) this.length = 0;
for (var i = 0; i < arguments[0].length; i ++) {
var object = arguments[0][i];
switch (typeof object) {
case "function":
objectType = jsapi.constants.OBJECTTYPES.FUNCTION;
break;
case "number":
objectType = jsapi.constants.OBJECTTYPES.NUMBER;
break;
case "string":
objectType = jsapi.constants.OBJECTTYPES.STRING;
break;
default:
if (!object) continue; // null or undefined
switch (object.constructor) {
case Boolean:
objectType = jsapi.constants.OBJECTTYPES.BOOLEAN;
break;
case Date:
objectType = jsapi.constants.OBJECTTYPES.DATE;
break;
case Number:
objectType = jsapi.constants.OBJECTTYPES.NUMBER;
break;
case RegExp:
objectType = jsapi.constants.OBJECTTYPES.REGEXP;
break;
case String:
objectType = jsapi.constants.OBJECTTYPES.STRING;
break;
default:
objectType = jsapi.constants.OBJECTTYPES.OBJECT;
}
};
switch (objectType) {
case jsapi.constants.OBJECTTYPES.STRING:
var expression = object.split(":");
if (expression.length > 1) switch (expression[0]) {
case "html":
case "xhtml":
case "xml":
object = jsapi.dom.parseString(expression.slice(1).join(":"));
break;
case "xpath":
object = jsapi.dom.getByXpath(expression.slice(1).join(":"));
break;
}
else if (/<[^<]*>/.test(object)) object = jsapi.dom.parseString(object);
default:
if (object.constructor == Array) Array.prototype.push.apply(this, object);
else if (typeof object == "object" && typeof object.length == "number" && object.constructor != String && object.constructor != Function)
Array.prototype.push.apply(this, Array.prototype.slice.apply(object));
else this[this.length ++] = object;
}
};
};
jsapi.jsapi.prototype = {
concat: function(object) {
var result = jsapi(this);
jsapi.jsapi.apply(result, [object]);
return result
},
extend: function(object, _this) {
/*
if _this evaluates to false, use the current result as "this"-object.
otherwise, use _this as "this"-object and pass the current result as first argument.
*/
for (var propertyName in object) if (typeof object[propertyName] == "function" &&
propertyName != "$" &&
propertyName != "extend" &&
propertyName != "toString" &&
propertyName != "valueOf") {
if (!this[propertyName]) {
this[propertyName] = function() {
if (this.length) {
var _callbacks = arguments.callee._callbacks;
for (var i = 0; i < this.length; i ++) {
for (var n = 0; n < _callbacks.length; n ++) {
var _this = _callbacks[n]._this || this[i],
_arguments = _callbacks[n]._this ? [this[i]].concat(Array.prototype.slice.apply(arguments)) : arguments;
if (_callbacks[n].hasValidArguments.apply(_callbacks[n], _arguments)) {
this[i] = _callbacks[n].apply(_this, _arguments);
}
}
}
};
return this;
};
this[propertyName]._callbacks = [];
};
if (!object[propertyName].hasValidArguments) {
if (object[propertyName]._args) object[propertyName].hasValidArguments = function() {
for (var i = 0; i < this._args.length; i ++) {
if (!(typeof this._args[i] == "string" ?
typeof arguments[i] == this._args[i] :
(typeof this._args[i] == "function" ?
this._args[i](arguments[i]) :
arguments[i] == this._args[i]))) {
return false;
}
};
return true
};
else object[propertyName].hasValidArguments = function() { return true };
};
object[propertyName]._this = _this;
if (this[propertyName]._callbacks.indexOf(object[propertyName]) < 0) this[propertyName]._callbacks.push(object[propertyName]);
}
},
toString: function() {
return Array.prototype.slice.apply(this).toString();
}
};
/* ##### jsapi.array.js ##### */
/*
<jsapi>
<author>2006 Florian Hoech</author>
<file>jsapi.array.js</file>
<dependencies>
jsapi.js
</dependencies>
</jsapi>
*/
jsapi.array = {
$: function(object) {
// make array from object with only the numerical indices
var array = [], n;
if (object.length != null) for (var i = 0; i < object.length; i ++) array[i] = object[i];
else for (var i in object) if (!isNaN(n = parseInt(i)) && n == i) array[n] = object[i];
return array
}
};
jsapi.array.$._args = [null];
/* ##### jsapi.array.flat.js ##### */
/*
<jsapi>
<author>2006 Florian Hoech</author>
<file>jsapi.array.search.js</file>
<dependencies>
jsapi.array.js
</dependencies>
</jsapi>
*/
jsapi.array.flat = function(a) {
var r = [];
for (var i = 0; i < a.length; i ++) {
if (a[i].constructor == Array) r = r.concat(jsapi.array.flat(a[i]));
else r.push(a[i])
};
return r
};
jsapi.array.flat._args = [Array];
/* ##### jsapi.dom.js ##### */
/*
<jsapi>
<author>2006 Florian Hoech</author>
<file>jsapi.dom.js</file>
<dependencies>
jsapi.js
</dependencies>
</jsapi>
*/
jsapi.dom = {};
/* ##### jsapi.dom.NODETYPES.js ##### */
/*
<jsapi>
<author>2006 Florian Hoech</author>
<file>jsapi.dom.NODETYPES.js</file>
<dependencies>
jsapi.dom.js
</dependencies>
</jsapi>
*/
jsapi.dom.NODETYPES = {
"1": "ELEMENT",
"2": "ATTRIBUTE",
"3": "TEXT",
"4": "CDATA_SECTION",
"5": "ENTITY_REFERENCE",
"6": "ENTITY",
"7": "PROCESSING_INSTRUCTION",
"8": "COMMENT",
"9": "DOCUMENT",
"10": "DOCUMENT_TYPE",
"11": "DOCUMENT_FRAGMENT",
"12": "NOTATION"
};
/* ##### jsapi.dom.isNode.js ##### */
/*
<jsapi>
<author>Florian Hoech</author>
<file>jsapi.dom.isNode.js</file>
<dependencies>
jsapi.dom.NODETYPES.js
</dependencies>
</jsapi>
*/
jsapi.dom.isNode = function(object) {
return !!(object && jsapi.dom.NODETYPES[object.nodeType] && object.cloneNode);
};
/* ##### jsapi.string.js ##### */
/*
<jsapi>
<author>2006 Florian Hoech</author>
<file>jsapi.string.js</file>
<dependencies>
jsapi.js
</dependencies>
</jsapi>
*/
jsapi.string = {};
/* ##### jsapi.string.trim.js ##### */
/*
<jsapi>
<author>2006 Florian Hoech</author>
<file>jsapi.string.trim.js</file>
<dependencies>
jsapi.string.js
</dependencies>
</jsapi>
*/
jsapi.string.trim = function(str) {
return str.replace(/(^\s+|\s+$)/g, "")
};
jsapi.string.trim._args = [String];
/* ##### jsapi.useragent.js ##### */
/*
<jsapi>
<author>2006 Florian Hoech</author>
<file>jsapi.useragent.js</file>
<dependencies>
jsapi.string.trim.js
</dependencies>
</jsapi>
TO-DO: add KHTML
*/
jsapi.useragent = {
$: function (ua) {
ua = (ua || navigator.userAgent).toLowerCase();
var i, j, match, _match, replace = [
[/(\d+\.)(\d+)\.(\d+)(\.(\d+))?/g, "$1$2$3$5"],
[/linux/g, ";linux;linux"],
[/mac/, ";mac;mac"],
[/microsoft ((p)ocket )?internet explorer/g, "ms$2ie"],
[/win32/g, "windows"],
[/windows (\w+)/g, "windows;windows $1"]
];
for (i = 0; i < replace.length; i ++) ua = ua.replace(replace[i][0], replace[i][1]);
ua = ua.split(/[\(\)\[\]\{\}\,;]/);
for (i in this) {
if (typeof this[i] != "object" && typeof this[i] != "function") delete this[i]
};
for (i = 0; i < ua.length; i ++) {
match = ua[i].match(/[a-z\.\-_]+(\s+[a-z\.\-_]+)*\Wv?\d+(\.\d+)*/g);
if (match) {
for (j = 0; j < match.length; j ++) {
_match = match[j].match(/([a-z\.\-_]+(\s[a-z\.\-_]+)*)\Wv?(\d+(\.\d+)*)/);
if (!this[_match[1]] || (parseFloat(_match[3]) == _match[3] && this[_match[1]] < parseFloat(_match[3]))) this[_match[1]] = parseFloat(_match[3]) == _match[3] ? parseFloat(_match[3]) : _match[3]
}
}
else {
ua[i] = jsapi.string.trim(ua[i]);
if (ua[i]) this[ua[i]] = true
}
};
if (this.konqueror && !this.khtml) this.khtml = true;
if (this.safari === true) delete this.safari; // safari would have a version number here
if (!this.gecko && this.mozilla) {
this.compatible = this.mozilla;
delete this.mozilla
};
if (this.opera || this.safari || this.konqueror) {
if (this.mozilla) delete this.mozilla;
if (this.msie) delete this.msie
};
return this
}
};
jsapi.useragent.toString = function() {
var props = [];
for (i in this) {
if (typeof this[i] != "object" && typeof this[i] != "function")
props.push((/\s/.test(i) ? "'" : "") + i + (/\s/.test(i) ? "'" : "") + ":" + (typeof this[i] == "string" ? '"' : "") + this[i] + (typeof this[i] == "string" ? '"' : ""))
};
return props.join(", ");
};
jsapi.useragent.$._args = [String];
jsapi.useragent.$();
/* ##### jsapi.util.js ##### */
/*
<jsapi>
<author>2006 Florian Hoech</author>
<file>jsapi.util.js</file>
<dependencies>
jsapi.js
</dependencies>
</jsapi>
*/
jsapi.util = {};
/* ##### jsapi.generic_accessor_mutator.js ##### */
/*
<jsapi>
<author>Florian Hoech</author>
<file>jsapi.generic_accessor_mutator.js</file>
<dependencies>
jsapi.js
jsapi.dom.js
jsapi.dom.isNode.js
jsapi.useragent.js
jsapi.util.js
</dependencies>
</jsapi>
*/
jsapi.constants.ATTRIBUTE_ALIASES = {
"class": "className",
"for": "htmlFor",
readonly: "readOnly",
maxlength: "maxLength"
};
jsapi._attribute = function(object, attributeName, value) { // if arguments.length == 2, get attribute. otherwise, if value == null, remove attribute, else set attribute
switch (attributeName) {
case "style":
case "value":
return arguments.length == 2 ? jsapi._property(object, attributeName) : jsapi._property(object, attributeName, value);
default:
if (jsapi.constants.ATTRIBUTE_ALIASES[attributeName]) return jsapi._property.apply(jsapi, arguments);
else {
if (arguments.length == 2) return object.getAttribute(attributeName); // get attribute
if (value == null) object.removeAttribute(attributeName); // remove attribute
else object.setAttribute(attributeName, value); // set attribute
}
};
return object
};
jsapi._property = function(object, propertyName, value) { // if arguments.length == 2, get property. otherwise, if value == null, delete property, else set property
switch (propertyName) {
case "style":
if (arguments.length == 2) return object.style.cssText; // get attribute
object.style.cssText = value || ""; // set attribute
break;
};
if (jsapi.dom.isNode(object)) propertyName = jsapi.constants.ATTRIBUTE_ALIASES[propertyName] || propertyName;
if (arguments.length == 2) return object[propertyName];
object[propertyName] = value; // set property
if (value == null) try { delete object[propertyName] } catch (e) { }; // delete property
return object
};
jsapi.dom.attr =
jsapi.dom.attribute = function (object, attribute, value) {
return arguments.length == 2 && (typeof attribute != "object" || attribute.constructor == Array) ? jsapi._get(object, jsapi._attribute, attribute) : jsapi._set(object, jsapi._attribute, attribute, value);
};
jsapi.util.prop =
jsapi.util.property = function (object, property, value) {
return arguments.length == 2 && (typeof property != "object" || property.constructor == Array) ? jsapi._get(object, jsapi._property, property) : jsapi._set(object, jsapi._property, property, value);
};
jsapi._get = function (object, callback, property) {
if (typeof property != "object") return callback(object, property);
else {
var result = [];
for (var i = 0; i < property.length; i ++) result.push(callback(object, property[i]));
return result;
}
};
jsapi._set = function (object, callback, property, value) {
if (typeof property != "object") callback(object, property, value);
else {
if (property.constructor == Array) for (var i = 0; i < property.length; i ++) callback(object, property[i], value);
else for (var propertyName in property) callback(object, propertyName, property[propertyName] != null ? property[propertyName] : value);
};
return object;
};;
/* ##### jsapi.dom.attribute.js ##### */
/*
<jsapi>
<author>2006 Florian Hoech</author>
<file>jsapi.dom.attribute.js</file>
<dependencies>
jsapi.generic_accessor_mutator.js
</dependencies>
</jsapi>
*/
/* ##### jsapi.dom.attributeAddWord.js ##### */
/*
<jsapi>
<author>2006 Florian Hoech</author>
<file>jsapi.dom.attributeAddWord.js</file>
<dependencies>
jsapi.dom.attribute.js
</dependencies>
</jsapi>
*/
jsapi.dom.attributeAddWord = function(element, attr, word) {
var value = jsapi.dom.attribute(element, attr);
return jsapi.dom.attribute(element, attr, (value != null ? value + " " : "") + word)
};
/* ##### jsapi.dom.attributeHasWord.js ##### */
/*
<jsapi>
<author>2006 Florian Hoech</author>
<file>jsapi.dom.attributeHasWord.js</file>
<dependencies>
jsapi.dom.attribute.js
</dependencies>
</jsapi>
*/
jsapi.dom.attributeHasWord = function(element, attr, word) {
return (new RegExp("(^|\\s)" + word + "(\\s|$)")).test(jsapi.dom.attribute(element, attr))
};
/* ##### jsapi.dom.attributeRemoveWord.js ##### */
/*
<jsapi>
<author>2006 Florian Hoech</author>
<file>jsapi.dom.attributeRemoveWord.js</file>
<dependencies>
jsapi.dom.attribute.js
</dependencies>
</jsapi>
*/
jsapi.dom.attributeRemoveWord = function(element, attr, word) {
var value = jsapi.dom.attribute(element, attr);
if (value) jsapi.dom.attribute(element, attr, value.replace(new RegExp("(^|\\s+)" + word + "(\\s|$)"), "$2"));
return element
};
/* ##### jsapi.math.js ##### */
/*
<jsapi>
<author>2006 Florian Hoech</author>
<file>jsapi.math.js</file>
<dependencies>
jsapi.array.flat.js
</dependencies>
</jsapi>
*/
jsapi.math = {
absmax: function(v) {
var a = jsapi.array.flat(arguments), r = a[0];
for (var i = 0; i < a.length; i ++) if (Math.abs(r) < Math.abs(a[i])) r = a[i];
return r
},
avg: function() {
var a = jsapi.array.flat(arguments), r = 0;
for (var i = 0; i < a.length; i ++) r += a[i];
return r / a.length
},
cbrt: function(x) {
return x >= 0 ? Math.pow (x, 1 / 3) : -Math.pow (-x, 1 / 3)
},
deg: function(v) {
return v * 180 / Math.PI
},
longToUnsigned: function(num) {
while (num < 0) num += 4294967296;
return num
},
max: function(v) {
var a = jsapi.array.flat(arguments), r = a[0];
for (var i = 0; i < a.length; i ++) r = Math.max(r, a[i]);
return r
},
min: function(v) {
var a = jsapi.array.flat(arguments), r = a[0];
for (var i = 0; i < a.length; i ++) r = Math.min(r, a[i]);
return r
},
rad: function(v) {
return v / 180 * Math.PI
}
};
jsapi.math.absmax._args = [Number];
jsapi.math.avg._args = [Number];
jsapi.math.cbrt._args = [Number];
jsapi.math.deg._args = [Number];
jsapi.math.longToUnsigned._args = [Number];
jsapi.math.max._args = [Array];
jsapi.math.min._args = [Array];
jsapi.math.rad._args = [Number];
/* ##### jsapi.math.color.js ##### */
/*
<jsapi>
<author>2006 Florian Hoech</author>
<file>jsapi.math.color.js</file>
<dependencies>
jsapi.math.js
</dependencies>
</jsapi>
*/
jsapi.math.color = {};
/* ##### jsapi.math.color.XYZ2CorColorTemp.js ##### */
/*
<jsapi>
<author>2007 Florian Hoech</author>
<file>jsapi.math.color.XYZ2CorColorTemp.js</file>
<dependencies>
jsapi.math.color.js
</dependencies>
</jsapi>
*/
jsapi.math.color.XYZ2CorColorTemp = function(x, y, z) {
// derived from ANSI C implementation by Bruce Lindbloom www.brucelindbloom.com
// LERP(a,b,c) = linear interpolation macro, is 'a' when c == 0.0 and 'b' when c == 1.0
function LERP(a,b,c) {
return (b - a) * c + a
};
var rt = [ // reciprocal temperature (K)
Number.MIN_VALUE, 10.0e-6, 20.0e-6, 30.0e-6, 40.0e-6, 50.0e-6,
60.0e-6, 70.0e-6, 80.0e-6, 90.0e-6, 100.0e-6, 125.0e-6,
150.0e-6, 175.0e-6, 200.0e-6, 225.0e-6, 250.0e-6, 275.0e-6,
300.0e-6, 325.0e-6, 350.0e-6, 375.0e-6, 400.0e-6, 425.0e-6,
450.0e-6, 475.0e-6, 500.0e-6, 525.0e-6, 550.0e-6, 575.0e-6,
600.0e-6
];
var uvt = [
[0.18006, 0.26352, -0.24341],
[0.18066, 0.26589, -0.25479],
[0.18133, 0.26846, -0.26876],
[0.18208, 0.27119, -0.28539],
[0.18293, 0.27407, -0.30470],
[0.18388, 0.27709, -0.32675],
[0.18494, 0.28021, -0.35156],
[0.18611, 0.28342, -0.37915],
[0.18740, 0.28668, -0.40955],
[0.18880, 0.28997, -0.44278],
[0.19032, 0.29326, -0.47888],
[0.19462, 0.30141, -0.58204],
[0.19962, 0.30921, -0.70471],
[0.20525, 0.31647, -0.84901],
[0.21142, 0.32312, -1.0182],
[0.21807, 0.32909, -1.2168],
[0.22511, 0.33439, -1.4512],
[0.23247, 0.33904, -1.7298],
[0.24010, 0.34308, -2.0637],
[0.24792, 0.34655, -2.4681], // Note: 0.24792 is a corrected value for the error found in W&S as 0.24702
[0.25591, 0.34951, -2.9641],
[0.26400, 0.35200, -3.5814],
[0.27218, 0.35407, -4.3633],
[0.28039, 0.35577, -5.3762],
[0.28863, 0.35714, -6.7262],
[0.29685, 0.35823, -8.5955],
[0.30505, 0.35907, -11.324],
[0.31320, 0.35968, -15.628],
[0.32129, 0.36011, -23.325],
[0.32931, 0.36038, -40.770],
[0.33724, 0.36051, -116.45]
];
var us, vs, p, di, dm, i;
if ((x < 1e-20) && (y < 1e-20) && (z < 1e-20)) return -1; // protect against possible divide-by-zero failure
us = (4 * x) / (x + 15 * y + 3 * z);
vs = (6 * y) / (x + 15 * y + 3 * z);
dm = 0;
for (i = 0; i < 31; i++) {
di = (vs - uvt[i][1]) - uvt[i][2] * (us - uvt[i][0]);
if ((i > 0) && (((di < 0) && (dm >= 0)) || ((di >= 0) && (dm < 0)))) break; // found lines bounding (us, vs) : i-1 and i
dm = di
};
if (i == 31) return -1; // bad XYZ input, color temp would be less than minimum of 1666.7 degrees, or too far towards blue
di = di / Math.sqrt(1 + uvt[i ][2] * uvt[i ][2]);
dm = dm / Math.sqrt(1 + uvt[i - 1][2] * uvt[i - 1][2]);
p = dm / (dm - di); // p = interpolation parameter, 0.0 : i-1, 1.0 : i
return 1 / (LERP(rt[i - 1], rt[i], p));
};
/* ##### jsapi.math.color.delta.js ##### */
/*
<jsapi>
<author>2007 Florian Hoech</author>
<file>jsapi.math.color.delta.js</file>
<dependencies>
jsapi.math.color.js
</dependencies>
</jsapi>
*/
jsapi.math.color.delta = function (L1, a1, b1, L2, a2, b2, method, p1, p2, p3, debug) {
/*
CIE 1994 & CMC calculation code derived from formulas on www.brucelindbloom.com
CIE 1994 code uses some alterations seen on www.farbmetrik-gall.de/cielab/korrcielab/cie94.html (see notes in code below)
CIE 2000 calculation code derived from Excel spreadsheet available at www.ece.rochester.edu/~gsharma/ciede2000
method: either "CIE94", "CMC", "CIE2K" or "CIE76" (default if method is not set)
p1, p2, p3 arguments have different meaning for each calculation method:
CIE 1994: if p1 is not null, calculation will be adjusted for textiles, otherwise graphics arts (default if p1 is not set)
CMC(l:c): p1 equals l (lightness) weighting factor and p2 equals c (chroma) weighting factor.
commonly used values are CMC(1:1) for perceptability (default if p1 and p2 are not set) and CMC(2:1) for acceptability
CIE 2000: p1 becomes kL (lightness) weighting factor, p2 becomes kC (chroma) weighting factor and p3 becomes kH (hue) weighting factor
(all three default to 1 if not set)
*/
for (var i = 0; i < 6; i ++) if (typeof arguments[i] != "number" || isNaN(arguments[i])) return NaN;
if (typeof method == "string") method = method.toLowerCase();
switch (method) {
case "94":
case "1994":
case "cie94":
case "cie1994":
var textiles = p1,
dL = L1 - L2,
C1 = Math.sqrt(Math.pow(a1, 2) + Math.pow(b1, 2)),
C2 = Math.sqrt(Math.pow(a2, 2) + Math.pow(b2, 2)),
dC = C1 - C2,
dH2 = Math.pow(a1 - a2, 2) + Math.pow(b1 - b2, 2) - Math.pow(dC, 2),
dH = dH2 > 0 ? Math.sqrt(dH2) : 0,
SL = 1,
K1 = textiles ? 0.048 : 0.045,
K2 = textiles ? 0.014 : 0.015,
C_ = (Math.sqrt((1 + (K1 * C1)) * (1 + (K1 * C2))) - 1) / K1, // www.farbmetrik-gall.de/cielab/korrcielab/cie94.html
SC = 1 + K1 * C_, // brucelindbloom.com formula originally used C1 instead of C_, but the results are different from ProfileMaker/MeasureTool implementation, so use this instead (found on www.farbmetrik-gall.de/cielab/korrcielab/cie94.html)
SH = 1 + K2 * C_, // brucelindbloom.com formula originally used C1 instead of C_, but the results are different from ProfileMaker/MeasureTool implementation, so use this instead (found on www.farbmetrik-gall.de/cielab/korrcielab/cie94.html)
KL = textiles ? 2 : 1,
KC = 1,
KH = 1,
dE = Math.sqrt(Math.pow(dL / (KL * SL), 2) + Math.pow(dC / (KC * SC), 2) + Math.pow(dH / (KH * SH), 2));
break;
case "cmc(2:1)":
case "cmc21":
p1 = 2;
case "cmc(1:1)":
case "cmc11":
case "cmc":
var l = typeof p1 == "number" ? p1 : 1,
c = typeof p2 == "number" ? p2 : 1;
dL = L1 - L2,
C1 = Math.sqrt(Math.pow(a1, 2) + Math.pow(b1, 2)),
C2 = Math.sqrt(Math.pow(a2, 2) + Math.pow(b2, 2)),
dC = C1 - C2,
dH2 = Math.pow(a1 - a2, 2) + Math.pow(b1 - b2, 2) - Math.pow(dC, 2),
dH = dH2 > 0 ? Math.sqrt(dH2) : 0,
SL = L1 < 16 ? 0.511 : (0.040975 * L1) / (1 + 0.01765 * L1),
SC = (0.0638 * C1) / (1 + 0.0131 * C1) + 0.638,
F = Math.sqrt(Math.pow(C1, 4) / (Math.pow(C1, 4) + 1900)),
H1 = jsapi.math.deg(Math.atan2(b1, a1)) + (b1 >= 0 ? 0 : 360),
T = 164 <= H1 && H1 <= 345 ? 0.56 + Math.abs(0.2 * Math.cos(jsapi.math.rad(H1 + 168))) : 0.36 + Math.abs(0.4 * Math.cos(jsapi.math.rad(H1 + 35))),
SH = SC * (F * T + 1 - F),
dE = Math.sqrt(Math.pow(dL / (l * SL), 2) + Math.pow(dC / (c * SC), 2) + Math.pow(dH / SH, 2));
break;
case "00":
case "2k":
case "2000":
case "cie00":
case "cie2k":
case "cie2000":
var pow25_7 = Math.pow(25, 7),
k_L = typeof p1 == "number" ? p1 : 1,
k_C = typeof p2 == "number" ? p2 : 1,
k_H = typeof p3 == "number" ? p3 : 1,
C1 = Math.sqrt(Math.pow(a1, 2) + Math.pow(b1, 2)),
C2 = Math.sqrt(Math.pow(a2, 2) + Math.pow(b2, 2)) ,
C_avg = jsapi.math.avg(C1, C2),
G = .5 * (1 - Math.sqrt(Math.pow(C_avg, 7) / (Math.pow(C_avg, 7) + pow25_7))),
L1_ = L1,
a1_ = (1 + G) * a1,
b1_ = b1,
L2_ = L2,
a2_ = (1 + G) * a2,
b2_ = b2,
C1_ = Math.sqrt(Math.pow(a1_, 2) + Math.pow(b1_, 2)),
C2_ = Math.sqrt(Math.pow(a2_, 2) + Math.pow(b2_, 2)),
h1_ = a1_ == 0 && b1_ == 0 ? 0 : jsapi.math.deg(Math.atan2(b1_, a1_)) + (b1_ >= 0 ? 0 : 360),
h2_ = a2_ == 0 && b2_ == 0 ? 0 : jsapi.math.deg(Math.atan2(b2_, a2_)) + (b2_ >= 0 ? 0 : 360),
dh_cond = h2_ - h1_ > 180 ? 1 : (h2_ - h1_ < -180 ? 2 : 0),
dh_ = dh_cond == 0 ? h2_ - h1_ : (dh_cond == 1 ? h2_ - h1_ - 360 : h2_ + 360 - h1_),
dL_ = L2_ - L1_,
dL = dL_,
dC_ = C2_ - C1_,
dC = dC_,
dH_ = 2 * Math.sqrt(C1_ * C2_) * Math.sin(jsapi.math.rad(dh_ / 2)),
dH = dH_,
L__avg = jsapi.math.avg(L1_, L2_),
C__avg = jsapi.math.avg(C1_, C2_),
h__avg_cond = C1_ * C2_ == 0 ? 3 : (Math.abs(h2_ - h1_) <= 180 ? 0 : (h2_ + h1_ < 360 ? 1 : 2)),
h__avg = h__avg_cond == 3 ? h1_ + h2_ : (h__avg_cond == 0 ? jsapi.math.avg(h1_, h2_) : (h__avg_cond == 1 ? jsapi.math.avg(h1_, h2_) + 180 : jsapi.math.avg(h1_, h2_) - 180)),
AB = Math.pow(L__avg - 50, 2), // (L'_ave-50)^2
S_L = 1 + .015 * AB / Math.sqrt(20 + AB),
S_C = 1 + .045 * C__avg,
T = 1 - .17 * Math.cos(jsapi.math.rad(h__avg - 30)) + .24 * Math.cos(jsapi.math.rad(2 * h__avg)) + .32 * Math.cos(jsapi.math.rad(3 * h__avg + 6))
- .2 * Math.cos(jsapi.math.rad(4 * h__avg - 63)),
S_H = 1 + .015 * C__avg * T,
dTheta = 30 * Math.exp(-1 * Math.pow((h__avg - 275) / 25, 2)),
R_C = 2 * Math.sqrt(Math.pow(C__avg, 7) / (Math.pow(C__avg, 7) + pow25_7)),
R_T = -Math.sin(jsapi.math.rad(2 * dTheta)) * R_C,
AJ = dL_ / S_L / k_L, // dL' / k_L / S_L
AK = dC_ / S_C / k_C, // dC' / k_C / S_C
AL = dH_ / S_H / k_H, // dH' / k_H / S_H
dE = Math.sqrt(Math.pow(AJ, 2) + Math.pow(AK, 2) + Math.pow(AL, 2) + R_T * AK * AL);
if (debug) {
r = (C1 + "|" + C2 + "|" + C_avg + "|" + G + "|" + L1_ + "|" + a1_ + "|" + b1_ + "|" + L2_ + "|" + a2_ + "|" + b2_ + "|" + C1_ + "|" + C2_ + "|" + h1_ + "|" + h2_ + "|" + dh_ + "|" + dL_ + "|" + dC_ + "|" + dH_ + "|" + L__avg + "|" + C__avg + "|" + h__avg + "|" + AB + "|" + S_L + "|" + S_C + "|" + T + "|" + S_H + "|" + dTheta + "|" + R_C + "|" + R_T + "|" + AJ + "|" + AK + "|" + AL + "|" + dE + "|" + dh_cond + "|" + h__avg_cond).split("|");
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
t = [];
n = alpha.indexOf("G");
for (i = 0; i < r.length; i ++) {
a = i + n < alpha.length ? alpha[i + n] : "A" + alpha[i + n - alpha.length];
t.push(a + ": " + r[i]);
}
return t.join("\n");
};
break;
default:
var dL = L1 - L2,
C1 = Math.sqrt(Math.pow(a1, 2) + Math.pow(b1, 2)),
C2 = Math.sqrt(Math.pow(a2, 2) + Math.pow(b2, 2)),
dC = C1 - C2,
dH2 = Math.pow(a1 - a2, 2) + Math.pow(b1 - b2, 2) - Math.pow(dC, 2),
dH = dH2 > 0 ? Math.sqrt(dH2) : 0,
dE = Math.sqrt(Math.pow(dL, 2) + Math.pow(a1 - a2, 2) + Math.pow(b1 - b2, 2));
if (isNaN(dH)) {
if (window.location.href.indexOf("?debug")>-1) alert('a1: ' + a1 + '\na2: ' + a2 + '\nMath.pow(a1 - a2, 2): ' + Math.pow(a1 - a2, 2) + '\nb1: ' + b1 + '\nb2: ' + b2 + '\nMath.pow(b1 - b2, 2): ' + Math.pow(b1 - b2, 2) + '\ndC: ' + dC + '\nMath.pow(dC, 2): ' + Math.pow(dC, 2) + '\nMath.pow(a1 - a2, 2) + Math.pow(b1 - b2, 2) - Math.pow(dC, 2): ' + (Math.pow(a1 - a2, 2) + Math.pow(b1 - b2, 2) - Math.pow(dC, 2)));
}
};
return {
E: dE,
L: dL,
C: dC,
H: dH,
a: a1 - a2,
b: b1 - b2
};
};
|