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

Script

The document discusses a dialogUtils module that handles opening and resolving popup windows in the Chrome browser. It defines functions to set the result of a dialog, get the arguments passed to a dialog, and open a dialog window by URL, returning a Promise.
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)
3K views1 page

Script

The document discusses a dialogUtils module that handles opening and resolving popup windows in the Chrome browser. It defines functions to set the result of a dialog, get the arguments passed to a dialog, and open a dialog window by URL, returning a Promise.
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

To // know popup windowvar 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.get(win_id)(response)
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: "gopup",
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