Added a Sales Sheet page along with other changes.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// https://tc39.github.io/ecma262/#sec-array.prototype.includes
|
||||
if (!Array.prototype.includes) {
|
||||
if(!Array.prototype.includes) {
|
||||
Object.defineProperty(Array.prototype, 'includes', {
|
||||
value: function(searchElement, fromIndex) {
|
||||
|
||||
@@ -8,10 +8,10 @@ if (!Array.prototype.includes) {
|
||||
throw new TypeError('"this" is null or not defined');
|
||||
}
|
||||
|
||||
var o = Object(this);
|
||||
let o = Object(this);
|
||||
|
||||
// 2. Let len be ? ToLength(? Get(O, "length")).
|
||||
var len = o.length >>> 0;
|
||||
let len = o.length >>> 0;
|
||||
|
||||
// 3. If len is 0, return false.
|
||||
if (len === 0) {
|
||||
@@ -20,14 +20,14 @@ if (!Array.prototype.includes) {
|
||||
|
||||
// 4. Let n be ? ToInteger(fromIndex).
|
||||
// (If fromIndex is undefined, this step produces the value 0.)
|
||||
var n = fromIndex | 0;
|
||||
let n = fromIndex | 0;
|
||||
|
||||
// 5. If n ≥ 0, then
|
||||
// a. Let k be n.
|
||||
// 6. Else n < 0,
|
||||
// a. Let k be len + n.
|
||||
// b. If k < 0, let k be 0.
|
||||
var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
|
||||
let k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
|
||||
|
||||
// 7. Repeat, while k < len
|
||||
while (k < len) {
|
||||
@@ -45,4 +45,64 @@ if (!Array.prototype.includes) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//http://stackoverflow.com/questions/5306680/move-an-array-element-from-one-array-position-to-another
|
||||
if(!Array.prototype.move) {
|
||||
Array.prototype.move = function (old_index, new_index) {
|
||||
if (new_index >= this.length) {
|
||||
let k = new_index - this.length;
|
||||
while ((k--) + 1) {
|
||||
this.push(undefined);
|
||||
}
|
||||
}
|
||||
this.splice(new_index, 0, this.splice(old_index, 1)[0]);
|
||||
return this; // for testing purposes
|
||||
};
|
||||
}
|
||||
|
||||
//My own implementation to work around Javascript's shitty naming and support for collection operations.
|
||||
if(!Array.prototype.remove) {
|
||||
Array.prototype.remove = function(item) {
|
||||
let index = this.indexOf(item);
|
||||
|
||||
if(index != -1) {
|
||||
this.splice(index, 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//My own implementation to work around Javascript's shitty naming and support for collection operations.
|
||||
// index is optional
|
||||
if(!Array.prototype.add) {
|
||||
Array.prototype.add = function(item, index) {
|
||||
if(index == undefined || isNaN(index) || index >= this.length) return this.push(item);
|
||||
else return this.splice(index, 0, item);
|
||||
}
|
||||
}
|
||||
|
||||
//My own implementation to work around Javascript's shitty naming and support for collection operations.
|
||||
// Sorts a contiguous section of the array.
|
||||
// Index is the index of the first element to be sorted (inclusive).
|
||||
// Length is the number of elements of the array to be sorted (must be >= 2). If the length + index is greater than the array length then it will be adjusted to the end of the array.
|
||||
// All other invalid inputs will result in no sorting action taken and no error.
|
||||
if(!Array.prototype.partialSort) {
|
||||
Array.prototype.partialSort = function(index, length, compareFunction) {
|
||||
if(index >= 0 && length >= 2 && index <= (this.length - 2)) {
|
||||
//Adjust the length so it doesn't over-run the array. This is the only error correction we will perform.
|
||||
if(index + length > this.length) length = this.length - index;
|
||||
|
||||
//Shallow copy of the data in the segment to be sorted.
|
||||
let sorted = this.slice(index, length + index);
|
||||
|
||||
sorted.sort(compareFunction);
|
||||
|
||||
//Put the sorted array elements back into the array.
|
||||
for(let i = index, j = 0; i <= length; i++, j++) {
|
||||
this[i] = sorted[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
* @param {Number} [levels] How many levels to go up. Default is 1
|
||||
* @returns {Blaze.TemplateInstance}
|
||||
*/
|
||||
Blaze.TemplateInstance.prototype.parentTemplate = function(levels) {
|
||||
Blaze.TemplateInstance.prototype.parentTemplate = Blaze.TemplateInstance.prototype.parentInstance = function(levels) {
|
||||
let view = this.view;
|
||||
|
||||
levels = (typeof levels === "undefined") ? 1 : levels;
|
||||
|
||||
Reference in New Issue
Block a user