<commit_before>import { Styles, Utils } from 'material-ui';
const Colors = Styles.Colors;
const Spacing = Styles.Spacing;
const ColorManipulator = Utils.ColorManipulator;

const ActorTheme = {
  spacing: Spacing,
  contentFontFamily: 'RobotoDraft, Roboto, sans-serif',

  getPalette() {
    return {
      primary1Color: '#4a90e2',
      primary2Color: '#486181',
      primary3Color: '#5191db',
      accent1Color: Colors.white,
      textColor: '#4d4d4d'
      //accent2Color: Colors.pinkA400,
      //accent3Color: Colors.pinkA100,
      //textColor: Colors.darkBlack,
      //canvasColor: Colors.white,
      //borderColor: Colors.grey300,
      //disabledColor: ColorManipulator.fade(Colors.darkBlack, 0.3)
    };
  },

  getComponentThemes(palette, spacing) {
    spacing = spacing || Spacing;
    let obj = {
      raisedButton: {
        color: palette.primary1Color,
        textColor: Colors.white
      },
      textField: {
        textColor: Colors.white,
        floatingLabelColor: Colors.white,
        disabledTextColor: Colors.white,
        hintColor: ColorManipulator.fade(Colors.white, .3),
        errorColor: '#eb8080',
        focusColor: palette.primary1Color,
        backgroundColor: 'transparent',
        borderColor: ColorManipulator.fade(Colors.white, .12)
      },
      tabs: {
        backgroundColor: palette.primary2Color
      },
      radioButton: {
        borderColor: ColorManipulator.fade(Colors.black, .15),
        checkedColor: palette.primary3Color,
        requiredColor: palette.primary3Color
      },
      dropDownMenu: {
        accentColor: palette.primary3Color
      },
      menuItem: {
        hoverColor: '#f5f6f7',
        selectedTextColor: palette.primary3Color
      }
    };

    return obj;
  },

  getSnackbarStyles() {
    return {
      left: 'auto',
      marginLeft: 0,
      right: 0,
      height: '40px',
      lineHeight: '40px',
      color: 'white',
      marginRight: 24,
      backgroundColor: '#4a90e2',
      textShadow: '0 1px 1px rgba(0,0,0,.3)'
    };
  }
};

export default ActorTheme;
<commit_msg>fix(web): disable pointer event on snackbar<commit_after>import { Styles, Utils } from 'material-ui';
const Colors = Styles.Colors;
const Spacing = Styles.Spacing;
const ColorManipulator = Utils.ColorManipulator;

const ActorTheme = {
  spacing: Spacing,
  contentFontFamily: 'RobotoDraft, Roboto, sans-serif',

  getPalette() {
    return {
      primary1Color: '#4a90e2',
      primary2Color: '#486181',
      primary3Color: '#5191db',
      accent1Color: Colors.white,
      textColor: '#4d4d4d'
      //accent2Color: Colors.pinkA400,
      //accent3Color: Colors.pinkA100,
      //textColor: Colors.darkBlack,
      //canvasColor: Colors.white,
      //borderColor: Colors.grey300,
      //disabledColor: ColorManipulator.fade(Colors.darkBlack, 0.3)
    };
  },

  getComponentThemes(palette, spacing) {
    spacing = spacing || Spacing;
    let obj = {
      raisedButton: {
        color: palette.primary1Color,
        textColor: Colors.white
      },
      textField: {
        textColor: Colors.white,
        floatingLabelColor: Colors.white,
        disabledTextColor: Colors.white,
        hintColor: ColorManipulator.fade(Colors.white, .3),
        errorColor: '#eb8080',
        focusColor: palette.primary1Color,
        backgroundColor: 'transparent',
        borderColor: ColorManipulator.fade(Colors.white, .12)
      },
      tabs: {
        backgroundColor: palette.primary2Color
      },
      radioButton: {
        borderColor: ColorManipulator.fade(Colors.black, .15),
        checkedColor: palette.primary3Color,
        requiredColor: palette.primary3Color
      },
      dropDownMenu: {
        accentColor: palette.primary3Color
      },
      menuItem: {
        hoverColor: '#f5f6f7',
        selectedTextColor: palette.primary3Color
      }
    };

    return obj;
  },

  getSnackbarStyles() {
    return {
      left: 'auto',
      marginLeft: 0,
      right: 0,
      height: '40px',
      lineHeight: '40px',
      color: 'white',
      marginRight: 24,
      pointerEvents: 'none',
      backgroundColor: '#4a90e2',
      textShadow: '0 1px 1px rgba(0,0,0,.3)'
    };
  }
};

export default ActorTheme;
<|endoftext|>


<commit_before>Prism.languages.haskell= {
	'comment': {
		pattern: /(^|[^-!#$%*+=\?&@|~.:<>^\\])(--[^-!#$%*+=\?&@|~.:<>^\\].*(\r?\n|$)|{-[\w\W]*?-})/gm,
		lookbehind: true
	},
	'string': /("|')(\\?.)*?\1/g,
	'keyword' : /\b(case|class|data|deriving|do|else|if|in|infixl|infixr|instance|let|module|newtype|of|primitive|then|type|where)\b/g,
	'import_statement' : {
		// The imported or hidden names are not included in this import
		// statement. This is because we want to highlight those exactly like
		// we do for the names in the program.
		pattern: /(\n|^)\s*(import)\s+(qualified\s+)?(([A-Z][_a-zA-Z0-9']*)(\.[A-Z][_a-zA-Z0-9']*)*)(\s+(as)\s+(([A-Z][_a-zA-Z0-9']*)(\.[A-Z][_a-zA-Z0-9']*)*))?(\s+hiding\b)?/gm,
		inside: {
			'keyword': /\b(import|qualified|as|hiding)\b/g
		}
	},
	// These are builtin variables only. Constructors are highlighted later as a constant.
	'builtin': /\b(abs|acos|acosh|all|and|any|appendFile|approxRational|asTypeOf|asin|asinh|atan|atan2|atanh|basicIORun|break|catch|ceiling|chr|compare|concat|concatMap|const|cos|cosh|curry|cycle|decodeFloat|denominator|digitToInt|div|divMod|drop|dropWhile|either|elem|encodeFloat|enumFrom|enumFromThen|enumFromThenTo|enumFromTo|error|even|exp|exponent|fail|filter|flip|floatDigits|floatRadix|floatRange|floor|fmap|foldl|foldl1|foldr|foldr1|fromDouble|fromEnum|fromInt|fromInteger|fromIntegral|fromRational|fst|gcd|getChar|getContents|getLine|group|head|id|inRange|index|init|intToDigit|interact|ioError|isAlpha|isAlphaNum|isAscii|isControl|isDenormalized|isDigit|isHexDigit|isIEEE|isInfinite|isLower|isNaN|isNegativeZero|isOctDigit|isPrint|isSpace|isUpper|iterate|last|lcm|length|lex|lexDigits|lexLitChar|lines|log|logBase|lookup|map|mapM|mapM_|max|maxBound|maximum|maybe|min|minBound|minimum|mod|negate|not|notElem|null|numerator|odd|or|ord|otherwise|pack|pi|pred|primExitWith|print|product|properFraction|putChar|putStr|putStrLn|quot|quotRem|range|rangeSize|read|readDec|readFile|readFloat|readHex|readIO|readInt|readList|readLitChar|readLn|readOct|readParen|readSigned|reads|readsPrec|realToFrac|recip|rem|repeat|replicate|return|reverse|round|scaleFloat|scanl|scanl1|scanr|scanr1|seq|sequence|sequence_|show|showChar|showInt|showList|showLitChar|showParen|showSigned|showString|shows|showsPrec|significand|signum|sin|sinh|snd|sort|span|splitAt|sqrt|subtract|succ|sum|tail|take|takeWhile|tan|tanh|threadToIOResult|toEnum|toInt|toInteger|toLower|toRational|toUpper|truncate|uncurry|undefined|unlines|until|unwords|unzip|unzip3|userError|words|writeFile|zip|zip3|zipWith|zipWith3)\b/g,
	// Most of this is needed because of the meaning of a single '.'.
	// If it stands alone freely, it is the function composition.
	// It may also be a separator between a package name and an identifier => no
	// operator. If it comes together with other special characters it is an
	// operator too.
	'operator' : /\s\.\s|([-!#$%*+=\?&@|~:<>^\\]*\.[-!#$%*+=\?&@|~:<>^\\]+)|([-!#$%*+=\?&@|~:<>^\\]+\.[-!#$%*+=\?&@|~:<>^\\]*)|[-!#$%*+=\?&@|~:<>^\\]+|(`([A-Z][_a-zA-Z0-9']*\.)*[_a-z][_a-zA-Z0-9']*`)/g,
	// In Haskell, nearly everything is a variable, do not highlight these.
	'hvariable': /\b([A-Z][_a-zA-Z0-9']*\.)*[_a-z][_a-zA-Z0-9']*\b/g,
	'constant': /\b([A-Z][_a-zA-Z0-9']*\.)*[A-Z][_a-zA-Z0-9']*\b/g,
	'number' : /\b-?\d*(\.?\d+)\b/g,
	'ignore' : /&(lt|gt|amp);/gi,
	'punctuation' : /[{}[\];(),.:]/g
};
<commit_msg>Fix documentation Haskell language definitions<commit_after>Prism.languages.haskell= {
	'comment': {
		pattern: /(^|[^-!#$%*+=\?&@|~.:<>^\\])(--[^-!#$%*+=\?&@|~.:<>^\\].*(\r?\n|$)|{-[\w\W]*?-})/gm,
		lookbehind: true
	},
	'string': /("|')(\\?.)*?\1/g,
	'keyword' : /\b(case|class|data|deriving|do|else|if|in|infixl|infixr|instance|let|module|newtype|of|primitive|then|type|where)\b/g,
	'import_statement' : {
		// The imported or hidden names are not included in this import
		// statement. This is because we want to highlight those exactly like
		// we do for the names in the program.
		pattern: /(\n|^)\s*(import)\s+(qualified\s+)?(([A-Z][_a-zA-Z0-9']*)(\.[A-Z][_a-zA-Z0-9']*)*)(\s+(as)\s+(([A-Z][_a-zA-Z0-9']*)(\.[A-Z][_a-zA-Z0-9']*)*))?(\s+hiding\b)?/gm,
		inside: {
			'keyword': /\b(import|qualified|as|hiding)\b/g
		}
	},
	// These are builtin variables only. Constructors are highlighted later as a constant.
	'builtin': /\b(abs|acos|acosh|all|and|any|appendFile|approxRational|asTypeOf|asin|asinh|atan|atan2|atanh|basicIORun|break|catch|ceiling|chr|compare|concat|concatMap|const|cos|cosh|curry|cycle|decodeFloat|denominator|digitToInt|div|divMod|drop|dropWhile|either|elem|encodeFloat|enumFrom|enumFromThen|enumFromThenTo|enumFromTo|error|even|exp|exponent|fail|filter|flip|floatDigits|floatRadix|floatRange|floor|fmap|foldl|foldl1|foldr|foldr1|fromDouble|fromEnum|fromInt|fromInteger|fromIntegral|fromRational|fst|gcd|getChar|getContents|getLine|group|head|id|inRange|index|init|intToDigit|interact|ioError|isAlpha|isAlphaNum|isAscii|isControl|isDenormalized|isDigit|isHexDigit|isIEEE|isInfinite|isLower|isNaN|isNegativeZero|isOctDigit|isPrint|isSpace|isUpper|iterate|last|lcm|length|lex|lexDigits|lexLitChar|lines|log|logBase|lookup|map|mapM|mapM_|max|maxBound|maximum|maybe|min|minBound|minimum|mod|negate|not|notElem|null|numerator|odd|or|ord|otherwise|pack|pi|pred|primExitWith|print|product|properFraction|putChar|putStr|putStrLn|quot|quotRem|range|rangeSize|read|readDec|readFile|readFloat|readHex|readIO|readInt|readList|readLitChar|readLn|readOct|readParen|readSigned|reads|readsPrec|realToFrac|recip|rem|repeat|replicate|return|reverse|round|scaleFloat|scanl|scanl1|scanr|scanr1|seq|sequence|sequence_|show|showChar|showInt|showList|showLitChar|showParen|showSigned|showString|shows|showsPrec|significand|signum|sin|sinh|snd|sort|span|splitAt|sqrt|subtract|succ|sum|tail|take|takeWhile|tan|tanh|threadToIOResult|toEnum|toInt|toInteger|toLower|toRational|toUpper|truncate|uncurry|undefined|unlines|until|unwords|unzip|unzip3|userError|words|writeFile|zip|zip3|zipWith|zipWith3)\b/g,
	// Most of this is needed because of the meaning of a single '.'.
	// If it stands alone freely, it is the function composition.
	// It may also be a separator between a module name and an identifier => no
	// operator. If it comes together with other special characters it is an
	// operator too.
	'operator' : /\s\.\s|([-!#$%*+=\?&@|~:<>^\\]*\.[-!#$%*+=\?&@|~:<>^\\]+)|([-!#$%*+=\?&@|~:<>^\\]+\.[-!#$%*+=\?&@|~:<>^\\]*)|[-!#$%*+=\?&@|~:<>^\\]+|(`([A-Z][_a-zA-Z0-9']*\.)*[_a-z][_a-zA-Z0-9']*`)/g,
	// In Haskell, nearly everything is a variable, do not highlight these.
	'hvariable': /\b([A-Z][_a-zA-Z0-9']*\.)*[_a-z][_a-zA-Z0-9']*\b/g,
	'constant': /\b([A-Z][_a-zA-Z0-9']*\.)*[A-Z][_a-zA-Z0-9']*\b/g,
	'number' : /\b-?\d*(\.?\d+)\b/g,
	'ignore' : /&(lt|gt|amp);/gi,
	'punctuation' : /[{}[\];(),.:]/g
};
<|endoftext|>


<commit_before>(function(a){a.fn.extend({datetimeparse:function(b){function t(a){var b=new Date;if(a>b){return true}return false}function s(a){switch(a.toLowerCase()){case"sun":case"sunday":var b=0;break;case"mon":case"monday":var b=1;break;case"tue":case"tues":case"tuesday":var b=2;break;case"wed":case"wednesday":var b=3;break;case"thur":case"thurs":case"thursday":var b=4;break;case"fri":case"friday":var b=5;break;case"sat":case"saturday":var b=6;break}if(b!=undefined){return b}return false}function r(a){if(a==undefined){return false}timeArray=a.split(":");for(var b=0;b<timeArray.length;b++){if(isNaN(parseInt(timeArray[b]))){return false}}if(a.length<=2&&timeArray.length==1){return true}if(timeArray.length==2){return true}if(timeArray.length==3){return true}return false}function q(a){var b=false;switch(a){case"a":case"am":b=true;break;case"p":case"pm":b=true;break}return b}function p(b){b=a.trim(b);if(b.substr(-1)=="/"){return false}if(b.length<=5){return b.charAt(1)=="/"||b.charAt(2)=="/"}else{var c=b.split("/").pop();if(c.length!=2&&c.length!=4){return false}var d=b.charAt(1)=="/"||b.charAt(2)=="/";var e=b.charAt(3)=="/"||b.charAt(4)=="/"||b.charAt(5)=="/";return d&&e}}function o(a,b){return}function n(a,b){return}function m(a){a=typeof a!="undefined"?a:new Date;a.setHours(b.hours);a.setMinutes(b.minutes);a.setSeconds(b.seconds);a.setMilliseconds(b.milliseconds);return a}function l(a){timeArray=a.split(":");if(timeArray.length<3){return 0}return timeArray[2]}function k(a,b){var c=a.split(":");var d=parseInt(c[0]);if(b==undefined){b="am"}if(b.indexOf("a")!=-1){if(d>11){d=d-12}}else{if(d<=11){d=d+12}}return d}function j(a){timeArray=a.split(":");if(timeArray.length<2){return 0}return timeArray[1]}function i(a,b){var c=b.getHours();var d=b.getDay();if(d==a){b.setHours(c+24*7)}else if(d<a){b.setHours(c+24*(a-d))}else if(d>a){b.setHours(c+24*(a-d+7))}return b}function h(a,b,c){switch(b){case"second":case"seconds":c.setSeconds(c.getSeconds()-a);break;case"minute":case"minutes":c.setMinutes(c.getMinutes()-a);break;case"hour":case"hours":c.setHours(c.getHours()-a);break;case"day":case"days":c.setHours(c.getHours()-24*a);break;case"week":case"weeks":c.setHours(c.getHours()-168*a);break;case"month":case"months":c.setMonth(c.getMonth()-a);break;case"year":case"years":c.setFullYear(c.getFullYear()-a);break}}function g(a,b,c){a=parseInt(a);switch(b){case"second":case"seconds":c.setSeconds(c.getSeconds()+a);break;case"minute":case"minutes":c.setMinutes(c.getMinutes()+a);break;case"hour":case"hours":c.setHours(c.getHours()+a);break;case"day":case"days":c.setHours(c.getHours()+24*a);break;case"week":case"weeks":c.setHours(c.getHours()+168*a);break;case"month":case"months":c.setMonth(c.getMonth()+a);break;case"year":case"years":c.setFullYear(c.getFullYear()+a);break}}function f(a){var b=new Date;while(a<b){var c=a.getHours();a.setHours(c+24)}return a}function e(a,c,e){if(e==null){e=new Date;e=m(e)}if(p(a)){e=new Date(c[0]);e=m(d)}else if(r(a)){var n=k(a,c[0]);var o=j(a);var q=l(a);e.setHours(n);e.setMinutes(o);e.setSeconds(q);c.shift()}else if(s(a)!=false){var t=s(a);e=i(t,e)}else if(a=="at"){if(r(c[0])){var n=k(c[0],c[1]);var o=j(c[0]);var q=l(c[0]);e.setHours(n);(function(a){a.fn.extend({datetimeparse:function(b){function t(a){var b=new Date;if(a>b){return true}return false}function s(a){switch(a.toLowerCase()){case"sun":case"sunday":var b=0;break;case"mon":case"monday":var b=1;break;case"tue":case"tues":case"tuesday":var b=2;break;case"wed":case"wednesday":var b=3;break;case"thur":case"thurs":case"thursday":var b=4;break;case"fri":case"friday":var b=5;break;case"sat":case"saturday":var b=6;break}if(b!=undefined){return b}return false}function r(a){if(a==undefined){return false}timeArray=a.split(":");for(var b=0;b<timeArray.length;b++){if(isNaN(parseInt(timeArray[b]))){return false}}if(a.length<=2&&timeArray.length==1){return true}if(timeArray.length==2){return true}if(timeArray.length==3){return true}return false}function q(a){var b=false;switch(a){case"a":case"am":b=true;break;case"p":case"pm":b=true;break}return b}function p(b){b=a.trim(b);if(b.substr(-1)=="/"){return false}if(b.length<=5){return b.charAt(1)=="/"||b.charAt(2)=="/"}else{var c=b.split("/").pop();if(c.length!=2&&c.length!=4){return false}var d=b.charAt(1)=="/"||b.charAt(2)=="/";var e=b.charAt(3)=="/"||b.charAt(4)=="/"||b.charAt(5)=="/";return d&&e}}function o(a,b){return}function n(a,b){return}function m(a){a=typeof a!="undefined"?a:new Date;a.setHours(b.hours);a.setMinutes(b.minutes);a.setSeconds(b.seconds);a.setMilliseconds(b.milliseconds);return a}function l(a){timeArray=a.split(":");if(timeArray.length<3){return 0}return timeArray[2]}function k(a,b){var c=a.split(":");var d=parseInt(c[0]);if(b==undefined){b="am"}if(b.indexOf("a")!=-1){if(d>11){d=d-12}}else{if(d<=11){d=d+12}}return d}function j(a){timeArray=a.split(":");if(timeArray.length<2){return 0}return timeArray[1]}function i(a,b){var c=b.getHours();var d=b.getDay();if(d==a){b.setHours(c+24*7)}else if(d<a){b.setHours(c+24*(a-d))}else if(d>a){b.setHours(c+24*(a-d+7))}return b}function h(a,b,c){switch(b){case"second":case"seconds":c.setSeconds(c.getSeconds()-a);break;case"minute":case"minutes":c.setMinutes(c.getMinutes()-a);break;case"hour":case"hours":c.setHours(c.getHours()-a);break;case"day":case"days":c.setHours(c.getHours()-24*a);break;case"week":case"weeks":c.setHours(c.getHours()-168*a);break;case"month":case"months":c.setMonth(c.getMonth()-a);break;case"year":case"years":c.setFullYear(c.getFullYear()-a);break}}function g(a,b,c){a=parseInt(a);switch(b){case"second":case"seconds":c.setSeconds(c.getSeconds()+a);break;case"minute":case"minutes":c.setMinutes(c.getMinutes()+a);break;case"hour":case"hours":c.setHours(c.getHours()+a);break;case"day":case"days":c.setHours(c.getHours()+24*a);break;case"week":case"weeks":c.setHours(c.getHours()+168*a);break;case"month":case"months":c.setMonth(c.getMonth()+a);break;case"year":case"years":c.setFullYear(c.getFullYear()+a);break}}function f(a){var b=new Date;while(a<b){var c=a.getHours();a.setHours(c+24)}return a}function e(a,c,e){if(e==null){e=new Date;e=m(e)}if(p(a)){e=new Date(c[0]);e=m(d)}else if(r(a)){var n=k(a,c[0]);var o=j(a);var q=l(a);e.setHours(n);e.setMinutes(o);e.setSeconds(q);c.shift()}else if(s(a)!=false){var t=s(a);e=i(t,e)}else if(a=="at"){if(r(c[0])){var n=k(c[0],c[1]);var o=j(c[0]);var q=l(c[0]);e.setHours(n);e.setMinutes(o);e.setSeconds(q);c.shift()}}else if(a=="on"){if(p(c[0])){oldHours=e.getHours();oldMinutes=e.getMinutes();oldSeconds=e.getSeconds();oldMilliseconds=e.getMilliseconds();e=new Date(c[0]);e.setHours(oldHours);e.setMinutes(oldMinutes);e.setSeconds(oldSeconds);e.setMilliseconds(oldMilliseconds)}else if(s(c[0])!=false){dotw=s(c[0]);i(dotw,e)}c.shift()}else if(a=="+"){g(c[0],c[1],e);c.shift();c.shift()}else if(a=="-"){h(c[0],c[1],e);c.shift();c.shift()}else if(a=="tom"||a=="tomorrow"){e=m(e);e.setHours(24)}else if(a=="today"){e=m(new Date)}else if(a=="now"){e=new Date}if(b.assumeFuture){e=f(e)}return e}var c={hours:0,minutes:0,seconds:0,milliseconds:0,assumeFuture:true};var b=a.extend(c,b);var d=null;this.each(function(){var b=a.trim(a(this).val());var c=b.split(" ");while(c.length>0){var f=e(c.shift(),c,d);if(f!=null){d=f}}});if(d==undefined){return"Something went wrong!"}return d}})})(jQuery);e.setMinutes(o);e.setSeconds(q);c.shift()}}else if(a=="on"){if(p(c[0])){oldHours=e.getHours();oldMinutes=e.getMinutes();oldSeconds=e.getSeconds();oldMilliseconds=e.getMilliseconds();e=new Date(c[0]);e.setHours(oldHours);e.setMinutes(oldMinutes);e.setSeconds(oldSeconds);e.setMilliseconds(oldMilliseconds)}else if(s(c[0])!=false){dotw=s(c[0]);i(dotw,e)}c.shift()}else if(a=="+"){g(c[0],c[1],e);c.shift();c.shift()}else if(a=="-"){h(c[0],c[1],e);c.shift();c.shift()}else if(a=="tom"||a=="tomorrow"){e=m(e);e.setHours(24)}else if(a=="today"){e=m(new Date)}else if(a=="now"){e=new Date}if(b.assumeFuture){e=f(e)}return e}var c={hours:0,minutes:0,seconds:0,milliseconds:0,assumeFuture:false};var b=a.extend(c,b);var d=null;this.each(function(){var b=a.trim(a(this).val());var c=b.split(" ");while(c.length>0){var f=e(c.shift(),c,d);if(f!=null){d=f}}});if(d==undefined){return"Something went wrong!"}return d}})})(jQuery)<commit_msg>Updated minified version.<commit_after>(function(a){a.fn.extend({datetimeparse:function(b){function t(a){var b=new Date;if(a>b){return true}return false}function s(a){switch(a.toLowerCase()){case"sun":case"sunday":var b=0;break;case"mon":case"monday":var b=1;break;case"tue":case"tues":case"tuesday":var b=2;break;case"wed":case"wednesday":var b=3;break;case"thur":case"thurs":case"thursday":var b=4;break;case"fri":case"friday":var b=5;break;case"sat":case"saturday":var b=6;break}if(b!=undefined){return b}return false}function r(a){if(a==undefined){return false}timeArray=a.split(":");for(var b=0;b<timeArray.length;b++){if(isNaN(parseInt(timeArray[b]))){return false}}if(a.length<=2&&timeArray.length==1){return true}if(timeArray.length==2){return true}if(timeArray.length==3){return true}return false}function q(a){var b=false;switch(a){case"a":case"am":b=true;break;case"p":case"pm":b=true;break}return b}function p(b){b=a.trim(b);if(b.substr(-1)=="/"){return false}if(b.length<=5){return b.charAt(1)=="/"||b.charAt(2)=="/"}else{var c=b.split("/").pop();if(c.length!=2&&c.length!=4){return false}var d=b.charAt(1)=="/"||b.charAt(2)=="/";var e=b.charAt(3)=="/"||b.charAt(4)=="/"||b.charAt(5)=="/";return d&&e}}function o(a,b){return}function n(a,b){return}function m(a){a=typeof a!="undefined"?a:new Date;a.setHours(b.hours);a.setMinutes(b.minutes);a.setSeconds(b.seconds);a.setMilliseconds(b.milliseconds);return a}function l(a){timeArray=a.split(":");if(timeArray.length<3){return 0}return timeArray[2]}function k(a,b){var c=a.split(":");var d=parseInt(c[0]);if(b==undefined){b="am"}if(b.indexOf("a")!=-1){if(d>11){d=d-12}}else{if(d<=11){d=d+12}}return d}function j(a){timeArray=a.split(":");if(timeArray.length<2){return 0}return timeArray[1]}function i(a,b){var c=b.getHours();var d=b.getDay();if(d==a){b.setHours(c+24*7)}else if(d<a){b.setHours(c+24*(a-d))}else if(d>a){b.setHours(c+24*(a-d+7))}return b}function h(a,b,c){switch(b){case"second":case"seconds":c.setSeconds(c.getSeconds()-a);break;case"minute":case"minutes":c.setMinutes(c.getMinutes()-a);break;case"hour":case"hours":c.setHours(c.getHours()-a);break;case"day":case"days":c.setHours(c.getHours()-24*a);break;case"week":case"weeks":c.setHours(c.getHours()-168*a);break;case"month":case"months":c.setMonth(c.getMonth()-a);break;case"year":case"years":c.setFullYear(c.getFullYear()-a);break}}function g(a,b,c){a=parseInt(a);switch(b){case"second":case"seconds":c.setSeconds(c.getSeconds()+a);break;case"minute":case"minutes":c.setMinutes(c.getMinutes()+a);break;case"hour":case"hours":c.setHours(c.getHours()+a);break;case"day":case"days":c.setHours(c.getHours()+24*a);break;case"week":case"weeks":c.setHours(c.getHours()+168*a);break;case"month":case"months":c.setMonth(c.getMonth()+a);break;case"year":case"years":c.setFullYear(c.getFullYear()+a);break}}function f(a){var b=new Date;while(a<b){var c=a.getHours();a.setHours(c+24)}return a}function e(a,c,e){if(e==null){e=new Date;e=m(e)}if(p(a)){e=new Date(c[0]);e=m(d)}else if(r(a)){var n=k(a,c[0]);var o=j(a);var q=l(a);e.setHours(n);e.setMinutes(o);e.setSeconds(q);c.shift()}else if(s(a)!=false){var t=s(a);e=i(t,e)}else if(a=="at"){if(r(c[0])){var n=k(c[0],c[1]);var o=j(c[0]);var q=l(c[0]);e.setHours(n);e.setMinutes(o);e.setSeconds(q);c.shift()}}else if(a=="on"){if(p(c[0])){oldHours=e.getHours();oldMinutes=e.getMinutes();oldSeconds=e.getSeconds();oldMilliseconds=e.getMilliseconds();e=new Date(c[0]);e.setHours(oldHours);e.setMinutes(oldMinutes);e.setSeconds(oldSeconds);e.setMilliseconds(oldMilliseconds)}else if(s(c[0])!=false){dotw=s(c[0]);i(dotw,e)}c.shift()}else if(a=="+"){g(c[0],c[1],e);c.shift();c.shift()}else if(a=="-"){h(c[0],c[1],e);c.shift();c.shift()}else if(a=="tom"||a=="tomorrow"){e=m(e);e.setHours(24)}else if(a=="today"){e=m(new Date)}else if(a=="now"){e=new Date}if(b.assumeFuture){e=f(e)}return e}var c={hours:0,minutes:0,seconds:0,milliseconds:0,assumeFuture:false};var b=a.extend(c,b);var d=null;this.each(function(){var b=a.trim(a(this).val());var c=b.split(" ");while(c.length>0){var f=e(c.shift(),c,d);if(f!=null){d=f}}});if(d==undefined){return"Something went wrong!"}return d}})})(jQuery)<|endoftext|>


<commit_before>import React, { PureComponent } from 'react';
import ReactSelect from 'react-select';
import PropTypes from 'prop-types';
import { IconChevronDownSmallOutline } from '@teamleader/ui-icons';
import { Button } from '../button';
import theme from './theme.css';

class Select extends PureComponent {
  state = {
    selectedOptions: [],
  };

  getControlStyles = (base, { isDisabled, isFocused }) => {
    const { inverse, size } = this.props;

    if(inverse) {
      return {
        ...base,
        backgroundColor: isDisabled ? '#3F4F61' : '#64788f',
        '&:hover': {
          borderColor: '#c1cede',
        },
        borderColor: isFocused ? '#c1cede' : isDisabled ? '#3F4F61' : '#64788f',
        boxShadow: isFocused ? '0 0 0 1px #c1cede' : 'none',
        minHeight: size === 'small' ? '30px' : size === 'medium' ? '36px' : '48px',
      };
    }

    return {
      ...base,
      backgroundColor: isDisabled ? '#e4e4e6' : '#fff',
      '&:hover': {
        borderColor: '#82828c',
      },
      borderColor: isFocused ? '#82828c' : isDisabled ? '#e4e4e6' : '#c0c0c4',
      boxShadow: isFocused ? '0 0 0 1px #82828c' : 'none',
      minHeight: size === 'small' ? '30px' : size === 'medium' ? '36px' : '48px',
    };
  };

  getDropDownIndicator = () => ({ isDisabled }) => (
    <Button
      className={theme['dropdown-indicator']}
      disabled={isDisabled}
      icon={<IconChevronDownSmallOutline />}
      size={this.props.size}
    />
  );

  getStyles = (size) => ({
    control: (base, { isDisabled, isFocused }) => this.getControlStyles(base, { isDisabled, isFocused }),
    indicatorSeparator: (base) => ({
      ...base,
      marginTop: 0,
      marginBottom: 0,
    }),
    option: (base, { isFocused, isSelected }) => ({
      ...base,
      color: '#344b63',
      backgroundColor: isFocused ? '#e4e4e6' : isSelected ? '#f7f7fa' : '#fff',
      '&:active': {
        backgroundColor: '#e4e4e6'
      },
    }),
  });

  handleChange = values => {
    this.setState({ selectedOptions: values });
  };

  render() {
    const { size, ...others } = this.props;
    const { selectedOptions } = this.state;

    return (
      <ReactSelect
        className={theme['select']}
        components={{ DropdownIndicator: this.getDropDownIndicator() }}
        onChange={this.handleChange}
        styles={this.getStyles(size)}
        value={selectedOptions}
        {...others}
      />
    );
  }
}

Select.propTypes = {
  /** Boolean indicating whether the select should render as inverse. */
  inverse: PropTypes.bool,
  size: PropTypes.oneOf(['small', 'medium', 'large']),
};

Select.defaultProps = {
  inverse: false,
  size: 'medium',
};

export default Select;
<commit_msg>Move indicator separator styles to a class method<commit_after>import React, { PureComponent } from 'react';
import ReactSelect from 'react-select';
import PropTypes from 'prop-types';
import { IconChevronDownSmallOutline } from '@teamleader/ui-icons';
import { Button } from '../button';
import theme from './theme.css';

class Select extends PureComponent {
  state = {
    selectedOptions: [],
  };

  getControlStyles = (base, { isDisabled, isFocused }) => {
    const { inverse, size } = this.props;

    if(inverse) {
      return {
        ...base,
        backgroundColor: isDisabled ? '#3F4F61' : '#64788f',
        '&:hover': {
          borderColor: '#c1cede',
        },
        borderColor: isFocused ? '#c1cede' : isDisabled ? '#3F4F61' : '#64788f',
        boxShadow: isFocused ? '0 0 0 1px #c1cede' : 'none',
        minHeight: size === 'small' ? '30px' : size === 'medium' ? '36px' : '48px',
      };
    }

    return {
      ...base,
      backgroundColor: isDisabled ? '#e4e4e6' : '#fff',
      '&:hover': {
        borderColor: '#82828c',
      },
      borderColor: isFocused ? '#82828c' : isDisabled ? '#e4e4e6' : '#c0c0c4',
      boxShadow: isFocused ? '0 0 0 1px #82828c' : 'none',
      minHeight: size === 'small' ? '30px' : size === 'medium' ? '36px' : '48px',
    };
  };

  getIndicatorSeparatorStyles = (base) => ({
    ...base,
    backgroundColor: this.props.inverse ? '#64788f' : '#c0c0c4',
    marginTop: 0,
    marginBottom: 0,
  });

  getDropDownIndicator = () => ({ isDisabled }) => (
    <Button
      className={theme['dropdown-indicator']}
      disabled={isDisabled}
      icon={<IconChevronDownSmallOutline />}
      size={this.props.size}
    />
  );

  getStyles = (size) => ({
    control: (base, { isDisabled, isFocused }) => this.getControlStyles(base, { isDisabled, isFocused }),
    indicatorSeparator: (base) => this.getIndicatorSeparatorStyles(base),
    option: (base, { isFocused, isSelected }) => ({
      ...base,
      color: '#344b63',
      backgroundColor: isFocused ? '#e4e4e6' : isSelected ? '#f7f7fa' : '#fff',
      '&:active': {
        backgroundColor: '#e4e4e6'
      },
    }),
  });

  handleChange = values => {
    this.setState({ selectedOptions: values });
  };

  render() {
    const { size, ...others } = this.props;
    const { selectedOptions } = this.state;

    return (
      <ReactSelect
        className={theme['select']}
        components={{ DropdownIndicator: this.getDropDownIndicator() }}
        onChange={this.handleChange}
        styles={this.getStyles(size)}
        value={selectedOptions}
        {...others}
      />
    );
  }
}

Select.propTypes = {
  /** Boolean indicating whether the select should render as inverse. */
  inverse: PropTypes.bool,
  size: PropTypes.oneOf(['small', 'medium', 'large']),
};

Select.defaultProps = {
  inverse: false,
  size: 'medium',
};

export default Select;
<|endoftext|>


<commit_before>import {defaultsDeep, forEach} from 'lodash'

export const selectProject = (state, slug) => {
  const project = state.projects[slug]

  return defaultsDeep({}, project, defaultProject)
}

export const getFilteredProjects = state => {
  const projects = Object.values(state.projects)
  const filters = state.filters

  return projects.filter(project => {
    // by default let's assume both advisor and categories match for all projects
    let matchAdvisor = true
    let matchCategory = true
    let matchSearch = true

    // if filters.advisor is set, update matchAdvisor boolean
    if (filters.advisor !== '') {
      matchAdvisor = project.advisor_id === filters.advisor
    }

    // if filters.category is set, update matchCategory boolean
    if (filters.category !== '') {
      // we use lodash.get here to protect
      // matchCategory = (project.topics[0] && get(project, 'topics[0].slug') === filters.category) || (project.topics[1] && get(project, 'topics[1].slug') === filters.category)
      forEach(project.topics, topic => {
        if (topic.slug !== filters.category) {
          matchCategory = false
        } else {
          matchCategory = true
          return false
        }
      })

    }

    if (filters.search !== null && filters.search !== []) {
      matchSearch = filters.search.indexOf(parseInt(project.student_id)) !== -1
    }

    // apply both categories and return
    return matchCategory && matchAdvisor && matchSearch
  })
}

const defaultProject = {
  student_id: '',
  student_name: '',
  student_slug: '',
  advisor_id: '',
  project_title: '',
  project_question: '',
  video_presentation_url: '',
  portfolio_icon: {
    src: '',
    title: '',
    alt: '',
    caption: '',
  },
  topics: [{
    name: '',
    slug: '',
  }],
  slide_show: [],
}
<commit_msg>fixed filter category<commit_after>import {defaultsDeep, forEach, reduce} from 'lodash'

export const selectProject = (state, slug) => {
  const project = state.projects[slug]

  return defaultsDeep({}, project, defaultProject)
}

export const getFilteredProjects = state => {
  const projects = Object.values(state.projects)
  const filters = state.filters

  return projects.filter(project => {
    // by default let's assume both advisor and categories match for all projects
    let matchAdvisor = true
    let matchCategory = true
    let matchSearch = true

    // if filters.advisor is set, update matchAdvisor boolean
    if (filters.advisor !== '') {
      matchAdvisor = project.advisor_id === filters.advisor
    }

    // if filters.category is set, update matchCategory boolean
    if (filters.category !== '') {
      // we use lodash.get here to protect
      // matchCategory = (project.topics[0] && get(project, 'topics[0].slug') === filters.category) || (project.topics[1] && get(project, 'topics[1].slug') === filters.category)
      const alltopics = reduce(project.topics, (acc, topic) => {
        return acc + topic.slug
      }, '')
      matchCategory = alltopics.indexOf(filters.category) === -1 ? false : true
    }

    if (filters.search !== null && filters.search !== []) {
      matchSearch = filters.search.indexOf(parseInt(project.student_id)) !== -1
    }

    // apply both categories and return
    return matchCategory && matchAdvisor && matchSearch
  })
}

const defaultProject = {
  student_id: '',
  student_name: '',
  student_slug: '',
  advisor_id: '',
  project_title: '',
  project_question: '',
  video_presentation_url: '',
  portfolio_icon: {
    src: '',
    title: '',
    alt: '',
    caption: '',
  },
  topics: [{
    name: '',
    slug: '',
  }],
  slide_show: [],
}
<|endoftext|>


<commit_before>#!/usr/bin/env node

var program = require('commander')
var command
var env
program
    .usage('[options]')
    .option('-f, --file [file]', 'config file - defaults to testem.json or testem.yml')
    .option('-p, --port [num]', 'server port - defaults to 7357', Number)
    .option('-l, --launch [list]', 'list of launchers to launch(comma separated)')
    .option('-s, --skip [list]', 'list of launchers to skip(comma separated)')
    .option('-d, --debug', 'output debug to debug log - testem.log')

program
    .command('launchers')
    .description('Print the list of available launchers (browsers & process launchers)')
    .action(function(e){
        env = e
        console.log(env)

    })

program
    .command('ci')
    .description('Continuous integration mode')
    .option('-t, --timeout [sec]', 'timeout a browser after [sec] seconds', null)
    .action(function(e){
        env = e
        console.log(env.skip)
        command = 'ci'
    })

program.parse(process.argv)

console.log(program)

<commit_msg>Update cli help to say milliseconds<commit_after>#!/usr/bin/env node

var program = require('commander')
var command
var env
program
    .usage('[options]')
    .option('-f, --file [file]', 'config file - defaults to testem.json or testem.yml')
    .option('-p, --port [num]', 'server port - defaults to 7357', Number)
    .option('-l, --launch [list]', 'list of launchers to launch(comma separated)')
    .option('-s, --skip [list]', 'list of launchers to skip(comma separated)')
    .option('-d, --debug', 'output debug to debug log - testem.log')

program
    .command('launchers')
    .description('Print the list of available launchers (browsers & process launchers)')
    .action(function(e){
        env = e
        console.log(env)

    })

program
    .command('ci')
    .description('Continuous integration mode')
    .option('-t, --timeout [ms]', 'timeout a browser after [ms] milliseconds', null)
    .action(function(e){
        env = e
        console.log(env.skip)
        command = 'ci'
    })

program.parse(process.argv)

console.log(program)

<|endoftext|>


<commit_before>'use strict';

var $ = require('jquery'),
    toggles = require('../libs/jquery-toggles/toggles.min');

function MasterSwitchComponent(html) {

    this.$html = html;

};

MasterSwitchComponent.prototype.init = function () {

    var component = this;

    component.$container = this.$html.find('.masterswitch');

    component.$container.each(function() {

        var $this = $(this);

        this.$control = $this.find('.masterswitch-control input');
        this.$content = $this.find('.masterswitch-content');
        this.$toggle = $this.find('.toggle');

        this.$toggle.toggles({
            checkbox: this.$control,
            on: this.$control.prop('checked'),
            text: {
                on: '',
                off: ''
            }
        });

        if (!this.$control.prop('checked')) {
            component.disableElements(this.$content);
        } else {
            component.switchOn(this.$control);
            component.enableElements(this.$content);
        }

        this.$toggle.on('toggle', function (e, active) {
            if (active) {
                component.switchOn(e.target);
            } else {
                component.switchOff(e.target);
            }
        });
    });

};

MasterSwitchComponent.prototype.switchOn = function (target) {

    var component = this;

    component.$target = $(target).closest('.masterswitch').find('.masterswitch-content');

    component.$target.removeClass('is-disabled');
    component.enableElements(component.$target);
};

MasterSwitchComponent.prototype.switchOff = function (target) {

    var component = this;

    component.$target = $(target).closest('.masterswitch').find('.masterswitch-content');

    component.$target.addClass('is-disabled');
    component.disableElements(component.$target);
};

MasterSwitchComponent.prototype.disableElements = function (target) {

    var component = this,
        CLICKABLES_SELECTOR = 'a, button, input, select';

    $(target)
        .on('click', CLICKABLES_SELECTOR, preventDefault)
        .find(CLICKABLES_SELECTOR)
            .addClass('disabled')
            .attr('disabled', 'disabled');

};

MasterSwitchComponent.prototype.enableElements = function (target) {

    var component = this,
        CLICKABLES_SELECTOR = 'a, button, input, select';

    $(target)
        .off('click', CLICKABLES_SELECTOR, preventDefault)
        .find(CLICKABLES_SELECTOR)
            .removeClass('disabled')
            .removeAttr('disabled')

};

function preventDefault(e) {
    e.preventDefault();
}

module.exports = MasterSwitchComponent;
<commit_msg>Remove jquery-toggles dependency from MasterSwitchComponent<commit_after>'use strict';

var $ = require('jquery');

function MasterSwitchComponent(html) {

    this.$html = html;

};

MasterSwitchComponent.prototype.init = function () {

    var component = this;

    component.$container = this.$html.find('.masterswitch');

    component.$container.each(function() {

        var $this = $(this);

        this.$control = $this.find('.masterswitch-control input');
        this.$content = $this.find('.masterswitch-content');

        if (!this.$control.prop('checked')) {
            component.disableElements(this.$content);
        } else {
            component.switchOn(this.$control);
            component.enableElements(this.$content);
        }

        this.$control.on('click change', function (e, active) {
            if ($(this).prop('checked')) {
                component.switchOn(e.target);
            } else {
                component.switchOff(e.target);
            }
        });
    });
};

MasterSwitchComponent.prototype.switchOn = function (target) {

    var component = this;

    component.$target = $(target).closest('.masterswitch').find('.masterswitch-content');

    component.$target.removeClass('is-disabled');
    component.enableElements(component.$target);
};

MasterSwitchComponent.prototype.switchOff = function (target) {

    var component = this;

    component.$target = $(target).closest('.masterswitch').find('.masterswitch-content');

    component.$target.addClass('is-disabled');
    component.disableElements(component.$target);
};

MasterSwitchComponent.prototype.disableElements = function (target) {

    var component = this,
        CLICKABLES_SELECTOR = 'a, button, input, select';

    $(target)
        .on('click', CLICKABLES_SELECTOR, preventDefault)
        .find(CLICKABLES_SELECTOR)
            .addClass('disabled')
            .attr('disabled', 'disabled');
};

MasterSwitchComponent.prototype.enableElements = function (target) {

    var component = this,
        CLICKABLES_SELECTOR = 'a, button, input, select';

    $(target)
        .off('click', CLICKABLES_SELECTOR, preventDefault)
        .find(CLICKABLES_SELECTOR)
            .removeClass('disabled')
            .removeAttr('disabled');
};

function preventDefault(e) {
    e.preventDefault();
}

module.exports = MasterSwitchComponent;
<|endoftext|>


<commit_before>////////////////////////////////////////////////////////////////////////////////
/// @brief test the foxx manager
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
///     http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Jan Steemann
/// @author Copyright 2013, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////

var jsunity = require("jsunity");
var fm = require("org/arangodb/foxx-manager");
var arango = require("org/arangodb").arango;

// -----------------------------------------------------------------------------
// --SECTION--                                                foxx manager tests
// -----------------------------------------------------------------------------

////////////////////////////////////////////////////////////////////////////////
/// @brief test suite
////////////////////////////////////////////////////////////////////////////////

function FoxxManagerSuite () {

  return {

////////////////////////////////////////////////////////////////////////////////
/// @brief test update
////////////////////////////////////////////////////////////////////////////////

    testUpdate : function () {
      fm.update();

      var result = fm.availableJson();
      var i, n;

      n = result.length;
      assertTrue(n > 0);

      // validate the results structure
      for (i = 0; i < n; ++i) {
        var entry = result[i];

        assertTrue(entry.hasOwnProperty("description"));
        assertTrue(entry.hasOwnProperty("name"));
        assertTrue(entry.hasOwnProperty("author"));
        assertTrue(entry.hasOwnProperty("latestVersion"));
      }
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test available
////////////////////////////////////////////////////////////////////////////////

    testFetch : function () {
      try {
        fm.purge("itzpapalotl");
      }
      catch (err) {
      }

      fm.update();
      fm.fetch("github", "jsteemann/itzpapalotl");

      var result = fm.fetchedJson(), i;

      for (i = 0; i < result.length; ++i) {
        var entry = result[i];

        if (entry.name === 'itzpapalotl') {
          assertEqual("jsteemann", entry.author);
          assertEqual("itzpapalotl", entry.name);
          assertTrue(entry.hasOwnProperty("description"));
          assertTrue(entry.hasOwnProperty("version"));
          assertTrue(entry.hasOwnProperty("path"));
        }
        return;
       }

      fail();
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test search
////////////////////////////////////////////////////////////////////////////////

    testSearchEmpty : function () {
      var result = fm.searchJson();

      var i, j, n;

      n = result.length;
      assertTrue(n > 0);

      // validate the results structure
      for (i = 0; i < n; ++i) {
        var entry = result[i];

        assertTrue(entry.hasOwnProperty("_key"));
        assertTrue(entry.hasOwnProperty("_rev"));
        assertTrue(entry.hasOwnProperty("description"));
        assertTrue(entry.hasOwnProperty("name"));
        assertTrue(entry.hasOwnProperty("author"));
        assertTrue(entry.hasOwnProperty("versions"));

        versions = entry.versions;

        for (version in entry.versions) {
          if (entry.versions.hasOwnProperty(version)) {
            assertMatch(/^\d+(\.\d+)*$/, version);
            assertTrue(entry.versions[version].hasOwnProperty("type"));
            assertTrue(entry.versions[version].hasOwnProperty("location"));
          }
        }
      }
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test search existings
////////////////////////////////////////////////////////////////////////////////

    testSearchAztec : function () {
      var result = fm.searchJson("itzpapalotl");

      var i, j, n;

      n = result.length;
      assertTrue(n > 0);

      // validate the results structure, simply take the first match
      var entry = result.pop();

      assertEqual("jsteemann", entry.author);
      assertEqual("itzpapalotl", entry.name);
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test install
////////////////////////////////////////////////////////////////////////////////

    testInstallSingle : function () {
      fm.update();

      try {
        fm.uninstall("/itz");
      }
      catch (err) {
      }

      fm.install("itzpapalotl", "/itz");

      var url = '/itz/random';
      var fetched = arango.GET(url);

      assertTrue(fetched.hasOwnProperty("name"));

      fm.uninstall("/itz");
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test install
////////////////////////////////////////////////////////////////////////////////

    testInstallMulti : function () {
      fm.update();

      try {
        fm.uninstall("/itz1");
        fm.uninstall("/itz2");
      }
      catch (err) {
      }

      fm.install("itzpapalotl", "/itz1");
      fm.install("itzpapalotl", "/itz2");

      var url, fetched;

      url  = '/itz1/random';
      fetched = arango.GET(url);
      assertTrue(fetched.hasOwnProperty("name"));

      url  = '/itz2/random';
      fetched = arango.GET(url);

      assertTrue(fetched.hasOwnProperty("name"));

      fm.uninstall("/itz1");
      fm.uninstall("/itz2");
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test uninstall
////////////////////////////////////////////////////////////////////////////////

    testUninstallInstalled : function () {
      fm.update();

      try {
        fm.uninstall("/itz");
      }
      catch (err) {
      }

      fm.install("itzpapalotl", "/itz");
      fm.uninstall("/itz");
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test uninstall
////////////////////////////////////////////////////////////////////////////////

    testUninstallUninstalled : function () {
      fm.update();

      try {
        fm.uninstall("/itz");
      }
      catch (err) {
      }

      try {
        // already uninstalled
        fm.uninstall("/itz");
        fail();
      }
      catch (err) {
      }
    }

  };
}

// -----------------------------------------------------------------------------
// --SECTION--                                                              main
// -----------------------------------------------------------------------------

////////////////////////////////////////////////////////////////////////////////
/// @brief executes the test suite
////////////////////////////////////////////////////////////////////////////////

jsunity.run(FoxxManagerSuite);

return jsunity.done();

// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)"
// End:

<commit_msg>added tests<commit_after>////////////////////////////////////////////////////////////////////////////////
/// @brief test the foxx manager
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
///     http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Jan Steemann
/// @author Copyright 2013, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////

var jsunity = require("jsunity");
var fm = require("org/arangodb/foxx-manager");
var arango = require("org/arangodb").arango;
var db = require("internal").db;

// -----------------------------------------------------------------------------
// --SECTION--                                                foxx manager tests
// -----------------------------------------------------------------------------

////////////////////////////////////////////////////////////////////////////////
/// @brief test suite
////////////////////////////////////////////////////////////////////////////////

function FoxxManagerSuite () {

  function inList (list, name) {
    var i;

    for (i = 0; i < list.length; ++i) {
      var entry = list[i];

      assertTrue(entry.hasOwnProperty("name"));

      if (entry.name === name) {
        return true;
      }
    }

    return false;
  }

  return {

////////////////////////////////////////////////////////////////////////////////
/// @brief test update
////////////////////////////////////////////////////////////////////////////////

    testUpdate : function () {
      fm.update();

      var result = fm.availableJson();
      var i, n;

      n = result.length;
      assertTrue(n > 0);

      // validate the results structure
      for (i = 0; i < n; ++i) {
        var entry = result[i];

        assertTrue(entry.hasOwnProperty("description"));
        assertTrue(entry.hasOwnProperty("name"));
        assertTrue(entry.hasOwnProperty("author"));
        assertTrue(entry.hasOwnProperty("latestVersion"));
      }
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test available
////////////////////////////////////////////////////////////////////////////////

    testFetch : function () {
      try {
        fm.purge("itzpapalotl");
      }
      catch (err) {
      }

      fm.update();
      fm.fetch("github", "jsteemann/itzpapalotl");

      var result = fm.fetchedJson(), i;

      for (i = 0; i < result.length; ++i) {
        var entry = result[i];

        if (entry.name === 'itzpapalotl') {
          assertEqual("jsteemann", entry.author);
          assertEqual("itzpapalotl", entry.name);
          assertTrue(entry.hasOwnProperty("description"));
          assertTrue(entry.hasOwnProperty("version"));
          assertTrue(entry.hasOwnProperty("path"));
        }
        return;
       }

      fail();
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test purge
////////////////////////////////////////////////////////////////////////////////

    testPurge : function () {
      try {
        fm.purge("itzpapalotl");
      }
      catch (err) {
      }

      fm.update();
      fm.install("itzpapalotl", "/itz1");
      fm.install("itzpapalotl", "/itz2");
      fm.install("itzpapalotl", "/itz3");

      fm.purge("itzpapalotl");

      assertFalse(inList(fm.listJson(), "itzpapalotl"));
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test purge
////////////////////////////////////////////////////////////////////////////////

    testPurgeSystem : function () {
      fm.update();

      try {
        fm.purge("aardvark");
        fail();
      }
      catch (err) {
      }
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test search
////////////////////////////////////////////////////////////////////////////////

    testSearchEmpty : function () {
      var result = fm.searchJson();

      var i, j, n;

      n = result.length;
      assertTrue(n > 0);

      // validate the results structure
      for (i = 0; i < n; ++i) {
        var entry = result[i];

        assertTrue(entry.hasOwnProperty("_key"));
        assertTrue(entry.hasOwnProperty("_rev"));
        assertTrue(entry.hasOwnProperty("description"));
        assertTrue(entry.hasOwnProperty("name"));
        assertTrue(entry.hasOwnProperty("author"));
        assertTrue(entry.hasOwnProperty("versions"));

        versions = entry.versions;

        for (version in entry.versions) {
          if (entry.versions.hasOwnProperty(version)) {
            assertMatch(/^\d+(\.\d+)*$/, version);
            assertTrue(entry.versions[version].hasOwnProperty("type"));
            assertTrue(entry.versions[version].hasOwnProperty("location"));
          }
        }
      }
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test search existings
////////////////////////////////////////////////////////////////////////////////

    testSearchAztec : function () {
      var result = fm.searchJson("itzpapalotl");

      var i, j, n;

      n = result.length;
      assertTrue(n > 0);

      // validate the results structure, simply take the first match
      var entry = result.pop();

      assertEqual("jsteemann", entry.author);
      assertEqual("itzpapalotl", entry.name);
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test install
////////////////////////////////////////////////////////////////////////////////

    testInstallSingle : function () {
      fm.update();

      try {
        fm.purge("/itzpapalotl");
      }
      catch (err) {
      }

      fm.install("itzpapalotl", "/itz");
      assertTrue(inList(fm.listJson(), "itzpapalotl"));

      var url = '/itz/random';
      var fetched = arango.GET(url);

      assertTrue(fetched.hasOwnProperty("name"));

      fm.uninstall("/itz");
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test install
////////////////////////////////////////////////////////////////////////////////

    testInstallMulti : function () {
      fm.update();

      try {
        fm.uninstall("/itz1");
        fm.uninstall("/itz2");
      }
      catch (err) {
      }

      fm.install("itzpapalotl", "/itz1");
      fm.install("itzpapalotl", "/itz2");

      var url, fetched;

      url  = '/itz1/random';
      fetched = arango.GET(url);
      assertTrue(fetched.hasOwnProperty("name"));

      url  = '/itz2/random';
      fetched = arango.GET(url);

      assertTrue(fetched.hasOwnProperty("name"));

      fm.uninstall("/itz1");
      fm.uninstall("/itz2");
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test uninstall
////////////////////////////////////////////////////////////////////////////////

    testUninstallInstalled : function () {
      fm.update();

      try {
        fm.purge("itzpapalotl");
      }
      catch (err) {
      }

      fm.install("itzpapalotl", "/itz");
      assertTrue(inList(fm.listJson(), "itzpapalotl"));

      fm.uninstall("/itz");
      assertFalse(inList(fm.listJson(), "itzpapalotl"));
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test uninstall
////////////////////////////////////////////////////////////////////////////////

    testUninstallUninstalled : function () {
      fm.update();

      try {
        fm.uninstall("/itz");
      }
      catch (err) {
      }

      try {
        // already uninstalled
        fm.uninstall("/itz");
        fail();
      }
      catch (err) {
      }
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test uninstall
////////////////////////////////////////////////////////////////////////////////

    testUninstallSystem : function () {
      fm.update();

      var doc = db._collection('_aal').firstExample({ type: "mount", name: "aardvark" });

      assertNotNull(doc);

      try {
        // cannout uninstall a system app
        fm.uninstall(doc.mount);
        fail();
      }
      catch (err) {
      }
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test unmount
////////////////////////////////////////////////////////////////////////////////

    testUnmountInstalled : function () {
      fm.update();

      try {
        fm.uninstall("/itz");
      }
      catch (err) {
      }

      fm.install("itzpapalotl", "/itz");
      fm.unmount("/itz");
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test unmount
////////////////////////////////////////////////////////////////////////////////

    testUnmountUninstalled : function () {
      fm.update();

      try {
        fm.uninstall("/itz");
      }
      catch (err) {
      }

      try {
        // already unmounted
        fm.unmount("/itz");
        fail();
      }
      catch (err) {
      }
    },

////////////////////////////////////////////////////////////////////////////////
/// @brief test unmount
////////////////////////////////////////////////////////////////////////////////

    testUnmountSystem : function () {
      fm.update();

      var doc = db._collection('_aal').firstExample({ type: "mount", name: "aardvark" });

      assertNotNull(doc);

      try {
        // cannout unmount a system app
        fm.unmount(doc.mount);
        fail();
      }
      catch (err) {
      }
    }

  };
}

// -----------------------------------------------------------------------------
// --SECTION--                                                              main
// -----------------------------------------------------------------------------

////////////////////////////////////////////////////////////////////////////////
/// @brief executes the test suite
////////////////////////////////////////////////////////////////////////////////

jsunity.run(FoxxManagerSuite);

return jsunity.done();

// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)"
// End:

<|endoftext|>


<commit_before>BR.TrackMessages = L.Class.extend({
    options: {
        edgeStyle: {
            color: 'yellow',
            opacity: 0.8,
            weight: 8,
            // show above quality coding (pane defined in RoutingPathQuality.js)
            pane: 'routingQualityPane',
        },
        // center hovered edge (way segment) on map
        syncMap: true,
    },

    // true when tab is shown, false when hidden
    active: false,

    columnOptions: {
        Longitude: { visible: false },
        Latitude: { visible: false },
        Elevation: { title: 'elev.', className: 'dt-body-right' },
        Distance: { title: 'dist.', className: 'dt-body-right' },
        CostPerKm: { title: '$/km', className: 'dt-body-right' },
        ElevCost: { title: 'elev$', className: 'dt-body-right' },
        TurnCost: { title: 'turn$', className: 'dt-body-right' },
        NodeCost: { title: 'node$', className: 'dt-body-right' },
        InitialCost: { title: 'initial$', className: 'dt-body-right' },
    },

    /**
     * @type {?BR.TrackEdges}
     */
    trackEdges: null,

    /**
     * @type {?L.Polyline}
     */
    trackPolyline: null,

    segments: null,

    initialize: function (map, options) {
        L.setOptions(this, options);
        this._map = map;

        var table = document.getElementById('datatable');
        this.tableClassName = table.className;
        this.tableParent = table.parentElement;

        var syncButton = document.getElementById('data-sync-map');
        L.DomEvent.on(syncButton, 'click', this._toggleSyncMap, this);

        this._mapMouseMoveHandlerBound = this.mapMouseMoveHandler.bind(this);
        this._mapMouseOutHandlerBound = this.mapMouseOutHandler.bind(this);
    },

    update: function (polyline, segments, layer) {
        var i,
            messages,
            columns,
            headings,
            data = [];

        if (!this.active) {
            this.listenMapEvents(layer, false);
            return;
        }

        this.trackPolyline = polyline;
        this.trackEdges = new BR.TrackEdges(segments);
        this.segments = segments;

        for (i = 0; segments && i < segments.length; i++) {
            messages = segments[i].feature.properties.messages;
            if (messages) {
                data = data.concat(messages.slice(1));
            }
        }

        this._destroyTable();

        if (data.length === 0) {
            this.listenMapEvents(layer, false);
            return;
        }

        headings = messages[0];
        columns = this._getColumns(headings, data);

        this._table = $('#datatable').DataTable({
            destroy: true,
            data: data,
            columns: columns,
            paging: false,
            searching: false,
            info: false,
            // flexbox workaround: without scrollY height Firefox extends to content height
            // (^= minimum height with flexbox?)
            scrollY: 50,
            scrollX: true,
            order: [],
        });

        // highlight track segment (graph edge) on row hover

        $('#datatable tbody tr').hover(L.bind(this._handleHover, this), L.bind(this._handleHoverOut, this));
        $('#datatable tbody').on('click', 'tr', L.bind(this._toggleSelected, this));

        this.listenMapEvents(layer, true);
    },

    listenMapEvents: function (layer, on) {
        if (layer) {
            if (on) {
                layer.on('mousemove', this._mapMouseMoveHandlerBound);
                layer.on('mouseout', this._mapMouseOutHandlerBound);
            } else {
                layer.off('mousemove', this._mapMouseMoveHandlerBound);
                layer.off('mouseout', this._mapMouseOutHandlerBound);
            }
        }
    },

    show: function () {
        this.active = true;
        this.options.requestUpdate(this);
    },

    hide: function () {
        this.active = false;
    },

    _destroyTable: function () {
        var ele;

        if ($.fn.DataTable.isDataTable('#datatable')) {
            // destroy option too slow on update, really remove elements with destroy method
            $('#datatable').DataTable().destroy(true);

            // recreate original table element, destroy removes all
            ele = document.createElement('table');
            ele.id = 'datatable';
            ele.className = this.tableClassName;
            this.tableParent.appendChild(ele);
        }

        return ele || document.getElementById('datatable');
    },

    _getColumns: function (headings, data) {
        var columns = [],
            defaultOptions,
            options,
            emptyColumns = this._getEmptyColumns(data);

        for (k = 0; k < headings.length; k++) {
            defaultOptions = {
                title: headings[k],
                visible: !emptyColumns[k],
            };
            options = L.extend(defaultOptions, this.columnOptions[headings[k]]);
            columns.push(options);
        }
        return columns;
    },

    _getEmptyColumns: function (data) {
        var empty = new Array(data[0].length),
            i;

        for (i = 0; i < empty.length; i++) {
            empty[i] = true;
        }

        data.forEach(function (row) {
            row.forEach(function (val, i) {
                empty[i] = empty[i] && !val;
            });
        });

        return empty;
    },

    _getRowEdge: function (tr) {
        var row = this._table.row($(tr)),
            trackLatLngs = this.trackPolyline.getLatLngs(),
            startIndex = row.index() > 0 ? this.trackEdges.edges[row.index() - 1] : 0,
            endIndex = this.trackEdges.edges[row.index()],
            edgeLatLngs = trackLatLngs.slice(startIndex, endIndex + 1);

        return L.polyline(edgeLatLngs, this.options.edgeStyle);
    },

    _handleHover: function (evt) {
        var tr = evt.currentTarget;

        this._hoveredEdge = this._getRowEdge(tr).addTo(this._map);
        if (this.options.syncMap && !this._selectedEdge) {
            this._map.panTo(this._hoveredEdge.getCenter());
        }
    },

    _handleHoverOut: function (evt) {
        this._map.removeLayer(this._hoveredEdge);
        this._hoveredEdge = null;
    },

    _toggleSelected: function (evt) {
        var tr = evt.currentTarget;

        if (tr.classList.toggle('selected')) {
            if (this._selectedEdge) {
                // no multi-select, remove selection of other row
                // (simpler to implement and to use?)
                this._map.removeLayer(this._selectedEdge);
                this._selectedRow.classList.remove('selected');
            }
            this._selectedEdge = this._getRowEdge(tr).addTo(this._map);
            this._selectedRow = tr;

            this._map.panTo(this._selectedEdge.getCenter());
        } else {
            this._map.removeLayer(this._selectedEdge);
            this._selectedEdge = null;
            this._selectedRow = null;
        }
    },

    _toggleSyncMap: function (evt) {
        var button = evt.currentTarget;

        button.classList.toggle('active');
        this.options.syncMap = !this.options.syncMap;
    },

    mapMouseMoveHandler: function (evt) {
        // initialize the vars for the closest item calculation
        let closestPointIdx = null;
        // large enough to be trumped by any point on the chart
        let closestDistance = 2 * Math.pow(100, 2);
        // consider a good enough match if the given point (lat and lng) is within
        // 1.1 meters of a point on the chart (there are 111,111 meters in a degree)
        const exactMatchRounding = 1.1 / 111111;

        const point = turf.point([evt.latlng.lng, evt.latlng.lat]);
        let idxOffset = 0;
        outer: for (let segment of this.segments) {
            const bestPointForSegement = turf.nearestPointOnLine(segment.feature, point);
            if (bestPointForSegement.properties.dist < closestDistance) {
                closestPointIdx = idxOffset + bestPointForSegement.properties.index;
                closestDistance = bestPointForSegement.properties.dist;
            }
            idxOffset += segment.feature.geometry.coordinates.length;
        }

        if (closestPointIdx !== null) {
            // Now map point to next data row
            let rowIdx = -1;
            for (let i = 0; i < this.trackEdges.edges.length; i++) {
                if (closestPointIdx < this.trackEdges.edges[i]) {
                    rowIdx = i;
                    break;
                }
            }
            if (rowIdx != -1) {
                // highlight found row
                const rowObj = this._table.row(rowIdx);
                if (rowObj && rowObj != this._mapHoveredRow) {
                    if (this._mapHoveredRow) {
                        this._mapHoveredRow.classList.remove('hoverRoute');
                    }
                    this._mapHoveredRow = rowObj.node();
                    this._mapHoveredRow.classList.add('hoverRoute');
                    this._mapHoveredRow.scrollIntoView(false);
                }
            }
        } else {
            if (this._mapHoveredRow) {
                this._mapHoveredRow.classList.remove('hoverRoute');
            }
        }
    },

    mapMouseOutHandler: function () {
        if (this._mapHoveredRow) {
            this._mapHoveredRow.classList.remove('hoverRoute');
        }
    },
});
<commit_msg>Bugfix: TrackMessage selected edge lingered after route deletion<commit_after>BR.TrackMessages = L.Class.extend({
    options: {
        edgeStyle: {
            color: 'yellow',
            opacity: 0.8,
            weight: 8,
            // show above quality coding (pane defined in RoutingPathQuality.js)
            pane: 'routingQualityPane',
        },
        // center hovered edge (way segment) on map
        syncMap: true,
    },

    // true when tab is shown, false when hidden
    active: false,

    columnOptions: {
        Longitude: { visible: false },
        Latitude: { visible: false },
        Elevation: { title: 'elev.', className: 'dt-body-right' },
        Distance: { title: 'dist.', className: 'dt-body-right' },
        CostPerKm: { title: '$/km', className: 'dt-body-right' },
        ElevCost: { title: 'elev$', className: 'dt-body-right' },
        TurnCost: { title: 'turn$', className: 'dt-body-right' },
        NodeCost: { title: 'node$', className: 'dt-body-right' },
        InitialCost: { title: 'initial$', className: 'dt-body-right' },
    },

    /**
     * @type {?BR.TrackEdges}
     */
    trackEdges: null,

    /**
     * @type {?L.Polyline}
     */
    trackPolyline: null,

    segments: null,

    initialize: function (map, options) {
        L.setOptions(this, options);
        this._map = map;

        var table = document.getElementById('datatable');
        this.tableClassName = table.className;
        this.tableParent = table.parentElement;

        var syncButton = document.getElementById('data-sync-map');
        L.DomEvent.on(syncButton, 'click', this._toggleSyncMap, this);

        this._mapMouseMoveHandlerBound = this.mapMouseMoveHandler.bind(this);
        this._mapMouseOutHandlerBound = this.mapMouseOutHandler.bind(this);
    },

    update: function (polyline, segments, layer) {
        var i,
            messages,
            columns,
            headings,
            data = [];

        if (!this.active) {
            this.listenMapEvents(layer, false);
            return;
        }

        this.trackPolyline = polyline;
        this.trackEdges = new BR.TrackEdges(segments);
        this.segments = segments;

        for (i = 0; segments && i < segments.length; i++) {
            messages = segments[i].feature.properties.messages;
            if (messages) {
                data = data.concat(messages.slice(1));
            }
        }

        this._destroyTable();
        this._destroyEdges();

        if (data.length === 0) {
            this.listenMapEvents(layer, false);
            return;
        }

        headings = messages[0];
        columns = this._getColumns(headings, data);

        this._table = $('#datatable').DataTable({
            destroy: true,
            data: data,
            columns: columns,
            paging: false,
            searching: false,
            info: false,
            // flexbox workaround: without scrollY height Firefox extends to content height
            // (^= minimum height with flexbox?)
            scrollY: 50,
            scrollX: true,
            order: [],
        });

        // highlight track segment (graph edge) on row hover

        $('#datatable tbody tr').hover(L.bind(this._handleHover, this), L.bind(this._handleHoverOut, this));
        $('#datatable tbody').on('click', 'tr', L.bind(this._toggleSelected, this));

        this.listenMapEvents(layer, true);
    },

    listenMapEvents: function (layer, on) {
        if (layer) {
            if (on) {
                layer.on('mousemove', this._mapMouseMoveHandlerBound);
                layer.on('mouseout', this._mapMouseOutHandlerBound);
            } else {
                layer.off('mousemove', this._mapMouseMoveHandlerBound);
                layer.off('mouseout', this._mapMouseOutHandlerBound);
            }
        }
    },

    show: function () {
        this.active = true;
        this.options.requestUpdate(this);
    },

    hide: function () {
        this.active = false;
    },

    _destroyTable: function () {
        var ele;

        if ($.fn.DataTable.isDataTable('#datatable')) {
            // destroy option too slow on update, really remove elements with destroy method
            $('#datatable').DataTable().destroy(true);

            // recreate original table element, destroy removes all
            ele = document.createElement('table');
            ele.id = 'datatable';
            ele.className = this.tableClassName;
            this.tableParent.appendChild(ele);
        }

        return ele || document.getElementById('datatable');
    },

    _destroyEdges: function () {
        if (this._selectedEdge) {
            this._map.removeLayer(this._selectedEdge);
            this._selectedEdge = null;
        }
        if (this._hoveredEdge) {
            this._map.removeLayer(this._hoveredEdge);
            this._hoveredEdge = null;
        }
    },

    _getColumns: function (headings, data) {
        var columns = [],
            defaultOptions,
            options,
            emptyColumns = this._getEmptyColumns(data);

        for (k = 0; k < headings.length; k++) {
            defaultOptions = {
                title: headings[k],
                visible: !emptyColumns[k],
            };
            options = L.extend(defaultOptions, this.columnOptions[headings[k]]);
            columns.push(options);
        }
        return columns;
    },

    _getEmptyColumns: function (data) {
        var empty = new Array(data[0].length),
            i;

        for (i = 0; i < empty.length; i++) {
            empty[i] = true;
        }

        data.forEach(function (row) {
            row.forEach(function (val, i) {
                empty[i] = empty[i] && !val;
            });
        });

        return empty;
    },

    _getRowEdge: function (tr) {
        var row = this._table.row($(tr)),
            trackLatLngs = this.trackPolyline.getLatLngs(),
            startIndex = row.index() > 0 ? this.trackEdges.edges[row.index() - 1] : 0,
            endIndex = this.trackEdges.edges[row.index()],
            edgeLatLngs = trackLatLngs.slice(startIndex, endIndex + 1);

        return L.polyline(edgeLatLngs, this.options.edgeStyle);
    },

    _handleHover: function (evt) {
        var tr = evt.currentTarget;

        this._hoveredEdge = this._getRowEdge(tr).addTo(this._map);
        if (this.options.syncMap && !this._selectedEdge) {
            this._map.panTo(this._hoveredEdge.getCenter());
        }
    },

    _handleHoverOut: function (evt) {
        this._map.removeLayer(this._hoveredEdge);
        this._hoveredEdge = null;
    },

    _toggleSelected: function (evt) {
        var tr = evt.currentTarget;

        if (tr.classList.toggle('selected')) {
            if (this._selectedEdge) {
                // no multi-select, remove selection of other row
                // (simpler to implement and to use?)
                this._map.removeLayer(this._selectedEdge);
                this._selectedRow.classList.remove('selected');
            }
            this._selectedEdge = this._getRowEdge(tr).addTo(this._map);
            this._selectedRow = tr;

            this._map.panTo(this._selectedEdge.getCenter());
        } else {
            this._map.removeLayer(this._selectedEdge);
            this._selectedEdge = null;
            this._selectedRow = null;
        }
    },

    _toggleSyncMap: function (evt) {
        var button = evt.currentTarget;

        button.classList.toggle('active');
        this.options.syncMap = !this.options.syncMap;
    },

    mapMouseMoveHandler: function (evt) {
        // initialize the vars for the closest item calculation
        let closestPointIdx = null;
        // large enough to be trumped by any point on the chart
        let closestDistance = 2 * Math.pow(100, 2);
        // consider a good enough match if the given point (lat and lng) is within
        // 1.1 meters of a point on the chart (there are 111,111 meters in a degree)
        const exactMatchRounding = 1.1 / 111111;

        const point = turf.point([evt.latlng.lng, evt.latlng.lat]);
        let idxOffset = 0;
        outer: for (let segment of this.segments) {
            const bestPointForSegement = turf.nearestPointOnLine(segment.feature, point);
            if (bestPointForSegement.properties.dist < closestDistance) {
                closestPointIdx = idxOffset + bestPointForSegement.properties.index;
                closestDistance = bestPointForSegement.properties.dist;
            }
            idxOffset += segment.feature.geometry.coordinates.length;
        }

        if (closestPointIdx !== null) {
            // Now map point to next data row
            let rowIdx = -1;
            for (let i = 0; i < this.trackEdges.edges.length; i++) {
                if (closestPointIdx < this.trackEdges.edges[i]) {
                    rowIdx = i;
                    break;
                }
            }
            if (rowIdx != -1) {
                // highlight found row
                const rowObj = this._table.row(rowIdx);
                if (rowObj && rowObj != this._mapHoveredRow) {
                    if (this._mapHoveredRow) {
                        this._mapHoveredRow.classList.remove('hoverRoute');
                    }
                    this._mapHoveredRow = rowObj.node();
                    this._mapHoveredRow.classList.add('hoverRoute');
                    this._mapHoveredRow.scrollIntoView(false);
                }
            }
        } else {
            if (this._mapHoveredRow) {
                this._mapHoveredRow.classList.remove('hoverRoute');
            }
        }
    },

    mapMouseOutHandler: function () {
        if (this._mapHoveredRow) {
            this._mapHoveredRow.classList.remove('hoverRoute');
        }
    },
});
<|endoftext|>


<commit_before>var IndoorWatermarkController = function() {
  var _indoorWatermarkElement = null;
  var _elementId = "eegeo-indoor-map-watermark";
  var _urlRoot = "https://cdn-webgl.eegeo.com/eegeojs/resources/indoor-vendors/";

  var _buildUrlForVendor = function(vendorKey) {
    return _urlRoot + vendorKey + "_logo.png";
  };

  var _precacheKnownVendors = function() {
    var knownVendors = ["eegeo", "micello"];

    knownVendors.forEach(function(vendor) {
      var vendorImageUrl = _buildUrlForVendor(vendor);
      var tempImage = new Image();
      tempImage.src = vendorImageUrl;
    });
  };

  _precacheKnownVendors();

  this.showWatermarkForVendor = function(vendorKey) {
    var imageUrl = _buildUrlForVendor(vendorKey);

    if (_indoorWatermarkElement === null) {
      _indoorWatermarkElement = document.getElementById(_elementId);
    }

    _indoorWatermarkElement.src = imageUrl;
    _indoorWatermarkElement.style.bottom = 0;
  };

  this.hideWatermark = function() {
    _indoorWatermarkElement.style.bottom = "-50px";
  };
};

module.exports = IndoorWatermarkController;<commit_msg>Watermark for WRLD branding. Also fixes a bug where the micello logo is not displayed due to case sensitivity. Pair: Malc<commit_after>var IndoorWatermarkController = function() {
  var _indoorWatermarkElement = null;
  var _elementId = "eegeo-indoor-map-watermark";
  var _urlRoot = "https://cdn-webgl.eegeo.com/eegeojs/resources/indoor-vendors/";

  var _buildUrlForVendor = function(vendorKey) {
    var vendorKeyLower = vendorKey.toLowerCase();
    if (vendorKeyLower === "eegeo")
    {
        vendorKeyLower = "wrld";
    }
    return _urlRoot + vendorKeyLower + "_logo.png";
  };

  var _precacheKnownVendors = function() {
    var knownVendors = ["eegeo", "micello"];

    knownVendors.forEach(function(vendor) {
      var vendorImageUrl = _buildUrlForVendor(vendor);
      var tempImage = new Image();
      tempImage.src = vendorImageUrl;
    });
  };

  _precacheKnownVendors();

  this.showWatermarkForVendor = function(vendorKey) {
    var imageUrl = _buildUrlForVendor(vendorKey);

    if (_indoorWatermarkElement === null) {
      _indoorWatermarkElement = document.getElementById(_elementId);
    }

    _indoorWatermarkElement.src = imageUrl;
    _indoorWatermarkElement.style.bottom = 0;
  };

  this.hideWatermark = function() {
    _indoorWatermarkElement.style.bottom = "-50px";
  };
};

module.exports = IndoorWatermarkController;<|endoftext|>