Created
July 18, 2017 20:08
-
-
Save davecra/4144f9db2d8f3470ca012d105876365e to your computer and use it in GitHub Desktop.
The message handler in OfficeJS dialogs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Handles messages coming from the parent | |
*/ | |
function startMessageHandler() { | |
setTimeout(function() { | |
var message = localStorage.getItem("dialogMessage"); | |
localStorage.setItem("dialogMessage", ""); // clear the message | |
if(message !== undefined && message !== null && message != "") | |
{ | |
var msg = JSON.parse(message); | |
if(msg.message == "update") { | |
// update the form | |
updateForm(msg.settings); | |
} else if(msg.message == "close") { | |
// do nothing special here | |
return; // stops the message pump | |
} else if(msg.message == "progress") { | |
if(msg.settings.Number > 100) return; | |
$("#bar").prop("value",msg.settings.Number); | |
} | |
} | |
startMessageHandler(); // call again | |
}, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment