I think it's important to have the persistent functions/variables live outside the document loaded handler, so they persist as long as the page is being viewed by the user.
This commit is contained in:
parent
8748e6f8cf
commit
6caf85b598
@ -1,13 +1,7 @@
|
||||
// Prevent injecting the JavaScript in IFRAMES, and from acting before Safari is ready...
|
||||
if ((window.top === window) && (typeof safari != 'undefined') && (document.location != null)) {
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
if (window.top === window)
|
||||
{
|
||||
var thisPageLinkObjects = null;
|
||||
|
||||
// I convert the native "link" node into an object that I can pass out to the global page
|
||||
function objectFromLink(theLink)
|
||||
{
|
||||
function objectFromLink(theLink) {
|
||||
var linkObject = new Object();
|
||||
|
||||
linkObject.href = theLink.href;
|
||||
@ -20,8 +14,7 @@ if ((window.top === window) && (typeof safari != 'undefined') && (document.loca
|
||||
// Some sites will list feeds with inappropriate or at least less-than-ideal information
|
||||
// in the MIME type attribute. We cover some edge cases here that allow to be passed through,
|
||||
// where they will successfully open as "feed://" URLs in the browser.
|
||||
function isValidFeedLink(theLink)
|
||||
{
|
||||
function isValidFeedLink(theLink) {
|
||||
var isValid = false;
|
||||
|
||||
switch (theLink.type)
|
||||
@ -44,8 +37,7 @@ if ((window.top === window) && (typeof safari != 'undefined') && (document.loca
|
||||
return isValid;
|
||||
}
|
||||
|
||||
function scanForSyndicationFeeds()
|
||||
{
|
||||
function scanForSyndicationFeeds() {
|
||||
// In case we don't find any, we establish that we have at least tried by setting the
|
||||
// variables to empty instead of null.
|
||||
thisPageLinkObjects = []
|
||||
@ -66,8 +58,7 @@ if ((window.top === window) && (typeof safari != 'undefined') && (document.loca
|
||||
}
|
||||
}
|
||||
|
||||
function subscribeToFeed(theFeed)
|
||||
{
|
||||
function subscribeToFeed(theFeed) {
|
||||
// Convert the URL to a feed:// scheme because Safari
|
||||
// will refuse to load e.g. a feed that is listed merely
|
||||
// as "text/xml". We do some preflighting of the link rel
|
||||
@ -86,8 +77,7 @@ if ((window.top === window) && (typeof safari != 'undefined') && (document.loca
|
||||
safari.extension.dispatchMessage("subscribeToFeed", { "url": feedURL });
|
||||
}
|
||||
|
||||
safari.self.addEventListener("message", function(event)
|
||||
{
|
||||
function messageHandler(event) {
|
||||
if (event.name === "toolbarButtonClicked")
|
||||
{
|
||||
// Workaround Radar #31182842, in which residual copies of our
|
||||
@ -116,9 +106,13 @@ if ((window.top === window) && (typeof safari != 'undefined') && (document.loca
|
||||
// Pass back the same validationID we were handed so they can look up the correlated validationHandler
|
||||
safari.extension.dispatchMessage("pong", { "validationID": event.message.validationID, "shouldValidate": shouldValidate });
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
// Prevent injecting the JavaScript in IFRAMES, and from acting before Safari is ready...
|
||||
if ((window.top === window) && (typeof safari != 'undefined') && (document.location != null))
|
||||
{
|
||||
safari.self.addEventListener("message", messageHandler, false)
|
||||
scanForSyndicationFeeds();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user