<commit_before>(function()
{
	'use strict';

	function resizeJumbotronElements()
	{
		resizeJumbotronElement(document.getElementById('jumbotron-video-fallback'));
		resizeJumbotronElement(document.getElementById('jumbotron-video'));
	}

	function resizeJumbotronElement(element)
	{
		var videoWidth = 1920;
		var videoHeight = 1080;
		var videoAspectRatio = videoWidth/videoHeight;

		if(!element)
		{
			return;
		}

		if(window.innerWidth / window.innerHeight > videoAspectRatio)
		{
			element.width = window.innerWidth;
			element.height = window.innerWidth / videoAspectRatio;
		}
		else
		{
			element.height = window.innerHeight;
			element.width = window.innerHeight * videoAspectRatio;
		}

		var horizontalMargin = (window.innerWidth - element.width) / 2;
		var verticalMargin = (window.innerHeight - element.height) / 2;

		element.style.marginLeft = horizontalMargin + 'px';
		element.style.marginTop = verticalMargin + 'px';
	}

	function fixEmail()
	{
		var anchor = document.getElementById('theemail');
		if(!anchor)
		{
			console.warn('fixEmail no anchor');
			return;
		}
		var encodedEmail = [68,80,79,85,66,68,85,33,74,72,79,66,68,74,80,66,87,66,84,15,68,80,78];
		anchor.innerHTML = encodedEmail
			.map(function(i)
			{
				return String.fromCharCode(i+31);
			})
			.join('');
		anchor.href = 'mailto:' + anchor.innerHTML;
	}

	function showJumbotronHeader()
	{
		var jumbotronHeader = document.getElementById('jumbotron-header');
		if(!jumbotronHeader)
		{
			console.warn('showJumbotronHeader no element');
			return;
		}
		jumbotronHeader.className += jumbotronHeader.className ? ' shown' : 'shown';
	}

	function waitForImageLoad()
	{
		var videoFallback = document.getElementById('jumbotron-video-fallback');
		if(videoFallback)
		{
			videoFallback.addEventListener("load", resizeJumbotronElements);
		}
	}

	function addVideo()
	{
		var container = document.getElementById('jumbotron-video-container');
		if(!container)
		{
			console.warn('addVideo: no container');
			return;
		}

		var video = document.createElement('video');
		video.id = 'jumbotron-video';
		video.autoPlay = true;
		video.loop = true;
		video.play();

		var sourceMP4 = document.createElement("source");
		sourceMP4.type = "video/mp4";
		sourceMP4.src = "app/static/video/head.mp4";
		video.appendChild(sourceMP4);

		var sourceOGG = document.createElement("source");
		sourceOGG.type = "video/webm";
		sourceOGG.src = "app/static/video/head.webm";
		video.appendChild(sourceOGG);

		container.appendChild(video);

		resizeJumbotronElement(video);
	}

	function writeSelfAge()
	{
		var msPerYear = 31557600000;
		var birthDate = new Date(1987,5,30);
  		var age = Math.floor((Date.now() - birthDate.getTime()) / msPerYear);

  		var ageElement = document.getElementById('profile-details-age');
  		if(ageElement)
  		{
  			ageElement.innerHTML = age;
  		}
	}

	document.addEventListener("DOMContentLoaded", fixEmail);
	document.addEventListener("DOMContentLoaded", resizeJumbotronElements);
	document.addEventListener("DOMContentLoaded", writeSelfAge);
	window.addEventListener("load", showJumbotronHeader);
	window.addEventListener("load", addVideo);
	window.addEventListener("load", resizeJumbotronElements);
	window.addEventListener("resize", resizeJumbotronElements);
})();<commit_msg>Open details on link click<commit_after>(function()
{
	'use strict';

	function resizeJumbotronElements()
	{
		resizeJumbotronElement(document.getElementById('jumbotron-video-fallback'));
		resizeJumbotronElement(document.getElementById('jumbotron-video'));
	}

	function resizeJumbotronElement(element)
	{
		var videoWidth = 1920;
		var videoHeight = 1080;
		var videoAspectRatio = videoWidth/videoHeight;

		if(!element)
		{
			return;
		}

		if(window.innerWidth / window.innerHeight > videoAspectRatio)
		{
			element.width = window.innerWidth;
			element.height = window.innerWidth / videoAspectRatio;
		}
		else
		{
			element.height = window.innerHeight;
			element.width = window.innerHeight * videoAspectRatio;
		}

		var horizontalMargin = (window.innerWidth - element.width) / 2;
		var verticalMargin = (window.innerHeight - element.height) / 2;

		element.style.marginLeft = horizontalMargin + 'px';
		element.style.marginTop = verticalMargin + 'px';
	}

	function fixEmail()
	{
		var anchor = document.getElementById('theemail');
		if(!anchor)
		{
			console.warn('fixEmail no anchor');
			return;
		}
		var encodedEmail = [53, 65, 64, 70, 51, 53, 70, 18, 59, 57, 64, 51, 53, 59, 65, 51, 72, 51, 69, 0, 53, 65, 63];
		anchor.innerHTML = encodedEmail
			.map(function(i)
			{
				return String.fromCharCode(i+46);
			})
			.join('');
		anchor.href = 'mailto:' + anchor.innerHTML;
	}

	function showJumbotronHeader()
	{
		var jumbotronHeader = document.getElementById('jumbotron-header');
		if(!jumbotronHeader)
		{
			console.warn('showJumbotronHeader no element');
			return;
		}
		jumbotronHeader.className += jumbotronHeader.className ? ' shown' : 'shown';
	}

	function waitForImageLoad()
	{
		var videoFallback = document.getElementById('jumbotron-video-fallback');
		if(videoFallback)
		{
			videoFallback.addEventListener("load", resizeJumbotronElements);
		}
	}

	function addVideo()
	{
		var container = document.getElementById('jumbotron-video-container');
		if(!container)
		{
			console.warn('addVideo: no container');
			return;
		}

		var video = document.createElement('video');
		video.id = 'jumbotron-video';
		video.autoPlay = true;
		video.loop = true;
		video.play();

		var sourceMP4 = document.createElement("source");
		sourceMP4.type = "video/mp4";
		sourceMP4.src = "app/static/video/head.mp4";
		video.appendChild(sourceMP4);

		var sourceOGG = document.createElement("source");
		sourceOGG.type = "video/webm";
		sourceOGG.src = "app/static/video/head.webm";
		video.appendChild(sourceOGG);

		container.appendChild(video);

		resizeJumbotronElement(video);
	}

	function writeSelfAge()
	{
		var msPerYear = 31557600000;
		var birthDate = new Date(1987,5,30);
  		var age = Math.floor((Date.now() - birthDate.getTime()) / msPerYear);

  		var ageElement = document.getElementById('profile-details-age');
  		if(ageElement)
  		{
  			ageElement.innerHTML = age;
  		}
	}

	function openDetailsSkills()
	{
		document.querySelectorAll('.skill-count').forEach(function (element)
		{
			element.addEventListener('click', function() {
				document.querySelector('.skills-legend').open = true;
			});
		});
	}

	document.addEventListener("DOMContentLoaded", fixEmail);
	document.addEventListener("DOMContentLoaded", resizeJumbotronElements);
	document.addEventListener("DOMContentLoaded", writeSelfAge);
	window.addEventListener("load", showJumbotronHeader);
	window.addEventListener("load", addVideo);
	window.addEventListener("load", resizeJumbotronElements);
	window.addEventListener("load", openDetailsSkills);
	window.addEventListener("resize", resizeJumbotronElements);
})();<|endoftext|>


<commit_before>var memtestUI = {
	ui : { /* references to document elements go here. */ },

	init: function() {
        this.ui.screen      = document.getElementById('screen');
        this.ui.appname     = document.getElementById('appname');
        this.ui.appvers     = document.getElementById('appvers');
        this.ui.passStatus  = document.getElementById('passstatus');
        this.ui.testStatus  = document.getElementById('teststatus');
        this.ui.segmentInfo = document.getElementById('segmentinfo');
        this.ui.testName    = document.getElementById('testname');
        this.ui.testPattern = document.getElementById('testpattern');

        this.ui.osinfo      = document.getElementById('osinfo');
        this.ui.cpuinfo     = document.getElementById('cpuinfo');
        this.ui.raminfo     = document.getElementById('raminfo');
        this.ui.info1       = document.getElementById('info1');
        this.ui.info2       = document.getElementById('info2');

        this.ui.passnum      = document.getElementById('passnum');
        this.ui.walltime     = document.getElementById('walltime');
        this.ui.lastpasstime = document.getElementById('lastpasstime');
        this.ui.memspeed     = document.getElementById('memspeed');
        this.ui.numerrors    = document.getElementById('numerrors');

        this.ui.errors       = document.getElementById('errors');

        this.ui.info1.textContent = this.makeChars(28, " ");
        this.ui.info2.textContent = this.makeChars(28, " ");

        /* Setup initial content */
        this.setVersion("0.01");
        this.setOSInfo();
        this.setCPUInfo();
        this.setRAMInfo();
        this.setPassStatus(0);
        this.setTestStatus(0);
        this.setSegmentInfo(-1);
        this.setTestName("waiting to begin…", 0);
        this.setTestPattern(0);
        this.setRuntime();
        this.setLastPassTime();
        this.setMemorySpeed(0);
        this.setPassNum(0);
	},

    makeChars: function(i, c) {
        var chars = "";
        while(i > 0 && i--)
            chars += c;
        return chars;
    },

    setOSInfo: function(os) {
        os = os || navigator.oscpu || navigator.platform;
        var len = 28;
        len -= 5;
        len -= os.length;
        this.ui.osinfo.textContent = " OS: " + os + this.makeChars(len, " "); // xxx truncate
    },

    setCPUInfo: function(cpu) {
        cpu = cpu || "unknown"; // content can't do this.
        var len = 28;
        len -= 5; // "CPU: "
        len -= cpu.length;
        this.ui.cpuinfo.textContent = "CPU: " + cpu + this.makeChars(len, " ");
    },
    setRAMInfo: function(ram) {
        ram = ram || "unknown"; // content can't do this.
        var len = 28;
        len -= 5; // "RAM: "
        len -= ram.length;
        this.ui.raminfo.textContent = "RAM: " + ram + this.makeChars(len, " ");
    },
	setVersion: function(version) {
	  var len = 28;
	  len -= 1; // hack, the red "+" is hardcoded.

      var appname = "MemtestJS";
	  version = " v" + version;

      var padding = (len - (appname.length + version.length)) / 2;
      var paddingLeft = Math.floor(padding);
      var paddingRight = Math.ceil(padding);

      this.ui.appname.textContent = this.makeChars(paddingLeft, " ") + appname;
      this.ui.appvers.textContent = version + this.makeChars(paddingRight, " ");
	},

    setPassStatus: function(percent) {
        var text = " Pass " + Math.floor(100 * percent) + "% ";
        if (percent < 0.10)
            text += " ";
        text += this.makeChars(Math.floor(39 * percent), "#");
        this.ui.passStatus.textContent = text;
    },

    setTestStatus: function(percent) {
        var text = " Test " + Math.floor(100 * percent) + "% ";
        if (percent < 0.10)
            text += " ";
        text += this.makeChars(Math.floor(39 * percent), "#");
        this.ui.testStatus.textContent = text;
    },

    setTestName: function(name) {
        var text = " Test ";
        if (MemtestRunner.isRunning) {
            var testnum = MemtestRunner.currentTestNum + 1;
            text += "#" + testnum;
            if (testnum < 10)
                text += " ";
        } else {
            text += "   ";
        }
        text += " [" + name + "]";
        // XXX truncate if > x chars?
        this.ui.testName.textContent = text;
    },

    setSegmentInfo: function(num, max, size) {
        // Original memtest format: Testing: 4096M - 9999M 1234M
        var text = " Testing: "
        if (num >= 0) {
            size = size / 1048576; // change to MB
            var begin = size * num;
            var end = size * (num + 1);
            var total = max * size;
            text += begin + "MB - " + end + "MB of " + total + "MB";
        }
        this.ui.segmentInfo.textContent = text;
    },

    setTestPattern: function(pattern) {
        var text = " Pattern:   ";
        var pat = pattern.toString(16);
        text += this.makeChars(8 - pat.length, "0") + pat;
        this.ui.testPattern.textContent = text;
    },

    setPassNum : function(num_passes) {
        var text = num_passes.toString();
        text = this.makeChars(6 - text.length, " ") + text;
        this.ui.passnum.textContent = text;
    },

    makeTimeString : function(duration) {
        var secs = duration % 60;
        if (secs < 10)
            secs = "0" + secs;
        var mins = Math.floor(duration / 60) % 60;
        if (mins < 10)
            mins = "0" + mins;
        var hours = Math.floor(duration / 3600);
        return hours + ":" + mins + ":" + secs;
    },

    setRuntime : function() {
        var text = "";
        if (runtime_start) {
            var seconds = Math.floor((Date.now() - runtime_start) / 1000);
            text = this.makeTimeString(seconds);
        }
        this.ui.walltime.textContent = this.makeChars(9 - text.length, " ") + text;
    },

    setLastPassTime : function() {
        var text = "";
        if (pass_start) {
            var seconds = Math.floor((Date.now() - pass_start) / 1000);
            text = this.makeTimeString(seconds);
        }
        this.ui.lastpasstime.textContent = this.makeChars(8 - text.length, " ") + text;
    },

    setMemorySpeed : function(blocks, start, stop) {
        var text;
        if (blocks) {
            var secs  = (stop - start) / 1000;
            var bytes = blocks * block_size / 1048576;
            var mbs = Math.round(bytes/secs);
            text = mbs + " MB/s";
        } else {
            text = "";
        }
        text = this.makeChars(9 - text.length, " ") + text;
        this.ui.memspeed.textContent = text;
    },

    setNumErrors : function(num_errors) {
        var text = num_errors.toString();
        text = this.makeChars(6 - text.length, " ") + text;
        this.ui.numerrors.textContent = text;
        if (num_errors)
            this.ui.numerrors.setAttribute("fail", true);
        else
            this.ui.numerrors.removeAttribute("fail");
    },

    reportBadMemory: function(seg, index, goodVal, badVal) {
        // Track this state outside of UI code?
        num_errors++;
        this.setNumErrors(num_errors);

        var hex, text = " ";

        var newErr = document.createElement("span");
        newErr.className = "badmem";

        var testnum = MemtestRunner.currentTestNum + 1;
        if (testnum < 10)
            text += " ";
        text += testnum

        text += "    ";
        if (num_passes < 10)
            text += " ";
        text += num_passes;

        text += "  ";
        var addr = "seg " + seg + ", offset " + index;
        addr += this.makeChars(23 - addr.length, " ");
        text += addr; // orig "000ac921e28 -  2761.1MB";

        text += "  ";
        hex = goodVal.toString(16);
        text += this.makeChars(8 - hex.length, "0") + hex;

        text += "  ";
        hex = badVal.toString(16);
        text += this.makeChars(8 - hex.length, "0") + hex;

        text += "  ";
        var badBits = (goodVal ^ badVal);
        hex = badBits.toString(16);
        text += this.makeChars(8 - hex.length, "0") + hex;

        // temp
        text += "  ";
        var errs = num_errors.toString();
        text += this.makeChars(5 - errs.length, " ") + errs;
        text += "     ";

        text += "\n";
        newErr.textContent = text;
        this.ui.errors.appendChild(newErr);
    },

    makeFinalReport: function() {
        var report = "";
        report += "Errors: " + num_errors + "\n";
        if (num_errors) {
            report += "Tst  Pass   Failing Address          Good       Bad     Err-Bits  Err #\n";
            report += "---  ----  -----------------------  --------  --------  --------  -----\n";
            report += this.ui.errors.textContent;
        }
        return report;
    },
};
<commit_msg>Change some tabs to spaces. Thanks, Sublime.<commit_after>var memtestUI = {
    ui : { /* references to document elements go here. */ },

    init: function() {
        this.ui.screen      = document.getElementById('screen');
        this.ui.appname     = document.getElementById('appname');
        this.ui.appvers     = document.getElementById('appvers');
        this.ui.passStatus  = document.getElementById('passstatus');
        this.ui.testStatus  = document.getElementById('teststatus');
        this.ui.segmentInfo = document.getElementById('segmentinfo');
        this.ui.testName    = document.getElementById('testname');
        this.ui.testPattern = document.getElementById('testpattern');

        this.ui.osinfo      = document.getElementById('osinfo');
        this.ui.cpuinfo     = document.getElementById('cpuinfo');
        this.ui.raminfo     = document.getElementById('raminfo');
        this.ui.info1       = document.getElementById('info1');
        this.ui.info2       = document.getElementById('info2');

        this.ui.passnum      = document.getElementById('passnum');
        this.ui.walltime     = document.getElementById('walltime');
        this.ui.lastpasstime = document.getElementById('lastpasstime');
        this.ui.memspeed     = document.getElementById('memspeed');
        this.ui.numerrors    = document.getElementById('numerrors');

        this.ui.errors       = document.getElementById('errors');

        this.ui.info1.textContent = this.makeChars(28, " ");
        this.ui.info2.textContent = this.makeChars(28, " ");

        /* Setup initial content */
        this.setVersion("0.01");
        this.setOSInfo();
        this.setCPUInfo();
        this.setRAMInfo();
        this.setPassStatus(0);
        this.setTestStatus(0);
        this.setSegmentInfo(-1);
        this.setTestName("waiting to begin…", 0);
        this.setTestPattern(0);
        this.setRuntime();
        this.setLastPassTime();
        this.setMemorySpeed(0);
        this.setPassNum(0);
    },

    makeChars: function(i, c) {
        var chars = "";
        while(i > 0 && i--)
            chars += c;
        return chars;
    },

    setOSInfo: function(os) {
        os = os || navigator.oscpu || navigator.platform;
        var len = 28;
        len -= 5;
        len -= os.length;
        this.ui.osinfo.textContent = " OS: " + os + this.makeChars(len, " "); // xxx truncate
    },

    setCPUInfo: function(cpu) {
        cpu = cpu || "unknown"; // content can't do this.
        var len = 28;
        len -= 5; // "CPU: "
        len -= cpu.length;
        this.ui.cpuinfo.textContent = "CPU: " + cpu + this.makeChars(len, " ");
    },
    setRAMInfo: function(ram) {
        ram = ram || "unknown"; // content can't do this.
        var len = 28;
        len -= 5; // "RAM: "
        len -= ram.length;
        this.ui.raminfo.textContent = "RAM: " + ram + this.makeChars(len, " ");
    },
    setVersion: function(version) {
      var len = 28;
      len -= 1; // hack, the red "+" is hardcoded.

      var appname = "MemtestJS";
      version = " v" + version;

      var padding = (len - (appname.length + version.length)) / 2;
      var paddingLeft = Math.floor(padding);
      var paddingRight = Math.ceil(padding);

      this.ui.appname.textContent = this.makeChars(paddingLeft, " ") + appname;
      this.ui.appvers.textContent = version + this.makeChars(paddingRight, " ");
    },

    setPassStatus: function(percent) {
        var text = " Pass " + Math.floor(100 * percent) + "% ";
        if (percent < 0.10)
            text += " ";
        text += this.makeChars(Math.floor(39 * percent), "#");
        this.ui.passStatus.textContent = text;
    },

    setTestStatus: function(percent) {
        var text = " Test " + Math.floor(100 * percent) + "% ";
        if (percent < 0.10)
            text += " ";
        text += this.makeChars(Math.floor(39 * percent), "#");
        this.ui.testStatus.textContent = text;
    },

    setTestName: function(name) {
        var text = " Test ";
        if (MemtestRunner.isRunning) {
            var testnum = MemtestRunner.currentTestNum + 1;
            text += "#" + testnum;
            if (testnum < 10)
                text += " ";
        } else {
            text += "   ";
        }
        text += " [" + name + "]";
        // XXX truncate if > x chars?
        this.ui.testName.textContent = text;
    },

    setSegmentInfo: function(num, max, size) {
        // Original memtest format: Testing: 4096M - 9999M 1234M
        var text = " Testing: "
        if (num >= 0) {
            size = size / 1048576; // change to MB
            var begin = size * num;
            var end = size * (num + 1);
            var total = max * size;
            text += begin + "MB - " + end + "MB of " + total + "MB";
        }
        this.ui.segmentInfo.textContent = text;
    },

    setTestPattern: function(pattern) {
        var text = " Pattern:   ";
        var pat = pattern.toString(16);
        text += this.makeChars(8 - pat.length, "0") + pat;
        this.ui.testPattern.textContent = text;
    },

    setPassNum : function(num_passes) {
        var text = num_passes.toString();
        text = this.makeChars(6 - text.length, " ") + text;
        this.ui.passnum.textContent = text;
    },

    makeTimeString : function(duration) {
        var secs = duration % 60;
        if (secs < 10)
            secs = "0" + secs;
        var mins = Math.floor(duration / 60) % 60;
        if (mins < 10)
            mins = "0" + mins;
        var hours = Math.floor(duration / 3600);
        return hours + ":" + mins + ":" + secs;
    },

    setRuntime : function() {
        var text = "";
        if (runtime_start) {
            var seconds = Math.floor((Date.now() - runtime_start) / 1000);
            text = this.makeTimeString(seconds);
        }
        this.ui.walltime.textContent = this.makeChars(9 - text.length, " ") + text;
    },

    setLastPassTime : function() {
        var text = "";
        if (pass_start) {
            var seconds = Math.floor((Date.now() - pass_start) / 1000);
            text = this.makeTimeString(seconds);
        }
        this.ui.lastpasstime.textContent = this.makeChars(8 - text.length, " ") + text;
    },

    setMemorySpeed : function(blocks, start, stop) {
        var text;
        if (blocks) {
            var secs  = (stop - start) / 1000;
            var bytes = blocks * block_size / 1048576;
            var mbs = Math.round(bytes/secs);
            text = mbs + " MB/s";
        } else {
            text = "";
        }
        text = this.makeChars(9 - text.length, " ") + text;
        this.ui.memspeed.textContent = text;
    },

    setNumErrors : function(num_errors) {
        var text = num_errors.toString();
        text = this.makeChars(6 - text.length, " ") + text;
        this.ui.numerrors.textContent = text;
        if (num_errors)
            this.ui.numerrors.setAttribute("fail", true);
        else
            this.ui.numerrors.removeAttribute("fail");
    },

    reportBadMemory: function(seg, index, goodVal, badVal) {
        // Track this state outside of UI code?
        num_errors++;
        this.setNumErrors(num_errors);

        var hex, text = " ";

        var newErr = document.createElement("span");
        newErr.className = "badmem";

        var testnum = MemtestRunner.currentTestNum + 1;
        if (testnum < 10)
            text += " ";
        text += testnum

        text += "    ";
        if (num_passes < 10)
            text += " ";
        text += num_passes;

        text += "  ";
        var addr = "seg " + seg + ", offset " + index;
        addr += this.makeChars(23 - addr.length, " ");
        text += addr; // orig "000ac921e28 -  2761.1MB";

        text += "  ";
        hex = goodVal.toString(16);
        text += this.makeChars(8 - hex.length, "0") + hex;

        text += "  ";
        hex = badVal.toString(16);
        text += this.makeChars(8 - hex.length, "0") + hex;

        text += "  ";
        var badBits = (goodVal ^ badVal);
        hex = badBits.toString(16);
        text += this.makeChars(8 - hex.length, "0") + hex;

        // temp
        text += "  ";
        var errs = num_errors.toString();
        text += this.makeChars(5 - errs.length, " ") + errs;
        text += "     ";

        text += "\n";
        newErr.textContent = text;
        this.ui.errors.appendChild(newErr);
    },

    makeFinalReport: function() {
        var report = "";
        report += "Errors: " + num_errors + "\n";
        if (num_errors) {
            report += "Tst  Pass   Failing Address          Good       Bad     Err-Bits  Err #\n";
            report += "---  ----  -----------------------  --------  --------  --------  -----\n";
            report += this.ui.errors.textContent;
        }
        return report;
    },
};
<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp');

var util = require('util');

var browserSync = require('browser-sync');

var middleware = require('./proxy');

function browserSyncInit(baseDir, files, browser) {
  browser = browser === undefined ? 'default' : browser;

  var routes = null;
  if(baseDir === 'src' || (util.isArray(baseDir) && baseDir.indexOf('src') !== -1)) {
    routes = {
      // Should be '/bower_components': '../bower_components'
      // Waiting for https://github.com/shakyShane/browser-sync/issues/308
      '/bower_components': 'bower_components'
    };
  }

  browserSync.instance = browserSync.init(files, {
    startPath: '/index.html',
    server: {
      baseDir: baseDir,
      middleware: middleware,
      routes: routes
    },
    browser: browser
  });

}

gulp.task('serve', ['watch'], function () {
  browserSyncInit([
    'src',
    '.tmp'
  ], [
    '.tmp/{app,components}/**/*.css',
    'src/assets/images/**/*',
    'src/*.html',
    'src/{app,components}/**/*.html',
    'src/{app,components}/**/*.js'
  ]);
});

gulp.task('serve:dist', ['build'], function () {
  browserSyncInit('dist');
});

gulp.task('serve:e2e', function () {
  browserSyncInit(['src', '.tmp'], null, []);
});

gulp.task('serve:e2e-dist', ['watch'], function () {
  browserSyncInit('dist', null, []);
});
<commit_msg>Fix gulp serve path.<commit_after>'use strict';

var gulp = require('gulp');

var util = require('util');

var browserSync = require('browser-sync');

var middleware = require('./proxy');

function browserSyncInit(baseDir, files, browser) {
  browser = browser === undefined ? 'default' : browser;

  var routes = null;
  if(baseDir === 'src' || (util.isArray(baseDir) && baseDir.indexOf('src') !== -1)) {
    routes = {
      // Should be '/bower_components': '../bower_components'
      // Waiting for https://github.com/shakyShane/browser-sync/issues/308
      '/bower_components': 'bower_components'
    };
  }

  browserSync.instance = browserSync.init(files, {
    startPath: '/',
    server: {
      baseDir: baseDir,
      middleware: middleware,
      routes: routes
    },
    browser: browser
  });

}

gulp.task('serve', ['watch'], function () {
  browserSyncInit([
    'src',
    '.tmp'
  ], [
    '.tmp/{app,components}/**/*.css',
    'src/assets/images/**/*',
    'src/*.html',
    'src/{app,components}/**/*.html',
    'src/{app,components}/**/*.js'
  ]);
});

gulp.task('serve:dist', ['build'], function () {
  browserSyncInit('dist');
});

gulp.task('serve:e2e', function () {
  browserSyncInit(['src', '.tmp'], null, []);
});

gulp.task('serve:e2e-dist', ['watch'], function () {
  browserSyncInit('dist', null, []);
});
<|endoftext|>


<commit_before>const html = require('choo/html');
const assets = require('../../common/assets');

module.exports = function(state) {
  const msg =
    state.params.reason === 'outdated'
      ? html`

${state.translate('notSupportedHeader')}

${state.translate(
        'notSupportedOutdatedDetail'
      )}

${state.translate(
          'updateFirefox'
        )}

${state.translate(
        'uploadPageExplainer'
      )}

`
      : html`

${state.translate('notSupportedHeader')}

${state.translate('notSupportedDetail')}

${state.translate(
        'notSupportedLink'
      )}

Firefox

          ${state.translate('downloadFirefoxButtonSub')}

${state.translate(
        'uploadPageExplainer'
      )}

`;
  const div = html`<div id="page-one">${msg}</div>`;
  return div;
};
<commit_msg>added utm params to unsupported page download link<commit_after>const html = require('choo/html');
const assets = require('../../common/assets');

module.exports = function(state) {
  const msg =
    state.params.reason === 'outdated'
      ? html`

${state.translate('notSupportedHeader')}

${state.translate(
        'notSupportedOutdatedDetail'
      )}

${state.translate(
          'updateFirefox'
        )}

${state.translate(
        'uploadPageExplainer'
      )}

`
      : html`

${state.translate('notSupportedHeader')}

${state.translate('notSupportedDetail')}

${state.translate(
        'notSupportedLink'
      )}

Firefox

          ${state.translate('downloadFirefoxButtonSub')}

${state.translate(
        'uploadPageExplainer'
      )}

`;
  const div = html`<div id="page-one">${msg}</div>`;
  return div;
};
<|endoftext|>


<commit_before>
export function validate_account_name(value) {
    let i, label, len, length, ref, suffix;

    suffix = 'Account name should ';
    if (!value) {
        return suffix + 'not be empty.';
    }
    length = value.length;
    if (length < 3) {
        return suffix + 'be longer.';
    }
    if (length > 16) {
        return suffix + 'be shorter.';
    }
    if (/\./.test(value)) {
        suffix = 'Each account segment should ';
    }
    ref = value.split('.');
    for (i = 0, len = ref.length; i < len; i++) {
        label = ref[i];
        if (!/^[a-z]/.test(label)) {
            return suffix + 'start with a letter.';
        }
        if (!/^[a-z0-9-]*$/.test(label)) {
            return suffix + 'have only letters, digits, or dashes.';
        }
        if (/--/.test(label)) {
            return suffix + 'have only one dash in a row.';
        }
        if (!/[a-z0-9]$/.test(label)) {
            return suffix + 'end with a letter or digit.';
        }
        if (!(label.length >= 3)) {
            return suffix + 'be longer';
        }
    }
    return null;
}<commit_msg>Include bad actor list check in to column for transfering, include new warning for phishing accounts<commit_after>export function validate_account_name(value) {
    const badActorList = /(polonox|poloneix|blocktrads|blocktrade|bittrexx)/;
    let i, label, len, length, ref, suffix;

    suffix = 'Account name should ';
    if (!value) {
        return suffix + 'not be empty.';
    }
    length = value.length;
    if (length < 3) {
        return suffix + 'be longer.';
    }
    if (length > 16) {
        return suffix + 'be shorter.';
    }
    if (/\./.test(value)) {
        suffix = 'Each account segment should ';
    }
    if (badActorList.test(value)) {
        return suffix = 'Use caution sending to this account. Please double check your spelling for possible phishing. ';
    }
    ref = value.split('.');
    for (i = 0, len = ref.length; i < len; i++) {
        label = ref[i];
        if (!/^[a-z]/.test(label)) {
            return suffix + 'start with a letter.';
        }
        if (!/^[a-z0-9-]*$/.test(label)) {
            return suffix + 'have only letters, digits, or dashes.';
        }
        if (/--/.test(label)) {
            return suffix + 'have only one dash in a row.';
        }
        if (!/[a-z0-9]$/.test(label)) {
            return suffix + 'end with a letter or digit.';
        }
        if (!(label.length >= 3)) {
            return suffix + 'be longer';
        }
    }
    return null;
}
<|endoftext|>


<commit_before>module.exports = function compareProjects(a, b) {
	return JSON.stringify(a) === JSON.stringify(b)
}
<commit_msg>Projects: fix compare<commit_after>module.exports = function compareProjects(a, b) {
	if (a && b) {
		return a.key === b.key
	} else {
		return false
	}
}
<|endoftext|>


<commit_before>import React from 'react'
import noCoverImg from './no-cover.png'

const Album = (album) => {
  const { title, artist, coverURL, _id } = album
  return (

        {
        coverURL
      ?
      :
      }

{title}

{artist}

  )
}

export default Album
<commit_msg>Album component enhanced markup + css<commit_after>import React from 'react'
import noCoverImg from './no-cover.png'

const Album = (album) => {
  const { title, artist, coverURL, _id } = album
  return (

      <div
        className='album_cover-area izi-yr'
        style={{
          background: `url(${coverURL || noCoverImg})`,
          backgroundSize: 'cover'
        }}
      >
        <button className='album_play-button izi-margin-top-auto' onClick={() => alert(_id)}>
          >
        </button>

{title}

{artist}

  )
}

export default Album
<|endoftext|>


<commit_before>(console = console || {}).log = function(text) {
  $("#messages").prepend(text + '
');
}

$(function() {
  $('li').each(function(index, element) {
    var exampleName = $(element).data('example');
    $('button', element).click(window[exampleName]);
  });
});

function animateBlock() {
  console.log('------------------');
  console.log('Starting animation');

  // Start the animation
  return $('#block').toggleClass('animate');
}

function basicExample() {
  TransitionCallbacks.addCallback(animateBlock(), function() {
    console.log('Transition finished');
  });
}

function cancellingExample() {
  var element = animateBlock()
  TransitionCallbacks.addCallback(element, function() {
    console.log('Oops, something went wrong :(');
  });

  console.log('Cancelling the callback');
  TransitionCallbacks.cancelCallback(element);
}

function copiedObjectExample() {
  var element = animateBlock();
  var callback = function() {
    console.log('Transition finished');
  }

  tm = new TransitionCallbacks();
  console.log('Created new TransitionCallbacks object');

  tm.addCallback(element, callback);
  console.log("Created a callback on the custom object");

  // Now to the same with the global object
  TransitionCallbacks.addCallback(element, callback);
  console.log("Created a callback on the global object");

  // Cancel the callback with the global object
  console.log("Cancel the callback with the global object");
  TransitionCallbacks.cancelCallback(callback);
}

function timeoutExample() {
  console.log('------------------');

  TransitionCallbacks.addCallback($("#block"), {timeout: 100}, function() {
    console.log('Callback called after timeout');
  });

  console.log('Starting the animation of the block');
  $('#block').toggleClass('animate');
}

function duplicatesExample() {
  var callback = function() {
    console.log('Transition finished')
  }

  var element = animateBlock()

  TransitionCallbacks.addCallback(element, callback);
  TransitionCallbacks.addCallback(element, callback);
  TransitionCallbacks.addCallback(element, callback);
  TransitionCallbacks.addCallback(element, callback);
  TransitionCallbacks.addCallback(element, callback);
}

function jQueryExample() {
  animateBlock().addTransitionCallback(function() {
    console.log('Transition finished')
  });
}
<commit_msg>Fix the broken example<commit_after>(console = console || {}).log = function(text) {
  $("#messages").prepend(text + '
');
}

$(function() {
  $('li').each(function(index, element) {
    var exampleName = $(element).data('example');
    $('button', element).click(window[exampleName]);
  });
});

function animateBlock() {
  console.log('------------------');
  console.log('Starting animation');

  // Start the animation
  return $('#block').toggleClass('animate');
}

function basicExample() {
  TransitionCallbacks.addCallback(animateBlock(), function() {
    console.log('Transition finished');
  });
}

function cancellingExample() {
  var element = animateBlock()
  TransitionCallbacks.addCallback(element, function() {
    console.log('Oops, something went wrong :(');
  });

  console.log('Cancelling the callback');
  TransitionCallbacks.cancelCallback(element);
}

function copiedObjectExample() {
  var element = animateBlock();
  var callback = function() {
    console.log('Transition finished');
  }

  tm = new TransitionCallbacks();
  console.log('Created new TransitionCallbacks object');

  tm.addCallback(element, callback);
  console.log("Created a callback on the custom object");

  // Now to the same with the global object
  TransitionCallbacks.addCallback(element, callback);
  console.log("Created a callback on the global object");

  // Cancel the callback with the global object
  console.log("Cancel the callback with the global object");
  TransitionCallbacks.cancelCallback(element);
}

function timeoutExample() {
  console.log('------------------');

  TransitionCallbacks.addCallback($("#block"), {timeout: 100}, function() {
    console.log('Callback called after timeout');
  });

  console.log('Starting the animation of the block');
  $('#block').toggleClass('animate');
}

function duplicatesExample() {
  var callback = function() {
    console.log('Transition finished')
  }

  var element = animateBlock()

  TransitionCallbacks.addCallback(element, callback);
  TransitionCallbacks.addCallback(element, callback);
  TransitionCallbacks.addCallback(element, callback);
  TransitionCallbacks.addCallback(element, callback);
  TransitionCallbacks.addCallback(element, callback);
}

function jQueryExample() {
  animateBlock().addTransitionCallback(function() {
    console.log('Transition finished')
  });
}
<|endoftext|>


<commit_before>
/**
 * Module dependencies.
 */

var cluster = require('../')
  , RedisStore = require('connect-redis')
  , express = require('express')
  , http = require('http');

// setup:
//   $ npm install express
//   $ npm install connect-redis
//   $ redis-server

var app = express.createServer()
  , store = new RedisStore;

app.use(express.cookieDecoder());
app.use(express.session({ store: store, secret: 'keyboard cat' }));
app.use(express.favicon());
app.use(function(req, res, next){
  req.session.views = req.session.views || 0;
  ++req.session.views;
  res.end('views ' + req.session.views);
});

cluster(app)
  .use(cluster.debug())
  .listen(3000);<commit_msg>Removed sessions from express example<commit_after>
/**
 * Module dependencies.
 */

var cluster = require('../')
  , express = require('express')
  , http = require('http');

// setup:
//   $ npm install express

var app = express.createServer();

app.get('/', function(req, res){
  res.send('Hello World');
});

cluster(app)
  .use(cluster.debug())
  .listen(3000);<|endoftext|>


<commit_before>
/**
  The tag mapper is responsible for mapping OSM tag information in to the
  document model, using a variety of different schemas found in /schema/*.
**/

var through = require('through2'),
    trimmer = require('trimmer'),
    merge = require('merge');

var localized_keys = require('../config/localized_keys');
var NAME_SCHEMA = require('../schema/name_osm');
var ADDRESS_SCHEMA = merge( true, false,
  require('../schema/address_osm'),
  require('../schema/address_naptan'),
  require('../schema/address_karlsruhe')
);

module.exports = function(){

  var stream = through.obj( function( doc, enc, done ) {

    var tags = doc.getMeta('tags');
    if( tags ){

      // Unfortunately we need to iterate over every tag,
      // so we only do the iteration once to save CPU.
      for( var tag in tags ){

        // Map localized names which begin with 'name:'
        // @ref: http://wiki.openstreetmap.org/wiki/Namespace#Language_code_suffix
        var suffix = getNameSuffix( tag );
        if( suffix ){
          var val1 = trim( tags[tag] );
          if( val1 ){
            doc.setName( suffix, val1 );
          }
        }

        // Map name data from our name mapping schema
        else if( tag in NAME_SCHEMA ){
          var val2 = trim( tags[tag] );
          if( val2 ){
            doc.setName( NAME_SCHEMA[tag], val2 );
          }
        }

        // Map address data from our address mapping schema
        else if( tag in ADDRESS_SCHEMA ){
          var val3 = trim( tags[tag] );
          if( val3 ){
            doc.setAddress( ADDRESS_SCHEMA[tag], val3 );
          }
        }
      }
    }

    this.push( doc );
    done();

  });

  // catch stream errors
  stream.on( 'error', console.error.bind( console, __filename ) );

  return stream;
};

// Clean string of leading/trailing junk chars
function trim( str ){
  return trimmer( str, '#$%^*()<>-=_{};:",./?\' ' );
}

// extract name suffix, eg for 'name:EN' return 'en'
// if not valid, return false.
function getNameSuffix( tag ){

  if( tag.length < 6 || tag.substr(0,5) !== 'name:' ){
    return false;
  }

  // normalize suffix
  var suffix = tag.substr(5).toLowerCase();

  // check the suffix is in the localized key list
  if( localized_keys.indexOf(suffix) === -1 ){
    return false;
  }

  return suffix;
}<commit_msg>formatting: uppercase constants for consistency<commit_after>
/**
  The tag mapper is responsible for mapping OSM tag information in to the
  document model, using a variety of different schemas found in /schema/*.
**/

var through = require('through2'),
    trimmer = require('trimmer'),
    merge = require('merge');

var LOCALIZED_KEYS = require('../config/localized_keys');
var NAME_SCHEMA = require('../schema/name_osm');
var ADDRESS_SCHEMA = merge( true, false,
  require('../schema/address_osm'),
  require('../schema/address_naptan'),
  require('../schema/address_karlsruhe')
);

module.exports = function(){

  var stream = through.obj( function( doc, enc, done ) {

    var tags = doc.getMeta('tags');
    if( tags ){

      // Unfortunately we need to iterate over every tag,
      // so we only do the iteration once to save CPU.
      for( var tag in tags ){

        // Map localized names which begin with 'name:'
        // @ref: http://wiki.openstreetmap.org/wiki/Namespace#Language_code_suffix
        var suffix = getNameSuffix( tag );
        if( suffix ){
          var val1 = trim( tags[tag] );
          if( val1 ){
            doc.setName( suffix, val1 );
          }
        }

        // Map name data from our name mapping schema
        else if( tag in NAME_SCHEMA ){
          var val2 = trim( tags[tag] );
          if( val2 ){
            doc.setName( NAME_SCHEMA[tag], val2 );
          }
        }

        // Map address data from our address mapping schema
        else if( tag in ADDRESS_SCHEMA ){
          var val3 = trim( tags[tag] );
          if( val3 ){
            doc.setAddress( ADDRESS_SCHEMA[tag], val3 );
          }
        }
      }
    }

    this.push( doc );
    done();

  });

  // catch stream errors
  stream.on( 'error', console.error.bind( console, __filename ) );

  return stream;
};

// Clean string of leading/trailing junk chars
function trim( str ){
  return trimmer( str, '#$%^*()<>-=_{};:",./?\' ' );
}

// extract name suffix, eg for 'name:EN' return 'en'
// if not valid, return false.
function getNameSuffix( tag ){

  if( tag.length < 6 || tag.substr(0,5) !== 'name:' ){
    return false;
  }

  // normalize suffix
  var suffix = tag.substr(5).toLowerCase();

  // check the suffix is in the localized key list
  if( LOCALIZED_KEYS.indexOf(suffix) === -1 ){
    return false;
  }

  return suffix;
}<|endoftext|>


<commit_before>var gpio = require('rpi-gpio');
var SPI = require('spi');
var config = require('nconf');
var async = require("async");
var leds = require("./modules/leds.js");
var PythonShell = require('python-shell');
var tempSensor = require("./modules/am2302.js");
var gasSensors = require("./modules/gasSensors.js");
var usbDevices = require("./modules/usbDevices.js");
var mainInterval;
var mainLoopTime = 60000;
config.use('file', { file: './config/default.json' });

// var faultStatus = {
//   "AM2302":true,
// "ext1":true,
// "ext2":true,
// "ext3":true,
// "wlan0":true,
// "wlan1":true,
// "imei":true,
// "iccid":true,
// "mic":true,
// "MQ7":true,
// "MQ135":true,
// "Camera":true,
// "Ethernet":true
// }
// NOTE: setup LEDS
leds.setup(gpio);

///////////////////// EVENTS /////////////////////////
// NOTE: register events from gas sensors
gasSensors.events.on('ready', function(sensorData) {
  console.log('gasSensors are ready');
  console.log(JSON.stringify(sensorData));
})
//////////////////////////////////////////////////////

async.series({
    am2302: function(callback){
      // NOTE: setup tempSensor
      tempSensor.setup(gpio,function(err){
        if(err){
          console.log("AM2302 failed to initialize");
        }else{
          leds.setFaultStatus("AM2302",false);
          console.log("tempSensor ready");
          callback(null, false);
        }
      });
    },
    ext: function(callback){
        callback(null, true);
    },
    usb: function(callback){
      usbDevices.deviceIds(function(err,results){
        if(err){
          console.error(err);
          callback(err);
        }else{
          console.log(JSON.stringify(results));
          callback(null, results);
        }
      });
    },
    mic: function(callback){
        callback(null, true);
    },
    gas: function(callback){
        // NOTE: setup gas sensor
        gasSensors.setup(gpio,SPI);
        callback(null, false);
    },
    camera: function(callback){
        callback(null, true);
    },
    ethernet: function(callback){
        callback(null, true);
    }
},
function(err, results) {
    // results is now equal to: {am2302: 1, ext: 2...}
    if(err) throw err;
    console.log(results.toString());
});

// usbDevices.deviceIds(function(err,results){
//   if(err){
//     console.error(err);
//   }else{
//     console.log(JSON.stringify(results));
//   }
// });

// // NOTE: options for setting up pi-timolo
// var options = {
//   mode: 'json',
//   scriptPath: '/home/pi/pi-timolo'
// };
// // NOTE: create timolo instance
// var timolo = new PythonShell('pi-timolo.py',options);
//
// // NOTE: register timolo message event
// timolo.on('message', function (message) {
//   // received a message sent from the Python script (a simple "print" statement)
//   console.log("Timolo " + message.hasOwnProperty('timolo'));
//   console.log("Motion " + message.hasOwnProperty('motion'));
//   console.log("Timelapse " + message.hasOwnProperty('timelapse'));
//   console.log(message);
// });

// NOTE: setup main loop interval
mainInterval = setInterval(mainLoop,mainLoopTime);

// NOTE: function that runs when the main interval expires
function mainLoop(){
  var tempReading = tempSensor.read();
  console.log("Temp: "+tempReading.temperature.toFixed(1) + " Humidity: "+tempReading.humidity.toFixed(1));
}
<commit_msg>handle usb setup error<commit_after>var gpio = require('rpi-gpio');
var SPI = require('spi');
var config = require('nconf');
var async = require("async");
var leds = require("./modules/leds.js");
var PythonShell = require('python-shell');
var tempSensor = require("./modules/am2302.js");
var gasSensors = require("./modules/gasSensors.js");
var usbDevices = require("./modules/usbDevices.js");
var mainInterval;
var mainLoopTime = 60000;
config.use('file', { file: './config/default.json' });

// var faultStatus = {
//   "AM2302":true,
// "ext1":true,
// "ext2":true,
// "ext3":true,
// "wlan0":true,
// "wlan1":true,
// "imei":true,
// "iccid":true,
// "mic":true,
// "MQ7":true,
// "MQ135":true,
// "Camera":true,
// "Ethernet":true
// }
// NOTE: setup LEDS
leds.setup(gpio);

///////////////////// EVENTS /////////////////////////
// NOTE: register events from gas sensors
gasSensors.events.on('ready', function(sensorData) {
  console.log('gasSensors are ready');
  console.log(JSON.stringify(sensorData));
})
//////////////////////////////////////////////////////

async.series({
    am2302: function(callback){
      // NOTE: setup tempSensor
      tempSensor.setup(gpio,function(err){
        if(err){
          console.log("AM2302 failed to initialize");
        }else{
          leds.setFaultStatus("AM2302",false);
          console.log("tempSensor ready");
          callback(null, false);
        }
      });
    },
    ext: function(callback){
        callback(null, true);
    },
    usb: function(callback){
      usbDevices.deviceIds(function(err,results){
        if(err){
          console.error(null,true);
          callback(err);
        }else{
          console.log(JSON.stringify(results));
          callback(null, results);
        }
      });
    },
    mic: function(callback){
        callback(null, true);
    },
    gas: function(callback){
        // NOTE: setup gas sensor
        gasSensors.setup(gpio,SPI);
        callback(null, false);
    },
    camera: function(callback){
        callback(null, true);
    },
    ethernet: function(callback){
        callback(null, true);
    }
},
function(err, results) {
    // results is now equal to: {am2302: 1, ext: 2...}
    if(err) console.error(err);
    console.log(results.toString());
});

// usbDevices.deviceIds(function(err,results){
//   if(err){
//     console.error(err);
//   }else{
//     console.log(JSON.stringify(results));
//   }
// });

// // NOTE: options for setting up pi-timolo
// var options = {
//   mode: 'json',
//   scriptPath: '/home/pi/pi-timolo'
// };
// // NOTE: create timolo instance
// var timolo = new PythonShell('pi-timolo.py',options);
//
// // NOTE: register timolo message event
// timolo.on('message', function (message) {
//   // received a message sent from the Python script (a simple "print" statement)
//   console.log("Timolo " + message.hasOwnProperty('timolo'));
//   console.log("Motion " + message.hasOwnProperty('motion'));
//   console.log("Timelapse " + message.hasOwnProperty('timelapse'));
//   console.log(message);
// });

// NOTE: setup main loop interval
mainInterval = setInterval(mainLoop,mainLoopTime);

// NOTE: function that runs when the main interval expires
function mainLoop(){
  var tempReading = tempSensor.read();
  console.log("Temp: "+tempReading.temperature.toFixed(1) + " Humidity: "+tempReading.humidity.toFixed(1));
}
<|endoftext|>


<commit_before>/**
 * CareWheels - Individual Status Controller
 *
 */
angular.module('careWheels')

.controller('individualStatusController', function($scope, GroupInfo){

  var analysis = GroupInfo.retrieveAnalyzedGroup();

  // This is simply a way to print out the analyzed object so that I can figure out how
  // to use it. It will print on the bottom of the Individual Status Page of the app.
  // To get rid of it, comment it out in individualStatus.html.
  $scope.testAnalysis = function() {
    var macguffin = analysis;
    var test;
    var smallerMacguffin = macguffin[3];
    //var obj = JSON.parse(smallerMacguffin);
    //test = obj.name;
    test = smallerMacguffin;
    return test;
  }

  $scope.getPings = function(time, type) {
    switch(time) {
    case 'midnight':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "* * * * * *";
        }
    case 'one':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'two':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'three':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "* *";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'four':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "* * *";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'five':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'six':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'seven':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "*";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "*";
        }
    case 'eight':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'nine':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'ten':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'eleven':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'twelve':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'thirteen':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'fourteen':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'fifteen':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'sixteen':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'seventeen':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'eighteen':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'nineteen':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'twenty':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'twentyone':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'twentytwo':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'twentythree':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    default:
        return 'error';
    }
  };

  $scope.getPresence = function(time) {
    switch(time) {
    case 'midnight':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'one':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'two':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'three':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'four':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'five':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'six':
        //This is where you put the function call to get the presence for this time.
        return "grey";
    case 'seven':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'eight':
        //This is where you put the function call to get the presence for this time.
        return "grey";
    case 'nine':
        //This is where you put the function call to get the presence for this time.
        return "grey";
    case 'ten':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'eleven':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'twelve':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'thirteen':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'fourteen':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'fifteen':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'sixteen':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'seventeen':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'eighteen':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'nineteen':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'twenty':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'twentyone':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'twentytwo':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'twentythree':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    default:
        return 'error';
    }
  };

  $scope.trevor = {
    name: 'Kylo',
    midnight: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'yellow'
      },
      meds: {
      	status: 'blue'
      }
    },
    one: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'yellow'
      },
      meds: {
      	status: 'blue'
      }
    },
    two: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'yellow'
      },
      meds: {
      	status: 'blue'
      }
    },
    three: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'blue'
      }
    },
    four: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'blue'
      }
    },
    five: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'red'
      }
    },
    six: {
      presence: {
        status: 'grey'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'red'
      }
    },
    seven: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'blue'
      }
    },
    eight: {
      presence: {
        status: 'grey'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'blue'
      }
    },
    nine: {
      presence: {
        status: 'grey'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'blue'
      }
    },
    ten: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'blue'
      }
    },
    eleven: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'blue'
      }
    },
    twelve: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'blue'
      }
    },
    thirteen: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    fourteen: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    fifteen: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    sixteen: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    seventeen: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    eighteen: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    nineteen: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    twenty: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    twentyone: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    twentytwo: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    twentythree: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    }
  };
});
<commit_msg>see if it works now<commit_after>/**
 * CareWheels - Individual Status Controller
 *
 */
angular.module('careWheels')

.controller('individualStatusController', function($scope, GroupInfo){

  //var analysis = GroupInfo.retrieveAnalyzedGroup();

  // This is simply a way to print out the analyzed object so that I can figure out how
  // to use it. It will print on the bottom of the Individual Status Page of the app.
  // To get rid of it, comment it out in individualStatus.html.
  //$scope.testAnalysis = function() {
  //  var macguffin = analysis;
  //  var test;
  //  var smallerMacguffin = macguffin[3];
    //var obj = JSON.parse(smallerMacguffin);
    //test = obj.name;
  //  test = smallerMacguffin;
  //  return test;
  //}

  $scope.getPings = function(time, type) {
    switch(time) {
    case 'midnight':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "* * * * * *";
        }
    case 'one':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'two':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'three':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "* *";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'four':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "* * *";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'five':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'six':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'seven':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "*";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "*";
        }
    case 'eight':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'nine':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'ten':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'eleven':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'twelve':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'thirteen':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'fourteen':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'fifteen':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'sixteen':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'seventeen':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'eighteen':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'nineteen':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'twenty':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'twentyone':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'twentytwo':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    case 'twentythree':
        if (type === 'meals'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
        else if (type === 'meds'){
          //This is where you put the function call to get the pings for this time.
          return "";
        }
    default:
        return 'error';
    }
  };

  $scope.getPresence = function(time) {
    switch(time) {
    case 'midnight':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'one':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'two':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'three':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'four':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'five':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'six':
        //This is where you put the function call to get the presence for this time.
        return "grey";
    case 'seven':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'eight':
        //This is where you put the function call to get the presence for this time.
        return "grey";
    case 'nine':
        //This is where you put the function call to get the presence for this time.
        return "grey";
    case 'ten':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'eleven':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'twelve':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'thirteen':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'fourteen':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'fifteen':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'sixteen':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'seventeen':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'eighteen':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'nineteen':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'twenty':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'twentyone':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'twentytwo':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    case 'twentythree':
        //This is where you put the function call to get the presence for this time.
        return "blue";
    default:
        return 'error';
    }
  };

  $scope.trevor = {
    name: 'Kylo',
    midnight: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'yellow'
      },
      meds: {
      	status: 'blue'
      }
    },
    one: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'yellow'
      },
      meds: {
      	status: 'blue'
      }
    },
    two: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'yellow'
      },
      meds: {
      	status: 'blue'
      }
    },
    three: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'blue'
      }
    },
    four: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'blue'
      }
    },
    five: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'red'
      }
    },
    six: {
      presence: {
        status: 'grey'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'red'
      }
    },
    seven: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'blue'
      }
    },
    eight: {
      presence: {
        status: 'grey'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'blue'
      }
    },
    nine: {
      presence: {
        status: 'grey'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'blue'
      }
    },
    ten: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'blue'
      }
    },
    eleven: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'blue'
      }
    },
    twelve: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
      	status: 'blue'
      }
    },
    thirteen: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    fourteen: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    fifteen: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    sixteen: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    seventeen: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    eighteen: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    nineteen: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    twenty: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    twentyone: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    twentytwo: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    },
    twentythree: {
      presence: {
        status: 'blue'
      },
      meals: {
        status: 'blue'
      },
      meds: {
        status: 'blue'
      }
    }
  };
});
<|endoftext|>


<commit_before>/**
 * standard Observer class.
 *
 * Might be used as a usual class or as a builder over another objects
 *
 * Copyright (C) 2008-2009 Nikolay V. Nemshilov aka St. <nemshilov#gma-il>
 */
var Observer = new Class({
  include: Options,

  /**
   * general constructor
   *
   * @param Object options
   */
  initialize: function(options) {
    this.setOptions(options);

    // catching up the event shortucts
    var ancestor, shorts = this.EVENTS || this.constructor.EVENTS ||
        ((ancestor = this.constructor.ancestors.any('EVENTS')) ?
          ancestor.EVENTS : null);

    Observer.createShortcuts(this, shorts);
  },

  /**
   * starts observing an event
   *
   * USAGE:
   *  observe(String event, Function callback[, arguments, ...]);
   *  observe(String event, String method_name[, arguments, ...]);
   *  observe(Object events_hash);
   *
   * @return Observer self
   */
  observe: function() {
    var args = $A(arguments), events = args.shift(), callback;
    if (!isHash(events)) { var hash = {}; hash[events] = args; events = hash; }

    if (!this.$listeners) this.$listeners = [];

    for (var name in events) {
      if (!isArray(events[name])) events[name] = [events[name]];
      callback = isString(events[name][0]) ? this[events[name][0]] : events[name][0];

      if (!this.observes(name, callback)) {
        hash = { e: name, f: callback, a: events[name].slice(1) };
        this.$listeners.push(hash);
        if (this.$o && this.$o.add) this.$o.add.call(this, hash);
      }
    }

    return this;
  },

  /**
   * checks if the observer observes given event and/or callback
   *
   * USAGE:
   *   observes(String event)
   *   observes(Function callback)
   *   observes(String event, Function callback)
   *
   * @retun Observer self
   */
  observes: function(event, callback) {
    if (this.$listeners) {
      if (!isString(event)) { callback = event; event = null; }

      return !!this.$listeners.any(function(i) {
        return (event && callback) ? i.e == event && i.f == callback :
          event ? i.e == event : i.f == callback;
      });
    }

    return false;
  },

  /**
   * stops observing an event or/and function
   *
   * USAGE:
   *   stopObserving(String event)
   *   stopObserving(Function callback)
   *   stopObserving(String event, Function callback)
   *
   * @return Observer self
   */
  stopObserving: function(event, callback) {
    if (this.$listeners) {
      if (!isString(event)) { callback = event; event = null; }

      this.$listeners = this.$listeners.filter(function(i) {
        var result = (event && callback) ? (i.e != event || i.f != callback) :
          (event ? i.e != event : i.f != callback);

        if (!result && this.$o && this.$o.remove) this.$o.remove.call(this, i);

        return result;
      }, this);
    }

    return this;
  },

  /**
   * returns the listeners list for the event
   *
   * NOTE: if no event was specified the method will return _all_
   *       event listeners for _all_ the events
   *
   * @param String event name
   * @return Array of listeners
   */
  listeners: function(event) {
    return (this.$listeners || []).filter(function(i) {
      return !event || i.e == event;
    }).map(function(i) { return i.f; }).uniq();
  },

  /**
   * initiates the event handling
   *
   * @param String event name
   * @param mixed optional argument
   * ........
   * @return Observer self
   */
  fire: function() {
    var args = $A(arguments), event = args.shift();

    (this.$listeners || []).each(function(i) {
      if (i.e == event) {
        (this.$o && this.$o.fire) ? this.$o.fire.call(this, event, args, i)  :
          i.f.apply(this, i.a.concat(args));
      }
    }, this);

    return this;
  },

  extend: {
    /**
     * adds an observer functionality to any object
     *
     * @param Object object
     * @param Array optional events list to build shortcuts
     * @return Object extended object
     */
    create: function(object, events) {
      $ext(object, Object.without(this.prototype, 'initialize', 'setOptions'), true);
      return this.createShortcuts(object, events || object['EVENTS']);
    },

    /**
     * builds shortcut methods to wire/fire events on the object
     *
     * @param Object object to extend
     * @param Array list of event names
     * @return Object extended object
     */
    createShortcuts: function(object, names) {
      (names || []).each(function(name) {
        var shortcuts = {}, name = name.replace(/:/g, '_').toLowerCase().camelize();
        shortcuts[name] = function() {
          return this.fire.apply(this, [name].concat($A(arguments)));
        };
        shortcuts['on'+name.capitalize()] = function() {
          return this.on.apply(this, [name].concat($A(arguments)));
        };
        $ext(object, shortcuts, true);
      });

      return object;
    }
  }
});

$alias(Observer.prototype, { observe: 'on' });<commit_msg>performance update<commit_after>/**
 * standard Observer class.
 *
 * Might be used as a usual class or as a builder over another objects
 *
 * Copyright (C) 2008-2009 Nikolay V. Nemshilov aka St. <nemshilov#gma-il>
 */
var Observer = new Class({
  include: Options,

  /**
   * general constructor
   *
   * @param Object options
   */
  initialize: function(options) {
    this.setOptions(options);

    // catching up the event shortucts
    var ancestor, shorts = this.EVENTS || this.constructor.EVENTS ||
        ((ancestor = this.constructor.ancestors.any('EVENTS')) ?
          ancestor.EVENTS : null);

    Observer.createShortcuts(this, shorts);
  },

  /**
   * starts observing an event
   *
   * USAGE:
   *  observe(String event, Function callback[, arguments, ...]);
   *  observe(String event, String method_name[, arguments, ...]);
   *  observe(Object events_hash);
   *
   * @return Observer self
   */
  observe: function() {
    var args = $A(arguments), events = args.shift(), callback;
    if (!isHash(events)) { var hash = {}; hash[events] = args; events = hash; }

    if (!this.$listeners) this.$listeners = [];

    for (var name in events) {
      if (!isArray(events[name])) events[name] = [events[name]];
      callback = isString(events[name][0]) ? this[events[name][0]] : events[name][0];

      hash = { e: name, f: callback, a: events[name].slice(1) };
      this.$listeners.push(hash);
      if (this.$o && this.$o.add) this.$o.add.call(this, hash);
    }

    return this;
  },

  /**
   * checks if the observer observes given event and/or callback
   *
   * USAGE:
   *   observes(String event)
   *   observes(Function callback)
   *   observes(String event, Function callback)
   *
   * @retun Observer self
   */
  observes: function(event, callback) {
    if (this.$listeners) {
      if (!isString(event)) { callback = event; event = null; }

      return !!this.$listeners.any(function(i) {
        return (event && callback) ? i.e == event && i.f == callback :
          event ? i.e == event : i.f == callback;
      });
    }

    return false;
  },

  /**
   * stops observing an event or/and function
   *
   * USAGE:
   *   stopObserving(String event)
   *   stopObserving(Function callback)
   *   stopObserving(String event, Function callback)
   *
   * @return Observer self
   */
  stopObserving: function(event, callback) {
    if (this.$listeners) {
      if (!isString(event)) { callback = event; event = null; }

      this.$listeners = this.$listeners.filter(function(i) {
        var result = (event && callback) ? (i.e != event || i.f != callback) :
          (event ? i.e != event : i.f != callback);

        if (!result && this.$o && this.$o.remove) this.$o.remove.call(this, i);

        return result;
      }, this);
    }

    return this;
  },

  /**
   * returns the listeners list for the event
   *
   * NOTE: if no event was specified the method will return _all_
   *       event listeners for _all_ the events
   *
   * @param String event name
   * @return Array of listeners
   */
  listeners: function(event) {
    return (this.$listeners || []).filter(function(i) {
      return !event || i.e == event;
    }).map(function(i) { return i.f; }).uniq();
  },

  /**
   * initiates the event handling
   *
   * @param String event name
   * @param mixed optional argument
   * ........
   * @return Observer self
   */
  fire: function() {
    var args = $A(arguments), event = args.shift();

    (this.$listeners || []).each(function(i) {
      if (i.e == event) {
        (this.$o && this.$o.fire) ? this.$o.fire.call(this, event, args, i)  :
          i.f.apply(this, i.a.concat(args));
      }
    }, this);

    return this;
  },

  extend: {
    /**
     * adds an observer functionality to any object
     *
     * @param Object object
     * @param Array optional events list to build shortcuts
     * @return Object extended object
     */
    create: function(object, events) {
      $ext(object, Object.without(this.prototype, 'initialize', 'setOptions'), true);
      return this.createShortcuts(object, events || object['EVENTS']);
    },

    /**
     * builds shortcut methods to wire/fire events on the object
     *
     * @param Object object to extend
     * @param Array list of event names
     * @return Object extended object
     */
    createShortcuts: function(object, names) {
      (names || []).each(function(name) {
        var shortcuts = {}, name = name.replace(/:/g, '_').toLowerCase().camelize();
        shortcuts[name] = function() {
          return this.fire.apply(this, [name].concat($A(arguments)));
        };
        shortcuts['on'+name.capitalize()] = function() {
          return this.on.apply(this, [name].concat($A(arguments)));
        };
        $ext(object, shortcuts, true);
      });

      return object;
    }
  }
});

$alias(Observer.prototype, { observe: 'on' });<|endoftext|>


<commit_before>goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.source.GeoJSON');
goog.require('ol.source.OSM');
goog.require('ol.style.DefaultStyleFunction');

var styleFunction = function(feature) {
  switch (feature.getGeometry().getType()) {
    case ol.geom.GeometryType.MULTI_LINE_STRING:
      return {
        stroke: {
          color: 'green',
          width: 1
        }
      };
    default:
      return ol.style.DefaultStyleFunction(feature);
  }
};

var geoJSONSource = new ol.source.GeoJSON(
    /** @type {ol.source.GeoJSONOptions} */ ({
      geoJSON: {
        'type': 'FeatureCollection',
        features: [
          {
            'type': 'Feature',
            'geometry': {
              'type': 'Point',
              'coordinates': [0, 0]
            }
          },
          {
            'type': 'Feature',
            'geometry': {
              'type': 'LineString',
              'coordinates': [[-1e7, -1e7], [1e7, 1e7]]
            }
          },
          {
            'type': 'Feature',
            'geometry': {
              'type': 'LineString',
              'coordinates': [[-1e7, 1e7], [1e7, -1e7]]
            }
          },
          {
            'type': 'Feature',
            'geometry': {
              'type': 'Polygon',
              'coordinates': [[[-5e6, -5e6], [0, 5e6], [5e6, -5e6]]]
            }
          },
          {
            'type': 'Feature',
            'geometry': {
              'type': 'MultiLineString',
              'coordinates': [
                [[-1e6, -7.5e5], [-1e6, 7.5e5]],
                [[1e6, -7.5e5], [1e6, 7.5e5]],
                [[-7.5e5, -1e6], [7.5e5, -1e6]],
                [[-7.5e5, 1e6], [7.5e5, 1e6]]
              ]
            }
          }
        ]
      }
    }));

var map = new ol.Map({
  layers: [
    new ol.layer.Tile({
      source: new ol.source.OSM()
    }),
    new ol.layer.Vector({
      source: geoJSONSource,
      styleFunction: styleFunction
    })
  ],
  renderer: ol.RendererHint.CANVAS,
  target: 'map',
  view: new ol.View2D({
    center: [0, 0],
    zoom: 2
  })
});
<commit_msg>Add MultiPolygon to GeoJSON example<commit_after>goog.require('ol.Map');
goog.require('ol.RendererHint');
goog.require('ol.View2D');
goog.require('ol.layer.Tile');
goog.require('ol.layer.Vector');
goog.require('ol.source.GeoJSON');
goog.require('ol.source.OSM');
goog.require('ol.style.DefaultStyleFunction');

var styleFunction = function(feature) {
  switch (feature.getGeometry().getType()) {
    case ol.geom.GeometryType.MULTI_LINE_STRING:
      return {
        stroke: {
          color: 'green',
          width: 1
        }
      };
    case ol.geom.GeometryType.MULTI_POLYGON:
      return {
        stroke: {
          color: 'yellow',
          width: 1
        }
      };
    default:
      return ol.style.DefaultStyleFunction(feature);
  }
};

var geoJSONSource = new ol.source.GeoJSON(
    /** @type {ol.source.GeoJSONOptions} */ ({
      geoJSON: {
        'type': 'FeatureCollection',
        features: [
          {
            'type': 'Feature',
            'geometry': {
              'type': 'Point',
              'coordinates': [0, 0]
            }
          },
          {
            'type': 'Feature',
            'geometry': {
              'type': 'LineString',
              'coordinates': [[-1e7, -1e7], [1e7, 1e7]]
            }
          },
          {
            'type': 'Feature',
            'geometry': {
              'type': 'LineString',
              'coordinates': [[-1e7, 1e7], [1e7, -1e7]]
            }
          },
          {
            'type': 'Feature',
            'geometry': {
              'type': 'Polygon',
              'coordinates': [[[-5e6, -5e6], [0, 5e6], [5e6, -5e6]]]
            }
          },
          {
            'type': 'Feature',
            'geometry': {
              'type': 'MultiLineString',
              'coordinates': [
                [[-1e6, -7.5e5], [-1e6, 7.5e5]],
                [[1e6, -7.5e5], [1e6, 7.5e5]],
                [[-7.5e5, -1e6], [7.5e5, -1e6]],
                [[-7.5e5, 1e6], [7.5e5, 1e6]]
              ]
            }
          },
          {
            'type': 'Feature',
            'geometry': {
              'type': 'MultiPolygon',
              'coordinates': [
                [[[-5e6, 6e6], [-5e6, 8e6], [-3e6, 8e6], [-3e6, 6e6]]],
                [[[-2e6, 6e6], [-2e6, 8e6], [0e6, 8e6], [0e6, 6e6]]],
                [[[1e6, 6e6], [1e6, 8e6], [3e6, 8e6], [3e6, 6e6]]]
              ]
            }
          }
        ]
      }
    }));

var map = new ol.Map({
  layers: [
    new ol.layer.Tile({
      source: new ol.source.OSM()
    }),
    new ol.layer.Vector({
      source: geoJSONSource,
      styleFunction: styleFunction
    })
  ],
  renderer: ol.RendererHint.CANVAS,
  target: 'map',
  view: new ol.View2D({
    center: [0, 0],
    zoom: 2
  })
});
<|endoftext|>