Skip to content

Commit

Permalink
Added BitLet.js, will be used to open the download window in a popup
Browse files Browse the repository at this point in the history
  • Loading branch information
abahgat committed Feb 12, 2010
1 parent 1803513 commit fa7ff38
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions bitlet4chrome/BitLet.js
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,46 @@
var BitLet = function(){
return {
openPopup : function(torrentUrl) {
var popUpWindow = window.open("http://www.bitlet.org/download?torrent=" + torrentUrl + "&referer=" + encodeURIComponent(location.href) + '&source=bitlet4chrome','', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=150');
if (popUpWindow==null || typeof(popUpWindow)=="undefined") {
return false;
} else {
return true;
}
},


openPopupChecked : function(torrentUrl) {
if (!BitLet.openPopup(torrentUrl))
alert("Grrrr, someone is blocking the download popup window. Please disable any popup blocker.");
return false;
},

openDownloadFromAnchor : function(anchor){
var torrentUrl = BitLet.getURLParam("torrent",anchor.href);
if (torrentUrl.lenght == 0){
alert("Missing \"torrent\" parameter");
return false;
}

BitLet.openPopupChecked(torrentUrl);
return false;
},

getURLParam : function(paramName,url){
var paramValue = null;
if ( url.indexOf("?") > -1 ){
var queryString = url.substr(url.indexOf("?"));
var parameters = queryString.split("&");
for ( var i = 0; i < parameters.length; i++ ){
if ( parameters[i].indexOf(paramName + "=") > -1 ){
var paramTuple = parameters[i].split("=");
paramValue = paramTuple[1];
break;
}
}
}
return paramValue;
}
}
};

0 comments on commit fa7ff38

Please sign in to comment.