functionaddEnvironmentFormToBody() { var form = document.createElement('div'); form.style = "position:absolute;width:600px;height:100px;top:200px;" form.innerHTML = generateForm(); document.body.appendChild(form); addChangeEventListenerToPlatformSelect(); addClickEventListenerToOpenButton(); }
functionaddClickEventListenerToOpenButton () { document.getElementById('openBtn').onclick = function () { var urlSelect = document.getElementById("openUrl"); var index = urlSelect.selectedIndex; window.open(urlSelect.options[index].value); } }
functionaddChangeEventListenerToPlatformSelect() { var platformSelect = document.getElementById('openPlatform'); var urlSelect = document.getElementById("openUrl"); platformSelect.onchange = function () { var index = platformSelect.selectedIndex; urlSelect.innerHTML = ""; var urlOptions = urls[platformSelect.options[index].value]; urlSelect.innerHTML = Object.keys(urlOptions).map((env) => { return`<option value='${urlOptions[env]}'>${env}</option>`; }).join('\n'); } fireChange(platformSelect); }
functionfireChange(element) { if ("createEvent"indocument) { var evt = document.createEvent("HTMLEvents"); evt.initEvent("change", false, true); element.dispatchEvent(evt); } else { element.fireEvent("onchange"); } } })();