<commit_before>/*
 * Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 */

/*jslint vars: true, plusplus: true, devel: true, browser: true, nomen: true, indent: 4, maxerr: 50 */
/*global define, describe, it, expect, beforeEach, afterEach, waits, waitsFor, waitsForDone, runs, $, brackets, waitsForDone, spyOn, tinycolor, KeyEvent */

define(function (require, exports, module) {
    "use strict";

    var NodeConnection   = brackets.getModule("utils/NodeConnection"),
        FileUtils        = brackets.getModule("file/FileUtils"),
        NativeFileSystem = brackets.getModule("file/NativeFileSystem").NativeFileSystem,
        ExtensionUtils   = brackets.getModule("utils/ExtensionUtils"),
        SpecRunnerUtils  = brackets.getModule("spec/SpecRunnerUtils"),
        Async            = brackets.getModule("utils/Async");

    // TODO: should put in system temp folder, but we don't have a generic way to get that
    var testFolder      = FileUtils.getNativeModuleDirectoryPath(module) + "/tmp-test";

    describe("bower-install", function () {

        // Unit tests for the underlying node server.
        describe("BowerDomain", function () {
            var nodeConnection,
                testBrackets,
                ProjectManager;

            beforeEach(function () {
                runs(function () {
                    var nodePromise = new $.Deferred();
                    nodeConnection = new NodeConnection();
                    nodeConnection.connect(true).then(function () {
                        nodeConnection.loadDomains(
                            [ExtensionUtils.getModulePath(module, "node/FileUtilsDomain")],
                            true
                        ).then(function () {
                            nodePromise.resolve();
                        });
                    });
                    waitsForDone(nodePromise, "connecting to node server");
                });

                runs(function () {
                    var domainPromise = new $.Deferred(),
                        retries = 0;

                    function waitForDomain() {
                        if (nodeConnection.domains.bower) {
                            domainPromise.resolve();
                        } else {
                            retries++;
                            if (retries >= 5) {
                                domainPromise.reject();
                            } else {
                                setTimeout(waitForDomain, 100);
                            }
                        }
                    }

                    waitForDomain();
                    waitsForDone(domainPromise, "waiting for Bower domain to load");
                });

                runs(function () {
                    var folderPromise = new $.Deferred();
                    SpecRunnerUtils.createTestWindowAndRun(this, function (testWindow) {
                        testBrackets = testWindow.brackets;
                        ProjectManager = testBrackets.test.ProjectManager;

                        testBrackets.fs.makedir(testFolder, 0, function (err) {
                            if (err === testBrackets.fs.NO_ERROR) {
                                ProjectManager.openProject(testFolder)
                                    .then(folderPromise.resolve, folderPromise.reject);
                            } else {
                                folderPromise.reject();
                            }
                        });
                        folderPromise.resolve();
                    });
                    waitsForDone(folderPromise, "waiting for test folder to be created");
                });
            });

            afterEach(function () {
                runs(function () {
                    SpecRunnerUtils.closeTestWindow();
                    waitsForDone(nodeConnection.domains.bower_test_fileutils.deleteRecursive(testFolder), "deleting test folder");
                });

                runs(function () {
                    nodeConnection.disconnect();
                    nodeConnection = null;
                });
            });

            it("should return a list of package names", function () {
                var serverInfo, packages, i;
                runs(function () {
                    nodeConnection.domains.bower.getPackages()
                        .done(function (data) {
                            packages = data;
                        });
                });

                waitsFor(function () { return packages; }, "waiting for bower package list", 10000);

                runs(function () {
                    expect(Array.isArray(packages)).toBe(true);
                    expect(packages.length).toBeGreaterThan(0);
                    for (i = 0; i < packages.length; i++) {
                        expect(typeof packages[i].name).toBe("string");
                        expect(typeof packages[i].url).toBe("string");
                    }
                });
            });

            it("should install jquery", function () {
                runs(function () {
                    waitsForDone(nodeConnection.domains.bower.installPackage(testFolder, "jquery"),
                                 "installing jquery", 10000);
                });
                runs(function () {
                    waitsForDone(FileUtils.readAsText(new NativeFileSystem.FileEntry(testFolder + "/bower_components/jquery/jquery.js")),
                                 "reading installed jquery");
                });
            });
        });
    });
});
<commit_msg>Fixing tests: - Migrate NodeConnection to NodeDomain - Update bower domain APIs calls<commit_after>/*
 * Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 */

/*jslint vars: true, plusplus: true, devel: true, browser: true, nomen: true, indent: 4, maxerr: 50 */
/*global define, describe, it, expect, beforeEach, afterEach, waits, waitsFor, waitsForDone, runs, $, brackets, waitsForDone, spyOn, tinycolor, KeyEvent */

define(function (require, exports, module) {
    "use strict";

    var NodeDomain       = brackets.getModule("utils/NodeDomain"),
        FileUtils        = brackets.getModule("file/FileUtils"),
        FileSystem       = brackets.getModule("filesystem/FileSystem"),
        ExtensionUtils   = brackets.getModule("utils/ExtensionUtils"),
        SpecRunnerUtils  = brackets.getModule("spec/SpecRunnerUtils"),
        Async            = brackets.getModule("utils/Async");

    // TODO: should put in system temp folder, but we don't have a generic way to get that
    var testFolder      = FileUtils.getNativeModuleDirectoryPath(module) + "/tmp-test";

    describe("bower-install", function () {

        // Unit tests for the underlying node server.
        describe("BowerDomain", function () {
            var bowerDomain,
                fileUtilsDomain,
                testBrackets,
                ProjectManager,
                emptyConfig = {};

            beforeEach(function () {
                runs(function () {
                    var bowerDomainPath = ExtensionUtils.getModulePath(module, "/node/BowerDomain"),
                        fileUtilsDomainPath = ExtensionUtils.getModulePath(module, "/node/FileUtilsDomain");

                    bowerDomain = new NodeDomain("bower", bowerDomainPath);
                    fileUtilsDomain = new NodeDomain("fileUtils", fileUtilsDomainPath);
                    //waitsForDone(nodePromise, "connecting to node server");
                });

                runs(function () {
                    var folderPromise = new $.Deferred();
                    SpecRunnerUtils.createTestWindowAndRun(this, function (testWindow) {
                        testBrackets = testWindow.brackets;
                        ProjectManager = testBrackets.test.ProjectManager;

                        testBrackets.fs.makedir(testFolder, 0, function (err) {
                            if (err === testBrackets.fs.NO_ERROR) {
                                ProjectManager.openProject(testFolder)
                                    .then(folderPromise.resolve, folderPromise.reject);
                            } else {
                                folderPromise.reject();
                            }
                        });
                        folderPromise.resolve();
                    });
                    waitsForDone(folderPromise, "waiting for test folder to be created");
                });
            });

            afterEach(function () {
                runs(function () {
                    SpecRunnerUtils.closeTestWindow();

                    fileUtilsDomain.exec("deleteRecursive", testFolder);
                });

                runs(function () {
                    bowerDomain = null;
                    fileUtilsDomain = null;
                });
            });

            it("should return a list of package names", function () {
                var serverInfo, packages, i;

                runs(function () {
                    bowerDomain.exec("getPackages", emptyConfig)
                        .done(function (data) {
                            packages = data;
                        });
                });

                waitsFor(function () { return packages; }, "waiting for bower package list", 100000);

                runs(function () {
                    expect(Array.isArray(packages)).toBe(true);
                    expect(packages.length).toBeGreaterThan(0);

                    for (i = 0; i < packages.length; i++) {
                        expect(typeof packages[i].name).toBe("string");
                        expect(typeof packages[i].url).toBe("string");
                    }
                });
            });

            it("should install jquery", function () {
                runs(function () {
                    waitsForDone(bowerDomain.exec("installPackage", testFolder, "jquery", emptyConfig),
                                 "installing jquery", 10000);
                });
                runs(function () {
                    var file = FileSystem.getFileForPath(testFolder + "/bower_components/jquery/dist/jquery.min.js");

                    waitsForDone(FileUtils.readAsText(file), "reading installed jquery");
                });
            });
        });
    });
});
<|endoftext|>


<commit_before>Seed({
	name : 'Mold.Tools.Test._',
	dna : 'package',
	include : [
		".ConsoleReporter",
		".Tester",
		".Unit"
]
});<commit_msg>.Unit removed<commit_after>Seed({
	name : 'Mold.Tools.Test._',
	dna : 'package',
	include : [
		".ConsoleReporter",
		".Tester",
	]
});<|endoftext|>


<commit_before>app.controller('ConsoleContextCtrl', ['$scope', function () {
    $('.menu.item').tab();
}]);
app.controller('MemoryContextCtrl', ['$scope', '$location', function ($scope, $location) {
    $('.message .close').on('click', function () {
        $(this).closest('.message').transition('fade');
    });
    $('.ui.submit').on('click', function () {
        $('#gc').submit();
    });
    $scope.visible = false;
    if ($location.search().success) {
        $scope.visible = true;
    }
}]);
app.controller('sqlDefineContextCtrl', ['$scope', function () {
    $('.menu.item').tab();
}]);

app.controller('indexCtrl', function($scope,$compile,$http,$ocLazyLoad) {

	$scope.tabs = [];

	//选中tabs
	$scope.selectId;
	$scope.breadcrumbData = [];

	$scope.isSelected = function(id){
		return _.isEqual($scope.selectId, id);
	}

	$scope.init = function(){}

    /**logout**/
    $scope.logout = function(){
      $('#logout').submit();
    }
});

app.controller('menuCtrl', function($scope,$http,$ocLazyLoad,$log) {

	$scope.menu;

	$scope.init=function(){
		$.ajax({
	         type : "post",
	         url : "/basic/menu/menuTreeData",
	         contentType:'application/json',
	         dataType:'json',
	         async:false,
	         success : function(data){
	       	  if(data.code = '0'){
	        	$scope.menu = data.result;

	        	/*初始化选中首页
	        	if(!_.isEmpty(data.result)){

	        		var item;
	        		for(var idx in data.result){
	        			item = data.result[idx];
	        			if(item.ico == 'ti-home'){
	        				$scope.$parent.selectId = item.id;
	        				$scope.$parent.tabs.push(item);
	        				break;
	        			}
	        		}

        			//TODO loading js ..
	        	}*/
	       	  }else{
	       		 $.error(data.message);
	       	  }
	         }
	    });
	}

	$scope.forward = function(item){

		if(!_.isEmpty(item.link)){
			var promise =  $ocLazyLoad.load("templates"+item.link+".js");
			promise.then(function(res){//success
 			},function(error){//error
			},function(info){//notify
			}).catch(function(ex){
			}).finally(function(res){

				if(_.findIndex($scope.$parent.tabs, item) < 0){
					$scope.$parent.tabs.push(item);
				}
				//绑定选中tab
				$scope.$parent.selectId = item.id;
			})
		}
	}

});
<commit_msg>222222<commit_after>app.controller('ConsoleContextCtrl', ['$scope', function () {
    $('.menu.item').tab();
}]);
app.controller('MemoryContextCtrl', ['$scope', '$location', function ($scope, $location) {
    $('.message .close').on('click', function () {
        $(this).closest('.message').transition('fade');
    });
    $('.ui.submit').on('click', function () {
        $('#gc').submit();
    });
    $scope.visible = false;
    if ($location.search().success) {
        $scope.visible = true;
    }
}]);
app.controller('sqlDefineContextCtrl', ['$scope', function () {
    $('.menu.item').tab();
}]);

app.controller('indexCtrl', function($scope,$compile,$http,$ocLazyLoad) {

	$scope.tabs = [];

	//选中tabs
	$scope.selectId;
	$scope.breadcrumbData = [];

	$scope.isSelected = function(id){
		return _.isEqual($scope.selectId, id);
	}

	$scope.init = function(){}

    /**logout**/
    $scope.logout = function(){
      $('#logout').submit();
    }
});

app.controller('menuCtrl', function($scope,$http,$ocLazyLoad,$log) {

	$scope.menu;

	$scope.init=function(){
		$.ajax({
	         type : "post",
	         url : "/basic/menu/menuTreeData",
	         contentType:'application/json',
	         dataType:'json',
	         async:false,
	         success : function(data){
	       	  if(data.code = '0'){
	        	$scope.menu = data.result;

	        	/*初始化选中首页*/
	        	if(!_.isEmpty(data.result)){

	        		var item;
	        		for(var idx in data.result){
	        			item = data.result[idx];
	        			if(item.ico == 'ti-home'){
	        				$scope.$parent.selectId = item.id;
	        				$scope.$parent.tabs.push(item);
	        				break;
	        			}
	        		}

        			//TODO loading js ..
	        	}
	       	  }else{
	       		 $.error(data.message);
	       	  }
	         }
	    });
	}

	$scope.forward = function(item){

		if(!_.isEmpty(item.link)){
			var promise =  $ocLazyLoad.load("templates"+item.link+".js");
			promise.then(function(res){//success
 			},function(error){//error
			},function(info){//notify
			}).catch(function(ex){
			}).finally(function(res){

				if(_.findIndex($scope.$parent.tabs, item) < 0){
					$scope.$parent.tabs.push(item);
				}
				//绑定选中tab
				$scope.$parent.selectId = item.id;
			})
		}
	}

});
<|endoftext|>


<commit_before>// For University Theme Color
function getColorByUnivName(univ) {
  if (univ == "KYU" || univ.includes("가야대")) return "#114fa1";
  if (univ == "GCHU" || univ.includes("가천대")) return "#00458c";
  if (univ == "CUK" || univ.includes("가톨릭대")) return "#003594";
  if (univ == "CKU" || univ.includes("가톨릭관동대")) return "#006276";
  if (univ == "MTU" || univ.includes("감리교신학대")) return "#800080";
  if (univ == "KANGNAM" || univ.includes("강남대")) return "#0091FF";
  if (univ == "GWNU" || univ.includes("강릉원주대")) return "#a90056";
  if (univ == "KNU" || univ.includes("강원대")) return "#1851a5";
  if (univ == "KU" || univ.includes("건국대") || univ == "건대") return "#036b3f";
  if (univ == "KONYANG" || univ.includes("건양대")) return "#006940";
  if (univ == "KGU" || univ.includes("경기대")) return "#004889";
  if (univ == "GNTECH" || univ.includes("경남과학기술대")) return "#2956a6";
  if (univ == "KYUNGNAM" || univ.includes("경남대")) return "#003A56";
  if (univ == "KDU" || univ.includes("경동대")) return "#0C4DA2";
  if (univ == "KPNU" || univ.includes("경북대")) return "#da2127";
  if (univ == "GNU" || univ.includes("경상대")) return "#242b90";
  if (univ == "KS" || univ.includes("경성대")) return "#0057b8";
  if (univ == "IKW" || univ.includes("경운대")) return "#23438e";
  if (univ == "KIU" || univ.includes("경일대")) return "#98012e";
  if (univ == "GJU" || univ.includes("경주대")) return "#df0013";
  if (univ == "KHU" || univ.includes("경희대")) return "#9d2235";
  if (univ == "KEIMYUNG" || univ.includes("계명대")) return "#024da0";
  if (univ == "KRU" || univ.includes("고려대") || univ == "고대") return "#862633";
  if (univ == "KOSIN" || univ.includes("고신대")) return "#003f91";
  if (univ == "KJNU" || univ.includes("공주대")) return "#01499a";
  if (univ == "KSU" || univ.includes("광신대")) return "#1d2881";
  if (univ == "KWU" || univ.includes("광운대")) return "#8a1601";
  if (univ == "GWJCU" || univ.includes("광주가톨릭대")) return "#ed1c24";
  if (univ == "GWJU" || univ.includes("광주대")) return "#144112";
  if (univ == "GWJWU" || univ.includes("광주여자대")) return "#008b9c";
  if (univ == "KMU" || univ.includes("국민대")) return "#2864ae";
  if (univ == "KSNU" || univ.includes("군산대")) return "#437fc1";
  if (univ == "FEU" || univ.includes("극동대")) return "#221f1f";
  if (univ == "GGU" || univ.includes("금강대")) return "#005aab";
  if (univ == "KIT" || univ.includes("금오공과대") || univ == "금오공대") return "#1e90ff";
  if (univ == "GCU" || univ.includes("김천대")) return "#57444e";
  if (univ == "KKOT" || univ.includes("꽃동네대")) return "#cf171f";

  if (univ == "NAZARENE" || univ.includes("나사렛대")) return "#b32f20";
  if (univ == "NBU" || univ.includes("남부대")) return "#13007d";
  if (univ == "NSU" || univ.includes("남서울대")) return "#1f519b";

  if (univ == "DKU" || univ.includes("단국대")) return "#245ca1";
  if (univ == "CU" || univ.includes("대구가톨릭대")) return "#0742a4";
  if (univ == "DAEGU" || univ.includes("대구대")) return "#00806e";
  if (univ == "DGAU" || univ.includes("대구예술대")) return "#df569e";
  if (univ == "DHU" || univ.includes("대구한의대")) return "#50ad95";
  if (univ == "DSU" || univ.includes("대신대")) return "#3680bd";
  if (univ == "DCU" || univ.includes("대전가톨릭대")) return "#7a42a0";
  if (univ == "DJU" || univ.includes("대전대")) return "#347c4d";
  if (univ == "DTU" || univ.includes("대전신학대")) return "#2d70b5";
  if (univ == "DJNU" || univ.includes("대진대")) return "#184490";
  if (univ == "DSWU" || univ.includes("덕성여자대") || univ.includes("덕성여대")) return "#ac145a";
  if (univ == "DGU" || univ.includes("동국대")) return "#cb6015";
  if (univ == "DDWU" || univ.includes("동덕여자대") || univ.includes("동덕여대")) return "#8b2842";
  if (univ == "TU" || univ.includes("동명대")) return "#53aa48";
  if (univ == "DSU" || univ.includes("동서대")) return "#d43645";
  if (univ == "DSNU" || univ.includes("동신대")) return "#255ea9";
  if (univ == "DAU" || univ.includes("동아대")) return "#29166f";
  if (univ == "DYU" || univ.includes("동양대")) return "#143b82";
  if (univ == "DEU" || univ.includes("동의대")) return "#0b3d91";

  if (univ == "LTU" || univ.includes("루터대")) return "#2457a6";

  if (univ == "MJU" || univ.includes("명지대")) return "#10336c";
  if (univ == "MWU" || univ.includes("목원대")) return "#8b0000";
  if (univ == "MCU" || univ.includes("목포가톨릭대")) return "#353a97";
  if (univ == "MPNU" || univ.includes("목포대")) return "#20b2aa";
  if (univ == "MPNMU" || univ.includes("목포해양대")) return "#1f5a92";

  if (univ == "PCU" || univ.includes("배재대")) return "#071d8e";
  if (univ == "BU" || univ.includes("백석대")) return "#12319b";
  if (univ == "PKNU" || univ.includes("부경대")) return "#13007c";
  if (univ == "CUP" || univ.includes("부산가톨릭대")) return "#9a2183";
  if (univ == "PNU" || univ.includes("부산대") || univ == "부대") return "#005baa";
  if (univ == "BUFS" || univ.includes("부산외국어대") || univ == "부산외대") return "#ffd000";
  if (univ == "BPU" || univ.includes("부산장신대")) return "#2d6fa8";

  if (univ == "SYU" || univ.includes("삼육대")) return "#5389c6";
  if (univ == "SMU" || univ.includes("상명대")) return "#1f519b";
  if (univ == "SGU" || univ.includes("서강대")) return "#B0232A";
  if (univ == "SKU" || univ.includes("서경대")) return "#71bf44";
  if (univ == "SNU" || univ.includes("서울대")) return "#20408e";
  if (univ == "SeoulTech" || univ.includes("서울과학기술대") || univ == "서울과기대") return "#00205b";
  if (univ == "UOS" || univ.includes("서울시립대")) return "#151f6d";
  if (univ == "SKHU" || univ.includes("성공회대")) return "#006BB1";
  if (univ == "SKKU" || univ.includes("성균관대")) return "#8DC63F";
  if (univ == "SJU" || univ.includes("세종대")) return "#ba0c2f";
  if (univ == "SSU" || univ.includes("숭실대")) return "#4badcd";
  if (univ == "SWC" || univ.includes("숭의여대")) return "062d8f";

  if (univ == "AJU" || univ.includes("아주대")) return "#0072ce";
  if (univ == "YSU" || univ.includes("연세대")) return "#16407d";
  if (univ == "JBNU" || univ.includes("전북대")) return "#56296f";
  if (univ == "JNU" || univ.includes("전남대")) return "#00913F";
  if (univ == "CAU" || univ.includes("중앙대")) return "#004c97";

  if (univ == "CNU" || univ.includes("충남대")) return "#003f98";

  if (univ == "PTU" || univ.includes("평택대")) return "#003e15";

  if (univ == "HUFS" || univ.includes("한국외국어대")) return "#00677F";
  if (univ == "KAU" || univ.includes("한국항공대")) return "#302475";
  if (univ == "HSU" || univ.includes("한성대")) return "#62b5e5";
  if (univ == "HYU" || univ.includes("한양대")) return "#003c71";
  if (univ == "HOSEO" || univ.includes("호서대")) return "#08449a";
  if (univ == "HIU" || univ.includes("홍익대")) return "#002c62";

  return "Not Found";
}
<commit_msg>Add Jeonju university<commit_after>// For University Theme Color
function getColorByUnivName(univ) {
  if (univ == "KYU" || univ.includes("가야대")) return "#114fa1";
  if (univ == "GCHU" || univ.includes("가천대")) return "#00458c";
  if (univ == "CUK" || univ.includes("가톨릭대")) return "#003594";
  if (univ == "CKU" || univ.includes("가톨릭관동대")) return "#006276";
  if (univ == "MTU" || univ.includes("감리교신학대")) return "#800080";
  if (univ == "KANGNAM" || univ.includes("강남대")) return "#0091FF";
  if (univ == "GWNU" || univ.includes("강릉원주대")) return "#a90056";
  if (univ == "KNU" || univ.includes("강원대")) return "#1851a5";
  if (univ == "KU" || univ.includes("건국대") || univ == "건대") return "#036b3f";
  if (univ == "KONYANG" || univ.includes("건양대")) return "#006940";
  if (univ == "KGU" || univ.includes("경기대")) return "#004889";
  if (univ == "GNTECH" || univ.includes("경남과학기술대")) return "#2956a6";
  if (univ == "KYUNGNAM" || univ.includes("경남대")) return "#003A56";
  if (univ == "KDU" || univ.includes("경동대")) return "#0C4DA2";
  if (univ == "KPNU" || univ.includes("경북대")) return "#da2127";
  if (univ == "GNU" || univ.includes("경상대")) return "#242b90";
  if (univ == "KS" || univ.includes("경성대")) return "#0057b8";
  if (univ == "IKW" || univ.includes("경운대")) return "#23438e";
  if (univ == "KIU" || univ.includes("경일대")) return "#98012e";
  if (univ == "GJU" || univ.includes("경주대")) return "#df0013";
  if (univ == "KHU" || univ.includes("경희대")) return "#9d2235";
  if (univ == "KEIMYUNG" || univ.includes("계명대")) return "#024da0";
  if (univ == "KRU" || univ.includes("고려대") || univ == "고대") return "#862633";
  if (univ == "KOSIN" || univ.includes("고신대")) return "#003f91";
  if (univ == "KJNU" || univ.includes("공주대")) return "#01499a";
  if (univ == "KSU" || univ.includes("광신대")) return "#1d2881";
  if (univ == "KWU" || univ.includes("광운대")) return "#8a1601";
  if (univ == "GWJCU" || univ.includes("광주가톨릭대")) return "#ed1c24";
  if (univ == "GWJU" || univ.includes("광주대")) return "#144112";
  if (univ == "GWJWU" || univ.includes("광주여자대")) return "#008b9c";
  if (univ == "KMU" || univ.includes("국민대")) return "#2864ae";
  if (univ == "KSNU" || univ.includes("군산대")) return "#437fc1";
  if (univ == "FEU" || univ.includes("극동대")) return "#221f1f";
  if (univ == "GGU" || univ.includes("금강대")) return "#005aab";
  if (univ == "KIT" || univ.includes("금오공과대") || univ == "금오공대") return "#1e90ff";
  if (univ == "GCU" || univ.includes("김천대")) return "#57444e";
  if (univ == "KKOT" || univ.includes("꽃동네대")) return "#cf171f";

  if (univ == "NAZARENE" || univ.includes("나사렛대")) return "#b32f20";
  if (univ == "NBU" || univ.includes("남부대")) return "#13007d";
  if (univ == "NSU" || univ.includes("남서울대")) return "#1f519b";

  if (univ == "DKU" || univ.includes("단국대")) return "#245ca1";
  if (univ == "CU" || univ.includes("대구가톨릭대")) return "#0742a4";
  if (univ == "DAEGU" || univ.includes("대구대")) return "#00806e";
  if (univ == "DGAU" || univ.includes("대구예술대")) return "#df569e";
  if (univ == "DHU" || univ.includes("대구한의대")) return "#50ad95";
  if (univ == "DSU" || univ.includes("대신대")) return "#3680bd";
  if (univ == "DCU" || univ.includes("대전가톨릭대")) return "#7a42a0";
  if (univ == "DJU" || univ.includes("대전대")) return "#347c4d";
  if (univ == "DTU" || univ.includes("대전신학대")) return "#2d70b5";
  if (univ == "DJNU" || univ.includes("대진대")) return "#184490";
  if (univ == "DSWU" || univ.includes("덕성여자대") || univ.includes("덕성여대")) return "#ac145a";
  if (univ == "DGU" || univ.includes("동국대")) return "#cb6015";
  if (univ == "DDWU" || univ.includes("동덕여자대") || univ.includes("동덕여대")) return "#8b2842";
  if (univ == "TU" || univ.includes("동명대")) return "#53aa48";
  if (univ == "DSU" || univ.includes("동서대")) return "#d43645";
  if (univ == "DSNU" || univ.includes("동신대")) return "#255ea9";
  if (univ == "DAU" || univ.includes("동아대")) return "#29166f";
  if (univ == "DYU" || univ.includes("동양대")) return "#143b82";
  if (univ == "DEU" || univ.includes("동의대")) return "#0b3d91";

  if (univ == "LTU" || univ.includes("루터대")) return "#2457a6";

  if (univ == "MJU" || univ.includes("명지대")) return "#10336c";
  if (univ == "MWU" || univ.includes("목원대")) return "#8b0000";
  if (univ == "MCU" || univ.includes("목포가톨릭대")) return "#353a97";
  if (univ == "MPNU" || univ.includes("목포대")) return "#20b2aa";
  if (univ == "MPNMU" || univ.includes("목포해양대")) return "#1f5a92";

  if (univ == "PCU" || univ.includes("배재대")) return "#071d8e";
  if (univ == "BU" || univ.includes("백석대")) return "#12319b";
  if (univ == "PKNU" || univ.includes("부경대")) return "#13007c";
  if (univ == "CUP" || univ.includes("부산가톨릭대")) return "#9a2183";
  if (univ == "PNU" || univ.includes("부산대") || univ == "부대") return "#005baa";
  if (univ == "BUFS" || univ.includes("부산외국어대") || univ == "부산외대") return "#ffd000";
  if (univ == "BPU" || univ.includes("부산장신대")) return "#2d6fa8";

  if (univ == "SYU" || univ.includes("삼육대")) return "#5389c6";
  if (univ == "SMU" || univ.includes("상명대")) return "#1f519b";
  if (univ == "SGU" || univ.includes("서강대")) return "#B0232A";
  if (univ == "SKU" || univ.includes("서경대")) return "#71bf44";
  if (univ == "SNU" || univ.includes("서울대")) return "#20408e";
  if (univ == "SeoulTech" || univ.includes("서울과학기술대") || univ == "서울과기대") return "#00205b";
  if (univ == "UOS" || univ.includes("서울시립대")) return "#151f6d";
  if (univ == "SKHU" || univ.includes("성공회대")) return "#006BB1";
  if (univ == "SKKU" || univ.includes("성균관대")) return "#8DC63F";
  if (univ == "SJU" || univ.includes("세종대")) return "#ba0c2f";
  if (univ == "SSU" || univ.includes("숭실대")) return "#4badcd";
  if (univ == "SWC" || univ.includes("숭의여대")) return "062d8f";

  if (univ == "AJU" || univ.includes("아주대")) return "#0072ce";
  if (univ == "YSU" || univ.includes("연세대")) return "#16407d";
  if (univ == "JBNU" || univ.includes("전북대")) return "#56296f";
  if (univ == "JNU" || univ.includes("전남대")) return "#00913F";
  if (univ == "CAU" || univ.includes("중앙대")) return "#004c97";

  if (univ == "CNU" || univ.includes("충남대")) return "#003f98";

  if (univ == "PTU" || univ.includes("평택대")) return "#003e15";

  if (univ == "HUFS" || univ.includes("한국외국어대")) return "#00677F";
  if (univ == "KAU" || univ.includes("한국항공대")) return "#302475";
  if (univ == "HSU" || univ.includes("한성대")) return "#62b5e5";
  if (univ == "HYU" || univ.includes("한양대")) return "#003c71";
  if (univ == "HOSEO" || univ.includes("호서대")) return "#08449a";
  if (univ == "HIU" || univ.includes("홍익대")) return "#002c62";
  if (univ == "JJU" || univ.includes("전주대")) return "#006ba6";

  return "Not Found";
}
<|endoftext|>


<commit_before>function viewCollections(collectionId) {

    var result = {};
    var pageDataRequests = []; // list of promises - one for each ajax request.
    pageDataRequests.push(
        $.ajax({
            url: "/zebedee/collections",
            type: "get",
            success: function (data) {
                result.data = data;
            },
            error: function (jqxhr) {
                handleApiError(jqxhr);
            }
        })
    );
    pageDataRequests.push(
        getTeams(
            success = function (team) {
                result.team = team;
            },
            error = function (response) {
                handleApiError(response);
            }
        )
    );

    $.when.apply($, pageDataRequests).then(function () {

        var response = [], teams = [], date = "";

        $.each(result.data, function (i, collection) {
            var approvalStates = {inProgress: false, thrownError: false, completed: false};

            if (collection.approvalStatus != "COMPLETE") {

                // Set publish date
                if (!collection.publishDate) {
                    date = '[manual collection]';
                } else if (collection.publishDate && collection.type === 'manual') {
                    date = StringUtils.formatIsoDateString(collection.publishDate) + ' [rolled back]';
                } else {
                    date = StringUtils.formatIsoDateString(collection.publishDate);
                }

                // Set approval state
                switch (collection.approvalStatus) {
                    case (undefined): {
                        break;
                    }
                    case ('IN_PROGRESS'): {
                        approvalStates.inProgress = true;
                        break;
                    }
                    case ('COMPLETE'): {
                        approvalStates.completed = true;
                        break;
                    }
                    case ('ERROR'): {
                        approvalStates.thrownError = true;
                        break;
                    }
                }

                response.push({id: collection.id, name: collection.name, date: date, approvalState: approvalStates});
            }
        });

        var isDataVis = false;
        if (Florence.Authentication.userType() === "DATA_VISUALISATION") {
            isDataVis = true;
        }
        var collectionsHtml = templates.collectionList({response: response, teams: result.team.teams, isDataVis: isDataVis});
        $('.section').html(collectionsHtml);

        if (collectionId) {
            viewCollectionDetails(collectionId, $('.js-selectable-table tr[data-id="' + collectionId + '"]'));
        }

        $('.js-selectable-table tbody tr').click(function () {
            var collectionId = $(this).attr('data-id');
            viewCollectionDetails(collectionId, $(this));
        });

        $("#team-tag").tagit({
            singleField: true,
            singleFieldNode: $('#team-input')
        });

        $('.ui-autocomplete-input').hide();

        $('select#team').change(function () {
            $('#team-tag').tagit('createTag', $("#team option:selected").text());
        });

        $('#team-input').change(function () {
            teams = $('#team-input').val().split(',');
            //After creating the array tagit leaves an empty string if all elements are removed
            if (teams.length === 1 && teams[0] === "") {
                teams = [];
            }
        });

        $('form input[type=radio]').click(function () {

            if ($(this).val() === 'manual') {
                $('#scheduledPublishOptions').hide();
            } else if ($(this).val() === 'scheduled') {
                $('#scheduledPublishOptions').show();
            } else if ($(this).val() === 'custom') {
                $('#customScheduleOptions').show();
                $('#releaseScheduleOptions').hide();
            } else if ($(this).val() === 'release') {
                $('#customScheduleOptions').hide();
                $('#releaseScheduleOptions').show();
            }
        });

        $(function () {
            var today = new Date();
            $('#date').datepicker({
                minDate: today,
                dateFormat: 'dd/mm/yy',
                constrainInput: true
            });
        });

        $('.btn-select-release').on("click", function (e) {
            e.preventDefault();
            viewReleaseSelector();
        });

        $('.form-create-collection').submit(function (e) {
            e.preventDefault();
            createCollection(teams);
        });
    });
}<commit_msg>Add not started boolean to approvalStates array<commit_after>function viewCollections(collectionId) {

    var result = {};
    var pageDataRequests = []; // list of promises - one for each ajax request.
    pageDataRequests.push(
        $.ajax({
            url: "/zebedee/collections",
            type: "get",
            success: function (data) {
                result.data = data;
            },
            error: function (jqxhr) {
                handleApiError(jqxhr);
            }
        })
    );
    pageDataRequests.push(
        getTeams(
            success = function (team) {
                result.team = team;
            },
            error = function (response) {
                handleApiError(response);
            }
        )
    );

    $.when.apply($, pageDataRequests).then(function () {

        var response = [], teams = [], date = "";

        $.each(result.data, function (i, collection) {
            var approvalStates = {inProgress: false, thrownError: false, completed: false, notStarted: false};

            if (collection.approvalStatus != "COMPLETE") {

                // Set publish date
                if (!collection.publishDate) {
                    date = '[manual collection]';
                } else if (collection.publishDate && collection.type === 'manual') {
                    date = StringUtils.formatIsoDateString(collection.publishDate) + ' [rolled back]';
                } else {
                    date = StringUtils.formatIsoDateString(collection.publishDate);
                }

                // Set approval state
                switch (collection.approvalStatus) {
                    case (undefined): {
                        break;
                    }
                    case ('NOT_STARTED'): {
                        approvalStates.notStarted = true;
                        break;
                    }
                    case ('IN_PROGRESS'): {
                        approvalStates.inProgress = true;
                        break;
                    }
                    case ('COMPLETE'): {
                        approvalStates.completed = true;
                        break;
                    }
                    case ('ERROR'): {
                        approvalStates.thrownError = true;
                        break;
                    }
                }

                response.push({id: collection.id, name: collection.name, date: date, approvalState: approvalStates});
            }
        });

        var isDataVis = false;
        if (Florence.Authentication.userType() === "DATA_VISUALISATION") {
            isDataVis = true;
        }
        var collectionsHtml = templates.collectionList({response: response, teams: result.team.teams, isDataVis: isDataVis});
        $('.section').html(collectionsHtml);

        if (collectionId) {
            viewCollectionDetails(collectionId, $('.js-selectable-table tr[data-id="' + collectionId + '"]'));
        }

        $('.js-selectable-table tbody tr').click(function () {
            var collectionId = $(this).attr('data-id');
            viewCollectionDetails(collectionId, $(this));
        });

        $("#team-tag").tagit({
            singleField: true,
            singleFieldNode: $('#team-input')
        });

        $('.ui-autocomplete-input').hide();

        $('select#team').change(function () {
            $('#team-tag').tagit('createTag', $("#team option:selected").text());
        });

        $('#team-input').change(function () {
            teams = $('#team-input').val().split(',');
            //After creating the array tagit leaves an empty string if all elements are removed
            if (teams.length === 1 && teams[0] === "") {
                teams = [];
            }
        });

        $('form input[type=radio]').click(function () {

            if ($(this).val() === 'manual') {
                $('#scheduledPublishOptions').hide();
            } else if ($(this).val() === 'scheduled') {
                $('#scheduledPublishOptions').show();
            } else if ($(this).val() === 'custom') {
                $('#customScheduleOptions').show();
                $('#releaseScheduleOptions').hide();
            } else if ($(this).val() === 'release') {
                $('#customScheduleOptions').hide();
                $('#releaseScheduleOptions').show();
            }
        });

        $(function () {
            var today = new Date();
            $('#date').datepicker({
                minDate: today,
                dateFormat: 'dd/mm/yy',
                constrainInput: true
            });
        });

        $('.btn-select-release').on("click", function (e) {
            e.preventDefault();
            viewReleaseSelector();
        });

        $('.form-create-collection').submit(function (e) {
            e.preventDefault();
            createCollection(teams);
        });
    });
}<|endoftext|>


<commit_before>"use strict";

(function(ADL){

	var XAPIDashboard = function(){
		this.statements = new ADL.Collection();
	}

	XAPIDashboard.prototype.fetchAllStatements = function(query, wrapper, cb){
		var self = this;
		if( !wrapper || typeof(wrapper) === 'function' ){
			if(typeof(wrapper) === 'function' && !cb)
				cb = wrapper;
			wrapper = ADL.XAPIWrapper;
		}

		wrapper.getStatements(query, null, function getMore(r){
			var response = JSON.parse(r.response);
			self.addStatements(response.statements);

			if(response.more){
				wrapper.getStatements(null, response.more, getMore);
			}

			else if(cb){
				cb();
			}
		});
	};

	//To-do
	XAPIDashboard.prototype.clearSavedStatements = function(){};

	XAPIDashboard.prototype.addStatements = function(statementsArr){
		if(statementsArr.response){
			try{
				statementsArr = JSON.parse(statementsArr.response).statements;
			}
			catch(e){
				console.error("Error parsing JSON data", statementsArr.response);
				return;
			}
		}

		this.statements = this.statements.union(new ADL.Collection(statementsArr));
	};

	// default aggregator requires opts.groupField
	// opts.aggregate, opts.pre, opts.post, opts.customize are optional functions
	XAPIDashboard.prototype.genLineGraph = function(container, opts){

		var data = this.statements;
		if(opts.pre)
			data = opts.pre(data);

		data = (opts.aggregate ? opts.aggregate : XAPIDashboard.accumulate)(data, opts);

		if(opts.post)
			data = opts.post(data);

		nv.addGraph(function(){
			var chart = nv.models.lineChart()
				.options({
					'x': function(d,i){ return d.in; },
					'y': function(d,i){ return d.out; },
					'showXAxis': true,
					'showYAxis': true,
					'transitionDuration': 250
				});

			if(opts.customize)
				opts.customize(chart);

			d3.select(container)
				.datum([{'values': data.contents}])
				.call(chart);

  			nv.utils.windowResize(chart.update);
			return chart;
		});
	};

	// default aggregator requires opts.xField
	// opts.aggregate, opts.pre, opts.post, opts.customize are optional functions
	XAPIDashboard.prototype.genBarGraph = function(container, opts){
		var data = this.statements;
		if(opts.pre)
			data = opts.pre(data);

		data = (opts.aggregate ? opts.aggregate : XAPIDashboard.count)(data, opts);

		if(opts.post)
			data = opts.post(data);

		nv.addGraph(function(){
			var chart = nv.models.discreteBarChart()
				.x(function(d){ return d.in; })
				.y(function(d){ return d.out; })
				.staggerLabels(true)
				.transitionDuration(250);

			if( opts.customize )
				opts.customize(chart);

			d3.select(container)
				.datum([{
					'values': data.contents}])
				.call(chart);

			nv.utils.windowResize(chart.update);
			return chart;
		});
	};

	/*
	 * Class methods to perform graph "formatting" operations
	 */

	XAPIDashboard.count = function(statements, opts){
		return statements.groupBy(opts.groupField, function(groupSet){ return groupSet.count(); });
	};

	XAPIDashboard.accumulate = function(statements, opts){
		return statements.transform(function(elem,index,array){
			return {
				'in': ADL.Collection.getValue(opts.xField)(elem),
				'out': opts.yField ? statements.select(ADL.Collection.first(index+1)).sum(opts.yField) : index+1,
				'sample': elem
			};
		});
	};

	ADL.XAPIDashboard = XAPIDashboard;

})(window.ADL = window.ADL || {});
<commit_msg>Added simple countRange function<commit_after>"use strict";

(function(ADL){

	var XAPIDashboard = function(){
		this.statements = new ADL.Collection();
	}

	XAPIDashboard.prototype.fetchAllStatements = function(query, wrapper, cb){
		var self = this;
		if( !wrapper || typeof(wrapper) === 'function' ){
			if(typeof(wrapper) === 'function' && !cb)
				cb = wrapper;
			wrapper = ADL.XAPIWrapper;
		}

		wrapper.getStatements(query, null, function getMore(r){
			var response = JSON.parse(r.response);
			self.addStatements(response.statements);

			if(response.more){
				wrapper.getStatements(null, response.more, getMore);
			}

			else if(cb){
				cb();
			}
		});
	};

	//To-do
	XAPIDashboard.prototype.clearSavedStatements = function(){};

	XAPIDashboard.prototype.addStatements = function(statementsArr){
		if(statementsArr.response){
			try{
				statementsArr = JSON.parse(statementsArr.response).statements;
			}
			catch(e){
				console.error("Error parsing JSON data", statementsArr.response);
				return;
			}
		}

		this.statements = this.statements.union(new ADL.Collection(statementsArr));
	};

	// default aggregator requires opts.groupField
	// opts.aggregate, opts.pre, opts.post, opts.customize are optional functions
	XAPIDashboard.prototype.genLineGraph = function(container, opts){

		var data = this.statements;
		if(opts.pre)
			data = opts.pre(data);

		data = (opts.aggregate ? opts.aggregate : XAPIDashboard.accumulate)(data, opts);

		if(opts.post)
			data = opts.post(data);

		nv.addGraph(function(){
			var chart = nv.models.lineChart()
				.options({
					'x': function(d,i){ return d.in; },
					'y': function(d,i){ return d.out; },
					'showXAxis': true,
					'showYAxis': true,
					'transitionDuration': 250
				});

			if(opts.customize)
				opts.customize(chart);

			d3.select(container)
				.datum([{'values': data.contents}])
				.call(chart);

  			nv.utils.windowResize(chart.update);
			return chart;
		});
	};

	// default aggregator requires opts.xField
	// opts.aggregate, opts.pre, opts.post, opts.customize are optional functions
	XAPIDashboard.prototype.genBarGraph = function(container, opts){
		var data = this.statements;
		if(opts.pre)
			data = opts.pre(data);

		data = (opts.aggregate ? opts.aggregate : XAPIDashboard.count)(data, opts);

		if(opts.post)
			data = opts.post(data);

		nv.addGraph(function(){
			var chart = nv.models.discreteBarChart()
				.x(function(d){ return d.in; })
				.y(function(d){ return d.out; })
				.staggerLabels(true)
				.transitionDuration(250);

			if( opts.customize )
				opts.customize(chart);

			d3.select(container)
				.datum([{
					'values': data.contents}])
				.call(chart);

			nv.utils.windowResize(chart.update);
			return chart;
		});
	};

	/*
	 * Class methods to perform graph "formatting" operations
	 */

	XAPIDashboard.count = function(statements, opts){
		return statements.groupBy(opts.groupField, function(groupSet){ return groupSet.count(); });
	};

	XAPIDashboard.accumulate = function(statements, opts){
		return statements.transform(function(elem,index,array){
			return {
				'in': ADL.Collection.getValue(opts.xField)(elem),
				'out': opts.yField ? statements.select(ADL.Collection.first(index+1)).sum(opts.yField) : index+1,
				'sample': elem
			};
		});
	};

	XAPIDashboard.countRange = function(statements, opts){
		var rangeArr = ADL.Collection.genRange(opts.range.start, opts.range.end, opts.range.increment);
		return statements.groupByRange(opts.groupField, rangeArr, function(groupSet){
			return groupSet.count()
		});
	};

	ADL.XAPIDashboard = XAPIDashboard;

})(window.ADL = window.ADL || {});
<|endoftext|>


<commit_before>Flag.create({
	name: 'Afghanistan'
}, {
	name: 'Albania'
}, {
	name: 'Algeria'
}, {
	name: 'American Samoa'
}, {
	name: 'Andorra'
}, {
	name: 'Angola'
}, {
	name: 'Anguilla'
}, {
	name: 'Antarctica'
}, {
	name: 'Antigua and Barbuda'
}, {
	name: 'Argentina'
}, {
	name: 'Armenia'
}, {
	name: 'Aruba'
}, {
	name: 'Australia'
}, {
	name: 'Austria'
}, {
	name: 'Azerbaijan'
}, {
	name: 'Bahamas'
}, {
	name: 'Bahrain'
}, {
	name: 'Bangladesh'
}, {
	name: 'Barbados'
}, {
	name: 'Belarus'
}, {
	name: 'Belgium'
}, {
	name: 'Belize'
}, {
	name: 'Benin'
}, {
	name: 'Bermuda'
}, {
	name: 'Bhutan'
}, {
	name: 'Bolivia'
}, {
	name: 'Bosnia and Herzegovina'
}, {
	name: 'Botswana'
}, {
	name: 'Bouvet Island'
}, {
	name: 'Brazil'
}, {
	name: 'British Indian Ocean Territory'
}, {
	name: 'Brunei Darussalam'
}, {
	name: 'Bulgaria'
}, {
	name: 'Burkina Faso'
}, {
	name: 'Burundi'
}, {
	name: 'Cambodia'
}, {
	name: 'Cameroon'
}, {
	name: 'Canada'
}, {
	name: 'Cape Verde'
}, {
	name: 'Cayman Islands'
}, {
	name: 'Central African Republic'
}, {
	name: 'Chad'
}, {
	name: 'Chile'
}, {
	name: 'China'
}, {
	name: 'Christmas Island'
}, {
	name: 'Cocos (Keeling) Islands'
}, {
	name: 'Colombia'
}, {
	name: 'Comoros'
}, {
	name: 'Congo'
}, {
	name: 'Congo, The Democratic Republic Of The'
}, {
	name: 'Cook Islands'
}, {
	name: 'Costa Rica'
}, {
	name: 'Croatia'
}, {
	name: 'Cuba'
}, {
	name: 'Cyprus'
}, {
	name: 'Czech Republic'
}, {
	name: 'Côte D\'Ivoire'
}, {
	name: 'Denmark'
}, {
	name: 'Djibouti'
}, {
	name: 'Dominica'
}, {
	name: 'Dominican Republic'
}, {
	name: 'Ecuador'
}, {
	name: 'Egypt'
}, {
	name: 'El Salvador'
}, {
	name: 'Equatorial Guinea'
}, {
	name: 'Eritrea'
}, {
	name: 'Estonia'
}, {
	name: 'Ethiopia'
}, {
	name: 'Falkland Islands (Malvinas)'
}, {
	name: 'Faroe Islands'
}, {
	name: 'Fiji'
}, {
	name: 'Finland'
}, {
	name: 'France'
}, {
	name: 'French Guiana'
}, {
	name: 'French Polynesia'
}, {
	name: 'French Southern Territories'
}, {
	name: 'Gabon'
}, {
	name: 'Gambia'
}, {
	name: 'Georgia'
}, {
	name: 'Germany'
}, {
	name: 'Ghana'
}, {
	name: 'Gibraltar'
}, {
	name: 'Greece'
}, {
	name: 'Greenland'
}, {
	name: 'Grenada'
}, {
	name: 'Guadeloupe'
}, {
	name: 'Guam'
}, {
	name: 'Guatemala'
}, {
	name: 'Guernsey'
}, {
	name: 'Guinea'
}, {
	name: 'Guinea-Bissau'
}, {
	name: 'Guyana'
}, {
	name: 'Haiti'
}, {
	name: 'Heard and McDonald Islands'
}, {
	name: 'Holy See (Vatican City State)'
}, {
	name: 'Honduras'
}, {
	name: 'Hong Kong'
}, {
	name: 'Hungary'
}, {
	name: 'Iceland'
}, {
	name: 'India'
}, {
	name: 'Indonesia'
}, {
	name: 'Iran, Islamic Republic Of'
}, {
	name: 'Iraq'
}, {
	name: 'Ireland'
}, {
	name: 'Isle of Man'
}, {
	name: 'Israel'
}, {
	name: 'Italy'
}, {
	name: 'Jamaica'
}, {
	name: 'Japan'
}, {
	name: 'Jersey'
}, {
	name: 'Jordan'
}, {
	name: 'Kazakhstan'
}, {
	name: 'Kenya'
}, {
	name: 'Kiribati'
}, {
	name: 'Korea, Democratic People\'s Republic Of'
}, {
	name: 'Korea, Republic of'
}, {
	name: 'Kuwait'
}, {
	name: 'Kyrgyzstan'
}, {
	name: 'Lao People\'s Democratic Republic'
}, {
	name: 'Latvia'
}, {
	name: 'Lebanon'
}, {
	name: 'Lesotho'
}, {
	name: 'Liberia'
}, {
	name: 'Libyan Arab Jamahiriya'
}, {
	name: 'Liechtenstein'
}, {
	name: 'Lithuania'
}, {
	name: 'Luxembourg'
}, {
	name: 'Macao'
}, {
	name: 'Macedonia, the Former Yugoslav Republic Of'
}, {
	name: 'Madagascar'
}, {
	name: 'Malawi'
}, {
	name: 'Malaysia'
}, {
	name: 'Maldives'
}, {
	name: 'Mali'
}, {
	name: 'Malta'
}, {
	name: 'Marshall Islands'
}, {
	name: 'Martinique'
}, {
	name: 'Mauritania'
}, {
	name: 'Mauritius'
}, {
	name: 'Mayotte'
}, {
	name: 'Mexico'
}, {
	name: 'Micronesia, Federated States Of'
}, {
	name: 'Moldova, Republic of'
}, {
	name: 'Monaco'
}, {
	name: 'Mongolia'
}, {
	name: 'Montenegro'
}, {
	name: 'Montserrat'
}, {
	name: 'Morocco'
}, {
	name: 'Mozambique'
}, {
	name: 'Myanmar'
}, {
	name: 'Namibia'
}, {
	name: 'Nauru'
}, {
	name: 'Nepal'
}, {
	name: 'Netherlands Antilles'
}, {
	name: 'Netherlands'
}, {
	name: 'New Caledonia'
}, {
	name: 'New Zealand'
}, {
	name: 'Nicaragua'
}, {
	name: 'Niger'
}, {
	name: 'Nigeria'
}, {
	name: 'Niue'
}, {
	name: 'Norfolk Island'
}, {
	name: 'Northern Mariana Islands'
}, {
	name: 'Norway'
}, {
	name: 'Oman'
}, {
	name: 'Pakistan'
}, {
	name: 'Palau'
}, {
	name: 'Palestinian Territory, Occupied'
}, {
	name: 'Panama'
}, {
	name: 'Papua New Guinea'
}, {
	name: 'Paraguay'
}, {
	name: 'Peru'
}, {
	name: 'Philippines'
}, {
	name: 'Pitcairn'
}, {
	name: 'Poland'
}, {
	name: 'Portugal'
}, {
	name: 'Puerto Rico'
}, {
	name: 'Qatar'
}, {
	name: 'Romania'
}, {
	name: 'Russian Federation'
}, {
	name: 'Rwanda'
}, {
	name: 'Réunion'
}, {
	name: 'Saint Barthélemy'
}, {
	name: 'Saint Helena'
}, {
	name: 'Saint Kitts And Nevis'
}, {
	name: 'Saint Lucia'
}, {
	name: 'Saint Martin'
}, {
	name: 'Saint Pierre And Miquelon'
}, {
	name: 'Saint Vincent And The Grenedines'
}, {
	name: 'Samoa'
}, {
	name: 'San Marino'
}, {
	name: 'Sao Tome and Principe'
}, {
	name: 'Saudi Arabia'
}, {
	name: 'Senegal'
}, {
	name: 'Serbia'
}, {
	name: 'Seychelles'
}, {
	name: 'Sierra Leone'
}, {
	name: 'Singapore'
}, {
	name: 'Slovakia'
}, {
	name: 'Slovenia'
}, {
	name: 'Solomon Islands'
}, {
	name: 'Somalia'
}, {
	name: 'South Africa'
}, {
	name: 'South Georgia and the South Sandwich Islands'
}, {
	name: 'Spain'
}, {
	name: 'Sri Lanka'
}, {
	name: 'Sudan'
}, {
	name: 'Suriname'
}, {
	name: 'Svalbard And Jan Mayen'
}, {
	name: 'Swaziland'
}, {
	name: 'Sweden'
}, {
	name: 'Switzerland'
}, {
	name: 'Syrian Arab Republic'
}, {
	name: 'Taiwan, Province Of China'
}, {
	name: 'Tajikistan'
}, {
	name: 'Tanzania, United Republic of'
}, {
	name: 'Thailand'
}, {
	name: 'Timor-Leste'
}, {
	name: 'Togo'
}, {
	name: 'Tokelau'
}, {
	name: 'Tonga'
}, {
	name: 'Trinidad and Tobago'
}, {
	name: 'Tunisia'
}, {
	name: 'Turkey'
}, {
	name: 'Turkmenistan'
}, {
	name: 'Turks and Caicos Islands'
}, {
	name: 'Tuvalu'
}, {
	name: 'Uganda'
}, {
	name: 'Ukraine'
}, {
	name: 'United Arab Emirates'
}, {
	name: 'United Kingdom'
}, {
	name: 'United States Minor Outlying Islands'
}, {
	name: 'United States'
}, {
	name: 'Uruguay'
}, {
	name: 'Uzbekistan'
}, {
	name: 'Vanuatu'
}, {
	name: 'Venezuela, Bolivarian Republic of'
}, {
	name: 'Viet Nam'
}, {
	name: 'Virgin Islands, British'
}, {
	name: 'Virgin Islands, U.S.'
}, {
	name: 'Wallis and Futuna'
}, {
	name: 'Western Sahara'
}, {
	name: 'Yemen'
}, {
	name: 'Zambia'
}, {
	name: 'Zimbabwe'
}, function(err) {
	if (err) return res.send(500);
	res.send(200);
});<commit_msg>remove countries<commit_after><|endoftext|>


<commit_before>/**
 * @file API the ProjectAjaxController
 */
import axios from "axios";
import { setBaseUrl } from "../../utilities/url-utilities";

const URL = setBaseUrl(`ajax/projects`);

/**
 * Returns the projects on the current page of the projects table.
 * @param {Object} params
 * @returns {Promise<{}|T>}
 */
export async function getPagedProjectsForUser(params) {
  try {
    const { data } = await axios.post(
      `${URL}?admin=${window.location.href.includes("all")}
  `,
      params
    );
    return data;
  } catch (e) {
    return {};
  }
}

/**
 * Get a list of available project roles
 * @returns {Promise<AxiosResponse<any>>}
 */
export async function getProjectRoles() {
  return await axios.get(`${URL}/roles`).then(({ data }) => data);
}

/**
 * Get project info (name, permissions)
 * @param {number} projectId - identifier for a project
 * @returns {Promise<AxiosResponse<any>>}
 */
export async function getProjectInfo(projectId) {
  return axios.get(`${URL}/${projectId}/info`).then(({ data }) => data);
}
<commit_msg>Removed unused function<commit_after>/**
 * @file API the ProjectAjaxController
 */
import axios from "axios";
import { setBaseUrl } from "../../utilities/url-utilities";

const URL = setBaseUrl(`ajax/projects`);

/**
 * Returns the projects on the current page of the projects table.
 * @param {Object} params
 * @returns {Promise<{}|T>}
 */
export async function getPagedProjectsForUser(params) {
  try {
    const { data } = await axios.post(
      `${URL}?admin=${window.location.href.includes("all")}
  `,
      params
    );
    return data;
  } catch (e) {
    return {};
  }
}

/**
 * Get a list of available project roles
 * @returns {Promise<AxiosResponse<any>>}
 */
export async function getProjectRoles() {
  return await axios.get(`${URL}/roles`).then(({ data }) => data);
}
<|endoftext|>


<commit_before>var Path = nodeRequire('path');
var $ = require('jquery');
var _ = require('underscore');
var Files = require('./files');

var menubar = new gui.Menu({ type: 'menubar' });
menubar.createMacBuiltin("p5");
var fileMenu = new gui.Menu();
var help = new gui.Menu();
//var edit = new gui.Menu();
var view = new gui.Menu();
var win = gui.Window.get();
var recentFilesMenu = new gui.Menu();
var exampleCategoryMenu = new gui.Menu();
var openRecent, examples;
var fs = nodeRequire('fs');

/* setup the menubar menus, submenus, functions and shortcuts. Conceptually the
 * menubar is an array of Menus, each of which is an array of MenuItems.
 * Menuitems may themselves be a submenu
 */
module.exports.setup = function(app) {
  fileMenu.append(new gui.MenuItem({ label: 'New Project',
    modifiers: 'shift-cmd', key: 'n', click: function(){
      app.newWindow(app.windowURL);
  }}));

  fileMenu.append(new gui.MenuItem({ label: 'New File',
    modifiers: 'cmd', key: 'n', click: function(){
      app.newFile();
  }}));

  fileMenu.append(new gui.MenuItem({ label: 'New Folder',
    click: function(){
      app.newFolder();
  }}));

  fileMenu.append(new gui.MenuItem({ label: 'Open',
    modifiers: 'cmd', key: 'o', click: function(){
      $('#openFile').trigger('click');
  }}));

  openRecent = new gui.MenuItem({label: 'Open Recent'});
  openRecent.submenu = recentFilesMenu;
  fileMenu.append(openRecent);

  fileMenu.append(new gui.MenuItem({ label: 'Close',
    modifiers: 'cmd', key: 'w', click: function(){
      app.closeProject();
  }}));

  fileMenu.append(new gui.MenuItem({ label: 'Save',
    modifiers: 'cmd', key: 's', click: function(){
      app.saveFile();
  }}));

  fileMenu.append(new gui.MenuItem({ label: 'Save File As...',
    modifiers: 'shift-cmd', key: 's', click: function(){
      app.saveFileAs(app.currentFile.path);
  }}));

  fileMenu.append(new gui.MenuItem({ label: 'Save Project As...',
    modifiers: 'alt-shift-cmd', key: 's', click: function(){
      $('#saveProject').trigger('click');
  }}));

  // add menu option for loading example sketches
  examples = new gui.MenuItem({label: 'Examples'});
  // create submenu
  var exampleDir = 'mode_assets/p5/examples';
  // get latest example categories
  var files = fs.readdirSync(exampleDir);

  files.forEach(function(category) {
    var sketchMenu = new gui.Menu();
    var categoryLabel = new gui.MenuItem({label: category});
    // populate submenu with sketches for that category
    var categoryDir = Path.join(exampleDir, category);
    if (fs.lstatSync(categoryDir).isDirectory()) {
      var sketches = fs.readdirSync(categoryDir);
      sketches.forEach(function(fileName) {
        sketchMenu.append(new gui.MenuItem({label: Files.cleanExampleName(fileName), click: function(){
          app.modeFunction('launchExample', exampleDir.concat('/').concat(category).concat('/').concat(fileName));
        }}));
      });
      categoryLabel.submenu = sketchMenu;
      exampleCategoryMenu.append(categoryLabel);
    }
  });

  examples.submenu = exampleCategoryMenu;
  fileMenu.append(examples);

  fileMenu.append(new gui.MenuItem({ type: 'separator' }));

  //fileMenu.append(new gui.MenuItem({ label: 'Export \t\t\t\u2318E', click: function(){
    //app.export();
  //}}));

  fileMenu.append(new gui.MenuItem({ label: 'Run',
    modifiers: 'cmd', key: 'r', click: function(){
      app.run();
  }}));

  help.append(new gui.MenuItem({ label: 'Reference', click: function(){
    app.showHelp();
  }}));

  view.append(new gui.MenuItem({ label: 'Reformat',
      modifiers: 'cmd', key: 't', click: function(){
        app.$.editor.reformat();
  }}));

  view.append(new gui.MenuItem({ type: 'separator' }));

  view.append(new gui.MenuItem({ label: 'Toggle Settings Panel',
    modifiers: 'cmd', key: ',', click: function(){
      app.toggleSettingsPane();
  }}))

  view.append(new gui.MenuItem({ label: 'Toggle Sidebar',
    modifiers: 'cmd', key: '.', click: function(){
      app.toggleSidebar();
  }}))

  view.append(new gui.MenuItem({ type: 'separator' }));

  view.append(new gui.MenuItem({ label: 'Increase Font Size',
    modifiers: 'cmd', key: '=', click: function(){
      app.changeFontSize(1);
  }}))

  view.append(new gui.MenuItem({ label: 'Decrease Font Size',
    modifiers: 'cmd', key: '-', click: function(){
      app.changeFontSize(-1);
  }}))

  menubar.insert(new gui.MenuItem({ label: 'File', submenu: fileMenu}),1);
  menubar.insert(new gui.MenuItem({ label: 'View', submenu: view}), 3);
  menubar.append(new gui.MenuItem({ label: 'Help', submenu: help}));

  /* The Edit Menu exists by default, so we obtain the reference to it here and
   * add tot he pre-existing menu
   */

  // get the existing edit menu
  var edit = menubar.items[2].submenu;

  // the native undo isn't allowing us to bind a click event on OS X,
  // current (hacky) solution is to remove the existing one and add a new one
  edit.remove(edit.items[0]);

  // create the new undo menu item
  var undo = new gui.MenuItem({
      label: 'Undo',
      key: "z"
  });

  // add event listener
  undo.on('click', function() {
    // execute ace editor undo command
    app.$.editor.ace.execCommand("undo");
  });

  // insert the new undo at the beginning
  edit.insert(undo, 0);

  edit.append(new gui.MenuItem({ type: 'separator' }));

  // Find and Find and Replace are different because the ace/brace editor has
  // native shortcuts for these commands. These two MenuItems only react
  // to being clicked on, so the shortcuts work without interference.
  var findItem = new gui.MenuItem(
      { label: 'Find', modifiers: 'cmd', key: 'f', click: function(){
      }});

  findItem.on('click', function(){
    console.log('find');
    app.$.editor.ace.execCommand("find");
  });

  edit.append(findItem);

  var repItem = new gui.MenuItem(
    { label: 'Find and Replace',
      modifiers: 'cmd-alt', key: 'f', click: function(){
    }});

  repItem.on('click', function(e){
    app.$.editor.ace.execCommand("replace");
  });

  edit.append(repItem);

  win.menu = menubar;

};

//reset the menubar to the current window's frame of reference. Used whenever
//the user switches focus between windows
module.exports.resetMenu = function() {
  win.menu = menubar;
};

module.exports.updateRecentFiles = function(app, path) {
  var recentFiles = JSON.parse(localStorage.recentFiles || '[]');

  if (typeof path !== 'undefined' && !app.temp) {
    recentFiles.unshift(path);
  }

  recentFiles = _.unique(recentFiles);

  if (recentFiles.length > 10) recentFiles.pop();

  localStorage.recentFiles = JSON.stringify(recentFiles);

  // clear the recentFilesMenu because we're going to repopulate it
  recentFilesMenu = new gui.Menu();
  openRecent.submenu = recentFilesMenu;

  // iterate through the recentFiles and append to the openRecent submenu
  recentFiles.forEach(function(p) {
    var m = new gui.MenuItem({ label: Path.basename(p), click: function() {
      app.openProject(p);
    }});
    recentFilesMenu.append(m);
  });
  if (recentFiles.length > 0) {
    recentFilesMenu.append(new gui.MenuItem({type: 'separator'}));
    recentFilesMenu.append(new gui.MenuItem({label: 'Clear Recent Projects', click: function(){
      localStorage.recentFiles = [];
      module.exports.updateRecentFiles(app);
    }}));
  }

  openRecent.enabled = (recentFiles.length !== 0);
};
<commit_msg>adds "show sketch folder" menu. closes #108<commit_after>var Path = nodeRequire('path');
var $ = require('jquery');
var _ = require('underscore');
var Files = require('./files');

var menubar = new gui.Menu({ type: 'menubar' });
menubar.createMacBuiltin("p5");
var fileMenu = new gui.Menu();
var help = new gui.Menu();
//var edit = new gui.Menu();
var view = new gui.Menu();
var win = gui.Window.get();
var recentFilesMenu = new gui.Menu();
var exampleCategoryMenu = new gui.Menu();
var openRecent, examples;
var fs = nodeRequire('fs');

/* setup the menubar menus, submenus, functions and shortcuts. Conceptually the
 * menubar is an array of Menus, each of which is an array of MenuItems.
 * Menuitems may themselves be a submenu
 */
module.exports.setup = function(app) {
  fileMenu.append(new gui.MenuItem({ label: 'New Project',
    modifiers: 'shift-cmd', key: 'n', click: function(){
      app.newWindow(app.windowURL);
  }}));

  fileMenu.append(new gui.MenuItem({ label: 'New File',
    modifiers: 'cmd', key: 'n', click: function(){
      app.newFile();
  }}));

  fileMenu.append(new gui.MenuItem({ label: 'New Folder',
    click: function(){
      app.newFolder();
  }}));

  fileMenu.append(new gui.MenuItem({ label: 'Open',
    modifiers: 'cmd', key: 'o', click: function(){
      $('#openFile').trigger('click');
  }}));

  openRecent = new gui.MenuItem({label: 'Open Recent'});
  openRecent.submenu = recentFilesMenu;
  fileMenu.append(openRecent);

  fileMenu.append(new gui.MenuItem({ label: 'Close',
    modifiers: 'cmd', key: 'w', click: function(){
      app.closeProject();
  }}));

  fileMenu.append(new gui.MenuItem({ label: 'Save',
    modifiers: 'cmd', key: 's', click: function(){
      app.saveFile();
  }}));

  fileMenu.append(new gui.MenuItem({ label: 'Save File As...',
    modifiers: 'shift-cmd', key: 's', click: function(){
      app.saveFileAs(app.currentFile.path);
  }}));

  fileMenu.append(new gui.MenuItem({ label: 'Save Project As...',
    modifiers: 'alt-shift-cmd', key: 's', click: function(){
      $('#saveProject').trigger('click');
  }}));

  // add menu option for loading example sketches
  examples = new gui.MenuItem({label: 'Examples'});
  // create submenu
  var exampleDir = 'mode_assets/p5/examples';
  // get latest example categories
  var files = fs.readdirSync(exampleDir);

  files.forEach(function(category) {
    var sketchMenu = new gui.Menu();
    var categoryLabel = new gui.MenuItem({label: category});
    // populate submenu with sketches for that category
    var categoryDir = Path.join(exampleDir, category);
    if (fs.lstatSync(categoryDir).isDirectory()) {
      var sketches = fs.readdirSync(categoryDir);
      sketches.forEach(function(fileName) {
        sketchMenu.append(new gui.MenuItem({label: Files.cleanExampleName(fileName), click: function(){
          app.modeFunction('launchExample', exampleDir.concat('/').concat(category).concat('/').concat(fileName));
        }}));
      });
      categoryLabel.submenu = sketchMenu;
      exampleCategoryMenu.append(categoryLabel);
    }
  });

  examples.submenu = exampleCategoryMenu;
  fileMenu.append(examples);

  fileMenu.append(new gui.MenuItem({ type: 'separator' }));

  //fileMenu.append(new gui.MenuItem({ label: 'Export \t\t\t\u2318E', click: function(){
    //app.export();
  //}}));

  fileMenu.append(new gui.MenuItem({ label: 'Run',
    modifiers: 'cmd', key: 'r', click: function(){
      app.run();
  }}));

  help.append(new gui.MenuItem({ label: 'Reference', click: function(){
    app.showHelp();
  }}));

  view.append(new gui.MenuItem({ label: 'Show Sketch Folder',
      modifiers: 'cmd', key: 'k', click: function(){
        gui.Shell.showItemInFolder(app.projectPath);
  }}));

  view.append(new gui.MenuItem({ type: 'separator' }));

  view.append(new gui.MenuItem({ label: 'Reformat',
      modifiers: 'cmd', key: 't', click: function(){
        app.$.editor.reformat();
  }}));

  view.append(new gui.MenuItem({ type: 'separator' }));

  view.append(new gui.MenuItem({ label: 'Toggle Settings Panel',
    modifiers: 'cmd', key: ',', click: function(){
      app.toggleSettingsPane();
  }}))

  view.append(new gui.MenuItem({ label: 'Toggle Sidebar',
    modifiers: 'cmd', key: '.', click: function(){
      app.toggleSidebar();
  }}))

  view.append(new gui.MenuItem({ type: 'separator' }));

  view.append(new gui.MenuItem({ label: 'Increase Font Size',
    modifiers: 'cmd', key: '=', click: function(){
      app.changeFontSize(1);
  }}))

  view.append(new gui.MenuItem({ label: 'Decrease Font Size',
    modifiers: 'cmd', key: '-', click: function(){
      app.changeFontSize(-1);
  }}))

  menubar.insert(new gui.MenuItem({ label: 'File', submenu: fileMenu}),1);
  menubar.insert(new gui.MenuItem({ label: 'View', submenu: view}), 3);
  menubar.append(new gui.MenuItem({ label: 'Help', submenu: help}));

  /* The Edit Menu exists by default, so we obtain the reference to it here and
   * add tot he pre-existing menu
   */

  // get the existing edit menu
  var edit = menubar.items[2].submenu;

  // the native undo isn't allowing us to bind a click event on OS X,
  // current (hacky) solution is to remove the existing one and add a new one
  edit.remove(edit.items[0]);

  // create the new undo menu item
  var undo = new gui.MenuItem({
      label: 'Undo',
      key: "z"
  });

  // add event listener
  undo.on('click', function() {
    // execute ace editor undo command
    app.$.editor.ace.execCommand("undo");
  });

  // insert the new undo at the beginning
  edit.insert(undo, 0);

  edit.append(new gui.MenuItem({ type: 'separator' }));

  // Find and Find and Replace are different because the ace/brace editor has
  // native shortcuts for these commands. These two MenuItems only react
  // to being clicked on, so the shortcuts work without interference.
  var findItem = new gui.MenuItem(
      { label: 'Find', modifiers: 'cmd', key: 'f', click: function(){
      }});

  findItem.on('click', function(){
    console.log('find');
    app.$.editor.ace.execCommand("find");
  });

  edit.append(findItem);

  var repItem = new gui.MenuItem(
    { label: 'Find and Replace',
      modifiers: 'cmd-alt', key: 'f', click: function(){
    }});

  repItem.on('click', function(e){
    app.$.editor.ace.execCommand("replace");
  });

  edit.append(repItem);

  win.menu = menubar;

};

//reset the menubar to the current window's frame of reference. Used whenever
//the user switches focus between windows
module.exports.resetMenu = function() {
  win.menu = menubar;
};

module.exports.updateRecentFiles = function(app, path) {
  var recentFiles = JSON.parse(localStorage.recentFiles || '[]');

  if (typeof path !== 'undefined' && !app.temp) {
    recentFiles.unshift(path);
  }

  recentFiles = _.unique(recentFiles);

  if (recentFiles.length > 10) recentFiles.pop();

  localStorage.recentFiles = JSON.stringify(recentFiles);

  // clear the recentFilesMenu because we're going to repopulate it
  recentFilesMenu = new gui.Menu();
  openRecent.submenu = recentFilesMenu;

  // iterate through the recentFiles and append to the openRecent submenu
  recentFiles.forEach(function(p) {
    var m = new gui.MenuItem({ label: Path.basename(p), click: function() {
      app.openProject(p);
    }});
    recentFilesMenu.append(m);
  });
  if (recentFiles.length > 0) {
    recentFilesMenu.append(new gui.MenuItem({type: 'separator'}));
    recentFilesMenu.append(new gui.MenuItem({label: 'Clear Recent Projects', click: function(){
      localStorage.recentFiles = [];
      module.exports.updateRecentFiles(app);
    }}));
  }

  openRecent.enabled = (recentFiles.length !== 0);
};
<|endoftext|>


<commit_before>const INITIAL_STATE = {
  title: "",
  server: "https://leplatrem-happiness.herokuapp.com/v1",
  bucket: "happiness"
};

export default function homepage(state=INITIAL_STATE, action) {
  return state;
}
<commit_msg>Switch to notmyidea<commit_after>const INITIAL_STATE = {
  title: "",
  server: "https://kinto.notmyidea.org/v1",
  bucket: "happiness"
};

export default function homepage(state=INITIAL_STATE, action) {
  return state;
}
<|endoftext|>


<commit_before>import Backbone from 'backbone';
import Marionette from 'backbone.marionette';

import {UserModel} from './base/models/auth';

const Nav = Marionette.View.extend({
  className: 'container-fluid',
  template: require('./templates/nav.html'),

  ui: {
    root: '.root',
    exercise: '.exercise',
    workout: '.workout'
  },

  events: {
    'click @ui.root': 'showRoot',
    'click @ui.exercise': 'showExercise',
    'click @ui.workout': 'showWorkout'
  },

  modelEvents: {
    sync: 'render',
    'change:token': 'render'
  },

  initialize: function() {
    this.model.fetch();
  },

  onRender: function() {
    if (this.model.isLoggedIn()) {
      this.ui.exercise.removeClass('hidden');
      this.ui.workout.removeClass('hidden');
    }
    else {
      this.ui.exercise.addClass('hidden');
      this.ui.workout.addClass('hidden');
    }
  },

  showRoot: function() {
    this._navigate('');
  },

  showExercise: function(e) {
    e.preventDefault();
    this._navigate('exercise/');
  },

  showWorkout: function(e) {
    e.preventDefault();
    this._navigate('workout/');
  },

  _navigate: function(url) {
    Backbone.history.navigate(url, {trigger: true});
  }
});

const Layout = Marionette.View.extend({
  template: require('./templates/base.html'),

  regions: {
    main: '#main',
    nav: '#nav'
  },

  onRender: function() {
    this.showChildView('nav', new Nav({
      model: new UserModel()
    }));
  }
});

export default new Layout();
<commit_msg>Made the setup a bit better 46<commit_after>import Backbone from 'backbone';
import Marionette from 'backbone.marionette';

import {UserModel} from './base/models/auth';

const Nav = Marionette.View.extend({
  className: 'container-fluid',
  template: require('./templates/nav.html'),

  ui: {
    root: '.root',
    exercise: '.exercise',
    workout: '.workout'
  },

  events: {
    'click @ui.root': 'showRoot',
    'click @ui.exercise': 'showExercise',
    'click @ui.workout': 'showWorkout'
  },

  modelEvents: {
    sync: 'render',
    'change:token': 'render'
  },

  onRender: function() {
    if (this.model.isLoggedIn()) {
      this.ui.exercise.removeClass('hidden');
      this.ui.workout.removeClass('hidden');
    }
    else {
      this.ui.exercise.addClass('hidden');
      this.ui.workout.addClass('hidden');
    }
  },

  showRoot: function() {
    this._navigate('');
  },

  showExercise: function(e) {
    e.preventDefault();
    this._navigate('exercise/');
  },

  showWorkout: function(e) {
    e.preventDefault();
    this._navigate('workout/');
  },

  _navigate: function(url) {
    Backbone.history.navigate(url, {trigger: true});
  }
});

const Layout = Marionette.View.extend({
  template: require('./templates/base.html'),

  regions: {
    main: '#main',
    nav: '#nav'
  },

  initialize: function() {
    this.model = new UserModel();
    this.model.fetch();
  },

  onRender: function() {
    this.showChildView('nav', new Nav({
      model: this.model
    }));
  }
});

export default new Layout();
<|endoftext|>


<commit_before>define('app/views/metric_node', ['app/views/templated'],
    //
    //  Metric Node View
    //
    //  @returns Class
    //
    function (TemplatedView) {

        'use strict';

        return TemplatedView.extend({

            //
            //
            //  Properties
            //
            //

            node: null,
            metric: null,
            unfold: false,
            element: null,

            //
            //
            //  Initialization
            //
            //

            load: function () {

                this.set('element', $('#'+this.elementId));
                this.indentNode();

                if (this.node.isRootNode)
                    this.unfoldChildren();

                if (this.node.isEndNode)
                    this.set('metric',
                        Mist.metricAddController.getMetric(
                            this.node.target));

            }.on('didInsertElement'),

            //
            //
            //  Methods
            //
            //

            indentNode: function () {
                // Loop starts from 1 because 0 nested items
                // should not be indented
                for (var i = 1; i < this.node.nestIndex; i++)
                    $('

').insertBefore(this.element);
            },

            foldChildren: function () {

                this.set('unfold', false);

                // Change icons
                var a = this.element.find('> a.parent-node').eq(0);
                a.removeClass('ui-icon-minus');
                a.addClass('ui-icon-carat-d');

                this.element.find('.nest').eq(0).slideUp();
            },

            foldSiblings: function () {
                var siblings = this.element.siblings().filter('.ember-view');
                siblings.toArray().forEach(function (sibling) {
                    Ember.View.views[sibling.id].foldChildren();
                });
            },

            preCenterNode: function () {
                this.set('prevOffsetTop', this.element.offset().top);
                this.set('prevWinScrollTop', $(window).scrollTop());
            },

            centerNode: function () {

                var afterOffsetTop = this.element.offset().top;
                var afterWinScrollTop = $(window).scrollTop();

                var prevTop = this.prevOffsetTop - this.prevWinScrollTop;
                var afterTop = afterOffsetTop - afterWinScrollTop;
                if (afterOffsetTop < afterWinScrollTop) {
                    var scrollTo = prevTop - afterTop;
                    Mist.smoothScroll($(window).scrollTop() - scrollTo);
                }
            },

            unfoldChildren: function () {

                this.preCenterNode();

                this.set('unfold', true);

                // Change icons
                var a = this.element.find('> a.parent-node').eq(0);
                a.removeClass('ui-icon-carat-d');
                a.addClass('ui-icon-minus');

                this.foldSiblings();
                var that = this;
                Ember.run.next(function () {
                    that.element.find('.nest').eq(0).slideDown(400, function () {
                        that.centerNode();
                    });
                });
            },

            //
            //
            //  Actions
            //
            //

            actions: {

                toggleUnfold: function () {
                    if (this.unfold)
                        this.foldChildren();
                    else
                        this.unfoldChildren();
                },

                selectMetric: function () {
                    var that = this;
                    Mist.metricAddController.set('newMetric', this.metric);
                    Mist.metricAddController.add();
                },
            }
        });
    }
);
<commit_msg>Try to fix centering error<commit_after>define('app/views/metric_node', ['app/views/templated'],
    //
    //  Metric Node View
    //
    //  @returns Class
    //
    function (TemplatedView) {

        'use strict';

        return TemplatedView.extend({

            //
            //
            //  Properties
            //
            //

            node: null,
            metric: null,
            unfold: false,
            element: null,

            //
            //
            //  Initialization
            //
            //

            load: function () {

                this.set('element', $('#'+this.elementId));
                this.indentNode();

                if (this.node.isRootNode)
                    this.unfoldChildren();

                if (this.node.isEndNode)
                    this.set('metric',
                        Mist.metricAddController.getMetric(
                            this.node.target));

            }.on('didInsertElement'),

            //
            //
            //  Methods
            //
            //

            indentNode: function () {
                // Loop starts from 1 because 0 nested items
                // should not be indented
                for (var i = 1; i < this.node.nestIndex; i++)
                    $('

').insertBefore(this.element);
            },

            foldChildren: function () {

                this.set('unfold', false);

                // Change icons
                var a = this.element.find('> a.parent-node').eq(0);
                a.removeClass('ui-icon-minus');
                a.addClass('ui-icon-carat-d');

                this.element.find('.nest').eq(0).slideUp();
            },

            foldSiblings: function () {
                var siblings = this.element.siblings().filter('.ember-view');
                siblings.toArray().forEach(function (sibling) {
                    Ember.View.views[sibling.id].foldChildren();
                });
            },

            preCenterNode: function () {
                this.set('prevOffsetTop', this.element.offset().top);
                this.set('prevWinScrollTop', $(window).scrollTop());
            },

            centerNode: function () {

                if (!this.element) return;
                var afterOffsetTop = this.element.offset().top;
                var afterWinScrollTop = $(window).scrollTop();

                var prevTop = this.prevOffsetTop - this.prevWinScrollTop;
                var afterTop = afterOffsetTop - afterWinScrollTop;
                if (afterOffsetTop < afterWinScrollTop) {
                    var scrollTo = prevTop - afterTop;
                    Mist.smoothScroll($(window).scrollTop() - scrollTo);
                }
            },

            unfoldChildren: function () {

                this.preCenterNode();

                this.set('unfold', true);

                // Change icons
                var a = this.element.find('> a.parent-node').eq(0);
                a.removeClass('ui-icon-carat-d');
                a.addClass('ui-icon-minus');

                this.foldSiblings();
                var that = this;
                Ember.run.next(function () {
                    that.element.find('.nest').eq(0).slideDown(400, function () {
                        that.centerNode();
                    });
                });
            },

            //
            //
            //  Actions
            //
            //

            actions: {

                toggleUnfold: function () {
                    if (this.unfold)
                        this.foldChildren();
                    else
                        this.unfoldChildren();
                },

                selectMetric: function () {
                    var that = this;
                    Mist.metricAddController.set('newMetric', this.metric);
                    Mist.metricAddController.add();
                },
            }
        });
    }
);
<|endoftext|>


<commit_before>/**
 * Copyright 2016 Google Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

 function prefetchArticles() {
	clients.matchAll({includeUncontrolled: true, type: 'window'}).then(function(clients){
		for (var i = 0; i < clients.length; i++) {
			var anchorLocation = clients[i].url.indexOf('#');
			var anchorName = clients[i].url.slice(anchorLocation + 1);
			if (anchorLocation != -1) {
				fetch('https://www.reddit.com/r/' + anchorName + '.json')
					.then(function(response) {
						return response.json();
					}).then(function(json) {
						json.data.children.forEach(function(child) {
							if (child.data.domain == ('self.' + anchorName)) {
								var jsonUrl = child.data.url.slice(0, -1) + '.json';
								var req = new Request(jsonUrl, {mode: 'cors'});
								caches.open('articles').then(function(aCache) {
									aCache.add(req);
								})
							}
						})
					})
			}
		}
	}).catch(function(err){
		console.log("Didn't work. Here's what happened: " + err);
	})
 }

 self.addEventListener('sync', function(event) {
 	//console.log("event: " + event);
 	if (event.tag == 'articles') {
		//console.log("Inside wait.");
		prefetchArticles();
 	}
 });

<commit_msg>Change function name.<commit_after>/**
 * Copyright 2016 Google Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

 function fetchArticles() {
	clients.matchAll({includeUncontrolled: true, type: 'window'}).then(function(clients){
		for (var i = 0; i < clients.length; i++) {
			var anchorLocation = clients[i].url.indexOf('#');
			var anchorName = clients[i].url.slice(anchorLocation + 1);
			if (anchorLocation != -1) {
				fetch('https://www.reddit.com/r/' + anchorName + '.json')
					.then(function(response) {
						return response.json();
					}).then(function(json) {
						json.data.children.forEach(function(child) {
							if (child.data.domain == ('self.' + anchorName)) {
								var jsonUrl = child.data.url.slice(0, -1) + '.json';
								var req = new Request(jsonUrl, {mode: 'cors'});
								caches.open('articles').then(function(aCache) {
									aCache.add(req);
								})
							}
						})
					})
			}
		}
	}).catch(function(err) {
		console.log("Didn't work. Here's what happened: " + err);
	})
 }

 self.addEventListener('sync', function(event) {
 	if (event.tag == 'articles') {
		fetchArticles();
 	}
 });

<|endoftext|>


<commit_before>// @flow
import {TinderAPI} from './TinderAPI'
import Promise from 'bluebird'

export default function authorizeFactory(instance: TinderAPI) {
    return function authorize({fbToken, fbId}: {fbToken: string, fbId: string}) {
        return Promise.fromCallback(callback => instance.client.authorize(fbToken, fbId, callback));
    }
}<commit_msg>Moved arguments to a separate type<commit_after>// @flow
import {TinderAPI} from './TinderAPI'
import Promise from 'bluebird'

type Arguments = {
    fbToken: string,
    fbId: string
}

export default function authorizeFactory(instance: TinderAPI) {
    return function authorize({fbToken, fbId}: Arguments) {
        return Promise.fromCallback(callback => instance.client.authorize(fbToken, fbId, callback));
    }
}<|endoftext|>


<commit_before>export function getProjectCost (project) {
  return project.cost.capital + project.cost.operating * ATF_CONFIG.budget.years
}

export function formatCost (cost) {
  if(cost < 1000000000) {
    return '$' + Math.round(cost/1000000) + 'M'
  }
  return '$' + Math.round(cost/100000000)/10 + 'B'

}
<commit_msg>Update costing formula<commit_after>import haversine from 'haversine'

export function getProjectCost (project) {
  if(project.cost && (project.cost.capital || project.cost.operating)) {
    return project.cost.capital + project.cost.operating * ATF_CONFIG.budget.years
  }
  switch(project.category) {
    case 'lrt':
    case 'rail':
    case 'rapid_bus':
      const dist = getProjectLength(project.geojson.geometry.coordinates)
      const modeCosts = ATF_CONFIG.budget[project.category]
      const cap = dist * modeCosts.capital_cost_per_mile * modeCosts.local_capital_share
      const ops = dist * modeCosts.operating_cost_per_mile * ATF_CONFIG.budget.years * modeCosts.local_operating_share
      return cap + ops
  }

  return 0
}

export function formatCost (cost) {
  if(cost < 1000000000) {
    return '$' + Math.round(cost/1000000) + 'M'
  }
  return '$' + Math.round(cost/100000000)/10 + 'B'

}

function getProjectLength (coords) {
  let dist = 0
  for(let i = 0; i < coords.length - 1; i++) {
    const start = {
      longitude: coords[i][0],
      latitude: coords[i][1]
    }
    const end = {
      longitude: coords[i+1][0],
      latitude: coords[i+1][1]
    }
    dist += haversine(start, end, {unit: 'mi'})
  }
  return dist
}
<|endoftext|>


<commit_before>// IE likes to cache too much :P
$.ajaxSetup({cache: false});

// Get PHP info
var token = $("#token").html();
var listType = $("#list-type").html();
var fullName = listType === "white" ? "Whitelist" : "Blacklist";

function sub(index, entry) {
    var domain = $("#"+index);
    domain.hide("highlight");
    $.ajax({
        url: "scripts/pi-hole/php/sub.php",
        method: "post",
        data: {"domain":entry, "list":listType, "token":token},
        success: function(response) {
            if(response.length !== 0){
                return;
            }
            domain.remove();
        },
        error: function(jqXHR, exception) {
            alert("Failed to remove the domain!");
        }
    });
}

function refresh(fade) {
    var list = $("#list");
    if(fade) {
        list.fadeOut(100);
    }
    $.ajax({
        url: "scripts/pi-hole/php/get.php",
        method: "get",
        data: {"list":listType},
        success: function(response) {
            list.html("");
            var data = JSON.parse(response);

            if(data.length === 0) {
                list.html("
Your " + fullName + " is empty!
");
            }
            else {
                data.forEach(function (entry, index) {
                    list.append(
                        "
" + entry +
                        "<button class=\"btn btn-danger btn-xs pull-right\" type=\"button\">" +
                        "</button>
"
                    );

                    // Handle button
                    $("#list #"+index+"").on("click", "button", function() {
                        sub(index, entry);
                    });
                });
            }
            list.fadeIn("fast");
        },
        error: function(jqXHR, exception) {
            $("#alFailure").show();
        }
    });
}

window.onload = refresh(false);

function add(domain) {
    if(domain.length === 0){
        return;
    }

    var alInfo = $("#alInfo");
    var alSuccess = $("#alSuccess");
    var alFailure = $("#alFailure");
    alInfo.show();
    alSuccess.hide();
    alFailure.hide();
    $.ajax({
        url: "scripts/pi-hole/php/add.php",
        method: "post",
        data: {"domain":domain, "list":listType, "token":token},
        success: function(response) {
          if (response.indexOf("not a valid argument") >= 0 ||
              response.indexOf("is not a valid domain") >= 0) {
            alFailure.show();
            alFailure.delay(1000).fadeOut(2000, function() {
                alFailure.hide();
            });
            alInfo.delay(1000).fadeOut(2000, function() {
                alInfo.hide();
            });
          } else {
            alSuccess.show();
            alSuccess.delay(1000).fadeOut(2000, function() {
                alSuccess.hide();
            });
            alInfo.delay(1000).fadeOut(2000, function() {
                alInfo.hide();
            });
            refresh(true);
          }
        },
        error: function(jqXHR, exception) {
            alFailure.show();
            alFailure.delay(1000).fadeOut(2000, function() {
                alFailure.hide();
            });
            alInfo.delay(1000).fadeOut(2000, function() {
                alInfo.hide();
            });
        }
    });
    $("#domain").val("");
}

function handleAdd() {
    $("#domain").val().split(/\s+/).forEach(function (domain) {
        add(domain);
    });
}

// Handle enter button for adding domains
$(document).keypress(function(e) {
    if(e.which === 13 && $("#domain").is(":focus")) {
        // Enter was pressed, and the input has focus
        handleAdd();
    }
});

// Handle buttons
$("#btnAdd").on("click", function() {
    handleAdd();
});
$("#btnRefresh").on("click", function() {
    refresh(true);
});

// Handle hiding of alerts
$(function(){
    $("[data-hide]").on("click", function(){
        $(this).closest("." + $(this).attr("data-hide")).hide();
    });
});
<commit_msg>Revert "Add multiple domains separated by whitespace"<commit_after>// IE likes to cache too much :P
$.ajaxSetup({cache: false});

// Get PHP info
var token = $("#token").html();
var listType = $("#list-type").html();
var fullName = listType === "white" ? "Whitelist" : "Blacklist";

function sub(index, entry) {
    var domain = $("#"+index);
    domain.hide("highlight");
    $.ajax({
        url: "scripts/pi-hole/php/sub.php",
        method: "post",
        data: {"domain":entry, "list":listType, "token":token},
        success: function(response) {
            if(response.length !== 0){
                return;
            }
            domain.remove();
        },
        error: function(jqXHR, exception) {
            alert("Failed to remove the domain!");
        }
    });
}

function refresh(fade) {
    var list = $("#list");
    if(fade) {
        list.fadeOut(100);
    }
    $.ajax({
        url: "scripts/pi-hole/php/get.php",
        method: "get",
        data: {"list":listType},
        success: function(response) {
            list.html("");
            var data = JSON.parse(response);

            if(data.length === 0) {
                list.html("
Your " + fullName + " is empty!
");
            }
            else {
                data.forEach(function (entry, index) {
                    list.append(
                        "
" + entry +
                        "<button class=\"btn btn-danger btn-xs pull-right\" type=\"button\">" +
                        "</button>
"
                    );

                    // Handle button
                    $("#list #"+index+"").on("click", "button", function() {
                        sub(index, entry);
                    });
                });
            }
            list.fadeIn("fast");
        },
        error: function(jqXHR, exception) {
            $("#alFailure").show();
        }
    });
}

window.onload = refresh(false);

function add() {
    var domain = $("#domain");
    if(domain.val().length === 0){
        return;
    }

    var alInfo = $("#alInfo");
    var alSuccess = $("#alSuccess");
    var alFailure = $("#alFailure");
    alInfo.show();
    alSuccess.hide();
    alFailure.hide();
    $.ajax({
        url: "scripts/pi-hole/php/add.php",
        method: "post",
        data: {"domain":domain.val(), "list":listType, "token":token},
        success: function(response) {
          if (response.indexOf("not a valid argument") >= 0 ||
              response.indexOf("is not a valid domain") >= 0) {
            alFailure.show();
            alFailure.delay(1000).fadeOut(2000, function() {
                alFailure.hide();
            });
            alInfo.delay(1000).fadeOut(2000, function() {
                alInfo.hide();
            });
          } else {
            alSuccess.show();
            alSuccess.delay(1000).fadeOut(2000, function() {
                alSuccess.hide();
            });
            alInfo.delay(1000).fadeOut(2000, function() {
                alInfo.hide();
            });
            domain.val("");
            refresh(true);
          }
        },
        error: function(jqXHR, exception) {
            alFailure.show();
            alFailure.delay(1000).fadeOut(2000, function() {
                alFailure.hide();
            });
            alInfo.delay(1000).fadeOut(2000, function() {
                alInfo.hide();
            });
        }
    });
}

// Handle enter button for adding domains
$(document).keypress(function(e) {
    if(e.which === 13 && $("#domain").is(":focus")) {
        // Enter was pressed, and the input has focus
        add();
    }
});

// Handle buttons
$("#btnAdd").on("click", function() {
    add();
});
$("#btnRefresh").on("click", function() {
    refresh(true);
});

// Handle hiding of alerts
$(function(){
    $("[data-hide]").on("click", function(){
        $(this).closest("." + $(this).attr("data-hide")).hide();
    });
});
<|endoftext|>


<commit_before>module.exports = function(gulp, config, plugins) {
    'use strict';

    var del = require('del');

    return function(callback) {
        del([config.output.base], callback);
    };
};<commit_msg>Updated clean task<commit_after>module.exports = function(gulp, config, plugins) {
    'use strict';

    var del = require('del');

    return function() {
        del([config.output.base]);
    };
};
<|endoftext|>