<commit_before>var CORS_PROXY_URL = "https://cors-anywhere.herokuapp.com/";
var CHECK_DOWNLOADS_FINISHED_EVERY_MS = 100;

/* User options */
var userDownload;
var targetName;
var section;
var nameFormat;
var restrictByScore;
var restrictByScoreType;
var restrictByScoreValue;
var includeImages;
var includeGifs;
var includeNsfw;

var checkFinishedInterval;
var downloadRequests = new Set();
var downloadedCount;
var toDownloadCount;
var zip;

$(document).ready(function() {
    setRandomNamePlaceholder();

    $(".ui.checkbox").checkbox();
    $("select.dropdown").dropdown();

    /* Make sure one or both of include images and include animated images are checked */
    $.fn.form.settings.rules.includeAny = function(value) {
        return $("#includeImagesInput").parent().checkbox("is checked")
            || $("#includeGifsInput").parent().checkbox("is checked");
    };

    $(".ui.form")
        .form({
            fields: {
                targetNameInput : "empty",
                imageAmountInput : "integer[0..]",
                restrictByScoreValueInput : "integer[0..]",
                includeImagesInput : "includeAny",
                includeGifsInput : "includeAny"
            }
        })
        .on("change", "#includeImagesInput,#includeGifsInput", function(e) {
            /*
                Removes the red text from include images/include
                animated images when one of them have been pressed.
            */
            $(".ui.form").form("validate form");
        });

    $("#restrictByScoreInput").parent().checkbox({
        onChange: function() {
            if (this.checked) {
                $("#restrictByScoreTypeInput").parent().removeClass("disabled");
            } else {
                $("#restrictByScoreTypeInput").parent().addClass("disabled");
            }
            $("#restrictByScoreValueInput").prop("disabled", !this.checked);
        }
    });

    $("#userDownloadInput").parent().checkbox({
        onChange: function() {
            if (this.checked) {
                $("label[for=targetNameInput]").text("User Name");
                $("#sectionInput").parent().parent().fadeOut("fast");
                $("#targetNameInput").removeAttr("placeholder");
            } else {
                $("label[for=targetNameInput]").text("Subreddit Name");
                $("#sectionInput").parent().parent().fadeIn("fast");
                setRandomNamePlaceholder();
            }
        }
    });
});

$("#downloadButton").click(function() {
    if ($(".ui.form").form("validate form")) {
        /* Reset states */
        $(".ui.form").addClass("loading");
        $("#unknownNameErrorBox").hide();
        $("#noImagesFoundWarningBox").hide();
        $("#downloadingInfoBox").show();
        downloadRequests.clear();
        downloadedCount = 0;
        toDownloadCount = 0;
        zip = new JSZip();
        updateUI();

        /* Read user options */
        userDownload = $("#userDownloadInput").parent().checkbox("is checked");
        targetName = $("#targetNameInput").val();
        section = $("#sectionInput").val();
        nameFormat = $("#nameFormatInput").val();
        restrictByScore = $("#restrictByScoreInput").parent().checkbox("is checked");
        restrictByScoreType = $("#restrictByScoreTypeInput").val();
        restrictByScoreValue = $("#restrictByScoreValueInput").val();
        includeImages = $("#includeImagesInput").parent().checkbox("is checked");
        includeGifs = $("#includeGifsInput").parent().checkbox("is checked");
        includeNsfw = $("#includeNsfwInput").parent().checkbox("is checked");

        if (userDownload) {
            /* Handle the user entering /user/ or user/ before the user name */
            if (targetName.startsWith("/user/")) {
                targetName = targetName.substring(3);
            } else if (targetName.startsWith("user/")) {
                targetName = targetName.substring(2);
            }
        } else {
            /* Handle the user entering /r/ or r/ before the sub name */
            if (targetName.startsWith("/r/")) {
                targetName = targetName.substring(3);
            } else if (targetName.startsWith("r/")) {
                targetName = targetName.substring(2);
            }
        }

        $(".targetNameText").text(targetName);

        if (userDownload) {
            $(".downloadTypeText").text("user");
        } else {
            $(".downloadTypeText").text("subreddit");
        }

        /* Find images to scrape and start downloading */
        var maxImageCount = $("#imageAmountInput").val();
        download(maxImageCount);
    }
});

function updateUI() {
    $("#downloadedCountText").text(downloadedCount);
    $("#toDownloadCountText").text(toDownloadCount);
}

function download(maxImageCount, anchor) {
    /* Max 100 posts per request */
    var maxImageCountNow = Math.min(maxImageCount, 100);

    /* Prevent extreme amounts of requests in the case that maxImageCountNow is for example 1 */
    if (maxImageCountNow < 50) {
        maxImageCountNow = 50;
    }

    var url;

    if (userDownload) {
        url = CORS_PROXY_URL
            + "https://www.reddit.com/user/" + targetName
            + ".json?limit=" + maxImageCountNow
            + (anchor !== undefined ? "&after=" + anchor : "");
    } else {
        url = CORS_PROXY_URL
            + "https://www.reddit.com/r/" + targetName
            + "/" + section + ".json?limit=" + maxImageCountNow
            + (anchor !== undefined ? "&after=" + anchor : "");
    }

    $.ajax({
        url: url,
        type: "GET",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function(result, status, xhr) {
            /* Make sure we haven't been redirected to the search page = subreddit doesn't exist */
            if (!userDownload && xhr.getResponseHeader("X-Final-Url").indexOf(section + ".json") === -1) {
                $("#unknownNameErrorBox").show();
                doneDownloading();
                return;
            }

            var children = result.data.children;

            var downloadedCountNow = 0;

            for (var i = 0; i < children.length; i++) {
                var post = children[i].data;

                /* Only download if there's a thumbnail */
                if (post.thumbnail_width === null) {
                    continue;
                }

                /* Respect user's nsfw option */
                if (!includeNsfw && post.over_18) {
                    continue;
                }

                /* Check if there are any images, there should be, but let's make sure */
                if (post.preview === undefined || post.preview.images.length == 0) {
                    continue;
                }

                /* Don't download images that come from posts with greater/less score than inputted */
                if (restrictByScore) {
                    if ((restrictByScoreType === "ge" && post.score < restrictByScoreValue)
                            || (restrictByScoreType === "le" && post.score > restrictByScoreValue)) {
                        continue;
                    }
                }

                var url = post.preview.images[0].source.url;

                if (isUrlFileFormatAccepted(url)) {
                    /* Force https */
                    if (url.startsWith("http:")) {
                        url = url.replace("http:", "https:");
                    }

                    toDownloadCount++;
                    downloadedCountNow++;
                    updateUI();

                    downloadImageAsBase64(url, post, function(url, post, data) {
                        var destinationFileName;

                        if (nameFormat === "file-name") {
                            destinationFileName = getFileNameWithExtension(url);
                        } else if (nameFormat === "post-id") {
                            destinationFileName = post.name + getFileExtension(url);
                        } else {
                            /* default: post-name */
                            var regex = /[^\/]+(?=\/$|$)/g;
                            var postName = regex.exec(post.permalink)[0];
                            destinationFileName = postName + getFileExtension(url);
                        }

                        zip.file(destinationFileName, data, { base64: true });
                        downloadedCount++;
                        updateUI();
                    });

                    if (downloadedCountNow == maxImageCount) {
                        break;
                    }
                }
            }

            maxImageCount -= downloadedCountNow;

            if (children.length === 0 || maxImageCount === 0) {
                checkFinishedInterval = setInterval(function() {
                    if (downloadedCount == toDownloadCount) {
                        doneDownloading();
                    }
                }, CHECK_DOWNLOADS_FINISHED_EVERY_MS);
            } else {
                if (result.data.after !== null) {
                    download(maxImageCount, result.data.after);
                } else {
                    /* If there are no more posts, quit */
                    doneDownloading();
                }
            }
        },
        error: function(error) {
            if (error.status === 404 || error.status === 403) {
                /* If HTTP status is 404 or 403, the subreddit probably doesn't exist */
                $("#unknownNameErrorBox").show();
            } else if (error.status !== 200) {
                /* Notify user when a non-handled status code is received */
                alert("Unknown status code " + error.status + " received from lookup request.\nPlease contact the developer.");
            }
            doneDownloading();
        }
    });
}

function isUrlFileFormatAccepted(url) {
    return (includeImages && (url.indexOf(".jpg?") !== -1 || url.indexOf(".png?") !== -1))
        || (includeGifs && (url.indexOf(".gif?") !== -1 || url.indexOf(".gifv?") !== -1));
}

function getFileNameWithExtension(url) {
    var regex = /[^/\\&\?]+\.\w{3,4}(?=[\?&].*$|$)/;
    var m = regex.exec(url);
    return m[0];
}

function getFileExtension(url) {
    var fileNameWithExt = getFileNameWithExtension(url);

    return fileNameWithExt
        .substring(fileNameWithExt.lastIndexOf("."));
}

function doneDownloading() {
    for (var xhr in downloadRequests) {
        xhr.abort();
    }

    clearInterval(checkFinishedInterval);

    if (downloadedCount > 0) {
        zip.generateAsync({ type:"blob" })
            .then(function(content) {
                saveAs(content, targetName + "_" + section + ".zip");
            });
    } else {
        /* Only show the "no images found" warning if the subreddit exists */
        if (!$("#unknownNameErrorBox").is(":visible")) {
            $("#noImagesFoundWarningBox").show();
        }
    }

    $(".ui.form").removeClass("loading");
    $("#downloadingInfoBox").hide();
}

function downloadImageAsBase64(url, post, callback) {
    var xhr = new XMLHttpRequest();
    xhr.onload = function() {
        downloadRequests.delete(this);

        var reader = new FileReader();
        reader.onloadend = function() {
            callback(url, post, reader.result.split(",").pop());
        }
        reader.readAsDataURL(xhr.response);
    };
    xhr.open("GET", CORS_PROXY_URL + url);
    xhr.responseType = "blob";
    xhr.send();

    downloadRequests.add(xhr);
}

/*
    Puts a random subreddit as sub name inputbox placeholder,
    list taken from https://www.reddit.com/reddits
*/
function setRandomNamePlaceholder() {
    var subreddits = [
        "funny",
        "pics",
        "me_irl",
        "aww",
        "dankmemes",
        "mildlyinteresting",
        "AdviceAnimals",
        "CrappyDesign",
        "OldSchoolCool",
        "2007scape"
    ];
    $("#targetNameInput").attr("placeholder",
        subreddits[Math.floor(Math.random() * subreddits.length)]);
}

// https://stackoverflow.com/a/30949767/4313694
$("button").on("mousedown",
    function(event) {
        event.preventDefault();
    }
);
<commit_msg>Disable section dropdown instead of fading<commit_after>var CORS_PROXY_URL = "https://cors-anywhere.herokuapp.com/";
var CHECK_DOWNLOADS_FINISHED_EVERY_MS = 100;

/* User options */
var userDownload;
var targetName;
var section;
var nameFormat;
var restrictByScore;
var restrictByScoreType;
var restrictByScoreValue;
var includeImages;
var includeGifs;
var includeNsfw;

var checkFinishedInterval;
var downloadRequests = new Set();
var downloadedCount;
var toDownloadCount;
var zip;

$(document).ready(function() {
    setRandomNamePlaceholder();

    $(".ui.checkbox").checkbox();
    $("select.dropdown").dropdown();

    /* Make sure one or both of include images and include animated images are checked */
    $.fn.form.settings.rules.includeAny = function(value) {
        return $("#includeImagesInput").parent().checkbox("is checked")
            || $("#includeGifsInput").parent().checkbox("is checked");
    };

    $(".ui.form")
        .form({
            fields: {
                targetNameInput : "empty",
                imageAmountInput : "integer[0..]",
                restrictByScoreValueInput : "integer[0..]",
                includeImagesInput : "includeAny",
                includeGifsInput : "includeAny"
            }
        })
        .on("change", "#includeImagesInput,#includeGifsInput", function(e) {
            /*
                Removes the red text from include images/include
                animated images when one of them have been pressed.
            */
            $(".ui.form").form("validate form");
        });

    $("#restrictByScoreInput").parent().checkbox({
        onChange: function() {
            if (this.checked) {
                $("#restrictByScoreTypeInput").parent().removeClass("disabled");
            } else {
                $("#restrictByScoreTypeInput").parent().addClass("disabled");
            }
            $("#restrictByScoreValueInput").prop("disabled", !this.checked);
        }
    });

    $("#userDownloadInput").parent().checkbox({
        onChange: function() {
            if (this.checked) {
                $("label[for=targetNameInput]").text("User Name");
                $("#sectionInput").parent().addClass("disabled");
                $("#targetNameInput").removeAttr("placeholder");
            } else {
                $("label[for=targetNameInput]").text("Subreddit Name");
                $("#sectionInput").parent().removeClass("disabled");
                setRandomNamePlaceholder();
            }
        }
    });
});

$("#downloadButton").click(function() {
    if ($(".ui.form").form("validate form")) {
        /* Reset states */
        $(".ui.form").addClass("loading");
        $("#unknownNameErrorBox").hide();
        $("#noImagesFoundWarningBox").hide();
        $("#downloadingInfoBox").show();
        downloadRequests.clear();
        downloadedCount = 0;
        toDownloadCount = 0;
        zip = new JSZip();
        updateUI();

        /* Read user options */
        userDownload = $("#userDownloadInput").parent().checkbox("is checked");
        targetName = $("#targetNameInput").val();
        section = $("#sectionInput").val();
        nameFormat = $("#nameFormatInput").val();
        restrictByScore = $("#restrictByScoreInput").parent().checkbox("is checked");
        restrictByScoreType = $("#restrictByScoreTypeInput").val();
        restrictByScoreValue = $("#restrictByScoreValueInput").val();
        includeImages = $("#includeImagesInput").parent().checkbox("is checked");
        includeGifs = $("#includeGifsInput").parent().checkbox("is checked");
        includeNsfw = $("#includeNsfwInput").parent().checkbox("is checked");

        if (userDownload) {
            /* Handle the user entering /user/ or user/ before the user name */
            if (targetName.startsWith("/user/")) {
                targetName = targetName.substring(3);
            } else if (targetName.startsWith("user/")) {
                targetName = targetName.substring(2);
            }
        } else {
            /* Handle the user entering /r/ or r/ before the sub name */
            if (targetName.startsWith("/r/")) {
                targetName = targetName.substring(3);
            } else if (targetName.startsWith("r/")) {
                targetName = targetName.substring(2);
            }
        }

        $(".targetNameText").text(targetName);

        if (userDownload) {
            $(".downloadTypeText").text("user");
        } else {
            $(".downloadTypeText").text("subreddit");
        }

        /* Find images to scrape and start downloading */
        var maxImageCount = $("#imageAmountInput").val();
        download(maxImageCount);
    }
});

function updateUI() {
    $("#downloadedCountText").text(downloadedCount);
    $("#toDownloadCountText").text(toDownloadCount);
}

function download(maxImageCount, anchor) {
    /* Max 100 posts per request */
    var maxImageCountNow = Math.min(maxImageCount, 100);

    /* Prevent extreme amounts of requests in the case that maxImageCountNow is for example 1 */
    if (maxImageCountNow < 50) {
        maxImageCountNow = 50;
    }

    var url;

    if (userDownload) {
        url = CORS_PROXY_URL
            + "https://www.reddit.com/user/" + targetName
            + ".json?limit=" + maxImageCountNow
            + (anchor !== undefined ? "&after=" + anchor : "");
    } else {
        url = CORS_PROXY_URL
            + "https://www.reddit.com/r/" + targetName
            + "/" + section + ".json?limit=" + maxImageCountNow
            + (anchor !== undefined ? "&after=" + anchor : "");
    }

    $.ajax({
        url: url,
        type: "GET",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function(result, status, xhr) {
            /* Make sure we haven't been redirected to the search page = subreddit doesn't exist */
            if (!userDownload && xhr.getResponseHeader("X-Final-Url").indexOf(section + ".json") === -1) {
                $("#unknownNameErrorBox").show();
                doneDownloading();
                return;
            }

            var children = result.data.children;

            var downloadedCountNow = 0;

            for (var i = 0; i < children.length; i++) {
                var post = children[i].data;

                /* Only download if there's a thumbnail */
                if (post.thumbnail_width === null) {
                    continue;
                }

                /* Respect user's nsfw option */
                if (!includeNsfw && post.over_18) {
                    continue;
                }

                /* Check if there are any images, there should be, but let's make sure */
                if (post.preview === undefined || post.preview.images.length == 0) {
                    continue;
                }

                /* Don't download images that come from posts with greater/less score than inputted */
                if (restrictByScore) {
                    if ((restrictByScoreType === "ge" && post.score < restrictByScoreValue)
                            || (restrictByScoreType === "le" && post.score > restrictByScoreValue)) {
                        continue;
                    }
                }

                var url = post.preview.images[0].source.url;

                if (isUrlFileFormatAccepted(url)) {
                    /* Force https */
                    if (url.startsWith("http:")) {
                        url = url.replace("http:", "https:");
                    }

                    toDownloadCount++;
                    downloadedCountNow++;
                    updateUI();

                    downloadImageAsBase64(url, post, function(url, post, data) {
                        var destinationFileName;

                        if (nameFormat === "file-name") {
                            destinationFileName = getFileNameWithExtension(url);
                        } else if (nameFormat === "post-id") {
                            destinationFileName = post.name + getFileExtension(url);
                        } else {
                            /* default: post-name */
                            var regex = /[^\/]+(?=\/$|$)/g;
                            var postName = regex.exec(post.permalink)[0];
                            destinationFileName = postName + getFileExtension(url);
                        }

                        zip.file(destinationFileName, data, { base64: true });
                        downloadedCount++;
                        updateUI();
                    });

                    if (downloadedCountNow == maxImageCount) {
                        break;
                    }
                }
            }

            maxImageCount -= downloadedCountNow;

            if (children.length === 0 || maxImageCount === 0) {
                checkFinishedInterval = setInterval(function() {
                    if (downloadedCount == toDownloadCount) {
                        doneDownloading();
                    }
                }, CHECK_DOWNLOADS_FINISHED_EVERY_MS);
            } else {
                if (result.data.after !== null) {
                    download(maxImageCount, result.data.after);
                } else {
                    /* If there are no more posts, quit */
                    doneDownloading();
                }
            }
        },
        error: function(error) {
            if (error.status === 404 || error.status === 403) {
                /* If HTTP status is 404 or 403, the subreddit probably doesn't exist */
                $("#unknownNameErrorBox").show();
            } else if (error.status !== 200) {
                /* Notify user when a non-handled status code is received */
                alert("Unknown status code " + error.status + " received from lookup request.\nPlease contact the developer.");
            }
            doneDownloading();
        }
    });
}

function isUrlFileFormatAccepted(url) {
    return (includeImages && (url.indexOf(".jpg?") !== -1 || url.indexOf(".png?") !== -1))
        || (includeGifs && (url.indexOf(".gif?") !== -1 || url.indexOf(".gifv?") !== -1));
}

function getFileNameWithExtension(url) {
    var regex = /[^/\\&\?]+\.\w{3,4}(?=[\?&].*$|$)/;
    var m = regex.exec(url);
    return m[0];
}

function getFileExtension(url) {
    var fileNameWithExt = getFileNameWithExtension(url);

    return fileNameWithExt
        .substring(fileNameWithExt.lastIndexOf("."));
}

function doneDownloading() {
    for (var xhr in downloadRequests) {
        xhr.abort();
    }

    clearInterval(checkFinishedInterval);

    if (downloadedCount > 0) {
        zip.generateAsync({ type:"blob" })
            .then(function(content) {
                saveAs(content, targetName + "_" + section + ".zip");
            });
    } else {
        /* Only show the "no images found" warning if the subreddit exists */
        if (!$("#unknownNameErrorBox").is(":visible")) {
            $("#noImagesFoundWarningBox").show();
        }
    }

    $(".ui.form").removeClass("loading");
    $("#downloadingInfoBox").hide();
}

function downloadImageAsBase64(url, post, callback) {
    var xhr = new XMLHttpRequest();
    xhr.onload = function() {
        downloadRequests.delete(this);

        var reader = new FileReader();
        reader.onloadend = function() {
            callback(url, post, reader.result.split(",").pop());
        }
        reader.readAsDataURL(xhr.response);
    };
    xhr.open("GET", CORS_PROXY_URL + url);
    xhr.responseType = "blob";
    xhr.send();

    downloadRequests.add(xhr);
}

/*
    Puts a random subreddit as sub name inputbox placeholder,
    list taken from https://www.reddit.com/reddits
*/
function setRandomNamePlaceholder() {
    var subreddits = [
        "funny",
        "pics",
        "me_irl",
        "aww",
        "dankmemes",
        "mildlyinteresting",
        "AdviceAnimals",
        "CrappyDesign",
        "OldSchoolCool",
        "2007scape"
    ];
    $("#targetNameInput").attr("placeholder",
        subreddits[Math.floor(Math.random() * subreddits.length)]);
}

// https://stackoverflow.com/a/30949767/4313694
$("button").on("mousedown",
    function(event) {
        event.preventDefault();
    }
);
<|endoftext|>


<commit_before>/// #order #vidInfo #vidLength

var feed = document.getElementById("feed");
var list = ["empty"];
var userInput = document.getElementById('userInput');
var userSubmit = document.getElementById('userSubmit');

/////// List creator. Called by other functions when the list needs to be recreated////////

function listCreate() {

  console.log("Creating list");
    feed.innerHTML = "";
  for(var x=1;x<list.length;x++){

    var card = document.createElement('div');  /// create the card itself,  which contains the below divs.
    card.className = "card";
    card.id =  "card" + x;
    feed.appendChild(card);

    var order = document.createElement('div');   ///create ordered number (place in list)
    order.className = "order";
    order.textContent = x;
    card.appendChild(order);

    var vidInfo = document.createElement('div');  /// Create video info (title)///
    vidInfo.className = "vidInfo";
    vidInfo.textContent = list[x];
    card.appendChild(vidInfo);

    //var vidLength = document.createElement('div');   ///  create Video length
    //vidLength.className="vidLength";
    //vidLength.textContent = list[x];
    //card.appendChild(vidLength);

    var delButton = document.createElement('div');  /////create delete button
    delButton.className = "fontawesome-minus";
    card.appendChild(delButton);

    function deleteCard(x) {
      console.log(x);
      list.splice(x,1);
      listCreate();
    };

    delButton.onclick = function(){
      deleteCard(x);
    };

  };
};

function user() {
  list[list.length] = userInput.value;
  listCreate();
}

userSubmit.onclick = function() {
  user();
};

listCreate();

/// note ON HOW TO REMOVE CARD:  remove list[x]<commit_msg>Initial deletion function<commit_after>/// #order #vidInfo #vidLength

var feed = document.getElementById("feed");
var list = ["empty"];
var userInput = document.getElementById('userInput');
var userSubmit = document.getElementById('userSubmit');

/////// List creator. Called by other functions when the list needs to be recreated////////

function listCreate() {

    console.log("Creating list");

    feed.innerHTML = "";
    for(var x=1;x<list.length;x++){

    var card = document.createElement('div');  /// create the card itself,  which contains the below divs.
    card.className = "card";
    card.id =  "card" + x;
    feed.appendChild(card);

    var order = document.createElement('div');   ///create ordered number (place in list)
    order.className = "order";
    order.textContent = x;
    card.appendChild(order);

    var vidInfo = document.createElement('div');  /// Create video info (title)///
    vidInfo.className = "vidInfo";
    vidInfo.textContent = list[x];
    card.appendChild(vidInfo);

    //var vidLength = document.createElement('div');   ///  create Video length
    //vidLength.className="vidLength";
    //vidLength.textContent = list[x];
    //card.appendChild(vidLength);

    var delButton = document.createElement('div');  /////create delete button
    delButton.className = "fontawesome-minus";
    card.appendChild(delButton);

    delButton.onclick = function(x){
      list.splice(x,1);
      listCreate();
    };

  };
};

function user() {
  list[list.length] = userInput.value;
  listCreate();
}

userSubmit.onclick = function() {
  user();
};

listCreate();<|endoftext|>


<commit_before>var app = angular.module('app', []);

app.controller("MainCtrl", function($scope, $interval, $timeout) {
  angular.extend($scope, {
    curDollar: 1000,
    roi: 0.8,
    variance: 0.7,
    log: [],
    games: {},
    allTiers: [
  		{
  			name: "Indie Game",
  			cost: 1000,
  			time: 20,
  			initialAwareness: 0.2,
  			unlockRequirement: null
  		},
  		{
  			name: "Small Game",
  			cost: 5000,
  			time: 30,
  			initialAwareness: 0.3,
  			unlockRequirement: null
  		},
  		{
  			name: "Medium Game",
  			cost: 20000,
  			time: 100,
  			initialAwareness: 0.4,
  			unlockRequirement: null
  		},
  		{
  			name: "Large Game",
  			cost: 130000,
  			time: 500,
  			initialAwareness: 0.6,
  			unlockRequirement: "cost"
  		},
  		{
  			name: "Epic Game",
  			cost: 2000000,
  			time: 800,
  			initialAwareness: 0.8,
  			unlockRequirement: "cost"
  		},
  		{
  			name: "Legendary Game",
  			cost: 40000000,
  			time: 1200,
  			initialAwareness: 1,
  			unlockRequirement: "success"
  		}
  	],
    tiers: [],
    timer: {
  	  gameSpeed: 1,
  	  gameSpeedCounter: 0,
  	  awarenessMax: 10,
  	  awarenessCounter: 0,
  	  progressMax: 1,
  	  progressCounter: 0
  	},
  	recurringSalesOn: true,
  	projects: [],
  	games: [],
  	name: ""
  });

	function initializeTiers() {
		$scope.tiers = [];
		for(var i = 0; i < $scope.allTiers.length; i++) {
		  var tier = $scope.allTiers[i];

		  if(tier.unlockRequirement === null){
		    $scope.tiers.push(tier);
		  }
		  else if(tier.unlockRequirement === "cost") {
		    if($scope.curDollar > tier.cost*0.1) {
		      $scope.tiers.push(tier);
		    }
		  }
		  else if(tier.unlockRequirement === "success") {
		    // add success criteria
		  }

		}
	}
	initializeTiers();

	$scope.start = function() {
	  $scope.curDollar = 4200;
	  $scope.roi = 0.8;
	  $scope.variance = 0.7;
		$scope.started = true;
	}
	$scope.start();

	$scope.makeGame = function(tier) {
		if($scope.curDollar < tier.cost) {
			return false;
		}
		$scope.curDollar -= tier.cost;

		$scope.requestName = true;
		$scope.name = "";
		$scope.curTier = tier;
	}

	$scope.giveMoney = function(amount){
		$scope.curDollar += amount;

		$scope.log.push("dSolver thanks you for thinking about him, and rewarded you with $"+amount);
	}

	$scope.startProject = function() {
		$scope.requestName = false;
		$scope.curProject = {
			name: $scope.name,
			tier: $scope.curTier,
			investment: $scope.curTier.cost,
			progress: 0,
			max: $scope.curTier.time
		}
	}

	$scope.boost = function() {
		var cost = $scope.curProject.tier.cost * 0.1;
		if($scope.curDollar < cost) {
		  return false;
		}

    var msg = "You spent $" + cost + " to speed up development time, it ";
		var max = Math.floor($scope.curProject.max / 10);
		var result = randDec(-max/4, max);
		if(result >= max/2) {
		  msg += "went fantastic!";
		} else if(result >= 0 && result < max/2) {
		  msg += "went alright.";
		} else {
		  msg += "went disastrously.";
		}

		$scope.curProject.progress += result;
		result = Math.round(result / $scope.curProject.max * 100);
		msg += " (" + result + "%)";
		$scope.curDollar -= cost
		$scope.curProject.investment += cost/2; // managers trying to speed up development isn't as worthwhile
		$scope.log.unshift(msg);
	}

	$scope.changeGameSpeed = function(val) {
	  $scope.timer.gameSpeed = val;
	}

	$scope.boostAwareness = function(game){
		$scope.curDollar -= Math.round(game.sales/3);
		game.awareness += randInt(10, 50)/100;
		if(game.awareness > 1){
			game.awareness = 1;
		}
	}
	$interval(gameTick, 100);

	function randInt(min, max) {
	  if(!min) min = 0;
	  if(!max) max = 100;
	  return Math.floor(Math.random() * (max - min) + min);
	}

	function randDec(min, max) {
	  if(!min) min = 0;
	  if(!max) max = 1;
	  return Math.random() * (max - min) + min;
	}

	function getReleaseProjectPerformance(initialSales, investment) {
		var ratio = initialSales / investment;

		var performances = [
				"dismally",
				"pretty bad",
				"alright",
				"better than expected",
				"pretty well",
				"amazingly"
		];

		var performance;
		if (ratio < 0.5) {
			performance = performances[0];
		} else if (ratio < 0.75) {
			performance = performances[1];
		} else if (ratio < 1.12) {
			performance = performances[2];
		} else if (ratio < 1.4) {
			performance = performances[3];
		} else if (ratio < 1.8) {
			performance = performances[4];
		} else {
			performance = performances[5];
		}
		return performance;
	}

	function gameTick() {
	  $scope.timer.gameSpeedCounter += $scope.timer.gameSpeed;
	  while($scope.timer.gameSpeedCounter >= 1) {
	    $scope.timer.gameSpeedCounter--;

  		$scope.timer.progressCounter++;
  		while($scope.timer.progressCounter >= $scope.timer.progressMax) {
  		  $scope.timer.progressCounter -= $scope.timer.progressMax;
  		  tickProjectProgress();
  		}

  		$scope.timer.awarenessCounter++;
  		while($scope.timer.awarenessCounter >= $scope.timer.awarenessMax) {
  		  $scope.timer.awarenessCounter -= $scope.timer.awarenessMax;
  		  tickGameAwareness();
  		}

  		var oldDollar = $scope.curDollar;
  		if (!$scope.curProject && $scope.curDollar === oldDollar && $scope.games.length > 0 && $scope.curDollar < $scope.tiers[0].cost * 0.1) {
  			$timeout(function() {
  				$scope.gameOver = true;
  				$scope.timer.gameSpeed = 0;
  			}, 2500);
  		}
	  }
	}

	function tickProjectProgress() {
		if ($scope.curProject) {
			$scope.curProject.progress += 0.1;
			if ($scope.curProject.progress >= $scope.curProject.max) {
				$scope.games[$scope.curProject.tier];

				var investment = $scope.curProject.investment;
				var initialSales = investment * (1 - $scope.variance) + Math.ceil(Math.random() * investment * (($scope.variance) * 2 * $scope.roi));
				var performance = getReleaseProjectPerformance(initialSales, investment);

        initialSales = Math.round(initialSales);
				$scope.curDollar += initialSales;

				var game = {
					name: $scope.curProject.name,
					sales: initialSales,
					recurringSales: 0,
					awareness: $scope.curProject.tier.initialAwareness,
					releaseSales: initialSales,
					releaseAwareness: $scope.curProject.tier.initialAwareness,
					releasePerformance: performance
				}

				$scope.games.push(game);
				$scope.log.unshift("Your " + $scope.curProject.tier.name + ", " + $scope.curProject.name + "  performed " + performance + ", it made $" + initialSales);
				$scope.curProject = null;

			}
		}
	}

	function tickGameAwareness() {
		if ($scope.games.length > 0 && $scope.recurringSalesOn) {
			angular.forEach($scope.games, function(game, index) {
				if (game.awareness > 0) {
					var recurringsale = game.releaseSales / 20 * game.awareness;

					$scope.curDollar += recurringsale;
					game.recurringSales += recurringsale;

					game.awareness -= randDec(0.005,0.015);

					if (game.awareness < 0) {
						game.awareness = 0;
					}
				}

			});
		}
	}

});

app.filter('reverse', function() {
  return function(items) {
    return items.slice().reverse();
  };
});<commit_msg>Now for functions!<commit_after>var app = angular.module('app', []);

app.controller("MainCtrl", function($scope, $interval, $timeout) {
  angular.extend($scope, {
    curDollar: 1000,
    roi: 0.8,
    variance: 0.7,
    log: [],
    games: {},
    allTiers: [
  		{
  			name: "Indie Game",
  			cost: 1000,
  			time: 20,
  			initialAwareness: 0.2,
  			unlockRequirement: null
  		},
  		{
  			name: "Small Game",
  			cost: 5000,
  			time: 30,
  			initialAwareness: 0.3,
  			unlockRequirement: null
  		},
  		{
  			name: "Medium Game",
  			cost: 20000,
  			time: 100,
  			initialAwareness: 0.4,
  			unlockRequirement: null
  		},
  		{
  			name: "Large Game",
  			cost: 130000,
  			time: 500,
  			initialAwareness: 0.6,
  			unlockRequirement: "cost"
  		},
  		{
  			name: "Epic Game",
  			cost: 2000000,
  			time: 800,
  			initialAwareness: 0.8,
  			unlockRequirement: "cost"
  		},
  		{
  			name: "Legendary Game",
  			cost: 40000000,
  			time: 1200,
  			initialAwareness: 1,
  			unlockRequirement: "success"
  		}
  	],
    tiers: [],
    timer: {
  	  gameSpeed: 1,
  	  gameSpeedCounter: 0,
  	  awarenessMax: 10,
  	  awarenessCounter: 0,
  	  progressMax: 1,
  	  progressCounter: 0
  	},
  	recurringSalesOn: true,
  	projects: [],
  	games: [],
  	name: ""
  });

  angular.extend($scope, {
  	start: function() {
  	  $scope.curDollar = 4200;
  	  $scope.roi = 0.8;
  	  $scope.variance = 0.7;
  		$scope.started = true;
  	},

  	makeGame: function(tier) {
  		if($scope.curDollar < tier.cost) {
  			return false;
  		}
  		$scope.curDollar -= tier.cost;

  		$scope.requestName = true;
  		$scope.name = "";
  		$scope.curTier = tier;
  	},

  	giveMoney: function(amount){
  		$scope.curDollar += amount;

  		$scope.log.push("dSolver thanks you for thinking about him, and rewarded you with $"+amount);
  	},

  	startProject: function() {
  		$scope.requestName = false;
  		$scope.curProject = {
  			name: $scope.name,
  			tier: $scope.curTier,
  			investment: $scope.curTier.cost,
  			progress: 0,
  			max: $scope.curTier.time
  		}
  	},

  	boost: function() {
  		var cost = $scope.curProject.tier.cost * 0.1;
  		if($scope.curDollar < cost) {
  		  return false;
  		}

      var msg = "You spent $" + cost + " to speed up development time, it ";
  		var max = Math.floor($scope.curProject.max / 10);
  		var result = randDec(-max/4, max);
  		if(result >= max/2) {
  		  msg += "went fantastic!";
  		} else if(result >= 0 && result < max/2) {
  		  msg += "went alright.";
  		} else {
  		  msg += "went disastrously.";
  		}

  		$scope.curProject.progress += result;
  		result = Math.round(result / $scope.curProject.max * 100);
  		msg += " (" + result + "%)";
  		$scope.curDollar -= cost
  		$scope.curProject.investment += cost/2; // managers trying to speed up development isn't as worthwhile
  		$scope.log.unshift(msg);
  	},

  	changeGameSpeed: function(val) {
  	  $scope.timer.gameSpeed = val;
  	},

  	boostAwareness: function(game){
  		$scope.curDollar -= Math.round(game.sales/3);
  		game.awareness += randInt(10, 50)/100;
  		if(game.awareness > 1){
  			game.awareness = 1;
  		}
  	},

  	initializeTiers: function() {
  		$scope.tiers = [];
  		for(var i = 0; i < $scope.allTiers.length; i++) {
  		  var tier = $scope.allTiers[i];

  		  if(tier.unlockRequirement === null){
  		    $scope.tiers.push(tier);
  		  }
  		  else if(tier.unlockRequirement === "cost") {
  		    if($scope.curDollar > tier.cost*0.1) {
  		      $scope.tiers.push(tier);
  		    }
  		  }
  		  else if(tier.unlockRequirement === "success") {
  		    // add success criteria
  		  }

  		}
  	},

  	getReleaseProjectPerformance: function(initialSales, investment) {
  		var ratio = initialSales / investment;

  		var performances = [
  				"dismally",
  				"pretty bad",
  				"alright",
  				"better than expected",
  				"pretty well",
  				"amazingly"
  		];

  		var performance;
  		if (ratio < 0.5) {
  			performance = performances[0];
  		} else if (ratio < 0.75) {
  			performance = performances[1];
  		} else if (ratio < 1.12) {
  			performance = performances[2];
  		} else if (ratio < 1.4) {
  			performance = performances[3];
  		} else if (ratio < 1.8) {
  			performance = performances[4];
  		} else {
  			performance = performances[5];
  		}
  		return performance;
  	},

  	gameTick: function() {
  	  $scope.timer.gameSpeedCounter += $scope.timer.gameSpeed;
  	  while($scope.timer.gameSpeedCounter >= 1) {
  	    $scope.timer.gameSpeedCounter--;

    		$scope.timer.progressCounter++;
    		while($scope.timer.progressCounter >= $scope.timer.progressMax) {
    		  $scope.timer.progressCounter -= $scope.timer.progressMax;
    		  $scope.tickProjectProgress();
    		}

    		$scope.timer.awarenessCounter++;
    		while($scope.timer.awarenessCounter >= $scope.timer.awarenessMax) {
    		  $scope.timer.awarenessCounter -= $scope.timer.awarenessMax;
    		  $scope.tickGameAwareness();
    		}

    		var oldDollar = $scope.curDollar;
    		if (!$scope.curProject && $scope.curDollar === oldDollar && $scope.games.length > 0 && $scope.curDollar < $scope.tiers[0].cost * 0.1) {
    			$timeout(function() {
    				$scope.gameOver = true;
    				$scope.timer.gameSpeed = 0;
    			}, 2500);
    		}
  	  }
  	},

  	tickProjectProgress: function() {
  		if ($scope.curProject) {
  			$scope.curProject.progress += 0.1;
  			if ($scope.curProject.progress >= $scope.curProject.max) {
  				$scope.games[$scope.curProject.tier];

  				var investment = $scope.curProject.investment;
  				var initialSales = investment * (1 - $scope.variance) + Math.ceil(Math.random() * investment * (($scope.variance) * 2 * $scope.roi));
  				var performance = $scope.getReleaseProjectPerformance(initialSales, investment);

          initialSales = Math.round(initialSales);
  				$scope.curDollar += initialSales;

  				var game = {
  					name: $scope.curProject.name,
  					sales: initialSales,
  					recurringSales: 0,
  					awareness: $scope.curProject.tier.initialAwareness,
  					releaseSales: initialSales,
  					releaseAwareness: $scope.curProject.tier.initialAwareness,
  					releasePerformance: performance
  				}

  				$scope.games.push(game);
  				$scope.log.unshift("Your " + $scope.curProject.tier.name + ", " + $scope.curProject.name + "  performed " + performance + ", it made $" + initialSales);
  				$scope.curProject = null;

  			}
  		}
  	},

  	tickGameAwareness: function() {
  		if ($scope.games.length > 0 && $scope.recurringSalesOn) {
  			angular.forEach($scope.games, function(game, index) {
  				if (game.awareness > 0) {
  					var recurringsale = game.releaseSales / 20 * game.awareness;

  					$scope.curDollar += recurringsale;
  					game.recurringSales += recurringsale;

  					game.awareness -= randDec(0.005,0.015);

  					if (game.awareness < 0) {
  						game.awareness = 0;
  					}
  				}

  			});
  		}
  	}

  });

	$scope.initializeTiers();
	$scope.start();
	$interval($scope.gameTick, 100);

	function randInt(min, max) {
	  if(!min) min = 0;
	  if(!max) max = 100;
	  return Math.floor(Math.random() * (max - min) + min);
	}

	function randDec(min, max) {
	  if(!min) min = 0;
	  if(!max) max = 1;
	  return Math.random() * (max - min) + min;
	}

});

app.filter('reverse', function() {
  return function(items) {
    return items.slice().reverse();
  };
});<|endoftext|>


<commit_before>/*
*** User Story: I can start a 25 minute pomodoro, and the timer will go *** off once 25 minutes has elapsed.
*** User Story: I can reset the clock for my next pomodoro.
*** User Story: I can customize the length of each pomodoro.
=====================================================================

        TODO:

            >> Make Animations look less shit: work in progrress
            >> fix CSS/LAYOUT: work in progress
            >> convert into minutes:
            >> upload Github
 ====================================================================
       >> Pomo Named Variable, Ids & Function refer to the break
*/

  $(document).ready(function() {

    //                  Timer ANIMATED COUNT BAR
  function startTween(){
    TweenMax.to($("#timerFill"), timerCount, {width: 294});
  }
    //                  POMO ANIMATED COUNT BAR
  function startTweenPomo(){
    TweenMax.to($("#pomoFill"), pomoCount, {width: 294});
  }
    //                  TIMER ANIMATED RESET BAR
  function resetTween(){
    TweenMax.to($("#timerFill"), 1, {width: 0});
  }
    //                  POMO ANIMATED RESET BAR
  function resetTweenPomo(){
    TweenMax.to($("#pomoFill"), 1, {width: 0});
  }

    //                 **** 25 Minute Timer Plus & Minus
  var timerCount = 25;
    //                  --- counts up
  $('#timerUp').click(function() {
    timerCount += 1;
   document.getElementById("timer").innerHTML = timerCount;
  });
    //                  ---- counts Down
  $('#timerDown').click(function() {
    //                  prevents counter < 0
    if (timerCount >= 1) {
      timerCount -= 1;
   document.getElementById("timer").innerHTML = timerCount;
    } else {
      alert("dont be lazy!")
    }
  });

    //                 **** 25 Minute Pomo Plus & Minus
  var pomoCount = 5;
    //                  ---- counts up
  $('#pomoUp').click(function() {
    pomoCount += 1;
   document.getElementById("pomoTimer").innerHTML = pomoCount;
  });
    //                 --- countsdown
  $('#pomoDown').click(function() {
    if (pomoCount >= 1) {
      pomoCount = pomoCount - 1;
   document.getElementById("pomoTimer").innerHTML = pomoCount;
    } else {
      alert("dont mess with me boy")
    }
  });

    //                 ****** RESET the TIMER button & ANIMATED BAR
  $('#resetButton').click(function(){
    timerCount = 25;
   document.getElementById("timer").innerHTML = timerCount;

    resetTween();
  });

    //                 ***** Timer Start Button Count Down starts Interval & calls counting function
  $('#timerStart').click(function(){
//                    --Disables + - and start button. Enables Reset
           document.getElementById('resetButton').disabled = false;
           document.getElementById('timerStart').disabled = true;
           document.getElementById('timerUp').disabled = true;
           document.getElementById('timerDown').disabled = true;
          stoppingTimer = setInterval(timerSecondsDown, 1000);
    //                 --- starts automation of ANINMATED_BAR
    startTween();
   });
    //                 ****  ^--- Function that counts down  ******
  function timerSecondsDown(){
  if (timerCount >= 1) {
      document.getElementById("timer").innerHTML =  timerCount -= 1;
      } else {
        timerCount = 0;
          alert("Count Down Finished: Break time");
        clearInterval(stoppingTimer)

    };

    $('#resetButton').click(function(){
//                 --Enables + - and start button. Disables Reset
            document.getElementById('resetButton').disabled = true;
            document.getElementById('timerStart').disabled = false;
            document.getElementById('timerUp').disabled = false;
            document.getElementById('timerDown').disabled = false;
  clearInterval(stoppingTimer)
  timerCount = 25;
  document.getElementById("timer").innerHTML = timerCount;
  resetTween();
  });

  }

    //                 **** Pomo Start Button Count Down starts Interval & calls counting function
  $('#pomoStart').click(function(){
//                    --Disables + - and start button. Enables Reset
             document.getElementById('resetPomoButton').disabled = false;
             document.getElementById('pomoStart').disabled = true;
             document.getElementById('pomoUp').disabled = true;
             document.getElementById('pomoDown').disabled = true;
    stopping = setInterval(pomoSecondsDown, 1000);
    //                 --- starts automation of ANINMATED_BAR
    startTweenPomo();
   });
    //                 ****  ^--- Function that counts down  ******
  function pomoSecondsDown() {
  if (pomoCount >= 1) {
    document.getElementById("pomoTimer").innerHTML =  pomoCount -= 1;
    } else {
      alert("Break has finsihed - Get back to work");
      clearInterval(stopping)
  };

  //                ******  RESET  the POMO button & ANIMATED BAR
  $('#resetPomoButton').click(function(){
    console.log("test");
  //                 --Enables + - and start button. Disables Reset
             document.getElementById('resetPomoButton').disabled = true;
             document.getElementById('pomoStart').disabled = false;
             document.getElementById('pomoUp').disabled = false;
             document.getElementById('pomoDown').disabled = false;
       clearInterval(stopping)
  pomoCount = 5;
  document.getElementById("pomoTimer").innerHTML = pomoCount;
  resetTweenPomo();

  });

  }
  });<commit_msg>testing update NOTEPAD<commit_after>/*
*** User Story: I can start a 25 minute pomodoro, and the timer will go *** off once 25 minutes has elapsed.
*** User Story: I can reset the clock for my next pomodoro.
*** User Story: I can customize the length of each pomodoro.
=====================================================================

        TODO:

            >> Make Animations look less shit: work in progrress
            >> fix CSS/LAYOUT: work in progress
            >> convert into minutes:
            >> upload Github
            >> testign github update 2
 ====================================================================
       >> Pomo Named Variable, Ids & Function refer to the break
*/

  $(document).ready(function() {

    //                  Timer ANIMATED COUNT BAR
  function startTween(){
    TweenMax.to($("#timerFill"), timerCount, {width: 294});
  }
    //                  POMO ANIMATED COUNT BAR
  function startTweenPomo(){
    TweenMax.to($("#pomoFill"), pomoCount, {width: 294});
  }
    //                  TIMER ANIMATED RESET BAR
  function resetTween(){
    TweenMax.to($("#timerFill"), 1, {width: 0});
  }
    //                  POMO ANIMATED RESET BAR
  function resetTweenPomo(){
    TweenMax.to($("#pomoFill"), 1, {width: 0});
  }

    //                 **** 25 Minute Timer Plus & Minus
  var timerCount = 25;
    //                  --- counts up
  $('#timerUp').click(function() {
    timerCount += 1;
   document.getElementById("timer").innerHTML = timerCount;
  });
    //                  ---- counts Down
  $('#timerDown').click(function() {
    //                  prevents counter < 0
    if (timerCount >= 1) {
      timerCount -= 1;
   document.getElementById("timer").innerHTML = timerCount;
    } else {
      alert("dont be lazy!")
    }
  });

    //                 **** 25 Minute Pomo Plus & Minus
  var pomoCount = 5;
    //                  ---- counts up
  $('#pomoUp').click(function() {
    pomoCount += 1;
   document.getElementById("pomoTimer").innerHTML = pomoCount;
  });
    //                 --- countsdown
  $('#pomoDown').click(function() {
    if (pomoCount >= 1) {
      pomoCount = pomoCount - 1;
   document.getElementById("pomoTimer").innerHTML = pomoCount;
    } else {
      alert("dont mess with me boy")
    }
  });

    //                 ****** RESET the TIMER button & ANIMATED BAR
  $('#resetButton').click(function(){
    timerCount = 25;
   document.getElementById("timer").innerHTML = timerCount;

    resetTween();
  });

    //                 ***** Timer Start Button Count Down starts Interval & calls counting function
  $('#timerStart').click(function(){
//                    --Disables + - and start button. Enables Reset
           document.getElementById('resetButton').disabled = false;
           document.getElementById('timerStart').disabled = true;
           document.getElementById('timerUp').disabled = true;
           document.getElementById('timerDown').disabled = true;
          stoppingTimer = setInterval(timerSecondsDown, 1000);
    //                 --- starts automation of ANINMATED_BAR
    startTween();
   });
    //                 ****  ^--- Function that counts down  ******
  function timerSecondsDown(){
  if (timerCount >= 1) {
      document.getElementById("timer").innerHTML =  timerCount -= 1;
      } else {
        timerCount = 0;
          alert("Count Down Finished: Break time");
        clearInterval(stoppingTimer)

    };

    $('#resetButton').click(function(){
//                 --Enables + - and start button. Disables Reset
            document.getElementById('resetButton').disabled = true;
            document.getElementById('timerStart').disabled = false;
            document.getElementById('timerUp').disabled = false;
            document.getElementById('timerDown').disabled = false;
  clearInterval(stoppingTimer)
  timerCount = 25;
  document.getElementById("timer").innerHTML = timerCount;
  resetTween();
  });

  }

    //                 **** Pomo Start Button Count Down starts Interval & calls counting function
  $('#pomoStart').click(function(){
//                    --Disables + - and start button. Enables Reset
             document.getElementById('resetPomoButton').disabled = false;
             document.getElementById('pomoStart').disabled = true;
             document.getElementById('pomoUp').disabled = true;
             document.getElementById('pomoDown').disabled = true;
    stopping = setInterval(pomoSecondsDown, 1000);
    //                 --- starts automation of ANINMATED_BAR
    startTweenPomo();
   });
    //                 ****  ^--- Function that counts down  ******
  function pomoSecondsDown() {
  if (pomoCount >= 1) {
    document.getElementById("pomoTimer").innerHTML =  pomoCount -= 1;
    } else {
      alert("Break has finsihed - Get back to work");
      clearInterval(stopping)
  };

  //                ******  RESET  the POMO button & ANIMATED BAR
  $('#resetPomoButton').click(function(){
    console.log("test");
  //                 --Enables + - and start button. Disables Reset
             document.getElementById('resetPomoButton').disabled = true;
             document.getElementById('pomoStart').disabled = false;
             document.getElementById('pomoUp').disabled = false;
             document.getElementById('pomoDown').disabled = false;
       clearInterval(stopping)
  pomoCount = 5;
  document.getElementById("pomoTimer").innerHTML = pomoCount;
  resetTweenPomo();

  });

  }
  });
<|endoftext|>


<commit_before>// Typewriter.js
// https://github.com/ronv/Typewriter.js

$.fn.typewriter = function() {
  this.each(function() {
    var c = $(this),
      b = c.html(),
      a = 0,
      d = 0;
    c.html("");
    var e = function() {
      if ("<" == b.substring(a, a + 1)) {
        var f = new RegExp(/<span class="instant"/),
          g = new RegExp(/<span class="clear"/);
        if (b.substring(a, b.length).match(f)) a += b.substring(a, b.length).indexOf("") + 7;
        else if (b.substring(a, b.length).match(g)) d = a, a += b.substring(a, b.length).indexOf("") + 7;
        else
          for (;
            ">" != b.substring(a, a + 1);) a++
      }
      c.html(b.substring(d, a++) + (a & 1 ? "_" : ""));
      a >= b.length || setTimeout(e, 70 + 100 *
        Math.random())
    };
    e()
  });
  return this
};
$(".terminal").typewriter();
$(".title").typewriter();<commit_msg>Speed up typing<commit_after>// Typewriter.js
// https://github.com/ronv/Typewriter.js

$.fn.typewriter = function() {
  this.each(function() {
    var c = $(this),
      b = c.html(),
      a = 0,
      d = 0;
    c.html("");
    var e = function() {
      if ("<" == b.substring(a, a + 1)) {
        var f = new RegExp(/<span class="instant"/),
          g = new RegExp(/<span class="clear"/);
        if (b.substring(a, b.length).match(f)) a += b.substring(a, b.length).indexOf("") + 7;
        else if (b.substring(a, b.length).match(g)) d = a, a += b.substring(a, b.length).indexOf("") + 7;
        else
          for (;
            ">" != b.substring(a, a + 1);) a++
      }
      c.html(b.substring(d, a++) + (a & 1 ? "_" : ""));
      a >= b.length || setTimeout(e, 40 + 70 *
        Math.random())
    };
    e()
  });
  return this
};
$(".terminal").typewriter();
$(".title").typewriter();<|endoftext|>


<commit_before>/*global $, Whisper, Backbone, textsecure, extension*/
/*
 * vim: ts=4:sw=4:expandtab
 */
(function () {
    'use strict';

    function logError(error) {
        extension.windows.getBackground(function(bg) {
            bg.console.log('index.html: ', error);
        });
    }

    window.onerror = function(message, script, line, col, error) {
        logError(error);
    };

    function render() {
        extension.windows.getBackground(function(bg) {
            bg.owsDesktopApp.getAppView(window).then(function(appView) {
                var bodyEl = document.getElementById('signal-container');
                bodyEl.innerHTML = "";
                bodyEl.append(appView.el);
            });
        });
    }

    window.addEventListener('onreload', render);
    render();
}());
<commit_msg>Use appendChild instead of append<commit_after>/*global $, Whisper, Backbone, textsecure, extension*/
/*
 * vim: ts=4:sw=4:expandtab
 */
(function () {
    'use strict';

    function logError(error) {
        extension.windows.getBackground(function(bg) {
            bg.console.log('index.html: ', error);
        });
    }

    window.onerror = function(message, script, line, col, error) {
        logError(error);
    };

    function render() {
        extension.windows.getBackground(function(bg) {
            bg.owsDesktopApp.getAppView(window).then(function(appView) {
                var bodyEl = document.getElementById('signal-container');
                bodyEl.innerHTML = "";
                bodyEl.appendChild(appView.el);
            });
        });
    }

    window.addEventListener('onreload', render);
    render();
}());
<|endoftext|>


<commit_before>// for debugging and tweaking from the console
var MAPS = {};
(function() {

    // returns the map provider for a given TileStache layer name
    function getProvider(layer) {
        return new MM.StamenTileLayer(layer);
    }

    function onImageError(_map, img) {
        // img.src = "images/tile-404.gif";
    }

    function init() {

        var providerLabel = document.getElementById("current-provider"),
            currentProvider = "toner",
            mapsByProvider = MAPS.byProvider = {};

        // our main map
        var main = MAPS.main = new MM.Map("map-main", getProvider(currentProvider), null,
            [new MM.DragHandler(), new MM.DoubleClickHandler(), new MM.TouchHandler()]);
        main.layers[0].requestManager.addCallback("requesterror", onImageError);

        mapsByProvider[currentProvider] = main;

        // keep a reference to the sub-map wrapper to figure out
        // positioning stuff
        var wrapper = MAPS.wrapper = document.getElementById("maps-sub"),
            subs = MAPS.sub = [],
            // then grab all the sub-map element references
            subParents = wrapper.querySelectorAll(".map");
        // create a map for each sub-map element
        for (var i = 0; i < subParents.length; i++) {
            var el = subParents[i],
                // the provider is based on the data-provider HTML attribute
                provider = el.getAttribute("data-provider"),
                // FIXME: these maps are not interactive
                map = new MM.Map(el, getProvider(provider), null, [new MM.DragHandler()]);
            map.addCallback("panned", function(_map, offset) {
                if (!main.panning) {
                    _map.panning = true;
                    main.panBy(offset[0], offset[1]);
                    _map.panning = false;
                }
            });
            map.layers[0].requestManager.addCallback("requesterror", onImageError);
            mapsByProvider[provider] = map;
            subs.push(map);
        }

        // sync sub-maps to the main map's center using their
        // relative positions on screen
        function updateSubMaps() {
            var mainWidth = main.dimensions.x,
                wrapperWidth = wrapper.offsetWidth,
                wrapperTop = wrapper.offsetTop,
                offsetX = mainWidth - (mainWidth - wrapperWidth) / 2;
            for (var i = 0; i < subs.length; i++) {
                var sub = subs[i],
                    point = new MM.Point(0, 0);
                point.x = offsetX - sub.dimensions.x / 2;
                point.y = wrapperTop + sub.parent.offsetTop + sub.dimensions.y / 2;
                sub.setCenterZoom(main.pointLocation(point), main.getZoom());
            }
        }

        // zoom click handlers
        MM.addEvent(document.getElementById("zoom-in"), "click", function() {
            try { main.zoomIn(); } catch (e) { }
            return false;
        });
        MM.addEvent(document.getElementById("zoom-out"), "click", function() {
            try { main.zoomOut(); } catch (e) { }
            return false;
        });

        var fslink = document.getElementById("fullscreen");
        if (fslink) {
            var fullscreen = false,
                fstimeout;
            function toggleFullscreen(link) {
                fullscreen = !fullscreen;
                if (fullscreen) {
                    document.body.className = "fullscreen";
                } else {
                    document.body.className = null;
                }
                clearTimeout(fstimeout);
                fstimeout = setTimeout(main.windowResize(), 1000);
            }

            MM.addEvent(fslink, "click", function(e) {
                try {
                    toggleFullscreen(e.target);
                } catch (error) {
                    console.error(error);
                }
                return MM.cancelEvent(e);
            });

            MM.addEvent(window, "keyup", function(e) {
                if (fullscreen && e.keyCode == 27) { // escape
                    toggleFullscreen(e.target);
                }
            });
        }

        // pan the sub-maps when the main map is panned
        main.addCallback("panned", function(_map, offset) {
            if (main.panning) return;
            main.panning = true;
            for (var i = 0; i < subs.length; i++) {
                var sub = subs[i];
                if (!sub.panning) {
                    sub.panBy(offset[0], offset[1]);
                }
            }
            main.panning = false;
        });

        // and for all other map redraw events, re-sync them
        main.addCallback("zoomed", updateSubMaps);
        main.addCallback("extentset", updateSubMaps);
        main.addCallback("centered", updateSubMaps);

        // set the initial map position
        main.setCenterZoom(new MM.Location(37.7706, -122.3782), 12);

        function updateTitle(map, provider) {
            // update the link in the clicked sub-map
            var node = map.parent.querySelector(".provider-name");
            node.innerHTML = provider.substr(0, 1).toUpperCase() + provider.substr(1);
            if ("href" in node) {
                node.href = "#" + provider;
            }
        }

        // and set up listening for the browser's location hash
        var hasher = new ProviderHash(main, currentProvider, function(provider) {
            if (!provider || !(provider in mapsByProvider)) {
                return false;
            }
            // if the provider has changed...
            if (provider != currentProvider) {
                // grab the provider from the corresponding map
                var source = mapsByProvider[provider],
                    target = main;
                // swap layers
                source.setLayerAt(0, getProvider(currentProvider));
                target.setLayerAt(0, getProvider(provider));

                updateTitle(source, currentProvider);
                updateTitle(target, provider);

                // update the selected provider label text
                if (providerLabel) {
                    providerLabel.innerHTML = provider;
                }

                // swap the map references in mapsByProvider
                mapsByProvider[provider] = target;
                mapsByProvider[currentProvider] = source;
                // and, finally, update currentProvider
                currentProvider = provider;
            }
            return true;
        });

        // set up form element references
        var searchForm = document.getElementById("search"),
            searchInput = document.getElementById("search-location"),
            searchButton = document.getElementById("search-submit");
        // listen for the submit event
        MM.addEvent(searchForm, "submit", function(e) {
            // remember the old search text
            var oldSearchText = searchButton.getAttribute("value");
            // put the button into its submitting state
            searchButton.setAttribute("value", "Finding...");
            searchButton.setAttribute("class", "btn disabled");
            // set up a function to rever the form to its original state
            // (which executes whether there was an error or not)
            function revert() {
                searchButton.setAttribute("class", "btn");
                searchButton.setAttribute("value", oldSearchText);
            }

            var query = searchInput.value;
            YahooPlaceSearch.geocode(query, function(places) {
                revert();
                // console.log("search results:", results);
                // TODO: find the most relevant result?
                try {
                    var result = places.place[0],
                        northeast = result.boundingBox.northEast,
                        southwest = result.boundingBox.southWest;
                    main.setExtent([
                        new MM.Location(northeast.latitude, northeast.longitude),
                        new MM.Location(southwest.latitude, southwest.longitude)
                    ]);
                } catch (e) {
                    alert('Sorry, something went wrong when searching for "' + query + '".');
                }
                // main.panBy(-(main.dimensions.x - wrapper.offsetWidth) / 2, 0);
            }, function(error) {
                revert();
                alert('Sorry, we couldn\'t find "' + query + '".');
            });

            // cancel the submit event
            return MM.cancelEvent(e);
        });

        // create static mini-maps for each of these elements
        var minis = document.querySelectorAll("#content .map");
        MAPS.minis = [];
        for (var i = 0; i < minis.length; i++) {
            var el = minis[i],
                provider = getProvider(el.getAttribute("data-provider")),
                center = parseCenter(el.getAttribute("data-center")),
                zoom = parseInt(el.getAttribute("data-zoom")),
                map = new MM.Map(el, provider, null, []);
            map.setCenterZoom(center, zoom);
            MAPS.minis.push(map);
        }

        var inheritLinks = document.querySelectorAll("a.hashish");
        for (var i = 0; i < inheritLinks.length; i++) {
            MM.addEvent(inheritLinks[i], "mouseover", function(e) {
                var link = e.target,
                    parts = link.href.split("#"),
                    suffix = location.hash.split("/").slice(1).join("/");
                link.href = [parts[0], suffix].join("#");
            });
        }
    }

    // parse a string into an MM.Location instance
    function parseCenter(str) {
        var parts = str.split(/,\s*/),
            lat = parseFloat(parts[0]),
            lon = parseFloat(parts[1]);
        return new MM.Location(lat, lon);
    }

    /**
     * The ProviderHash is a class that looks for a provider name at the beginning
     * of the hash and calls the supplied setProvider(provider) function whenever it
     * changes.
     *
     * One feature of this parser is that it substitutes the center and zoom back in
     * if the hash changes to just "#provider", so you can link to new providers by
     * setting a link's href to simply "#provider" and ProviderHash will update the
     * hash accordingly.
     *
     * setProvider(provider) should accept a string and return true if the supplied
     * provider name was valid, or return false in any other case.
     *
     * Note also that ProviderHash requires a valid providerName in the constructor
     * to correctly set the initial hash value.
     */
    var ProviderHash = function(map, providerName, setProvider) {
        this.providerName = providerName;
        this.setProvider = setProvider;
        MM.Hash.call(this, map);
    };

    ProviderHash.prototype = {
        // the currently selected provider name
        providerName: null,

        /**
         * Our parseHash() function looks for a provider name in the beginning of
         * the URL.
         */
        parseHash: function(hash) {
            var parts = hash.split("/");
            if (parts.length > 0) {
                var provider = parts.shift();
                var parsed = parts.length
                    ? MM.Hash.prototype.parseHash.call(this, parts.join("/"))
                    : {center: this.map.getCenter(), zoom: this.map.getZoom()};
                if (parsed) {
                    // console.log("parsed hash:", provider, parsed);
                    var didSetProvider = this.setProvider.call(this.map, provider);
                    if (didSetProvider) {
                        this.providerName = provider;
                        return parsed;
                    } else {
                        return false;
                    }
                } else {
                    // console.log("parse error:", hash, parts, this.providerName);
                }
                return parsed;
            } else {
                // console.warn("(zero length, unable to parse");
                return false;
            }
        },

        /**
         * Our formatHash() function inserts the provider name as the first
         * slash-delimited element in the URL.
         */
        formatHash: function(hash) {
            var format = MM.Hash.prototype.formatHash.call(this, hash);
            return "#" + this.providerName + "/" + format.substr(1);
        }
    };

    MM.extend(ProviderHash, MM.Hash);

    try {

        init();

    } catch (e) {
        console.error(e);
    }

})();

var YahooPlaceSearch = {
    appid: "1DiQEyLV34HbAVHyl0iWC5tAZ8wpLMPzIeFE9QsTukhx6H.Cn9bM70c_5dYgh7cR8w--",
    url: "http://where.yahooapis.com/v1/places.q({q});count=1?callback=?",
    geocode: function(query, success, error) {
        var data = {};
        data.appid = YahooPlaceSearch.appid;
        data.select = "long";
        data.format = "json";
        return reqwest({
            url: YahooPlaceSearch.url.replace("{q}", encodeURIComponent(query)),
            type: "jsonp",
            jsonpCallback: "callback",
            data: data,
            success: function(response) {
                var results = response.places;
                if (results) {
                    success.call(null, results);
                } else {
                    error.call(null, "No results", response);
                }
            },
            error: error
        });
    }
};
<commit_msg>renamed inheritLinks -> hashish<commit_after>// for debugging and tweaking from the console
var MAPS = {};
(function() {

    // returns the map provider for a given TileStache layer name
    function getProvider(layer) {
        return new MM.StamenTileLayer(layer);
    }

    function onImageError(_map, img) {
        // img.src = "images/tile-404.gif";
    }

    function init() {

        var providerLabel = document.getElementById("current-provider"),
            currentProvider = "toner",
            mapsByProvider = MAPS.byProvider = {};

        // our main map
        var main = MAPS.main = new MM.Map("map-main", getProvider(currentProvider), null,
            [new MM.DragHandler(), new MM.DoubleClickHandler(), new MM.TouchHandler()]);
        main.layers[0].requestManager.addCallback("requesterror", onImageError);

        mapsByProvider[currentProvider] = main;

        // keep a reference to the sub-map wrapper to figure out
        // positioning stuff
        var wrapper = MAPS.wrapper = document.getElementById("maps-sub"),
            subs = MAPS.sub = [],
            // then grab all the sub-map element references
            subParents = wrapper.querySelectorAll(".map");
        // create a map for each sub-map element
        for (var i = 0; i < subParents.length; i++) {
            var el = subParents[i],
                // the provider is based on the data-provider HTML attribute
                provider = el.getAttribute("data-provider"),
                // FIXME: these maps are not interactive
                map = new MM.Map(el, getProvider(provider), null, [new MM.DragHandler()]);
            map.addCallback("panned", function(_map, offset) {
                if (!main.panning) {
                    _map.panning = true;
                    main.panBy(offset[0], offset[1]);
                    _map.panning = false;
                }
            });
            map.layers[0].requestManager.addCallback("requesterror", onImageError);
            mapsByProvider[provider] = map;
            subs.push(map);
        }

        // sync sub-maps to the main map's center using their
        // relative positions on screen
        function updateSubMaps() {
            var mainWidth = main.dimensions.x,
                wrapperWidth = wrapper.offsetWidth,
                wrapperTop = wrapper.offsetTop,
                offsetX = mainWidth - (mainWidth - wrapperWidth) / 2;
            for (var i = 0; i < subs.length; i++) {
                var sub = subs[i],
                    point = new MM.Point(0, 0);
                point.x = offsetX - sub.dimensions.x / 2;
                point.y = wrapperTop + sub.parent.offsetTop + sub.dimensions.y / 2;
                sub.setCenterZoom(main.pointLocation(point), main.getZoom());
            }
        }

        // zoom click handlers
        MM.addEvent(document.getElementById("zoom-in"), "click", function() {
            try { main.zoomIn(); } catch (e) { }
            return false;
        });
        MM.addEvent(document.getElementById("zoom-out"), "click", function() {
            try { main.zoomOut(); } catch (e) { }
            return false;
        });

        var fslink = document.getElementById("fullscreen");
        if (fslink) {
            var fullscreen = false,
                fstimeout;
            function toggleFullscreen(link) {
                fullscreen = !fullscreen;
                if (fullscreen) {
                    document.body.className = "fullscreen";
                } else {
                    document.body.className = null;
                }
                clearTimeout(fstimeout);
                fstimeout = setTimeout(main.windowResize(), 1000);
            }

            MM.addEvent(fslink, "click", function(e) {
                try {
                    toggleFullscreen(e.target);
                } catch (error) {
                    console.error(error);
                }
                return MM.cancelEvent(e);
            });

            MM.addEvent(window, "keyup", function(e) {
                if (fullscreen && e.keyCode == 27) { // escape
                    toggleFullscreen(e.target);
                }
            });
        }

        // pan the sub-maps when the main map is panned
        main.addCallback("panned", function(_map, offset) {
            if (main.panning) return;
            main.panning = true;
            for (var i = 0; i < subs.length; i++) {
                var sub = subs[i];
                if (!sub.panning) {
                    sub.panBy(offset[0], offset[1]);
                }
            }
            main.panning = false;
        });

        // and for all other map redraw events, re-sync them
        main.addCallback("zoomed", updateSubMaps);
        main.addCallback("extentset", updateSubMaps);
        main.addCallback("centered", updateSubMaps);

        // set the initial map position
        main.setCenterZoom(new MM.Location(37.7706, -122.3782), 12);

        function updateTitle(map, provider) {
            // update the link in the clicked sub-map
            var node = map.parent.querySelector(".provider-name");
            node.innerHTML = provider.substr(0, 1).toUpperCase() + provider.substr(1);
            if ("href" in node) {
                node.href = "#" + provider;
            }
        }

        // and set up listening for the browser's location hash
        var hasher = new ProviderHash(main, currentProvider, function(provider) {
            if (!provider || !(provider in mapsByProvider)) {
                return false;
            }
            // if the provider has changed...
            if (provider != currentProvider) {
                // grab the provider from the corresponding map
                var source = mapsByProvider[provider],
                    target = main;
                // swap layers
                source.setLayerAt(0, getProvider(currentProvider));
                target.setLayerAt(0, getProvider(provider));

                updateTitle(source, currentProvider);
                updateTitle(target, provider);

                // update the selected provider label text
                if (providerLabel) {
                    providerLabel.innerHTML = provider;
                }

                // swap the map references in mapsByProvider
                mapsByProvider[provider] = target;
                mapsByProvider[currentProvider] = source;
                // and, finally, update currentProvider
                currentProvider = provider;
            }
            return true;
        });

        // set up form element references
        var searchForm = document.getElementById("search"),
            searchInput = document.getElementById("search-location"),
            searchButton = document.getElementById("search-submit");
        // listen for the submit event
        MM.addEvent(searchForm, "submit", function(e) {
            // remember the old search text
            var oldSearchText = searchButton.getAttribute("value");
            // put the button into its submitting state
            searchButton.setAttribute("value", "Finding...");
            searchButton.setAttribute("class", "btn disabled");
            // set up a function to rever the form to its original state
            // (which executes whether there was an error or not)
            function revert() {
                searchButton.setAttribute("class", "btn");
                searchButton.setAttribute("value", oldSearchText);
            }

            var query = searchInput.value;
            YahooPlaceSearch.geocode(query, function(places) {
                revert();
                // console.log("search results:", results);
                // TODO: find the most relevant result?
                try {
                    var result = places.place[0],
                        northeast = result.boundingBox.northEast,
                        southwest = result.boundingBox.southWest;
                    main.setExtent([
                        new MM.Location(northeast.latitude, northeast.longitude),
                        new MM.Location(southwest.latitude, southwest.longitude)
                    ]);
                } catch (e) {
                    alert('Sorry, something went wrong when searching for "' + query + '".');
                }
                // main.panBy(-(main.dimensions.x - wrapper.offsetWidth) / 2, 0);
            }, function(error) {
                revert();
                alert('Sorry, we couldn\'t find "' + query + '".');
            });

            // cancel the submit event
            return MM.cancelEvent(e);
        });

        // create static mini-maps for each of these elements
        var minis = document.querySelectorAll("#content .map");
        MAPS.minis = [];
        for (var i = 0; i < minis.length; i++) {
            var el = minis[i],
                provider = getProvider(el.getAttribute("data-provider")),
                center = parseCenter(el.getAttribute("data-center")),
                zoom = parseInt(el.getAttribute("data-zoom")),
                map = new MM.Map(el, provider, null, []);
            map.setCenterZoom(center, zoom);
            MAPS.minis.push(map);
        }

        var hashish = document.querySelectorAll("a.hashish");
        for (var i = 0; i < hashish.length; i++) {
            MM.addEvent(hashish[i], "mouseover", function(e) {
                var link = e.target,
                    parts = link.href.split("#"),
                    suffix = location.hash.split("/").slice(1).join("/");
                link.href = [parts[0], suffix].join("#");
            });
        }
    }

    // parse a string into an MM.Location instance
    function parseCenter(str) {
        var parts = str.split(/,\s*/),
            lat = parseFloat(parts[0]),
            lon = parseFloat(parts[1]);
        return new MM.Location(lat, lon);
    }

    /**
     * The ProviderHash is a class that looks for a provider name at the beginning
     * of the hash and calls the supplied setProvider(provider) function whenever it
     * changes.
     *
     * One feature of this parser is that it substitutes the center and zoom back in
     * if the hash changes to just "#provider", so you can link to new providers by
     * setting a link's href to simply "#provider" and ProviderHash will update the
     * hash accordingly.
     *
     * setProvider(provider) should accept a string and return true if the supplied
     * provider name was valid, or return false in any other case.
     *
     * Note also that ProviderHash requires a valid providerName in the constructor
     * to correctly set the initial hash value.
     */
    var ProviderHash = function(map, providerName, setProvider) {
        this.providerName = providerName;
        this.setProvider = setProvider;
        MM.Hash.call(this, map);
    };

    ProviderHash.prototype = {
        // the currently selected provider name
        providerName: null,

        /**
         * Our parseHash() function looks for a provider name in the beginning of
         * the URL.
         */
        parseHash: function(hash) {
            var parts = hash.split("/");
            if (parts.length > 0) {
                var provider = parts.shift();
                var parsed = parts.length
                    ? MM.Hash.prototype.parseHash.call(this, parts.join("/"))
                    : {center: this.map.getCenter(), zoom: this.map.getZoom()};
                if (parsed) {
                    // console.log("parsed hash:", provider, parsed);
                    var didSetProvider = this.setProvider.call(this.map, provider);
                    if (didSetProvider) {
                        this.providerName = provider;
                        return parsed;
                    } else {
                        return false;
                    }
                } else {
                    // console.log("parse error:", hash, parts, this.providerName);
                }
                return parsed;
            } else {
                // console.warn("(zero length, unable to parse");
                return false;
            }
        },

        /**
         * Our formatHash() function inserts the provider name as the first
         * slash-delimited element in the URL.
         */
        formatHash: function(hash) {
            var format = MM.Hash.prototype.formatHash.call(this, hash);
            return "#" + this.providerName + "/" + format.substr(1);
        }
    };

    MM.extend(ProviderHash, MM.Hash);

    try {

        init();

    } catch (e) {
        console.error(e);
    }

})();

var YahooPlaceSearch = {
    appid: "1DiQEyLV34HbAVHyl0iWC5tAZ8wpLMPzIeFE9QsTukhx6H.Cn9bM70c_5dYgh7cR8w--",
    url: "http://where.yahooapis.com/v1/places.q({q});count=1?callback=?",
    geocode: function(query, success, error) {
        var data = {};
        data.appid = YahooPlaceSearch.appid;
        data.select = "long";
        data.format = "json";
        return reqwest({
            url: YahooPlaceSearch.url.replace("{q}", encodeURIComponent(query)),
            type: "jsonp",
            jsonpCallback: "callback",
            data: data,
            success: function(response) {
                var results = response.places;
                if (results) {
                    success.call(null, results);
                } else {
                    error.call(null, "No results", response);
                }
            },
            error: error
        });
    }
};
<|endoftext|>


<commit_before>// var namebtn=document.getElementById("namediv");
// var picdiv=document.getElementById('picdiv');
// namebtn.onclick=function(){
// 	alert("welcome to my webside");
// };
var namebtn=$('#namediv');
var images=$('.image');
var picdiv=$('#picdiv');

namebtn.click(function(){
	alert('welcome!');
});

$(function() {
    $('.banner').unslider();
});

$('.banner').unslider({
	speed: 500,               //  The speed to animate each slide (in milliseconds)
	delay: 1000,              //  The delay between slide animations (in milliseconds)
	complete: function() {},  //  A function that gets called after every slide animation
	keys: true,               //  Enable keyboard (left, right) arrow shortcuts
	dots: true,               //  Display dot navigation
	fluid: false              //  Support responsive design. May break non-responsive designs
});
<commit_msg>update<commit_after>// var namebtn=document.getElementById("namediv");
// var picdiv=document.getElementById('picdiv');
// namebtn.onclick=function(){
// 	alert("welcome to my webside");
// };
var namebtn=$('#namediv');
var images=$('.image');
var picdiv=$('#picdiv');

namebtn.click(function(){
	alert('welcome!');
});

$(function() {
    $('.banner').unslider();
});

$('.banner').unslider({
	speed: 500,               //  The speed to animate each slide (in milliseconds)
	delay: 1000,              //  The delay between slide animations (in milliseconds)
	complete: function() {},  //  A function that gets called after every slide animation
	keys: true,               //  Enable keyboard (left, right) arrow shortcuts
	dots: true,               //  Display dot navigation
	fluid: false              //  Support responsive design. May break non-responsive designs
});
Galleria.run('.galleria');
<|endoftext|>