Skip to content

Commit

Permalink
Fixed getScript calls in Google Feed Plugin [#613]
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher De Cairos committed Dec 22, 2011
2 parents 1951313 + b7b52ab commit 7d9c150
Showing 1 changed file with 52 additions and 52 deletions.
104 changes: 52 additions & 52 deletions plugins/googlefeed/popcorn.googlefeed.js
Expand Up @@ -2,58 +2,7 @@
(function ( Popcorn ) {

var i = 1,
scriptLoaded = false,

dynamicFeedLoad = function() {
var dontLoad = false,
k = 0,
links = document.getElementsByTagName( "link" ),
len = links.length,
head = document.head || document.getElementsByTagName( "head" )[ 0 ],
css = document.createElement( "link" ),
resource = "//www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.";

if ( !window.GFdynamicFeedControl ) {

Popcorn.getScript( resource + "js", function() {
scriptLoaded = true;
});

} else {
scriptLoaded = true;
}

// Checking if the css file is already included
for ( ; k < len; k++ ){
if ( links[ k ].href === resource + "css" ) {
dontLoad = true;
}
}

if ( !dontLoad ) {
css.type = "text/css";
css.rel = "stylesheet";
css.href = resource + "css";
head.insertBefore( css, head.firstChild );
}
};

if ( !window.google ) {

Popcorn.getScript( "//www.google.com/jsapi", function() {

google.load( "feeds", "1", {

callback: function () {

dynamicFeedLoad();
}
});
});

} else {
dynamicFeedLoad();
}
scriptLoaded = false;

/**
* googlefeed popcorn plug-in
Expand Down Expand Up @@ -81,6 +30,57 @@

Popcorn.plugin( "googlefeed", function( options ) {

var dynamicFeedLoad = function() {
var dontLoad = false,
k = 0,
links = document.getElementsByTagName( "link" ),
len = links.length,
head = document.head || document.getElementsByTagName( "head" )[ 0 ],
css = document.createElement( "link" ),
resource = "//www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.";

if ( !window.GFdynamicFeedControl ) {

Popcorn.getScript( resource + "js", function() {
scriptLoaded = true;
});

} else {
scriptLoaded = true;
}

// Checking if the css file is already included
for ( ; k < len; k++ ){
if ( links[ k ].href === resource + "css" ) {
dontLoad = true;
}
}

if ( !dontLoad ) {
css.type = "text/css";
css.rel = "stylesheet";
css.href = resource + "css";
head.insertBefore( css, head.firstChild );
}
};

if ( !window.google ) {

Popcorn.getScript( "//www.google.com/jsapi", function() {

google.load( "feeds", "1", {

callback: function () {

dynamicFeedLoad();
}
});
});

} else {
dynamicFeedLoad();
}

// create a new div and append it to the parent div so nothing
// that already exists in the parent div gets overwritten
var newdiv = document.createElement( "div" ),
Expand Down

0 comments on commit 7d9c150

Please sign in to comment.