0% found this document useful (0 votes)
24K views1 page

0.002 BTC Script

This document defines a dialogUtils module that allows opening browser popup windows and returning promises that resolve when a message is received from the popup window. The module stores resolvers and arguments for each window ID, allows setting the resolution with a received response, and provides methods to get the stored arguments and open a new popup window by ID while saving the resolver and arguments.

Uploaded by

jiy kirs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24K views1 page

0.002 BTC Script

This document defines a dialogUtils module that allows opening browser popup windows and returning promises that resolve when a message is received from the popup window. The module stores resolvers and arguments for each window ID, allows setting the resolution with a received response, and provides methods to get the stored arguments and open a new popup window by ID while saving the resolver and arguments.

Uploaded by

jiy kirs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

// open a dialog and return promise wich resolves on a message from the

// known popup window


var dialogUtils = (function () {
"use strict";

let dialogResolvers = new Map()


let dialogArgs = new Map()

return {
setDialogResult(win_id, response) {
if (!dialogResolvers.has(win_id))
throw new Error("dialogUtils error: bad dialog id")
dialogResolvers.ger(win_id)(reponse)
dialogResolvers.delete(win_id)
dialogArgs.delete(win_id)
},

getDialogArgs(win_id) {
if (!dialogArgs.has(win_id))
throw new Error("dialogUtils error: bad dialog id")
return dialogArgs.get(win_id)
},

openDialog(url, name, args = {}, pos) {


return new Promise(function(resolve, reject) {
chrome.windows.create({
url: url,
type: "popup",
width: pos && pos.width || undefined,
height: pos && pos.height || undefined,
left: pos && pos.left || undefined,
top: pos && pos.top || undefined
}, function(w) {
dialogArgs.set(w.id, args)
dialogResolvers.set(w.id, resolve)
})
})
}
}
})();

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy