From 5cd7736afa606802be013246eab792fc35259928 Mon Sep 17 00:00:00 2001 From: MattMo Date: Sun, 11 Dec 2022 20:52:42 -0800 Subject: [PATCH] Added code to generate US States and Countries. --- ignite-html-select.js | 389 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 389 insertions(+) diff --git a/ignite-html-select.js b/ignite-html-select.js index aedb41c..bc9cf61 100644 --- a/ignite-html-select.js +++ b/ignite-html-select.js @@ -120,6 +120,395 @@ import { IgniteTemplate } from "../ignite-html/ignite-template.js"; return this.innerHTML(html); } +/** + * Generates a list of US States. + * @param {String} placeholder If set, outputs a placeholder option with a value of 0. + * @param {Boolean} shorthand If true, outputs the states in the two letter form. + * @returns {IgniteTemplate} This ignite template + */ +IgniteTemplate.prototype.states = function(placeholder = null, shorthand = true) { + //Generate html and populate the template with it. + var html = ''; + + if (placeholder) { + html += ``; + } + + if (shorthand) { + html += ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `; + } else { + html += ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `; + } + + return this.innerHTML(html); +} + +/** + * Generates a list of countries. + * @param {String} placeholder If set, outputs a placeholder option with a value of 0. + * @returns {IgniteTemplate} This ignite template + */ +IgniteTemplate.prototype.countries = function(placeholder = null) { + //Generate html and populate the template with it. + var html = ''; + + if (placeholder) { + html += ``; + } + + html += ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + `; + + return this.innerHTML(html); +} + /** * Generates a series of numbers. * @param {Number} from The starting number.