<commit_before>'use strict';
/* global document */

const util = require('./util');
const applyStyle = require('./style').applyStyle;
const pad = 4;

/* symbol {
  title: 'foo',
  geom: 'line', //valid: 'point', 'line', 'polygon'
  data: {
    zoom: 15,
    foo: 'bar',
    buz: 'lol'
  }
}
*/

let drawer = {
  point: function(canvas, style) {
    let ctx = canvas.getContext('2d'),
        hw = canvas.width / 2,
        hh = canvas.height / 2,
        radius = Math.min(hw, hh) - pad;

    applyStyle(style, ctx);
    ctx.beginPath();
    ctx.arc(hw, hh, radius, 2 * Math.PI, false);
    style.fill && ctx.fill();
    style.line && ctx.stroke();

    return canvas;
  },

  line: function(canvas, style) {
    let ctx = canvas.getContext('2d'),
        w = canvas.width,
        h = canvas.height;

    applyStyle(style, ctx);

    ctx.beginPath();
    ctx.moveTo(pad, h - pad);
    ctx.lineTo(w - pad, pad);
    style.line && ctx.stroke();

    return canvas;
  },

  polygon: function(canvas, style) {
    let ctx = canvas.getContext('2d'),
        w = canvas.width,
        h = canvas.height;

    applyStyle(style, ctx);

    ctx.beginPath();
    ctx.rect(pad, pad, w - 2 * pad, h - 2 * pad);
    style.fill && ctx.fill();
    style.line && ctx.stroke();

    return canvas;
  }
};

function drawSymbol(styleFn, symbol) {
  let fakeFeature = {properties: symbol.data},
      zoom = symbol.data.zoom || 0,
      style = styleFn(fakeFeature, zoom),
      canvas = document.createElement('canvas');

  canvas.width = 24;
  canvas.height = 24;

  drawer[symbol.geom](canvas, style);

  return canvas.toDataURL();
}

function createTitleFromSymbolData(data) {
  let conditions = [];

  for (let k in data) {
    conditions.push(data[k]);
  }

  return conditions.join('&');
}

function createSymbolsFromStyle(styleDef, geom) {
  let variants = {
    zoom: []
  };

  // Buscar propiedades que tienen definición de tipo mapbox-gl-function
  let functionProperties = Object.keys(styleDef)
    .filter((key) => typeof styleDef[key] === 'object');

  // Si todas las propiedades son constantes, el estilo no depende del feature
  if (!functionProperties.length) {
    return [{
      title: 'single symbol',
      geom: geom,
      data: {}
    }];
  }

  // Para cada uno de los valores definidos como mapbox-gl-function se debe
  // obtener un conjunto de valores de muestra
  functionProperties.forEach(function(key) {
    let value = styleDef[key];
    let property = value.property;

    if (property && !variants[property]) {
      variants[property] = [];
    }

    value.stops.forEach(function(stop) {
      let propValue = stop[0];

      if (!property) {
        variants.zoom.push(propValue);
      } else if (typeof propValue === 'object') {
        variants.zoom.push(propValue.zoom);
        variants[property].push(propValue.value);
      } else {
        variants[property].push(propValue);
      }
    });
  });

  // ordenar y eliminar duplicados desde las muestras
  for (let k in variants) {
    util.unique(util.sort(variants[k]));
  }

  // ahora con las muestras se debe construir todas las combinaciones posibles
  let keys = Object.keys(variants).filter((k) => variants[k].length);
  let allValues = keys.map((k) => variants[k]);

  return util.cartesianProduct(allValues)
    .map(function(values) {
      let data = util.zipObject(keys, values);
      let symbol = {
        title: createTitleFromSymbolData(data),
        geom: geom,
        data: data
      };
      return symbol;
    });
}

module.exports = {
  createSymbolsFromStyle,
  drawSymbol
};
<commit_msg>Multiforms are added<commit_after>'use strict';
/* global document */

const util = require('./util');
const applyStyle = require('./style').applyStyle;
const pad = 4;

/* symbol {
  title: 'foo',
  geom: 'line', //valid: 'point', 'line', 'polygon', 'multipoint', 'multiline', 'multilinestring', 'multipolygon'
  data: {
    zoom: 15,
    foo: 'bar',
    buz: 'lol'
  }
}
*/

let drawer = {
  point: function(canvas, style) {
    let ctx = canvas.getContext('2d'),
        hw = canvas.width / 2,
        hh = canvas.height / 2,
        radius = Math.min(hw, hh) - pad;

    applyStyle(style, ctx);
    ctx.beginPath();
    ctx.arc(hw, hh, radius, 2 * Math.PI, false);
    style.fill && ctx.fill();
    style.line && ctx.stroke();

    return canvas;
  },
  multipoint: function(canvas, style) {
    drawer['point'](canvas, style);
  },

  line: function(canvas, style) {
    let ctx = canvas.getContext('2d'),
        w = canvas.width,
        h = canvas.height;

    applyStyle(style, ctx);

    ctx.beginPath();
    ctx.moveTo(pad, h - pad);
    ctx.lineTo(w - pad, pad);
    style.line && ctx.stroke();

    return canvas;
  },
  multiline: function(canvas, style) {
    drawer['line'](canvas, style);
  },
  multilinestring: function(canvas, style) {
    drawer['line'](canvas, style);
  },

  polygon: function(canvas, style) {
    let ctx = canvas.getContext('2d'),
        w = canvas.width,
        h = canvas.height;

    applyStyle(style, ctx);

    ctx.beginPath();
    ctx.rect(pad, pad, w - 2 * pad, h - 2 * pad);
    style.fill && ctx.fill();
    style.line && ctx.stroke();

    return canvas;
  },
  multipolygon: function(canvas, style) {
    drawer['polygon'](canvas, style);
  }
};

function drawSymbol(styleFn, symbol) {
  let fakeFeature = {properties: symbol.data},
      zoom = symbol.data.zoom || 0,
      style = styleFn(fakeFeature, zoom),
      canvas = document.createElement('canvas');

  canvas.width = 24;
  canvas.height = 24;

  drawer[symbol.geom](canvas, style);
  return canvas.toDataURL();
}

function createTitleFromSymbolData(data) {
  let conditions = [];

  for (let k in data) {
    conditions.push(data[k]);
  }

  return conditions.join('&');
}

function createSymbolsFromStyle(styleDef, geom) {
  let variants = {
    zoom: []
  };

  // Buscar propiedades que tienen definición de tipo mapbox-gl-function
  let functionProperties = Object.keys(styleDef)
    .filter((key) => typeof styleDef[key] === 'object');

  // Si todas las propiedades son constantes, el estilo no depende del feature
  if (!functionProperties.length) {
    return [{
      title: 'single symbol',
      geom: geom,
      data: {}
    }];
  }

  // Para cada uno de los valores definidos como mapbox-gl-function se debe
  // obtener un conjunto de valores de muestra
  functionProperties.forEach(function(key) {
    let value = styleDef[key];
    let property = value.property;

    if (property && !variants[property]) {
      variants[property] = [];
    }

    value.stops.forEach(function(stop) {
      let propValue = stop[0];

      if (!property) {
        variants.zoom.push(propValue);
      } else if (typeof propValue === 'object') {
        variants.zoom.push(propValue.zoom);
        variants[property].push(propValue.value);
      } else {
        variants[property].push(propValue);
      }
    });
  });

  // ordenar y eliminar duplicados desde las muestras
  for (let k in variants) {
    util.unique(util.sort(variants[k]));
  }

  // ahora con las muestras se debe construir todas las combinaciones posibles
  let keys = Object.keys(variants).filter((k) => variants[k].length);
  let allValues = keys.map((k) => variants[k]);

  return util.cartesianProduct(allValues)
    .map(function(values) {
      let data = util.zipObject(keys, values);
      let symbol = {
        title: createTitleFromSymbolData(data),
        geom: geom,
        data: data
      };
      return symbol;
    });
}

module.exports = {
  createSymbolsFromStyle,
  drawSymbol
};
<|endoftext|>


<commit_before>import main, {Options, OptionsError} from '../lib/main.js';
import Logger from '../lib/Logger.js';
import {WARN, INFO} from '../lib/logger/level.js';
import fs from 'fs';
import path from 'path';

const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'package.json'), {encoding: 'utf8'}));

process.title = pkg.name;

function version(status=0) {
  process.stdout.write(`${pkg.version}\n`);
  process.exit(status);
}

function help(status=0) {
  process.stdout.write(`Usage: ${process.title} [options]
Options:
  --help                   Display this information.
  --version                Output the script version.
  --verbose                Increase logging output.
`);
  process.exit(status);
}

try {
  const args = {};

  const unparsed = process.argv.slice(2).filter(arg => {
    switch (arg) {
    case '--verbose': args.verbose = true; return false;
    case '--help': help(); return false;
    case '--version': version(); return false;
    default: return true;
    }
  });

  if (unparsed.length) {
    throw new OptionsError(`Unknown arguments: ${unparsed.join(', ')}`);
  }

  const logger = new Logger({level: args.verbose ? INFO : WARN});

  const options = new Options({logger});

  const status = main(options);

  process.exit(status);
} catch (e) {
  if (e instanceof OptionsError) {
    process.stderr.write(`${e.message}\n`);
    process.exit(2);
  } else {
    process.stderr.write(`${e}\n`);
    process.exit(1);
  }
}
<commit_msg>Make help text look like upstream compilers<commit_after>import main, {Options, OptionsError} from '../lib/main.js';
import Logger from '../lib/Logger.js';
import {WARN, INFO} from '../lib/logger/level.js';
import fs from 'fs';
import path from 'path';

const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'package.json'), {encoding: 'utf8'}));

process.title = pkg.name;

function version(status=0) {
  process.stdout.write(`${pkg.version}\n`);
  process.exit(status);
}

function help(status=0) {
  process.stdout.write(`Usage: ${process.title} [<option>...]

This is a Cap'n Proto compiler plugin which generates ECMAscript modules. It
is meant to be run using the Cap'n Proto compiler, e.g.:
    capnp compile -oes foo.capnp

Options:
    --verbose
        Log informational messages to stderr; useful for debugging.
    --version
        Print version information and exit.
    --help
        Display this help text and exit.
`);
  process.exit(status);
}

try {
  const args = {};

  const unparsed = process.argv.slice(2).filter(arg => {
    switch (arg) {
    case '--verbose': args.verbose = true; return false;
    case '--help': help(); return false;
    case '--version': version(); return false;
    default: return true;
    }
  });

  if (unparsed.length) {
    throw new OptionsError(`Unknown arguments: ${unparsed.join(', ')}`);
  }

  const logger = new Logger({level: args.verbose ? INFO : WARN});

  const options = new Options({logger});

  const status = main(options);

  process.exit(status);
} catch (e) {
  if (e instanceof OptionsError) {
    process.stderr.write(`${e.message}\n`);
    process.exit(2);
  } else {
    process.stderr.write(`${e}\n`);
    process.exit(1);
  }
}
<|endoftext|>


<commit_before>var exec = require("cordova/exec");

/**
 * The Cordova plugin ID for this plugin.
 */
var PLUGIN_ID = "EpsonPrinter";

/**
 * The plugin which will be exported and exposed in the global scope.
 */
var Printer = function () { };

/**
 * Blocks user input using an indeterminate spinner.
 *
 * An optional label can be shown below the spinner.
 *
 * @param [string] labelText - The optional value to show in a label.
 * @param [options] options - The optional options object used to customize behavior.
 * @param [function] successCallback - The success callback for this asynchronous function.
 * @param [function] failureCallback - The failure callback for this asynchronous function; receives an error string.
 */

//takes the IP address of the printer
Printer.connect = function (id, success, error) {
    exec(success, error, 'EpsonPrinter', 'connect', [id]);
};

//need to pass in the builder model, string
Printer.createBuilder = function (model, success, error) {
    exec(success, error, 'EpsonPrinter', 'createBuilder', [model]);
};

Printer.getStatus = function (success, error) {
    exec(success, error, 'EpsonPrinter', 'getStatus', []);
};

Printer.removeBuilder = function (success, error) {
    exec(success, error, 'EpsonPrinter', 'removeBuilder', []);
};

//need to pass the string to add text
Printer.addText = function (text, success, error) {
    exec(success, error, 'EpsonPrinter', 'addText', [text]);
};

//need to pass in the ENUM for printer align
Printer.addTextAlign = function (align, success, error) {
    exec(success, error, 'EpsonPrinter', 'addTextAlign', [align]);
};

//need to pass in the ENUM for printer language
Printer.addTextLang = function (lang, success, error) {
    exec(success, error, 'EpsonPrinter', 'addTextLang', [lang]);
};

Printer.addSymbol = function (address, type, level, size, success, error) {
    exec(success, error, 'EpsonPrinter', 'addSymbol', [address, type, level, size]);
}

//need to pass in boolean for text smoothing
Printer.addTextSmooth = function (smooth, success, error) {
    exec(success, error, 'EpsonPrinter', 'addTextSmooth', [smooth]);
};

//need to number of lines to feed
Printer.addFeedLine = function (line, success, error) {
    exec(success, error, 'EpsonPrinter', 'addFeedLine', [line]);
};

//takes a number from 1-8 (width, height)
Printer.addTextSize = function (width, height, success, error) {
    exec(success, error, 'EpsonPrinter', 'addTextSize', [width, height]);
};

//Uses ENUM for values
//int reverse = Specifies inversion of black and white for text.
//int ul = Specifies the underline style.
//int em = Specifies the bold style.
//int color = Specifies the color
Printer.addTextStyle = function (reverse, ul, em, color, success, error) {
    exec(success, error, 'EpsonPrinter', 'addTextStyle', [reverse, ul, em, color]);
};

//need to pass in the ENUM for printer font
Printer.addTextFont = function (font, success, error) {
    exec(success, error, 'EpsonPrinter', 'addTextFont', [font]);
};

//need to pass in the ENUM for printer cut
Printer.addCut = function (cut, success, error) {
    exec(success, error, 'EpsonPrinter', 'addCut', [cut]);
};

Printer.sendToPrinter = function (success, error) {
    exec(success, error, 'EpsonPrinter', 'sendToPrinter', []);
};

module.exports = Printer;<commit_msg>Delete<commit_after><|endoftext|>


<commit_before>/**
 * SuperBox
 * The lightbox reimagined. Fully responsive HTML5 image galleries.
 *
 * Latest version: https://github.com/seyDoggy/superbox
 * Original version: https://github.com/toddmotto/superbox
 *
 * Copyright 2013 Todd Motto <http://www.toddmotto.com>
 * Copyright 2013 Adam Merrifield <http://seydesign.com>
 *
 * Licensed under the MIT license <http://www.opensource.org/licenses/mit-license.php>
 */
 ;(function($, undefined) {
	'use strict';

	var pluginName = 'SuperBox',
		pluginVersion = '3.0.0';

	$.fn.SuperBox = function(options) {

		/*
		 * DECLARATIONS
		 */
		var sbImgBottom,
			sbShowTop,
			sbShow = $('
'),
			sbImg = $(''),
			sbClose = $(''),
			sbFloat = $('
'),
			sbList = this.find('>div'),
			sbList8 = this.find('>div:nth-child(8n)'),
			sbList6 = this.find('>div:nth-child(6n)'),
			sbList4 = this.find('>div:nth-child(4n)'),
			sbList2 = this.find('>div:nth-child(2n)');

		/*
		 * METHODS
		 */

		/**
		 * setLastClass
		 *
		 * Last thumbnail is determined based on window width.
		 */
		var setLastClass = function(){
			sbList.removeClass('superbox-last');
			sbList8.addClass('superbox-last');
			$(window).resize(function(){
				if ($(window).width() > 1024) {
					sbList.removeClass('superbox-last');
					sbList8.addClass('superbox-last');
				} else if ($(window).width() > 767) {
					sbList.removeClass('superbox-last');
					sbList6.addClass('superbox-last');
				} else if ($(window).width() > 485) {
					sbList.removeClass('superbox-last');
					sbList4.addClass('superbox-last');
				} else {
					sbList.removeClass('superbox-last');
					sbList2.addClass('superbox-last');
				}
			});
		};

		/**
		 * createSuperboxShow
		 *
		 * Dynamically create superbox-show and insert it after superbox-last,
		 * apply data-img of the thumbnail to the source of the full image,
		 * open the superbox-show,
		 * fade in and out of each image,
		 * close superbox-show when X is clicked
		 * close superbox-show when open image is clicked
		 */
		var createSuperboxShow = function(elem){
			/*
			 * DECLARATIONS (createSuperboxShow)
			 */
			var noSuperbox = !$('.superbox-show').length,
				isOpen = elem.hasClass('superbox-O'),
				notLast = !elem.hasClass('superbox-last'),
				notInRowA = !elem.nextAll('.superbox-last:first').next('.superbox-show').length,
				notInRowB = !elem.next('.superbox-show').length,
			/*
			 * METHODS (createSuperboxShow)
			 */
				fabricate = function(type){
					if (type === 'A') {
						createAfterLastA();
					} else {
						createAfterLastB();
					}
					setImageData(elem);
					openSuperboxShow();
				},
				revealImage = function(bool){
					if (bool === true) {
						$('.superbox-show img.superbox-current-img').animate({opacity:1},750);
					} else {
						$('.superbox-show img.superbox-current-img').animate({opacity:0},100,function(){
							setImageData(elem);
						});
					}
				},
				quickSwap = function(){
					revealImage(false);
					revealImage(true);
					setOpenClass(true);
				},
				createAfterLastA = function(){
					sbShow.append(sbImg).append(sbClose).insertAfter(elem.nextAll('.superbox-last:first'));
				},
				createAfterLastB = function(){
					sbShow.append(sbImg).append(sbClose).insertAfter(elem);
				},
				setImageData = function(elem){
					$('img.superbox-current-img').attr('src',elem.find('img').data('img'));
				},
				openSuperboxShow = function(){
					$('.superbox-show').slideDown('slow',function(){
						revealImage(true);
						setOpenClass(true);
					});
				},
				setOpenClass = function(bool){
					if (bool === true) {
						sbList.removeClass('superbox-O');
						elem.addClass('superbox-O');
					} else {
						sbList.removeClass('superbox-O');
					}
				},
				closeSuperBoxShow = function(){
					var closeUp = function(){
						revealImage(false);
						$('.superbox-show').slideUp(function(){
							$(this).remove();
							setOpenClass(false);
							revealImage(false);
						});
					};
					$('.superbox-close').on('click',function(event){
						event.preventDefault();
						closeUp();
					});
					if (isOpen === true) {
						closeUp();
					}
				};

			/*
			 * IMPLEMENTATION (createSuperboxShow)
			 */
			if (isOpen === false) {
				if (notLast === true && notInRowA === true) {
					if (noSuperbox === true) {
						fabricate('A');
					} else {
						revealImage(false);
						$('.superbox-show').slideUp(function(){
							fabricate('A');
						});
					}
				} else if (notLast === false && notInRowB === true) {
					if (noSuperbox === true) {
						fabricate('B');
					} else {
						revealImage(false);
						$('.superbox-show').slideUp(function(){
							revealImage(false);
							fabricate('B');
						});
					}
				} else {
					quickSwap();
				}
			}

			closeSuperBoxShow();
		};

		/**
		 * keepShowAfterLast
		 *
		 * Move superbox-show to after superbox-last when window is resized
		 */
		var keepShowAfterLast = function(){
			$(window).resize(function(){
				if ($('.superbox-O').hasClass('superbox-last')) {
					$('.superbox-show').insertAfter($('.superbox-O'));
				} else {
					$('.superbox-show').insertAfter($('.superbox-O').nextAll('.superbox-last:first'));
				}
			});
		};

		/*
		 * IMPLEMENTATION
		 */

		/*
		 * Add superbox-active class to allow for CSS to take hold
		 */
		this.addClass('superbox-active');

		/*
		 * Add superbox-list class for easier CSS targeting
		 */
		sbList.addClass('superbox-list');

		/*
		 * Set superbox-last class
		 */
		setLastClass();

		/*
		 * Create final float
		 */
		sbFloat.appendTo(this);

		/*
		 * Open/Close superbox-show based on click
		 */
		sbList.on('click',function(){

			/*
			 * Set sbImgBottom to bottom position of clicked image
			 */
			sbImgBottom = $(this).find('img').offset().top + $(this).find('img').height();

			/*
			 * Create superbox-show
			 */
			createSuperboxShow($(this));

			/*
			 * Keep superbox-show after the proper row at all times
			 */
			keepShowAfterLast();

		});

		return this;
	};
})(jQuery);<commit_msg>Added setSuperboxHeight function with appropriate defaults.<commit_after>/**
 * SuperBox
 * The lightbox reimagined. Fully responsive HTML5 image galleries.
 *
 * Latest version: https://github.com/seyDoggy/superbox
 * Original version: https://github.com/toddmotto/superbox
 *
 * Copyright 2013 Todd Motto <http://www.toddmotto.com>
 * Copyright 2013 Adam Merrifield <http://seydesign.com>
 *
 * Licensed under the MIT license <http://www.opensource.org/licenses/mit-license.php>
 */
 ;(function($, undefined) {
	'use strict';

	var pluginName = 'SuperBox',
		pluginVersion = '3.0.0';

	$.fn.SuperBox = function(options) {

		/*
		 * OPTIONS
		 */
		var defaults = $.extend({
			height : 400,
			view : 'landscape'
		}, options);

		/*
		 * DECLARATIONS
		 */
		var sbImgBottom,
			sbShowTop,
			sbShow = $('
'),
			sbImg = $(''),
			sbClose = $(''),
			sbFloat = $('
'),
			sbList = this.find('>div'),
			sbList8 = this.find('>div:nth-child(8n)'),
			sbList6 = this.find('>div:nth-child(6n)'),
			sbList4 = this.find('>div:nth-child(4n)'),
			sbList2 = this.find('>div:nth-child(2n)');

		/*
		 * METHODS
		 */

		/**
		 * setLastClass
		 *
		 * Last thumbnail is determined based on window width.
		 */
		var setLastClass = function(){
			var lastThumbnail = function(){
				if ($(window).width() > 1024) {
					sbList.removeClass('superbox-last');
					sbList8.addClass('superbox-last');
				} else if ($(window).width() > 767) {
					sbList.removeClass('superbox-last');
					sbList6.addClass('superbox-last');
				} else if ($(window).width() > 485) {
					sbList.removeClass('superbox-last');
					sbList4.addClass('superbox-last');
				} else {
					sbList.removeClass('superbox-last');
					sbList2.addClass('superbox-last');
				}
			};

			lastThumbnail();
			$(window).resize(function(){
				lastThumbnail();
			});
		};

		/**
		 * setSuperBoxHeight
		 *
		 * Set superbox-show outer height based on default height,
		 * based on viewport height,
		 * based on standard 2:3 ratio,
		 * based on default orientation.
		 */
		var setSuperBoxHeight = (function(){
			var thisWidth = $('.superbox-show').outerWidth(true),
				thisHeight = defaults.height + (16 * 3), /* 1.5em padding */
				newHeight = thisHeight,
				thisWindow = $(window).height() * 0.80,
				thisView = defaults.view,
				thisRatio = 0.6667;

			if (newHeight > thisWindow) {
				newHeight = thisWindow;
			}
			if ((thisView === 'landscape') && (thisWidth < newHeight / thisRatio)) {
				newHeight = thisWidth * thisRatio;
			}
			if ((thisView === 'portrait') && (thisWidth < newHeight * thisRatio)) {
				newHeight = thisWidth / thisRatio;
			}
			if ((thisView === 'square') && (thisWidth < newHeight)) {
				newHeight = thisWidth;
			}
			$('.superbox-show').outerHeight(newHeight);
		});

		/**
		 * createSuperboxShow
		 *
		 * Dynamically create superbox-show and insert it after superbox-last,
		 * apply data-img of the thumbnail to the source of the full image,
		 * open the superbox-show,
		 * fade in and out of each image,
		 * close superbox-show when X is clicked
		 * close superbox-show when open image is clicked
		 */
		var createSuperboxShow = function(elem){
			/*
			 * DECLARATIONS (createSuperboxShow)
			 */
			var noSuperbox = !$('.superbox-show').length,
				isOpen = elem.hasClass('superbox-O'),
				notLast = !elem.hasClass('superbox-last'),
				notInRowA = !elem.nextAll('.superbox-last:first').next('.superbox-show').length,
				notInRowB = !elem.next('.superbox-show').length,
			/*
			 * METHODS (createSuperboxShow)
			 */
				fabricate = function(type){
					if (type === 'A') {
						createAfterLastA();
					} else {
						createAfterLastB();
					}
					setImageData(elem);
					openSuperboxShow();
				},
				revealImage = function(bool){
					if (bool === true) {
						$('.superbox-show img.superbox-current-img').animate({opacity:1},750);
					} else {
						$('.superbox-show img.superbox-current-img').animate({opacity:0},100,function(){
							setImageData(elem);
						});
					}
				},
				quickSwap = function(){
					revealImage(false);
					revealImage(true);
					setOpenClass(true);
				},
				createAfterLastA = function(){
					sbShow.append(sbImg).append(sbClose).insertAfter(elem.nextAll('.superbox-last:first'));
					setSuperBoxHeight();
				},
				createAfterLastB = function(){
					sbShow.append(sbImg).append(sbClose).insertAfter(elem);
					setSuperBoxHeight();
				},
				setImageData = function(elem){
					$('img.superbox-current-img').attr('src',elem.find('img').data('img'));
				},
				openSuperboxShow = function(){
					$('.superbox-show').slideDown('slow',function(){
						revealImage(true);
						setOpenClass(true);
					});
				},
				setOpenClass = function(bool){
					if (bool === true) {
						sbList.removeClass('superbox-O');
						elem.addClass('superbox-O');
					} else {
						sbList.removeClass('superbox-O');
					}
				},
				closeSuperBoxShow = function(){
					var closeUp = function(){
						revealImage(false);
						$('.superbox-show').slideUp(function(){
							$(this).remove();
							setOpenClass(false);
							revealImage(false);
						});
					};
					$('.superbox-close').on('click',function(event){
						event.preventDefault();
						closeUp();
					});
					if (isOpen === true) {
						closeUp();
					}
				};

			/*
			 * IMPLEMENTATION (createSuperboxShow)
			 */
			if (isOpen === false) {
				if (notLast === true && notInRowA === true) {
					if (noSuperbox === true) {
						fabricate('A');
					} else {
						revealImage(false);
						$('.superbox-show').slideUp(function(){
							fabricate('A');
						});
					}
				} else if (notLast === false && notInRowB === true) {
					if (noSuperbox === true) {
						fabricate('B');
					} else {
						revealImage(false);
						$('.superbox-show').slideUp(function(){
							revealImage(false);
							fabricate('B');
						});
					}
				} else {
					quickSwap();
				}
			}

			closeSuperBoxShow();
		};

		/**
		 * keepShowAfterLast
		 *
		 * Move superbox-show to after superbox-last when window is resized
		 */
		var keepShowAfterLast = function(){
			$(window).resize(function(){
				if ($('.superbox-O').hasClass('superbox-last')) {
					$('.superbox-show').insertAfter($('.superbox-O'));
				} else {
					$('.superbox-show').insertAfter($('.superbox-O').nextAll('.superbox-last:first'));
				}
			});
		};

		/*
		 * IMPLEMENTATION
		 */

		/*
		 * Add superbox-active class to allow for CSS to take hold
		 */
		this.addClass('superbox-active');

		/*
		 * Add superbox-list class for easier CSS targeting
		 */
		sbList.addClass('superbox-list');

		/*
		 * Set superbox-last class
		 */
		setLastClass();

		/*
		 * Adjust superbox-show height based on window size
		 */
		$(window).resize(function(){
			setSuperBoxHeight();
		});

		/*
		 * Create final float
		 */
		sbFloat.appendTo(this);

		/*
		 * Open/Close superbox-show based on click
		 */
		sbList.on('click',function(){

			/*
			 * Set sbImgBottom to bottom position of clicked image
			 */
			sbImgBottom = $(this).find('img').offset().top + $(this).find('img').height();

			/*
			 * Create superbox-show
			 */
			createSuperboxShow($(this));

			/*
			 * Keep superbox-show after the proper row at all times
			 */
			keepShowAfterLast();
		});

		return this;
	};
})(jQuery);<|endoftext|>


<commit_before>'use strict';

/**
 * @ngdoc type
 * @name angular.Module
 * @module ng
 * @description
 *
 * Interface for configuring angular {@link angular.module modules}.
 */

function setupModuleLoader(window) {

  var $injectorMinErr = minErr('$injector');
  var ngMinErr = minErr('ng');

  function ensure(obj, name, factory) {
    return obj[name] || (obj[name] = factory());
  }

  var angular = ensure(window, 'angular', Object);

  // We need to expose `angular.$$minErr` to modules such as `ngResource` that reference it during bootstrap
  angular.$$minErr = angular.$$minErr || minErr;

  return ensure(angular, 'module', function() {
    /** @type {Object.<string, angular.Module>} */
    var modules = {};

    /**
     * @ngdoc function
     * @name angular.module
     * @module ng
     * @description
     *
     * The `angular.module` is a global place for creating, registering and retrieving Angular
     * modules.
     * All modules (angular core or 3rd party) that should be available to an application must be
     * registered using this mechanism.
     *
     * When passed two or more arguments, a new module is created.  If passed only one argument, an
     * existing module (the name passed as the first argument to `module`) is retrieved.
     *
     *
     * # Module
     *
     * A module is a collection of services, directives, filters, and configuration information.
     * `angular.module` is used to configure the {@link auto.$injector $injector}.
     *
     * ```js
     * // Create a new module
     * var myModule = angular.module('myModule', []);
     *
     * // register a new service
     * myModule.value('appName', 'MyCoolApp');
     *
     * // configure existing services inside initialization blocks.
     * myModule.config(function($locationProvider) {
     *   // Configure existing providers
     *   $locationProvider.hashPrefix('!');
     * });
     * ```
     *
     * Then you can create an injector and load your modules like this:
     *
     * ```js
     * var injector = angular.injector(['ng', 'myModule'])
     * ```
     *
     * However it's more likely that you'll just use
     * {@link ng.directive:ngApp ngApp} or
     * {@link angular.bootstrap} to simplify this process for you.
     *
     * @param {!string} name The name of the module to create or retrieve.
     * @param {Array.<string>=} requires If specified then new module is being created. If
     *        unspecified then the module is being retrieved for further configuration.
     * @param {Function} configFn Optional configuration function for the module. Same as
     *        {@link angular.Module#config Module#config()}.
     * @returns {module} new module with the {@link angular.Module} api.
     */
    return function module(name, requires, configFn) {
      var assertNotHasOwnProperty = function(name, context) {
        if (name === 'hasOwnProperty') {
          throw ngMinErr('badname', 'hasOwnProperty is not a valid {0} name', context);
        }
      };

      assertNotHasOwnProperty(name, 'module');
      if (requires && modules.hasOwnProperty(name)) {
        modules[name] = null;
      }
      return ensure(modules, name, function() {
        if (!requires) {
          throw $injectorMinErr('nomod', "Module '{0}' is not available! You either misspelled " +
             "the module name or forgot to load it. If registering a module ensure that you " +
             "specify the dependencies as the second argument.", name);
        }

        /** @type {!Array.<Array.<*>>} */
        var invokeQueue = [];

        /** @type {!Array.<Function>} */
        var runBlocks = [];

        var config = invokeLater('$injector', 'invoke');

        /** @type {angular.Module} */
        var moduleInstance = {
          // Private state
          _invokeQueue: invokeQueue,
          _runBlocks: runBlocks,

          /**
           * @ngdoc property
           * @name angular.Module#requires
           * @module ng
           * @returns {Array.<string>} List of module names which must be loaded before this module.
           * @description
           * Holds the list of modules which the injector will load before the current module is
           * loaded.
           */
          requires: requires,

          /**
           * @ngdoc property
           * @name angular.Module#name
           * @module ng
           * @returns {string} Name of the module.
           * @description
           */
          name: name,

          /**
           * @ngdoc method
           * @name angular.Module#provider
           * @module ng
           * @param {string} name service name
           * @param {Function} providerType Construction function for creating new instance of the
           *                                service.
           * @description
           * See {@link auto.$provide#provider $provide.provider()}.
           */
          provider: invokeLater('$provide', 'provider'),

          /**
           * @ngdoc method
           * @name angular.Module#factory
           * @module ng
           * @param {string} name service name
           * @param {Function} providerFunction Function for creating new instance of the service.
           * @description
           * See {@link auto.$provide#factory $provide.factory()}.
           */
          factory: invokeLater('$provide', 'factory'),

          /**
           * @ngdoc method
           * @name angular.Module#service
           * @module ng
           * @param {string} name service name
           * @param {Function} constructor A constructor function that will be instantiated.
           * @description
           * See {@link auto.$provide#service $provide.service()}.
           */
          service: invokeLater('$provide', 'service'),

          /**
           * @ngdoc method
           * @name angular.Module#value
           * @module ng
           * @param {string} name service name
           * @param {*} object Service instance object.
           * @description
           * See {@link auto.$provide#value $provide.value()}.
           */
          value: invokeLater('$provide', 'value'),

          /**
           * @ngdoc method
           * @name angular.Module#constant
           * @module ng
           * @param {string} name constant name
           * @param {*} object Constant value.
           * @description
           * Because the constant are fixed, they get applied before other provide methods.
           * See {@link auto.$provide#constant $provide.constant()}.
           */
          constant: invokeLater('$provide', 'constant', 'unshift'),

          /**
           * @ngdoc method
           * @name angular.Module#animation
           * @module ng
           * @param {string} name animation name
           * @param {Function} animationFactory Factory function for creating new instance of an
           *                                    animation.
           * @description
           *
           * **NOTE**: animations take effect only if the **ngAnimate** module is loaded.
           *
           *
           * Defines an animation hook that can be later used with
           * {@link ngAnimate.$animate $animate} service and directives that use this service.
           *
           * ```js
           * module.animation('.animation-name', function($inject1, $inject2) {
           *   return {
           *     eventName : function(element, done) {
           *       //code to run the animation
           *       //once complete, then run done()
           *       return function cancellationFunction(element) {
           *         //code to cancel the animation
           *       }
           *     }
           *   }
           * })
           * ```
           *
           * See {@link ngAnimate.$animateProvider#register $animateProvider.register()} and
           * {@link ngAnimate ngAnimate module} for more information.
           */
          animation: invokeLater('$animateProvider', 'register'),

          /**
           * @ngdoc method
           * @name angular.Module#filter
           * @module ng
           * @param {string} name Filter name.
           * @param {Function} filterFactory Factory function for creating new instance of filter.
           * @description
           * See {@link ng.$filterProvider#register $filterProvider.register()}.
           */
          filter: invokeLater('$filterProvider', 'register'),

          /**
           * @ngdoc method
           * @name angular.Module#controller
           * @module ng
           * @param {string|Object} name Controller name, or an object map of controllers where the
           *    keys are the names and the values are the constructors.
           * @param {Function} constructor Controller constructor function.
           * @description
           * See {@link ng.$controllerProvider#register $controllerProvider.register()}.
           */
          controller: invokeLater('$controllerProvider', 'register'),

          /**
           * @ngdoc method
           * @name angular.Module#directive
           * @module ng
           * @param {string|Object} name Directive name, or an object map of directives where the
           *    keys are the names and the values are the factories.
           * @param {Function} directiveFactory Factory function for creating new instance of
           * directives.
           * @description
           * See {@link ng.$compileProvider#directive $compileProvider.directive()}.
           */
          directive: invokeLater('$compileProvider', 'directive'),

          /**
           * @ngdoc method
           * @name angular.Module#config
           * @module ng
           * @param {Function} configFn Execute this function on module load. Useful for service
           *    configuration.
           * @description
           * Use this method to register work which needs to be performed on module loading.
           */
          config: config,

          /**
           * @ngdoc method
           * @name angular.Module#run
           * @module ng
           * @param {Function} initializationFn Execute this function after injector creation.
           *    Useful for application initialization.
           * @description
           * Use this method to register work which should be performed when the injector is done
           * loading all modules.
           */
          run: function(block) {
            runBlocks.push(block);
            return this;
          }
        };

        if (configFn) {
          config(configFn);
        }

        return  moduleInstance;

        /**
         * @param {string} provider
         * @param {string} method
         * @param {String=} insertMethod
         * @returns {angular.Module}
         */
        function invokeLater(provider, method, insertMethod) {
          return function() {
            invokeQueue[insertMethod || 'push']([provider, method, arguments]);
            return moduleInstance;
          };
        }
      });
    };
  });

}
<commit_msg>docs(loader): add annotations to example<commit_after>'use strict';

/**
 * @ngdoc type
 * @name angular.Module
 * @module ng
 * @description
 *
 * Interface for configuring angular {@link angular.module modules}.
 */

function setupModuleLoader(window) {

  var $injectorMinErr = minErr('$injector');
  var ngMinErr = minErr('ng');

  function ensure(obj, name, factory) {
    return obj[name] || (obj[name] = factory());
  }

  var angular = ensure(window, 'angular', Object);

  // We need to expose `angular.$$minErr` to modules such as `ngResource` that reference it during bootstrap
  angular.$$minErr = angular.$$minErr || minErr;

  return ensure(angular, 'module', function() {
    /** @type {Object.<string, angular.Module>} */
    var modules = {};

    /**
     * @ngdoc function
     * @name angular.module
     * @module ng
     * @description
     *
     * The `angular.module` is a global place for creating, registering and retrieving Angular
     * modules.
     * All modules (angular core or 3rd party) that should be available to an application must be
     * registered using this mechanism.
     *
     * When passed two or more arguments, a new module is created.  If passed only one argument, an
     * existing module (the name passed as the first argument to `module`) is retrieved.
     *
     *
     * # Module
     *
     * A module is a collection of services, directives, filters, and configuration information.
     * `angular.module` is used to configure the {@link auto.$injector $injector}.
     *
     * ```js
     * // Create a new module
     * var myModule = angular.module('myModule', []);
     *
     * // register a new service
     * myModule.value('appName', 'MyCoolApp');
     *
     * // configure existing services inside initialization blocks.
     * myModule.config(['$locationProvider', function($locationProvider) {
     *   // Configure existing providers
     *   $locationProvider.hashPrefix('!');
     * }]);
     * ```
     *
     * Then you can create an injector and load your modules like this:
     *
     * ```js
     * var injector = angular.injector(['ng', 'myModule'])
     * ```
     *
     * However it's more likely that you'll just use
     * {@link ng.directive:ngApp ngApp} or
     * {@link angular.bootstrap} to simplify this process for you.
     *
     * @param {!string} name The name of the module to create or retrieve.
     * @param {Array.<string>=} requires If specified then new module is being created. If
     *        unspecified then the module is being retrieved for further configuration.
     * @param {Function} configFn Optional configuration function for the module. Same as
     *        {@link angular.Module#config Module#config()}.
     * @returns {module} new module with the {@link angular.Module} api.
     */
    return function module(name, requires, configFn) {
      var assertNotHasOwnProperty = function(name, context) {
        if (name === 'hasOwnProperty') {
          throw ngMinErr('badname', 'hasOwnProperty is not a valid {0} name', context);
        }
      };

      assertNotHasOwnProperty(name, 'module');
      if (requires && modules.hasOwnProperty(name)) {
        modules[name] = null;
      }
      return ensure(modules, name, function() {
        if (!requires) {
          throw $injectorMinErr('nomod', "Module '{0}' is not available! You either misspelled " +
             "the module name or forgot to load it. If registering a module ensure that you " +
             "specify the dependencies as the second argument.", name);
        }

        /** @type {!Array.<Array.<*>>} */
        var invokeQueue = [];

        /** @type {!Array.<Function>} */
        var runBlocks = [];

        var config = invokeLater('$injector', 'invoke');

        /** @type {angular.Module} */
        var moduleInstance = {
          // Private state
          _invokeQueue: invokeQueue,
          _runBlocks: runBlocks,

          /**
           * @ngdoc property
           * @name angular.Module#requires
           * @module ng
           * @returns {Array.<string>} List of module names which must be loaded before this module.
           * @description
           * Holds the list of modules which the injector will load before the current module is
           * loaded.
           */
          requires: requires,

          /**
           * @ngdoc property
           * @name angular.Module#name
           * @module ng
           * @returns {string} Name of the module.
           * @description
           */
          name: name,

          /**
           * @ngdoc method
           * @name angular.Module#provider
           * @module ng
           * @param {string} name service name
           * @param {Function} providerType Construction function for creating new instance of the
           *                                service.
           * @description
           * See {@link auto.$provide#provider $provide.provider()}.
           */
          provider: invokeLater('$provide', 'provider'),

          /**
           * @ngdoc method
           * @name angular.Module#factory
           * @module ng
           * @param {string} name service name
           * @param {Function} providerFunction Function for creating new instance of the service.
           * @description
           * See {@link auto.$provide#factory $provide.factory()}.
           */
          factory: invokeLater('$provide', 'factory'),

          /**
           * @ngdoc method
           * @name angular.Module#service
           * @module ng
           * @param {string} name service name
           * @param {Function} constructor A constructor function that will be instantiated.
           * @description
           * See {@link auto.$provide#service $provide.service()}.
           */
          service: invokeLater('$provide', 'service'),

          /**
           * @ngdoc method
           * @name angular.Module#value
           * @module ng
           * @param {string} name service name
           * @param {*} object Service instance object.
           * @description
           * See {@link auto.$provide#value $provide.value()}.
           */
          value: invokeLater('$provide', 'value'),

          /**
           * @ngdoc method
           * @name angular.Module#constant
           * @module ng
           * @param {string} name constant name
           * @param {*} object Constant value.
           * @description
           * Because the constant are fixed, they get applied before other provide methods.
           * See {@link auto.$provide#constant $provide.constant()}.
           */
          constant: invokeLater('$provide', 'constant', 'unshift'),

          /**
           * @ngdoc method
           * @name angular.Module#animation
           * @module ng
           * @param {string} name animation name
           * @param {Function} animationFactory Factory function for creating new instance of an
           *                                    animation.
           * @description
           *
           * **NOTE**: animations take effect only if the **ngAnimate** module is loaded.
           *
           *
           * Defines an animation hook that can be later used with
           * {@link ngAnimate.$animate $animate} service and directives that use this service.
           *
           * ```js
           * module.animation('.animation-name', function($inject1, $inject2) {
           *   return {
           *     eventName : function(element, done) {
           *       //code to run the animation
           *       //once complete, then run done()
           *       return function cancellationFunction(element) {
           *         //code to cancel the animation
           *       }
           *     }
           *   }
           * })
           * ```
           *
           * See {@link ngAnimate.$animateProvider#register $animateProvider.register()} and
           * {@link ngAnimate ngAnimate module} for more information.
           */
          animation: invokeLater('$animateProvider', 'register'),

          /**
           * @ngdoc method
           * @name angular.Module#filter
           * @module ng
           * @param {string} name Filter name.
           * @param {Function} filterFactory Factory function for creating new instance of filter.
           * @description
           * See {@link ng.$filterProvider#register $filterProvider.register()}.
           */
          filter: invokeLater('$filterProvider', 'register'),

          /**
           * @ngdoc method
           * @name angular.Module#controller
           * @module ng
           * @param {string|Object} name Controller name, or an object map of controllers where the
           *    keys are the names and the values are the constructors.
           * @param {Function} constructor Controller constructor function.
           * @description
           * See {@link ng.$controllerProvider#register $controllerProvider.register()}.
           */
          controller: invokeLater('$controllerProvider', 'register'),

          /**
           * @ngdoc method
           * @name angular.Module#directive
           * @module ng
           * @param {string|Object} name Directive name, or an object map of directives where the
           *    keys are the names and the values are the factories.
           * @param {Function} directiveFactory Factory function for creating new instance of
           * directives.
           * @description
           * See {@link ng.$compileProvider#directive $compileProvider.directive()}.
           */
          directive: invokeLater('$compileProvider', 'directive'),

          /**
           * @ngdoc method
           * @name angular.Module#config
           * @module ng
           * @param {Function} configFn Execute this function on module load. Useful for service
           *    configuration.
           * @description
           * Use this method to register work which needs to be performed on module loading.
           */
          config: config,

          /**
           * @ngdoc method
           * @name angular.Module#run
           * @module ng
           * @param {Function} initializationFn Execute this function after injector creation.
           *    Useful for application initialization.
           * @description
           * Use this method to register work which should be performed when the injector is done
           * loading all modules.
           */
          run: function(block) {
            runBlocks.push(block);
            return this;
          }
        };

        if (configFn) {
          config(configFn);
        }

        return  moduleInstance;

        /**
         * @param {string} provider
         * @param {string} method
         * @param {String=} insertMethod
         * @returns {angular.Module}
         */
        function invokeLater(provider, method, insertMethod) {
          return function() {
            invokeQueue[insertMethod || 'push']([provider, method, arguments]);
            return moduleInstance;
          };
        }
      });
    };
  });

}
<|endoftext|>


<commit_before>var surfaces = [];

function Surface(name, kodaira, c2, c12, h11) {
  this.name = name;
  this.kodaira = kodaira;
  this.c2 = c2;
  this.c12 = c12;
  this.h11 = h11;
}

// Kodaira dimension -\infty

var plane = new Surface("projective plane", -1, 3, 9, 1);
surfaces.push(plane);

var hirzebruch = new Surface("Hirzebruch surfaces", -1, 4, 8, 2);
hirzebruch.construction = "Ruled surface over $\\mathbb{P}^1$, i.e. it is defined as $\\operatorname{Proj}(\\mathcal{O}_{\\mathbb{P}^1}\\oplus\\mathcal{O}_{\\mathbb{P}^1}(n))$ for some $n\\geq 0$.";
surfaces.push(hirzebruch);

// this can increase whenever we increase the size of the viewport, currently not implemented
for (var g = 1; g < 5; g++) {
  var ruled = new Surface("ruled surfaces", -1, 4 - 4*g, 8 - 8*g, 2);
  surfaces.push(ruled);
}

// Kodaira dimension 0

surfaces.push(
  {
    "name" : "abelian surfaces",
    "kodaira" : 0,
    "c2" : 0,
    "c12" : 0,
    "h11" : 4,
    "description" : "Abelian variety of dimension $2$.",
  }
);

surfaces.push(
  {
    "name" : "Enriques surfaces",
    "kodaira" : 0,
    "c2" : 12,
    "c12" : 0,
    "h11" : 10,
    "description" : "Algebraic surface such that $\\mathrm{q}=0$ and the canonical line bundle is non-trivial but has trivial square.",
  }
);

surfaces.push(
  {
    "name" : "K3 surfaces",
    "kodaira" : 0,
    "c2" : 24,
    "c12" : 0,
    "h11" : 20,
    "description" : "Algebraic surface such that $q = 0$ and the canonical bundle is trivial.",
  }
);

surfaces.push(
  {
    "name" : "bielliptic surfaces",
    "kodaira" : 0,
    "c2" : 0,
    "c12" : 0,
    "h11" : 2,
    "description" : "Algebraic surface with an elliptic fibration over an elliptic curve.",
  }
);

// Kodaira dimension 1

// this can increase whenever we increase the size of the viewport, currently not implemented
//for (var x = 1; x < 9; x++) {
//  surfaces.push(
//    {
//      "name" : "elliptic surfaces",
//      "kodaira" : 1,
//      "c2" : 12*x,
//      "c12" : 0,
//      "description" : "Algebraic surface with a proper morphism to a curve, such that almost all fibres are smooth curves of genus $1$.",
//    }
//  );
//}

// Kodaira dimension 2

surfaces.push(
  {
    "name" : "fake projective planes",
    "kodaira" : 2,
    "c2" : 3,
    "c12" : 9,
    "h11" : 1,
    "description" : "Algebraic surface with the same Betti numbers as the projective plane (but not isomorphic to it). There are 50 different such surfaces.",
  }
);

surfaces.push(
  {
    "name" : "Beauville surfaces",
    "kodaira" : 2,
    "c2" : 4,
    "c12" : 8,
    "h11" : 2,
    "description" : "
Algebraic surface introduced by Beauville, with the same numerical characteristics as a quadric surface (or Hirzebruch surface). See Complex algebraic surfaces, Arnaud Beauville (1996).",
    "construction" : "Take two smooth curves $C_1$ and $C_2$ of genus $g_1$ and $g_2$. Let $G$ be a finite group acting on $C_1$ and $C_2$ such that

$\\#G=(g_1-1)(g_2-1)$
no $g\\in G\\setminus\\{1\\}$ has a fix point on both $C_1$ and $C_2$
$C_i/G$ is rational
 Then $(C_1\\times C_2)/G$ is a Beauville surface."
  }
);

for (var n = 2; n <= 6; n++) {
  surfaces.push(
    {
      "name" : "Burniat surfaces",
      "kodaira" : 2,
      "c2" : 12 - n,
      "c12" : n,
      "h11" : 10 - n,
      "description" : "Algebraic surface introduced by Burniat. See Sur les surfaces de genre $P_{12}>1$, Pol Burniat (1966).",
    }
  );
}

surfaces.push(
  {
    "name" : "Campedelli surface",
    "kodaira" : 2,
    "c2" : 10,
    "c12" : 2,
    "h11" : 8,
    "description" : "Algebraic surface introduced by Campedelli.",
  }
);

surfaces.push(
  {
    "name" : "Catanese surface",
    "kodaira" : 2,
    "c2" : 10,
    "c12" : 2,
    "h11" : 8,
    "description" : "Algebraic surface introduced by Catanese, in Babbage's conjecture, contact of surfaces, symmetric determinantal varieties and applications (1981).",
  }
);

surfaces.push(
  {
    "name" : "Godeaux surface",
    "kodaira" : 2,
    "c2" : 11,
    "c12" : 1,
    "h11" : 9,
    "description" : "Algebraic surface introduced by Lucien Godeaux.",
  }
);

surfaces.push(
  {
    "name" : "Barlow surface",
    "kodaira" : 2,
    "c2" : 11,
    "c12" : 1,
    "h11" : 9,
    "description" : "Algebraic surface introduced by Rebecca Barlow. See Some new surfaces with $p_{g} = 0$, Rebecca Barlow (1984).",
  }
);

surfaces.push(
  {
    "name" : "Fano surfaces",
    "kodaira" : 2,
    "c2" : 27,
    "c12" : 45,
    "h11" : 25,
    "description" : "These surfaces parametrise lines on a non-singular cubic threefold.",
    "construction" : "Subvariety in the Grassmannian of lines in $\\mathbb{P}^4$ lying on a non-singular cubic threefold.",
  }
);

// products of two curves of genus >= 2
for (var g1 = 2; g1 < 5; g1++) {
  // some (i,j)'s don't show up in the graph, but this is the easiest solution
  for (var g2 = g1; g2 < 9; g2++) {
    var c2 = 4 - 4*(g1+g2) + 4*g1*g2;
    var c12 = 8*g1*g2 - 8*(g1+g2) + 8;
    var h11 = 2*g1*g2 + 2;

    var product = new Surface("Product of curves of genus " + g1 + " and " + g2, 2, c2, c12, h11);
    product.construction = "Let $C_1$ and $C_2$ be curves of genus $g_1,g_2\\geq 2$. Then $C_1\\times C_2$ is always of general type.";
    product.description = "The numerical invariants are completely determined in terms of $g_1=" + g1 + "$ and $g_2=" + g2 + "$, with $\\mathrm{q}=g_1+g_2$, $\\mathrm{p}_{\\mathrm{g}}=g_1g_2$ and $\\mathrm{h}^{1,1}=2g_1g_2+2$.";
    surfaces.push(product);
  }
}

// complete intersections

// compute c_1^2 of a complete intersection with degrees d
function cic12(d) {
  var c12 = 0;

  for (var i = 0; i < d.length; i++)
    c12 = c12 + d[i];
  c12 = c12 - (d.length + 3);
  c12 = c12 * c12;

  for (var i = 0; i < d.length; i++)
    c12 = c12 * d[i];

  return c12;
}

// compute c_2 of a complete intersection with degrees d
function cic2(d) {
  var c2 = 0;

  c2 = c2 + ((d.length + 3) * (d.length + 2)) / 2;

  for (var i = 0; i < d.length; i++) {
    c2 = c2 - (d.length + 3) * d[i];
    c2 = c2 + d[i] * d[i];
  }

  for (var i = 0; i < d.length; i++) {
    for (var j = i + 1; j < d.length; j++) {
      c2 = c2 + d[i] * d[j];
    }
  }

  for (var i = 0; i < d.length; i++)
    c2 = c2 * d[i];

  return c2;
}

// compute h^{1,1} of a complete intersection with degrees d
function cih11(d) {
  var c12 = cic12(d);
  var c2 = cic2(d);

  var pg = (c12 + c2) / 12 - 1;

  return c2 - 2 - 2 * pg;
}

// I didn't have a clue of how big the c_1^2 and c_2 would get, apparently this list is way bigger than what can be displayed
var degrees = [[5], [6], [7], [8],
               [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [4, 4],
               [2, 2, 3], [2, 2, 4], [2, 3, 3], [2, 3, 4], [2, 4, 4],
               [2, 2, 2, 2], [2, 2, 2, 3], [2, 2, 2, 4], [2, 2, 3, 3],
               [2, 2, 2, 2, 2]
              ];

for (var i = 0; i < degrees.length; i++) {
  var c12 = cic12(degrees[i]);
  var c2 = cic2(degrees[i]);
  var h11 = cih11(degrees[i]);

  var product = new Surface("Complete intersection of degree $(" + degrees[i].join(",") + ")$", 2, c2, c12, h11);
    surfaces.push(product);
}
<commit_msg>Upgrade Kodaira dimension 0 to the new format<commit_after>var surfaces = [];

function Surface(name, kodaira, c2, c12, h11) {
  this.name = name;
  this.kodaira = kodaira;
  this.c2 = c2;
  this.c12 = c12;
  this.h11 = h11;
}

// Kodaira dimension -\infty

var plane = new Surface("projective plane", -1, 3, 9, 1);
surfaces.push(plane);

var hirzebruch = new Surface("Hirzebruch surfaces", -1, 4, 8, 2);
hirzebruch.construction = "Ruled surface over $\\mathbb{P}^1$, i.e. it is defined as $\\operatorname{Proj}(\\mathcal{O}_{\\mathbb{P}^1}\\oplus\\mathcal{O}_{\\mathbb{P}^1}(n))$ for some $n\\geq 0$.";
surfaces.push(hirzebruch);

// this can increase whenever we increase the size of the viewport, currently not implemented
for (var g = 1; g < 5; g++) {
  var ruled = new Surface("ruled surfaces", -1, 4 - 4*g, 8 - 8*g, 2);
  surfaces.push(ruled);
}

// Kodaira dimension 0

var abelian = new Surface("abelian surfaces", 0, 0, 0, 4);
abelian.description = "Abelian variety of dimension $2$.";
surfaces.push(abelian);

var enriques = new Surface("Enriques surfaces", 0, 12, 0, 10);
enriques.description = "Algebraic surface such that $\\mathrm{q}=0$ and the canonical line bundle is non-trivial but has trivial square.";
surfaces.push(enriques);

var k3 = new Surface("K3 surfaces", 0, 24, 0, 20);
k3.description = "Algebraic surface such that $q = 0$ and the canonical bundle is trivial.";
surfaces.push(k3);

var bielliptic = new Surface("bielliptic surfaces", 0, 0, 0, 2)
bielliptic.description = "Algebraic surface with an elliptic fibration over an elliptic curve.";
surfaces.push(bielliptic);

// Kodaira dimension 1

// this can increase whenever we increase the size of the viewport, currently not implemented
//for (var x = 1; x < 9; x++) {
//  surfaces.push(
//    {
//      "name" : "elliptic surfaces",
//      "kodaira" : 1,
//      "c2" : 12*x,
//      "c12" : 0,
//      "description" : "Algebraic surface with a proper morphism to a curve, such that almost all fibres are smooth curves of genus $1$.",
//    }
//  );
//}

// Kodaira dimension 2

surfaces.push(
  {
    "name" : "fake projective planes",
    "kodaira" : 2,
    "c2" : 3,
    "c12" : 9,
    "h11" : 1,
    "description" : "Algebraic surface with the same Betti numbers as the projective plane (but not isomorphic to it). There are 50 different such surfaces.",
  }
);

surfaces.push(
  {
    "name" : "Beauville surfaces",
    "kodaira" : 2,
    "c2" : 4,
    "c12" : 8,
    "h11" : 2,
    "description" : "
Algebraic surface introduced by Beauville, with the same numerical characteristics as a quadric surface (or Hirzebruch surface). See Complex algebraic surfaces, Arnaud Beauville (1996).",
    "construction" : "Take two smooth curves $C_1$ and $C_2$ of genus $g_1$ and $g_2$. Let $G$ be a finite group acting on $C_1$ and $C_2$ such that

$\\#G=(g_1-1)(g_2-1)$
no $g\\in G\\setminus\\{1\\}$ has a fix point on both $C_1$ and $C_2$
$C_i/G$ is rational
 Then $(C_1\\times C_2)/G$ is a Beauville surface."
  }
);

for (var n = 2; n <= 6; n++) {
  surfaces.push(
    {
      "name" : "Burniat surfaces",
      "kodaira" : 2,
      "c2" : 12 - n,
      "c12" : n,
      "h11" : 10 - n,
      "description" : "Algebraic surface introduced by Burniat. See Sur les surfaces de genre $P_{12}>1$, Pol Burniat (1966).",
    }
  );
}

surfaces.push(
  {
    "name" : "Campedelli surface",
    "kodaira" : 2,
    "c2" : 10,
    "c12" : 2,
    "h11" : 8,
    "description" : "Algebraic surface introduced by Campedelli.",
  }
);

surfaces.push(
  {
    "name" : "Catanese surface",
    "kodaira" : 2,
    "c2" : 10,
    "c12" : 2,
    "h11" : 8,
    "description" : "Algebraic surface introduced by Catanese, in Babbage's conjecture, contact of surfaces, symmetric determinantal varieties and applications (1981).",
  }
);

surfaces.push(
  {
    "name" : "Godeaux surface",
    "kodaira" : 2,
    "c2" : 11,
    "c12" : 1,
    "h11" : 9,
    "description" : "Algebraic surface introduced by Lucien Godeaux.",
  }
);

surfaces.push(
  {
    "name" : "Barlow surface",
    "kodaira" : 2,
    "c2" : 11,
    "c12" : 1,
    "h11" : 9,
    "description" : "Algebraic surface introduced by Rebecca Barlow. See Some new surfaces with $p_{g} = 0$, Rebecca Barlow (1984).",
  }
);

surfaces.push(
  {
    "name" : "Fano surfaces",
    "kodaira" : 2,
    "c2" : 27,
    "c12" : 45,
    "h11" : 25,
    "description" : "These surfaces parametrise lines on a non-singular cubic threefold.",
    "construction" : "Subvariety in the Grassmannian of lines in $\\mathbb{P}^4$ lying on a non-singular cubic threefold.",
  }
);

// products of two curves of genus >= 2
for (var g1 = 2; g1 < 5; g1++) {
  // some (i,j)'s don't show up in the graph, but this is the easiest solution
  for (var g2 = g1; g2 < 9; g2++) {
    var c2 = 4 - 4*(g1+g2) + 4*g1*g2;
    var c12 = 8*g1*g2 - 8*(g1+g2) + 8;
    var h11 = 2*g1*g2 + 2;

    var product = new Surface("Product of curves of genus " + g1 + " and " + g2, 2, c2, c12, h11);
    product.construction = "Let $C_1$ and $C_2$ be curves of genus $g_1,g_2\\geq 2$. Then $C_1\\times C_2$ is always of general type.";
    product.description = "The numerical invariants are completely determined in terms of $g_1=" + g1 + "$ and $g_2=" + g2 + "$, with $\\mathrm{q}=g_1+g_2$, $\\mathrm{p}_{\\mathrm{g}}=g_1g_2$ and $\\mathrm{h}^{1,1}=2g_1g_2+2$.";
    surfaces.push(product);
  }
}

// complete intersections

// compute c_1^2 of a complete intersection with degrees d
function cic12(d) {
  var c12 = 0;

  for (var i = 0; i < d.length; i++)
    c12 = c12 + d[i];
  c12 = c12 - (d.length + 3);
  c12 = c12 * c12;

  for (var i = 0; i < d.length; i++)
    c12 = c12 * d[i];

  return c12;
}

// compute c_2 of a complete intersection with degrees d
function cic2(d) {
  var c2 = 0;

  c2 = c2 + ((d.length + 3) * (d.length + 2)) / 2;

  for (var i = 0; i < d.length; i++) {
    c2 = c2 - (d.length + 3) * d[i];
    c2 = c2 + d[i] * d[i];
  }

  for (var i = 0; i < d.length; i++) {
    for (var j = i + 1; j < d.length; j++) {
      c2 = c2 + d[i] * d[j];
    }
  }

  for (var i = 0; i < d.length; i++)
    c2 = c2 * d[i];

  return c2;
}

// compute h^{1,1} of a complete intersection with degrees d
function cih11(d) {
  var c12 = cic12(d);
  var c2 = cic2(d);

  var pg = (c12 + c2) / 12 - 1;

  return c2 - 2 - 2 * pg;
}

// I didn't have a clue of how big the c_1^2 and c_2 would get, apparently this list is way bigger than what can be displayed
var degrees = [[5], [6], [7], [8],
               [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [4, 4],
               [2, 2, 3], [2, 2, 4], [2, 3, 3], [2, 3, 4], [2, 4, 4],
               [2, 2, 2, 2], [2, 2, 2, 3], [2, 2, 2, 4], [2, 2, 3, 3],
               [2, 2, 2, 2, 2]
              ];

for (var i = 0; i < degrees.length; i++) {
  var c12 = cic12(degrees[i]);
  var c2 = cic2(degrees[i]);
  var h11 = cih11(degrees[i]);

  var product = new Surface("Complete intersection of degree $(" + degrees[i].join(",") + ")$", 2, c2, c12, h11);
    surfaces.push(product);
}
<|endoftext|>


<commit_before>const Header = require('./header.js')

const BODY = Symbol('body')
class Pax {
  constructor (obj, global) {
    this.atime = obj.atime || null
    this.charset = obj.charset || null
    this.comment = obj.comment || null
    this.ctime = obj.ctime || null
    this.gid = obj.gid || null
    this.gname = obj.gname || null
    this.linkpath = obj.linkpath || null
    this.mtime = obj.mtime || null
    this.path = obj.path || null
    this.realtime = obj.realtime || null
    this.security = obj.security || null
    this.size = obj.size || null
    this.uid = obj.uid || null
    this.uname = obj.uname || null
    this.dev = obj.dev || null
    this.ino = obj.ino || null
    this.nlink = obj.nlink || null
    this.global = global || false
  }

  encode () {
    const body = this.encodeBody()
    if (body === '')
      return null

    // round up to 512 bytes
    // add 512 for header
    const bodyLen = Buffer.byteLength(body)
    const bufLen = 512 * Math.ceil(1 + bodyLen / 512)
    const buf = Buffer.allocUnsafe(bufLen)

    new Header({
      path: 'PaxHeader' + path.join('/', props.path || ''),
      mode: this.mode || 0o644,
      uid: this.uid || null,
      gid: this.gid || null,
      size: bodyLen,
      mtime: this.mtime || null,
      typeKey: this.global ? 'g' : 'x',
      type: this.global ? 'GlobalExtendedHeader' : 'ExtendedHeader',
      linkpath: '',
      uname: this.uname || '',
      gname: this.gname || '',
      devmaj: 0,
      devmin: 0,
      atime: this.atime || null,
      ctime: this.ctime || null
    }, buf)

    buf.write(body, 512, bodyLen, 'utf8')
    for (let i = bodyLen + 512; i < buf.length; i++) {
      buf[i] = 0
    }
  }

  encodeBody () {
    return (
      this.encodeField('atime') +
      this.encodeField('charset') +
      this.encodeField('comment') +
      this.encodeField('ctime') +
      this.encodeField('gid') +
      this.encodeField('gname') +
      this.encodeField('linkpath') +
      this.encodeField('mtime') +
      this.encodeField('path') +
      this.encodeField('realtime') +
      this.encodeField('security') +
      this.encodeField('size') +
      this.encodeField('uid') +
      this.encodeField('uname') +
      this.encodeField('dev') +
      this.encodeField('ino') +
      this.encodeField('nlink')
    )
  }

  encodeField (field) {
    if (this[field] === null || this[field] === undefined)
      return ''
    if (field === 'dev' || field === 'ino' || field === 'nlink')
      field = 'SCHILY.' + field
    const kv = ' ' + field + '=' + this[field] + '\n'
    const byteLen = Buffer.byteLength(s)
    // the digits includes the length of the digits in ascii base-10
    // so if it's 9 characters, then adding 1 for the 9 makes it 10
    // which makes it 11 chars.
    let digits = Math.floor(Math.log(byteLen) / Math.log(10)) + 1
    if (byteLen + digits >= Math.pow(10, digits))
      digits += 1
    const len = digits + s.length
    return len + s
  }
}

Pax.parse = (string, ex, g) => new Pax(merge(parseKV(string), ex), g)

const parsePax = (string, ex) => new Pax(merge(parseKV(string), ex))

const merge = (a, b) =>
  b ? Object.keys(a).reduce((s, k) => (s[k] = a[k], s), b) : a

const parseKV = string =>
  string
    .replace(/\n$/, '')
    .split('\n')
    .reduce(parseKVLine, Object.create(null))

const parseKVLine = (set, line) => {
  const n = parseInt(line, 10)
  assert.equal(n, Buffer.byteLength(line) + 1)  // + trailing \n
  line = line.substr((n + ' ').length)
  const kv = line.split('=')
  const k = kv.shift().replace(/^SCHILY\.(dev|ino|nlink)/, '$1')
  const v = kv.join('=')
  set[k] = /^[0-9]+$/.test(v) ? +v : v
  return set
}

module.exports = Pax
<commit_msg>remove unused symbol in pax.js<commit_after>const Header = require('./header.js')

class Pax {
  constructor (obj, global) {
    this.atime = obj.atime || null
    this.charset = obj.charset || null
    this.comment = obj.comment || null
    this.ctime = obj.ctime || null
    this.gid = obj.gid || null
    this.gname = obj.gname || null
    this.linkpath = obj.linkpath || null
    this.mtime = obj.mtime || null
    this.path = obj.path || null
    this.realtime = obj.realtime || null
    this.security = obj.security || null
    this.size = obj.size || null
    this.uid = obj.uid || null
    this.uname = obj.uname || null
    this.dev = obj.dev || null
    this.ino = obj.ino || null
    this.nlink = obj.nlink || null
    this.global = global || false
  }

  encode () {
    const body = this.encodeBody()
    if (body === '')
      return null

    const bodyLen = Buffer.byteLength(body)
    // round up to 512 bytes
    // add 512 for header
    const bufLen = 512 * Math.ceil(1 + bodyLen / 512)
    const buf = Buffer.allocUnsafe(bufLen)

    new Header({
      path: 'PaxHeader' + path.join('/', props.path || ''),
      mode: this.mode || 0o644,
      uid: this.uid || null,
      gid: this.gid || null,
      size: bodyLen,
      mtime: this.mtime || null,
      typeKey: this.global ? 'g' : 'x',
      type: this.global ? 'GlobalExtendedHeader' : 'ExtendedHeader',
      linkpath: '',
      uname: this.uname || '',
      gname: this.gname || '',
      devmaj: 0,
      devmin: 0,
      atime: this.atime || null,
      ctime: this.ctime || null
    }, buf)

    buf.write(body, 512, bodyLen, 'utf8')
    for (let i = bodyLen + 512; i < buf.length; i++) {
      buf[i] = 0
    }

    return buf
  }

  encodeBody () {
    return (
      this.encodeField('atime') +
      this.encodeField('charset') +
      this.encodeField('comment') +
      this.encodeField('ctime') +
      this.encodeField('gid') +
      this.encodeField('gname') +
      this.encodeField('linkpath') +
      this.encodeField('mtime') +
      this.encodeField('path') +
      this.encodeField('realtime') +
      this.encodeField('security') +
      this.encodeField('size') +
      this.encodeField('uid') +
      this.encodeField('uname') +
      this.encodeField('dev') +
      this.encodeField('ino') +
      this.encodeField('nlink')
    )
  }

  encodeField (field) {
    if (this[field] === null || this[field] === undefined)
      return ''
    if (field === 'dev' || field === 'ino' || field === 'nlink')
      field = 'SCHILY.' + field
    const kv = ' ' + field + '=' + this[field] + '\n'
    const byteLen = Buffer.byteLength(s)
    // the digits includes the length of the digits in ascii base-10
    // so if it's 9 characters, then adding 1 for the 9 makes it 10
    // which makes it 11 chars.
    let digits = Math.floor(Math.log(byteLen) / Math.log(10)) + 1
    if (byteLen + digits >= Math.pow(10, digits))
      digits += 1
    const len = digits + s.length
    return len + s
  }
}

Pax.parse = (string, ex, g) => new Pax(merge(parseKV(string), ex), g)

const parsePax = (string, ex) => new Pax(merge(parseKV(string), ex))

const merge = (a, b) =>
  b ? Object.keys(a).reduce((s, k) => (s[k] = a[k], s), b) : a

const parseKV = string =>
  string
    .replace(/\n$/, '')
    .split('\n')
    .reduce(parseKVLine, Object.create(null))

const parseKVLine = (set, line) => {
  const n = parseInt(line, 10)
  assert.equal(n, Buffer.byteLength(line) + 1)  // + trailing \n
  line = line.substr((n + ' ').length)
  const kv = line.split('=')
  const k = kv.shift().replace(/^SCHILY\.(dev|ino|nlink)/, '$1')
  const v = kv.join('=')
  set[k] = /^[0-9]+$/.test(v) ? +v : v
  return set
}

module.exports = Pax
<|endoftext|>


<commit_before>import MessageTemplate from './messageTemplate';
import LogEvent from './logEvent';
import * as logLevels from './logLevels';

const _levelMap = new WeakMap();
const _pipeline = new WeakMap();

export default class Logger {
  constructor(levelMap, pipeline) {
    _levelMap.set(this, levelMap);
    _pipeline.set(this, pipeline);
  }

  error(messageTemplate, ...properties) {
    this.write.call(this, logLevels.ERROR, messageTemplate, ...properties);
  }

  warn(messageTemplate, ...properties) {
    this.write.call(this, logLevels.WARN, messageTemplate, ...properties);
  }

  info(messageTemplate, ...properties) {
    this.write.call(this, logLevels.INFO, messageTemplate, ...properties);
  }

  debug(messageTemplate, ...properties) {
    this.write.call(this, logLevels.DEBUG, messageTemplate, ...properties);
  }

  verbose(messageTemplate, ...properties) {
    this.write.call(this, logLevels.VERBOSE, messageTemplate, ...properties);
  }

  write(level, messageTemplate, ...properties) {
    if (!_levelMap.get(this).isEnabled(level)) {
      return;
    }
    const parsedTemplate = new MessageTemplate(messageTemplate);
    const properties = parsedTemplate.bindProperties(properties);

    const event = new LogEvent(new Date(), level, parsedTemplate, properties);
    _pipeline.get(this).emit([event]);
  }

  enrich(properties, destructure) {
    const enrichedPipeline = new Pipeline([
      // Set stuff
    ]);
    return new Logger(_levelMap.get(this), enrichedPipeline);
  }

  flush() {
    return _pipeline.get(this).flush();
  }

  close() {
    return _pipeline.get(this).close();
  }
}
<commit_msg>It's getting late...<commit_after>import MessageTemplate from './messageTemplate';
import LogEvent from './logEvent';
import * as logLevels from './logLevels';

const _levelMap = new WeakMap();
const _pipeline = new WeakMap();

export default class Logger {
  constructor(levelMap, pipeline) {
    _levelMap.set(this, levelMap);
    _pipeline.set(this, pipeline);
  }

  error(messageTemplate, ...properties) {
    this.write.call(this, logLevels.ERROR, messageTemplate, ...properties);
  }

  warn(messageTemplate, ...properties) {
    this.write.call(this, logLevels.WARN, messageTemplate, ...properties);
  }

  info(messageTemplate, ...properties) {
    this.write.call(this, logLevels.INFO, messageTemplate, ...properties);
  }

  debug(messageTemplate, ...properties) {
    this.write.call(this, logLevels.DEBUG, messageTemplate, ...properties);
  }

  verbose(messageTemplate, ...properties) {
    this.write.call(this, logLevels.VERBOSE, messageTemplate, ...properties);
  }

  write(level, messageTemplate, ...properties) {
    if (!_levelMap.get(this).isEnabled(level)) {
      return;
    }
    const parsedTemplate = new MessageTemplate(messageTemplate);
    const boundProperties = parsedTemplate.bindProperties(properties);

    const event = new LogEvent(new Date(), level, parsedTemplate, boundProperties);
    _pipeline.get(this).emit([event]);
  }

  enrich(properties, destructure) {
    const enrichedPipeline = new Pipeline([
      // Set stuff
    ]);
    return new Logger(_levelMap.get(this), enrichedPipeline);
  }

  flush() {
    return _pipeline.get(this).flush();
  }

  close() {
    return _pipeline.get(this).close();
  }
}
<|endoftext|>


<commit_before>TrelloPowerUp.initialize({
  'card-buttons': function(t, options){
    return [{
      icon: './images/icon-gray.svg',
      text: 'Time track',
      callback: function(t){
        return t.overlay({
          title: 'Time track',
          url: './overlay.html',
          args: { user: '' }
        });
      }
    },
    {
      icon: './images/icon-gray.svg',
      text: 'Estimate Card',
      callback: function(t){
        return t.overlay({
          title: 'Estimate Card',
          url: './estimate.html'
        });
      }
    }];
  },
  'card-badges': function(t, card) {
    return getBadges(t);
  },
  'show-settings': function(t, options){
    return t.popup({
      title: 'Google Form Settings',
      url: './settings.html',
      height: 184
    });
  }
});

// var calculateTrackedHours = function() {
//   // return '3'
//   // var Promise = TrelloPowerUp.Promise;
//   // var t = TrelloPowerUp.iframe();
//   var gEstimationSheetUrl = '';
//   var userEmail = '';

//   t.render(function(){
//     return Promise.all([
//       t.get('board', 'shared', 'estimatetimeurl'),
//       t.get('organization', 'private', 'email')
//     ])
//     .spread(function(savedEstimationSheetUrl, savedUserEmail){
//       if(savedEstimationSheetUrl){
//         gEstimationSheetUrl = savedEstimationSheetUrl;
//       }
//       if(savedUserEmail){
//         userEmail = savedUserEmail;
//       }
//     })

//     console.log('gEstimationSheetUrl: ', gEstimationSheetUrl);
//     console.log('userEmail: ', userEmail);
//     // getValues = "select sum(F) WHERE D = '" + userEmail + "'";
//     // console.log('Results: ', getValues);

//     // console.log('Warning: Please add your personal email on settings');
//     // if (gEstimationSheetUrl && userEmail) {
//     //   getValues = "select sum(F) WHERE D = '" + userEmail + "'";

//     //   console.log('Results: ', getValues);

//     //   $('#switch-hitters').sheetrock({
//     //     url: gEstimationSheetUrl,
//     //     query: getValues,
//     //     callback: function (error, options, response) {
//     //       if (error) { console.log('Error :', message); }
//     //     }
//     //   }).text();
//     // }
//   });
// };

var getBadges = function(t){
  console.log('Compilation: ', 14);

  var gEstimationSheetUrl = '';
  var userEmail = '';
  var timeTracked = '';

  return t.get('board', 'shared', 'estimatetimeurl')
  .then(function(savedEstimationSheetUrl) {
    gEstimationSheetUrl = 'https://docs.google.com/spreadsheets/d/1_1o8qHdUPdgzwZEV5PDx3VDt9IoByaeJDNcOAAIQZ7M/edit#gid=440459845';
    return t.get('organization', 'private', 'email');
  })
  .then(function(userEmail) {
    userEmail = userEmail;

    console.log('gEstimationSheetUrl: ', gEstimationSheetUrl);
    console.log('userEmail: ', userEmail);

    if (gEstimationSheetUrl && userEmail) {
      getValues = "select sum(F) WHERE B = '" + userEmail + "'";

      console.log("Before get data");

      var other = $('body').sheetrock({
        url: gEstimationSheetUrl,
        query: getValues,
        callback: function (error, options, response) {
          if (!error) {
            timeTracked = $(response.html).find('td').text();
            console.log(response.html);
            console.log('timeTracked: ', timeTracked);

            $('a[href="' + '/c/7vnwoTZO/10-trello-analizar-e-implementar-la-forma-de-sincronizar-un-spreadsheet-con-task-en-trello' + '"]').parent('.list-card-details')
            .find('.plugin-color-red .badge-text')
            .text(timeTracked);

          } else {
            console.log('Error :', message);
          }
        }
      }).find('td').text();
    }

    console.log("Other: ", other);
    console.log("Time: ", timeTracked);

    return [
      {
        title: 'Time Tracked',
        text: timeTracked,
        icon: './images/clock-track.svg', // for card front badges only
        color: 'red',
        refresh: 15
      }
    ]

    // if(lowercaseName.indexOf('static') > -1){
    //   // return an array of badge objects
    //   return [{
    //     title: 'Global Estimation', // for detail badges only
    //     text: 'Static',
    //     icon: icon, // for card front badges only
    //     color: badgeColor
    //   }];
    // } else {
    //   return [];
    // }
  })
};
<commit_msg>set timeTracked<commit_after>TrelloPowerUp.initialize({
  'card-buttons': function(t, options){
    return [{
      icon: './images/icon-gray.svg',
      text: 'Time track',
      callback: function(t){
        return t.overlay({
          title: 'Time track',
          url: './overlay.html',
          args: { user: '' }
        });
      }
    },
    {
      icon: './images/icon-gray.svg',
      text: 'Estimate Card',
      callback: function(t){
        return t.overlay({
          title: 'Estimate Card',
          url: './estimate.html'
        });
      }
    }];
  },
  'card-badges': function(t, card) {
    return getBadges(t);
  },
  'show-settings': function(t, options){
    return t.popup({
      title: 'Google Form Settings',
      url: './settings.html',
      height: 184
    });
  }
});

// var calculateTrackedHours = function() {
//   // return '3'
//   // var Promise = TrelloPowerUp.Promise;
//   // var t = TrelloPowerUp.iframe();
//   var gEstimationSheetUrl = '';
//   var userEmail = '';

//   t.render(function(){
//     return Promise.all([
//       t.get('board', 'shared', 'estimatetimeurl'),
//       t.get('organization', 'private', 'email')
//     ])
//     .spread(function(savedEstimationSheetUrl, savedUserEmail){
//       if(savedEstimationSheetUrl){
//         gEstimationSheetUrl = savedEstimationSheetUrl;
//       }
//       if(savedUserEmail){
//         userEmail = savedUserEmail;
//       }
//     })

//     console.log('gEstimationSheetUrl: ', gEstimationSheetUrl);
//     console.log('userEmail: ', userEmail);
//     // getValues = "select sum(F) WHERE D = '" + userEmail + "'";
//     // console.log('Results: ', getValues);

//     // console.log('Warning: Please add your personal email on settings');
//     // if (gEstimationSheetUrl && userEmail) {
//     //   getValues = "select sum(F) WHERE D = '" + userEmail + "'";

//     //   console.log('Results: ', getValues);

//     //   $('#switch-hitters').sheetrock({
//     //     url: gEstimationSheetUrl,
//     //     query: getValues,
//     //     callback: function (error, options, response) {
//     //       if (error) { console.log('Error :', message); }
//     //     }
//     //   }).text();
//     // }
//   });
// };

var getBadges = function(t){
  console.log('Compilation: ', 15);

  var gEstimationSheetUrl = '';
  var userEmail = '';
  var timeTracked = '';

  return t.get('board', 'shared', 'estimatetimeurl')
  .then(function(savedEstimationSheetUrl) {
    gEstimationSheetUrl = 'https://docs.google.com/spreadsheets/d/1_1o8qHdUPdgzwZEV5PDx3VDt9IoByaeJDNcOAAIQZ7M/edit#gid=440459845';
    return t.get('organization', 'private', 'email');
  })
  .then(function(userEmail) {
    userEmail = userEmail;

    console.log('gEstimationSheetUrl: ', gEstimationSheetUrl);
    console.log('userEmail: ', userEmail);

    if (gEstimationSheetUrl && userEmail) {
      getValues = "select sum(F) WHERE B = '" + userEmail + "'";

      console.log("Before get data");

      var other = $('body').sheetrock({
        url: gEstimationSheetUrl,
        query: getValues,
        callback: function (error, options, response) {
          if (!error) {
            timeTracked = $(response.html).find('td').text();
            console.log(response.html);
            console.log('timeTracked: ', timeTracked);

            var badge = $('a[href="' + '/c/7vnwoTZO/10-trello-analizar-e-implementar-la-forma-de-sincronizar-un-spreadsheet-con-task-en-trello' + '"]').parent('.list-card-details')
            .find('.plugin-color-red .badge-text');
            console.log('badge: ', badge);
            badge.text(timeTracked);

          } else {
            console.log('Error :', message);
          }
        }
      }).find('td').text();
    }

    console.log("Other: ", other);
    console.log("Time: ", timeTracked);

    return [
      {
        title: 'Time Tracked',
        text: timeTracked,
        icon: './images/clock-track.svg', // for card front badges only
        color: 'red',
        refresh: 15
      }
    ]

    // if(lowercaseName.indexOf('static') > -1){
    //   // return an array of badge objects
    //   return [{
    //     title: 'Global Estimation', // for detail badges only
    //     text: 'Static',
    //     icon: icon, // for card front badges only
    //     color: badgeColor
    //   }];
    // } else {
    //   return [];
    // }
  })
};
<|endoftext|>


<commit_before>const winston = require('winston');

let logger;

winston.level = process.env.NVIM_NODE_LOG_LEVEL || 'debug';

if (process.env.NVIM_NODE_LOG_FILE) {
  logger = new winston.Logger({
    transports: [
      new winston.transports.File({
        filename: process.env.NVIM_NODE_LOG_FILE,
        level: winston.level,
        json: false,
      }),
    ],
  });
} else {
  if (!process.env.ALLOW_CONSOLE) {
    // Remove Console transport
    winston.remove(winston.transports.Console);
  }
  logger = winston;
}

module.exports = logger;
module.exports.default = module.exports;
<commit_msg>Remove default export from logger for now<commit_after>const winston = require('winston');

let logger;

winston.level = process.env.NVIM_NODE_LOG_LEVEL || 'debug';

if (process.env.NVIM_NODE_LOG_FILE) {
  logger = new winston.Logger({
    transports: [
      new winston.transports.File({
        filename: process.env.NVIM_NODE_LOG_FILE,
        level: winston.level,
        json: false,
      }),
    ],
  });
} else {
  if (!process.env.ALLOW_CONSOLE) {
    // Remove Console transport
    winston.remove(winston.transports.Console);
  }
  logger = winston;
}

module.exports = logger;
// module.exports.default = module.exports;
<|endoftext|>