on beforeunload from window if $warnOnLeave set event.returnValue to '' call event.preventDefault() end end def Modal.ResetAssign(elId, elName) set form to #abstractAssignForm set form's @data-itemId to elId set #assignModalItemName's innerText to elName repeat for ul in <#abstractAssignForm .dropdown ul/> call filterOptions(undefined, ul) add @data-pending-reset to ul end repeat for input in set input's @data-default-value to input's @data-old-value set input's value to input's @data-default-value end repeat for div in
add .d-none to div set 's innerHtml to "" set 's innerText to "0" set 's innerText to "s" end repeat for el in <#abstractAssignForm .active/> remove .active from el end trigger resetTags on #group-group-dropdown -- Reset inputs repeat for item in <#nav-tabContent input /> if item.type is 'text' then set item.value to '' else if item.type is 'checkbox' then set item.checked to false end end -- Reset pin (doesn't exist for configurations) if (#flexSwitchCheck) set #flexSwitchCheck's checked to false end -- Reset selected items set invoices to <#selectedItems-invoice > div /> set tags to <#selectedItems-tag > div /> set accounts to <#selectedItems-account > div /> set items to [] append invoices to items append tags to items append accounts to items repeat for i in items remove i end trigger click on #device-group-tab set #device-group-tab's checked to true end def DisplayOptions(ulOptions) repeat for li in ( in ulOptions) set li.style.display to 'block' end end def CTC.isValidVin(vin) -- Check length if vin.length is not 17 return false end set upperVin to vin.toUpperCase() set invalidChars to ['I', 'O', 'Q'] -- Validate characters for char in upperVin if invalidChars.includes(char) return false end end -- valid ASCII alphanumeric check set charValues to { '0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8, 'J': 1, 'K': 2, 'L': 3, 'M': 4, 'N': 5, 'P': 7, 'R': 9, 'S': 2, 'T': 3, 'U': 4, 'V': 5, 'W': 6, 'X': 7, 'Y': 8, 'Z': 9 } for char in upperVin if charValues[char] is undefined return false end end set weights to [8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2] -- Compute checksum set checksum to 0 set i to 0 repeat 17 times set checksum to checksum + (charValues[upperVin[i]] * weights[i]) set i to i + 1 end set checksum to (checksum mod 11) -- Validate check digit set checkDigit to null if checksum is 10 set checkDigit to 'X' else set checkDigit to String.fromCharCode(checksum + 48) end return checkDigit is upperVin[8] end -- Processes an element for both HTMX and hyperscript. def ProcessElement(el) call _hyperscript.processNode(el) call htmx.process(el) end -- Processes an element for both HTMX and hyperscript. def ProcessElement(el) call _hyperscript.processNode(el) call htmx.process(el) end -- Create a clone of target in the shadow DOM. Target should have a valid id. -- All created clones will be stored inside an invisible #target div at the end of #rootContainer. -- Each shadow node containing the cloned content is also encapsulated by a container div with an id as follows: -- `${target.id}Template`. So cloning #element creates #impl__templates__ > #elementTemplate > (...shadow node) -- You can load the clone into the real DOM using the ShadowTemplate.Apply(template, target) function. def ShadowTemplate.Create(tgt) set container to #impl__templates__ make a set its @id to (tgt's @id + 'Template') set template to it js (template, tgt) const shadow = template.attachShadow({mode: 'open'}); shadow.innerHTML = tgt.innerHTML; end if #{template's @id} exists -- Ensure the "latest" template is kept. call container.replaceChild(template, #{template's @id}) else call container.appendChild(template) end end -- Apply the innerHTML of a shadow node to a target element's innerHTML. -- Pass the element containing the shadow root, typically created using ShadowTemplate.Create. def ShadowTemplate.Apply(tgt, template) set tgt.innerHTML to template.shadowRoot.innerHTML ProcessElement(tgt) end -- Fetches the template associated with tgt, if one exists. def ShadowTemplate.Fetch(tgt) set id to `${tgt.id}Template` return #{id} end -- Fetches and applies tgt's associated template to tgt. def ShadowTemplate.FApply(tgt) ShadowTemplate.Apply(tgt, ShadowTemplate.Fetch(tgt)) end