Skip to content

Commit

Permalink
Fix tiemout warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjbradshaw committed Mar 29, 2017
1 parent 245cc3b commit 18df681
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/iframeResizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,11 @@
settings[iframeId].firstRun = false;
}

function clearWarningTimeout() {
clearTimeout(settings[iframeId].msgTimeout);
settings[iframeId].warningTimeout = 0;
}

var
msg = event.data,
messageData = {},
Expand All @@ -499,8 +504,7 @@
} else if (isMessageForUs()){
messageData = processMsg();
iframeId = logId = messageData.id;

clearTimeout(settings[iframeId].msgTimeout);
settings[iframeId].loaded = true;

if (!isMessageFromMetaParent() && hasSettings(iframeId)){
log(iframeId,'Received: '+msg);
Expand Down Expand Up @@ -644,17 +648,19 @@
}

function warnOnNoResponse() {

function warning() {
warn(id, 'No response from iFrame. Check iFrameResizer.contentWindow.js has been loaded in iFrame');
if (!settings[id].loaded && !errorShown) {
errorShown = true;
warn(id, 'IFrame has not responded within '+ settings[id].warningTimeout/1000 +' seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ingored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning.');
}
}

if (!!noResponseWarning) {
if (!!noResponseWarning && !!settings[id].warningTimeout) {
settings[id].msgTimeout = setTimeout(warning, settings[id].warningTimeout);

}
}

var errorShown = false;

id = id || iframe.id;

Expand Down

0 comments on commit 18df681

Please sign in to comment.