<commit_before>define([
  "dojo",
  "..",
  "../_Contained",
  "./_LayoutWidget"], function(dojo, dijit) {
	// module:
	//		dijit/layout/_ContentPaneResizeMixin
	// summary:
	//		TODOC

dojo.declare("dijit.layout._ContentPaneResizeMixin", null, {
	// summary:
	//		Resize() functionality of ContentPane.   If there's a single layout widget
	//		child then it will call resize() with the same dimensions as the ContentPane.
	//		Otherwise just calls resize on each child.
	//
	//		Also implements basic startup() functionality, where starting the parent
	//		will start the children

	// doLayout: Boolean
	//		- false - don't adjust size of children
	//		- true - if there is a single visible child widget, set it's size to
	//				however big the ContentPane is
	doLayout: true,

	// isContainer: [protected] Boolean
	//		Indicates that this widget acts as a "parent" to the descendant widgets.
	//		When the parent is started it will call startup() on the child widgets.
	//		See also `isLayoutContainer`.
	isContainer: true,

	// isLayoutContainer: [protected] Boolean
	//		Indicates that this widget will call resize() on it's child widgets
	//		when they become visible.
	isLayoutContainer: true,

	_startChildren: function(){
		// summary:
		//		Call startup() on all children including non _Widget ones like dojo.dnd.Source objects

		// This starts all the widgets
		dojo.forEach(this.getChildren(), function(child){
			child.startup();
			child._started = true;
		});
	},

	startup: function(){
		// summary:
		//		See `dijit.layout._LayoutWidget.startup` for description.
		//		Although ContentPane doesn't extend _LayoutWidget, it does implement
		//		the same API.

		if(this._started){ return; }

		var parent = dijit._Contained.prototype.getParent.call(this);
		this._childOfLayoutWidget = parent && parent.isLayoutContainer;

		// I need to call resize() on my child/children (when I become visible), unless
		// I'm the child of a layout widget in which case my parent will call resize() on me and I'll do it then.
		this._needLayout = !this._childOfLayoutWidget;

		this.inherited(arguments);

		this._startChildren();

		if(this._isShown()){
			this._onShow();
		}

		if(!this._childOfLayoutWidget){
			// If my parent isn't a layout container, since my style *may be* width=height=100%
			// or something similar (either set directly or via a CSS class),
			// monitor when my size changes so that I can re-layout.
			// For browsers where I can't directly monitor when my size changes,
			// monitor when the viewport changes size, which *may* indicate a size change for me.
			this.connect(dojo.isIE ? this.domNode : dojo.global, 'onresize', function(){
				// Using function(){} closure to ensure no arguments to resize.
				this._needLayout = !this._childOfLayoutWidget;
				this.resize();
			});
		}
	},

	_checkIfSingleChild: function(){
		// summary:
		//		Test if we have exactly one visible widget as a child,
		//		and if so assume that we are a container for that widget,
		//		and should propagate startup() and resize() calls to it.
		//		Skips over things like data stores since they aren't visible.

		var childNodes = dojo.query("> *", this.containerNode).filter(function(node){
				return node.tagName !== "SCRIPT"; // or a regexp for hidden elements like script|area|map|etc..
			}),
			childWidgetNodes = childNodes.filter(function(node){
				return dojo.hasAttr(node, "data-dojo-type") || dojo.hasAttr(node, "dojoType") || dojo.hasAttr(node, "widgetId");
			}),
			candidateWidgets = dojo.filter(childWidgetNodes.map(dijit.byNode), function(widget){
				return widget && widget.domNode && widget.resize;
			});

		if(
			// all child nodes are widgets
			childNodes.length == childWidgetNodes.length &&

			// all but one are invisible (like dojo.data)
			candidateWidgets.length == 1
		){
			this._singleChild = candidateWidgets[0];
		}else{
			delete this._singleChild;
		}

		// So we can set overflow: hidden to avoid a safari bug w/scrollbars showing up (#9449)
		dojo.toggleClass(this.containerNode, this.baseClass + "SingleChild", !!this._singleChild);
	},

	resize: function(changeSize, resultSize){
		// summary:
		//		See `dijit.layout._LayoutWidget.resize` for description.
		//		Although ContentPane doesn't extend _LayoutWidget, it does implement
		//		the same API.

		// For the TabContainer --> BorderContainer --> ContentPane case, _onShow() is
		// never called, so resize() is our trigger to do the initial href download (see [20099]).
		// However, don't load href for closed TitlePanes.
		if(!this._wasShown && this.open !== false){
			this._onShow();
		}

		this._resizeCalled = true;

		this._scheduleLayout(changeSize, resultSize);
	},

	_scheduleLayout: function(changeSize, resultSize){
		// summary:
		//		Resize myself, and call resize() on each of my child layout widgets, either now
		//		(if I'm currently visible) or when I become visible
		if(this._isShown()){
			this._layout(changeSize, resultSize);
		}else{
			this._needLayout = true;
			this._changeSize = changeSize;
			this._resultSize = resultSize;
		}
	},

	_layout: function(changeSize, resultSize){
		// summary:
		//		Resize myself according to optional changeSize/resultSize parameters, like a layout widget.
		//		Also, since I am a Container widget, each of my children expects me to
		//		call resize() or layout() on them.
		//
		//		Should be called on initialization and also whenever we get new content
		//		(from an href, or from set('content', ...))... but deferred until
		//		the ContentPane is visible

		// Set margin box size, unless it wasn't specified, in which case use current size.
		if(changeSize){
			dojo.marginBox(this.domNode, changeSize);
		}

		// Compute content box size of containerNode in case we [later] need to size our single child.
		var cn = this.containerNode;
		if(cn === this.domNode){
			// If changeSize or resultSize was passed to this method and this.containerNode ==
			// this.domNode then we can compute the content-box size without querying the node,
			// which is more reliable (similar to LayoutWidget.resize) (see for example #9449).
			var mb = resultSize || {};
			dojo.mixin(mb, changeSize || {}); // changeSize overrides resultSize
			if(!("h" in mb) || !("w" in mb)){
				mb = dojo.mixin(dojo.marginBox(cn), mb); // just use dojo.marginBox() to fill in missing values
			}
			this._contentBox = dijit.layout.marginBox2contentBox(cn, mb);
		}else{
			this._contentBox = dojo.contentBox(cn);
		}

		this._layoutChildren();

		delete this._needLayout;
	},

	_layoutChildren: function(){
		// Call _checkIfSingleChild() again in case app has manually mucked w/the content
		// of the ContentPane (rather than changing it through the set("content", ...) API.
		if(this.doLayout){
			this._checkIfSingleChild();
		}

		if(this._singleChild && this._singleChild.resize){
			var cb = this._contentBox || dojo.contentBox(this.containerNode);

			// note: if widget has padding this._contentBox will have l and t set,
			// but don't pass them to resize() or it will doubly-offset the child
			this._singleChild.resize({w: cb.w, h: cb.h});
		}else{
			// All my child widgets are independently sized (rather than matching my size),
			// but I still need to call resize() on each child to make it layout.
			dojo.forEach(this.getChildren(), function(widget){
				if(widget.resize){
					widget.resize();
				}
			});
		}
	},

	_isShown: function(){
		// summary:
		//		Returns true if the content is currently shown.
		// description:
		//		If I am a child of a layout widget then it actually returns true if I've ever been visible,
		//		not whether I'm currently visible, since that's much faster than tracing up the DOM/widget
		//		tree every call, and at least solves the performance problem on page load by deferring loading
		//		hidden ContentPanes until they are first shown

		if(this._childOfLayoutWidget){
			// If we are TitlePane, etc - we return that only *IF* we've been resized
			if(this._resizeCalled && "open" in this){
				return this.open;
			}
			return this._resizeCalled;
		}else if("open" in this){
			return this.open;		// for TitlePane, etc.
		}else{
			var node = this.domNode, parent = this.domNode.parentNode;
			return (node.style.display != 'none') && (node.style.visibility != 'hidden') && !dojo.hasClass(node, "dijitHidden") &&
					parent && parent.style && (parent.style.display != 'none');
		}
	},

	_onShow: function(){
		// summary:
		//		Called when the ContentPane is made visible
		// description:
		//		For a plain ContentPane, this is called on initialization, from startup().
		//		If the ContentPane is a hidden pane of a TabContainer etc., then it's
		//		called whenever the pane is made visible.
		//
		//		Does layout/resize of child widget(s)

		if(this._needLayout){
			// If a layout has been scheduled for when we become visible, do it now
			this._layout(this._changeSize, this._resultSize);
		}

		this.inherited(arguments);

		// Need to keep track of whether ContentPane has been shown (which is different than
		// whether or not it's currently visible).
		this._wasShown = true;
	}
});

return dijit.layout._ContentPaneResizeMixin;
});
<commit_msg>Check if child._started is set before calling startup().   Not sure if this check is necessary but other code does it.   Fixes #12878 !strict, thanks mrnoouts.<commit_after>define([
  "dojo",
  "..",
  "../_Contained",
  "./_LayoutWidget"], function(dojo, dijit) {
	// module:
	//		dijit/layout/_ContentPaneResizeMixin
	// summary:
	//		TODOC

dojo.declare("dijit.layout._ContentPaneResizeMixin", null, {
	// summary:
	//		Resize() functionality of ContentPane.   If there's a single layout widget
	//		child then it will call resize() with the same dimensions as the ContentPane.
	//		Otherwise just calls resize on each child.
	//
	//		Also implements basic startup() functionality, where starting the parent
	//		will start the children

	// doLayout: Boolean
	//		- false - don't adjust size of children
	//		- true - if there is a single visible child widget, set it's size to
	//				however big the ContentPane is
	doLayout: true,

	// isContainer: [protected] Boolean
	//		Indicates that this widget acts as a "parent" to the descendant widgets.
	//		When the parent is started it will call startup() on the child widgets.
	//		See also `isLayoutContainer`.
	isContainer: true,

	// isLayoutContainer: [protected] Boolean
	//		Indicates that this widget will call resize() on it's child widgets
	//		when they become visible.
	isLayoutContainer: true,

	_startChildren: function(){
		// summary:
		//		Call startup() on all children including non _Widget ones like dojo.dnd.Source objects

		// This starts all the widgets
		dojo.forEach(this.getChildren(), function(child){
			if(!child._started){
				child.startup();
				child._started = true;
			}
		});
	},

	startup: function(){
		// summary:
		//		See `dijit.layout._LayoutWidget.startup` for description.
		//		Although ContentPane doesn't extend _LayoutWidget, it does implement
		//		the same API.

		if(this._started){ return; }

		var parent = dijit._Contained.prototype.getParent.call(this);
		this._childOfLayoutWidget = parent && parent.isLayoutContainer;

		// I need to call resize() on my child/children (when I become visible), unless
		// I'm the child of a layout widget in which case my parent will call resize() on me and I'll do it then.
		this._needLayout = !this._childOfLayoutWidget;

		this.inherited(arguments);

		this._startChildren();

		if(this._isShown()){
			this._onShow();
		}

		if(!this._childOfLayoutWidget){
			// If my parent isn't a layout container, since my style *may be* width=height=100%
			// or something similar (either set directly or via a CSS class),
			// monitor when my size changes so that I can re-layout.
			// For browsers where I can't directly monitor when my size changes,
			// monitor when the viewport changes size, which *may* indicate a size change for me.
			this.connect(dojo.isIE ? this.domNode : dojo.global, 'onresize', function(){
				// Using function(){} closure to ensure no arguments to resize.
				this._needLayout = !this._childOfLayoutWidget;
				this.resize();
			});
		}
	},

	_checkIfSingleChild: function(){
		// summary:
		//		Test if we have exactly one visible widget as a child,
		//		and if so assume that we are a container for that widget,
		//		and should propagate startup() and resize() calls to it.
		//		Skips over things like data stores since they aren't visible.

		var childNodes = dojo.query("> *", this.containerNode).filter(function(node){
				return node.tagName !== "SCRIPT"; // or a regexp for hidden elements like script|area|map|etc..
			}),
			childWidgetNodes = childNodes.filter(function(node){
				return dojo.hasAttr(node, "data-dojo-type") || dojo.hasAttr(node, "dojoType") || dojo.hasAttr(node, "widgetId");
			}),
			candidateWidgets = dojo.filter(childWidgetNodes.map(dijit.byNode), function(widget){
				return widget && widget.domNode && widget.resize;
			});

		if(
			// all child nodes are widgets
			childNodes.length == childWidgetNodes.length &&

			// all but one are invisible (like dojo.data)
			candidateWidgets.length == 1
		){
			this._singleChild = candidateWidgets[0];
		}else{
			delete this._singleChild;
		}

		// So we can set overflow: hidden to avoid a safari bug w/scrollbars showing up (#9449)
		dojo.toggleClass(this.containerNode, this.baseClass + "SingleChild", !!this._singleChild);
	},

	resize: function(changeSize, resultSize){
		// summary:
		//		See `dijit.layout._LayoutWidget.resize` for description.
		//		Although ContentPane doesn't extend _LayoutWidget, it does implement
		//		the same API.

		// For the TabContainer --> BorderContainer --> ContentPane case, _onShow() is
		// never called, so resize() is our trigger to do the initial href download (see [20099]).
		// However, don't load href for closed TitlePanes.
		if(!this._wasShown && this.open !== false){
			this._onShow();
		}

		this._resizeCalled = true;

		this._scheduleLayout(changeSize, resultSize);
	},

	_scheduleLayout: function(changeSize, resultSize){
		// summary:
		//		Resize myself, and call resize() on each of my child layout widgets, either now
		//		(if I'm currently visible) or when I become visible
		if(this._isShown()){
			this._layout(changeSize, resultSize);
		}else{
			this._needLayout = true;
			this._changeSize = changeSize;
			this._resultSize = resultSize;
		}
	},

	_layout: function(changeSize, resultSize){
		// summary:
		//		Resize myself according to optional changeSize/resultSize parameters, like a layout widget.
		//		Also, since I am a Container widget, each of my children expects me to
		//		call resize() or layout() on them.
		//
		//		Should be called on initialization and also whenever we get new content
		//		(from an href, or from set('content', ...))... but deferred until
		//		the ContentPane is visible

		// Set margin box size, unless it wasn't specified, in which case use current size.
		if(changeSize){
			dojo.marginBox(this.domNode, changeSize);
		}

		// Compute content box size of containerNode in case we [later] need to size our single child.
		var cn = this.containerNode;
		if(cn === this.domNode){
			// If changeSize or resultSize was passed to this method and this.containerNode ==
			// this.domNode then we can compute the content-box size without querying the node,
			// which is more reliable (similar to LayoutWidget.resize) (see for example #9449).
			var mb = resultSize || {};
			dojo.mixin(mb, changeSize || {}); // changeSize overrides resultSize
			if(!("h" in mb) || !("w" in mb)){
				mb = dojo.mixin(dojo.marginBox(cn), mb); // just use dojo.marginBox() to fill in missing values
			}
			this._contentBox = dijit.layout.marginBox2contentBox(cn, mb);
		}else{
			this._contentBox = dojo.contentBox(cn);
		}

		this._layoutChildren();

		delete this._needLayout;
	},

	_layoutChildren: function(){
		// Call _checkIfSingleChild() again in case app has manually mucked w/the content
		// of the ContentPane (rather than changing it through the set("content", ...) API.
		if(this.doLayout){
			this._checkIfSingleChild();
		}

		if(this._singleChild && this._singleChild.resize){
			var cb = this._contentBox || dojo.contentBox(this.containerNode);

			// note: if widget has padding this._contentBox will have l and t set,
			// but don't pass them to resize() or it will doubly-offset the child
			this._singleChild.resize({w: cb.w, h: cb.h});
		}else{
			// All my child widgets are independently sized (rather than matching my size),
			// but I still need to call resize() on each child to make it layout.
			dojo.forEach(this.getChildren(), function(widget){
				if(widget.resize){
					widget.resize();
				}
			});
		}
	},

	_isShown: function(){
		// summary:
		//		Returns true if the content is currently shown.
		// description:
		//		If I am a child of a layout widget then it actually returns true if I've ever been visible,
		//		not whether I'm currently visible, since that's much faster than tracing up the DOM/widget
		//		tree every call, and at least solves the performance problem on page load by deferring loading
		//		hidden ContentPanes until they are first shown

		if(this._childOfLayoutWidget){
			// If we are TitlePane, etc - we return that only *IF* we've been resized
			if(this._resizeCalled && "open" in this){
				return this.open;
			}
			return this._resizeCalled;
		}else if("open" in this){
			return this.open;		// for TitlePane, etc.
		}else{
			var node = this.domNode, parent = this.domNode.parentNode;
			return (node.style.display != 'none') && (node.style.visibility != 'hidden') && !dojo.hasClass(node, "dijitHidden") &&
					parent && parent.style && (parent.style.display != 'none');
		}
	},

	_onShow: function(){
		// summary:
		//		Called when the ContentPane is made visible
		// description:
		//		For a plain ContentPane, this is called on initialization, from startup().
		//		If the ContentPane is a hidden pane of a TabContainer etc., then it's
		//		called whenever the pane is made visible.
		//
		//		Does layout/resize of child widget(s)

		if(this._needLayout){
			// If a layout has been scheduled for when we become visible, do it now
			this._layout(this._changeSize, this._resultSize);
		}

		this.inherited(arguments);

		// Need to keep track of whether ContentPane has been shown (which is different than
		// whether or not it's currently visible).
		this._wasShown = true;
	}
});

return dijit.layout._ContentPaneResizeMixin;
});
<|endoftext|>


<commit_before>/*
   simple_example.js
   Plist-to-JSON

   Created by Codeboxed on 2011-05-16.
*/

var win = Ti.UI.currentWindow;

Ti.include('../plist_to_json.js');

var array = plist_to_json('plists/simple_example.plist');

Ti.API.info(array);

alert('Check the log...');
<commit_msg>Added extensive usage for simple-example.js<commit_after>/*
   simple_example.js
   Plist-to-JSON

   Created by Codeboxed on 2011-05-16.
*/

var win = Ti.UI.currentWindow;

Ti.include('../plist-to-json.js');

var goodFilePath = 'plists/simple_example.plist';
var wrongFilePath = 'simple_example.plist';
var validXMLString = '<?xml version="1.0" encoding="utf-8"?><plist version="1.0"> <array>' +
					 '<dict> <key>title</key> <string>The Caledonian Brewery</string>' +
					 '<key>image</key> <string>wl-cal-brewery.jpg</string> <key>weblink</key>' +
					 '<string>http://www.caledonian-brewery.co.uk</string> </dict> <dict> ' +
					 '<key>title</key> <string>The Scotch Whisky Experience</string>' +
					 '<key>image</key> <string>wl-scottish-whisky.jpg</string> <key>weblink</key> ' +
					 '<string>http://www.whisky-heritage.co.uk</string> </dict> </array> </plist>';

// Init the PlistToJson class
var plistToJson = new PlistToJson();

// Tests
var runValidJsonObject = plistToJson.run(goodFilePath);

Ti.API.info(runValidJsonObject);

var runNoParam = plistToJson.run();

var runWrongFilePath = plistToJson.run(wrongFilePath);

Ti.API.info('--------------');

var testValidJsonObject = plistToJson.testFile(goodFilePath);

var testValidJsonString = plistToJson.testString(validXMLString);

alert('Check the project log to see the results...');
<|endoftext|>


<commit_before>ko.bindingHandlers.ckeditor = {
    init: function (element, valueAccessor, allBindingsAccessor, context) {
        var options = allBindingsAccessor().ckeditorOptions || {};
        var modelValue = valueAccessor();
        var value = ko.utils.unwrapObservable(valueAccessor());

        $(element).html(value);
        var editor = CKEDITOR.replace(element, {
            toolbar: 'Standard'
        });

        //handle edits made in the editor
        editor.on('change', function (e) {
            var self = this;
            if (ko.isWriteableObservable(self)) {
                self(e.editor.getData());
            }
        }, modelValue, element);

        //handle disposal (if KO removes by the template binding)
        ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
            if (editor) {
                CKEDITOR.remove(editor);
            };
        });
    },
    update: function (element, valueAccessor, allBindingsAccessor, context) {
        // handle programmatic updates to the observable
        var newValue = ko.utils.unwrapObservable(valueAccessor());
        var id = $(element).attr('id');

        if (CKEDITOR.instances[id].getData() != newValue)
            CKEDITOR.instances[id].setData(newValue);
    }
};

//ko.bindingHandlers.endereco = {
//    init: function (element, valueAccessor, allBindingsAccessor) {

//        //Register templates
//        //if ($('#addressForm').length == 0) {

//        //    //Coloca template
//        //    var script = document.createElement('script');
//        //    script.type = 'text/x-tmpl';
//        //    script.id = "template-addressForm";
//        //    $(script).text(templateLoad.AddressTemplate());
//        //    $("body").append(script);

//        //    //Registra local para aplicar template
//        //    var div = document.createElement('div');
//        //    div.id = "addressForm";
//        //    $(div).html(templateLoad.AddressTemplate());
//        //    $(".page-content").append(div);

//        //    ko.renderTemplate("template-addressForm", viewModel.addressCurrent, {}, $("#addressForm")[0], "replaceNode");
//        //}

//        var menuContextId = allBindingsAccessor().contextMenu;
//        $(element).contextmenu({
//            target: "#" + menuContextId,
//        });
//        $(element).prop('readonly', true);
//        $(element).after('' + core.culture.address_ToolTip() + '');

//        //Colocando informação de visualização
//        var logradouro = "";
//        var cidade = Enumerable.From(viewModel.CidadeList())
//            .Where(function (x) { return x.Cid_Cidade_Id() == valueAccessor().Cid_Cidade_Id() })
//            .FirstOrDefault();
//        var estado = Enumerable.From(viewModel.EstadoList())
//            .Where(function (x) { return x.Est_Estado_Id() == valueAccessor().Est_Estado_Id() })
//            .FirstOrDefault();
//        var cid_Name = cidade == null ? "" : cidade.Cid_Name();
//        var est_UF = estado == null ? "" : estado.Est_UF();
//        if (valueAccessor().End_Logradouro() != null || valueAccessor().End_Numero() != null)
//            logradouro = valueAccessor().End_Logradouro() + ", " + valueAccessor().End_Numero();
//        if(cid_Name != "" || est_UF != "")
//            logradouro += " - " + cid_Name + "/" + est_UF;
//        $(element).val(logradouro);

//        ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
//            //$(element).select2('destroy');
//        });
//    },
//    update: function (element) {
//        //$(element).trigger('change');
//    }
//};

ko.bindingHandlers.select2 = {
    init: function (element, valueAccessor) {
        $(element).select2(valueAccessor());

        ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
            $(element).select2('destroy');
        });
    },
    update: function (element) {
        $(element).trigger('change');
    }
};

ko.bindingHandlers.multiselect = {
    init: function (element, valueAccessor) {
        $(element).multiSelect(valueAccessor());

        if (valueAccessor().availableObs != null) {
            valueAccessor().availableObs.subscribe(function (value) {
                $(element).multiSelect('refresh');
            });
        }
        if (valueAccessor().selectedObs != null) {
            valueAccessor().selectedObs.subscribe(function (value) {
                $(element).multiSelect('refresh');
            });
        }

        ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
            $(element).multiSelect('destroy');
        });
    },
    update: function (element) {
        $(element).multiSelect('refresh');
    }
};

ko.bindingHandlers.colorpicker = {
    init: function (element, valueAccessor) {
        var value = ko.utils.unwrapObservable(valueAccessor());
        $(element).val(value);
        $(element).colorpicker();

        $(element).colorpicker().on('changeColor', function (ev) {
            $(element).val(ev.color.toHex());
            $(element).change();
        });

        ko.utils.registerEventHandler(element, "change", function () {
            var observable = valueAccessor();
            observable($(element).val());
        });

        ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
            $(element).colorpicker('hide');
        });
    },
    update: function (element, valueAccessor) {
        var value = ko.utils.unwrapObservable(valueAccessor());
        $(element).val(value);
        $(element).change();
    }
};

//ko.bindingHandlers.carousel = {

//    init: function (element, valueAccessor) {
//        if ($('#carouselView').length == 0) {
//            $("body").append(templateLoad.Carousel_ViewTemplate());
//        }
//        if ($('#template-carouselThumbnail').length == 0) {
//            var script = document.createElement('script');
//            script.type = 'text/x-tmpl';
//            script.id = "template-carouselThumbnail";
//            $(script).text(templateLoad.Carousel_ThumbnailTemplate());
//            $("body").append(script);
//        }

//        //$(element).append("

");
//        //var region = $(element).find('#thumbnailRegion')[0];
//        //ko.renderTemplate("template-carouselThumbnail", valueAccessor().observable, {}, region, "replaceNode");

//        $(element).append(templateLoad.Carousel_ThumbnailTemplate());

//        //$(element).find('.thumbnail').click(function () {
//        //    $('.modal-body').empty();
//        //    var title = $(this).parent('a').attr("title");
//        //    $('.modal-title').html(title);
//        //    $($(this).parents('div').html()).appendTo('.modal-body');
//        //    $('#myModal').modal({ show: true });
//        //});

//    },
//    update: function (element) {
//        //$(element).find('.thumbnail').click(function () {
//        //    $('.modal-body').empty();
//        //    var title = $(this).parent('a').attr("title");
//        //    $('.modal-title').html(title);
//        //    $($(this).parents('div').html()).appendTo('.modal-body');
//        //    $('#myModal').modal({ show: true });
//        //});
//    }

//}
//ko.bindingHandlers.fileupload = {
//    init: function (element, valueAccessor) {

//        //Register templates
//        if ($('#template-download').length == 0) {
//            var script = document.createElement('script');
//            script.type = 'text/x-tmpl';
//            script.id = "template-download";
//            $(script).text(templateLoad.FileUpload_DownloadTemplate());
//            $("body").append(script);
//        }
//        if ($('#template-upload').length == 0) {
//            var script = document.createElement('script');
//            script.type = 'text/x-tmpl';
//            script.id = "template-upload";
//            $(script).text(templateLoad.FileUpload_UploadTemplate());
//            $("body").append(script);
//        }

//        var defaults = {
//            disableImageResize: false,
//            autoUpload: true,
//            url: core.urlBaseWebApi() + "FileUpload"
//            , observable: viewModel != null && viewModel.FileUpload != null ? viewModel.FileUpload : null
//        };

//        defaults = $.extend(true, defaults, valueAccessor());

//        var observable = defaults.observable;//pode ser passado pela configuração

//        $(element).append(templateLoad.FileUpload());
//        $(element).fileupload(defaults)
//            .bind('fileuploaddone', function (e, data) {
//            })
//            .bind('fileuploadcompleted', function (e, data) {
//                $(data.context).find('.size').text('ok');
//                $(data.context).find('.name').text(data.result[0].displayName);
//                //data.result
//                var btnRemove = $(data.context).find('.glyphicon-ban-circle');
//                btnRemove.removeClass('glyphicon-ban-circle');
//                btnRemove.addClass('glyphicon-remove-circle');

//                var retorno = data.result[0];

//                //register in viewModel
//                if (observable != null) {
//                    observable.push(data.result[0]);
//                }

//                $(btnRemove).bind("click", function () {
//                    $.asyncRequest.delete({
//                        Url: core.urlBaseWebApi() + retorno.delete_url
//                    });
//                    observable.remove(function (item) { return item.name == retorno.name });
//                });
//            })
//        //.bind('fileuploadprocessdone', function (e, data) {
//        //    alert(data);
//        //})

//        ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
//            $(element).fileupload('destroy');
//        });
//    },
//    update: function (element) {
//        //$(element).multiSelect('refresh');
//    }
//};
if (ko.validation != null) {
    ko.validation.registerExtenders();
}<commit_msg>corrigindo nome<commit_after>ko.bindingHandlers.wysiwyg = {
    init: function (element, valueAccessor, allBindingsAccessor, context) {
        var options = allBindingsAccessor().ckeditorOptions || {};
        var modelValue = valueAccessor();
        var value = ko.utils.unwrapObservable(valueAccessor());

        $(element).html(value);
        var editor = CKEDITOR.replace(element, {
            toolbar: 'Standard'
        });

        //handle edits made in the editor
        editor.on('change', function (e) {
            var self = this;
            if (ko.isWriteableObservable(self)) {
                self(e.editor.getData());
            }
        }, modelValue, element);

        //handle disposal (if KO removes by the template binding)
        ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
            if (editor) {
                CKEDITOR.remove(editor);
            };
        });
    },
    update: function (element, valueAccessor, allBindingsAccessor, context) {
        // handle programmatic updates to the observable
        var newValue = ko.utils.unwrapObservable(valueAccessor());
        var id = $(element).attr('id');

        if (CKEDITOR.instances[id].getData() != newValue)
            CKEDITOR.instances[id].setData(newValue);
    }
};

//ko.bindingHandlers.endereco = {
//    init: function (element, valueAccessor, allBindingsAccessor) {

//        //Register templates
//        //if ($('#addressForm').length == 0) {

//        //    //Coloca template
//        //    var script = document.createElement('script');
//        //    script.type = 'text/x-tmpl';
//        //    script.id = "template-addressForm";
//        //    $(script).text(templateLoad.AddressTemplate());
//        //    $("body").append(script);

//        //    //Registra local para aplicar template
//        //    var div = document.createElement('div');
//        //    div.id = "addressForm";
//        //    $(div).html(templateLoad.AddressTemplate());
//        //    $(".page-content").append(div);

//        //    ko.renderTemplate("template-addressForm", viewModel.addressCurrent, {}, $("#addressForm")[0], "replaceNode");
//        //}

//        var menuContextId = allBindingsAccessor().contextMenu;
//        $(element).contextmenu({
//            target: "#" + menuContextId,
//        });
//        $(element).prop('readonly', true);
//        $(element).after('' + core.culture.address_ToolTip() + '');

//        //Colocando informação de visualização
//        var logradouro = "";
//        var cidade = Enumerable.From(viewModel.CidadeList())
//            .Where(function (x) { return x.Cid_Cidade_Id() == valueAccessor().Cid_Cidade_Id() })
//            .FirstOrDefault();
//        var estado = Enumerable.From(viewModel.EstadoList())
//            .Where(function (x) { return x.Est_Estado_Id() == valueAccessor().Est_Estado_Id() })
//            .FirstOrDefault();
//        var cid_Name = cidade == null ? "" : cidade.Cid_Name();
//        var est_UF = estado == null ? "" : estado.Est_UF();
//        if (valueAccessor().End_Logradouro() != null || valueAccessor().End_Numero() != null)
//            logradouro = valueAccessor().End_Logradouro() + ", " + valueAccessor().End_Numero();
//        if(cid_Name != "" || est_UF != "")
//            logradouro += " - " + cid_Name + "/" + est_UF;
//        $(element).val(logradouro);

//        ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
//            //$(element).select2('destroy');
//        });
//    },
//    update: function (element) {
//        //$(element).trigger('change');
//    }
//};

ko.bindingHandlers.select2 = {
    init: function (element, valueAccessor) {
        $(element).select2(valueAccessor());

        ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
            $(element).select2('destroy');
        });
    },
    update: function (element) {
        $(element).trigger('change');
    }
};

ko.bindingHandlers.multiselect = {
    init: function (element, valueAccessor) {
        $(element).multiSelect(valueAccessor());

        if (valueAccessor().availableObs != null) {
            valueAccessor().availableObs.subscribe(function (value) {
                $(element).multiSelect('refresh');
            });
        }
        if (valueAccessor().selectedObs != null) {
            valueAccessor().selectedObs.subscribe(function (value) {
                $(element).multiSelect('refresh');
            });
        }

        ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
            $(element).multiSelect('destroy');
        });
    },
    update: function (element) {
        $(element).multiSelect('refresh');
    }
};

ko.bindingHandlers.colorpicker = {
    init: function (element, valueAccessor) {
        var value = ko.utils.unwrapObservable(valueAccessor());
        $(element).val(value);
        $(element).colorpicker();

        $(element).colorpicker().on('changeColor', function (ev) {
            $(element).val(ev.color.toHex());
            $(element).change();
        });

        ko.utils.registerEventHandler(element, "change", function () {
            var observable = valueAccessor();
            observable($(element).val());
        });

        ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
            $(element).colorpicker('hide');
        });
    },
    update: function (element, valueAccessor) {
        var value = ko.utils.unwrapObservable(valueAccessor());
        $(element).val(value);
        $(element).change();
    }
};

//ko.bindingHandlers.carousel = {

//    init: function (element, valueAccessor) {
//        if ($('#carouselView').length == 0) {
//            $("body").append(templateLoad.Carousel_ViewTemplate());
//        }
//        if ($('#template-carouselThumbnail').length == 0) {
//            var script = document.createElement('script');
//            script.type = 'text/x-tmpl';
//            script.id = "template-carouselThumbnail";
//            $(script).text(templateLoad.Carousel_ThumbnailTemplate());
//            $("body").append(script);
//        }

//        //$(element).append("

");
//        //var region = $(element).find('#thumbnailRegion')[0];
//        //ko.renderTemplate("template-carouselThumbnail", valueAccessor().observable, {}, region, "replaceNode");

//        $(element).append(templateLoad.Carousel_ThumbnailTemplate());

//        //$(element).find('.thumbnail').click(function () {
//        //    $('.modal-body').empty();
//        //    var title = $(this).parent('a').attr("title");
//        //    $('.modal-title').html(title);
//        //    $($(this).parents('div').html()).appendTo('.modal-body');
//        //    $('#myModal').modal({ show: true });
//        //});

//    },
//    update: function (element) {
//        //$(element).find('.thumbnail').click(function () {
//        //    $('.modal-body').empty();
//        //    var title = $(this).parent('a').attr("title");
//        //    $('.modal-title').html(title);
//        //    $($(this).parents('div').html()).appendTo('.modal-body');
//        //    $('#myModal').modal({ show: true });
//        //});
//    }

//}
//ko.bindingHandlers.fileupload = {
//    init: function (element, valueAccessor) {

//        //Register templates
//        if ($('#template-download').length == 0) {
//            var script = document.createElement('script');
//            script.type = 'text/x-tmpl';
//            script.id = "template-download";
//            $(script).text(templateLoad.FileUpload_DownloadTemplate());
//            $("body").append(script);
//        }
//        if ($('#template-upload').length == 0) {
//            var script = document.createElement('script');
//            script.type = 'text/x-tmpl';
//            script.id = "template-upload";
//            $(script).text(templateLoad.FileUpload_UploadTemplate());
//            $("body").append(script);
//        }

//        var defaults = {
//            disableImageResize: false,
//            autoUpload: true,
//            url: core.urlBaseWebApi() + "FileUpload"
//            , observable: viewModel != null && viewModel.FileUpload != null ? viewModel.FileUpload : null
//        };

//        defaults = $.extend(true, defaults, valueAccessor());

//        var observable = defaults.observable;//pode ser passado pela configuração

//        $(element).append(templateLoad.FileUpload());
//        $(element).fileupload(defaults)
//            .bind('fileuploaddone', function (e, data) {
//            })
//            .bind('fileuploadcompleted', function (e, data) {
//                $(data.context).find('.size').text('ok');
//                $(data.context).find('.name').text(data.result[0].displayName);
//                //data.result
//                var btnRemove = $(data.context).find('.glyphicon-ban-circle');
//                btnRemove.removeClass('glyphicon-ban-circle');
//                btnRemove.addClass('glyphicon-remove-circle');

//                var retorno = data.result[0];

//                //register in viewModel
//                if (observable != null) {
//                    observable.push(data.result[0]);
//                }

//                $(btnRemove).bind("click", function () {
//                    $.asyncRequest.delete({
//                        Url: core.urlBaseWebApi() + retorno.delete_url
//                    });
//                    observable.remove(function (item) { return item.name == retorno.name });
//                });
//            })
//        //.bind('fileuploadprocessdone', function (e, data) {
//        //    alert(data);
//        //})

//        ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
//            $(element).fileupload('destroy');
//        });
//    },
//    update: function (element) {
//        //$(element).multiSelect('refresh');
//    }
//};
if (ko.validation != null) {
    ko.validation.registerExtenders();
}<|endoftext|>


<commit_before>var files = [
	{size:199203743, file:"Agraulis_vanillae_helico2_-_scaffolds.fa.gz"},
	{size:2463800, file:"Bicyclus_anynana_nBa.0.1_-_annotations.gff3.gz"},
	{size:3595365, file:"Bicyclus_anynana_nBa.0.1_-_cds.fa.gz"},
	{size:3599352, file:"Bicyclus_anynana_nBa.0.1_-_cds_translationid.fa.gz"},
	{size:2430037, file:"Bicyclus_anynana_nBa.0.1_-_proteins.fa.gz"},
	{size:124508456, file:"Bicyclus_anynana_nBa.0.1_-_scaffolds.fa.gz"},
	{size:5294217, file:"Bombyx_mori_-_cds.fa.gz"},
	{size:5299461, file:"Bombyx_mori_-_cds_translationid.fa.gz"},
	{size:3584771, file:"Bombyx_mori_-_proteins.fa.gz"},
	{size:124508833, file:"Bombyx_mori_-_scaffolds.fa.gz"},
	{size:1538595, file:"Chilo_suppressalis_CsuOGS1.0_-_annotations.gff3.gz"},
	{size:2710787, file:"Chilo_suppressalis_CsuOGS1.0_-_cds.fa.gz"},
	{size:2715059, file:"Chilo_suppressalis_CsuOGS1.0_-_cds_translationid.fa.gz"},
	{size:1841833, file:"Chilo_suppressalis_CsuOGS1.0_-_proteins.fa.gz"},
	{size:97453071, file:"Chilo_suppressalis_CsuOGS1.0_-_scaffolds.fa.gz"},
	{size:5951218, file:"Danaus_plexippus_-_cds.fa.gz"},
	{size:5956192, file:"Danaus_plexippus_-_cds_translationid.fa.gz"},
	{size:4017779, file:"Danaus_plexippus_-_proteins.fa.gz"},
	{size:78278098, file:"Danaus_plexippus_-_scaffolds.fa.gz"},
	{size:254282575, file:"Eueides_tales_helico2_-_scaffolds.fa.gz"},
	{size:129854244, file:"Heliconius_besckei_helico2_-_scaffolds.fa.gz"},
	{size:180937916, file:"Heliconius_burneyi_helico2_-_scaffolds.fa.gz"},
	{size:169045538, file:"Heliconius_cydno_helico2_-_scaffolds.fa.gz"},
	{size:154098471, file:"Heliconius_demeter_helico2_-_scaffolds.fa.gz"},
	{size:217475369, file:"Heliconius_elevatus_helico2_-_scaffolds.fa.gz"},
	{size:186584009, file:"Heliconius_erato_helico2_-_scaffolds.fa.gz"},
	{size:252294336, file:"Heliconius_erato_himera_helico2_-_scaffolds.fa.gz"},
	{size:161272311, file:"Heliconius_hecale_helico1_-_scaffolds.fa.gz"},
	{size:143474565, file:"Heliconius_himera_helico1_-_scaffolds.fa.gz"},
	{size:5099943, file:"Heliconius_melpomene_-_cds.fa.gz"},
	{size:5104276, file:"Heliconius_melpomene_-_cds_translationid.fa.gz"},
	{size:120627641, file:"Heliconius_melpomene_helico2_-_scaffolds.fa.gz"},
	{size:2224431, file:"Heliconius_melpomene_Hmel2_-_annotations.gff3.gz"},
	{size:4870257, file:"Heliconius_melpomene_Hmel2_-_cds.fa.gz"},
	{size:4875915, file:"Heliconius_melpomene_Hmel2_-_cds_translationid.fa.gz"},
	{size:3269084, file:"Heliconius_melpomene_Hmel2_-_proteins.fa.gz"},
	{size:78354330, file:"Heliconius_melpomene_Hmel2_-_scaffolds.fa.gz"},
	{size:3433031, file:"Heliconius_melpomene_-_proteins.fa.gz"},
	{size:77174375, file:"Heliconius_melpomene_-_scaffolds.fa.gz"},
	{size:150592036, file:"Heliconius_numata_helico2_-_scaffolds.fa.gz"},
	{size:179956443, file:"Heliconius_pardalinus_helico2_-_scaffolds.fa.gz"},
	{size:243966374, file:"Heliconius_telesiphe_helico2_-_scaffolds.fa.gz"},
	{size:132293669, file:"Heliconius_timareta_helico2_-_scaffolds.fa.gz"},
	{size:156685873, file:"Laparus_doris_helico2_-_scaffolds.fa.gz"},
	{size:2380794, file:"Lerema_accius_v1.1_-_annotations.gff3.gz"},
	{size:6190490, file:"Lerema_accius_v1.1_-_cds.fa.gz"},
	{size:6196438, file:"Lerema_accius_v1.1_-_cds_translationid.fa.gz"},
	{size:4167403, file:"Lerema_accius_v1.1_-_proteins.fa.gz"},
	{size:84315486, file:"Lerema_accius_v1.1_-_scaffolds.fa.gz"},
	{size:5354669, file:"Manduca_sexta_Msex_1.0_-_annotations.gff3.gz"},
	{size:6382415, file:"Manduca_sexta_Msex_1.0_-_cds.fa.gz"},
	{size:6390599, file:"Manduca_sexta_Msex_1.0_-_cds_translationid.fa.gz"},
	{size:4438082, file:"Manduca_sexta_Msex_1.0_-_proteins.fa.gz"},
	{size:115522877, file:"Manduca_sexta_Msex_1.0_-_scaffolds.fa.gz"},
	{size:4797821, file:"Melitaea_cinxia_-_cds.fa.gz"},
	{size:4801526, file:"Melitaea_cinxia_-_cds_translationid.fa.gz"},
	{size:3256548, file:"Melitaea_cinxia_-_proteins.fa.gz"},
	{size:104636312, file:"Melitaea_cinxia_-_scaffolds.fa.gz"},
	{size:333980318, file:"Neruda_aoede_helico2_-_scaffolds.fa.gz"},
	{size:2280010, file:"Papilio_glaucus_v1.1_-_annotations.gff3.gz"},
	{size:5658735, file:"Papilio_glaucus_v1.1_-_cds.fa.gz"},
	{size:5662957, file:"Papilio_glaucus_v1.1_-_cds_translationid.fa.gz"},
	{size:3822943, file:"Papilio_glaucus_v1.1_-_proteins.fa.gz"},
	{size:105783471, file:"Papilio_glaucus_v1.1_-_scaffolds.fa.gz"},
	{size:5158751, file:"Pieris_napi_DAS5_-_annotations.gff3.gz"},
	{size:4628895, file:"Pieris_napi_DAS5_-_cds.fa.gz"},
	{size:4634332, file:"Pieris_napi_DAS5_-_cds_translationid.fa.gz"},
	{size:3087503, file:"Pieris_napi_DAS5_-_proteins.fa.gz"},
	{size:87177885, file:"Pieris_napi_DAS5_-_scaffolds.fa.gz"},
	{size:4053967, file:"Plodia_interpunctella_v1_-_annotations.gff3.gz"},
	{size:6345748, file:"Plodia_interpunctella_v1_-_cds.fa.gz"},
	{size:6355802, file:"Plodia_interpunctella_v1_-_cds_translationid.fa.gz"},
	{size:4305707, file:"Plodia_interpunctella_v1_-_proteins.fa.gz"},
	{size:91139740, file:"Plodia_interpunctella_v1_-_scaffolds.fa.gz"},
	{size:3638005, file:"Plutella_xylostella_DBM_FJ_v1.1_-_annotations.gff3.gz"},
	{size:7260277, file:"Plutella_xylostella_DBM_FJ_v1.1_-_cds.fa.gz"},
	{size:7268507, file:"Plutella_xylostella_DBM_FJ_v1.1_-_cds_translationid.fa.gz"},
	{size:4887224, file:"Plutella_xylostella_DBM_FJ_v1.1_-_proteins.fa.gz"},
	{size:111435224, file:"Plutella_xylostella_DBM_FJ_v1.1_-_scaffolds.fa.gz"}
]<commit_msg>remove P. napi from bulk downloads<commit_after>var files = [
	{size:199203743, file:"Agraulis_vanillae_helico2_-_scaffolds.fa.gz"},
	{size:2463800, file:"Bicyclus_anynana_nBa.0.1_-_annotations.gff3.gz"},
	{size:3595365, file:"Bicyclus_anynana_nBa.0.1_-_cds.fa.gz"},
	{size:3599352, file:"Bicyclus_anynana_nBa.0.1_-_cds_translationid.fa.gz"},
	{size:2430037, file:"Bicyclus_anynana_nBa.0.1_-_proteins.fa.gz"},
	{size:124508456, file:"Bicyclus_anynana_nBa.0.1_-_scaffolds.fa.gz"},
	{size:5294217, file:"Bombyx_mori_-_cds.fa.gz"},
	{size:5299461, file:"Bombyx_mori_-_cds_translationid.fa.gz"},
	{size:3584771, file:"Bombyx_mori_-_proteins.fa.gz"},
	{size:124508833, file:"Bombyx_mori_-_scaffolds.fa.gz"},
	{size:1538595, file:"Chilo_suppressalis_CsuOGS1.0_-_annotations.gff3.gz"},
	{size:2710787, file:"Chilo_suppressalis_CsuOGS1.0_-_cds.fa.gz"},
	{size:2715059, file:"Chilo_suppressalis_CsuOGS1.0_-_cds_translationid.fa.gz"},
	{size:1841833, file:"Chilo_suppressalis_CsuOGS1.0_-_proteins.fa.gz"},
	{size:97453071, file:"Chilo_suppressalis_CsuOGS1.0_-_scaffolds.fa.gz"},
	{size:5951218, file:"Danaus_plexippus_-_cds.fa.gz"},
	{size:5956192, file:"Danaus_plexippus_-_cds_translationid.fa.gz"},
	{size:4017779, file:"Danaus_plexippus_-_proteins.fa.gz"},
	{size:78278098, file:"Danaus_plexippus_-_scaffolds.fa.gz"},
	{size:254282575, file:"Eueides_tales_helico2_-_scaffolds.fa.gz"},
	{size:129854244, file:"Heliconius_besckei_helico2_-_scaffolds.fa.gz"},
	{size:180937916, file:"Heliconius_burneyi_helico2_-_scaffolds.fa.gz"},
	{size:169045538, file:"Heliconius_cydno_helico2_-_scaffolds.fa.gz"},
	{size:154098471, file:"Heliconius_demeter_helico2_-_scaffolds.fa.gz"},
	{size:217475369, file:"Heliconius_elevatus_helico2_-_scaffolds.fa.gz"},
	{size:186584009, file:"Heliconius_erato_helico2_-_scaffolds.fa.gz"},
	{size:252294336, file:"Heliconius_erato_himera_helico2_-_scaffolds.fa.gz"},
	{size:161272311, file:"Heliconius_hecale_helico1_-_scaffolds.fa.gz"},
	{size:143474565, file:"Heliconius_himera_helico1_-_scaffolds.fa.gz"},
	{size:5099943, file:"Heliconius_melpomene_-_cds.fa.gz"},
	{size:5104276, file:"Heliconius_melpomene_-_cds_translationid.fa.gz"},
	{size:120627641, file:"Heliconius_melpomene_helico2_-_scaffolds.fa.gz"},
	{size:2224431, file:"Heliconius_melpomene_Hmel2_-_annotations.gff3.gz"},
	{size:4870257, file:"Heliconius_melpomene_Hmel2_-_cds.fa.gz"},
	{size:4875915, file:"Heliconius_melpomene_Hmel2_-_cds_translationid.fa.gz"},
	{size:3269084, file:"Heliconius_melpomene_Hmel2_-_proteins.fa.gz"},
	{size:78354330, file:"Heliconius_melpomene_Hmel2_-_scaffolds.fa.gz"},
	{size:3433031, file:"Heliconius_melpomene_-_proteins.fa.gz"},
	{size:77174375, file:"Heliconius_melpomene_-_scaffolds.fa.gz"},
	{size:150592036, file:"Heliconius_numata_helico2_-_scaffolds.fa.gz"},
	{size:179956443, file:"Heliconius_pardalinus_helico2_-_scaffolds.fa.gz"},
	{size:243966374, file:"Heliconius_telesiphe_helico2_-_scaffolds.fa.gz"},
	{size:132293669, file:"Heliconius_timareta_helico2_-_scaffolds.fa.gz"},
	{size:156685873, file:"Laparus_doris_helico2_-_scaffolds.fa.gz"},
	{size:2380794, file:"Lerema_accius_v1.1_-_annotations.gff3.gz"},
	{size:6190490, file:"Lerema_accius_v1.1_-_cds.fa.gz"},
	{size:6196438, file:"Lerema_accius_v1.1_-_cds_translationid.fa.gz"},
	{size:4167403, file:"Lerema_accius_v1.1_-_proteins.fa.gz"},
	{size:84315486, file:"Lerema_accius_v1.1_-_scaffolds.fa.gz"},
	{size:5354669, file:"Manduca_sexta_Msex_1.0_-_annotations.gff3.gz"},
	{size:6382415, file:"Manduca_sexta_Msex_1.0_-_cds.fa.gz"},
	{size:6390599, file:"Manduca_sexta_Msex_1.0_-_cds_translationid.fa.gz"},
	{size:4438082, file:"Manduca_sexta_Msex_1.0_-_proteins.fa.gz"},
	{size:115522877, file:"Manduca_sexta_Msex_1.0_-_scaffolds.fa.gz"},
	{size:4797821, file:"Melitaea_cinxia_-_cds.fa.gz"},
	{size:4801526, file:"Melitaea_cinxia_-_cds_translationid.fa.gz"},
	{size:3256548, file:"Melitaea_cinxia_-_proteins.fa.gz"},
	{size:104636312, file:"Melitaea_cinxia_-_scaffolds.fa.gz"},
	{size:333980318, file:"Neruda_aoede_helico2_-_scaffolds.fa.gz"},
	{size:2280010, file:"Papilio_glaucus_v1.1_-_annotations.gff3.gz"},
	{size:5658735, file:"Papilio_glaucus_v1.1_-_cds.fa.gz"},
	{size:5662957, file:"Papilio_glaucus_v1.1_-_cds_translationid.fa.gz"},
	{size:3822943, file:"Papilio_glaucus_v1.1_-_proteins.fa.gz"},
	{size:105783471, file:"Papilio_glaucus_v1.1_-_scaffolds.fa.gz"},
	{size:4053967, file:"Plodia_interpunctella_v1_-_annotations.gff3.gz"},
	{size:6345748, file:"Plodia_interpunctella_v1_-_cds.fa.gz"},
	{size:6355802, file:"Plodia_interpunctella_v1_-_cds_translationid.fa.gz"},
	{size:4305707, file:"Plodia_interpunctella_v1_-_proteins.fa.gz"},
	{size:91139740, file:"Plodia_interpunctella_v1_-_scaffolds.fa.gz"},
	{size:3638005, file:"Plutella_xylostella_DBM_FJ_v1.1_-_annotations.gff3.gz"},
	{size:7260277, file:"Plutella_xylostella_DBM_FJ_v1.1_-_cds.fa.gz"},
	{size:7268507, file:"Plutella_xylostella_DBM_FJ_v1.1_-_cds_translationid.fa.gz"},
	{size:4887224, file:"Plutella_xylostella_DBM_FJ_v1.1_-_proteins.fa.gz"},
	{size:111435224, file:"Plutella_xylostella_DBM_FJ_v1.1_-_scaffolds.fa.gz"}
]<|endoftext|>


<commit_before>/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
 * full list of contributors). Published under the 2-clause BSD license.
 * See license.txt in the OpenLayers distribution or repository for the
 * full text of the license. */

/**
 * @requires OpenLayers/Layer/Google.js
 */

/**
 * Constant: OpenLayers.Layer.Google.v3
 *
 * Mixin providing functionality specific to the Google Maps API v3.
 *
 * To use this layer, you must include the GMaps v3 API in your html. To match
 * Google's zoom animation better with OpenLayers animated zooming, configure
 * your map with a zoomDuration of 10:
 *
 * (code)
 * new OpenLayers.Map('map', {zoomDuration: 10});
 * (end)
 *
 * Note that this layer configures the google.maps.map object with the
 * "disableDefaultUI" option set to true. Using UI controls that the Google
 * Maps API provides is not supported by the OpenLayers API.
 */
OpenLayers.Layer.Google.v3 = {

    /**
     * Constant: DEFAULTS
     * {Object} It is not recommended to change the properties set here. Note
     * that Google.v3 layers only work when sphericalMercator is set to true.
     *
     * (code)
     * {
     *     sphericalMercator: true,
     *     projection: "EPSG:900913"
     * }
     * (end)
     */
    DEFAULTS: {
        sphericalMercator: true,
        projection: "EPSG:900913"
    },

    /**
     * APIProperty: animationEnabled
     * {Boolean} If set to true, the transition between zoom levels will be
     *     animated (if supported by the GMaps API for the device used). Set to
     *     false to match the zooming experience of other layer types. Default
     *     is true. Note that the GMaps API does not give us control over zoom
     *     animation, so if set to false, when zooming, this will make the
     *     layer temporarily invisible, wait until GMaps reports the map being
     *     idle, and make it visible again. The result will be a blank layer
     *     for a few moments while zooming.
     */
    animationEnabled: true,

    /**
     * Method: loadMapObject
     * Load the GMap and register appropriate event listeners.
     */
    loadMapObject: function() {
        if (!this.type) {
            this.type = google.maps.MapTypeId.ROADMAP;
        }
        var mapObject;
        var cache = OpenLayers.Layer.Google.cache[this.map.id];
        if (cache) {
            // there are already Google layers added to this map
            mapObject = cache.mapObject;
            // increment the layer count
            ++cache.count;
        } else {
            // this is the first Google layer for this map
            // create GMap
            var center = this.map.getCenter();
            var container = document.createElement('div');
            container.className = "olForeignContainer";
            container.style.width = '100%';
            container.style.height = '100%';
            mapObject = new google.maps.Map(container, {
                center: center ?
                    new google.maps.LatLng(center.lat, center.lon) :
                    new google.maps.LatLng(0, 0),
                zoom: this.map.getZoom() || 0,
                mapTypeId: this.type,
                disableDefaultUI: true,
                keyboardShortcuts: false,
                draggable: false,
                disableDoubleClickZoom: true,
                scrollwheel: false,
                streetViewControl: false,
                tilt: (this.useTiltImages ? 45: 0)
            });
            var googleControl = document.createElement('div');
            googleControl.style.width = '100%';
            googleControl.style.height = '100%';
            mapObject.controls[google.maps.ControlPosition.TOP_LEFT].push(googleControl);

            // cache elements for use by any other google layers added to
            // this same map
            cache = {
                googleControl: googleControl,
                mapObject: mapObject,
                count: 1
            };
            OpenLayers.Layer.Google.cache[this.map.id] = cache;
        }
        this.mapObject = mapObject;
        this.setGMapVisibility(this.visibility);
    },

    /**
     * APIMethod: onMapResize
     */
    onMapResize: function() {
        if (this.visibility) {
            google.maps.event.trigger(this.mapObject, "resize");
        }
    },

    /**
     * Method: setGMapVisibility
     * Display the GMap container and associated elements.
     *
     * Parameters:
     * visible - {Boolean} Display the GMap elements.
     */
    setGMapVisibility: function(visible) {
        var cache = OpenLayers.Layer.Google.cache[this.map.id];
        var map = this.map;
        if (cache) {
            var type = this.type;
            var layers = map.layers;
            var layer;
            for (var i=layers.length-1; i>=0; --i) {
                layer = layers[i];
                if (layer instanceof OpenLayers.Layer.Google &&
                            layer.visibility === true && layer.inRange === true) {
                    type = layer.type;
                    visible = true;
                    break;
                }
            }
            var container = this.mapObject.getDiv();
            if (visible === true) {
                //see: https://github.com/openlayers/openlayers/issues/1450#issuecomment-146207698
                if (container.parentNode !== map.div) {
                    if (!cache.rendered) {
                        var me = this;
                        google.maps.event.addListenerOnce(this.mapObject, 'tilesloaded', function() {
                            cache.rendered = true;
                            me.setGMapVisibility(me.getVisibility());
                            me.moveTo(me.map.getCenter());
                            cache.googleControl.appendChild(map.viewPortDiv);
                        });
                    } else {
                        cache.googleControl.appendChild(map.viewPortDiv);
                    }
                    map.div.appendChild(container);
                    google.maps.event.trigger(this.mapObject, 'resize');
                }
                this.mapObject.setMapTypeId(type);
            } else if (cache.googleControl.hasChildNodes()) {
                map.div.appendChild(map.viewPortDiv);
                map.div.removeChild(container);
            }
        }
    },

    /**
     * Method: getMapContainer
     *
     * Returns:
     * {DOMElement} the GMap container's div
     */
    getMapContainer: function() {
        return this.mapObject.getDiv();
    },

  //
  // TRANSLATION: MapObject Bounds <-> OpenLayers.Bounds
  //

    /**
     * APIMethod: getMapObjectBoundsFromOLBounds
     *
     * Parameters:
     * olBounds - {<OpenLayers.Bounds>}
     *
     * Returns:
     * {Object} A MapObject Bounds, translated from olBounds
     *          Returns null if null value is passed in
     */
    getMapObjectBoundsFromOLBounds: function(olBounds) {
        var moBounds = null;
        if (olBounds != null) {
            var sw = this.sphericalMercator ?
              this.inverseMercator(olBounds.bottom, olBounds.left) :
              new OpenLayers.LonLat(olBounds.bottom, olBounds.left);
            var ne = this.sphericalMercator ?
              this.inverseMercator(olBounds.top, olBounds.right) :
              new OpenLayers.LonLat(olBounds.top, olBounds.right);
            moBounds = new google.maps.LatLngBounds(
                new google.maps.LatLng(sw.lat, sw.lon),
                new google.maps.LatLng(ne.lat, ne.lon)
            );
        }
        return moBounds;
    },

    /************************************
     *                                  *
     *   MapObject Interface Controls   *
     *                                  *
     ************************************/

  // LonLat - Pixel Translation

    /**
     * APIMethod: getMapObjectLonLatFromMapObjectPixel
     *
     * Parameters:
     * moPixel - {Object} MapObject Pixel format
     *
     * Returns:
     * {Object} MapObject LonLat translated from MapObject Pixel
     */
    getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
        var size = this.map.getSize();
        var lon = this.getLongitudeFromMapObjectLonLat(this.mapObject.center);
        var lat = this.getLatitudeFromMapObjectLonLat(this.mapObject.center);
        var res = this.map.getResolution();

        var delta_x = moPixel.x - (size.w / 2);
        var delta_y = moPixel.y - (size.h / 2);

        var lonlat = new OpenLayers.LonLat(
            lon + delta_x * res,
            lat - delta_y * res
        );

        if (this.wrapDateLine) {
            lonlat = lonlat.wrapDateLine(this.maxExtent);
        }
        return this.getMapObjectLonLatFromLonLat(lonlat.lon, lonlat.lat);
    },

    /**
     * APIMethod: getMapObjectPixelFromMapObjectLonLat
     *
     * Parameters:
     * moLonLat - {Object} MapObject LonLat format
     *
     * Returns:
     * {Object} MapObject Pixel transtlated from MapObject LonLat
     */
    getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
        var lon = this.getLongitudeFromMapObjectLonLat(moLonLat);
        var lat = this.getLatitudeFromMapObjectLonLat(moLonLat);
        var res = this.map.getResolution();
        var extent = this.map.getExtent();
        return this.getMapObjectPixelFromXY((1/res * (lon - extent.left)),
                                            (1/res * (extent.top - lat)));
    },

    /**
     * APIMethod: setMapObjectCenter
     * Set the mapObject to the specified center and zoom
     *
     * Parameters:
     * center - {Object} MapObject LonLat format
     * zoom - {int} MapObject zoom format
     */
    setMapObjectCenter: function(center, zoom) {
        if (this.animationEnabled === false && zoom != this.mapObject.zoom) {
            var mapContainer = this.getMapContainer();
            google.maps.event.addListenerOnce(
                this.mapObject,
                "idle",
                function() {
                    mapContainer.style.visibility = "";
                }
            );
            mapContainer.style.visibility = "hidden";
        }
        this.mapObject.setOptions({
            center: center,
            zoom: zoom
        });
    },

  // Bounds

    /**
     * APIMethod: getMapObjectZoomFromMapObjectBounds
     *
     * Parameters:
     * moBounds - {Object} MapObject Bounds format
     *
     * Returns:
     * {Object} MapObject Zoom for specified MapObject Bounds
     */
    getMapObjectZoomFromMapObjectBounds: function(moBounds) {
        return this.mapObject.getBoundsZoomLevel(moBounds);
    },

    /************************************
     *                                  *
     *       MapObject Primitives       *
     *                                  *
     ************************************/

  // LonLat

    /**
     * APIMethod: getMapObjectLonLatFromLonLat
     *
     * Parameters:
     * lon - {Float}
     * lat - {Float}
     *
     * Returns:
     * {Object} MapObject LonLat built from lon and lat params
     */
    getMapObjectLonLatFromLonLat: function(lon, lat) {
        var gLatLng;
        if(this.sphericalMercator) {
            var lonlat = this.inverseMercator(lon, lat);
            gLatLng = new google.maps.LatLng(lonlat.lat, lonlat.lon);
        } else {
            gLatLng = new google.maps.LatLng(lat, lon);
        }
        return gLatLng;
    },

  // Pixel

    /**
     * APIMethod: getMapObjectPixelFromXY
     *
     * Parameters:
     * x - {Integer}
     * y - {Integer}
     *
     * Returns:
     * {Object} MapObject Pixel from x and y parameters
     */
    getMapObjectPixelFromXY: function(x, y) {
        return new google.maps.Point(x, y);
    }

};
<commit_msg>adjusting openlayers/google api fix<commit_after>/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
 * full list of contributors). Published under the 2-clause BSD license.
 * See license.txt in the OpenLayers distribution or repository for the
 * full text of the license. */

/**
 * @requires OpenLayers/Layer/Google.js
 */

/**
 * Constant: OpenLayers.Layer.Google.v3
 *
 * Mixin providing functionality specific to the Google Maps API v3.
 *
 * To use this layer, you must include the GMaps v3 API in your html. To match
 * Google's zoom animation better with OpenLayers animated zooming, configure
 * your map with a zoomDuration of 10:
 *
 * (code)
 * new OpenLayers.Map('map', {zoomDuration: 10});
 * (end)
 *
 * Note that this layer configures the google.maps.map object with the
 * "disableDefaultUI" option set to true. Using UI controls that the Google
 * Maps API provides is not supported by the OpenLayers API.
 */
OpenLayers.Layer.Google.v3 = {

    /**
     * Constant: DEFAULTS
     * {Object} It is not recommended to change the properties set here. Note
     * that Google.v3 layers only work when sphericalMercator is set to true.
     *
     * (code)
     * {
     *     sphericalMercator: true,
     *     projection: "EPSG:900913"
     * }
     * (end)
     */
    DEFAULTS: {
        sphericalMercator: true,
        projection: "EPSG:900913"
    },

    /**
     * APIProperty: animationEnabled
     * {Boolean} If set to true, the transition between zoom levels will be
     *     animated (if supported by the GMaps API for the device used). Set to
     *     false to match the zooming experience of other layer types. Default
     *     is true. Note that the GMaps API does not give us control over zoom
     *     animation, so if set to false, when zooming, this will make the
     *     layer temporarily invisible, wait until GMaps reports the map being
     *     idle, and make it visible again. The result will be a blank layer
     *     for a few moments while zooming.
     */
    animationEnabled: true,

    /**
     * Method: loadMapObject
     * Load the GMap and register appropriate event listeners.
     */
    loadMapObject: function() {
        if (!this.type) {
            this.type = google.maps.MapTypeId.ROADMAP;
        }
        var mapObject;
        var cache = OpenLayers.Layer.Google.cache[this.map.id];
        if (cache) {
            // there are already Google layers added to this map
            mapObject = cache.mapObject;
            // increment the layer count
            ++cache.count;
        } else {
            // this is the first Google layer for this map
            // create GMap
            var center = this.map.getCenter();
            var container = document.createElement('div');
            container.className = "olForeignContainer";
            container.style.width = '100%';
            container.style.height = '100%';
            mapObject = new google.maps.Map(container, {
                center: center ?
                    new google.maps.LatLng(center.lat, center.lon) :
                    new google.maps.LatLng(0, 0),
                zoom: this.map.getZoom() || 0,
                mapTypeId: this.type,
                disableDefaultUI: true,
                keyboardShortcuts: false,
                draggable: false,
                disableDoubleClickZoom: true,
                scrollwheel: false,
                streetViewControl: false,
                tilt: (this.useTiltImages ? 45: 0)
            });
            var googleControl = document.createElement('div');
            googleControl.style.width = '100%';
            googleControl.style.height = '100%';
            mapObject.controls[google.maps.ControlPosition.TOP_LEFT].push(googleControl);

            // cache elements for use by any other google layers added to
            // this same map
            cache = {
                googleControl: googleControl,
                mapObject: mapObject,
                count: 1
            };
            OpenLayers.Layer.Google.cache[this.map.id] = cache;
        }
        this.mapObject = mapObject;
        this.setGMapVisibility(this.visibility);
    },

    /**
     * APIMethod: onMapResize
     */
    onMapResize: function() {
        if (this.visibility) {
            google.maps.event.trigger(this.mapObject, "resize");
        }
    },

    /**
     * Method: setGMapVisibility
     * Display the GMap container and associated elements.
     *
     * Parameters:
     * visible - {Boolean} Display the GMap elements.
     */
    setGMapVisibility: function(visible) {
        var cache = OpenLayers.Layer.Google.cache[this.map.id];
        var map = this.map;
        if (cache) {
            var type = this.type;
            var layers = map.layers;
            var layer;
            for (var i=layers.length-1; i>=0; --i) {
                layer = layers[i];
                if (layer instanceof OpenLayers.Layer.Google &&
                            layer.visibility === true && layer.inRange === true) {
                    type = layer.type;
                    visible = true;
                    break;
                }
            }
            var container = this.mapObject.getDiv();
            if (visible === true) {
                //see: https://github.com/openlayers/openlayers/issues/1450#issuecomment-146207698
                if (container.parentNode !== map.div) {
                    if (!cache.rendered) {
                        var me = this;
                        google.maps.event.addListenerOnce(this.mapObject, 'tilesloaded', function() {
                            cache.rendered = true;
                            me.setGMapVisibility(me.getVisibility());
                            me.moveTo(me.map.getCenter());
                        });
                    }
                    map.div.appendChild(container);
                    cache.googleControl.appendChild(map.viewPortDiv);
                    google.maps.event.trigger(this.mapObject, 'resize');
                }
                this.mapObject.setMapTypeId(type);
            } else if (cache.googleControl.hasChildNodes()) {
                map.div.appendChild(map.viewPortDiv);
                map.div.removeChild(container);
            }
        }
    },

    /**
     * Method: getMapContainer
     *
     * Returns:
     * {DOMElement} the GMap container's div
     */
    getMapContainer: function() {
        return this.mapObject.getDiv();
    },

  //
  // TRANSLATION: MapObject Bounds <-> OpenLayers.Bounds
  //

    /**
     * APIMethod: getMapObjectBoundsFromOLBounds
     *
     * Parameters:
     * olBounds - {<OpenLayers.Bounds>}
     *
     * Returns:
     * {Object} A MapObject Bounds, translated from olBounds
     *          Returns null if null value is passed in
     */
    getMapObjectBoundsFromOLBounds: function(olBounds) {
        var moBounds = null;
        if (olBounds != null) {
            var sw = this.sphericalMercator ?
              this.inverseMercator(olBounds.bottom, olBounds.left) :
              new OpenLayers.LonLat(olBounds.bottom, olBounds.left);
            var ne = this.sphericalMercator ?
              this.inverseMercator(olBounds.top, olBounds.right) :
              new OpenLayers.LonLat(olBounds.top, olBounds.right);
            moBounds = new google.maps.LatLngBounds(
                new google.maps.LatLng(sw.lat, sw.lon),
                new google.maps.LatLng(ne.lat, ne.lon)
            );
        }
        return moBounds;
    },

    /************************************
     *                                  *
     *   MapObject Interface Controls   *
     *                                  *
     ************************************/

  // LonLat - Pixel Translation

    /**
     * APIMethod: getMapObjectLonLatFromMapObjectPixel
     *
     * Parameters:
     * moPixel - {Object} MapObject Pixel format
     *
     * Returns:
     * {Object} MapObject LonLat translated from MapObject Pixel
     */
    getMapObjectLonLatFromMapObjectPixel: function(moPixel) {
        var size = this.map.getSize();
        var lon = this.getLongitudeFromMapObjectLonLat(this.mapObject.center);
        var lat = this.getLatitudeFromMapObjectLonLat(this.mapObject.center);
        var res = this.map.getResolution();

        var delta_x = moPixel.x - (size.w / 2);
        var delta_y = moPixel.y - (size.h / 2);

        var lonlat = new OpenLayers.LonLat(
            lon + delta_x * res,
            lat - delta_y * res
        );

        if (this.wrapDateLine) {
            lonlat = lonlat.wrapDateLine(this.maxExtent);
        }
        return this.getMapObjectLonLatFromLonLat(lonlat.lon, lonlat.lat);
    },

    /**
     * APIMethod: getMapObjectPixelFromMapObjectLonLat
     *
     * Parameters:
     * moLonLat - {Object} MapObject LonLat format
     *
     * Returns:
     * {Object} MapObject Pixel transtlated from MapObject LonLat
     */
    getMapObjectPixelFromMapObjectLonLat: function(moLonLat) {
        var lon = this.getLongitudeFromMapObjectLonLat(moLonLat);
        var lat = this.getLatitudeFromMapObjectLonLat(moLonLat);
        var res = this.map.getResolution();
        var extent = this.map.getExtent();
        return this.getMapObjectPixelFromXY((1/res * (lon - extent.left)),
                                            (1/res * (extent.top - lat)));
    },

    /**
     * APIMethod: setMapObjectCenter
     * Set the mapObject to the specified center and zoom
     *
     * Parameters:
     * center - {Object} MapObject LonLat format
     * zoom - {int} MapObject zoom format
     */
    setMapObjectCenter: function(center, zoom) {
        if (this.animationEnabled === false && zoom != this.mapObject.zoom) {
            var mapContainer = this.getMapContainer();
            google.maps.event.addListenerOnce(
                this.mapObject,
                "idle",
                function() {
                    mapContainer.style.visibility = "";
                }
            );
            mapContainer.style.visibility = "hidden";
        }
        this.mapObject.setOptions({
            center: center,
            zoom: zoom
        });
    },

  // Bounds

    /**
     * APIMethod: getMapObjectZoomFromMapObjectBounds
     *
     * Parameters:
     * moBounds - {Object} MapObject Bounds format
     *
     * Returns:
     * {Object} MapObject Zoom for specified MapObject Bounds
     */
    getMapObjectZoomFromMapObjectBounds: function(moBounds) {
        return this.mapObject.getBoundsZoomLevel(moBounds);
    },

    /************************************
     *                                  *
     *       MapObject Primitives       *
     *                                  *
     ************************************/

  // LonLat

    /**
     * APIMethod: getMapObjectLonLatFromLonLat
     *
     * Parameters:
     * lon - {Float}
     * lat - {Float}
     *
     * Returns:
     * {Object} MapObject LonLat built from lon and lat params
     */
    getMapObjectLonLatFromLonLat: function(lon, lat) {
        var gLatLng;
        if(this.sphericalMercator) {
            var lonlat = this.inverseMercator(lon, lat);
            gLatLng = new google.maps.LatLng(lonlat.lat, lonlat.lon);
        } else {
            gLatLng = new google.maps.LatLng(lat, lon);
        }
        return gLatLng;
    },

  // Pixel

    /**
     * APIMethod: getMapObjectPixelFromXY
     *
     * Parameters:
     * x - {Integer}
     * y - {Integer}
     *
     * Returns:
     * {Object} MapObject Pixel from x and y parameters
     */
    getMapObjectPixelFromXY: function(x, y) {
        return new google.maps.Point(x, y);
    }

};
<|endoftext|>


<commit_before>/* Author: Jim Camut */

function Calendarize() {
	var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
	var dayNames = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];

	return {

		// Return the days in a month - given a year and the month number
		getDaysInMonth: function(month, year) {
			var date = new Date(year, month, 1);
			var days = [];
			while (date.getMonth() === month) {
				days.push(new Date(date));
				date.setDate(date.getDate() + 1);
			}
			return days;
		},

		// return an array of the first day of each month for a given year
		getMonthsInYear: function(year) {
			var date = new Date(year, 0, 1);
			var months = [];
			var monthCount = 0;
			while (monthCount < 12) {
				months.push(new Date(date));
				date.setMonth(date.getMonth() + 1);
				monthCount++;
			}
			return months;
		},

		// Create a full 12-month calendar
		buildYearCalendar: function(el, year) {
			var _this = this;
			var months = _this.getMonthsInYear(year);

			var opts = {
				showMonth: true,
				showDaysOfWeek: true,
				showYear: true,
				clickHandler: function(e) {
					var day = e.target.getAttribute("data-date");
					alert(day);
				}
			};

			months.forEach(function(a, b) {
				var $monthNode = _this.buildMonth(b, year, opts);
				if (b == 0) console.log($monthNode);
				el.appendChild($monthNode);
			});
		},

		// Add days and place fillers for a given month
		buildMonth: function(monthNum, year, opts) {
			//if (monthNum === undefined || year === undefined) return "something is missing";
			var _this = this;
			var dtm = new Date(year, monthNum, 1);
			var dtmMonth = dtm.getMonth();
			var prevM = new Date(dtm.setMonth(dtmMonth - 1));
			var nextM = new Date(dtm.setMonth(dtmMonth + 1));
			var daysInMonth = _this.getDaysInMonth(monthNum, year);
			var daysPrevMonth = _this.getDaysInMonth(prevM.getMonth(), prevM.getFullYear());
			var daysNextMonth = _this.getDaysInMonth(nextM.getMonth(), nextM.getFullYear());
			var $monthNode = document.createElement('div');
			var $titleNode = document.createElement('h3');
			var skipLength = daysInMonth[0].getDay();
			var preLength = daysInMonth.length + skipLength;
			var postLength = function() {
				if (preLength % 7 === 0) {
					return 0;
				} else {
					if (preLength < 35) {
						return 35 - preLength;
					} else {
						return 42 - preLength;
					}
				}
			}

			$monthNode.classList.add('month');

			// Add a Title to the month
			if (opts.showMonth) {
				$titleNode.innerText = monthNames[monthNum] + (opts.showYear ? " " + year : '');
				$monthNode.appendChild($titleNode);
			}

			// Add Days of week to the top row
			if (opts.showDaysOfWeek) {
				dayNames.forEach(function(a, b) {
					var $dayNode = document.createElement('div');
					$dayNode.classList.add('dow');
					$dayNode.innerHTML = dayNames[b];
					$monthNode.appendChild($dayNode);
				});
			}

			// Add blank days to fill in before first day
			for (var i = 0; i < skipLength; i++) {
				var $dayNode = document.createElement('div');
				$dayNode.classList.add('dummy-day');
				$dayNode.innerText = daysPrevMonth.length - (skipLength - (i + 1));
				$monthNode.appendChild($dayNode);
			}

			// Place a day for each day of the month
			daysInMonth.forEach(function(c, d) {
				var $dayNode = document.createElement('div');
				$dayNode.classList.add('day');
				$dayNode.setAttribute("data-date", c);
				$dayNode.innerHTML = (d + 1);
				var dow = new Date(c).getDay();
				if (dow === 0 || dow === 6) $dayNode.classList.add('weekend');
				if (opts.clickHandler) {
					$dayNode.addEventListener("click", opts.clickHandler);
				}
				$monthNode.appendChild($dayNode);
			});

			// Add in the dummy filler days to make an even block
			for (var j = 0; j < postLength(); j++) {
				var $dayNode = document.createElement('div');
				$dayNode.classList.add('dummy-day');
				$dayNode.innerText = j + 1;
				$monthNode.appendChild($dayNode);
			}

			return $monthNode;

		}
	}
}
<commit_msg>improvements<commit_after>/* Author: Jim Camut */

function Calendarize() {
	var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
	var dayNames = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];

	return {

		// Return the days in a month - given a year and the month number
		getDaysInMonth: function(month, year) {
			var date = new Date(year, month, 1);
			var days = [];
			while (date.getMonth() === month) {
				days.push(new Date(date));
				date.setDate(date.getDate() + 1);
			}
			return days;
		},

		// return an array of the first day of each month for a given year
		getMonthsInYear: function(year) {
			var date = new Date(year, 0, 1);
			var months = [];
			var monthCount = 0;
			while (monthCount < 12) {
				months.push(new Date(date));
				date.setMonth(date.getMonth() + 1);
				monthCount++;
			}
			return months;
		},

		getMonthsInRange: function(startDate, endDate) {
			var start = new Date(startDate.getFullYear(), startDate.getMonth(), 1);
			var end = new Date(endDate.getFullYear(), endDate.getMonth(), 1);
			var months = [];
			var monthCount = 0;
			while (start <= end) {
				months.push( new Date(start) );
				start.setMonth(start.getMonth() + 1);
				monthCount++;
			}
			return months;
		},

		// Create a full 12-month calendar
		buildYearCalendar: function(el, year) {
			var _this = this;
			var months = _this.getMonthsInYear(year);

			var opts = {
				showMonth: true,
				showDaysOfWeek: true,
				showYear: true,
				clickHandler: function(e) {
					var day = e.target.getAttribute("data-date");
					//alert(day);
				}
			};

			months.forEach(function(a, b) {
				var $monthNode = _this.buildMonth(b, year, opts);
				el.appendChild($monthNode);
			});
		},

		buildMonthsInRange: function(el, opts, startDate, limit) {
			var _this = this;
			var endDate = new Date( new Date().setDate(startDate.getDate() + limit) );
			var months = _this.getMonthsInRange(startDate, endDate);

			opts = opts  || {};
			opts.limitDate = endDate || false;
			if (opts.reverse) months = months.reverse();

			months.forEach(function(a, b) {
				var month = a.getMonth();
				var year = a.getFullYear();
				var $monthNode = _this.buildMonth(month, year, opts);
				el.appendChild($monthNode);
			});
		},

		// Add days and place fillers for a given month
		// This function and the one above needs consolidated
		buildMonth: function(monthNum, year, opts) {
			//if (monthNum === undefined || year === undefined) return "something is missing";
			var _this = this;
			var dtm = new Date(year, monthNum, 1);
			var dtmMonth = dtm.getMonth();
			var prevM = new Date(dtm.setMonth(dtmMonth - 1));
			var nextM = new Date(dtm.setMonth(dtmMonth + 1));
			var daysInMonth = _this.getDaysInMonth(monthNum, year);
			var daysPrevMonth = _this.getDaysInMonth(prevM.getMonth(), prevM.getFullYear());
			var daysNextMonth = _this.getDaysInMonth(nextM.getMonth(), nextM.getFullYear());
			var $monthNode = document.createElement('div');
			var $titleNode = document.createElement('h4');
			var skipLength = daysInMonth[0].getDay();
			var preLength = daysInMonth.length + skipLength;
			var postLength = function() {
				if (preLength % 7 === 0) {
					return 0;
				} else {
					if (preLength < 35) {
						return 35 - preLength;
					} else {
						return 42 - preLength;
					}
				}
			}

			$monthNode.classList.add('month');

			// Add a Title to the month
			if (opts.showMonth) {
				$titleNode.innerText = monthNames[monthNum] + (opts.showYear ? " " + year : '');
				$monthNode.appendChild($titleNode);
			}

			// Add Days of week to the top row
			if (opts.showDaysOfWeek) {
				dayNames.forEach(function(a, b) {
					var $dayNode = document.createElement('div');
					$dayNode.classList.add('dow');
					$dayNode.innerText = dayNames[b];
					$monthNode.appendChild($dayNode);
				});
			}

			// Add blank days to fill in before first day
			for (var i = 0; i < skipLength; i++) {
				var $dayNode = document.createElement('div');
				$dayNode.classList.add('dummy-day');
				$dayNode.innerText = daysPrevMonth.length - (skipLength - (i + 1));
				$monthNode.appendChild($dayNode);
			}

			// Place a day for each day of the month
			daysInMonth.forEach(function(c, d) {
				var today = new Date(new Date().setHours(0, 0, 0, 0));
				var $dayNode = document.createElement('div');
				$dayNode.classList.add('day');
				$dayNode.setAttribute("data-date", c);
				$dayNode.innerText = (d + 1);
				var dow = new Date(c).getDay();
				var dateParsed = Date.parse(c);
				var todayParsed = Date.parse(today);

				if (dateParsed === todayParsed) $dayNode.classList.add('today');
				if (dateParsed > todayParsed) $dayNode.classList.add('future');
				if (dateParsed <todayParsed) $dayNode.classList.add('past');

				if (dow === 0 || dow === 6) $dayNode.classList.add('weekend');
				if (opts.onlyCurrent && c < today) $dayNode.classList.add('dummy-day');
				if (opts.limitDate) {
					if (c > opts.limitDate) {
						$dayNode.classList.add('dummy-day');
					}
				}

				if (opts.filterDayOfWeek) {
					var valid = false;
					for (var i = 0; i < opts.filterDayOfWeek.length; i++) {
						if (c.getDay() == opts.filterDayOfWeek[i]) {
							valid = true;
						}
					}
					if (!valid) {
						$dayNode.classList.add('dummy-day');
					}
				}
				if (opts.clickHandler && !$dayNode.classList.contains('dummy-day')) {
					function handleEvent(e) {
						e = e || window.event;
						e.preventDefault();
						e.stopPropagation();
						var touches = false;
						if (!touches) {
							touches = true;
							setTimeout(function() {
								touches = false;
							}, 300);
							opts.clickHandler(e);
						}
					}
					$dayNode.addEventListener("touchstart", handleEvent);
					$dayNode.addEventListener("mousedown", handleEvent);
				}
				$monthNode.appendChild($dayNode);
			});

			// Add in the dummy filler days to make an even block
			for (var j = 0; j < postLength(); j++) {
				var $dayNode = document.createElement('div');
				$dayNode.classList.add('dummy-day');
				$dayNode.innerText = j + 1;
				$monthNode.appendChild($dayNode);
			}

			return $monthNode;

		}
	}
}

<|endoftext|>


<commit_before>
(function(global) {
  var Recorder;

  Recorder = {
    recorder: null,
    recorderOriginalWidth: 0,
    recorderOriginalHeight: 0,
    uploadFormId: null,
    uploadFieldName: null,
    isReady: false,

    connect: function(name, attempts) {
      if(navigator.appName.indexOf("Microsoft") != -1) {
        Recorder.recorder = window[name];
      } else {
        Recorder.recorder = document[name];
      }

      if(attempts >= 40) {
        return;
      }

      // flash app needs time to load and initialize
      if(Recorder.recorder && Recorder.recorder.init) {
        Recorder.recorderOriginalWidth = Recorder.recorder.width;
        Recorder.recorderOriginalHeight = Recorder.recorder.height;
        if(Recorder.uploadFormId && $) {
          var frm = $(Recorder.uploadFormId);
          Recorder.recorder.init(frm.attr('action').toString(), Recorder.uploadFieldName, frm.serializeArray());
        }
        return;
      }

      setTimeout(function() {Recorder.connect(name, attempts+1);}, 100);
    },

    playBack: function(name) {
      Recorder.recorder.playBack(name);
    },

    pausePlayBack: function(name) {
      Recorder.recorder.pausePlayBack(name);
    },

    playBackFrom: function(name, time) {
    	Recorder.recorder.playBackFrom(name, time);
    },

    record: function(name, filename) {
      Recorder.recorder.record(name, filename);
    },

    resize: function(width, height) {
      Recorder.recorder.width = width + "px";
      Recorder.recorder.height = height + "px";
    },

    defaultSize: function(width, height) {
      Recorder.resize(Recorder.recorderOriginalWidth, Recorder.recorderOriginalHeight);
    },

    show: function() {
      Recorder.recorder.show();
    },

    hide: function() {
      Recorder.recorder.hide();
    },

    duration: function(name) {
      return Recorder.recorder.duration(name || Recorder.uploadFieldName);
    },

    updateForm: function() {
      var frm = $(Recorder.uploadFormId);
      Recorder.recorder.update(frm.serializeArray());
    },

    showPermissionWindow: function() {
      Recorder.resize(240, 160);
      // need to wait until app is resized before displaying permissions screen
      setTimeout(function(){Recorder.recorder.permit();}, 1);
    },

    configure: function(rate, gain, silenceLevel, silenceTimeout) {
      rate = parseInt(rate || 22);
      gain = parseInt(gain || 100);
      silenceLevel = parseInt(silenceLevel || 0);
      silenceTimeout = parseInt(silenceTimeout || 4000);
      switch(rate) {
      case 44:
      case 22:
      case 11:
      case 8:
      case 5:
        break;
      default:
        throw("invalid rate " + rate);
      }

      if(gain < 0 || gain > 100) {
        throw("invalid gain " + gain);
      }

      if(silenceLevel < 0 || silenceLevel > 100) {
        throw("invalid silenceLevel " + silenceLevel);
      }

      if(silenceTimeout < -1) {
        throw("invalid silenceTimeout " + silenceTimeout);
      }

      Recorder.recorder.configure(rate, gain, silenceLevel, silenceTimeout);
    },

    setUseEchoSuppression: function(val) {
      if(typeof(val) != 'boolean') {
        throw("invalid value for setting echo suppression, val: " + val);
      }

      Recorder.recorder.setUseEchoSuppression(val);
    },

    setLoopBack: function(val) {
      if(typeof(val) != 'boolean') {
        throw("invalid value for setting loop back, val: " + val);
      }

      Recorder.recorder.setLoopBack(val);
    }
  };

  global.FWRecorder = Recorder;

})(this);<commit_msg>getCurrentTime - added to javascirpt interface<commit_after>
(function(global) {
  var Recorder;

  Recorder = {
    recorder: null,
    recorderOriginalWidth: 0,
    recorderOriginalHeight: 0,
    uploadFormId: null,
    uploadFieldName: null,
    isReady: false,

    connect: function(name, attempts) {
      if(navigator.appName.indexOf("Microsoft") != -1) {
        Recorder.recorder = window[name];
      } else {
        Recorder.recorder = document[name];
      }

      if(attempts >= 40) {
        return;
      }

      // flash app needs time to load and initialize
      if(Recorder.recorder && Recorder.recorder.init) {
        Recorder.recorderOriginalWidth = Recorder.recorder.width;
        Recorder.recorderOriginalHeight = Recorder.recorder.height;
        if(Recorder.uploadFormId && $) {
          var frm = $(Recorder.uploadFormId);
          Recorder.recorder.init(frm.attr('action').toString(), Recorder.uploadFieldName, frm.serializeArray());
        }
        return;
      }

      setTimeout(function() {Recorder.connect(name, attempts+1);}, 100);
    },

    playBack: function(name) {
      Recorder.recorder.playBack(name);
    },

    pausePlayBack: function(name) {
      Recorder.recorder.pausePlayBack(name);
    },

    playBackFrom: function(name, time) {
    	Recorder.recorder.playBackFrom(name, time);
    },

    record: function(name, filename) {
      Recorder.recorder.record(name, filename);
    },

    resize: function(width, height) {
      Recorder.recorder.width = width + "px";
      Recorder.recorder.height = height + "px";
    },

    defaultSize: function(width, height) {
      Recorder.resize(Recorder.recorderOriginalWidth, Recorder.recorderOriginalHeight);
    },

    show: function() {
      Recorder.recorder.show();
    },

    hide: function() {
      Recorder.recorder.hide();
    },

    duration: function(name) {
      return Recorder.recorder.duration(name || Recorder.uploadFieldName);
    },

    getCurrentTime: function(name) {
    	return Recorder.recorder.getCurrentTime(name);
    },

    updateForm: function() {
      var frm = $(Recorder.uploadFormId);
      Recorder.recorder.update(frm.serializeArray());
    },

    showPermissionWindow: function() {
      Recorder.resize(240, 160);
      // need to wait until app is resized before displaying permissions screen
      setTimeout(function(){Recorder.recorder.permit();}, 1);
    },

    configure: function(rate, gain, silenceLevel, silenceTimeout) {
      rate = parseInt(rate || 22);
      gain = parseInt(gain || 100);
      silenceLevel = parseInt(silenceLevel || 0);
      silenceTimeout = parseInt(silenceTimeout || 4000);
      switch(rate) {
      case 44:
      case 22:
      case 11:
      case 8:
      case 5:
        break;
      default:
        throw("invalid rate " + rate);
      }

      if(gain < 0 || gain > 100) {
        throw("invalid gain " + gain);
      }

      if(silenceLevel < 0 || silenceLevel > 100) {
        throw("invalid silenceLevel " + silenceLevel);
      }

      if(silenceTimeout < -1) {
        throw("invalid silenceTimeout " + silenceTimeout);
      }

      Recorder.recorder.configure(rate, gain, silenceLevel, silenceTimeout);
    },

    setUseEchoSuppression: function(val) {
      if(typeof(val) != 'boolean') {
        throw("invalid value for setting echo suppression, val: " + val);
      }

      Recorder.recorder.setUseEchoSuppression(val);
    },

    setLoopBack: function(val) {
      if(typeof(val) != 'boolean') {
        throw("invalid value for setting loop back, val: " + val);
      }

      Recorder.recorder.setLoopBack(val);
    }
  };

  global.FWRecorder = Recorder;

})(this);<|endoftext|>


<commit_before>import { join } from 'path';
import { replaceCode, appendFile, addNpmPackage } from '../utils';

async function generateMongodbDatabase(params) {
  switch (params.framework) {
    case 'express':
      const app = join(__base, 'build', params.uuid, 'app.js');
      const mongooseRequire = join(__base, 'modules', 'database', 'mongodb', 'mongoose-require.js');
      const mongooseConnect = join(__base, 'modules', 'database', 'mongodb', 'mongoose-connect.js');

      await replaceCode(app, 'DATABASE_REQUIRE', mongooseRequire);
      await replaceCode(app, 'DATABASE_CONNECTION', mongooseConnect, { leadingBlankLine: true });

      await appendFile(join(__base, 'build', params.uuid, '.env'), 'MONGODB=mongodb://localhost/test');

      await addNpmPackage('mongoose', params);
      break;
    case 'hapi':
      break;
    case 'meteor':
      break;
    default:
  }
}

export default generateMongodbDatabase;
<commit_msg>Create models dir and copy user model for mongodb generator<commit_after>import { join } from 'path';
import { replaceCode, mkdirs, copy, appendFile, addNpmPackage } from '../utils';

async function generateMongodbDatabase(params) {
  const build = join(__base, 'build', params.uuid);

  switch (params.framework) {
    case 'express':
      const app = join(build, 'app.js');
      const mongooseRequire = join(__base, 'modules', 'database', 'mongodb', 'mongoose-require.js');
      const mongooseConnect = join(__base, 'modules', 'database', 'mongodb', 'mongoose-connect.js');
      const mongooseUserModel = join(__base, 'modules', 'database', 'mongodb', 'mongoose-model.js');

      await replaceCode(app, 'DATABASE_REQUIRE', mongooseRequire);
      await replaceCode(app, 'DATABASE_CONNECTION', mongooseConnect, { leadingBlankLine: true });

      await appendFile(join(build, '.env'), 'MONGODB=mongodb://localhost/test');

      await addNpmPackage('mongoose', params);

      // Create models dir
      await mkdirs(join(__base, 'build', params.uuid, 'models'));
      await copy(mongooseUserModel, join(build, 'models', 'user.js'));

      break;
    case 'hapi':
      break;
    case 'meteor':
      break;
    default:
  }
}

export default generateMongodbDatabase;
<|endoftext|>