Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Statistics constructor
- var statisticsRequest = function (tier, rank) {
- this["tier"] = tier;
- this["rank"] = rank;
- this["stats"] = "";
- this["statsWindow"] = document.createElement("iframe"); //Creates an iframe
- this["statsWindow"].hidden = true;
- document.body.appendChild(this["statsWindow"]);
- this["setHandleDownloadComplete_string"] = "this.default()";
- };
- statisticsRequest.prototype = Object.create(function () { }); //Statistics prototype
- statisticsRequest.prototype.constructor = statisticsRequest; //Creates the constructor
- statisticsRequest.prototype.downloadStatistics = function () { //Downloads the statistics
- this["tier"] = this["tier"].toLowerCase();
- this["rank"] = this["rank"].toLowerCase();
- filename = this["tier"] + "-" + this["rank"] + ".txt";
- var_name = "var" + Math.floor(Math.random()*10000) + Math.floor(Math.random()*10000); //Creates a random name for a variable (It's a high number because it shouldn't be repeated)
- eval(var_name + " = ''"); //Creates a variable named after the the previous one (THIS WILL COINTAIN THE USAGE STATISTICS)
- //INCLUDE THE PATH OF THE LIBRARY ON THE LINK BELLOW
- this["statsWindow"].src = "../js/lib/statRequest.php?filename="+filename+"&id="+var_name; //Sends the name of the file and the name to the variable to the server
- this["statsWindow"].onload = (function (objThis, vname, objIframe) { return function () { objThis["stats"] = eval(vname); objThis.handleDownloadComplete(); } }) (this, var_name, this["statsWindow"]); //Handles on document load (when the data is ready)
- //this["iframe"] = statsWindow;
- };
- statisticsRequest.prototype.setAttributes = function (tier, rank) { //Sets the tier and the ranking of the statistics
- this["tier"] = tier;
- this["rank"] = rank;
- }
- //HANDLE PROGRESS
- statisticsRequest.prototype.handleDownloadComplete = function () {
- eval(this["setHandleDownloadComplete_string"]);
- };
- statisticsRequest.prototype.setHandleDownloadComplete = function (functionName) {
- this["setHandleDownloadComplete_string"] = functionName;
- };
- statisticsRequest.prototype.default = function () { }; //Empty function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement