Permalink
Browse files

Added BitLet.js, will be used to open the download window in a popup

  • Loading branch information...
1 parent 1803513 commit fa7ff382b55471e96606ff9fdaf11a053da4d022 @abahgat committed Feb 12, 2010
Showing with 46 additions and 0 deletions.
  1. +46 −0 bitlet4chrome/BitLet.js
View
@@ -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.