MCPcopy Create free account
hub / github.com/breck7/scroll / addOption

Function addOption

external/.datatables.js:20616–20645  ·  view source on GitHub ↗
(filt, text)

Source from the content-addressed store, hash-verified

20614 }
20615 // Function to add an option to the select element
20616 var addOption = function (filt, text) {
20617 if (that.s.type.includes("html") && filt !== null && typeof filt === "string") {
20618 filt.replace(/(<([^>]+)>)/gi, "")
20619 }
20620 // Add text and value, stripping out any html if that is the column type
20621 var opt = $$3("<option>", {
20622 type: Array.isArray(filt) ? "Array" : "String",
20623 value: filt
20624 })
20625 .data("sbv", filt)
20626 .addClass(that.classes.option)
20627 .addClass(that.classes.notItalic)
20628 // Have to add the text this way so that special html characters are not escaped - &amp; etc.
20629 .html(typeof text === "string" ? text.replace(/(<([^>]+)>)/gi, "") : text)
20630 var val = opt.val()
20631 // Check that this value has not already been added
20632 if (added.indexOf(val) === -1) {
20633 added.push(val)
20634 options.push(opt)
20635 if (preDefined !== null && Array.isArray(preDefined[0])) {
20636 preDefined[0] = preDefined[0].sort().join(",")
20637 }
20638 // If this value was previously selected as indicated by preDefined, then select it again
20639 if (preDefined !== null && opt.val() === preDefined[0]) {
20640 opt.prop("selected", true)
20641 el.removeClass(Criteria.classes.italic)
20642 that.dom.valueTitle.removeProp("selected")
20643 }
20644 }
20645 }
20646 // If this is to add the individual values within the array we need to loop over the array
20647 if (array) {
20648 for (var i = 0; i < value.filter.length; i++) {

Callers 1

.datatables.jsFile · 0.85

Calls 4

replaceMethod · 0.80
indexOfMethod · 0.80
sortMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected