Skip to content

Instantly share code, notes, and snippets.

@davecra
Created July 18, 2017 20:08
Show Gist options
  • Save davecra/4144f9db2d8f3470ca012d105876365e to your computer and use it in GitHub Desktop.
Save davecra/4144f9db2d8f3470ca012d105876365e to your computer and use it in GitHub Desktop.
The message handler in OfficeJS dialogs
/**
* 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