Closed GoogleCodeExporter closed 8 years ago
/** * @private, frame messaging interface (for same-domain-policy frames only) */ _XFrameMessaging : function() { // each tag gets a hash queue ($ = no tag ). var tagStack = { '$' : [] }; var isEmpty = function(v, allowBlank) { return v === null || v === undefined || (!allowBlank ? v === '' : false); }; var apply = function(o, c, defaults) { if (defaults) { apply(o, defaults); } if (o && c && typeof c == 'object') { for (var p in c) { o[p] = c[p]; } } return o; }; window.sendMessage = function(message, tag, origin) { var MIF; if (MIF = arguments.callee.manager) { if (message._fromHost) { var fn, result; // only raise matching-tag handlers var compTag = message.tag || tag || null; var mstack = !isEmpty(compTag) ? tagStack[compTag.toLowerCase()] || [] : tagStack["$"]; for (var i = 0, l = mstack.length; i < l; i++) { if (fn = mstack[i]) { result = fn.apply(fn.__scope, arguments) === false ? false : result; if (fn.__single) { mstack[i] = null; } if (result === false) { break; } } } return result; } else { message = { type : isEmpty(tag) ? 'message' : 'message:' + tag.toLowerCase().replace(/^\s+|\s+$/g, ''), data : message, domain : origin || document.domain, uri : document.documentURI, source : window, tag : isEmpty(tag) ? null : tag.toLowerCase() }; try { return MIF.disableMessaging !== true ? MIF.fireEvent.call(MIF, message.type, MIF, message) : null; } catch (ex) { } // trap for message:tag handlers not yet defined return null; } } }; window.onhostmessage = function(fn, scope, single, tag) { if (typeof fn == 'function') { if (!isEmpty(fn.__index)) { throw "onhostmessage: duplicate handler definition" + (tag ? " for tag:" + tag : ''); } var k = isEmpty(tag) ? "$" : tag.toLowerCase(); tagStack[k] || (tagStack[k] = []); apply(fn, { __tag : k, __single : single || false, __scope : scope || window, __index : tagStack[k].length }); tagStack[k].push(fn); } else { throw "onhostmessage: function required"; } }; window.unhostmessage = function(fn) { if (typeof fn == 'function' && typeof fn.__index != 'undefined') { var k = fn.__tag || "$"; tagStack[k][fn.__index] = null; } }; },
Original issue reported on code.google.com by livin...@gmail.com on 15 May 2009 at 11:25
livin...@gmail.com
What exactly IS the issue?
Original comment by BeamG...@gmail.com on 15 May 2009 at 11:54
BeamG...@gmail.com
Thx: livinphp. Missed that one. ;)
Original comment by BeamG...@gmail.com on 16 May 2009 at 1:58
Original issue reported on code.google.com by
livin...@gmail.com
on 15 May 2009 at 11:25