Added more documentation. Added numbers function to generate a series of numbers.
This commit is contained in:
parent
d8a563df82
commit
9ccdb53eee
@ -82,7 +82,7 @@ IgniteTemplate.prototype.months = function (placeholder = null, shorthand = true
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Generates a series of days.
|
||||||
* @param {Number} from The starting day.
|
* @param {Number} from The starting day.
|
||||||
* @param {Number} to The ending day.
|
* @param {Number} to The ending day.
|
||||||
* @param {String} placeholder The placeholder option if set, it's value will be 0, this will be the text displayed.
|
* @param {String} placeholder The placeholder option if set, it's value will be 0, this will be the text displayed.
|
||||||
@ -108,3 +108,31 @@ IgniteTemplate.prototype.days = function (from = 1, to = 31, placeholder = null,
|
|||||||
|
|
||||||
return this.innerHTML(html);
|
return this.innerHTML(html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a series of numbers.
|
||||||
|
* @param {*} from The starting number.
|
||||||
|
* @param {*} to The ending number.
|
||||||
|
* @param {*} placeholder The placeholder option if set, it's value will be -1, this will be the text displayed.
|
||||||
|
* @param {*} descending Whether or not the from number if first and the to number is last.
|
||||||
|
*/
|
||||||
|
IgniteTemplate.prototype.numbers = function (from = 0, to = 100, placeholder = null, descending = false) {
|
||||||
|
//Generate html and populate the template with it.
|
||||||
|
var html = '';
|
||||||
|
|
||||||
|
if (placeholder) {
|
||||||
|
html += `<option value='-1'>${placeholder}</option>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (descending) {
|
||||||
|
for (var i = to; i >= from; i--) {
|
||||||
|
html += `<option value='${i}'>${i}</option>`;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (var i = from; i <= to; i++) {
|
||||||
|
html += `<option value='${i}'>${i}</option>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.innerHTML(html);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user