Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions megaupload/megaupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,33 @@ var mgDownloadHelper = {}
mgDownloadHelper.getFileName = function(doc)
{
try {
var downloadlink = doc.getElementById("downloadlink");
var href = downloadlink.firstChild.href;
var p = href.lastIndexOf("/")
if (p!=-1) {
var fileName = href.substring(p + 1);
fileName = fileName.replace("%20", " ");
return fileName;
var downloadlink = doc.getElementById("downloadlink"); // get all the elements with the element with id as downloadlink
var href = downloadlink.firstChild.href; // take the first child and get the href element
var p = href.lastIndexOf("/") // taking out the last element after the / which is name of any object
if (p!=-1) { // check if there is / in the above href i.e. there was linkwith something
var fileName = href.substring(p + 1); // creates variable filemane with name of the original file on mega extratcted above
fileName = fileName.replace("%20", " "); // replace html space code(%20) with space of string
return fileName; // return the extracted filename
} else {
return "";
return ""; // other wise no file name was extracted
}
} catch(ex){
return "";
return ""; // if exception was catched then return null file name
}
}
mgDownloadHelper.onLoad = function()
{
var doc = document;
var downloadcounter = doc.getElementById("downloadcounter");
if (downloadcounter) {
downloadcounter.style.display = 'none';
var downloadlink = doc.getElementById("downloadlink");
if (downloadlink) {
downloadlink.hidden = true;
if (downloadlink.firstChild) downloadlink.firstChild.style.display = 'none';
var downloadcounter = doc.getElementById("downloadcounter"); // getting all the elements with id downloadcounter
if (downloadcounter) { // if there exist element with downlaodcounter
downloadcounter.style.display = 'none'; // dont show the element wich has id downloadcounter
var downloadlink = doc.getElementById("downloadlink"); // getting all the elements with id downloadlink
if (downloadlink) { // if there exist element with download link
downloadlink.hidden = true; // make downloadlink hidden
if (downloadlink.firstChild) downloadlink.firstChild.style.display = 'none'; //if there is chil d of downloadlink then make it hidden
}

var folderPath = "";
var folderPath = ""; // setting the path for download

doc.destFile = null;
var div = doc.createElement("div");
Expand All @@ -57,18 +57,18 @@ mgDownloadHelper.onLoad = function()
downloadcounter.parentNode.appendChild(div);

var ina = setInterval(function() {
var countdown = doc.getElementById("countdown");
var countdown = doc.getElementById("countdown"); // get elements with countdoen
confirmText.innerHTML = "Now you can continue browsing, the file will be downloaded automatically!<br>Your automatic download will start in <font style='font-size:12px;color:#df3f4e'><b>"+ countdown.innerHTML +"</b></font> seconds.";

if (countdown.innerHTML == "1") {
if (countdown.innerHTML == "1") { //if countdown elements is one the set timout to 1500ms
var inaa = setTimeout(function() {
var downloadlink = doc.getElementById("downloadlink");
document.location = downloadlink.firstChild.href;
}, 1500);
clearInterval(ina)
}
},1000);
},1000); // sets timer for 1000ms
}
}

mgDownloadHelper.onLoad();
mgDownloadHelper.onLoad(); // calls on load function