<commit_before>var X = X || {};

X.Video = (function() {

  'use strict';

  var canvas;

  var background_maps;
  var tile_data;
  var oam;

  var vblank = function() {
  	X.CPU.request_interrupt(0);
  	return true;
  };

  return {

    // LCD control

    get LCDC() { return X.Memory.r(0xFF40); },
  	get display_enable() { return X.Utils.bit(this.LCDC, 7); },
  	get window_tile_map() { return X.Utils.bit(this.LCDC, 6) ? 0x9C00 : 0x9800; },
  	get window_enable() { return X.Utils.bit(this.LCDC, 5); },
  	get bg_window_tile_data() { return X.Utils.bit(this.LCDC, 4) ? 0x8000 : 0x8800; },
  	get bg_tile_map() { return X.Utils.bit(this.LCDC, 3) ? 0x9C00 : 0x9800; },
  	get obj_size() { return X.Utils.bit(this.LCDC, 2) ? 16 : 8; },
  	get obj_enable() { return X.Utils.bit(this.LCDC, 1); },
  	get bg_enable() { return X.Utils.bit(this.LCDC, 0); },

    // STAT

    get STAT() { return X.Memory.r(0xFF41); },
    get line_y_coincidence_interrupt() { return X.Utils.bit(this.STAT, 6); },
    get oam_interrupt() { return X.Utils.bit(this.STAT, 5); },
    get vblank_interrupt() { return X.Utils.bit(this.STAT, 4); },
    get hblank_interrupt() { return X.Utils.bit(this.STAT, 3); },
    get line_y_coincidence() { return X.Utils.bit(this.STAT, 2); }, set line_y_coincidence(x) { X.Memory.w(0xFF41, this.STAT & 0xFB | x) },
    get mode() { return this.STAT & 0x3; }, set mode(x) { X.Memory.w(0xFF41, this.STAT & 0x7C | x); },

    // Position and scrolling

  	get scroll_y() { return X.Memory.r(0xFF42); },
  	get scroll_x() { return X.Memory.r(0xFF43); },
  	get line_y() { return X.Memory.r(0xFF44); }, set line_y(x) { X.Memory.w(0xFF44, x); },
  	get line_y_compare() { return X.Memory.r(0xFF45); },
  	get window_x() { return X.Memory.r(0xFF4A); },
  	get window_y() { return X.Memory.r(0xFF4B); },

    // Palettes

  	get bg_palette() { return X.Memory.r(0xFF47); },
    get obj_palette_0() { return X.Memory.r(0xFF48); },
    get obj_palette_1() { return X.Memory.r(0xFF49); },

    /*colors: [
      [1, 1, 1, 1],
      [0.7, 0.7, 0.7, 1],
      [0.4, 0.4, 0.4, 1],
      [0, 0, 0, 1]
    ],*/
    colors: [
      [0xFF, 0xFF, 0xFF, 0xFF],
      [0xAA, 0xAA, 0xAA, 0xFF],
      [0x50, 0x50, 0x50, 0xFF],
      [0, 0, 0, 0xFF]
    ],

  	/**
  		* Memory mapping
  		*/

		r: function(address) {

			// Tile data
			if (address < 0x9800) {
				return tile_data[address - 0x8000];
			}

			// Background maps
			else if (address < 0xA000) {
				return background_maps[address - 0x9800];
			}

			// OAM
			else {
				return oam[address - 0xFE00];
			}
		},

		w: function(address, value) {

			// Tile data
			if (address < 0x9800) {
				tile_data[address - 0x8000] = value;
				this.update_cached_tile(address - 0x8000);
				return value
			}

			// Background maps
			else if (address < 0xA000) {
				return background_maps[address - 0x9800] = value;
			}

			// OAM
			else {
				return oam[address - 0xFE00] = value;
			}
		},

		dma_transfer: function(value) {

			var starting_address = value * 0x100;

			for (var i = 0; i < 160; ++i) {
				oam[i] = X.Memory.r(starting_address + i);
			}
		},

		/**
			*
			*/

    cached_tiles: new Array(384),

    update_cached_tile: function(index) {

    	var tile_number = Math.floor(index / 16);
    	var memory_row = index - index % 2;
    	var image_row = Math.floor((index % 16) / 2);

    	for (var p = 0; p < 8; ++p) {

    		var a = X.Utils.bit(tile_data[memory_row], p);
        var b = X.Utils.bit(tile_data[memory_row + 1], p);
        var c = a | b << 1;

        this.cached_tiles[tile_number][image_row*8 + (7-p)] = c;
      }

    },

    init: function() {

      X.Renderer.init();

      canvas = document.querySelector('section#game canvas').getContext('2d');

			background_maps = new Array(2048);
		  tile_data = new Array(6144);
		  oam = new Array(160);

		  X.Utils.fill(background_maps);
		  X.Utils.fill(tile_data);
		  X.Utils.fill(oam);

      for (var t = 0, l = this.cached_tiles.length; t < l; ++t) {
      	var pixels = new Array(64);
      	X.Utils.fill(pixels);
      	this.cached_tiles[t] = pixels;
      }
    },

    reset: function() {

      X.Renderer.reset();

		  X.Utils.fill(background_maps);
		  X.Utils.fill(tile_data);
		  X.Utils.fill(oam);

    	this.mode = 2; // Really necessary??
    },

    line_x: 0,

    scan: function(cycles) {

      if (!this.display_enable)
        return;

      // Background
      if (this.bg_enable)
        X.Renderer.scan_background(this.line_y);

      // Window
      if (this.window_enable) {

      }

      // Objects
      if (this.obj_enable) {

      }
    },

    next_frame: function() {

      X.Renderer.draw_frame(canvas);

      this.line_y = 0x90; // XXX really necessary?
    },

    mode_cycles: 2,
    mode_durations: [204, 4560, 80, 172],

    change_mode: function(m) {

      this.mode_cycles -= this.mode_durations[this.mode];
      this.mode = m;
    },

    step: function(cycles) {

      this.mode_cycles += cycles;

      switch (this.mode) {

        case 0: // H-Blank
          if (this.mode_cycles > this.mode_durations[0]) {
          	if (this.line_y >= 144) {
	            this.change_mode(1);
	            this.next_frame();
      				return vblank();
	          }
          	else {
	            this.change_mode(2);
	            ++this.line_y;
              this.line_x = 0;

              // Check line coincidence
              if (this.line_y == this.line_y_compare) {
                //this.line_y_coincidence = true;
              }
	          }
	        }
          break;

        case 1: // V-Blank
          this.line_y = 145 + Math.floor(this.mode_cycles/456);
          if (this.mode_cycles > this.mode_durations[1]) {
            this.change_mode(2);
            this.line_y = 0;
            this.line_x = 0;
          }
          break;

        case 2: // OAM access
          if (this.mode_cycles > this.mode_durations[2]) {
            this.change_mode(3);
          }
          break;

        case 3: // OAM + VRAM access
          if (this.mode_cycles > this.mode_durations[3]) {
            this.scan();
            this.change_mode(0);
          }
          break;
      }
	  }

  };

})();

X.Renderer = (function() {

  'use strict';

  var canvas;
  var buffer;

  // Cached palettes:

  var cached_palettes = {
    bg: [],
    obj_0: [],
    obj_1: []
  };

  return {

    init: function() {

      var canvas_dom = document.createElement('canvas');
      canvas_dom.width = 160;
      canvas_dom.height = 144;
      document.querySelector('section#game').appendChild(canvas_dom);

      canvas = canvas_dom.getContext('2d');

      buffer = canvas.createImageData(canvas_dom.width, canvas_dom.height);

      // Maintain cached palettes for faster access

      var palettes = ['bg', 'obj_0', 'obj_1'];

      _.each(palettes, function(palette, index) {
        X.Memory.watch(0xFF47 + index, function(prop, old_val, new_val) {
          for (var b = 0; b < 4; ++b) {
            var color = X.Video.colors[X.Utils.bit(new_val, b*2) | X.Utils.bit(new_val, b*2 + 1) << 1];
            cached_palettes[palette][b] = [color[0], color[1], color[2], color[3]];
          }
        });
      });
    },

    reset: function() {

    },

    scan_background: function(y) {

      var sy = (y + X.Video.scroll_y) % 256;
      var ty = Math.floor(sy/8);
      var py = sy % 8;

      for (var x = 0; x < 160; ++x) {

        var sx = (x + X.Video.scroll_x) % 256;
        var tx = Math.floor(sx/8);
        var px = sx % 8;

        // Fetch the tile

        var tile_number = X.Memory.r(X.Video.bg_tile_map + ty*32 + tx);
        var tile_index = X.Video.bg_window_tile_data == 0x8000 ? tile_number : 256 + X.Utils.signed(tile_number);

        var tile = X.Video.cached_tiles[tile_index];

        // Fetch the pixel color

        var color = cached_palettes.bg[tile[py*8 + px]];

        // Draw the pixel

        this.scan_pixel(x, y, color);
      }
    },

    scan_obj: function() {

      for (var o = 0; o < 40; ++o) {

        var address = 0xFE00 + o*4;
        var pos_y = X.Memory.r(address);
        var pos_x = X.Memory.r(address + 1);

        // Skip the object if it is off-screen
        if (pos_y == 0 || pos_y >= 160 || pos_x == 0 || pos_x >= 168)
          continue;

        pos_y -= 16;
        pos_x -= 8;

        var tile_number = X.Memory.r(address + 2);
        var tile = X.Video.cached_tiles[tile_number];

        var attributes = X.Memory.r(address + 3);
        var obj_above = X.Utils.bit(attributes, 7);
        var flip_y = X.Utils.bit(attributes, 6);
        var flip_x = X.Utils.bit(attributes, 5);
        var palette = X.Utils.bit(attributes, 4) ? cached_palettes.obj_1 : cached_palettes.obj_0;

        for (var y = 0; y < 8; ++y) {
          for (var x = 0; x < 8; ++x) {

            var color_index = tile[y*8 + x];
            if (color_index == 0)
              continue;

            this.scan_pixel(pos_x + x, pos_y + y, palette[color_index]);
          }
        }
      }
    },

    scan_pixel: function(x, y, color) {

      var index = (y * 160 + x) * 4;
      buffer.data[index] = color[0];
      buffer.data[index + 1] = color[1];
      buffer.data[index + 2] = color[2];
      buffer.data[index + 3] = color[3];
    },

    draw_frame: function(destination_canvas) {

      this.scan_obj(); // TODO sync with scanlining
      canvas.putImageData(buffer, 0, 0);

      //this.draw_background(destination_canvas, true);
      //this.draw_obj(destination_canvas);
    },

    draw_background: function(destination_canvas, scrolling, wrapping) {

      var sx = scrolling ? X.Video.scroll_x : 0;
      var sy = scrolling ? X.Video.scroll_y : 0;

      destination_canvas.drawImage(canvas, sx, sy, 160, 144, 0, 0, 160, 144);
    },

    draw_obj: function(destination_canvas) {

      // TODO
    }

  };

})();
<commit_msg>- handle 8x16 tiles<commit_after>var X = X || {};

X.Video = (function() {

  'use strict';

  var canvas;

  var background_maps;
  var tile_data;
  var oam;

  var vblank = function() {
  	X.CPU.request_interrupt(0);
  	return true;
  };

  return {

    // LCD control

    get LCDC() { return X.Memory.r(0xFF40); },
  	get display_enable() { return X.Utils.bit(this.LCDC, 7); },
  	get window_tile_map() { return X.Utils.bit(this.LCDC, 6) ? 0x9C00 : 0x9800; },
  	get window_enable() { return X.Utils.bit(this.LCDC, 5); },
  	get bg_window_tile_data() { return X.Utils.bit(this.LCDC, 4) ? 0x8000 : 0x8800; },
  	get bg_tile_map() { return X.Utils.bit(this.LCDC, 3) ? 0x9C00 : 0x9800; },
  	get obj_size() { return X.Utils.bit(this.LCDC, 2) ? 16 : 8; },
  	get obj_enable() { return X.Utils.bit(this.LCDC, 1); },
  	get bg_enable() { return X.Utils.bit(this.LCDC, 0); },

    // STAT

    get STAT() { return X.Memory.r(0xFF41); },
    get line_y_coincidence_interrupt() { return X.Utils.bit(this.STAT, 6); },
    get oam_interrupt() { return X.Utils.bit(this.STAT, 5); },
    get vblank_interrupt() { return X.Utils.bit(this.STAT, 4); },
    get hblank_interrupt() { return X.Utils.bit(this.STAT, 3); },
    get line_y_coincidence() { return X.Utils.bit(this.STAT, 2); }, set line_y_coincidence(x) { X.Memory.w(0xFF41, this.STAT & 0xFB | x) },
    get mode() { return this.STAT & 0x3; }, set mode(x) { X.Memory.w(0xFF41, this.STAT & 0x7C | x); },

    // Position and scrolling

  	get scroll_y() { return X.Memory.r(0xFF42); },
  	get scroll_x() { return X.Memory.r(0xFF43); },
  	get line_y() { return X.Memory.r(0xFF44); }, set line_y(x) { X.Memory.w(0xFF44, x); },
  	get line_y_compare() { return X.Memory.r(0xFF45); },
  	get window_x() { return X.Memory.r(0xFF4A); },
  	get window_y() { return X.Memory.r(0xFF4B); },

    // Palettes

  	get bg_palette() { return X.Memory.r(0xFF47); },
    get obj_palette_0() { return X.Memory.r(0xFF48); },
    get obj_palette_1() { return X.Memory.r(0xFF49); },

    /*colors: [
      [1, 1, 1, 1],
      [0.7, 0.7, 0.7, 1],
      [0.4, 0.4, 0.4, 1],
      [0, 0, 0, 1]
    ],*/
    colors: [
      [0xFF, 0xFF, 0xFF, 0xFF],
      [0xAA, 0xAA, 0xAA, 0xFF],
      [0x50, 0x50, 0x50, 0xFF],
      [0, 0, 0, 0xFF]
    ],

  	/**
  		* Memory mapping
  		*/

		r: function(address) {

			// Tile data
			if (address < 0x9800) {
				return tile_data[address - 0x8000];
			}

			// Background maps
			else if (address < 0xA000) {
				return background_maps[address - 0x9800];
			}

			// OAM
			else {
				return oam[address - 0xFE00];
			}
		},

		w: function(address, value) {

			// Tile data
			if (address < 0x9800) {
				tile_data[address - 0x8000] = value;
				this.update_cached_tile(address - 0x8000);
				return value
			}

			// Background maps
			else if (address < 0xA000) {
				return background_maps[address - 0x9800] = value;
			}

			// OAM
			else {
				return oam[address - 0xFE00] = value;
			}
		},

		dma_transfer: function(value) {

			var starting_address = value * 0x100;

			for (var i = 0; i < 160; ++i) {
				oam[i] = X.Memory.r(starting_address + i);
			}
		},

		/**
			*
			*/

    cached_tiles: new Array(384),

    update_cached_tile: function(index) {

    	var tile_number = Math.floor(index / 16);
    	var memory_row = index - index % 2;
    	var image_row = Math.floor((index % 16) / 2);

    	for (var p = 0; p < 8; ++p) {

    		var a = X.Utils.bit(tile_data[memory_row], p);
        var b = X.Utils.bit(tile_data[memory_row + 1], p);
        var c = a | b << 1;

        this.cached_tiles[tile_number][image_row*8 + (7-p)] = c;
      }

    },

    init: function() {

      X.Renderer.init();

      canvas = document.querySelector('section#game canvas').getContext('2d');

			background_maps = new Array(2048);
		  tile_data = new Array(6144);
		  oam = new Array(160);

		  X.Utils.fill(background_maps);
		  X.Utils.fill(tile_data);
		  X.Utils.fill(oam);

      for (var t = 0, l = this.cached_tiles.length; t < l; ++t) {
      	var pixels = new Array(64);
      	X.Utils.fill(pixels);
      	this.cached_tiles[t] = pixels;
      }
    },

    reset: function() {

      X.Renderer.reset();

		  X.Utils.fill(background_maps);
		  X.Utils.fill(tile_data);
		  X.Utils.fill(oam);

    	this.mode = 2; // Really necessary??
    },

    line_x: 0,

    scan: function(cycles) {

      if (!this.display_enable)
        return;

      // Background
      if (this.bg_enable)
        X.Renderer.scan_background(this.line_y);

      // Window
      if (this.window_enable) {

      }

      // Objects
      if (this.obj_enable) {

      }
    },

    next_frame: function() {

      X.Renderer.draw_frame(canvas);

      this.line_y = 0x90; // XXX really necessary?
    },

    mode_cycles: 2,
    mode_durations: [204, 4560, 80, 172],

    change_mode: function(m) {

      this.mode_cycles -= this.mode_durations[this.mode];
      this.mode = m;
    },

    step: function(cycles) {

      this.mode_cycles += cycles;

      switch (this.mode) {

        case 0: // H-Blank
          if (this.mode_cycles > this.mode_durations[0]) {
          	if (this.line_y >= 144) {
	            this.change_mode(1);
	            this.next_frame();
      				return vblank();
	          }
          	else {
	            this.change_mode(2);
	            ++this.line_y;
              this.line_x = 0;

              // Check line coincidence
              if (this.line_y == this.line_y_compare) {
                //this.line_y_coincidence = true;
              }
	          }
	        }
          break;

        case 1: // V-Blank
          this.line_y = 145 + Math.floor(this.mode_cycles/456);
          if (this.mode_cycles > this.mode_durations[1]) {
            this.change_mode(2);
            this.line_y = 0;
            this.line_x = 0;
          }
          break;

        case 2: // OAM access
          if (this.mode_cycles > this.mode_durations[2]) {
            this.change_mode(3);
          }
          break;

        case 3: // OAM + VRAM access
          if (this.mode_cycles > this.mode_durations[3]) {
            this.scan();
            this.change_mode(0);
          }
          break;
      }
	  }

  };

})();

X.Renderer = (function() {

  'use strict';

  var canvas;
  var buffer;

  // Cached palettes:

  var cached_palettes = {
    bg: [],
    obj_0: [],
    obj_1: []
  };

  return {

    init: function() {

      var canvas_dom = document.createElement('canvas');
      canvas_dom.width = 160;
      canvas_dom.height = 144;
      document.querySelector('section#game').appendChild(canvas_dom);

      canvas = canvas_dom.getContext('2d');

      buffer = canvas.createImageData(canvas_dom.width, canvas_dom.height);

      // Maintain cached palettes for faster access

      var palettes = ['bg', 'obj_0', 'obj_1'];

      _.each(palettes, function(palette, index) {
        X.Memory.watch(0xFF47 + index, function(prop, old_val, new_val) {
          for (var b = 0; b < 4; ++b) {
            var color = X.Video.colors[X.Utils.bit(new_val, b*2) | X.Utils.bit(new_val, b*2 + 1) << 1];
            cached_palettes[palette][b] = [color[0], color[1], color[2], color[3]];
          }
        });
      });
    },

    reset: function() {

    },

    scan_background: function(y) {

      var sy = (y + X.Video.scroll_y) % 256;
      var ty = Math.floor(sy/8);
      var py = sy % 8;

      for (var x = 0; x < 160; ++x) {

        var sx = (x + X.Video.scroll_x) % 256;
        var tx = Math.floor(sx/8);
        var px = sx % 8;

        // Fetch the tile

        var tile_number = X.Memory.r(X.Video.bg_tile_map + ty*32 + tx);
        var tile_index = X.Video.bg_window_tile_data == 0x8000 ? tile_number : 256 + X.Utils.signed(tile_number);

        var tile = X.Video.cached_tiles[tile_index];

        // Fetch the pixel color

        var color = cached_palettes.bg[tile[py*8 + px]];

        // Draw the pixel

        this.scan_pixel(x, y, color);
      }
    },

    scan_obj: function() {

      for (var o = 0; o < 40; ++o) {

        var address = 0xFE00 + o*4;
        var pos_y = X.Memory.r(address);
        var pos_x = X.Memory.r(address + 1);

        // Skip the object if it is off-screen
        if (pos_y == 0 || pos_y >= 160 || pos_x == 0 || pos_x >= 168)
          continue;

        pos_y -= 16;
        pos_x -= 8;

        var tile_number = X.Memory.r(address + 2);
        var attributes = X.Memory.r(address + 3);
        var obj_above = X.Utils.bit(attributes, 7);
        var flip_y = X.Utils.bit(attributes, 6);
        var flip_x = X.Utils.bit(attributes, 5);
        var palette = X.Utils.bit(attributes, 4) ? cached_palettes.obj_1 : cached_palettes.obj_0;

        var tile_size = X.Video.obj_size == 8 ? 1 : 2;

        for (var h = 0; h < tile_size; ++h) {

          var tile = X.Video.cached_tiles[tile_number + h];

          for (var y = 0; y < 8; ++y) {

            var py = pos_y + y + h*8;

            for (var x = 0; x < 8; ++x) {

              var px = pos_x + x;

              if (px >= 160 || py >= 144)
                continue;

              var color_index = tile[y*8 + x];
              if (color_index == 0)
                continue;

              this.scan_pixel(px, py, palette[color_index]);
            }
          }
        }
      }
    },

    scan_pixel: function(x, y, color) {

      var index = (y * 160 + x) * 4;
      buffer.data[index] = color[0];
      buffer.data[index + 1] = color[1];
      buffer.data[index + 2] = color[2];
      buffer.data[index + 3] = color[3];
    },

    draw_frame: function(destination_canvas) {

      this.scan_obj(); // TODO sync with scanlining
      canvas.putImageData(buffer, 0, 0);

      //this.draw_background(destination_canvas, true);
      //this.draw_obj(destination_canvas);
    },

    draw_background: function(destination_canvas, scrolling, wrapping) {

      var sx = scrolling ? X.Video.scroll_x : 0;
      var sy = scrolling ? X.Video.scroll_y : 0;

      destination_canvas.drawImage(canvas, sx, sy, 160, 144, 0, 0, 160, 144);
    },

    draw_obj: function(destination_canvas) {

      // TODO
    }

  };

})();
<|endoftext|>


<commit_before>function initPage(config){
    //set the title
    $(document).attr('title', config.title);

    var contents = [];
    for (var d in config.div){
	//insert the divs
	$("#maincontent").prepend("

");

	var div = $("#"+d);
	//set CSS
	div.css(config.div[d]);

	if(div.height() <  1){
	    contents.push(div);
	}
    }

    var s = document.styleSheets[document.styleSheets.length-1];
    config.css.forEach(function(d){
	s.insertRule(d,s.cssRules.length);
    });
    debugger;

    $(window).on("resize load orientationchange", function(){
	contents.forEach(function(div){
	    //this will not work for multi maps
	    div.height($("#nc-container").height());
	    div.width($("#nc-container").width());
	});
    });

    $(window).resize(); //force resize on the first call
}

function initNanocube(config){
    var nc = new Nanocube({
	url:config.url,
	ready: function(nc){
	    //set options (colormap etc)
	    var options = {
		nanocube:nc,
		config: config,
		tilesurl:config.tilesurl,
		heatmapmaxlevel:config.heatmapmaxlevel
	    };

	    //create the model
	    var model = new Model(options);

	    //set the initial view
	    for(var sp in config.latlonbox.min){
		model.spatial_vars[sp]
		    .map.fitBounds([config.latlonbox.min[sp],
				    config.latlonbox.max[sp]]);
	    }
	}
    });
};
<commit_msg>fixed optional css reading<commit_after>function initPage(config){
    //set the title
    $(document).attr('title', config.title);

    var contents = [];
    for (var d in config.div){
	//insert the divs
	$("#maincontent").prepend("

");

	var div = $("#"+d);
	//set CSS
	div.css(config.div[d]);

	if(div.height() <  1){
	    contents.push(div);
	}
    }

    if ('css' in config){
	var s = document.styleSheets[document.styleSheets.length-1];
	config.css.forEach(function(d){
	    s.insertRule(d,s.cssRules.length);
	});
    }

    $(window).on("resize load orientationchange", function(){
	contents.forEach(function(div){
	    //this will not work for multi maps
	    div.height($("#nc-container").height());
	    div.width($("#nc-container").width());
	});
    });

    $(window).resize(); //force resize on the first call
}

function initNanocube(config){
    var nc = new Nanocube({
	url:config.url,
	ready: function(nc){
	    //set options (colormap etc)
	    var options = {
		nanocube:nc,
		config: config,
		tilesurl:config.tilesurl,
		heatmapmaxlevel:config.heatmapmaxlevel
	    };

	    //create the model
	    var model = new Model(options);

	    //set the initial view
	    for(var sp in config.latlonbox.min){
		model.spatial_vars[sp]
		    .map.fitBounds([config.latlonbox.min[sp],
				    config.latlonbox.max[sp]]);
	    }
	}
    });
};
<|endoftext|>


<commit_before>Package.describe({
  name: 'storyteller:accounts-server',
  version: '0.2.0',
  summary: 'Server side package for storyteller:accounts-react-materialize for username and e-mail operations.',
  git: 'https://github.com/StorytellerCZ/meteor-accounts-server',
  documentation: 'README.md'
});

Package.onUse(function(api) {
  api.versionsFrom('1.2.1');
  api.use(['meteor', 'ecmascript', 'accounts-password', 'check']);
  api.use(['aldeed:simple-schema@1.5.3', 'matb33:collection-hooks@0.8.4', 'alanning:roles@1.2.15'])
  api.imply(['accounts-password', 'check', 'aldeed:simple-schema', 'matb33:collection-hooks', 'alanning:roles'])
  api.mainModule('accounts-server.js', 'server');
});

Package.onTest(function(api) {
  api.use('ecmascript');
  api.use('tinytest');
  api.use('storyteller:accounts-server');
  api.mainModule('accounts-server-tests.js');
});
<commit_msg>Update summary<commit_after>Package.describe({
  name: 'storyteller:accounts-server',
  version: '0.2.0',
  summary: 'Server side for methods and subscriptions for username and e-mail operations.',
  git: 'https://github.com/StorytellerCZ/meteor-accounts-server',
  documentation: 'README.md'
});

Package.onUse(function(api) {
  api.versionsFrom('1.2.1');
  api.use(['meteor', 'ecmascript', 'accounts-password', 'check']);
  api.use(['aldeed:simple-schema@1.5.3', 'matb33:collection-hooks@0.8.4', 'alanning:roles@1.2.15'])
  api.imply(['accounts-password', 'check', 'aldeed:simple-schema', 'matb33:collection-hooks', 'alanning:roles'])
  api.mainModule('accounts-server.js', 'server');
});

Package.onTest(function(api) {
  api.use('ecmascript');
  api.use('tinytest');
  api.use('storyteller:accounts-server');
  api.mainModule('accounts-server-tests.js');
});
<|endoftext|>


<commit_before>
// limbus-buildgen - A "build anywhere" C/C++ makefile/project generator.
// Written in 2014 by Jesper Oskarsson jesosk@gmail.com
//
// To the extent possible under law, the author(s) have dedicated all copyright
// and related and neighboring rights to this software to the public domain worldwide.
// This software is distributed without any warranty.
//
// You should have received a copy of the CC0 Public Domain Dedication along with this software.
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

var should = require('should');
var util = require('./util.js');
var shell = require('./shell.js');

describe('Linking', function () {
    beforeEach(function () {
        return util.beforeEach().then(function () {
            return shell.mkdir('temp/include');
        }).then(function () {
            return shell.copyFiles([
                'linked.c',
                'linked_dynamic.c',
                'source/mylibrary.c',
                'include/mylibrary.h',
                'source/mydynamiclibrary.c',
                'include/mydynamiclibrary.h',
                'math.c',
            ], 'features/linking/', 'temp/');
        });
    });

    afterEach(function () {
        return util.afterEach();
    });

    it('should compile and link correctly given several source files and includes', function () {
        return util.generateCompileAndRun({
            config: {
                type: 'application',
                host: process.platform,
                files: [
                    'linked.c',
                    'source/mylibrary.c'
                ],
                includePaths: [
                    'include'
                ],
                outputName: 'linked'
            },
            command: 'linked',
            expectOutputToMatch: /42/
        });
    });

    it('should pass linker flags as is', function () {
        return util.buildSimple({
            type: 'application',
            host: process.platform,
            files: ['simple.c'],
            outputName: 'app',
            linkerFlags: process.platform === 'win32' ? '/invalid-flag' : '--invalid-flag'
        }).should.be.rejected();
    });

    it('should link with libm by default', function () {
        return util.generateCompileAndRun({
            config: {
                type: 'application',
                host: process.platform,
                files: [
                    'math.c'
                ],
                outputName: 'math'
            },
            command: 'math',
            expectOutputToMatch: /42/
        });
    });

    it('should compile to an executable with outputName', function () {
        return util.generateCompileAndRun({
            config: {
                type: 'application',
                host: process.platform,
                files: [
                    'simple.c'
                ],
                outputName: 'my_executable'
            },
            command: 'my_executable',
            expectOutputToMatch: /42/
        });
    });

    it('should compile a static library and then be able to link to it', function () {
        return util.generateCompileAndRun({
            config: [
                {
                    type: 'static-library',
                    host: process.platform,
                    files: [
                        'source/mylibrary.c'
                    ],
                    outputName: 'my_lib_name'
                },
                {
                    type: 'application',
                    host: process.platform,
                    files: [
                        'linked.c'
                    ],
                    libraries: [
                        'my_lib_name'
                    ],
                    includePaths: [
                        'include'
                    ],
                    outputName: 'linked_with_library'
                }
            ],
            command: 'linked_with_library',
            expectOutputToMatch: /42/
        });
    });

    it('should compile a dynamic library and then be able to link to it', function () {
        return util.generateCompileAndRun({
            config: [
                {
                    type: 'static-library',
                    host: process.platform,
                    files: [
                        'source/mylibrary.c'
                    ],
                    outputName: 'my_lib_name'
                },
                {
                    type: 'dynamic-library',
                    host: process.platform,
                    files: [
                        'source/mydynamiclibrary.c'
                    ],
                    libraries: [
                        'my_lib_name'
                    ],
                    outputName: 'my_dyn_lib_name'
                },
                {
                    type: 'application',
                    host: process.platform,
                    files: [
                        'linked_dynamic.c'
                    ],
                    libraries: [
                        'my_dyn_lib_name'
                    ],
                    includePaths: [
                        'include'
                    ],
                    // On linux systems the shared object won't be looked for in
                    // the current working directory by default. We just add a
                    // flag so that it is.
                    linkerFlags: (process.platform === 'linux') ? '-Wl,-rpath=.' : '',
                    outputName: 'linked_with_library'
                }
            ],
            command: 'linked_with_library',
            expectOutputToMatch: /42/
        });
    });
});
<commit_msg>Update linking.feature.js<commit_after>
// limbus-buildgen - A "build anywhere" C/C++ makefile/project generator.
// Written in 2014 by Jesper Oskarsson jesosk@gmail.com
//
// To the extent possible under law, the author(s) have dedicated all copyright
// and related and neighboring rights to this software to the public domain worldwide.
// This software is distributed without any warranty.
//
// You should have received a copy of the CC0 Public Domain Dedication along with this software.
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

var should = require('should');
var util = require('./util.js');
var shell = require('./shell.js');

describe('Linking', function () {
    beforeEach(function () {
        return util.beforeEach().then(function () {
            return shell.mkdir('temp/include');
        }).then(function () {
            return shell.copyFiles([
                'linked.c',
                'linked_dynamic.c',
                'source/mylibrary.c',
                'include/mylibrary.h',
                'source/mydynamiclibrary.c',
                'include/mydynamiclibrary.h',
                'math.c',
            ], 'features/linking/', 'temp/');
        });
    });

    afterEach(function () {
        return util.afterEach();
    });

    it('should compile and link correctly given several source files and includes', function () {
        return util.generateCompileAndRun({
            config: {
                type: 'application',
                host: process.platform,
                files: [
                    'linked.c',
                    'source/mylibrary.c'
                ],
                includePaths: [
                    'include'
                ],
                outputName: 'linked'
            },
            command: 'linked',
            expectOutputToMatch: /42/
        });
    });

    it('should pass linker flags as is', function () {
        return util.buildSimple({
            type: 'application',
            host: process.platform,
            files: ['simple.c'],
            outputName: 'app',
            linkerFlags: process.platform === 'win32' ? '/KEYFILE' : '-nostdlib'
        }).should.be.rejected();
    });

    it('should link with libm by default', function () {
        return util.generateCompileAndRun({
            config: {
                type: 'application',
                host: process.platform,
                files: [
                    'math.c'
                ],
                outputName: 'math'
            },
            command: 'math',
            expectOutputToMatch: /42/
        });
    });

    it('should compile to an executable with outputName', function () {
        return util.generateCompileAndRun({
            config: {
                type: 'application',
                host: process.platform,
                files: [
                    'simple.c'
                ],
                outputName: 'my_executable'
            },
            command: 'my_executable',
            expectOutputToMatch: /42/
        });
    });

    it('should compile a static library and then be able to link to it', function () {
        return util.generateCompileAndRun({
            config: [
                {
                    type: 'static-library',
                    host: process.platform,
                    files: [
                        'source/mylibrary.c'
                    ],
                    outputName: 'my_lib_name'
                },
                {
                    type: 'application',
                    host: process.platform,
                    files: [
                        'linked.c'
                    ],
                    libraries: [
                        'my_lib_name'
                    ],
                    includePaths: [
                        'include'
                    ],
                    outputName: 'linked_with_library'
                }
            ],
            command: 'linked_with_library',
            expectOutputToMatch: /42/
        });
    });

    it('should compile a dynamic library and then be able to link to it', function () {
        return util.generateCompileAndRun({
            config: [
                {
                    type: 'static-library',
                    host: process.platform,
                    files: [
                        'source/mylibrary.c'
                    ],
                    outputName: 'my_lib_name'
                },
                {
                    type: 'dynamic-library',
                    host: process.platform,
                    files: [
                        'source/mydynamiclibrary.c'
                    ],
                    libraries: [
                        'my_lib_name'
                    ],
                    outputName: 'my_dyn_lib_name'
                },
                {
                    type: 'application',
                    host: process.platform,
                    files: [
                        'linked_dynamic.c'
                    ],
                    libraries: [
                        'my_dyn_lib_name'
                    ],
                    includePaths: [
                        'include'
                    ],
                    // On linux systems the shared object won't be looked for in
                    // the current working directory by default. We just add a
                    // flag so that it is.
                    linkerFlags: (process.platform === 'linux') ? '-Wl,-rpath=.' : '',
                    outputName: 'linked_with_library'
                }
            ],
            command: 'linked_with_library',
            expectOutputToMatch: /42/
        });
    });
});
<|endoftext|>


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

    var ScrollGallery = function (options) {
        var defaults = {
            PageSize: 3,
            PageIndex: 0,
            Prefix: "sg", /* TODO: Actually use the prefix */
            MaintainScrollPosition: false,
            Easing: "",
            Speed: 1000,
            Selectors: {
                Gallery: null,
                Next: null,
                Previous: null,
                Indicators: null,
                PageTotal: null,
                PageCurrent: null
            },
            IndicatorOptions: {
                Rounded: true,
                ShowPageNumber: false,
                ClickToJump: true,
                IncreaseTouchSurface: true
            }
        };

        var statics = {
            Classes: {
                Gallery: "scroll-gallery",
                GalleryElement: "scroll-gallery-element",
                WideTouchable: "widen"
            },
            Attributes: {
                Rounded: "data-rounded",
                PageNumber: "data-page-number",
                Rank: "data-rank"
            },
            ItemCount: 0
        };

        var config = $.extend(defaults, options, statics);

        function enhanceElements() {
            $(config.Selectors.Gallery).addClass(config.Classes.Gallery);

            var $elements = $(config.Selectors.Gallery).find("> *");
            $elements.each(function (i, element) {
                $(element).attr(config.Attributes.Rank, i);
                $(element).addClass(config.Classes.GalleryElement);
            });
        }

        function createPageIndicators() {
            var $container = $(config.Selectors.Indicators);

            if (config.IndicatorOptions.IncreaseTouchSurface) {
                $container.addClass(config.Classes.WideTouchable);
            }

            var $ul = $("

");

            if (config.IndicatorOptions.Rounded) {
                $ul.attr(config.Attributes.Rounded, "true");
            }

            for (var i = 0; i < getTotalPages() ; i++) {
                var $li = $("

");
                $li.attr(config.Attributes.PageNumber, i + 1);

                var $button = $("<button />");
                $button.val(config.IndicatorOptions.ShowPageNumber ? (i + 1) : "");
                $li.append($button);

                $ul.append($li);
            }

            $container.append($ul);

            $(config.Selectors.Indicators).find("[" + config.Attributes.PageNumber + "]").on("click", function () {
                $(config.Selectors.Gallery).trigger("page-changed", {
                    PageIndex: parseInt($(this).attr(config.Attributes.PageNumber)) - 1
                });
            });
        }

        function updatePageButtons() {
            $(config.Selectors.Next).prop("disabled", !hasNextPage());
            $(config.Selectors.Previous).prop("disabled", !hasPreviousPage());
        }

        function updatePageIndicators() {
            $(config.Selectors.Indicators).find("[" + config.Attributes.PageNumber + "]").removeAttr("current-page");
            $(config.Selectors.Indicators).find("[" + config.Attributes.PageNumber + "=" + (config.PageIndex + 1) + "]").attr("current-page", '');
        }

        function updatePageDisplay() {
            $(config.Selectors.PageCurrent).text(config.PageIndex + 1);
            $(config.Selectors.PageTotal).text(getTotalPages());
        }

        function updateItemCount() {
            config.ItemCount = $(config.Selectors.Gallery).find("[" + config.Attributes.Rank + "]").length;
        }

        function hasNextPage() {
            return (config.PageIndex + 1) * config.PageSize < config.ItemCount;
        }

        function hasPreviousPage() {
            return config.PageIndex > 0;
        }

        function getScrollPosition() {
            var $scrollElement = $(config.Selectors.Gallery).find("[" + config.Attributes.Rank + "='" + [config.PageIndex * config.PageSize] + "']");

            var layout = ($scrollElement.outerWidth(true) - $scrollElement.innerWidth()) / 2;

            var pageAdjustment = config.PageIndex > 0 ? layout : 0;

            var $parent = $scrollElement.parent();

            return ($scrollElement.position().left - layout) + $parent.scrollLeft() + pageAdjustment - $parent.offset().left;
        }

        function scrollTo() {
            $(config.Selectors.Gallery).stop().animate({ scrollLeft: getScrollPosition() }, config.Speed, config.Easing);
        }

        function getTotalPages() {
            return Math.ceil(config.ItemCount / config.PageSize);
        }

        function onPageChanged(event, data) {
            config.PageIndex = data.PageIndex;
            scrollTo();
            updatePageButtons();
            updatePageIndicators();
            updatePageDisplay();
        }

        function onNextPage() {
            if (hasNextPage()) {
                $(config.Selectors.Gallery).trigger("page-changed", {
                    PageIndex: config.PageIndex + 1
                });
            }
        }

        function onPreviousPage() {
            if (hasPreviousPage()) {
                $(options.Selectors.Gallery).trigger("page-changed", {
                    PageIndex: options.PageIndex - 1
                });
            }
        }

        function validate() {
            if (!$(config.Selectors.Gallery).length) {
                throw "Missing Selector: Gallery";
            }

            if (!$(config.Selectors.Indicators).length && (!$(config.Selectors.Previous) || !$(config.Selectors.Next))) {
                throw "Missing Selector: Indicators or Previous/Next";
            }
        }

        function initialize() {
            validate();

            $(config.Selectors.Gallery).on("page-changed", onPageChanged);
            $(config.Selectors.Next).on("click", onNextPage);
            $(config.Selectors.Previous).on("click", onPreviousPage);

            enhanceElements();
            updateItemCount();

            if (!config.MaintainScrollPosition) {
                $(document).ready(function () {
                    $(config.Selectors.Gallery).scrollLeft(0);
                });
            } else {
                $(document).ready(function () {
                    $(config.Selectors.Gallery).scrollLeft(getScrollPosition());
                });
            }
            updatePageButtons();
            if ($(config.Selectors.Indicators).length) {
                createPageIndicators();
                updatePageIndicators();
            }
            updatePageDisplay();
        }

        initialize();
    };

    window.ScrollGallery = window.ScrollGallery || ScrollGallery;
})();<commit_msg>Scope defaults and statics out of the ScrollGallery<commit_after>(function () {
    "use strict";

    var defaults = {
        PageSize: 3,
        PageIndex: 0,
        Prefix: "sg", /* TODO: Actually use the prefix */
        MaintainScrollPosition: false,
        Easing: "",
        Speed: 1000,
        Selectors: {
            Gallery: null,
            Next: null,
            Previous: null,
            Indicators: null,
            PageTotal: null,
            PageCurrent: null
        },
        IndicatorOptions: {
            Rounded: true,
            ShowPageNumber: false,
            ClickToJump: true,
            IncreaseTouchSurface: true
        }
    };

    var statics = {
        Classes: {
            Gallery: "scroll-gallery",
            GalleryElement: "scroll-gallery-element",
            WideTouchable: "widen"
        },
        Attributes: {
            Rounded: "data-rounded",
            PageNumber: "data-page-number",
            Rank: "data-rank"
        },
        ItemCount: 0
    };

    var ScrollGallery = function (options) {

        var config = $.extend(defaults, options, statics);

        function enhanceElements() {
            $(config.Selectors.Gallery).addClass(config.Classes.Gallery);

            var $elements = $(config.Selectors.Gallery).find("> *");
            $elements.each(function (i, element) {
                $(element).attr(config.Attributes.Rank, i);
                $(element).addClass(config.Classes.GalleryElement);
            });
        }

        function createPageIndicators() {
            var $container = $(config.Selectors.Indicators);

            if (config.IndicatorOptions.IncreaseTouchSurface) {
                $container.addClass(config.Classes.WideTouchable);
            }

            var $ul = $("

");

            if (config.IndicatorOptions.Rounded) {
                $ul.attr(config.Attributes.Rounded, "true");
            }

            for (var i = 0; i < getTotalPages() ; i++) {
                var $li = $("

");
                $li.attr(config.Attributes.PageNumber, i + 1);

                var $button = $("<button />");
                $button.val(config.IndicatorOptions.ShowPageNumber ? (i + 1) : "");
                $li.append($button);

                $ul.append($li);
            }

            $container.append($ul);

            $(config.Selectors.Indicators).find("[" + config.Attributes.PageNumber + "]").on("click", function () {
                $(config.Selectors.Gallery).trigger("page-changed", {
                    PageIndex: parseInt($(this).attr(config.Attributes.PageNumber)) - 1
                });
            });
        }

        function updatePageButtons() {
            $(config.Selectors.Next).prop("disabled", !hasNextPage());
            $(config.Selectors.Previous).prop("disabled", !hasPreviousPage());
        }

        function updatePageIndicators() {
            $(config.Selectors.Indicators).find("[" + config.Attributes.PageNumber + "]").removeAttr("current-page");
            $(config.Selectors.Indicators).find("[" + config.Attributes.PageNumber + "=" + (config.PageIndex + 1) + "]").attr("current-page", '');
        }

        function updatePageDisplay() {
            $(config.Selectors.PageCurrent).text(config.PageIndex + 1);
            $(config.Selectors.PageTotal).text(getTotalPages());
        }

        function updateItemCount() {
            config.ItemCount = $(config.Selectors.Gallery).find("[" + config.Attributes.Rank + "]").length;
        }

        function hasNextPage() {
            return (config.PageIndex + 1) * config.PageSize < config.ItemCount;
        }

        function hasPreviousPage() {
            return config.PageIndex > 0;
        }

        function getScrollPosition() {
            var $scrollElement = $(config.Selectors.Gallery).find("[" + config.Attributes.Rank + "='" + [config.PageIndex * config.PageSize] + "']");

            var layout = ($scrollElement.outerWidth(true) - $scrollElement.innerWidth()) / 2;

            var pageAdjustment = config.PageIndex > 0 ? layout : 0;

            var $parent = $scrollElement.parent();

            return ($scrollElement.position().left - layout) + $parent.scrollLeft() + pageAdjustment - $parent.offset().left;
        }

        function scrollTo() {
            $(config.Selectors.Gallery).stop().animate({ scrollLeft: getScrollPosition() }, config.Speed, config.Easing);
        }

        function getTotalPages() {
            return Math.ceil(config.ItemCount / config.PageSize);
        }

        function onPageChanged(event, data) {
            config.PageIndex = data.PageIndex;
            scrollTo();
            updatePageButtons();
            updatePageIndicators();
            updatePageDisplay();
        }

        function onNextPage() {
            if (hasNextPage()) {
                $(config.Selectors.Gallery).trigger("page-changed", {
                    PageIndex: config.PageIndex + 1
                });
            }
        }

        function onPreviousPage() {
            if (hasPreviousPage()) {
                $(options.Selectors.Gallery).trigger("page-changed", {
                    PageIndex: options.PageIndex - 1
                });
            }
        }

        function validate() {
            if (!$(config.Selectors.Gallery).length) {
                throw "Missing Selector: Gallery";
            }

            if (!$(config.Selectors.Indicators).length && (!$(config.Selectors.Previous) || !$(config.Selectors.Next))) {
                throw "Missing Selector: Indicators or Previous/Next";
            }
        }

        function initialize() {
            validate();

            $(config.Selectors.Gallery).on("page-changed", onPageChanged);
            $(config.Selectors.Next).on("click", onNextPage);
            $(config.Selectors.Previous).on("click", onPreviousPage);

            enhanceElements();
            updateItemCount();

            if (!config.MaintainScrollPosition) {
                $(document).ready(function () {
                    $(config.Selectors.Gallery).scrollLeft(0);
                });
            } else {
                $(document).ready(function () {
                    $(config.Selectors.Gallery).scrollLeft(getScrollPosition());
                });
            }
            updatePageButtons();
            if ($(config.Selectors.Indicators).length) {
                createPageIndicators();
                updatePageIndicators();
            }
            updatePageDisplay();
        }

        initialize();
    };

    window.ScrollGallery = window.ScrollGallery || ScrollGallery;
})();<|endoftext|>


<commit_before>var fs = Npm.require('fs');
var path = Npm.require('path');

Package.describe({
  "summary": "Render your app before the DDP connection even comes alive - magic?",
  "version": "2.16.1",
  "git": "https://github.com/abecks/fast-render",
  "name": "staringatlights:fast-render"
});

Npm.depends({
  "connect": "2.13.0"
});

Package.onUse(function(api) {
  configure(api);
  api.export('FastRender', ['client', 'server']);
  api.export('__init_fast_render', ['client']);
});

Package.onTest(function(api) {
  configure(api);
  api.use('tinytest', ['client', 'server']);
  api.use('http', 'server');
  api.use('random', ['server', 'client']);
  api.use('mongo', ['server', 'client']);

  api.addFiles([
    'tests/utils.js'
  ], ['client', 'server']);

  api.addFiles([
    'tests/client/fast_render.js',
    'tests/client/ddp_update.js'
  ], 'client');

  api.addFiles([
    'tests/server/context.js',
    'tests/server/integration.js'
  ], 'server');
});

function configure (api) {
  api.versionsFrom('METEOR@0.9.3');
  api.use('staringatlights:inject-data@2.0.1', ['client', 'server']);
  api.use('iron:router@0.9.0 || 1.0.0', ['client', 'server'], {weak: true});
  api.use('chuangbo:cookie@1.1.0', 'client');
  api.use('meteorhacks:picker@1.0.3', 'server');
  api.use('meteorhacks:meteorx@1.4.1', 'server');

  api.use(['minimongo', 'livedata', 'ejson', 'underscore', 'webapp', 'routepolicy', 'accounts-base', 'random'], ['server']);
  api.use(['minimongo', 'underscore', 'deps', 'ejson', 'accounts-base'], ['client']);

  api.addFiles([
    'lib/utils.js'
  ], ['client', 'server']);

  api.addFiles([
    'lib/server/namespace.js',
    'lib/server/utils.js',
    'lib/server/routes.js',
    'lib/server/publish_context.js',
    'lib/server/context.js',
    'lib/server/iron_router_support.js',
  ], 'server');

  api.addFiles([
    'lib/client/id_tools.js',
    'lib/client/fast_render.js',
    'lib/client/debugger.js',
    'lib/client/ddp_update.js',
    'lib/client/auth.js',
    'lib/client/boot.js'
  ], 'client');

}
<commit_msg>Update repo url<commit_after>var fs = Npm.require('fs');
var path = Npm.require('path');

Package.describe({
  "summary": "Render your app before the DDP connection even comes alive - magic?",
  "version": "2.16.2",
  "git": "https://github.com/abecks/meteor-fast-render",
  "name": "staringatlights:fast-render"
});

Npm.depends({
  "connect": "2.13.0"
});

Package.onUse(function(api) {
  configure(api);
  api.export('FastRender', ['client', 'server']);
  api.export('__init_fast_render', ['client']);
});

Package.onTest(function(api) {
  configure(api);
  api.use('tinytest', ['client', 'server']);
  api.use('http', 'server');
  api.use('random', ['server', 'client']);
  api.use('mongo', ['server', 'client']);

  api.addFiles([
    'tests/utils.js'
  ], ['client', 'server']);

  api.addFiles([
    'tests/client/fast_render.js',
    'tests/client/ddp_update.js'
  ], 'client');

  api.addFiles([
    'tests/server/context.js',
    'tests/server/integration.js'
  ], 'server');
});

function configure (api) {
  api.versionsFrom('METEOR@0.9.3');
  api.use('staringatlights:inject-data@2.0.1', ['client', 'server']);
  api.use('iron:router@0.9.0 || 1.0.0', ['client', 'server'], {weak: true});
  api.use('chuangbo:cookie@1.1.0', 'client');
  api.use('meteorhacks:picker@1.0.3', 'server');
  api.use('meteorhacks:meteorx@1.4.1', 'server');

  api.use(['minimongo', 'livedata', 'ejson', 'underscore', 'webapp', 'routepolicy', 'accounts-base', 'random'], ['server']);
  api.use(['minimongo', 'underscore', 'deps', 'ejson', 'accounts-base'], ['client']);

  api.addFiles([
    'lib/utils.js'
  ], ['client', 'server']);

  api.addFiles([
    'lib/server/namespace.js',
    'lib/server/utils.js',
    'lib/server/routes.js',
    'lib/server/publish_context.js',
    'lib/server/context.js',
    'lib/server/iron_router_support.js',
  ], 'server');

  api.addFiles([
    'lib/client/id_tools.js',
    'lib/client/fast_render.js',
    'lib/client/debugger.js',
    'lib/client/ddp_update.js',
    'lib/client/auth.js',
    'lib/client/boot.js'
  ], 'client');

}
<|endoftext|>


<commit_before>/* globals game */

game.staticEntity = me.ObjectEntity.extend({

    /* -----

    constructor

    ------ */

    init: function(x, y, settings) {
        // call the constructor
        this.parent(x, y, settings);
        // set the default horizontal & vertical speed (accel vector)
        this.setVelocity(3, 3);

        // set the display to follow our position on both axis
        me.game.viewport.follow(this.pos, me.game.viewport.AXIS.BOTH);

        this.gravity = 0;

        this.update();

    },

    /* -----

    update the player pos

    ------ */
    update: function(dt) {
        var dir = Math.floor(Math.random() * 4);
        if(dir === 0) {
            this.vel.x = 0;
            this.vel.y = 0;
            this.vel.x -= Math.floor(Math.random() * 4);
        } else if(dir === 1) {
            this.vel.x = 0;
            this.vel.y = 0;
            this.vel.x += Math.floor(Math.random() * 4);
        } else if(dir === 2) {
            this.vel.x = 0;
            this.vel.y = 0;
            this.vel.y -= Math.floor(Math.random() * 4);
        } else {
            this.vel.x = 0;
            this.vel.y = 0;
            this.vel.y += Math.floor(Math.random() * 4);
        }

        this.updateMovement();

        return true;
    },
    /* ---

       callback when everything is loaded

       ---  */

    loaded: function (){

    }
});<commit_msg>removed follow for shakie<commit_after>/* globals game */

game.staticEntity = me.ObjectEntity.extend({

    /* -----

    constructor

    ------ */

    init: function(x, y, settings) {
        // call the constructor
        this.parent(x, y, settings);
        // set the default horizontal & vertical speed (accel vector)
        this.setVelocity(3, 3);

        this.gravity = 0;

        this.update();

    },

    /* -----

    update the player pos

    ------ */
    update: function(dt) {
        var dir = Math.floor(Math.random() * 4);
        if(dir === 0) {
            this.vel.x = 0;
            this.vel.y = 0;
            this.vel.x -= Math.floor(Math.random() * 4);
        } else if(dir === 1) {
            this.vel.x = 0;
            this.vel.y = 0;
            this.vel.x += Math.floor(Math.random() * 4);
        } else if(dir === 2) {
            this.vel.x = 0;
            this.vel.y = 0;
            this.vel.y -= Math.floor(Math.random() * 4);
        } else {
            this.vel.x = 0;
            this.vel.y = 0;
            this.vel.y += Math.floor(Math.random() * 4);
        }

        this.updateMovement();

        return true;
    },
    /* ---

       callback when everything is loaded

       ---  */

    loaded: function (){

    }
});<|endoftext|>


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

  function _requirePartial(rvPartial, callback) {
    var src = rvPartial.getAttribute('src') || false,
        target = rvPartial.getAttribute('target');

    if (!target) {
      return callback(false);
    }

    if (src) {
      window.Ractive.getHtml(src)
        .then(function(template) {
          template = _applyAbsolutePath(template, src);

          callback(target, template);
        });

      return;
    }

    callback(target, rvPartial.innerHTML);
  }

  function _fetchPartials(element, parent) {
    return new window.Ractive.Promise(function(fulfil) {
      var partials = {},
          rvPartials = element.querySelectorAll('rv-partial'),
          count = rvPartials.length,
          partialName;

      for (partialName in parent.partials) {
        partials[partialName] = parent.partials[partialName];
      }

      if (!count) {
        return fulfil(partials);
      }

      Array.prototype.map.call(rvPartials, function(rvPartial) {
        _requirePartial(rvPartial, function(target, template) {
          if (target) {
            partials[target] = template;
          }

          --count;
          if (count < 1) {
            fulfil(partials);
          }
        });
      });
    });
  }

  function _fetchDataBinding(element, parent) {
    var data = {},
        binds = {},
        attr,
        name;

    for (var i = 0; i < element.attributes.length; i++) {
      attr = element.attributes[i];
      if (attr.name.indexOf('data-bind-') === 0) {
        name = attr.name.substr(10, attr.name.length - 10);
        data[name] = parent.get(attr.value);
        binds[name] = attr.value;
      }
      else if (attr.name.indexOf('data-') === 0) {
        name = attr.name.substr(5, attr.name.length - 5);
        data[name] = attr.value;
      }
    }

    return {
      data: data,
      binds: binds
    };
  }

  function _applyAbsolutePath(template, src) {
    var newSrc = src.split('/'),
        a = document.createElement('a'),
        host = window.location.protocol + '//' + window.location.host;

    return template.replace(/[^-]src="(.*?)"/g, function(match, elementSrc) {
      if (
        elementSrc.indexOf('{') === 0 ||
        elementSrc.indexOf('/') === 0 ||
        elementSrc.indexOf('http://') === 0 ||
        elementSrc.indexOf('https://') === 0
      ) {
        return match;
      }

      newSrc.pop();
      newSrc.push(elementSrc);

      a.href = newSrc.join('/');

      return match.replace(elementSrc, a.href.substr(host.length, a.href.length - host.length));
    });
  }

  function _createObserver(parent, view, bind, keypath) {
    return parent.observe(keypath, function(value) {
      view.set(bind, value);
    });
  }

  function _requireElement(parent, element, callback, forceNoScript, forceNoCSS) {
    forceNoScript = forceNoScript || false;

    var src = element.getAttribute('src'),
        name = element.getAttribute('name'),
        noScript = forceNoScript || element.getAttribute('no-script') == 'true',
        noCSS = forceNoCSS || element.getAttribute('no-css') == 'true';

    if (!src) {
      throw new Error('nv-require needs to have a "src" attrbute');
    }

    if (!name) {
      throw new Error('nv-require needs to have a "name" attrbute');
    }

    element.setAttribute('loaded', 'true');

    if (!window.Ractive.templates[name]) {

      if (!noScript) {
        return window.Ractive.require(src + '.js').then(function() {
          _requireElement(parent, element, callback, true, noCSS);
        });
      }

      if (!noCSS) {
        return window.Ractive.require(src + '.css').then(function() {
          _requireElement(parent, element, callback, noScript, true);
        });
      }

      window.Ractive.getHtml(src + '.html')
        .then(function(template) {
          template = _applyAbsolutePath(template, src);

          window.Ractive.templates[name] = template;

          _requireElement(parent, element, callback);
        });

      return;
    }

    var template = window.Ractive.templates[name],
        databinding = _fetchDataBinding(element, parent);

    _fetchPartials(element, parent)
      .then(function(partials) {

        element.innerHTML = '';

        window.Ractive.fireController(name, function Component(config) {
          config = config || {};

          config.el = config.el || element;
          config.template = config.template || template;
          if (config.partials) {
            var partial;

            for (partial in config.partials) {
              partials[partial] = config.partials[partial];
            }
          }

          config.partials = partials;
          config.parentRequire = parent;

          var ractive = new window.Ractive(config),
              observers = [],
              bind;

          for (bind in databinding.binds) {
            observers.push(_createObserver(parent, ractive, bind, databinding.binds[bind]));
          }

          ractive.on('teardown', function() {
            ractive.parentRequire = null;

            var i;

            for (i = 0; i < observers.length; i++) {
              observers[i].cancel();
            }

            observers = null;

            if (parent && parent.childrenRequire) {
              for (i = 0; i < parent.childrenRequire.length; i++) {
                if (parent.childrenRequire[i] === ractive) {
                  parent.childrenRequire.splice(i, 1);
                  break;
                }
              }
            }

            if (ractive.childrenRequire) {
              for (i = ractive.childrenRequire.length - 1; i >= 0; i--) {
                ractive.childrenRequire[i].teardown();
              }
            }
          });

          ractive.childrenRequire = [];
          parent.childrenRequire.push(ractive);

          return ractive;
        }, databinding.data, element, {
          template: template,
          partials: partials
        }, function() {
          if (callback) {
            callback();
          }
        });

      });
  }

  function _inScope(element, parent) {
    if (element.parentNode != parent) {
      if (element.parentNode.tagName.toLowerCase() == 'rv-require') {
        return false;
      }

      return _inScope(element.parentNode, parent);
    }

    return true;
  }

  function _inject(name, file, elementConstructor, callback) {
    name = name.split('/').pop();

    if (window.Ractive.injects.indexOf(name) > -1) {
      return callback();
    }

    var element = elementConstructor();
    element.onload = callback;

    window.Ractive.injects.push(name);
    document.getElementsByTagName('head')[0].appendChild(element);
  }

  function _injectJS(name, file, callback) {
    _inject(name, file, function() {
      var script = document.createElement('script');
      script.type = 'text/javascript';
      script.src = file;

      return script;
    }, callback);
  }

  function _injectCSS(name, file, callback) {
    _inject(name, file, function() {
      var link = document.createElement('link');
      link.rel = 'stylesheet';
      link.href = file;

      return link;
    }, callback);
  }

  window.Ractive.templates = window.Ractive.templates || {};
  window.Ractive.injects = window.Ractive.injects || [];

  window.Ractive.require = function(name, file) {
    var extension = null;

    if (!name) {
      throw new Error('You have to specify a file/name');
    }

    file = file || name;

    extension = (file.split('.').pop() || '').toLowerCase();
    if (extension == 'js') {
      return new window.Ractive.Promise(function(fulfil) {
        _injectJS(name, file, fulfil);
      });
    }
    else if (extension == 'css') {
      return new window.Ractive.Promise(function(fulfil) {
        _injectCSS(name, file, fulfil);
      });
    }
  };

  window.Ractive.prototype.require = function(name) {
    name = name || null;

    var _this = this;

    this.childrenRequire = this.childrenRequire || [];

    return new window.Ractive.Promise(function(fulfil) {

      var elements = name ?
            _this.el.querySelectorAll('rv-require[src][ondemand="' + name + '"]:not([loaded="true"])') :
            _this.el.querySelectorAll('rv-require[src]:not([loaded="true"]):not([ondemand])'),
          count = elements.length;

      if (count < 1) {
        return fulfil();
      }

      [].forEach.call(elements, function(element) {

        if (_inScope(element, _this.el)) {
          _requireElement(_this, element, function() {
            --count;
            if (count < 1) {
              fulfil();
            }
          });
        }
        else {
          --count;
          if (count < 1) {
            fulfil();
          }
        }
      });

    });
  };

})();
<commit_msg>feat(require): add findChild() and findParent() methods<commit_after>(function() {
  'use strict';

  function _requirePartial(rvPartial, callback) {
    var src = rvPartial.getAttribute('src') || false,
        target = rvPartial.getAttribute('target');

    if (!target) {
      return callback(false);
    }

    if (src) {
      window.Ractive.getHtml(src)
        .then(function(template) {
          template = _applyAbsolutePath(template, src);

          callback(target, template);
        });

      return;
    }

    callback(target, rvPartial.innerHTML);
  }

  function _fetchPartials(element, parent) {
    return new window.Ractive.Promise(function(fulfil) {
      var partials = {},
          rvPartials = element.querySelectorAll('rv-partial'),
          count = rvPartials.length,
          partialName;

      for (partialName in parent.partials) {
        partials[partialName] = parent.partials[partialName];
      }

      if (!count) {
        return fulfil(partials);
      }

      Array.prototype.map.call(rvPartials, function(rvPartial) {
        _requirePartial(rvPartial, function(target, template) {
          if (target) {
            partials[target] = template;
          }

          --count;
          if (count < 1) {
            fulfil(partials);
          }
        });
      });
    });
  }

  function _fetchDataBinding(element, parent) {
    var data = {},
        binds = {},
        attr,
        name;

    for (var i = 0; i < element.attributes.length; i++) {
      attr = element.attributes[i];
      if (attr.name.indexOf('data-bind-') === 0) {
        name = attr.name.substr(10, attr.name.length - 10);
        data[name] = parent.get(attr.value);
        binds[name] = attr.value;
      }
      else if (attr.name.indexOf('data-') === 0) {
        name = attr.name.substr(5, attr.name.length - 5);
        data[name] = attr.value;
      }
    }

    return {
      data: data,
      binds: binds
    };
  }

  function _applyAbsolutePath(template, src) {
    var newSrc = src.split('/'),
        a = document.createElement('a'),
        host = window.location.protocol + '//' + window.location.host;

    return template.replace(/[^-]src="(.*?)"/g, function(match, elementSrc) {
      if (
        elementSrc.indexOf('{') === 0 ||
        elementSrc.indexOf('/') === 0 ||
        elementSrc.indexOf('http://') === 0 ||
        elementSrc.indexOf('https://') === 0
      ) {
        return match;
      }

      newSrc.pop();
      newSrc.push(elementSrc);

      a.href = newSrc.join('/');

      return match.replace(elementSrc, a.href.substr(host.length, a.href.length - host.length));
    });
  }

  function _createObserver(parent, view, bind, keypath) {
    return parent.observe(keypath, function(value) {
      view.set(bind, value);
    });
  }

  function _findChild(ractive, attribute, value) {
    for (var i = 0; i < ractive.childrenRequire.length; i++) {
      if (ractive.childrenRequire[i].el.getAttribute(attribute) == value) {
        return ractive.childrenRequire[i];
      }
    }

    return null;
  }

  function _findParent(ractive, attribute, value) {
    for (var i = 0; i < ractive.parentRequire.length; i++) {
      if (ractive.parentRequire[i].el.getAttribute(attribute) == value) {
        return ractive.parentRequire[i];
      }
    }

    return null;
  }

  function _requireElement(parent, element, callback, forceNoScript, forceNoCSS) {
    forceNoScript = forceNoScript || false;

    var src = element.getAttribute('src'),
        name = element.getAttribute('name'),
        noScript = forceNoScript || element.getAttribute('no-script') == 'true',
        noCSS = forceNoCSS || element.getAttribute('no-css') == 'true';

    if (!src) {
      throw new Error('nv-require needs to have a "src" attrbute');
    }

    if (!name) {
      throw new Error('nv-require needs to have a "name" attrbute');
    }

    element.setAttribute('loaded', 'true');

    if (!window.Ractive.templates[name]) {

      if (!noScript) {
        return window.Ractive.require(src + '.js').then(function() {
          _requireElement(parent, element, callback, true, noCSS);
        });
      }

      if (!noCSS) {
        return window.Ractive.require(src + '.css').then(function() {
          _requireElement(parent, element, callback, noScript, true);
        });
      }

      window.Ractive.getHtml(src + '.html')
        .then(function(template) {
          template = _applyAbsolutePath(template, src);

          window.Ractive.templates[name] = template;

          _requireElement(parent, element, callback);
        });

      return;
    }

    var template = window.Ractive.templates[name],
        databinding = _fetchDataBinding(element, parent);

    _fetchPartials(element, parent)
      .then(function(partials) {

        element.innerHTML = '';

        window.Ractive.fireController(name, function Component(config) {
          config = config || {};

          config.el = config.el || element;
          config.template = config.template || template;
          if (config.partials) {
            var partial;

            for (partial in config.partials) {
              partials[partial] = config.partials[partial];
            }
          }

          config.partials = partials;
          config.parentRequire = parent;

          var ractive = new window.Ractive(config),
              observers = [],
              bind;

          for (bind in databinding.binds) {
            observers.push(_createObserver(parent, ractive, bind, databinding.binds[bind]));
          }

          ractive.on('teardown', function() {
            ractive.parentRequire = null;

            var i;

            for (i = 0; i < observers.length; i++) {
              observers[i].cancel();
            }

            observers = null;

            if (parent && parent.childrenRequire) {
              for (i = 0; i < parent.childrenRequire.length; i++) {
                if (parent.childrenRequire[i] === ractive) {
                  parent.childrenRequire.splice(i, 1);
                  break;
                }
              }
            }

            if (ractive.childrenRequire) {
              for (i = ractive.childrenRequire.length - 1; i >= 0; i--) {
                ractive.childrenRequire[i].teardown();
              }
            }
          });

          ractive.childrenRequire = [];

          ractive.findParent = function(attribute, value) {
            return _findParent(ractive, attribute, value);
          };

          ractive.findChild = function(attribute, value) {
            return _findChild(ractive, attribute, value);
          };

          parent.childrenRequire.push(ractive);

          return ractive;
        }, databinding.data, element, {
          template: template,
          partials: partials
        }, function() {
          if (callback) {
            callback();
          }
        });

      });
  }

  function _inScope(element, parent) {
    if (element.parentNode != parent) {
      if (element.parentNode.tagName.toLowerCase() == 'rv-require') {
        return false;
      }

      return _inScope(element.parentNode, parent);
    }

    return true;
  }

  function _inject(name, file, elementConstructor, callback) {
    name = name.split('/').pop();

    if (window.Ractive.injects.indexOf(name) > -1) {
      return callback();
    }

    var element = elementConstructor();
    element.onload = callback;

    window.Ractive.injects.push(name);
    document.getElementsByTagName('head')[0].appendChild(element);
  }

  function _injectJS(name, file, callback) {
    _inject(name, file, function() {
      var script = document.createElement('script');
      script.type = 'text/javascript';
      script.src = file;

      return script;
    }, callback);
  }

  function _injectCSS(name, file, callback) {
    _inject(name, file, function() {
      var link = document.createElement('link');
      link.rel = 'stylesheet';
      link.href = file;

      return link;
    }, callback);
  }

  window.Ractive.templates = window.Ractive.templates || {};
  window.Ractive.injects = window.Ractive.injects || [];

  window.Ractive.require = function(name, file) {
    var extension = null;

    if (!name) {
      throw new Error('You have to specify a file/name');
    }

    file = file || name;

    extension = (file.split('.').pop() || '').toLowerCase();
    if (extension == 'js') {
      return new window.Ractive.Promise(function(fulfil) {
        _injectJS(name, file, fulfil);
      });
    }
    else if (extension == 'css') {
      return new window.Ractive.Promise(function(fulfil) {
        _injectCSS(name, file, fulfil);
      });
    }
  };

  window.Ractive.prototype.require = function(name) {
    name = name || null;

    var _this = this;

    this.childrenRequire = this.childrenRequire || [];

    return new window.Ractive.Promise(function(fulfil) {

      var elements = name ?
            _this.el.querySelectorAll('rv-require[src][ondemand="' + name + '"]:not([loaded="true"])') :
            _this.el.querySelectorAll('rv-require[src]:not([loaded="true"]):not([ondemand])'),
          count = elements.length;

      if (count < 1) {
        return fulfil();
      }

      [].forEach.call(elements, function(element) {

        if (_inScope(element, _this.el)) {
          _requireElement(_this, element, function() {
            --count;
            if (count < 1) {
              fulfil();
            }
          });
        }
        else {
          --count;
          if (count < 1) {
            fulfil();
          }
        }
      });

    });
  };

})();
<|endoftext|>


<commit_before>height = 600
width = 800

var app = new PIXI.Application(width, height, { backgroundColor : 0xffffff, antialias: true });
document.body.appendChild(app.view);

epoch_height = 100
// [log end,log start,color,level,name]
epoch = [[0,1,0xFF700B,1,'steve'],[1,2,0x993300,1,'jerry'],[2,2.1,0x0000ff,1,'tim'],[0,2,0x003300,2,'named eras']]

function year(log_year){
	return Math.pow(10,log_year)-1
}

function epoch_length(era){
	return (year(era[1])-year(era[0]))
}

(function() {
	// epoch colourings
	era = []
	for(var i = 0; i < epoch.length; i++){
		era.push(new PIXI.Graphics());
		era[i].beginFill(epoch[i][2], 1);
		era[i].drawRect(0, height-epoch_height*epoch[i][3],epoch_length(epoch[i]), epoch_height); // drawRect(year(epoch[i][0]), height-epoch_height*epoch[i][3],epoch_length(epoch[i]), epoch_height);
		app.stage.addChild(era[i]);
	}

	// epoch names

	names = []
	for(var i = 0; i < epoch.length; i++){
		names.push(new PIXI.Text(epoch[i][4]))
		names[i].x = year(epoch[i][0]);
		names[i].y = height-epoch_height*epoch[i][3];
		names[i].width = epoch_length(epoch[i])
		app.stage.addChild(names[i]);
	}

	var left_change = true
	var right_change = true
	var scroll = 0
	var scale  = 2

	function mainLoop() {

		//check how we should be scaling
		$(document).keydown(function (event){
			if (event.keyCode == 68 && right_change){
				scroll += 1
				right_change = false
			};
			if (event.keyCode == 65 && left_change){
				scroll += -1
				left_change = false
			};
		});

		//change the scale
		scale += scroll*0.005

		$(document).keyup(function (event){
			if (event.keyCode == 68 && !right_change){
				scroll += -1
				right_change = true
			};
			if (event.keyCode == 65 && !left_change){
				scroll += 1
				left_change = true
			};
		});

		//drawing
		for(var i = 0; i < epoch.length; i++){
			names[i].x = year(epoch[i][0])*Math.pow(10,scale)
			era[i].x   = year(epoch[i][0])*Math.pow(10,scale)

			names[i].width = epoch_length(epoch[i])*Math.pow(10,scale)
			era[i].width   = epoch_length(epoch[i])*Math.pow(10,scale)
		}

		setTimeout(mainLoop, 1); // Run, run, as fast as you can!
	};

	mainLoop();
}).call();<commit_msg>timeline 2<commit_after>height = 600
width = 800

var app = new PIXI.Application(width, height, { backgroundColor : 0xffffff, antialias: true });
document.body.appendChild(app.view);

epoch_height = 100
// [log end,log start,color,level,name]
epoch = [[0,1,0xFF700B,1,'steve'],[1,2,0x993300,1,'jerry'],[2,2.1,0x0000ff,1,'tim'],[0,2,0x003300,2,'named eras']]

function year(log_year){
	return Math.pow(10,log_year)-1
}

function epoch_length(era){
	return (year(era[1])-year(era[0]))
}

(function() {
	// epoch colourings
	era = []
	for(var i = 0; i < epoch.length; i++){
		era.push(new PIXI.Graphics());
		era[i].beginFill(epoch[i][2], 1);
		era[i].drawRect(0, height-epoch_height*epoch[i][3],epoch_length(epoch[i]), epoch_height); // drawRect(year(epoch[i][0]), height-epoch_height*epoch[i][3],epoch_length(epoch[i]), epoch_height);
		app.stage.addChild(era[i]);
	}

	// epoch names

	names = []
	for(var i = 0; i < epoch.length; i++){
		names.push(new PIXI.Text(epoch[i][4]))
		names[i].x = year(epoch[i][0]);
		names[i].y = height-epoch_height*epoch[i][3];
		app.stage.addChild(names[i]);
	}

	var left_change = true
	var right_change = true
	var scroll = 0
	var scale  = 2

	function mainLoop() {

		//check how we should be scaling
		$(document).keydown(function (event){
			if (event.keyCode == 68 && right_change){
				scroll += 1
				right_change = false
			};
			if (event.keyCode == 65 && left_change){
				scroll += -1
				left_change = false
			};
		});

		//change the scale
		scale += scroll*0.005

		$(document).keyup(function (event){
			if (event.keyCode == 68 && !right_change){
				scroll += -1
				right_change = true
			};
			if (event.keyCode == 65 && !left_change){
				scroll += 1
				left_change = true
			};
		});

		//drawing
		for(var i = 0; i < epoch.length; i++){
			names[i].x = year(epoch[i][0])*Math.pow(10,scale)
			era[i].x   = year(epoch[i][0])*Math.pow(10,scale)

			names[i].width = Math.min(names[i].width,epoch_length(epoch[i])*Math.pow(10,scale))
			era[i].width   = epoch_length(epoch[i])*Math.pow(10,scale)
		}

		setTimeout(mainLoop, 1); // Run, run, as fast as you can!
	};

	mainLoop();
}).call();<|endoftext|>


<commit_before>Package.describe({
  name: 'dbarrett:dropzonejs',
  summary: 'Dropzone.js - an open source library that provides drag\'n\'drop file uploads with image previews',
  version: '3.10.2',
  git: 'https://github.com/devonbarrett/meteor-dropzone.git'
});

Package.onUse(function(api) {
  api.versionsFrom('1.0');

  api.use([
    'templating',
    'underscore'
  ], 'client');

  //add dropzone library
  api.addFiles([
  	'lib/3.10.2/dropzone.js',
  	'lib/3.10.2/images/spritemap.png',
  	'lib/3.10.2/images/spritemap@2x.png',
  	'lib/3.10.2/css/basic.css',
  	'lib/3.10.2/css/dropzone.css',
  ], 'client');

  //add dropzone template
  api.addFiles([
  	'lib/dbarrett:dropzonejs.html',
  	'lib/dbarrett:dropzonejs.js'
  ], 'client');
});

Package.onTest(function(api) {
  api.use('tinytest');
  api.use('dbarrett:dropzonejs');
  api.addFiles('dbarrett:dropzonejs-tests.js');
});<commit_msg>remove tests<commit_after>Package.describe({
  name: 'dbarrett:dropzonejs',
  summary: 'Dropzone.js - an open source library that provides drag\'n\'drop file uploads with image previews',
  version: '3.10.2',
  git: 'https://github.com/devonbarrett/meteor-dropzone.git'
});

Package.onUse(function(api) {
  api.versionsFrom('1.0');

  api.use([
    'templating',
    'underscore'
  ], 'client');

  //add dropzone library
  api.addFiles([
  	'lib/3.10.2/dropzone.js',
  	'lib/3.10.2/images/spritemap.png',
  	'lib/3.10.2/images/spritemap@2x.png',
  	'lib/3.10.2/css/basic.css',
  	'lib/3.10.2/css/dropzone.css',
  ], 'client');

  //add dropzone template
  api.addFiles([
  	'lib/dbarrett:dropzonejs.html',
  	'lib/dbarrett:dropzonejs.js'
  ], 'client');
});<|endoftext|>


<commit_before>const DecorationTypes = {
  "pre-confirm": {
    decorationProps: {
      type: "highlight",
      class: "vim-mode-plus-find-char pre-confirm",
    },
  },
  "post-confirm": {
    timeout: 2000,
    decorationProps: {
      type: "highlight",
      class: "vim-mode-plus-find-char post-confirm",
    },
  },
  "post-confirm long": {
    timeout: 4000,
    decorationProps: {
      type: "highlight",
      class: "vim-mode-plus-find-char post-confirm long",
    },
  },
}

module.exports = class HighlightFind {
  constructor(vimState) {
    this.vimState = vimState
    vimState.onDidDestroy(() => this.destroy())

    const {editor} = vimState
    this.markerLayer = editor.addMarkerLayer()
    this.decorationLayer = editor.decorateMarkerLayer(this.markerLayer, {})
  }

  destroy() {
    this.decorationLayer.destroy()
    this.markerLayer.destroy()
  }

  clearMarkers() {
    this.markerLayer.clear()
  }

  highlightCursorRows(regex, decorationType, backwards, currentIndex) {
    this.clearMarkers()

    const vimState = this.vimState
    const editor = this.vimState.editor
    const visibleRange = this.vimState.utils.getVisibleBufferRange(editor)
    if (!visibleRange) return

    const cursors = editor.getCursors().filter(cursor => visibleRange.containsPoint(cursor.getBufferPosition()))
    if (!cursors.length) return

    let scanRanges
    if (vimState.getConfig("findAcrossLines")) {
      const cursorsOrdered = this.vimState.utils.sortCursors(cursors)
      scanRanges = backwards
        ? [[visibleRange.start, cursorsOrdered.pop().getBufferPosition()]]
        : [[cursorsOrdered.shift().getBufferPosition(), visibleRange.end]]
    } else {
      scanRanges = backwards
        ? cursors.map(cursor => [cursor.getCurrentLineBufferRange().start, cursor.getBufferPosition()])
        : cursors.map(cursor => [cursor.getBufferPosition(), cursor.getCurrentLineBufferRange().end])
    }

    const ranges = []
    for (const scanRange of scanRanges) {
      editor.scanInBufferRange(regex, scanRange, ({range}) => ranges.push(range))
    }
    if (!ranges.length) return

    let currentRange
    if (decorationType === "pre-confirm") {
      const cursorPosition = editor.getCursorBufferPosition()
      const candidates = backwards
        ? ranges.slice().reverse().filter(range => range.start.isLessThan(cursorPosition))
        : ranges.filter(range => range.start.isGreaterThan(cursorPosition))
      currentRange = candidates[currentIndex]
    }
    this.highlightRanges(ranges, decorationType, currentRange)
  }

  highlightRanges(ranges, decorationType, currentRange) {
    if (this.clearMarkerTimeoutID) {
      clearTimeout(this.clearMarkerTimeoutID)
      this.clearMarkerTimeoutID = null
    }

    // We need to force update here to restart(re-trigger) keyframe animation.
    this.vimState.editor.component.updateSync()

    for (const range of ranges) {
      this.markerLayer.markBufferRange(range)
    }

    const {timeout, decorationProps} = DecorationTypes[decorationType]
    this.decorationLayer.setProperties(decorationProps)

    if (currentRange) {
      const currentMarker = this.markerLayer.getMarkers().find(marker => marker.getBufferRange().isEqual(currentRange))
      this.decorationLayer.setPropertiesForMarker(currentMarker, {
        type: "highlight",
        class: "vim-mode-plus-find-char pre-confirm current",
      })
    }

    if (timeout) {
      this.clearMarkerTimeoutID = setTimeout(() => this.clearMarkers(), timeout)
    }
  }
}
<commit_msg>better marker volatility option<commit_after>const DecorationTypes = {
  "pre-confirm": {
    decorationProps: {
      type: "highlight",
      class: "vim-mode-plus-find-char pre-confirm",
    },
  },
  "post-confirm": {
    timeout: 2000,
    decorationProps: {
      type: "highlight",
      class: "vim-mode-plus-find-char post-confirm",
    },
  },
  "post-confirm long": {
    timeout: 4000,
    decorationProps: {
      type: "highlight",
      class: "vim-mode-plus-find-char post-confirm long",
    },
  },
}

module.exports = class HighlightFind {
  constructor(vimState) {
    this.vimState = vimState
    vimState.onDidDestroy(() => this.destroy())

    const {editor} = vimState
    this.markerLayer = editor.addMarkerLayer()
    this.decorationLayer = editor.decorateMarkerLayer(this.markerLayer, {})
  }

  destroy() {
    this.decorationLayer.destroy()
    this.markerLayer.destroy()
  }

  clearMarkers() {
    this.markerLayer.clear()
  }

  highlightCursorRows(regex, decorationType, backwards, currentIndex) {
    this.clearMarkers()

    const vimState = this.vimState
    const editor = this.vimState.editor
    const visibleRange = this.vimState.utils.getVisibleBufferRange(editor)
    if (!visibleRange) return

    const cursors = editor.getCursors().filter(cursor => visibleRange.containsPoint(cursor.getBufferPosition()))
    if (!cursors.length) return

    let scanRanges
    if (vimState.getConfig("findAcrossLines")) {
      const cursorsOrdered = this.vimState.utils.sortCursors(cursors)
      scanRanges = backwards
        ? [[visibleRange.start, cursorsOrdered.pop().getBufferPosition()]]
        : [[cursorsOrdered.shift().getBufferPosition(), visibleRange.end]]
    } else {
      scanRanges = backwards
        ? cursors.map(cursor => [cursor.getCurrentLineBufferRange().start, cursor.getBufferPosition()])
        : cursors.map(cursor => [cursor.getBufferPosition(), cursor.getCurrentLineBufferRange().end])
    }

    const ranges = []
    for (const scanRange of scanRanges) {
      editor.scanInBufferRange(regex, scanRange, ({range}) => ranges.push(range))
    }
    if (!ranges.length) return

    let currentRange
    if (decorationType === "pre-confirm") {
      const cursorPosition = editor.getCursorBufferPosition()
      const candidates = backwards
        ? ranges.slice().reverse().filter(range => range.start.isLessThan(cursorPosition))
        : ranges.filter(range => range.start.isGreaterThan(cursorPosition))
      currentRange = candidates[currentIndex]
    }
    this.highlightRanges(ranges, decorationType, currentRange)
  }

  highlightRanges(ranges, decorationType, currentRange) {
    if (this.clearMarkerTimeoutID) {
      clearTimeout(this.clearMarkerTimeoutID)
      this.clearMarkerTimeoutID = null
    }

    // We need to force update here to restart(re-trigger) keyframe animation.
    this.vimState.editor.component.updateSync()

    for (const range of ranges) {
      this.markerLayer.markBufferRange(range, {invalidate: "touch"})
    }

    const {timeout, decorationProps} = DecorationTypes[decorationType]
    this.decorationLayer.setProperties(decorationProps)

    if (currentRange) {
      const currentMarker = this.markerLayer.getMarkers().find(marker => marker.getBufferRange().isEqual(currentRange))
      this.decorationLayer.setPropertiesForMarker(currentMarker, {
        type: "highlight",
        class: "vim-mode-plus-find-char pre-confirm current",
      })
    }

    if (timeout) {
      this.clearMarkerTimeoutID = setTimeout(() => this.clearMarkers(), timeout)
    }
  }
}
<|endoftext|>