MCPcopy
hub / github.com/ampproject/amphtml / showConfirmation_

Function showConfirmation_

tools/experiments/experiments.js:350–370  ·  view source on GitHub ↗

* Shows confirmation and calls callback if it's approved. * @param {string} message * @param {function()} callback

(message, callback)

Source from the content-addressed store, hash-verified

348 * @param {function()} callback
349 */
350function showConfirmation_(message, callback) {
351 const container = devAssert(document.getElementById('popup-container'));
352 const messageElement = devAssert(document.getElementById('popup-message'));
353 const confirmButton = devAssert(document.getElementById('popup-button-ok'));
354 const cancelButton = devAssert(
355 document.getElementById('popup-button-cancel')
356 );
357 const unlistenSet = [];
358 const closePopup = (affirmative) => {
359 container.classList.remove('show');
360 unlistenSet.forEach((unlisten) => unlisten());
361 if (affirmative) {
362 callback();
363 }
364 };
365
366 messageElement.textContent = message;
367 unlistenSet.push(listenOnce(confirmButton, 'click', () => closePopup(true)));
368 unlistenSet.push(listenOnce(cancelButton, 'click', () => closePopup(false)));
369 container.classList.add('show');
370}
371
372/**
373 * Loads the AMP_CONFIG objects from whatever the v0.js is that the user has

Callers 2

buildFunction · 0.85
toggleExperiment_Function · 0.85

Calls 6

devAssertFunction · 0.90
listenOnceFunction · 0.90
closePopupFunction · 0.85
getElementByIdMethod · 0.45
pushMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected