diff --git a/audiocontext-setsinkid/app.js b/audiocontext-setsinkid/app.js index 79d6b5fc..37b52c77 100644 --- a/audiocontext-setsinkid/app.js +++ b/audiocontext-setsinkid/app.js @@ -7,13 +7,13 @@ playBtn.disabled = true; mediaDeviceBtn.addEventListener('click', async () => { if ("setSinkId" in AudioContext.prototype) { - selectDiv.innerHTML = ''; + selectDiv.replaceChildren(); const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); const devices = await navigator.mediaDevices.enumerateDevices(); const label = document.createElement('label'); - label.innerHTML = 'Select output device:'; + label.textContent = 'Select output device:'; label.htmlFor = 'output-device-select'; const select = document.createElement('select'); @@ -54,8 +54,17 @@ mediaDeviceBtn.addEventListener('click', async () => { stream.getAudioTracks().forEach((track) => track.stop()); } else { + const elem = (tag,props={})=> Object.assign(document.createElement(tag),props); const para = document.createElement('p'); - para.innerHTML = 'Your browser doesn\'t support AudioContext.setSinkId(). Check the browser compatibility information to see which browsers support it.' + para.append( + "Your browser doesn\'t support ", + elem('code',{textContent:"AudioContext.setSinkId()"}),". Check the ", + elem('a',{ + href:"https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/setSinkId#browser_compatibility", + textContent:"browser compatibility information" + }), + " to see which browsers support it." + ); selectDiv.appendChild(para); } }); diff --git a/channel-messaging-multimessage/index.html b/channel-messaging-multimessage/index.html index a24e137e..56462f1f 100644 --- a/channel-messaging-multimessage/index.html +++ b/channel-messaging-multimessage/index.html @@ -51,7 +51,7 @@

Channel messaging demo

// Handle messages received on port1 function onMessage(e) { - output.innerHTML = e.data; + output.textContent = e.data; input.value = ""; } diff --git a/contact-picker/demo.js b/contact-picker/demo.js index ed565c3f..db9373d5 100644 --- a/contact-picker/demo.js +++ b/contact-picker/demo.js @@ -61,7 +61,7 @@ async function getContacts() { function handleResults(contacts) { ulResults.classList.toggle("success", true); ulResults.classList.toggle("error", false); - ulResults.innerHTML = ""; + ulResults.replaceChildren(); renderResults(contacts); } @@ -72,24 +72,32 @@ function enableProp(cbox) { function renderResults(contacts) { contacts.forEach((contact) => { - const lines = []; - if (contact.name) lines.push(`Name: ${contact.name.join(", ")}`); - if (contact.email) lines.push(`E-mail: ${contact.email.join(", ")}`); - if (contact.tel) lines.push(`Telephone: ${contact.tel.join(", ")}`); + const li = document.createElement("li"); + function newLine(key,value){ + li.appendChild(document.createElement('b')).textContent = key + ": "; + if(value instanceof Node) li.appendChild(value); + else if(value != null && value !== "") li.appendChild(document.createTextNode(value)); + li.appendChild(document.createElement('br')); + } + if (contact.name) newLine("Name",contact.name.join(", ")); + if (contact.email) newLine("E-Mail",contact.email.join(", ")); + if (contact.tel) newLine("Telephone",contact.tel.join(", ")); if (contact.address) { contact.address.forEach((address) => { - lines.push(`Address: ${JSON.stringify(address)}`); + newLine("Address",JSON.stringify(address)); }); } if (contact.icon) { contact.icon.forEach((icon) => { const imgURL = URL.createObjectURL(icon); - lines.push(`Icon: `); + const img = document.createElement("img"); + img.src=imgURL; + newLine("Icon", img); }); } - lines.push(`Raw: ${JSON.stringify(contact)}`); - const li = document.createElement("li"); - li.innerHTML = lines.join("
"); + const code = document.createElement('code'); + code.textContent = JSON.stringify(contact); + newLine("Raw",code); ulResults.appendChild(li); }); const strContacts = JSON.stringify(contacts, null, 2); diff --git a/edit-context/html-editor/editor.js b/edit-context/html-editor/editor.js index 1abad15e..247a011b 100644 --- a/edit-context/html-editor/editor.js +++ b/edit-context/html-editor/editor.js @@ -80,7 +80,7 @@ if (IS_CUSTOM_HIGHLIGHT_SUPPORTED) { // The render function's job is to update the view when the model changes. function render(text, selectionStart, selectionEnd) { // Empty the editor. We're re-rendering everything. - editorEl.innerHTML = ""; + editorEl.replaceChildren(); // Tokenize the text. currentTokens = tokenizeHTML(text); diff --git a/execcommand/script.js b/execcommand/script.js index 2c3c5f7c..e9e5219a 100644 --- a/execcommand/script.js +++ b/execcommand/script.js @@ -250,8 +250,8 @@ commands.forEach((command) => { } else { button.setAttribute("disabled", "true"); } - button.innerHTML = ` ${command.name}`; + const i = document.createElement("i"); + i.className = command.icon ? `fa fa-${command.icon}` : ""; + button.append(i, ` ${command.name}`); buttons.appendChild(button); }); diff --git a/fetch/fetch-array-buffer/index.html b/fetch/fetch-array-buffer/index.html index d8feaa3e..c9a414c3 100644 --- a/fetch/fetch-array-buffer/index.html +++ b/fetch/fetch-array-buffer/index.html @@ -53,7 +53,7 @@

Fetch arrayBuffer example

play.onclick = () => { getData() .then((source) => { - errorDisplay.innerHTML = ""; + errorDisplay.replaceChildren(); currentSource = source; currentSource.start(0); play.disabled = true; @@ -73,7 +73,7 @@

Fetch arrayBuffer example

}; // dump script to pre element - pre.innerHTML = myScript.innerHTML; + pre.textContent = myScript.textContent; diff --git a/indexeddb-examples/idbcursor/scripts/main.js b/indexeddb-examples/idbcursor/scripts/main.js index f4a8a170..52f036ff 100644 --- a/indexeddb-examples/idbcursor/scripts/main.js +++ b/indexeddb-examples/idbcursor/scripts/main.js @@ -78,7 +78,7 @@ window.onload = function () { }; function displayData() { - list.innerHTML = ""; + list.replaceChildren(); const transaction = db.transaction(["rushAlbumList"], "readonly"); const objectStore = transaction.objectStore("rushAlbumList"); @@ -86,11 +86,9 @@ window.onload = function () { const cursor = event.target.result; if (cursor) { const listItem = document.createElement("li"); - listItem.innerHTML = - "" + - cursor.value.albumTitle + - ", " + - cursor.value.year; + const strong = document.createElement('strong'); + strong.textContent = cursor.value.albumTitle; + listItem.append(strong,", ",cursor.value.year); list.appendChild(listItem); //console.log(cursor.source); @@ -109,7 +107,7 @@ window.onload = function () { }; function advanceResult() { - list.innerHTML = ""; + list.replaceChildren(); const transaction = db.transaction(["rushAlbumList"], "readonly"); const objectStore = transaction.objectStore("rushAlbumList"); @@ -117,11 +115,9 @@ window.onload = function () { const cursor = event.target.result; if (cursor) { const listItem = document.createElement("li"); - listItem.innerHTML = - "" + - cursor.value.albumTitle + - ", " + - cursor.value.year; + const strong = document.createElement('strong'); + strong.textContent = cursor.value.albumTitle; + listItem.append(strong,", ",cursor.value.year); list.appendChild(listItem); cursor.advance(2); } else { @@ -135,7 +131,7 @@ window.onload = function () { }; function deleteResult() { - list.innerHTML = ""; + list.replaceChildren(); const transaction = db.transaction(["rushAlbumList"], "readwrite"); const objectStore = transaction.objectStore("rushAlbumList"); @@ -151,11 +147,9 @@ window.onload = function () { }; } else { const listItem = document.createElement("li"); - listItem.innerHTML = - "" + - cursor.value.albumTitle + - ", " + - cursor.value.year; + const strong = document.createElement('strong'); + strong.textContent = cursor.value.albumTitle; + listItem.append(strong,", ",cursor.value.year); list.appendChild(listItem); } cursor.continue(); @@ -170,7 +164,7 @@ window.onload = function () { }; function updateResult() { - list.innerHTML = ""; + list.replaceChildren(); const transaction = db.transaction(["rushAlbumList"], "readwrite"); const objectStore = transaction.objectStore("rushAlbumList"); @@ -188,11 +182,9 @@ window.onload = function () { } const listItem = document.createElement("li"); - listItem.innerHTML = - "" + - cursor.value.albumTitle + - ", " + - cursor.value.year; + const strong = document.createElement('strong'); + strong.textContent = cursor.value.albumTitle; + listItem.append(strong,", ",cursor.value.year); list.appendChild(listItem); cursor.continue(); @@ -207,7 +199,7 @@ window.onload = function () { }; function backwards() { - list.innerHTML = ""; + list.replaceChildren(); const transaction = db.transaction(["rushAlbumList"], "readonly"); const objectStore = transaction.objectStore("rushAlbumList"); @@ -215,11 +207,9 @@ window.onload = function () { const cursor = event.target.result; if (cursor) { const listItem = document.createElement("li"); - listItem.innerHTML = - "" + - cursor.value.albumTitle + - ", " + - cursor.value.year; + const strong = document.createElement('strong'); + strong.textContent = cursor.value.albumTitle; + listItem.append(strong,", ",cursor.value.year); list.appendChild(listItem); console.log(cursor.direction); diff --git a/indexeddb-examples/idbindex/scripts/main.js b/indexeddb-examples/idbindex/scripts/main.js index 8a1a4ac4..a1a9bcd6 100644 --- a/indexeddb-examples/idbindex/scripts/main.js +++ b/indexeddb-examples/idbindex/scripts/main.js @@ -166,7 +166,7 @@ window.onload = function () { for (let i = 0; i < thControls.length; i++) { const activeThead = thControls[i]; activeThead.onclick = function (e) { - activeIndex = e.target.innerHTML; + activeIndex = e.target.textContent; if (activeIndex == "ID") { displayDataByKey(); } else { @@ -190,7 +190,7 @@ window.onload = function () { } function displayDataByKey() { - tableEntry.innerHTML = ""; + tableEntry.replaceChildren(); const transaction = db.transaction(["contactsList"], "readonly"); const objectStore = transaction.objectStore("contactsList"); @@ -198,31 +198,23 @@ window.onload = function () { const cursor = event.target.result; if (cursor) { const tableRow = document.createElement("tr"); - tableRow.innerHTML = - "" + - cursor.value.id + - "" + - "" + - cursor.value.lName + - "" + - "" + - cursor.value.fName + - "" + - "" + - cursor.value.jTitle + - "" + - "" + - cursor.value.company + - "" + - "" + - cursor.value.eMail + - "" + - "" + - cursor.value.phone + - "" + - "" + - cursor.value.age + - ""; + const fields = [ + cursor.value.id, + cursor.value.lName, + cursor.value.fName, + cursor.value.jTitle, + cursor.value.company, + cursor.value.eMail, + cursor.value.phone, + cursor.value.age + ]; + + fields.forEach(value => { + const td = document.createElement("td"); + td.textContent = value; + tableRow.appendChild(td); + }); + tableEntry.appendChild(tableRow); cursor.continue(); @@ -233,7 +225,7 @@ window.onload = function () { } function displayDataByIndex(activeIndex) { - tableEntry.innerHTML = ""; + tableEntry.replaceChildren(); const transaction = db.transaction(["contactsList"], "readonly"); const objectStore = transaction.objectStore("contactsList"); @@ -268,31 +260,24 @@ window.onload = function () { const cursor = event.target.result; if (cursor) { const tableRow = document.createElement("tr"); - tableRow.innerHTML = - "" + - cursor.value.id + - "" + - "" + - cursor.value.lName + - "" + - "" + - cursor.value.fName + - "" + - "" + - cursor.value.jTitle + - "" + - "" + - cursor.value.company + - "" + - "" + - cursor.value.eMail + - "" + - "" + - cursor.value.phone + - "" + - "" + - cursor.value.age + - ""; + + const values = [ + cursor.value.id, + cursor.value.lName, + cursor.value.fName, + cursor.value.jTitle, + cursor.value.company, + cursor.value.eMail, + cursor.value.phone, + cursor.value.age + ]; + + values.forEach(val => { + const td = document.createElement("td"); + td.textContent = val; + tableRow.appendChild(td); + }); + tableEntry.appendChild(tableRow); cursor.continue(); diff --git a/indexeddb-examples/idbkeyrange/scripts/main.js b/indexeddb-examples/idbkeyrange/scripts/main.js index 398ee909..d495fab2 100644 --- a/indexeddb-examples/idbkeyrange/scripts/main.js +++ b/indexeddb-examples/idbkeyrange/scripts/main.js @@ -139,7 +139,7 @@ window.onload = function () { console.log(keyRangeValue.upperOpen); } - list.innerHTML = ""; + list.replaceChildren(); const transaction = db.transaction(["fThings"], "readonly"); let objectStore = transaction.objectStore("fThings"); @@ -157,11 +157,9 @@ window.onload = function () { const cursor = event.target.result; if (cursor) { const listItem = document.createElement("li"); - listItem.innerHTML = - "" + - cursor.value.fThing + - ", " + - cursor.value.fRating; + const strong = document.createElement('strong'); + strong.textContent = cursor.value.fThing; + listItem.replaceChildren(strong,", ",cursor.value.fRating); list.appendChild(listItem); cursor.continue(); diff --git a/local-font-access/index.js b/local-font-access/index.js index 99fb017c..372ae3cc 100644 --- a/local-font-access/index.js +++ b/local-font-access/index.js @@ -15,7 +15,10 @@ async function populatefonts() { const availableFonts = await window.queryLocalFonts(); console.log(availableFonts); for (const fontData of availableFonts) { - selectElem.innerHTML += ``; + const option = document.createElement('option'); + option.value = fontData.family; + option.textContent = fontData.fullName; + selectElem.appendChild(option); } selectElemContainer.style.display = "block"; diff --git a/media/mediaerror/index.html b/media/mediaerror/index.html index 22f28bb9..fb8f6b20 100644 --- a/media/mediaerror/index.html +++ b/media/mediaerror/index.html @@ -1,6 +1,8 @@ - + + + MediaError Example diff --git a/media/mediaerror/main.js b/media/mediaerror/main.js index 6e503696..252afbd8 100644 --- a/media/mediaerror/main.js +++ b/media/mediaerror/main.js @@ -1,8 +1,13 @@ window.addEventListener("load", startup, false); -function displayErrorMessage(msg) { - document.getElementById("log").innerHTML += msg; +function displayErrorMessage(code,msg) { + const p = document.createElement("p"); + p.textContent = msg; + const strong = document.createElement("strong"); + strong.textContent = "Error: "+ code +" "; + p.prepend(strong); + document.getElementById("log").appendChild(p); } function startup() { @@ -46,6 +51,6 @@ function startup() { s += " " + message; } - displayErrorMessage("Error " + err.code + ": " + s + "
"); + displayErrorMessage(err.code , s); }; } diff --git a/pointerevents/Multi-touch_interaction.html b/pointerevents/Multi-touch_interaction.html index c62d8a1a..e189c956 100644 --- a/pointerevents/Multi-touch_interaction.html +++ b/pointerevents/Multi-touch_interaction.html @@ -44,20 +44,12 @@ function log(name, ev) { var o = document.getElementsByTagName("output")[0]; - var s = - name + - ": pointerID = " + - ev.pointerId + - " ; pointerType = " + - ev.pointerType + - " ; isPrimary = " + - ev.isPrimary; - o.innerHTML += s + "
"; + o.innerText += `${name}: pointerID = ${ev.pointerId} ; pointerType = ${ev.pointerType} ; isPrimary = ${ev.isPrimary} \n`; } function clearLog(event) { var o = document.getElementsByTagName("output")[0]; - o.innerHTML = ""; + o.replaceChildren(); } function update_background(ev) { diff --git a/pointerevents/Pinch_zoom_gestures.html b/pointerevents/Pinch_zoom_gestures.html index 6d4bcce6..53aeb695 100644 --- a/pointerevents/Pinch_zoom_gestures.html +++ b/pointerevents/Pinch_zoom_gestures.html @@ -34,20 +34,12 @@ function log(prefix, ev) { if (!logEvents) return; var o = document.getElementsByTagName("output")[0]; - var s = - prefix + - ": pointerID = " + - ev.pointerId + - " ; pointerType = " + - ev.pointerType + - " ; isPrimary = " + - ev.isPrimary; - o.innerHTML += s + "
"; + o.innerText += `${prefix}: pointerID = ${ev.pointerId} ; pointerType = ${ev.pointerType} ; isPrimary = ${ev.isPrimary} \n`; } function clearLog(event) { var o = document.getElementsByTagName("output")[0]; - o.innerHTML = ""; + o.replaceChildren(); } function pointerdown_handler(ev) { diff --git a/pointerevents/Using_Pointer_Events.html b/pointerevents/Using_Pointer_Events.html index a44e1df2..90a41dca 100644 --- a/pointerevents/Using_Pointer_Events.html +++ b/pointerevents/Using_Pointer_Events.html @@ -127,7 +127,8 @@ function log(msg) { var p = document.getElementById('log'); - p.innerHTML = msg + "\n" + p.innerHTML; + const txtNode = document.createTextNode(msg+ "\n"); + p.prepend(txtNode); } diff --git a/server-sent-events/index.html b/server-sent-events/index.html index 6fa5fadf..2bf748bf 100644 --- a/server-sent-events/index.html +++ b/server-sent-events/index.html @@ -42,7 +42,7 @@ // var newElement = document.createElement("li"); // // var obj = JSON.parse(e.data); - // newElement.innerHTML = "ping at " + obj.time; + // newElement.textContent = "ping at " + obj.time; // eventList.appendChild(newElement); // }, false); diff --git a/service-worker/simple-service-worker/app.js b/service-worker/simple-service-worker/app.js index e5f4f308..82064924 100644 --- a/service-worker/simple-service-worker/app.js +++ b/service-worker/simple-service-worker/app.js @@ -45,7 +45,7 @@ const createGalleryFigure = async (galleryImage) => { const myName = document.createElement('span'); myName.textContent = `${galleryImage.name}: `; const myCredit = document.createElement('span'); - myCredit.innerHTML = `Taken by ${galleryImage.credit}`; + myCredit.textContent = `Taken by ${galleryImage.credit}`; myCaption.append(myName, myCredit); myImage.src = window.URL.createObjectURL(imageBlob); myImage.setAttribute('alt', galleryImage.alt); diff --git a/touchevents/Multi-touch_interaction.html b/touchevents/Multi-touch_interaction.html index 1541a352..7750153b 100644 --- a/touchevents/Multi-touch_interaction.html +++ b/touchevents/Multi-touch_interaction.html @@ -48,20 +48,20 @@ ev.targetTouches.length + " ; changedTouches = " + ev.changedTouches.length; - o.innerHTML += s + "
"; + o.innerText += s + " \n"; if (printTargetIds) { s = ""; for (var i = 0; i < ev.targetTouches.length; i++) { - s += "... id = " + ev.targetTouches[i].identifier + "
"; + s += "... id = " + ev.targetTouches[i].identifier + " \n"; } - o.innerHTML += s; + o.innerText += s; } } function clearLog(event) { var o = document.getElementsByTagName("output")[0]; - o.innerHTML = ""; + o.replaceChildren(); } function update_background(ev) { diff --git a/viewport-segments-api/index.js b/viewport-segments-api/index.js index 293f6a6e..60087767 100644 --- a/viewport-segments-api/index.js +++ b/viewport-segments-api/index.js @@ -34,8 +34,11 @@ function addSegmentOutput(segments, i, elem) { elem.appendChild(divElem); - divElem.innerHTML = `

Viewport segment ${i + 1}

-

${segment.width}px x ${segment.height}px

`; + const h2 = document.createElement('h2'); + h2.textContent = `Viewport segment ${i + 1}`; + const p = document.createElement('p'); + p.textContent = `${segment.width}px x ${segment.height}px`; + divElem.append(h2,p); } function reportSegments() { diff --git a/web-speech-api/on-device-speech-color-changer/script.js b/web-speech-api/on-device-speech-color-changer/script.js index b1bbccce..9dc7bbf1 100644 --- a/web-speech-api/on-device-speech-color-changer/script.js +++ b/web-speech-api/on-device-speech-color-changer/script.js @@ -76,12 +76,18 @@ const bg = document.querySelector("html"); const hints = document.querySelector(".hints"); const startBtn = document.querySelector("button"); -let colorHTML = ""; +let colorHTML = document.createDocumentFragment(); colors.forEach(function (v, i, a) { console.log(v, i); - colorHTML += `${v} `; + const span = document.createElement('span'); + span.textContent = v; + span.style.backgroundColor = v; + colorHTML.append(span," "); }); -hints.innerHTML = `Press the button then say a color to change the background color of the app. For example, you could try ${colorHTML}`; +hints.replaceChildren( + `Press the button then say a color to change the background color of the app. For example, you could try`, + colorHTML + ); startBtn.addEventListener("click", () => { // check availability of target language diff --git a/web-speech-api/speak-easy-synthesis/script.js b/web-speech-api/speak-easy-synthesis/script.js index 4ff5fe51..1dea8f27 100644 --- a/web-speech-api/speak-easy-synthesis/script.js +++ b/web-speech-api/speak-easy-synthesis/script.js @@ -26,7 +26,7 @@ function populateVoiceList() { }); const selectedIndex = voiceSelect.selectedIndex < 0 ? 0 : voiceSelect.selectedIndex; - voiceSelect.innerHTML = ""; + voiceSelect.replaceChildren(); for (let i = 0; i < voices.length; i++) { const option = document.createElement("option"); diff --git a/web-speech-api/speech-color-changer/script.js b/web-speech-api/speech-color-changer/script.js index 10c41538..1c0872a5 100644 --- a/web-speech-api/speech-color-changer/script.js +++ b/web-speech-api/speech-color-changer/script.js @@ -63,15 +63,15 @@ const bg = document.querySelector("html"); const hints = document.querySelector(".hints"); const startBtn = document.querySelector("button"); -let colorHTML = ""; +let colorHTML = document.createDocumentFragment(); colors.forEach(function (v, i, a) { console.log(v, i); - colorHTML += ' ' + v + " "; + const span = document.createElement('span'); + span.style.backgroundColor = v; + span.textContent = v; + colorHTML.appendChild(span); }); -hints.innerHTML = - "Press the button then say a color to change the background color of the app. Try " + - colorHTML + - "."; +hints.append("Press the button then say a color to change the background color of the app. Try ", colorHTML, "."); startBtn.onclick = function () { recognition.start(); diff --git a/web-speech-api/speech-color-changer/style.css b/web-speech-api/speech-color-changer/style.css index 2b5c06fb..79d0c4a5 100644 --- a/web-speech-api/speech-color-changer/style.css +++ b/web-speech-api/speech-color-changer/style.css @@ -37,3 +37,6 @@ ul { .hints span { text-shadow: 0px 0px 6px rgba(255, 255, 255, 0.7); } +.hints{ + overflow-wrap: break-word; +} \ No newline at end of file diff --git a/webxr/script.js b/webxr/script.js index 5ed08581..aa86e74e 100644 --- a/webxr/script.js +++ b/webxr/script.js @@ -675,25 +675,48 @@ function renderScene(gl, view, programInfo, buffers, texture, deltaTime) { // MathML-rendered matrix, because MathML is nifty! function displayMatrix(mat, rowLength, target) { - let outHTML = ""; if (mat && rowLength && rowLength <= mat.length) { - let numRows = mat.length / rowLength; - outHTML = - "\n\n[\n\n"; + const numRows = mat.length / rowLength; + + const math = document.createElementNS("http://www.w3.org/1998/Math/MathML", "math"); + math.setAttribute("display", "block"); + + const mrow = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mrow"); + + const openBracket = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mo"); + openBracket.textContent = "["; + mrow.appendChild(openBracket); + + const mtable = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mtable"); for (let y = 0; y < numRows; y++) { - outHTML += "\n"; + const mtr = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mtr"); + for (let x = 0; x < rowLength; x++) { - outHTML += `${mat[x * rowLength + y].toFixed(2)}\n`; + const mtd = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mtd"); + const mn = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mn"); + + const value = mat[y * rowLength + x]; + mn.textContent = Number(value).toFixed(2); + + mtd.appendChild(mn); + mtr.appendChild(mtd); } - outHTML += "\n"; + + mtable.appendChild(mtr); } - outHTML += "\n]\n\n"; - } + mrow.appendChild(mtable); - target.innerHTML = outHTML; + const closeBracket = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mo"); + closeBracket.textContent = "]"; + mrow.appendChild(closeBracket); + + math.appendChild(mrow); + + target.replaceChildren(math); + } } // diff --git a/webxr/webxr-polyfill.js b/webxr/webxr-polyfill.js index 7911f64b..467167ef 100644 --- a/webxr/webxr-polyfill.js +++ b/webxr/webxr-polyfill.js @@ -4411,7 +4411,7 @@ function RotateInstructions() { s.lineHeight = '24px'; s.margin = '24px 25%'; s.width = '50%'; - text.innerHTML = 'Place your phone into your Cardboard viewer.'; + text.textContent = 'Place your phone into your Cardboard viewer.'; overlay.appendChild(text); var snackbar = document.createElement('div'); var s = snackbar.style; @@ -4426,10 +4426,10 @@ function RotateInstructions() { overlay.appendChild(snackbar); var snackbarText = document.createElement('div'); snackbarText.style.float = 'left'; - snackbarText.innerHTML = 'No Cardboard viewer?'; + snackbarText.textContent = 'No Cardboard viewer?'; var snackbarButton = document.createElement('a'); snackbarButton.href = 'https://www.google.com/get/cardboard/get-cardboard/'; - snackbarButton.innerHTML = 'get one'; + snackbarButton.textContent = 'get one'; snackbarButton.target = '_blank'; var s = snackbarButton.style; s.float = 'right'; @@ -4591,7 +4591,7 @@ ViewerSelector.prototype.createH1_ = function (name) { s.fontWeight = 'bold'; s.marginTop = 0; s.marginBottom = '24px'; - h1.innerHTML = name; + h1.textContent = name; return h1; }; ViewerSelector.prototype.createChoice_ = function (id, name) { @@ -4607,14 +4607,14 @@ ViewerSelector.prototype.createChoice_ = function (id, name) { var label = document.createElement('label'); label.style.marginLeft = '4px'; label.setAttribute('for', id); - label.innerHTML = name; + label.textContent = name; div.appendChild(input); div.appendChild(label); return div; }; ViewerSelector.prototype.createButton_ = function (label, onclick) { var button = document.createElement('button'); - button.innerHTML = label; + button.textContent = label; var s = button.style; s.float = 'right'; s.textTransform = 'uppercase'; diff --git a/window-management-api/index.js b/window-management-api/index.js index ee53ec0e..84d10e2b 100644 --- a/window-management-api/index.js +++ b/window-management-api/index.js @@ -74,16 +74,26 @@ function createPopover() { popoverElem = document.createElement('div'); popoverElem.id = "block-warning"; popoverElem.popover = "manual"; - popoverElem.innerHTML = ` -

Please disable popup blocking

-

Your browser is blocking the app's popup windows. Please enable popups and then try again. - You can do this by clicking the icon to the right of your web address bar, selecting the "Always allow..." - option, then clicking "Done".

- - Browser dialog window with title Popups blocked, showing options to allow popups or keep blocking them, with Done and Manage buttons at the bottom - -

- `; + const h2 = document.createElement("h2"); + h2.textContent = "Please disable popup blocking"; + + const p1 = document.createElement("p"); + p1.textContent = + "Your browser is blocking the app's popup windows. Please enable popups and then try again. " + + 'You can do this by clicking the icon to the right of your web address bar, selecting the "Always allow..." option, then clicking "Done".'; + + const img = document.createElement("img"); + img.src = "popups-blocked.png"; + img.alt = "Browser dialog window with title Popups blocked, showing options to allow popups or keep blocking them, with Done and Manage buttons at the bottom"; + + const button = document.createElement("button"); + button.id = "popover-dismiss"; + button.textContent = "OK, got it"; + + const p2 = document.createElement("p"); + p2.append(button); + + popoverElem.replaceChildren(h2, p1, img, p2); document.body.append(popoverElem);