<commit_before>
const {app, BrowserWindow, ipcMain, shell} = require('electron');
const path = require('path');
const url = require('url');
const fs = require('fs');

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;

function createWindow() {
    // Create the browser window.
    var width = 800,
        height = 600;

    const screen = require('electron').screen;
    if (screen) {
        const display = screen.getPrimaryDisplay();
        if (display && display.workArea) {
            width = display.workArea.width || width;
            height = display.workArea.height || height;
        }
    }

    mainWindow = new BrowserWindow({
        width: width,
        height: height,
        minWidth: 400,
        minHeight: 400,
        textAreasAreResizable: false,
        plugins: true,
        show: false // Don't show it until it's ready to prevent showing a blank screen.
    });

    // And load the index.html of the app.
    mainWindow.loadURL(url.format({
        pathname: path.join(__dirname, 'index.html'),
        protocol: 'file:',
        slashes: true
    }));

    mainWindow.once('ready-to-show', () => {
        mainWindow.show();
        mainWindow.maximize();
    });

    // Emitted when the window is closed.
    mainWindow.on('closed', () => {
        // Dereference the window object.
        mainWindow = null
    });
}

// This method will be called when Electron has finished initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', function() {
    createWindow();
});

// Quit when all windows are closed.
app.on('window-all-closed', () => {
    app.quit();
});

app.on('activate', () => {
    // On macOS it's common to re-create a window in the app when the dock icon is clicked and there are no other windows open.
    if (mainWindow === null) {
        createWindow();
    }
});

// Read the config.json file to set app's protocol (custom URL scheme).
fs.readFile(path.join(__dirname, 'config.json'), 'utf8', (err, data) => {
    var ssoScheme = 'moodlemobile'; // Default value.
    if (!err) {
        try {
            data = JSON.parse(data);
            ssoScheme = data.customurlscheme;
        } catch(ex) {}
    }

    app.setAsDefaultProtocolClient(ssoScheme);
});

// Make sure that only a single instance of the app is running.
var shouldQuit = app.makeSingleInstance((argv, workingDirectory) => {
    // Another instance was launched. If it was launched with a URL, it should be in the second param.
    if (argv && argv[1]) {
        appLaunched(argv[1]);
    }
});

if (shouldQuit) {
    // It's not the main instance of the app, kill it.
    app.quit();
} else {
    // Listen for open-url events (Mac OS only).
    app.on('open-url', (event, url) => {
        event.preventDefault();
        appLaunched(url);
    });
}

function appLaunched(url) {
    // App was launched again with a URL. Focus the main window and send an event to treat the URL.
    if (mainWindow) {
        focusApp();
        mainWindow.webContents.send('mmAppLaunched', url); // Send an event to the main window.
    }
}

function focusApp() {
    if (mainWindow) {
        if (mainWindow.isMinimized()) {
            mainWindow.restore();
        }
        mainWindow.focus();
    }
}

// Listen for events sent by the renderer processes (windows).
ipcMain.on('openItem', (event, path) => {
    shell.openItem(path);
});

ipcMain.on('closeSecondaryWindows', () => {
    var windows = BrowserWindow.getAllWindows();
    for (var i = 0; i < windows.length; i++) {
        if (!mainWindow || windows[i].id != mainWindow.id) {
            windows[i].close();
        }
    }
});

ipcMain.on('focusApp', focusApp);
<commit_msg>MOBILE-2180 desktop: Focus when relaunched and use exit instead of quit<commit_after>
const {app, BrowserWindow, ipcMain, shell} = require('electron');
const path = require('path');
const url = require('url');
const fs = require('fs');

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;

function createWindow() {
    // Create the browser window.
    var width = 800,
        height = 600;

    const screen = require('electron').screen;
    if (screen) {
        const display = screen.getPrimaryDisplay();
        if (display && display.workArea) {
            width = display.workArea.width || width;
            height = display.workArea.height || height;
        }
    }

    mainWindow = new BrowserWindow({
        width: width,
        height: height,
        minWidth: 400,
        minHeight: 400,
        textAreasAreResizable: false,
        plugins: true,
        show: false // Don't show it until it's ready to prevent showing a blank screen.
    });

    // And load the index.html of the app.
    mainWindow.loadURL(url.format({
        pathname: path.join(__dirname, 'index.html'),
        protocol: 'file:',
        slashes: true
    }));

    mainWindow.once('ready-to-show', () => {
        mainWindow.show();
        mainWindow.maximize();
    });

    // Emitted when the window is closed.
    mainWindow.on('closed', () => {
        // Dereference the window object.
        mainWindow = null
    });
}

// This method will be called when Electron has finished initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', function() {
    createWindow();
});

// Quit when all windows are closed.
app.on('window-all-closed', () => {
    app.exit();
});

app.on('activate', () => {
    // On macOS it's common to re-create a window in the app when the dock icon is clicked and there are no other windows open.
    if (mainWindow === null) {
        createWindow();
    }
});

// Read the config.json file to set app's protocol (custom URL scheme).
fs.readFile(path.join(__dirname, 'config.json'), 'utf8', (err, data) => {
    var ssoScheme = 'moodlemobile'; // Default value.
    if (!err) {
        try {
            data = JSON.parse(data);
            ssoScheme = data.customurlscheme;
        } catch(ex) {}
    }

    app.setAsDefaultProtocolClient(ssoScheme);
});

// Make sure that only a single instance of the app is running.
var shouldQuit = app.makeSingleInstance((argv, workingDirectory) => {
    // Another instance was launched. If it was launched with a URL, it should be in the second param.
    if (argv && argv[1]) {
        appLaunched(argv[1]);
    } else {
        focusApp();
    }
});

// For some reason, shouldQuit is always true in signed Mac apps so we should ingore it.
if (shouldQuit && os.platform().indexOf('darwin') == -1) {
    // It's not the main instance of the app, kill it.
    app.exit();
    return;
}

// Listen for open-url events (Mac OS only).
app.on('open-url', (event, url) => {
    event.preventDefault();
    appLaunched(url);
});

function appLaunched(url) {
    // App was launched again with a URL. Focus the main window and send an event to treat the URL.
    if (mainWindow) {
        focusApp();
        mainWindow.webContents.send('mmAppLaunched', url); // Send an event to the main window.
    }
}

function focusApp() {
    if (mainWindow) {
        if (mainWindow.isMinimized()) {
            mainWindow.restore();
        }
        mainWindow.focus();
    }
}

// Listen for events sent by the renderer processes (windows).
ipcMain.on('openItem', (event, path) => {
    shell.openItem(path);
});

ipcMain.on('closeSecondaryWindows', () => {
    var windows = BrowserWindow.getAllWindows();
    for (var i = 0; i < windows.length; i++) {
        if (!mainWindow || windows[i].id != mainWindow.id) {
            windows[i].close();
        }
    }
});

ipcMain.on('focusApp', focusApp);
<|endoftext|>


<commit_before>var _data = [
	{
		'name':'infoQ',
		'url':'http://www.infoq.com/cn/'
	},
	{
		'name':'w3school',
		'url':'http://www.w3school.com.cn/'
	},
	{
		'name':'蓝色理想',
		'url':'http://bbs.blueidea.com/'
	},
	{
		'name':'博客园',
		'url':'http://www.cnblogs.com/'
	},
	{
		'name':'CSDN',
		'url':'http://www.csdn.net/'
	},
	{
		'name':'51cto.com',
		'url':'http://www.51cto.com/'
	},
	{
		'name':'开源中国',
		'url':'http://www.oschina.net/'
	},
	{
		'name':'在线工具',
		'url':'http://tool.oschina.net/'
	},
	{
		'name':'cocoachina',
		'url':'http://www.cocoachina.com/'
	}
];<commit_msg>updated 现代魔方<commit_after>var _data = [
	{
		'name':'infoQ',
		'url':'http://www.infoq.com/cn/'
	},
	{
		'name':'w3school',
		'url':'http://www.w3school.com.cn/'
	},
	{
		'name':'蓝色理想',
		'url':'http://bbs.blueidea.com/'
	},
	{
		'name':'博客园',
		'url':'http://www.cnblogs.com/'
	},
	{
		'name':'CSDN',
		'url':'http://www.csdn.net/'
	},
	{
		'name':'51cto.com',
		'url':'http://www.51cto.com/'
	},
	{
		'name':'开源中国',
		'url':'http://www.oschina.net/'
	},
	{
		'name':'在线工具',
		'url':'http://tool.oschina.net/'
	},
	{
		'name':'cocoachina',
		'url':'http://www.cocoachina.com/'
	},
	{
		'name':'现代魔法学院',
		'url':'http://www.nowamagic.net/'
	}
];<|endoftext|>


<commit_before>/*global require, describe, it */
var should = require('should');
var bubbleSort = require('../src/index.js');

describe('Sorting a list', function() {
  it('sorts [16, 42, 8, 4, 15, 23]', function() {
    var list = [16, 42, 8, 4, 15, 23];
    var sorted = [4, 8, 15, 16, 23, 42];

    bubbleSort(list).should.equal(sorted);
  });

  it('sorts [0, 0, 0, 1]', function() {
    var list = [0, 0, 0, 1];
    var sorted = [1, 0, 0, 0];

    bubbleSort(list).should.equal(sorted);
  });

  it('sorts [0, 1, 0, 1]', function() {
    var list = [0, 1, 0, 1];
    var sorted = [1, 1, 0, 0];

    bubbleSort(list).should.equal(sorted);
  });

  it('sorts [1, 0, 0, 0]', function() {
    var list = [1, 0, 0, 0];
    var sorted = [1, 0, 0, 0];

    bubbleSort(list).should.equal(sorted);
  });
});<commit_msg>eql actually checks lists. equal does not.<commit_after>/*global require, describe, it */
var should = require('should');
var bubbleSort = require('../src/index.js');

describe('Sorting a list', function() {
  it('sorts [16, 42, 8, 4, 15, 23]', function() {
    var list = [16, 42, 8, 4, 15, 23];
    var sorted = [4, 8, 15, 16, 23, 42];

    bubbleSort(list).should.eql(sorted);
  });

  it('sorts [0, 0, 0, 1]', function() {
    var list = [0, 0, 0, 1];
    var sorted = [1, 0, 0, 0];

    bubbleSort(list).should.eql(sorted);
  });

  it('sorts [0, 1, 0, 1]', function() {
    var list = [0, 1, 0, 1];
    var sorted = [1, 1, 0, 0];

    bubbleSort(list).should.eql(sorted);
  });

  it('sorts [1, 0, 0, 0]', function() {
    var list = [1, 0, 0, 0];
    var sorted = [1, 0, 0, 0];

    bubbleSort(list).should.eql(sorted);
  });
});
<|endoftext|>


<commit_before>/*
 * Copyright 2016 Small Batch, Inc.
 *
 * 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.
 */
/* Web Font Loader v1.6.16 - (c) Adobe Systems, Google. License: Apache 2.0 */
(function(){function aa(a,b,c){return a.call.apply(a.bind,arguments)}function ba(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}}function n(a,b,c){n=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?aa:ba;return n.apply(null,arguments)}var p=Date.now||function(){return+new Date};function r(a,b){this.F=a;this.k=b||a;this.H=this.k.document}var ca=!!window.FontFace;r.prototype.createElement=function(a,b,c){a=this.H.createElement(a);if(b)for(var d in b)b.hasOwnProperty(d)&&("style"==d?a.style.cssText=b[d]:a.setAttribute(d,b[d]));c&&a.appendChild(this.H.createTextNode(c));return a};function s(a,b,c){a=a.H.getElementsByTagName(b)[0];a||(a=document.documentElement);a.insertBefore(c,a.lastChild)}
function t(a,b,c){b=b||[];c=c||[];for(var d=a.className.split(/\s+/),e=0;e<b.length;e+=1){for(var f=!1,g=0;g<d.length;g+=1)if(b[e]===d[g]){f=!0;break}f||d.push(b[e])}b=[];for(e=0;e<d.length;e+=1){f=!1;for(g=0;g<c.length;g+=1)if(d[e]===c[g]){f=!0;break}f||b.push(d[e])}a.className=b.join(" ").replace(/\s+/g," ").replace(/^\s+|\s+$/,"")}function u(a,b){for(var c=a.className.split(/\s+/),d=0,e=c.length;d<e;d++)if(c[d]==b)return!0;return!1}
function v(a){if("string"===typeof a.fa)return a.fa;var b=a.k.location.protocol;"about:"==b&&(b=a.F.location.protocol);return"https:"==b?"https:":"http:"}function x(a,b,c){function d(){l&&e&&f&&(l(g),l=null)}b=a.createElement("link",{rel:"stylesheet",href:b,media:"all"});var e=!1,f=!0,g=null,l=c||null;ca?(b.onload=function(){e=!0;d()},b.onerror=function(){e=!0;g=Error("Stylesheet failed to load");d()}):setTimeout(function(){e=!0;d()},0);s(a,"head",b)}
function y(a,b,c,d){var e=a.H.getElementsByTagName("head")[0];if(e){var f=a.createElement("script",{src:b}),g=!1;f.onload=f.onreadystatechange=function(){g||this.readyState&&"loaded"!=this.readyState&&"complete"!=this.readyState||(g=!0,c&&c(null),f.onload=f.onreadystatechange=null,"HEAD"==f.parentNode.tagName&&e.removeChild(f))};e.appendChild(f);setTimeout(function(){g||(g=!0,c&&c(Error("Script load timeout")))},d||5E3);return f}return null};function z(){this.S=0;this.K=null}function A(a){a.S++;return function(){a.S--;B(a)}}function C(a,b){a.K=b;B(a)}function B(a){0==a.S&&a.K&&(a.K(),a.K=null)};function D(a){this.ea=a||"-"}D.prototype.d=function(a){for(var b=[],c=0;c<arguments.length;c++)b.push(arguments[c].replace(/[\W_]+/g,"").toLowerCase());return b.join(this.ea)};function E(a,b){this.Q=a;this.M=4;this.L="n";var c=(b||"n4").match(/^([nio])([1-9])$/i);c&&(this.L=c[1],this.M=parseInt(c[2],10))}E.prototype.getName=function(){return this.Q};function da(a){return F(a)+" "+(a.M+"00")+" 300px "+G(a.Q)}function G(a){var b=[];a=a.split(/,\s*/);for(var c=0;c<a.length;c++){var d=a[c].replace(/['"]/g,"");-1!=d.indexOf(" ")||/^\d/.test(d)?b.push("'"+d+"'"):b.push(d)}return b.join(",")}function I(a){return a.L+a.M}
function F(a){var b="normal";"o"===a.L?b="oblique":"i"===a.L&&(b="italic");return b}function ea(a){var b=4,c="n",d=null;a&&((d=a.match(/(normal|oblique|italic)/i))&&d[1]&&(c=d[1].substr(0,1).toLowerCase()),(d=a.match(/([1-9]00|normal|bold)/i))&&d[1]&&(/bold/i.test(d[1])?b=7:/[1-9]00/.test(d[1])&&(b=parseInt(d[1].substr(0,1),10))));return c+b};function fa(a,b){this.a=a;this.j=a.k.document.documentElement;this.O=b;this.f="wf";this.e=new D("-");this.da=!1!==b.events;this.u=!1!==b.classes}function ga(a){a.u&&t(a.j,[a.e.d(a.f,"loading")]);J(a,"loading")}function K(a){if(a.u){var b=u(a.j,a.e.d(a.f,"active")),c=[],d=[a.e.d(a.f,"loading")];b||c.push(a.e.d(a.f,"inactive"));t(a.j,c,d)}J(a,"inactive")}function J(a,b,c){if(a.da&&a.O[b])if(c)a.O[b](c.getName(),I(c));else a.O[b]()};function ha(){this.t={}}function ia(a,b,c){var d=[],e;for(e in b)if(b.hasOwnProperty(e)){var f=a.t[e];f&&d.push(f(b[e],c))}return d};function L(a,b){this.a=a;this.h=b;this.m=this.a.createElement("span",{"aria-hidden":"true"},this.h)}function M(a,b){var c=a.m,d;d="display:block;position:absolute;top:-9999px;left:-9999px;font-size:300px;width:auto;height:auto;line-height:normal;margin:0;padding:0;font-variant:normal;white-space:nowrap;font-family:"+G(b.Q)+";"+("font-style:"+F(b)+";font-weight:"+(b.M+"00")+";");c.style.cssText=d}function N(a){s(a.a,"body",a.m)}L.prototype.remove=function(){var a=this.m;a.parentNode&&a.parentNode.removeChild(a)};function O(a,b,c,d,e,f){this.G=a;this.J=b;this.g=d;this.a=c;this.v=e||3E3;this.h=f||void 0}O.prototype.start=function(){function a(){p()-d>=c.v?c.J(c.g):b.fonts.load(da(c.g),c.h).then(function(b){1<=b.length?c.G(c.g):setTimeout(a,25)},function(){c.J(c.g)})}var b=this.a.k.document,c=this,d=p();a()};function P(a,b,c,d,e,f,g){this.G=a;this.J=b;this.a=c;this.g=d;this.h=g||"BESbswy";this.s={};this.v=e||3E3;this.Z=f||null;this.D=this.C=this.A=this.w=null;this.w=new L(this.a,this.h);this.A=new L(this.a,this.h);this.C=new L(this.a,this.h);this.D=new L(this.a,this.h);M(this.w,new E(this.g.getName()+",serif",I(this.g)));M(this.A,new E(this.g.getName()+",sans-serif",I(this.g)));M(this.C,new E("serif",I(this.g)));M(this.D,new E("sans-serif",I(this.g)));N(this.w);N(this.A);N(this.C);N(this.D)}
var Q={ia:"serif",ha:"sans-serif"},R=null;function S(){if(null===R){var a=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);R=!!a&&(536>parseInt(a[1],10)||536===parseInt(a[1],10)&&11>=parseInt(a[2],10))}return R}P.prototype.start=function(){this.s.serif=this.C.m.offsetWidth;this.s["sans-serif"]=this.D.m.offsetWidth;this.ga=p();ja(this)};function ka(a,b,c){for(var d in Q)if(Q.hasOwnProperty(d)&&b===a.s[Q[d]]&&c===a.s[Q[d]])return!0;return!1}
function ja(a){var b=a.w.m.offsetWidth,c=a.A.m.offsetWidth,d;(d=b===a.s.serif&&c===a.s["sans-serif"])||(d=S()&&ka(a,b,c));d?p()-a.ga>=a.v?S()&&ka(a,b,c)&&(null===a.Z||a.Z.hasOwnProperty(a.g.getName()))?T(a,a.G):T(a,a.J):la(a):T(a,a.G)}function la(a){setTimeout(n(function(){ja(this)},a),50)}function T(a,b){setTimeout(n(function(){this.w.remove();this.A.remove();this.C.remove();this.D.remove();b(this.g)},a),0)};function U(a,b,c){this.a=a;this.p=b;this.P=0;this.ba=this.Y=!1;this.v=c}var V=null;U.prototype.V=function(a){var b=this.p;b.u&&t(b.j,[b.e.d(b.f,a.getName(),I(a).toString(),"active")],[b.e.d(b.f,a.getName(),I(a).toString(),"loading"),b.e.d(b.f,a.getName(),I(a).toString(),"inactive")]);J(b,"fontactive",a);this.ba=!0;ma(this)};
U.prototype.W=function(a){var b=this.p;if(b.u){var c=u(b.j,b.e.d(b.f,a.getName(),I(a).toString(),"active")),d=[],e=[b.e.d(b.f,a.getName(),I(a).toString(),"loading")];c||d.push(b.e.d(b.f,a.getName(),I(a).toString(),"inactive"));t(b.j,d,e)}J(b,"fontinactive",a);ma(this)};function ma(a){0==--a.P&&a.Y&&(a.ba?(a=a.p,a.u&&t(a.j,[a.e.d(a.f,"active")],[a.e.d(a.f,"loading"),a.e.d(a.f,"inactive")]),J(a,"active")):K(a.p))};function na(a){this.F=a;this.q=new ha;this.$=0;this.T=this.U=!0}na.prototype.load=function(a){this.a=new r(this.F,a.context||this.F);this.U=!1!==a.events;this.T=!1!==a.classes;oa(this,new fa(this.a,a),a)};
function pa(a,b,c,d,e){var f=0==--a.$;(a.T||a.U)&&setTimeout(function(){var a=e||null,l=d||null||{};if(0===c.length&&f)K(b.p);else{b.P+=c.length;f&&(b.Y=f);var h,k=[];for(h=0;h<c.length;h++){var m=c[h],w=l[m.getName()],q=b.p,H=m;q.u&&t(q.j,[q.e.d(q.f,H.getName(),I(H).toString(),"loading")]);J(q,"fontloading",H);q=null;null===V&&(V=window.FontFace?(q=/Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent))?42<parseInt(q[1],10):!0:!1);q=V?new O(n(b.V,b),n(b.W,b),b.a,m,b.v,w):new P(n(b.V,b),n(b.W,b),
b.a,m,b.v,a,w);k.push(q)}for(h=0;h<k.length;h++)k[h].start()}},0)}function oa(a,b,c){var d=[],e=c.timeout;ga(b);var d=ia(a.q,c,a.a),f=new U(a.a,b,e);a.$=d.length;b=0;for(c=d.length;b<c;b++)d[b].load(function(b,c,d){pa(a,f,b,c,d)})};function qa(a,b,c){this.N=a?a:b+ra;this.o=[];this.R=[];this.ca=c||""}var ra="//fonts.googleapis.com/css";function sa(a,b){for(var c=b.length,d=0;d<c;d++){var e=b[d].split(":");3==e.length&&a.R.push(e.pop());var f="";2==e.length&&""!=e[1]&&(f=":");a.o.push(e.join(f))}}
qa.prototype.d=function(){if(0==this.o.length)throw Error("No fonts to load!");if(-1!=this.N.indexOf("kit="))return this.N;for(var a=this.o.length,b=[],c=0;c<a;c++)b.push(this.o[c].replace(/ /g,"+"));a=this.N+"?family="+b.join("%7C");0<this.R.length&&(a+="&subset="+this.R.join(","));0<this.ca.length&&(a+="&text="+encodeURIComponent(this.ca));return a};function ta(a){this.o=a;this.aa=[];this.I={}}
var ua={latin:"BESbswy",cyrillic:"йяЖ",greek:"αβΣ",khmer:"កខគ",Hanuman:"កខគ"},va={thin:"1",extralight:"2","extra-light":"2",ultralight:"2","ultra-light":"2",light:"3",regular:"4",book:"4",medium:"5","semi-bold":"6",semibold:"6","demi-bold":"6",demibold:"6",bold:"7","extra-bold":"8",extrabold:"8","ultra-bold":"8",ultrabold:"8",black:"9",heavy:"9",l:"3",r:"4",b:"7"},wa={i:"i",italic:"i",n:"n",normal:"n"},xa=/^(thin|(?:(?:extra|ultra)-?)?light|regular|book|medium|(?:(?:semi|demi|extra|ultra)-?)?bold|black|heavy|l|r|b|[1-9]00)?(n|i|normal|italic)?$/;
ta.prototype.parse=function(){for(var a=this.o.length,b=0;b<a;b++){var c=this.o[b].split(":"),d=c[0].replace(/\+/g," "),e=["n4"];if(2<=c.length){var f;var g=c[1];f=[];if(g)for(var g=g.split(","),l=g.length,h=0;h<l;h++){var k;k=g[h];if(k.match(/^[\w-]+$/))if(k=xa.exec(k.toLowerCase()),null==k)k="";else{var m;m=k[1];if(null==m||""==m)m="4";else{var w=va[m];m=w?w:isNaN(m)?"4":m.substr(0,1)}k=k[2];k=[null==k||""==k?"n":wa[k],m].join("")}else k="";k&&f.push(k)}0<f.length&&(e=f);3==c.length&&(c=c[2],f=
[],c=c?c.split(","):f,0<c.length&&(c=ua[c[0]])&&(this.I[d]=c))}this.I[d]||(c=ua[d])&&(this.I[d]=c);for(c=0;c<e.length;c+=1)this.aa.push(new E(d,e[c]))}};function ya(a,b){this.a=a;this.c=b}var za={Arimo:!0,Cousine:!0,Tinos:!0};ya.prototype.load=function(a){var b=new z,c=this.a,d=new qa(this.c.api,v(c),this.c.text),e=this.c.families;sa(d,e);var f=new ta(e);f.parse();x(c,d.d(),A(b));C(b,function(){a(f.aa,f.I,za)})};function W(a,b){this.a=a;this.c=b;this.X=[]}W.prototype.B=function(a){var b=this.a;return v(this.a)+(this.c.api||"//f.fontdeck.com/s/css/js/")+(b.k.location.hostname||b.F.location.hostname)+"/"+a+".js"};
W.prototype.load=function(a){var b=this.c.id,c=this.a.k,d=this;b?(c.__webfontfontdeckmodule__||(c.__webfontfontdeckmodule__={}),c.__webfontfontdeckmodule__[b]=function(b,c){for(var g=0,l=c.fonts.length;g<l;++g){var h=c.fonts[g];d.X.push(new E(h.name,ea("font-weight:"+h.weight+";font-style:"+h.style)))}a(d.X)},y(this.a,this.B(b),function(b){b&&a([])})):a([])};function X(a,b){this.a=a;this.c=b}X.prototype.B=function(a){return(this.c.api||"https://use.typekit.net")+"/"+a+".js"};X.prototype.load=function(a){var b=this.c.id,c=this.a.k;b?y(this.a,this.B(b),function(b){if(b)a([]);else if(c.Typekit&&c.Typekit.config&&c.Typekit.config.fn){b=c.Typekit.config.fn;for(var e=[],f=0;f<b.length;f+=2)for(var g=b[f],l=b[f+1],h=0;h<l.length;h++)e.push(new E(g,l[h]));try{c.Typekit.load({events:!1,classes:!1,async:!0})}catch(k){}a(e)}},2E3):a([])};function Y(a,b){this.a=a;this.c=b}Y.prototype.B=function(a,b){var c=v(this.a),d=(this.c.api||"fast.fonts.net/jsapi").replace(/^.*http(s?):(\/\/)?/,"");return c+"//"+d+"/"+a+".js"+(b?"?v="+b:"")};
Y.prototype.load=function(a){function b(){if(e["__mti_fntLst"+c]){var d=e["__mti_fntLst"+c](),g=[],l;if(d)for(var h=0;h<d.length;h++){var k=d[h].fontfamily;void 0!=d[h].fontStyle&&void 0!=d[h].fontWeight?(l=d[h].fontStyle+d[h].fontWeight,g.push(new E(k,l))):g.push(new E(k))}a(g)}else setTimeout(function(){b()},50)}var c=this.c.projectId,d=this.c.version;if(c){var e=this.a.k;y(this.a,this.B(c,d),function(c){c?a([]):b()}).id="__MonotypeAPIScript__"+c}else a([])};function Aa(a,b){this.a=a;this.c=b}Aa.prototype.load=function(a){var b,c,d=this.c.urls||[],e=this.c.families||[],f=this.c.testStrings||{},g=new z;b=0;for(c=d.length;b<c;b++)x(this.a,d[b],A(g));var l=[];b=0;for(c=e.length;b<c;b++)if(d=e[b].split(":"),d[1])for(var h=d[1].split(","),k=0;k<h.length;k+=1)l.push(new E(d[0],h[k]));else l.push(new E(d[0]));C(g,function(){a(l,f)})};var Z=new na(window);Z.q.t.custom=function(a,b){return new Aa(b,a)};Z.q.t.fontdeck=function(a,b){return new W(b,a)};Z.q.t.monotype=function(a,b){return new Y(b,a)};Z.q.t.typekit=function(a,b){return new X(b,a)};Z.q.t.google=function(a,b){return new ya(b,a)};var $={load:n(Z.load,Z)};"function"===typeof define&&define.amd?define(function(){return $}):"undefined"!==typeof module&&module.exports?module.exports=$:(window.WebFont=$,window.WebFontConfig&&Z.load(window.WebFontConfig));}());
<commit_msg>Delete webfont<commit_after><|endoftext|>


<commit_before>/* The MIT License (MIT)
Copyright (c) 2016 The MITRE Corporation

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.
*/

/* National Weather Service Icons */
/* Makes use of Leaflet JS: http://leafletjs.com/ */
/* SVG Icons courtesy of GEOHuntsville: http://geohuntsville.org/page/geoq */

/* Dependent on L.Marker.AutoResizeSVG found at
   http://github.com/john-kilgo/L.Marker.AutoResizeSVG
   Include marker-resize-svg.js in your HTML document */

L.NWSIconsLayer = L.GeoJSON.extend({
    // Options are JSON object found in database
    options: {
        debug: true
    },

    // NOTE: A possible way to organize (possible list) of icons?
    _icons: {
        statement : {
            flood : "StatementFloodOutlineHaloed.svg",
            tornado : "StatementHurricaneOutlineHaloed.svg",
            hurricane : "StatementHurricaneOutlineHaloed.svg",
            tropicalStorm : "StatementTropicalStormOutlineHaloed.svg"
        },
        warning : {
            evacuate : "warningEvacuateImmediatelyHaloed.svg",
            fire : "warningFireOutlineHaloed.svg",
            flood : "warningFloodOutlineHaloed.svg",
            hurricane : "warningHurricaneOutlineHaloed.svg",
            thunderstorm : "warningSevereThunderstormOutlineHaloed.svg",
            tropicalStorm : "warningTropicalStormOutlineHaloed1.svg",
            tsunami : "warningTsumaniDraftHaloed.svg"
        },
        watch : {
            fire : "watchFireOutlineHaloed.svg",
            flood : "watchFloodOutlineHaloed.svg",
            hurricane : "watchHurricaneOutlineHaloed.svg",
            thunderstorm : "watchSevereThunderstormOutlineHaloed.svg",
            tornado : "watchTornadoColorOutlineHaloed.svg",
            tropicalStorm : "watchTropicalStormOutlineHaloed.svg",
            winterStorm : "watchWinterStormHaloed.svg"
        },
    },

    initialize: function (load, map, options) {
        // Merge options together
        L.Util.setOptions(this, options);

        if (site_settings.FEMA_IPAWS) {
            L.Util.setOptions(this, site_settings.FEMA_IPAWS);
            console.log(this.options);
        } else {
            console.error("NWS Icons: Fatal Error. site_settings missing. Please visit GeoQ Admin site and add FEMA_IPAWS json settings object.")
            return;
        }

        // Markers to add to map
        this._layers = {};
        // Our map
        this._map = map;

        if (this._map) {
            this.NWSLayerGroup.addTo(this._map);

            // When map moves update bounds
            var _this = this; // Set the context of the event handler
            this._map.on('moveend', function() {
                _this.geocode();
                _this.load(_this.testCallBack);
            });
        }

        // Map adjusts onload triggering the moveend event handler several times
        // this section may therefore be redundant?
        /*if (load) {
            //this.addMediaQ(options);
            this.geocode();
            this.load(this.testCallBack);
        }*/
    },

    // Gets the bounds of the Workcell and calls for GeoCode info
    geocode: function() {
        var map = this._map;
        var bounds = map.getBounds();

        var ringObject = '{"rings":[[[' +
                bounds._southWest.lng + ',' + bounds._northEast.lat + '],[' +
                bounds._northEast.lng + ',' + bounds._northEast.lat + '],[' +
                bounds._northEast.lng + ',' + bounds._southWest.lat + '],[' +
                bounds._southWest.lng + ',' + bounds._southWest.lat + '],[' +
                bounds._southWest.lng + ',' + bounds._northEast.lat + ']]],' +
                '"spatialReference":{"wkid":4326}}';

        var url = "/geoq/proxy/https://tigerweb.geo.census.gov/arcgis/rest/services/Generalized_ACS2015/State_County/MapServer/11/query?where=&text=&objectIds=&time=&geometry=" + ringObject + "&geometryType=esriGeometryPolygon&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=GEOID&returnGeometry=false&returnTrueCurves=false&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&resultOffset=&resultRecordCount=&f=pjson";

        $.ajax({
            type: 'GET',
            context: this,
            url: url,
            dataType: 'json',
        })
        .done(this._geocode)
        .fail(this.ajaxError)

        /// PArse out and generate SAME codes and put into array
        //this._sameCodes <<<< John will generate

    },

    // Finds and saves SAME codes
    _geocode: function(data) {
        var features = data.features;
        this._sameCodes = [];

        for (var i=0; i < features.length; i++) {
            var tmp = features[i]["attributes"]["GEOID"];
            tmp = tmp.toString();
            // Prepend '0' in order to convert FIPS 5-1 to NWS SAME code
            tmp = '0' + tmp;
            this._sameCodes.push(tmp);
        }
    },

    // Loads the FEMA list server
    load: function(callback) {
        var options = this.options;

        if (!options.FEMAkey) {
            log.error("No key set for NWS Cap messages");
            console.error("No key set for NWS Cap messages");
            return;
        }

        $.ajax({
            type: "POST",
            url: "/geoq/api/geo/ipaws",
            context: this,
            data: {develop: true, key: this.options.FEMAkey}
        }).done(function( data ) {
                // To be changed to callback
                console.log(data);
        }).fail(this.ajaxError);
    },

    // On add of the layer
   /* addMediaQ: function(options) {
        var _this = this;
        // Below is the function called on each piece of data.
        var cb = function(data) { _this._addMediaQ(data, this.options); };
        this.loadMediaQ(cb, options);
    },
    // Parses JSON
    _addMediaQ: function(data, options) {
        L.MediaQLayer.parseJSON(data, this);
        if (!this) return;

        this.addTo(this._map);
    },*/

    // NWS Callback IPAWS Parse
    parseIPAWS: function(data) {

    },

    // If an ajax error occurs
    ajaxError: function (resultobj) {
        console.error("Ajax error.");
        console.log(resultobj);
        log.error("Request called for, but no valid response was received from the server, result:", resultobj);
    },
    // Where icons/paths are stored
    NWSLayerGroup: L.layerGroup(),
    // IDs of layers??
    layer_ids: {},

// begin break with old code in extend

    parseJSON: function (data, layer){
        var result;
        if (typeof data=="object") {
            result = data;
        } else {
            try {
                result = JSON.parse(data);
            } catch (ex){
                log.error("Error parsing JSON returned from server");
                return;
            }
        }

        layer.options.onEachFeature = function(feature, layer) {
            L.MediaQLayer.onEachFeature(feature, layer, layer.options, this);
        };

        // layer.options.style = leaflet_helper.constructors.polygonStyleBuilderCallback;
        layer.pointToLayer = function(feature, latlng) {
            return L.MediaQLayer.iconBuilderCallback(feature, latlng, layer);
        };

        layer.addData(data);
    },

    // Make icon and place in marker.
    iconBuilderCallback: function(feature, latlng, layerConfig){
        var iconX = 15;
        var iconY = 24;
        var iconAnchor = null;

        layerConfig = layerConfig || {geojson_layer_count:1, name:'MediaQ Layer'};

        var iconUrl = this.options.iconUrl || "";

        //Build the icon injects
        var iconData = {
            iconUrl: iconUrl,
            iconSize: new L.Point(iconX, iconY),
            text: layerConfig.name
        };
        if (iconAnchor) iconData.iconAnchor = iconAnchor;
        var icon = new MapMarker(iconData);

        //Construct the final Icon
        return L.rotatedMarker(latlng, {icon: icon});
    },

    // Polygon Style
    /*polygonStyleBuilderCallback: function(feature) {
        var polyFillColor = '#ff0000';

        var style = {
            weight: 2,
            opacity: 1,
            color: 'white',
            fillOpacity: 0.1,
            fillColor: polyFillColor};

        return style;
    },*/

    // Assign popups to each feature
    onEachFeature: function (feature, layer, layerConfig, mediaqOptions) {
        if (feature.properties) {
            var popupContent = "";
            if (feature.properties.popupContent) {
                popupContent = feature.properties.popupContent;
            } else if (feature.properties.vid) {
                popupContent = L.MediaQLayer.clean("MediaQ Id: " + feature.properties.vid);
                if (feature.properties.href){
                    var link = L.MediaQLayer.clean(feature.properties.href); //Strip out any offending
                    popupContent = "
MediaQ Video
"+
                        "
<video width='320' height='240' controls><source src='"+link+"' type='video/mp4'></video>"+
                        "
<button type='button' class='btn btn-small' " +
                        "onclick='L.MediaQLayer.displayHidePath(\"" + feature.properties.vid + "\", \"" +
                        mediaqOptions.url + mediaqOptions.metadata_link + "\", \"" +
                        mediaqOptions.key + "\");' >Display/Hide Path</button>
";
                }
            }
            if (popupContent && _.isString(popupContent)) {

                if (!popupContent.indexOf("")){
                    if (layerConfig && layerConfig.name) {
                        if (!feature.properties.id) {
                            feature.properties.id = leaflet_helper.id_count++;
                        }
                        var id = feature.properties.id;
                        popupContent += L.MediaQLayer.addLinksToPopup(layerConfig.name, id, true, false);
                    }
                }
                layer.bindPopup(popupContent);
            }
            if (feature.properties.heading && parseInt(feature.properties.heading) && layer.options){
                layer.options.angle = parseInt(feature.properties.heading);
            }
        }
    },

    // Path of video
    /* displayHidePath: function(vid, queryurl, key) {
        var layer_ids = this.prototype.layer_ids;
        var ourlayergroup = this.prototype.mediaqLayerGroup;

        if (layer_ids[vid]) {
            // remove layer from layer group
            var layer = ourlayergroup.getLayer(layer_ids[vid]);
            ourlayergroup.removeLayer(layer);
            delete layer_ids[vid];
            return;
        }
        var params = {'VID':vid};
        var url = queryurl.replace(/{[^{}]+}/g, function(k) {
            return params[k.replace(/[{}]+/g, "")] || "";
        });

        var cb = function(data) {
            try {
                var markerOptions = { radius: 4, fillColor: "#ff0000", color: "#f00", weight: 1, opacity: 1};
                var newlayer = L.geoJson(data, {
                    pointToLayer: function (feature, latlng) {
                        return L.circleMarker(latlng, markerOptions);
                    }
                });
                newlayer.addTo(ourlayergroup);
                var id = ourlayergroup.getLayerId(newlayer);
                layer_ids[vid] = id;
            } catch (ex){
                log.error("Error parsing JSON returned from server");
                return;
            }
        };

        var error = function(data) {
            log.error("got error");
        };

        $.ajax({
            type: 'GET',
            url: leaflet_helper.proxify(url),
            headers: {
                'X-API-KEY': key
            },
            dataType: 'json',
            success: cb,
            error: error
        });
    },*/
    // Add links to popup (not needed)
    /*addLinksToPopup: function (layerName,id,useMove,useHide,useDrop) {

        var spanLink = ""+layerName+"";
        spanLink += ""+id+"";
        var output = "";
        if (useMove) {
            output += "
Click on a feature to link this to it"+spanLink+""
        }
        if (useHide) {
            output += "
Hide this Item"+spanLink+"";
        }
        if (useDrop) {
            output += "
"+spanLink+"";
        }
        if (output) output = "
"+output;

        return output;

    },*/
    /* Rewrite to clean once data received
    clean: function (text) {
        return jQuery("
"+text+"
").text() || "";
    },
    // ??????
    getLatLngs: function (xml) {
        var el = xml.getElementsByTagName('coordinates');
        var coords = [];
        for (var j = 0; j < el.length; j++) {
            // text might span many childNodes
            coords = coords.concat(this._read_coords(el[j]));
        }
        return coords;
    },
    // ???????
    _read_coords: function (el) {
        var text = '', coords = [], i;
        for (i = 0; i < el.childNodes.length; i++) {
            text = text + el.childNodes[i].nodeValue;
        }
        text = text.split(/[\s\n]+/);
        for (i = 0; i < text.length; i++) {
            var ll = text[i].split(',');
            if (ll.length < 2) {
                continue;
            }
            coords.push(new L.LatLng(ll[1], ll[0]));
        }
        return coords;
    },*/
});
<commit_msg>Json Dictionary populated from FEMA<commit_after>/* The MIT License (MIT)
Copyright (c) 2016 The MITRE Corporation

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.
*/

/* National Weather Service Icons */
/* Makes use of Leaflet JS: http://leafletjs.com/ */
/* SVG Icons courtesy of GEOHuntsville: http://geohuntsville.org/page/geoq */

/* Dependent on L.Marker.AutoResizeSVG found at
   http://github.com/john-kilgo/L.Marker.AutoResizeSVG
   Include marker-resize-svg.js in your HTML document */

L.NWSIconsLayer = L.GeoJSON.extend({
    // Options are JSON object found in database
    options: {
        debug: true
    },

    // NOTE: A possible way to organize (possible list) of icons?
    _icons: {
        statement : {
            flood : "StatementFloodOutlineHaloed.svg",
            tornado : "StatementHurricaneOutlineHaloed.svg",
            hurricane : "StatementHurricaneOutlineHaloed.svg",
            tropicalStorm : "StatementTropicalStormOutlineHaloed.svg"
        },
        warning : {
            evacuate : "warningEvacuateImmediatelyHaloed.svg",
            fire : "warningFireOutlineHaloed.svg",
            flood : "warningFloodOutlineHaloed.svg",
            hurricane : "warningHurricaneOutlineHaloed.svg",
            thunderstorm : "warningSevereThunderstormOutlineHaloed.svg",
            tropicalStorm : "warningTropicalStormOutlineHaloed1.svg",
            tsunami : "warningTsumaniDraftHaloed.svg"
        },
        watch : {
            fire : "watchFireOutlineHaloed.svg",
            flood : "watchFloodOutlineHaloed.svg",
            hurricane : "watchHurricaneOutlineHaloed.svg",
            thunderstorm : "watchSevereThunderstormOutlineHaloed.svg",
            tornado : "watchTornadoColorOutlineHaloed.svg",
            tropicalStorm : "watchTropicalStormOutlineHaloed.svg",
            winterStorm : "watchWinterStormHaloed.svg"
        },
    },

    initialize: function (load, map, options) {
        // Merge options together
        L.Util.setOptions(this, options);

        if (site_settings.FEMA_IPAWS) {
            L.Util.setOptions(this, site_settings.FEMA_IPAWS);
            console.log(this.options);
        } else {
            console.error("NWS Icons: Fatal Error. site_settings missing. Please visit GeoQ Admin site and add FEMA_IPAWS json settings object.")
            return;
        }

        // Markers to add to map
        this._layers = {};
        // Our map
        this._map = map;

        if (this._map) {
            this.NWSLayerGroup.addTo(this._map);

            // When map moves update bounds
            var _this = this; // Set the context of the event handler
            this._map.on('moveend', function() {
                _this.geocode();
                _this.load(_this.parseIPAWS);
            });
        }

        // Map adjusts onload triggering the moveend event handler several times
        // this section may therefore be redundant?
        /*if (load) {
            //this.addMediaQ(options);
            this.geocode();
            this.load(this.testCallBack);
        }*/
    },

    // Gets the bounds of the Workcell and calls for GeoCode info
    geocode: function() {
        var map = this._map;
        var bounds = map.getBounds();

        var ringObject = '{"rings":[[[' +
                bounds._southWest.lng + ',' + bounds._northEast.lat + '],[' +
                bounds._northEast.lng + ',' + bounds._northEast.lat + '],[' +
                bounds._northEast.lng + ',' + bounds._southWest.lat + '],[' +
                bounds._southWest.lng + ',' + bounds._southWest.lat + '],[' +
                bounds._southWest.lng + ',' + bounds._northEast.lat + ']]],' +
                '"spatialReference":{"wkid":4326}}';

        var url = "/geoq/proxy/https://tigerweb.geo.census.gov/arcgis/rest/services/Generalized_ACS2015/State_County/MapServer/11/query?where=&text=&objectIds=&time=&geometry=" + ringObject + "&geometryType=esriGeometryPolygon&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=GEOID&returnGeometry=false&returnTrueCurves=false&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&resultOffset=&resultRecordCount=&f=pjson";

        $.ajax({
            type: 'GET',
            context: this,
            url: url,
            dataType: 'json',
        })
        .done(this._geocode)
        .fail(this.ajaxError)

        /// PArse out and generate SAME codes and put into array
        //this._sameCodes <<<< John will generate

    },

    // Finds and saves SAME codes
    _geocode: function(data) {
        var features = data.features;
        this._sameCodes = [];

        for (var i=0; i < features.length; i++) {
            var tmp = features[i]["attributes"]["GEOID"];
            tmp = tmp.toString();
            // Prepend '0' in order to convert FIPS 5-1 to NWS SAME code
            tmp = '0' + tmp;
            this._sameCodes.push(tmp);
        }
    },

    // Loads the FEMA list server
    load: function(callback) {
        var options = this.options;

        if (!options.FEMAkey) {
            log.error("No key set for NWS Cap messages");
            console.error("No key set for NWS Cap messages");
            return;
        }

        $.ajax({
            type: "POST",
            url: "/geoq/api/geo/ipaws",
            context: this,
            data: {develop: true, key: this.options.FEMAkey}
        }).done(callback)
        .fail(this.ajaxError);
    },

    // On add of the layer
   /* addMediaQ: function(options) {
        var _this = this;
        // Below is the function called on each piece of data.
        var cb = function(data) { _this._addMediaQ(data, this.options); };
        this.loadMediaQ(cb, options);
    },
    // Parses JSON
    _addMediaQ: function(data, options) {
        L.MediaQLayer.parseJSON(data, this);
        if (!this) return;

        this.addTo(this._map);
    },*/

    // NWS Callback IPAWS Parse
    parseIPAWS: function(data) {
        this._jsonData = [];
        var sameArray = [];
        var control;
        var alerts = data.getElementsByTagName("alert");
        console.log(alerts);
        for (var i = 0; i < alerts.length; i++) {
            control = false;
            var info = alerts[i].getElementsByTagName("info");
            var area = info[0].getElementsByTagName("area");
            var geocodes = area[0].getElementsByTagName("geocode");
            var polygon = area[0].getElementsByTagName("polygon");

            if (info && area && geocodes && polygon && this._sameCodes) {
                for (var j = 0; j < geocodes.length; j++) {
                    if (geocodes[j].childNodes[0].innerHTML == "SAME" && control != true) {
                        for (var k = 0; k < this._sameCodes.length; k++) {
                            if (this._sameCodes[k] == geocodes[j].childNodes[1].innerHTML) {
                                control = true;
                            }
                        }

                    }
                }
            }

            if (control) {
                var tmpJson = {};
                console.log("here");
                console.log(info[0].getElementsByTagName("event")[0].innerHTML);
                tmpJson["identifier"] = String(alerts[i].getElementsByTagName("identifier")[0].innerHTML);
                tmpJson["sent"] = alerts[i].getElementsByTagName("sent")[0].innerHTML;
                tmpJson["status"] = alerts[i].getElementsByTagName("status")[0].innerHTML;
                tmpJson["event"] = info[0].getElementsByTagName("event")[0].innerHTML;
                tmpJson["severity"] = info[0].getElementsByTagName("severity")[0].innerHTML;
                tmpJson["certainty"] = info[0].getElementsByTagName("certainty")[0].innerHTML;
                tmpJson["effective"] = info[0].getElementsByTagName("effective")[0].innerHTML;
                tmpJson["onset"] = info[0].getElementsByTagName("onset")[0].innerHTML;
                tmpJson["expires"] = info[0].getElementsByTagName("expires")[0].innerHTML;
                tmpJson["headline"] = info[0].getElementsByTagName("headline")[0].innerHTML;
                tmpJson["description"] = info[0].getElementsByTagName("description")[0].innerHTML;
                tmpJson["instruction"] = info[0].getElementsByTagName("instruction")[0].innerHTML;

                var mapData, jsonMapData = [];
                var rawData = polygon[0].innerHTML;
                mapData = rawData.split(" ");

                for (var j = 0; j < mapData.length; j++) {
                    var latlong = mapData[i].split(",");
                    var jsonLatLong = {};
                    jsonLatLong["lat"] = latlong[0];
                    jsonLatLong["long"] = latlong[1];

                    jsonMapData.push(jsonLatLong);
                }

                //tmpJson["msgtype"] = alerts[i].getElementsByTagName("msgtype")[0].innerHTML;

                tmpJson["coordinates"] = jsonMapData;

                this._jsonData.push(tmpJson);

            }

            console.log(this._jsonData);

        }

    },
    // If an ajax error occurs
    ajaxError: function (resultobj) {
        console.error("Ajax error.");
        console.log(resultobj);
        log.error("Request called for, but no valid response was received from the server, result:", resultobj);
    },
    // Where icons/paths are stored
    NWSLayerGroup: L.layerGroup(),
    // IDs of layers??
    layer_ids: {},

// begin break with old code in extend

    parseJSON: function (data, layer){
        var result;
        if (typeof data=="object") {
            result = data;
        } else {
            try {
                result = JSON.parse(data);
            } catch (ex){
                log.error("Error parsing JSON returned from server");
                return;
            }
        }

        layer.options.onEachFeature = function(feature, layer) {
            L.MediaQLayer.onEachFeature(feature, layer, layer.options, this);
        };

        // layer.options.style = leaflet_helper.constructors.polygonStyleBuilderCallback;
        layer.pointToLayer = function(feature, latlng) {
            return L.MediaQLayer.iconBuilderCallback(feature, latlng, layer);
        };

        layer.addData(data);
    },

    // Make icon and place in marker.
    iconBuilderCallback: function(feature, latlng, layerConfig){
        var iconX = 15;
        var iconY = 24;
        var iconAnchor = null;

        layerConfig = layerConfig || {geojson_layer_count:1, name:'MediaQ Layer'};

        var iconUrl = this.options.iconUrl || "";

        //Build the icon injects
        var iconData = {
            iconUrl: iconUrl,
            iconSize: new L.Point(iconX, iconY),
            text: layerConfig.name
        };
        if (iconAnchor) iconData.iconAnchor = iconAnchor;
        var icon = new MapMarker(iconData);

        //Construct the final Icon
        return L.rotatedMarker(latlng, {icon: icon});
    },

    // Polygon Style
    /*polygonStyleBuilderCallback: function(feature) {
        var polyFillColor = '#ff0000';

        var style = {
            weight: 2,
            opacity: 1,
            color: 'white',
            fillOpacity: 0.1,
            fillColor: polyFillColor};

        return style;
    },*/

    // Assign popups to each feature
    onEachFeature: function (feature, layer, layerConfig, mediaqOptions) {
        if (feature.properties) {
            var popupContent = "";
            if (feature.properties.popupContent) {
                popupContent = feature.properties.popupContent;
            } else if (feature.properties.vid) {
                popupContent = L.MediaQLayer.clean("MediaQ Id: " + feature.properties.vid);
                if (feature.properties.href){
                    var link = L.MediaQLayer.clean(feature.properties.href); //Strip out any offending
                    popupContent = "
MediaQ Video
"+
                        "
<video width='320' height='240' controls><source src='"+link+"' type='video/mp4'></video>"+
                        "
<button type='button' class='btn btn-small' " +
                        "onclick='L.MediaQLayer.displayHidePath(\"" + feature.properties.vid + "\", \"" +
                        mediaqOptions.url + mediaqOptions.metadata_link + "\", \"" +
                        mediaqOptions.key + "\");' >Display/Hide Path</button>
";
                }
            }
            if (popupContent && _.isString(popupContent)) {

                if (!popupContent.indexOf("")){
                    if (layerConfig && layerConfig.name) {
                        if (!feature.properties.id) {
                            feature.properties.id = leaflet_helper.id_count++;
                        }
                        var id = feature.properties.id;
                        popupContent += L.MediaQLayer.addLinksToPopup(layerConfig.name, id, true, false);
                    }
                }
                layer.bindPopup(popupContent);
            }
            if (feature.properties.heading && parseInt(feature.properties.heading) && layer.options){
                layer.options.angle = parseInt(feature.properties.heading);
            }
        }
    },

    // Path of video
    /* displayHidePath: function(vid, queryurl, key) {
        var layer_ids = this.prototype.layer_ids;
        var ourlayergroup = this.prototype.mediaqLayerGroup;

        if (layer_ids[vid]) {
            // remove layer from layer group
            var layer = ourlayergroup.getLayer(layer_ids[vid]);
            ourlayergroup.removeLayer(layer);
            delete layer_ids[vid];
            return;
        }
        var params = {'VID':vid};
        var url = queryurl.replace(/{[^{}]+}/g, function(k) {
            return params[k.replace(/[{}]+/g, "")] || "";
        });

        var cb = function(data) {
            try {
                var markerOptions = { radius: 4, fillColor: "#ff0000", color: "#f00", weight: 1, opacity: 1};
                var newlayer = L.geoJson(data, {
                    pointToLayer: function (feature, latlng) {
                        return L.circleMarker(latlng, markerOptions);
                    }
                });
                newlayer.addTo(ourlayergroup);
                var id = ourlayergroup.getLayerId(newlayer);
                layer_ids[vid] = id;
            } catch (ex){
                log.error("Error parsing JSON returned from server");
                return;
            }
        };

        var error = function(data) {
            log.error("got error");
        };

        $.ajax({
            type: 'GET',
            url: leaflet_helper.proxify(url),
            headers: {
                'X-API-KEY': key
            },
            dataType: 'json',
            success: cb,
            error: error
        });
    },*/
    // Add links to popup (not needed)
    /*addLinksToPopup: function (layerName,id,useMove,useHide,useDrop) {

        var spanLink = ""+layerName+"";
        spanLink += ""+id+"";
        var output = "";
        if (useMove) {
            output += "
Click on a feature to link this to it"+spanLink+""
        }
        if (useHide) {
            output += "
Hide this Item"+spanLink+"";
        }
        if (useDrop) {
            output += "
"+spanLink+"";
        }
        if (output) output = "
"+output;

        return output;

    },*/
    /* Rewrite to clean once data received
    clean: function (text) {
        return jQuery("
"+text+"
").text() || "";
    },
    // ??????
    getLatLngs: function (xml) {
        var el = xml.getElementsByTagName('coordinates');
        var coords = [];
        for (var j = 0; j < el.length; j++) {
            // text might span many childNodes
            coords = coords.concat(this._read_coords(el[j]));
        }
        return coords;
    },
    // ???????
    _read_coords: function (el) {
        var text = '', coords = [], i;
        for (i = 0; i < el.childNodes.length; i++) {
            text = text + el.childNodes[i].nodeValue;
        }
        text = text.split(/[\s\n]+/);
        for (i = 0; i < text.length; i++) {
            var ll = text[i].split(',');
            if (ll.length < 2) {
                continue;
            }
            coords.push(new L.LatLng(ll[1], ll[0]));
        }
        return coords;
    },*/
});
<|endoftext|>


<commit_before>Template.register.rendered = function () {
    /*
    * Reset form select field values
    * to prevent an edge case bug for code push
    * where accommodations value was undefined
    */

    $('#age').val('');
    $('#registration_type').val('');
    $('#accommodations').val('');
    $('#carbon-tax').val('');
};

Template.register.helpers({
    'price': function () {
        /*
        * Get the dynamically calculated registration fee.
        */

        //Set the registration object
        // from current registration details.
        try {
            var registration = {
                ageGroup: ageGroupVar.get(),
                type: registrationTypeVar.get(),
                accommodations: accommodationsVar.get(),
                days: daysVar.get(),
                firstTimeAttender: firstTimeAttenderVar.get(),
                linens: linensVar.get(),
                createdAt: new Date(),
                carbonTax: carbonTaxVar.get()
            };
        } catch (error) {
            console.log(error.message);
        }

        // Calculate the price
        try {
            var registrationPrice = calculateRegistrationPrice(registration);
        } catch (error) {
            console.log(error.message);
        }

        return registrationPrice;
    }
});

Template.register.events({
    'change form': function () {
        // Make sure all reactive vars are up to date.
        setReactiveVars();
    },
    'keyup #carbon-tax': function () {
        setReactiveVars();
    }
});
<commit_msg>Add donation field to calculation<commit_after>Template.register.rendered = function () {
    /*
    * Reset form select field values
    * to prevent an edge case bug for code push
    * where accommodations value was undefined
    */

    $('#age').val('');
    $('#registration_type').val('');
    $('#accommodations').val('');
    $('#carbon-tax').val('');
};

Template.register.helpers({
    'price': function () {
        /*
        * Get the dynamically calculated registration fee.
        */

        //Set the registration object
        // from current registration details.
        try {
            var registration = {
                ageGroup: ageGroupVar.get(),
                type: registrationTypeVar.get(),
                accommodations: accommodationsVar.get(),
                days: daysVar.get(),
                firstTimeAttender: firstTimeAttenderVar.get(),
                linens: linensVar.get(),
                createdAt: new Date(),
                carbonTax: carbonTaxVar.get(),
                donation: donationVar.get()
            };
        } catch (error) {
            console.log(error.message);
        }

        // Calculate the price
        try {
            var registrationPrice = calculateRegistrationPrice(registration);
        } catch (error) {
            console.log(error.message);
        }

        return registrationPrice;
    }
});

Template.register.events({
    'change form': function () {
        // Make sure all reactive vars are up to date.
        setReactiveVars();
    },
    'keyup #carbon-tax': function () {
        setReactiveVars();
    }
});
<|endoftext|>


<commit_before>'use strict'

// store keys outside of this instance
const TOKEN_KEYS = {}

/**
 *
 */
class CloudFoundryEnvironmentAdapter {

    constructor() {
        this._vcap_application = JSON.parse(process.env.VCAP_APPLICATION || '{}')
    }

    /**
     *
     * @returns {String} the unique id of the current application
     */
    getApplicationId() {
        return this._vcap_application.application_id
    }

    /**
     *
     * @returns {String} the url of the cloudfoundry cloud controller
     */
    getCloudControllerUrl() {
        return this._vcap_application.cf_api
    }

    /**
     *
     * @returns {String} the url of the info endpoint of the cloud controller
     */
    getCloudControllerInfoUrl() {
        return [
            this.getCloudControllerUrl(),
            'info'
        ].join('/')
    }

    /**
     *
     * @returns {String} the url of th permissions endpoint of the cloud controller
     */
    getPermissionsUrl() {
        return [
            this.getCloudControllerUrl(),
            'v2',
            'apps',
            this.getApplicationId(),
            'permissions'
        ].join('/')
    }
}

module.exports = new CloudFoundryEnvironmentAdapter()<commit_msg>chore: remove unused token keys field<commit_after>'use strict'

/**
 *
 */
class CloudFoundryEnvironmentAdapter {

    constructor() {
        this._vcap_application = JSON.parse(process.env.VCAP_APPLICATION || '{}')
    }

    /**
     *
     * @returns {String} the unique id of the current application
     */
    getApplicationId() {
        return this._vcap_application.application_id
    }

    /**
     *
     * @returns {String} the url of the cloudfoundry cloud controller
     */
    getCloudControllerUrl() {
        return this._vcap_application.cf_api
    }

    /**
     *
     * @returns {String} the url of the info endpoint of the cloud controller
     */
    getCloudControllerInfoUrl() {
        return [
            this.getCloudControllerUrl(),
            'info'
        ].join('/')
    }

    /**
     *
     * @returns {String} the url of th permissions endpoint of the cloud controller
     */
    getPermissionsUrl() {
        return [
            this.getCloudControllerUrl(),
            'v2',
            'apps',
            this.getApplicationId(),
            'permissions'
        ].join('/')
    }
}

module.exports = new CloudFoundryEnvironmentAdapter()<|endoftext|>


<commit_before>function PrinterStateViewModel(loginStateViewModel) {
    var self = this;

    self.loginState = loginStateViewModel;

    self.stateString = ko.observable(undefined);
    self.isErrorOrClosed = ko.observable(undefined);
    self.isOperational = ko.observable(undefined);
    self.isPrinting = ko.observable(undefined);
    self.isPaused = ko.observable(undefined);
    self.isError = ko.observable(undefined);
    self.isReady = ko.observable(undefined);
    self.isLoading = ko.observable(undefined);
    self.isSdReady = ko.observable(undefined);

    self.filename = ko.observable(undefined);
    self.progress = ko.observable(undefined);
    self.filesize = ko.observable(undefined);
    self.filepos = ko.observable(undefined);
    self.printTime = ko.observable(undefined);
    self.printTimeLeft = ko.observable(undefined);
    self.sd = ko.observable(undefined);
    self.timelapse = ko.observable(undefined);

    self.filament = ko.observableArray([]);
    self.estimatedPrintTime = ko.observable(undefined);

    self.currentHeight = ko.observable(undefined);

    self.estimatedPrintTimeString = ko.computed(function() {
        if (!self.estimatedPrintTime())
            return "-";
        return formatDuration(self.estimatedPrintTime());
    });
    self.byteString = ko.computed(function() {
        if (!self.filesize())
            return "-";
        var filepos = self.filepos() ? formatSize(self.filepos()) : "-";
        return filepos + " / " + formatSize(self.filesize());
    });
    self.heightString = ko.computed(function() {
        if (!self.currentHeight())
            return "-";
        return _.sprintf("%.02fmm", self.currentHeight());
    });
    self.printTimeString = ko.computed(function() {
        if (!self.printTime())
            return "-";
        return formatDuration(self.printTime());
    });
    self.printTimeLeftString = ko.computed(function() {
        if (!self.printTimeLeft())
            return "-";
        return formatDuration(self.printTimeLeft());
    });
    self.progressString = ko.computed(function() {
        if (!self.progress())
            return 0;
        return self.progress();
    });
    self.pauseString = ko.computed(function() {
        if (self.isPaused())
            return "Continue";
        else
            return "Pause";
    });

    self.timelapseString = ko.computed(function() {
        var timelapse = self.timelapse();

        if (!timelapse || !timelapse.hasOwnProperty("type"))
            return "-";

        var type = timelapse["type"];
        if (type == "zchange") {
            return "On Z Change";
        } else if (type == "timed") {
            return "Timed (" + timelapse["options"]["interval"] + "s)";
        } else {
            return "-";
        }
    });

    self.fromCurrentData = function(data) {
        self._fromData(data);
    };

    self.fromHistoryData = function(data) {
        self._fromData(data);
    };

    self.fromTimelapseData = function(data) {
        self.timelapse(data);
    };

    self._fromData = function(data) {
        self._processStateData(data.state);
        self._processJobData(data.job);
        self._processProgressData(data.progress);
        self._processZData(data.currentZ);
    };

    self._processStateData = function(data) {
        self.stateString(data.stateString);
        self.isErrorOrClosed(data.flags.closedOrError);
        self.isOperational(data.flags.operational);
        self.isPaused(data.flags.paused);
        self.isPrinting(data.flags.printing);
        self.isError(data.flags.error);
        self.isReady(data.flags.ready);
        self.isSdReady(data.flags.sdReady);
    };

    self._processJobData = function(data) {
        if (data.file) {
            self.filename(data.file.name);
            self.filesize(data.file.size);
            self.sd(data.file.origin == "sdcard");
        } else {
            self.filename(undefined);
            self.filesize(undefined);
            self.sd(undefined);
        }

        self.estimatedPrintTime(data.estimatedPrintTime);

        var result = [];
        if (data.filament && typeof(data.filament) == "object" && _.keys(data.filament).length > 0) {
            var i = 0;
            do {
                var key = "tool" + i;
                if (data.filament[key].hasOwnProperty("length") && data.filament[key].length > 0) {
                    result.push({
                        name: ko.observable("Tool " + i),
                        data: ko.observable(data.filament[key])
                    });
                }
                i++;
            } while (data.filament.hasOwnProperty("tool" + i));
        }
        self.filament(result);
    };

    self._processProgressData = function(data) {
        if (data.completion) {
            self.progress(data.completion);
        } else {
            self.progress(undefined);
        }
        self.filepos(data.filepos);
        self.printTime(data.printTime);
        self.printTimeLeft(data.printTimeLeft);
    };

    self._processZData = function(data) {
        self.currentHeight(data);
    };

    self.print = function() {
        var restartCommand = function() {
            self._jobCommand("restart");
        };

        if (self.isPaused()) {
            $("#confirmation_dialog .confirmation_dialog_message").text("This will restart the print job from the beginning.");
            $("#confirmation_dialog .confirmation_dialog_acknowledge").unbind("click");
            $("#confirmation_dialog .confirmation_dialog_acknowledge").click(function(e) {e.preventDefault(); $("#confirmation_dialog").modal("hide"); restartCommand(); });
            $("#confirmation_dialog").modal("show");
        } else {
            self._jobCommand("start");
        }

    };

    self.pause = function() {
        self._jobCommand("pause");
    };

    self.cancel = function() {
        self._jobCommand("cancel");
    };

    self._jobCommand = function(command) {
        $.ajax({
            url: API_BASEURL + "job",
            type: "POST",
            dataType: "json",
            contentType: "application/json; charset=UTF-8",
            data: JSON.stringify({command: command})
        });
    }
}
<commit_msg>Made metadata reading in client a bit more resilient against errors<commit_after>function PrinterStateViewModel(loginStateViewModel) {
    var self = this;

    self.loginState = loginStateViewModel;

    self.stateString = ko.observable(undefined);
    self.isErrorOrClosed = ko.observable(undefined);
    self.isOperational = ko.observable(undefined);
    self.isPrinting = ko.observable(undefined);
    self.isPaused = ko.observable(undefined);
    self.isError = ko.observable(undefined);
    self.isReady = ko.observable(undefined);
    self.isLoading = ko.observable(undefined);
    self.isSdReady = ko.observable(undefined);

    self.filename = ko.observable(undefined);
    self.progress = ko.observable(undefined);
    self.filesize = ko.observable(undefined);
    self.filepos = ko.observable(undefined);
    self.printTime = ko.observable(undefined);
    self.printTimeLeft = ko.observable(undefined);
    self.sd = ko.observable(undefined);
    self.timelapse = ko.observable(undefined);

    self.filament = ko.observableArray([]);
    self.estimatedPrintTime = ko.observable(undefined);

    self.currentHeight = ko.observable(undefined);

    self.estimatedPrintTimeString = ko.computed(function() {
        if (!self.estimatedPrintTime())
            return "-";
        return formatDuration(self.estimatedPrintTime());
    });
    self.byteString = ko.computed(function() {
        if (!self.filesize())
            return "-";
        var filepos = self.filepos() ? formatSize(self.filepos()) : "-";
        return filepos + " / " + formatSize(self.filesize());
    });
    self.heightString = ko.computed(function() {
        if (!self.currentHeight())
            return "-";
        return _.sprintf("%.02fmm", self.currentHeight());
    });
    self.printTimeString = ko.computed(function() {
        if (!self.printTime())
            return "-";
        return formatDuration(self.printTime());
    });
    self.printTimeLeftString = ko.computed(function() {
        if (!self.printTimeLeft())
            return "-";
        return formatDuration(self.printTimeLeft());
    });
    self.progressString = ko.computed(function() {
        if (!self.progress())
            return 0;
        return self.progress();
    });
    self.pauseString = ko.computed(function() {
        if (self.isPaused())
            return "Continue";
        else
            return "Pause";
    });

    self.timelapseString = ko.computed(function() {
        var timelapse = self.timelapse();

        if (!timelapse || !timelapse.hasOwnProperty("type"))
            return "-";

        var type = timelapse["type"];
        if (type == "zchange") {
            return "On Z Change";
        } else if (type == "timed") {
            return "Timed (" + timelapse["options"]["interval"] + "s)";
        } else {
            return "-";
        }
    });

    self.fromCurrentData = function(data) {
        self._fromData(data);
    };

    self.fromHistoryData = function(data) {
        self._fromData(data);
    };

    self.fromTimelapseData = function(data) {
        self.timelapse(data);
    };

    self._fromData = function(data) {
        self._processStateData(data.state);
        self._processJobData(data.job);
        self._processProgressData(data.progress);
        self._processZData(data.currentZ);
    };

    self._processStateData = function(data) {
        self.stateString(data.stateString);
        self.isErrorOrClosed(data.flags.closedOrError);
        self.isOperational(data.flags.operational);
        self.isPaused(data.flags.paused);
        self.isPrinting(data.flags.printing);
        self.isError(data.flags.error);
        self.isReady(data.flags.ready);
        self.isSdReady(data.flags.sdReady);
    };

    self._processJobData = function(data) {
        if (data.file) {
            self.filename(data.file.name);
            self.filesize(data.file.size);
            self.sd(data.file.origin == "sdcard");
        } else {
            self.filename(undefined);
            self.filesize(undefined);
            self.sd(undefined);
        }

        self.estimatedPrintTime(data.estimatedPrintTime);

        var result = [];
        if (data.filament && typeof(data.filament) == "object" && _.keys(data.filament).length > 0) {
            var i = 0;
            do {
                var key = "tool" + i;
                if (data.filament.hasOwnProperty(key) && data.filament[key].hasOwnProperty("length") && data.filament[key].length > 0) {
                    result.push({
                        name: ko.observable("Tool " + i),
                        data: ko.observable(data.filament[key])
                    });
                }
                i++;
            } while (data.filament.hasOwnProperty("tool" + i));
        }
        self.filament(result);
    };

    self._processProgressData = function(data) {
        if (data.completion) {
            self.progress(data.completion);
        } else {
            self.progress(undefined);
        }
        self.filepos(data.filepos);
        self.printTime(data.printTime);
        self.printTimeLeft(data.printTimeLeft);
    };

    self._processZData = function(data) {
        self.currentHeight(data);
    };

    self.print = function() {
        var restartCommand = function() {
            self._jobCommand("restart");
        };

        if (self.isPaused()) {
            $("#confirmation_dialog .confirmation_dialog_message").text("This will restart the print job from the beginning.");
            $("#confirmation_dialog .confirmation_dialog_acknowledge").unbind("click");
            $("#confirmation_dialog .confirmation_dialog_acknowledge").click(function(e) {e.preventDefault(); $("#confirmation_dialog").modal("hide"); restartCommand(); });
            $("#confirmation_dialog").modal("show");
        } else {
            self._jobCommand("start");
        }

    };

    self.pause = function() {
        self._jobCommand("pause");
    };

    self.cancel = function() {
        self._jobCommand("cancel");
    };

    self._jobCommand = function(command) {
        $.ajax({
            url: API_BASEURL + "job",
            type: "POST",
            dataType: "json",
            contentType: "application/json; charset=UTF-8",
            data: JSON.stringify({command: command})
        });
    }
}
<|endoftext|>


<commit_before>System.config({
  baseURL: "./",
  defaultJSExtensions: true,
  transpiler: "babel",
  babelOptions: {
    "stage": 1,
    "optional": [
      "runtime",
      "optimisation.modules.system"
    ]
  },
  paths: {
    "github:*": "jspm_packages/github/*",
    "npm:*": "jspm_packages/npm/*"
  },
  buildCSS: true,
  separateCSS: true,

  map: {
    "AngularStompDK": "github:davinkevin/AngularStompDK@0.3.4",
    "angular": "github:angular/bower-angular@1.4.8",
    "angular-animate": "github:angular/bower-angular-animate@1.4.8",
    "angular-bootstrap": "github:angular-ui/bootstrap-bower@0.14.3",
    "angular-hotkeys": "github:chieffancypants/angular-hotkeys@1.4.5",
    "angular-loading-bar": "github:chieffancypants/angular-loading-bar@0.8.0",
    "angular-mocks": "npm:angular-mocks@1.4.8",
    "angular-notification": "github:neoziro/angular-notification@1.1.1",
    "angular-route": "github:angular/bower-angular-route@1.4.8",
    "angular-sanitize": "github:angular/bower-angular-sanitize@1.4.8",
    "angular-touch": "github:angular/bower-angular-touch@1.4.8",
    "angular-truncate": "github:sparkalow/angular-truncate@master",
    "animate.css": "github:daneden/animate.css@3.5.0",
    "babel": "npm:babel-core@5.8.34",
    "babel-runtime": "npm:babel-runtime@5.8.34",
    "bootstrap-less": "github:distros/bootstrap-less@3.3.9",
    "clean-css": "npm:clean-css@3.4.8",
    "clipboard": "github:zenorocha/clipboard.js@1.5.5",
    "core-js": "npm:core-js@1.2.6",
    "css": "github:systemjs/plugin-css@0.1.20",
    "font-awesome": "github:components/font-awesome@4.5.0",
    "highcharts-ng": "github:pablojim/highcharts-ng@0.0.11",
    "highcharts-release": "github:highcharts/highcharts-release@4.1.10",
    "ionicons": "github:driftyco/ionicons@2.0.1",
    "lodash": "github:lodash/lodash@3.10.1",
    "ng-file-upload": "github:danialfarid/ng-file-upload@9.1.2",
    "ng-tags-input": "github:mbenford/ngTagsInput@3.0.0",
    "ngstorage": "github:gsklee/ngStorage@0.3.10",
    "restangular": "github:mgonto/restangular@1.5.1",
    "sockjs-client": "github:sockjs/sockjs-client@0.3.4",
    "stomp-websocket": "github:jmesnil/stomp-websocket@2.3.4",
    "systemjs/plugin-text": "github:systemjs/plugin-text@0.0.2",
    "text": "github:systemjs/plugin-text@0.0.2",
    "videogular": "github:videogular/bower-videogular@1.4.0",
    "videogular-buffering": "github:videogular/bower-videogular-buffering@1.4.0",
    "videogular-controls": "github:videogular/bower-videogular-controls@1.4.0",
    "videogular-overlay-play": "github:videogular/bower-videogular-overlay-play@1.4.0",
    "videogular-poster": "github:videogular/bower-videogular-poster@1.4.0",
    "videogular-themes-default": "github:videogular/bower-videogular-themes-default@1.4.0",
    "github:angular/bower-angular-animate@1.4.8": {
      "angular": "github:angular/bower-angular@1.4.8"
    },
    "github:angular/bower-angular-route@1.4.8": {
      "angular": "github:angular/bower-angular@1.4.8"
    },
    "github:angular/bower-angular-sanitize@1.4.8": {
      "angular": "github:angular/bower-angular@1.4.8"
    },
    "github:angular/bower-angular-touch@1.4.8": {
      "angular": "github:angular/bower-angular@1.4.8"
    },
    "github:chieffancypants/angular-hotkeys@1.4.5": {
      "angular": "github:angular/bower-angular@1.4.8"
    },
    "github:chieffancypants/angular-loading-bar@0.8.0": {
      "angular": "github:angular/bower-angular@1.4.8",
      "css": "github:systemjs/plugin-css@0.1.20"
    },
    "github:davinkevin/AngularStompDK@0.3.4": {
      "angular": "github:angular/bower-angular@1.4.8",
      "stomp-websocket": "github:jmesnil/stomp-websocket@2.3.4"
    },
    "github:distros/bootstrap-less@3.3.9": {
      "jquery": "github:components/jquery@2.1.4"
    },
    "github:jspm/nodelibs-assert@0.1.0": {
      "assert": "npm:assert@1.3.0"
    },
    "github:jspm/nodelibs-buffer@0.1.0": {
      "buffer": "npm:buffer@3.5.5"
    },
    "github:jspm/nodelibs-events@0.1.1": {
      "events": "npm:events@1.0.2"
    },
    "github:jspm/nodelibs-http@1.7.1": {
      "Base64": "npm:Base64@0.2.1",
      "events": "github:jspm/nodelibs-events@0.1.1",
      "inherits": "npm:inherits@2.0.1",
      "stream": "github:jspm/nodelibs-stream@0.1.0",
      "url": "github:jspm/nodelibs-url@0.1.0",
      "util": "github:jspm/nodelibs-util@0.1.0"
    },
    "github:jspm/nodelibs-https@0.1.0": {
      "https-browserify": "npm:https-browserify@0.0.0"
    },
    "github:jspm/nodelibs-os@0.1.0": {
      "os-browserify": "npm:os-browserify@0.1.2"
    },
    "github:jspm/nodelibs-path@0.1.0": {
      "path-browserify": "npm:path-browserify@0.0.0"
    },
    "github:jspm/nodelibs-process@0.1.2": {
      "process": "npm:process@0.11.2"
    },
    "github:jspm/nodelibs-stream@0.1.0": {
      "stream-browserify": "npm:stream-browserify@1.0.0"
    },
    "github:jspm/nodelibs-url@0.1.0": {
      "url": "npm:url@0.10.3"
    },
    "github:jspm/nodelibs-util@0.1.0": {
      "util": "npm:util@0.10.3"
    },
    "github:mbenford/ngTagsInput@3.0.0": {
      "angular": "github:angular/bower-angular@1.4.8",
      "css": "github:systemjs/plugin-css@0.1.20"
    },
    "github:mgonto/restangular@1.5.1": {
      "angular": "github:angular/bower-angular@1.4.8",
      "lodash": "npm:lodash@3.10.1"
    },
    "npm:amdefine@1.0.0": {
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "module": "github:jspm/nodelibs-module@0.1.0",
      "path": "github:jspm/nodelibs-path@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:assert@1.3.0": {
      "util": "npm:util@0.10.3"
    },
    "npm:babel-runtime@5.8.34": {
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:buffer@3.5.5": {
      "base64-js": "npm:base64-js@0.0.8",
      "child_process": "github:jspm/nodelibs-child_process@0.1.0",
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "ieee754": "npm:ieee754@1.1.6",
      "isarray": "npm:isarray@1.0.0",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:clean-css@3.4.8": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "commander": "npm:commander@2.8.1",
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "http": "github:jspm/nodelibs-http@1.7.1",
      "https": "github:jspm/nodelibs-https@0.1.0",
      "os": "github:jspm/nodelibs-os@0.1.0",
      "path": "github:jspm/nodelibs-path@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "source-map": "npm:source-map@0.4.4",
      "url": "github:jspm/nodelibs-url@0.1.0",
      "util": "github:jspm/nodelibs-util@0.1.0"
    },
    "npm:commander@2.8.1": {
      "child_process": "github:jspm/nodelibs-child_process@0.1.0",
      "events": "github:jspm/nodelibs-events@0.1.1",
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "graceful-readlink": "npm:graceful-readlink@1.0.1",
      "path": "github:jspm/nodelibs-path@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:core-js@1.2.6": {
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "path": "github:jspm/nodelibs-path@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "systemjs-json": "github:systemjs/plugin-json@0.1.0"
    },
    "npm:core-util-is@1.0.2": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0"
    },
    "npm:graceful-readlink@1.0.1": {
      "fs": "github:jspm/nodelibs-fs@0.1.2"
    },
    "npm:https-browserify@0.0.0": {
      "http": "github:jspm/nodelibs-http@1.7.1"
    },
    "npm:inherits@2.0.1": {
      "util": "github:jspm/nodelibs-util@0.1.0"
    },
    "npm:lodash@3.10.1": {
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:os-browserify@0.1.2": {
      "os": "github:jspm/nodelibs-os@0.1.0"
    },
    "npm:path-browserify@0.0.0": {
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:process@0.11.2": {
      "assert": "github:jspm/nodelibs-assert@0.1.0"
    },
    "npm:punycode@1.3.2": {
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:readable-stream@1.1.13": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "core-util-is": "npm:core-util-is@1.0.2",
      "events": "github:jspm/nodelibs-events@0.1.1",
      "inherits": "npm:inherits@2.0.1",
      "isarray": "npm:isarray@0.0.1",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "stream-browserify": "npm:stream-browserify@1.0.0",
      "string_decoder": "npm:string_decoder@0.10.31"
    },
    "npm:source-map@0.4.4": {
      "amdefine": "npm:amdefine@1.0.0",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:stream-browserify@1.0.0": {
      "events": "github:jspm/nodelibs-events@0.1.1",
      "inherits": "npm:inherits@2.0.1",
      "readable-stream": "npm:readable-stream@1.1.13"
    },
    "npm:string_decoder@0.10.31": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0"
    },
    "npm:url@0.10.3": {
      "assert": "github:jspm/nodelibs-assert@0.1.0",
      "punycode": "npm:punycode@1.3.2",
      "querystring": "npm:querystring@0.2.0",
      "util": "github:jspm/nodelibs-util@0.1.0"
    },
    "npm:util@0.10.3": {
      "inherits": "npm:inherits@2.0.1",
      "process": "github:jspm/nodelibs-process@0.1.2"
    }
  }
});
<commit_msg>fix(frontend): fixing the dependency version of highcharts and add override<commit_after>System.config({
  baseURL: "./",
  defaultJSExtensions: true,
  transpiler: "babel",
  babelOptions: {
    "stage": 1,
    "optional": [
      "runtime",
      "optimisation.modules.system"
    ]
  },
  paths: {
    "github:*": "jspm_packages/github/*",
    "npm:*": "jspm_packages/npm/*"
  },
  buildCSS: true,
  separateCSS: true,

  map: {
    "AngularStompDK": "github:davinkevin/AngularStompDK@0.3.4",
    "angular": "github:angular/bower-angular@1.4.8",
    "angular-animate": "github:angular/bower-angular-animate@1.4.8",
    "angular-bootstrap": "github:angular-ui/bootstrap-bower@0.14.3",
    "angular-hotkeys": "github:chieffancypants/angular-hotkeys@1.4.5",
    "angular-loading-bar": "github:chieffancypants/angular-loading-bar@0.8.0",
    "angular-mocks": "npm:angular-mocks@1.4.8",
    "angular-notification": "github:neoziro/angular-notification@1.1.1",
    "angular-route": "github:angular/bower-angular-route@1.4.8",
    "angular-sanitize": "github:angular/bower-angular-sanitize@1.4.8",
    "angular-touch": "github:angular/bower-angular-touch@1.4.8",
    "angular-truncate": "github:sparkalow/angular-truncate@master",
    "animate.css": "github:daneden/animate.css@3.5.0",
    "babel": "npm:babel-core@5.8.34",
    "babel-runtime": "npm:babel-runtime@5.8.34",
    "bootstrap-less": "github:distros/bootstrap-less@3.3.9",
    "clean-css": "npm:clean-css@3.4.8",
    "clipboard": "github:zenorocha/clipboard.js@1.5.5",
    "core-js": "npm:core-js@1.2.6",
    "css": "github:systemjs/plugin-css@0.1.20",
    "font-awesome": "github:components/font-awesome@4.5.0",
    "highcharts-ng": "github:pablojim/highcharts-ng@0.0.11",
    "highcharts-release": "github:highcharts/highcharts-release@4.1.9",
    "ionicons": "github:driftyco/ionicons@2.0.1",
    "lodash": "github:lodash/lodash@3.10.1",
    "ng-file-upload": "github:danialfarid/ng-file-upload@9.1.2",
    "ng-tags-input": "github:mbenford/ngTagsInput@3.0.0",
    "ngstorage": "github:gsklee/ngStorage@0.3.10",
    "restangular": "github:mgonto/restangular@1.5.1",
    "sockjs-client": "github:sockjs/sockjs-client@0.3.4",
    "stomp-websocket": "github:jmesnil/stomp-websocket@2.3.4",
    "systemjs/plugin-text": "github:systemjs/plugin-text@0.0.2",
    "text": "github:systemjs/plugin-text@0.0.2",
    "videogular": "github:videogular/bower-videogular@1.4.0",
    "videogular-buffering": "github:videogular/bower-videogular-buffering@1.4.0",
    "videogular-controls": "github:videogular/bower-videogular-controls@1.4.0",
    "videogular-overlay-play": "github:videogular/bower-videogular-overlay-play@1.4.0",
    "videogular-poster": "github:videogular/bower-videogular-poster@1.4.0",
    "videogular-themes-default": "github:videogular/bower-videogular-themes-default@1.4.0",
    "github:angular/bower-angular-animate@1.4.8": {
      "angular": "github:angular/bower-angular@1.4.8"
    },
    "github:angular/bower-angular-route@1.4.8": {
      "angular": "github:angular/bower-angular@1.4.8"
    },
    "github:angular/bower-angular-sanitize@1.4.8": {
      "angular": "github:angular/bower-angular@1.4.8"
    },
    "github:angular/bower-angular-touch@1.4.8": {
      "angular": "github:angular/bower-angular@1.4.8"
    },
    "github:chieffancypants/angular-hotkeys@1.4.5": {
      "angular": "github:angular/bower-angular@1.4.8"
    },
    "github:chieffancypants/angular-loading-bar@0.8.0": {
      "angular": "github:angular/bower-angular@1.4.8",
      "css": "github:systemjs/plugin-css@0.1.20"
    },
    "github:davinkevin/AngularStompDK@0.3.4": {
      "angular": "github:angular/bower-angular@1.4.8",
      "stomp-websocket": "github:jmesnil/stomp-websocket@2.3.4"
    },
    "github:distros/bootstrap-less@3.3.9": {
      "jquery": "github:components/jquery@2.1.4"
    },
    "github:jspm/nodelibs-assert@0.1.0": {
      "assert": "npm:assert@1.3.0"
    },
    "github:jspm/nodelibs-buffer@0.1.0": {
      "buffer": "npm:buffer@3.5.5"
    },
    "github:jspm/nodelibs-events@0.1.1": {
      "events": "npm:events@1.0.2"
    },
    "github:jspm/nodelibs-http@1.7.1": {
      "Base64": "npm:Base64@0.2.1",
      "events": "github:jspm/nodelibs-events@0.1.1",
      "inherits": "npm:inherits@2.0.1",
      "stream": "github:jspm/nodelibs-stream@0.1.0",
      "url": "github:jspm/nodelibs-url@0.1.0",
      "util": "github:jspm/nodelibs-util@0.1.0"
    },
    "github:jspm/nodelibs-https@0.1.0": {
      "https-browserify": "npm:https-browserify@0.0.0"
    },
    "github:jspm/nodelibs-os@0.1.0": {
      "os-browserify": "npm:os-browserify@0.1.2"
    },
    "github:jspm/nodelibs-path@0.1.0": {
      "path-browserify": "npm:path-browserify@0.0.0"
    },
    "github:jspm/nodelibs-process@0.1.2": {
      "process": "npm:process@0.11.2"
    },
    "github:jspm/nodelibs-stream@0.1.0": {
      "stream-browserify": "npm:stream-browserify@1.0.0"
    },
    "github:jspm/nodelibs-url@0.1.0": {
      "url": "npm:url@0.10.3"
    },
    "github:jspm/nodelibs-util@0.1.0": {
      "util": "npm:util@0.10.3"
    },
    "github:mbenford/ngTagsInput@3.0.0": {
      "angular": "github:angular/bower-angular@1.4.8",
      "css": "github:systemjs/plugin-css@0.1.20"
    },
    "github:mgonto/restangular@1.5.1": {
      "angular": "github:angular/bower-angular@1.4.8",
      "lodash": "npm:lodash@3.10.1"
    },
    "npm:amdefine@1.0.0": {
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "module": "github:jspm/nodelibs-module@0.1.0",
      "path": "github:jspm/nodelibs-path@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:assert@1.3.0": {
      "util": "npm:util@0.10.3"
    },
    "npm:babel-runtime@5.8.34": {
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:buffer@3.5.5": {
      "base64-js": "npm:base64-js@0.0.8",
      "child_process": "github:jspm/nodelibs-child_process@0.1.0",
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "ieee754": "npm:ieee754@1.1.6",
      "isarray": "npm:isarray@1.0.0",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:clean-css@3.4.8": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "commander": "npm:commander@2.8.1",
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "http": "github:jspm/nodelibs-http@1.7.1",
      "https": "github:jspm/nodelibs-https@0.1.0",
      "os": "github:jspm/nodelibs-os@0.1.0",
      "path": "github:jspm/nodelibs-path@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "source-map": "npm:source-map@0.4.4",
      "url": "github:jspm/nodelibs-url@0.1.0",
      "util": "github:jspm/nodelibs-util@0.1.0"
    },
    "npm:commander@2.8.1": {
      "child_process": "github:jspm/nodelibs-child_process@0.1.0",
      "events": "github:jspm/nodelibs-events@0.1.1",
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "graceful-readlink": "npm:graceful-readlink@1.0.1",
      "path": "github:jspm/nodelibs-path@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:core-js@1.2.6": {
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "path": "github:jspm/nodelibs-path@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "systemjs-json": "github:systemjs/plugin-json@0.1.0"
    },
    "npm:core-util-is@1.0.2": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0"
    },
    "npm:graceful-readlink@1.0.1": {
      "fs": "github:jspm/nodelibs-fs@0.1.2"
    },
    "npm:https-browserify@0.0.0": {
      "http": "github:jspm/nodelibs-http@1.7.1"
    },
    "npm:inherits@2.0.1": {
      "util": "github:jspm/nodelibs-util@0.1.0"
    },
    "npm:lodash@3.10.1": {
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:os-browserify@0.1.2": {
      "os": "github:jspm/nodelibs-os@0.1.0"
    },
    "npm:path-browserify@0.0.0": {
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:process@0.11.2": {
      "assert": "github:jspm/nodelibs-assert@0.1.0"
    },
    "npm:punycode@1.3.2": {
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:readable-stream@1.1.13": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "core-util-is": "npm:core-util-is@1.0.2",
      "events": "github:jspm/nodelibs-events@0.1.1",
      "inherits": "npm:inherits@2.0.1",
      "isarray": "npm:isarray@0.0.1",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "stream-browserify": "npm:stream-browserify@1.0.0",
      "string_decoder": "npm:string_decoder@0.10.31"
    },
    "npm:source-map@0.4.4": {
      "amdefine": "npm:amdefine@1.0.0",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:stream-browserify@1.0.0": {
      "events": "github:jspm/nodelibs-events@0.1.1",
      "inherits": "npm:inherits@2.0.1",
      "readable-stream": "npm:readable-stream@1.1.13"
    },
    "npm:string_decoder@0.10.31": {
      "buffer": "github:jspm/nodelibs-buffer@0.1.0"
    },
    "npm:url@0.10.3": {
      "assert": "github:jspm/nodelibs-assert@0.1.0",
      "punycode": "npm:punycode@1.3.2",
      "querystring": "npm:querystring@0.2.0",
      "util": "github:jspm/nodelibs-util@0.1.0"
    },
    "npm:util@0.10.3": {
      "inherits": "npm:inherits@2.0.1",
      "process": "github:jspm/nodelibs-process@0.1.2"
    }
  }
});
<|endoftext|>


<commit_before>import { GraduationRequirements } from '../database-controller/graduation-requirement/graduationRequirement';
import { createNewGradRequirement } from '../database-controller/graduation-requirement/methods';

export const populateGraduationRequirementsFixture = function populateGraduationRequirementsFixture() {
  populateComScienceFoundationRequirementsFixture();
  populateComSciITProfessionalismFixture();
  populateComSciMathScienceFixture();
};

const populateComScienceFoundationRequirementsFixture = function populateComScienceFoundationRequirementsFixture() {
  const requirementName = 'Computer Science Foundation';
  const modules = ['CS1010', 'CS1020', 'CS2010', 'CS1231', 'CS2100', 'CS2103T', 'CS2105', 'CS2106', 'CS3230'];
  const academicYearList = ['AY 2016/2017', 'AY 2015/2016'];

  createNewGradRequirement(requirementName, academicYearList, modules);
};

const populateComSciITProfessionalismFixture = function populateComSciITProfessionalismFixture() {
  const requirementName = 'IT Professionalism';
  const modules = ['IS1103', 'CS2101', 'ES2660'];
  const academicYearList = ['AY 2016/2017', 'AY 2015/2016'];

  createNewGradRequirement(requirementName, academicYearList, modules);
};

const populateComSciMathScienceFixture = function populateComSciMathScienceFixture()  {
  const requirementName = 'Mathematics and Sciences';
  const modules = ['MA1301', 'MA1521', 'MA1101R', 'ST2334', 'PC1221',
                   'CM1121', 'CM1131', 'CM1417', 'LSM1301', 'LSM1302',
                   'PC1141', 'PC1142', 'PC1143', 'PC1144', 'PC1221',
                   'PC1222', 'PC1432', 'MA2213','MA2214', 'CM1101', 'CM1111',
                   'CM1161', 'CM1191', 'CM1401', 'CM1402', 'CM1501', 'CM1502',
                   'LSM1303', 'PC1421', 'PC1431', 'PC1433', 'MA1104', 'MA2101',
                   'MA2108', 'MA2501', 'ST2132', 'ST2137'];
  const academicYearList = ['AY 2016/2017', 'AY 2015/2016'];

  createNewGradRequirement(requirementName, academicYearList, modules);
}
<commit_msg>ADD gradRequirementFixtures<commit_after>import { GraduationRequirements } from '../database-controller/graduation-requirement/graduationRequirement';
import { createNewGradRequirement } from '../database-controller/graduation-requirement/methods';

export const populateGraduationRequirementsFixture = function populateGraduationRequirementsFixture() {
  populateComScienceFoundationRequirementsFixture();
  populateComSciITProfessionalismFixture();
  populateComSciMathScienceFixture();
  populateTeamProjectFixture();
  populateIndustrialExperienceFixture();
};

const populateComScienceFoundationRequirementsFixture = function populateComScienceFoundationRequirementsFixture() {
  const requirementName = 'Computer Science Foundation';
  const modules = ['CS1010', 'CS1020', 'CS2010', 'CS1231', 'CS2100', 'CS2103T', 'CS2105', 'CS2106', 'CS3230'];

  createNewGradRequirement(requirementName, modules);
};

const populateComSciITProfessionalismFixture = function populateComSciITProfessionalismFixture() {
  const requirementName = 'IT Professionalism';
  const modules = ['IS1103', 'CS2101', 'ES2660'];

  createNewGradRequirement(requirementName, modules);
};

const populateComSciMathScienceFixture = function populateComSciMathScienceFixture()  {
  const requirementName = 'Mathematics and Sciences';
  const modules = ['MA1301', 'MA1521', 'MA1101R', 'ST2334', 'PC1221',
                   'CM1121', 'CM1131', 'CM1417', 'LSM1301', 'LSM1302',
                   'PC1141', 'PC1142', 'PC1143', 'PC1144', 'PC1221',
                   'PC1222', 'PC1432', 'MA2213','MA2214', 'CM1101', 'CM1111',
                   'CM1161', 'CM1191', 'CM1401', 'CM1402', 'CM1501', 'CM1502',
                   'LSM1303', 'PC1421', 'PC1431', 'PC1433', 'MA1104', 'MA2101',
                   'MA2108', 'MA2501', 'ST2132', 'ST2137'];

  createNewGradRequirement(requirementName, modules);
}

const populateTeamProjectFixture = function populateTeamProjectFixure() {
  const requirementName = 'Computer Systems Team Project';
  const modules = ['CS3201', 'CS3202'];

  createNewGradRequirement(requirementName, modules);
}

const populateIndustrialExperienceFixture = function populateIndustrialExperienceFixture()  {
  const requirementName = 'Industrial Experience Training';
  const modules = ['CP3880'];

  createNewGradRequirement(requirementName, modules);
}
<|endoftext|>