<commit_before>/*
 * The aspiredb project
 *
 * Copyright (c) 2013 University of British Columbia
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

/**
 * Ideogram colour legend for colouring variants based on variant type, CNV type, etc.
 */
var ColourLegend = function(ctx) {

	this.displayProperty = null;
	this.colors = [ "red", "blue", "black", "purple", "brown", "olive", "maroon", "orange" ];
	this.defaultColour = "rgba(0,0,0,0.5)";
	this.nextColourIndex = 0;
//	this.valueToColourMap = [];
	this.characteristicList = {};
	this.ctx = ctx;
	this.baseColourPicker = null;
}

ColourLegend.prototype.assignColor = function(variantType, defaultColor){//, htmlLabel) {
	var colour;
	if ( this.characteristicList.length == 0 || ( ( colour = this.characteristicList[variantType] ) == undefined ) ) {
		colour = defaultColor == undefined ? this.colors[this.nextColourIndex] : defaultColor;
//		this.valueToColourMap.push( htmlLabel == undefined ? [ "" + variantType + "
\n" ] : [htmlLabel] );
		this.characteristicList[variantType] = colour;
		this.nextColourIndex++;
	}
	return colour;
};

//sets the display property and creates a baseColourPicker that will be used on each variant
ColourLegend.prototype.setColourCode = function(property) {
	this.displayProperty = property;

	this.nextColourIndex = 0;
//	this.valueToColourMap = [];
	this.characteristicList = {};

	var me = this;

	// if variant type property : CNV, SNV, indel, translocation, inversion
	if ( property instanceof VariantTypeProperty ) {
		this.baseColourPicker = function(variant) {
			return me.assignColor(variant.variantType);
		}
	}

	// if CNV type : LOSS, GAIN
	else if ( property instanceof CNVTypeProperty ) {
		this.baseColourPicker = function(variant) {
			return me.assignColor(variant.type);
		}
	}

	// if variant labels
	else if ( property instanceof VariantLabelProperty ) {

		this.baseColourPicker = function(variant) {
			if ( variant.labels.length > 0 ) {
				// Adding a ~ character to prevent users creating labels such as 'No Label' and screwing with the color picking
				return me.assignColor("~" + variant.labels[0].name, '#' + variant.labels[0].colour);//, ASPIREdb.view.LabelControlWindow.getHtmlLabel( variant.labels[0] ) + "
\n");
			} else {
				return me.assignColor('No Label', '#303030');
			}
		}
	}

	// if subject labels
	else if ( property instanceof SubjectLabelProperty ) {

		this.baseColourPicker = function(variant) {
			var subject = variant.subject;
			if ( subject != null && subject.labels.length > 0 ) {
				// Adding a ~ character to prevent users creating labels such as 'No Label' and screwing with the color picking
				return me.assignColor("~" + subject.labels[0].name, '#' + subject.labels[0].colour);//, ASPIREdb.view.LabelControlWindow.getHtmlLabel( subject.labels[0] ) + "
\n");
			} else {
				return me.assignColor('No Label', '#303030');
			}
		}
	}

	// if Characteristic type : benign, pathogenic, unknown
	else if ( property instanceof CharacteristicProperty ) {

		var name = property.name;

		this.baseColourPicker = function(variant) {
			var characteristicValueObject = variant.characteristics[name];
			if ( characteristicValueObject != undefined && characteristicValueObject !== null) {
				// Adding a ~ character to prevent users creating labels such as 'No Label' and screwing with the color picking
				return me.assignColor(characteristicValueObject.value);
			} else {
				return me.assignColor('No data', '#303030');
			}
		}
	}
};

ColourLegend.prototype.getColour = function(variant) {

	if ( this.displayProperty == null || this.baseColourPicker == null )
		return this.defaultColour;

	return this.baseColourPicker(variant);
};

ColourLegend.prototype.measureWidth = function() {
	var maxWidth = 0;
	for (var legendEntry in this.characteristicList) {

		var w = this.ctx.measureText(legendEntry).width + 45;

		maxWidth = w > maxWidth ? w : maxWidth;

	}
	return Math.round( maxWidth ) + 1;
};

ColourLegend.prototype.refresh = function() {

	var ctx = this.ctx;

	var legendX = 0;
	var legendY = 0;

	ctx.beginPath();
	ctx.lineWidth=1;
	ctx.textBaseline = "middle";

	// entries
	ctx.font = "14px Arial";
	var maxwidth = 0;
	var entries = 5;
	var entryHeight = 20;
	i = 0;
	for (var legendEntry in this.characteristicList) {

		ctx.fillStyle = this.characteristicList[legendEntry];
		ctx.fillRect(legendX + 5,legendY + 5 + entryHeight*i, 10, 10);

		ctx.fillStyle = "black";
		ctx.fillText(legendEntry, legendX + 35, legendY + 10 + entryHeight*i);
		var w = ctx.measureText(legendEntry).width + 35;

		maxwidth = w > maxwidth ? w : maxwidth;
		i++;
	}

};<commit_msg>Remove the tilde used in the ColourLegend entry key from displaying in the legend.<commit_after>/*
 * The aspiredb project
 *
 * Copyright (c) 2013 University of British Columbia
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

/**
 * Ideogram colour legend for colouring variants based on variant type, CNV type, etc.
 */
var ColourLegend = function(ctx) {

	this.displayProperty = null;
	this.colors = [ "red", "blue", "black", "purple", "brown", "olive", "maroon", "orange" ];
	this.defaultColour = "rgba(0,0,0,0.5)";
	this.nextColourIndex = 0;
//	this.valueToColourMap = [];
	this.characteristicList = {};
	this.ctx = ctx;
	this.baseColourPicker = null;
}

ColourLegend.prototype.assignColor = function(variantType, defaultColor, displayName){//, htmlLabel) {
	var colour;
	if ( this.characteristicList.length == 0 || ( ( colour = this.characteristicList[variantType] ) == undefined ) ) {
		colour = defaultColor == undefined ? this.colors[this.nextColourIndex] : defaultColor;
		displayName = displayName == undefined ? variantType : displayName;
//		this.valueToColourMap.push( htmlLabel == undefined ? [ "" + variantType + "
\n" ] : [htmlLabel] );
		this.characteristicList[variantType] = {colour:colour, displayName: displayName};
		this.nextColourIndex++;
	}
	return colour;
};

//sets the display property and creates a baseColourPicker that will be used on each variant
ColourLegend.prototype.setColourCode = function(property) {
	this.displayProperty = property;

	this.nextColourIndex = 0;
//	this.valueToColourMap = [];
	this.characteristicList = {};

	var me = this;

	// if variant type property : CNV, SNV, indel, translocation, inversion
	if ( property instanceof VariantTypeProperty ) {
		this.baseColourPicker = function(variant) {
			return me.assignColor(variant.variantType);
		}
	}

	// if CNV type : LOSS, GAIN
	else if ( property instanceof CNVTypeProperty ) {
		this.baseColourPicker = function(variant) {
			return me.assignColor(variant.type);
		}
	}

	// if variant labels
	else if ( property instanceof VariantLabelProperty ) {

		this.baseColourPicker = function(variant) {
			if ( variant.labels.length > 0 ) {
				// Adding a ~ character to prevent users creating labels such as 'No Label' and screwing with the color picking
				return me.assignColor("~" + variant.labels[0].name, '#' + variant.labels[0].colour, variant.labels[0].name);//, ASPIREdb.view.LabelControlWindow.getHtmlLabel( variant.labels[0] ) + "
\n");
			} else {
				return me.assignColor('No Label', '#303030');
			}
		}
	}

	// if subject labels
	else if ( property instanceof SubjectLabelProperty ) {

		this.baseColourPicker = function(variant) {
			var subject = variant.subject;
			if ( subject != null && subject.labels.length > 0 ) {
				// Adding a ~ character to prevent users creating labels such as 'No Label' and screwing with the color picking
				return me.assignColor("~" + subject.labels[0].name, '#' + subject.labels[0].colour, subject.labels[0].name);//, ASPIREdb.view.LabelControlWindow.getHtmlLabel( subject.labels[0] ) + "
\n");
			} else {
				return me.assignColor('No Label', '#303030');
			}
		}
	}

	// if Characteristic type : benign, pathogenic, unknown
	else if ( property instanceof CharacteristicProperty ) {

		var name = property.name;

		this.baseColourPicker = function(variant) {
			var characteristicValueObject = variant.characteristics[name];
			if ( characteristicValueObject != undefined && characteristicValueObject !== null) {
				// Adding a ~ character to prevent users creating labels such as 'No Label' and screwing with the color picking
				return me.assignColor(characteristicValueObject.value);
			} else {
				return me.assignColor('No data', '#303030');
			}
		}
	}
};

ColourLegend.prototype.getColour = function(variant) {

	if ( this.displayProperty == null || this.baseColourPicker == null )
		return this.defaultColour;

	return this.baseColourPicker(variant);
};

ColourLegend.prototype.measureWidth = function() {
	var maxWidth = 0;
	for (var legendEntry in this.characteristicList) {
		var displayName = this.characteristicList[legendEntry].displayName;
		var w = this.ctx.measureText(displayName).width + 45;

		maxWidth = w > maxWidth ? w : maxWidth;

	}
	return Math.round( maxWidth ) + 1;
};

ColourLegend.prototype.refresh = function() {

	var ctx = this.ctx;

	var legendX = 0;
	var legendY = 0;

	ctx.beginPath();
	ctx.lineWidth=1;
	ctx.textBaseline = "middle";

	// entries
	ctx.font = "14px Arial";
	var maxwidth = 0;
	var entries = 5;
	var entryHeight = 20;
	i = 0;
	for (var legendEntryKey in this.characteristicList) {
		var legendEntry = this.characteristicList[legendEntryKey];
		ctx.fillStyle = legendEntry.colour;
		ctx.fillRect(legendX + 5,legendY + 5 + entryHeight*i, 10, 10);

		ctx.fillStyle = "black";
		ctx.fillText(legendEntry.displayName, legendX + 35, legendY + 10 + entryHeight*i);
		var w = ctx.measureText(legendEntry.displayName).width + 35;

		maxwidth = w > maxwidth ? w : maxwidth;
		i++;
	}

};<|endoftext|>


<commit_before>TP.panel.Home = function(config) {
    config = config || {};

    // create site root file checkboxen
    var fs = {};
    if(TP.config.rootFiles) {
        var items = [];
        items.push({
            border: false
            ,html: '
Pick any files from your site root that you wish to be included in your Theme.
'
            ,style: {
                padding: '8px'
            }
        });
        Ext.each(TP.config.rootFiles, function(f){
            items.push({
                xtype: 'checkbox'
                ,id: 'rootfile-' + f.replace(' ', '_')
                ,name: 'rootFiles[]'
                ,boxLabel: f
                ,inputValue: f
                ,hideLabel: true
                ,style: {marginLeft: '17px'}
            });
        });
        fs = {
            title: 'Files'
            ,items: items
        }
    }

    // create package checkboxen
    var ps = {};
    if(TP.config.packages) {
        var items = [];
        items.push({
            border: false
            ,html: '
Pick any transport packages that you would like included in your Theme. They will be added as "subpackages" in your theme package.
'
            ,style: {
                padding: '8px'
            }
        });
        Ext.each(TP.config.packages, function(p){
            items.push({
                xtype: 'checkbox'
                ,id: 'subpackage-' + p.replace(' ', '_')
                ,name: 'subpackages[]'
                ,boxLabel: p
                ,inputValue: p
                ,hideLabel: true
                ,style: {marginLeft: '17px'}
            });
        });
        ps = {
            title: 'Packages'
            ,items: items
        }
    }

    Ext.apply(config,{
        id: 'tp-panel-home'
        ,url: TP.config.connector_url
        ,baseParams: {
            action: 'build'
        }
        ,border: false
        ,baseCls: 'modx-formpanel'
        ,cls: 'container'
        ,fileUpload: true
        ,listeners: {
            'beforeSubmit': {fn:this.beforeSubmit,scope:this}
            ,'success': {fn:this.success,scope:this}
        }
        ,items: [{
            html: '
'+_('themepackagercomponent')+'
'
            ,border: false
            ,id: 'tp-home-header'
            ,cls: 'modx-page-header'
        },{
            xtype: 'modx-tabs'
            ,border: true
            ,autoDestroy: false
            ,deferredRender: false
            ,defaults: { border: false ,autoHeight: true, bodyStyle: 'padding: 17px;',labelWidth:200 }
            ,items: [{
                title: _('themepackagercomponent.package')
                ,draggable: false
                ,layout: 'form'
                ,defaults: {border:false,autoHeight:true,bodyStyle:'padding:8px;'}
                ,items: [{
                    html: _('themepackagercomponent.intro_msg')
                    ,border: false
                    ,style: {
                        paddingBottom: '9px'
                    }
                },{
                    xtype: 'textfield'
                    ,fieldLabel: _('themepackagercomponent.package_name')
                    ,description: _('themepackagercomponent.package_name_desc')
                    ,name: 'category'
                    ,id: 'tp-category-name'
                    ,value: _('themepackagercomponent.mypackage')
                },{
                    xtype: 'textfield'
                    ,name: 'version'
                    ,fieldLabel: _('themepackagercomponent.version')
                    ,description: _('themepackagercomponent.version_desc')
                    ,value: '1.0'
                },{
                    xtype: 'textfield'
                    ,name: 'release'
                    ,fieldLabel: _('themepackagercomponent.release')
                    ,description: _('themepackagercomponent.release_desc')
                    ,value: 'beta1'
                },{
                    xtype: 'checkboxgroup'
                    ,fieldLabel: 'Package All'
                    ,defaults: {
                        xtype: 'checkbox'
                        ,inputValue: 'yes'
                        ,checked: false
                    }
                    ,items: [
                        {
                            id: 'tpc-package-everything-checkbox'
                            ,name: 'everything'
                            ,boxLabel: _('themepackagercomponent.all_elements')
                            ,description: _('themepackagercomponent.all_elements_desc')
                            ,inputValue: 'yes'
                            ,checked: false
                            ,listeners: {
                                check: {
                                    fn: function (el, checked) {
                                        if (checked) {
                                            Ext.getCmp('tpc-tab-elements').disable();
                                            Ext.getCmp('tpc-tab-subpackages').disable();
                                        } else {
                                            Ext.getCmp('tpc-tab-elements').enable();
                                            Ext.getCmp('tpc-tab-subpackages').enable();
                                        }
                                    }
                                    ,scope: this
                                }
                            }
                        },{
                            id: 'tpc-package-allfiles-checkbox'
                            ,name: 'allfiles'
                            ,boxLabel: _('themepackagercomponent.all_files')
                            ,description: _('themepackagercomponent.all_files_desc')
                            ,inputValue: 'yes'
                            ,checked: false
                            ,listeners: {
                                check: {
                                    fn: function (el, checked) {
                                        if (checked) {
                                            Ext.getCmp('tpc-tab-directories').disable();
                                        } else {
                                            Ext.getCmp('tpc-tab-directories').enable();
                                        }
                                    }
                                    ,scope: this
                                }
                            }
                        }
                    ]
                },{
                    title: _('themepackagercomponent.install_options_title')
                    ,html: _('themepackagercomponent.enduser_option_desc')
                    ,style: {
                        paddingTop: '17px'
                    }
                },{
                    xtype:'fieldset'
                    ,defaults:{border:false,autoHeight:true}
                    ,items: [
                        {
                            xtype: 'compositefield'
                            ,defaults: {border:false,autoHeight:true}
                            ,items: [
                                {
                                    xtype: 'checkbox'
                                    ,id: 'tpc-enduser_option_merge-checkbox'
                                    ,name: 'enduser_option_merge'
                                    ,fieldLabel: _('themepackagercomponent.enduser_option_merge_label')
                                    ,checked: true
                                    ,inputValue: 'yes'
                                },{
                                    xtype:'fieldset'
                                    ,border: true
                                    ,defaults: {border:false, autoHeight:true}
                                    ,items: [
                                        {
                                            xtype: 'radiogroup'
                                            ,id: 'tpc-default-merge-option-picker'
                                            ,hidden: false
                                            ,fieldLabel: 'Default'
                                            ,description: 'Specify whether your Theme package will Merge with the user\'s site on install, or completely replace it.'
                                            ,defaults: {labelSeparator: ''}
                                            ,width: 200
                                            ,items: [
                                                {
                                                    xtype: 'radio'
                                                    ,id: 'tpc-default-merge-option-picker-merge'
                                                    ,name: 'enduser_install_action_default'
                                                    ,boxLabel: 'Add'
                                                    ,inputValue: 'merge'
                                                    ,checked: true
                                                }, {
                                                    xtype: 'radio'
                                                    ,id: 'tpc-default-merge-option-picker-replace'
                                                    ,name: 'enduser_install_action_default'
                                                    ,boxLabel: 'Overwrite'
                                                    ,inputValue: 'replace'
                                                }
                                            ]
                                        }
                                    ]
                                }
                            ]
                        },{
                            html: '' + _('themepackagercomponent.enduser_option_merge_desc') + ''
                        }
                    ]
                }
                ,{
                    xtype:'fieldset'
                    ,defaults:{border:false,autoHeight:true}
                    ,items: [
                        {
                            xtype: 'compositefield'
                            ,defaults:{border:false,autoHeight:true}
                            ,items:[
                                {
                                    xtype: 'checkbox'
                                    ,id: 'tpc-enduser-option-samplecontent'
                                    ,name: 'enduser_option_samplecontent'
                                    ,fieldLabel: _('themepackagercomponent.enduser_option_samplecontent_label')
                                    ,checked: true
                                    ,inputValue: 'yes'
                                },{
                                    xtype:'fieldset'
                                    ,border: true
                                    ,defaults: {border:false, autoHeight:true}
                                    ,items: [
                                        {
                                            xtype: 'radiogroup'
                                            ,id: 'tpc-default-samplecontent-picker'
                                            ,hidden: false
                                            ,fieldLabel: 'Default'
                                            ,description: 'Specify whether the Theme install will default to adding your sample content or not.'
                                            ,width: 200
                                            ,defaults: {labelSeparator: ''}
                                            ,items: [
                                                {
                                                    xtype: 'radio'
                                                    ,id: 'tpc-default-samplecontent-picker-yes'
                                                    ,name: 'enduser_install_samplecontent_default'
                                                    ,boxLabel: 'Yes'
                                                    ,inputValue: 'yes'
                                                    ,checked: true
                                                }, {
                                                    xtype: 'radio'
                                                    ,id: 'tpc-default-samplecontent-picker-no'
                                                    ,name: 'enduser_install_samplecontent_default'
                                                    ,boxLabel: 'No'
                                                    ,inputValue: 'no'
                                                }
                                            ]
                                        }
                                    ]
                                }
                            ]
                        },{
                            html: '' + _('themepackagercomponent.enduser_option_samplecontent_desc') + ''
                        }
                    ]
                }]
            },{
                title: _('themepackagercomponent.elements')
                ,id: 'tpc-tab-elements'
                ,disabled: false
                ,deferredRender: false
                ,defaults: { border: false ,autoHeight: true }
                ,items: [
                    // Templates
                    {
                        title: _('themepackagercomponent.templates')
                    },{
                        html: _('themepackagercomponent.templates.intro_msg')
                        ,style: {margin: '10px'}
                    },{
                        xtype: 'hidden'
                        ,id: 'tp-tree-templates-selected_ids'
                        ,name: 'tp_template_ids'
                        ,value: ''
                    },{
                        xtype: 'tp-tree-templates'
                        ,id: 'tp-tree-templates-panel'
                        ,style: {marginLeft: '10px'}
                        ,listeners: {
                            checkchange: function(el,checked) {
                                if (el.childNodes.length > 0) {
                                    for (var child in el.childNodes) {
                                        if (!isNaN(child)) {
                                            el.childNodes[child].ui.checkbox.checked = checked
                                            el.childNodes[child].attributes.checked = checked
                                        }
                                    }
                                }
                                this.updateSelected();
                            }
                        }
                    },{html: ' '}

                    // Chunks
                    ,{
                        title: _('themepackagercomponent.chunks')
                    },{
                        html: _('themepackagercomponent.chunks.intro_msg')
                        ,style: {margin: '10px'}
                    },{
                        xtype: 'hidden'
                        ,id: 'tp-tree-chunks-selected_ids'
                        ,name: 'tp_chunk_ids'
                        ,value: ''
                    }
                    ,{
                        xtype: 'tp-tree-chunks'
                        ,id: 'tp-tree-chunks-panel'
                        ,style: {marginLeft: '10px'}
                        ,listeners: {
                            checkchange: function(el,checked) {
                                if (el.childNodes.length > 0) {
                                    for (var child in el.childNodes) {
                                        if (!isNaN(child)) {
                                            el.childNodes[child].ui.checkbox.checked = checked
                                            el.childNodes[child].attributes.checked = checked
                                        }
                                    }
                                }
                                this.updateSelected();
                            }
                        }
                    },{html: ' '}

                    // Snippets
                    ,{
                        title: _('themepackagercomponent.snippets')
                    },{
                        html: _('themepackagercomponent.snippets.intro_msg')
                        ,style: {margin: '10px'}
                    },{
                        xtype: 'hidden'
                        ,id: 'tp-tree-snippets-selected_ids'
                        ,name: 'tp_snippet_ids'
                        ,value: ''
                    }
                    ,{
                        xtype: 'tp-tree-snippets'
                        ,id: 'tp-tree-snippets-panel'
                        ,style: {marginLeft: '10px'}
                        ,listeners: {
                            checkchange: function(el,checked) {
                                if (el.childNodes.length > 0) {
                                    for (var child in el.childNodes) {
                                        if (!isNaN(child)) {
                                            el.childNodes[child].ui.checkbox.checked = checked
                                            el.childNodes[child].attributes.checked = checked
                                        }
                                    }
                                }
                                this.updateSelected();
                            }
                        }
                    },{html: ' '}

                    // Plugins
                    ,{
                        title: _('themepackagercomponent.plugins')
                    },{
                        html: _('themepackagercomponent.plugins.intro_msg')
                        ,style: {margin: '10px'}
                    },{
                        xtype: 'hidden'
                        ,id: 'tp-tree-plugins-selected_ids'
                        ,name: 'tp_plugin_ids'
                        ,value: ''
                    }
                    ,{
                        xtype: 'tp-tree-plugins'
                        ,id: 'tp-tree-plugins-panel'
                        ,style: {marginLeft: '10px'}
                        ,listeners: {
                            checkchange: function(el,checked) {
                                if (el.childNodes.length > 0) {
                                    for (var child in el.childNodes) {
                                        if (!isNaN(child)) {
                                            el.childNodes[child].ui.checkbox.checked = checked
                                            el.childNodes[child].attributes.checked = checked
                                        }
                                    }
                                }
                                this.updateSelected();
                            }
                        }
                    },{html: ' '}
                    //,ps

                    // end of Elements tab
                ]
            }
            ,{
                title: _('themepackagercomponent.subpackages')
                ,id: 'tpc-tab-subpackages'
                ,disabled: false
                ,defaults: { border: false ,autoHeight: true }
                ,items: [{
                    html: _('themepackagercomponent.subpackages.intro_msg')
                },{
                    xtype: 'tp-grid-packages'
                    ,id: 'tp-grid-packages'
                    ,preventRender: true
                }]
            }
            ,{
                title: _('themepackagercomponent.directories')
                ,id: 'tpc-tab-directories'
                ,disabled: false
                ,defaults: { border: false ,autoHeight: true }
                ,items: [fs, {
                    title: 'Directories'
                    ,style: {
                        paddingTop: '17px'
                    }
                },{
                    html: _('themepackagercomponent.directories.intro_msg')
                    ,style: {
                        padding: '8px'
                    }
                },{
                    xtype: 'tp-grid-directories'
                    ,id: 'tp-grid-directories'
                    ,preventRender: true
                }]
            },{
                title: _('themepackagercomponent.advanced_title')
                ,id: 'tpc-tab-advanced'
                ,disabled: false
                ,layout: 'form'
                ,deferredRender: false
                ,defaults:{border:false,autoHeight:true}
                ,items: [
                    {
                        xtype: 'textfield'
                        ,id: 'tpc-advanced-settings'
                        ,name: 'settings'
                        ,grow: true
                        ,growMin: 250
                        ,growMax: 1000
                        ,fieldLabel: _('themepackagercomponent.advanced.settings')
                        ,regex: /^[a-zA-Z0-9_\-]+\s*(,\s*[a-zA-Z0-9_\-]+\s*)*$/
                        ,regexText: _('themepackagercomponent.advanced.settings_invalid')
                        ,msgTarget: 'under'
                    },{
                        html: '' + _('themepackagercomponent.advanced.settings_desc') + ''
                        ,style: {
                            marginBottom: '35px'
                            ,marginLeft: '15px'
                        }
                    },{
                        xtype: 'textfield'
                        ,fieldLabel: _('themepackagercomponent.resources_field')
                        ,name: 'resources'
                        ,id: 'tp-resource-list'
                        ,value: ''
                        ,regex: /^[0-9]+\s*(,\s*[0-9]+\s*)*$/
                        ,regexText: _('themepackagercomponent.resources_field_invalid')
                        ,msgTarget: 'under'
                    },{
                        html: '' + _('themepackagercomponent.resources_field_desc') + ''
                        ,style: {
                            marginBottom: '35px'
                            ,marginLeft: '17px'
                        }
                    }
                ]
            }]
        }]
    });
    TP.panel.Home.superclass.constructor.call(this,config);
};
Ext.extend(TP.panel.Home,MODx.FormPanel,{
    beforeSubmit: function(o) {
        Ext.apply(o.form.baseParams,{
            templates: Ext.getCmp('tp-tree-templates-selected_ids').getValue()
            ,chunks: Ext.getCmp('tp-tree-chunks-selected_ids').getValue()
            ,plugins: Ext.getCmp('tp-tree-plugins-selected_ids').getValue()
            ,snippets: Ext.getCmp('tp-tree-snippets-selected_ids').getValue()
            ,packages: Ext.getCmp('tp-grid-packages').encode()
            ,directories: Ext.getCmp('tp-grid-directories').encode()
        });
    }
    ,success: function(o) {
        if (o.result.success) {
            var name = o.result.message;

            Ext.getCmp('tp-btn-export').setDisabled(false);
            Ext.getCmp('tp-grid-packages').getStore().commitChanges();
            Ext.getCmp('tp-grid-directories').getStore().commitChanges();

            location.href = TP.config.connector_url+'?action=build&download='+name+'&HTTP_MODAUTH='+MODx.siteId;
        }
    }
});
Ext.reg('tp-panel-home',TP.panel.Home);<commit_msg>allow more characters in settings names<commit_after>TP.panel.Home = function(config) {
    config = config || {};

    // create site root file checkboxen
    var fs = {};
    if(TP.config.rootFiles) {
        var items = [];
        items.push({
            border: false
            ,html: '
Pick any files from your site root that you wish to be included in your Theme.
'
            ,style: {
                padding: '8px'
            }
        });
        Ext.each(TP.config.rootFiles, function(f){
            items.push({
                xtype: 'checkbox'
                ,id: 'rootfile-' + f.replace(' ', '_')
                ,name: 'rootFiles[]'
                ,boxLabel: f
                ,inputValue: f
                ,hideLabel: true
                ,style: {marginLeft: '17px'}
            });
        });
        fs = {
            title: 'Files'
            ,items: items
        }
    }

    // create package checkboxen
    var ps = {};
    if(TP.config.packages) {
        var items = [];
        items.push({
            border: false
            ,html: '
Pick any transport packages that you would like included in your Theme. They will be added as "subpackages" in your theme package.
'
            ,style: {
                padding: '8px'
            }
        });
        Ext.each(TP.config.packages, function(p){
            items.push({
                xtype: 'checkbox'
                ,id: 'subpackage-' + p.replace(' ', '_')
                ,name: 'subpackages[]'
                ,boxLabel: p
                ,inputValue: p
                ,hideLabel: true
                ,style: {marginLeft: '17px'}
            });
        });
        ps = {
            title: 'Packages'
            ,items: items
        }
    }

    Ext.apply(config,{
        id: 'tp-panel-home'
        ,url: TP.config.connector_url
        ,baseParams: {
            action: 'build'
        }
        ,border: false
        ,baseCls: 'modx-formpanel'
        ,cls: 'container'
        ,fileUpload: true
        ,listeners: {
            'beforeSubmit': {fn:this.beforeSubmit,scope:this}
            ,'success': {fn:this.success,scope:this}
        }
        ,items: [{
            html: '
'+_('themepackagercomponent')+'
'
            ,border: false
            ,id: 'tp-home-header'
            ,cls: 'modx-page-header'
        },{
            xtype: 'modx-tabs'
            ,border: true
            ,autoDestroy: false
            ,deferredRender: false
            ,defaults: { border: false ,autoHeight: true, bodyStyle: 'padding: 17px;',labelWidth:200 }
            ,items: [{
                title: _('themepackagercomponent.package')
                ,draggable: false
                ,layout: 'form'
                ,defaults: {border:false,autoHeight:true,bodyStyle:'padding:8px;'}
                ,items: [{
                    html: _('themepackagercomponent.intro_msg')
                    ,border: false
                    ,style: {
                        paddingBottom: '9px'
                    }
                },{
                    xtype: 'textfield'
                    ,fieldLabel: _('themepackagercomponent.package_name')
                    ,description: _('themepackagercomponent.package_name_desc')
                    ,name: 'category'
                    ,id: 'tp-category-name'
                    ,value: _('themepackagercomponent.mypackage')
                },{
                    xtype: 'textfield'
                    ,name: 'version'
                    ,fieldLabel: _('themepackagercomponent.version')
                    ,description: _('themepackagercomponent.version_desc')
                    ,value: '1.0'
                },{
                    xtype: 'textfield'
                    ,name: 'release'
                    ,fieldLabel: _('themepackagercomponent.release')
                    ,description: _('themepackagercomponent.release_desc')
                    ,value: 'beta1'
                },{
                    xtype: 'checkboxgroup'
                    ,fieldLabel: 'Package All'
                    ,defaults: {
                        xtype: 'checkbox'
                        ,inputValue: 'yes'
                        ,checked: false
                    }
                    ,items: [
                        {
                            id: 'tpc-package-everything-checkbox'
                            ,name: 'everything'
                            ,boxLabel: _('themepackagercomponent.all_elements')
                            ,description: _('themepackagercomponent.all_elements_desc')
                            ,inputValue: 'yes'
                            ,checked: false
                            ,listeners: {
                                check: {
                                    fn: function (el, checked) {
                                        if (checked) {
                                            Ext.getCmp('tpc-tab-elements').disable();
                                            Ext.getCmp('tpc-tab-subpackages').disable();
                                        } else {
                                            Ext.getCmp('tpc-tab-elements').enable();
                                            Ext.getCmp('tpc-tab-subpackages').enable();
                                        }
                                    }
                                    ,scope: this
                                }
                            }
                        },{
                            id: 'tpc-package-allfiles-checkbox'
                            ,name: 'allfiles'
                            ,boxLabel: _('themepackagercomponent.all_files')
                            ,description: _('themepackagercomponent.all_files_desc')
                            ,inputValue: 'yes'
                            ,checked: false
                            ,listeners: {
                                check: {
                                    fn: function (el, checked) {
                                        if (checked) {
                                            Ext.getCmp('tpc-tab-directories').disable();
                                        } else {
                                            Ext.getCmp('tpc-tab-directories').enable();
                                        }
                                    }
                                    ,scope: this
                                }
                            }
                        }
                    ]
                },{
                    title: _('themepackagercomponent.install_options_title')
                    ,html: _('themepackagercomponent.enduser_option_desc')
                    ,style: {
                        paddingTop: '17px'
                    }
                },{
                    xtype:'fieldset'
                    ,defaults:{border:false,autoHeight:true}
                    ,items: [
                        {
                            xtype: 'compositefield'
                            ,defaults: {border:false,autoHeight:true}
                            ,items: [
                                {
                                    xtype: 'checkbox'
                                    ,id: 'tpc-enduser_option_merge-checkbox'
                                    ,name: 'enduser_option_merge'
                                    ,fieldLabel: _('themepackagercomponent.enduser_option_merge_label')
                                    ,checked: true
                                    ,inputValue: 'yes'
                                },{
                                    xtype:'fieldset'
                                    ,border: true
                                    ,defaults: {border:false, autoHeight:true}
                                    ,items: [
                                        {
                                            xtype: 'radiogroup'
                                            ,id: 'tpc-default-merge-option-picker'
                                            ,hidden: false
                                            ,fieldLabel: 'Default'
                                            ,description: 'Specify whether your Theme package will Merge with the user\'s site on install, or completely replace it.'
                                            ,defaults: {labelSeparator: ''}
                                            ,width: 200
                                            ,items: [
                                                {
                                                    xtype: 'radio'
                                                    ,id: 'tpc-default-merge-option-picker-merge'
                                                    ,name: 'enduser_install_action_default'
                                                    ,boxLabel: 'Add'
                                                    ,inputValue: 'merge'
                                                    ,checked: true
                                                }, {
                                                    xtype: 'radio'
                                                    ,id: 'tpc-default-merge-option-picker-replace'
                                                    ,name: 'enduser_install_action_default'
                                                    ,boxLabel: 'Overwrite'
                                                    ,inputValue: 'replace'
                                                }
                                            ]
                                        }
                                    ]
                                }
                            ]
                        },{
                            html: '' + _('themepackagercomponent.enduser_option_merge_desc') + ''
                        }
                    ]
                }
                ,{
                    xtype:'fieldset'
                    ,defaults:{border:false,autoHeight:true}
                    ,items: [
                        {
                            xtype: 'compositefield'
                            ,defaults:{border:false,autoHeight:true}
                            ,items:[
                                {
                                    xtype: 'checkbox'
                                    ,id: 'tpc-enduser-option-samplecontent'
                                    ,name: 'enduser_option_samplecontent'
                                    ,fieldLabel: _('themepackagercomponent.enduser_option_samplecontent_label')
                                    ,checked: true
                                    ,inputValue: 'yes'
                                },{
                                    xtype:'fieldset'
                                    ,border: true
                                    ,defaults: {border:false, autoHeight:true}
                                    ,items: [
                                        {
                                            xtype: 'radiogroup'
                                            ,id: 'tpc-default-samplecontent-picker'
                                            ,hidden: false
                                            ,fieldLabel: 'Default'
                                            ,description: 'Specify whether the Theme install will default to adding your sample content or not.'
                                            ,width: 200
                                            ,defaults: {labelSeparator: ''}
                                            ,items: [
                                                {
                                                    xtype: 'radio'
                                                    ,id: 'tpc-default-samplecontent-picker-yes'
                                                    ,name: 'enduser_install_samplecontent_default'
                                                    ,boxLabel: 'Yes'
                                                    ,inputValue: 'yes'
                                                    ,checked: true
                                                }, {
                                                    xtype: 'radio'
                                                    ,id: 'tpc-default-samplecontent-picker-no'
                                                    ,name: 'enduser_install_samplecontent_default'
                                                    ,boxLabel: 'No'
                                                    ,inputValue: 'no'
                                                }
                                            ]
                                        }
                                    ]
                                }
                            ]
                        },{
                            html: '' + _('themepackagercomponent.enduser_option_samplecontent_desc') + ''
                        }
                    ]
                }]
            },{
                title: _('themepackagercomponent.elements')
                ,id: 'tpc-tab-elements'
                ,disabled: false
                ,deferredRender: false
                ,defaults: { border: false ,autoHeight: true }
                ,items: [
                    // Templates
                    {
                        title: _('themepackagercomponent.templates')
                    },{
                        html: _('themepackagercomponent.templates.intro_msg')
                        ,style: {margin: '10px'}
                    },{
                        xtype: 'hidden'
                        ,id: 'tp-tree-templates-selected_ids'
                        ,name: 'tp_template_ids'
                        ,value: ''
                    },{
                        xtype: 'tp-tree-templates'
                        ,id: 'tp-tree-templates-panel'
                        ,style: {marginLeft: '10px'}
                        ,listeners: {
                            checkchange: function(el,checked) {
                                if (el.childNodes.length > 0) {
                                    for (var child in el.childNodes) {
                                        if (!isNaN(child)) {
                                            el.childNodes[child].ui.checkbox.checked = checked
                                            el.childNodes[child].attributes.checked = checked
                                        }
                                    }
                                }
                                this.updateSelected();
                            }
                        }
                    },{html: ' '}

                    // Chunks
                    ,{
                        title: _('themepackagercomponent.chunks')
                    },{
                        html: _('themepackagercomponent.chunks.intro_msg')
                        ,style: {margin: '10px'}
                    },{
                        xtype: 'hidden'
                        ,id: 'tp-tree-chunks-selected_ids'
                        ,name: 'tp_chunk_ids'
                        ,value: ''
                    }
                    ,{
                        xtype: 'tp-tree-chunks'
                        ,id: 'tp-tree-chunks-panel'
                        ,style: {marginLeft: '10px'}
                        ,listeners: {
                            checkchange: function(el,checked) {
                                if (el.childNodes.length > 0) {
                                    for (var child in el.childNodes) {
                                        if (!isNaN(child)) {
                                            el.childNodes[child].ui.checkbox.checked = checked
                                            el.childNodes[child].attributes.checked = checked
                                        }
                                    }
                                }
                                this.updateSelected();
                            }
                        }
                    },{html: ' '}

                    // Snippets
                    ,{
                        title: _('themepackagercomponent.snippets')
                    },{
                        html: _('themepackagercomponent.snippets.intro_msg')
                        ,style: {margin: '10px'}
                    },{
                        xtype: 'hidden'
                        ,id: 'tp-tree-snippets-selected_ids'
                        ,name: 'tp_snippet_ids'
                        ,value: ''
                    }
                    ,{
                        xtype: 'tp-tree-snippets'
                        ,id: 'tp-tree-snippets-panel'
                        ,style: {marginLeft: '10px'}
                        ,listeners: {
                            checkchange: function(el,checked) {
                                if (el.childNodes.length > 0) {
                                    for (var child in el.childNodes) {
                                        if (!isNaN(child)) {
                                            el.childNodes[child].ui.checkbox.checked = checked
                                            el.childNodes[child].attributes.checked = checked
                                        }
                                    }
                                }
                                this.updateSelected();
                            }
                        }
                    },{html: ' '}

                    // Plugins
                    ,{
                        title: _('themepackagercomponent.plugins')
                    },{
                        html: _('themepackagercomponent.plugins.intro_msg')
                        ,style: {margin: '10px'}
                    },{
                        xtype: 'hidden'
                        ,id: 'tp-tree-plugins-selected_ids'
                        ,name: 'tp_plugin_ids'
                        ,value: ''
                    }
                    ,{
                        xtype: 'tp-tree-plugins'
                        ,id: 'tp-tree-plugins-panel'
                        ,style: {marginLeft: '10px'}
                        ,listeners: {
                            checkchange: function(el,checked) {
                                if (el.childNodes.length > 0) {
                                    for (var child in el.childNodes) {
                                        if (!isNaN(child)) {
                                            el.childNodes[child].ui.checkbox.checked = checked
                                            el.childNodes[child].attributes.checked = checked
                                        }
                                    }
                                }
                                this.updateSelected();
                            }
                        }
                    },{html: ' '}
                    //,ps

                    // end of Elements tab
                ]
            }
            ,{
                title: _('themepackagercomponent.subpackages')
                ,id: 'tpc-tab-subpackages'
                ,disabled: false
                ,defaults: { border: false ,autoHeight: true }
                ,items: [{
                    html: _('themepackagercomponent.subpackages.intro_msg')
                },{
                    xtype: 'tp-grid-packages'
                    ,id: 'tp-grid-packages'
                    ,preventRender: true
                }]
            }
            ,{
                title: _('themepackagercomponent.directories')
                ,id: 'tpc-tab-directories'
                ,disabled: false
                ,defaults: { border: false ,autoHeight: true }
                ,items: [fs, {
                    title: 'Directories'
                    ,style: {
                        paddingTop: '17px'
                    }
                },{
                    html: _('themepackagercomponent.directories.intro_msg')
                    ,style: {
                        padding: '8px'
                    }
                },{
                    xtype: 'tp-grid-directories'
                    ,id: 'tp-grid-directories'
                    ,preventRender: true
                }]
            },{
                title: _('themepackagercomponent.advanced_title')
                ,id: 'tpc-tab-advanced'
                ,disabled: false
                ,layout: 'form'
                ,deferredRender: false
                ,defaults:{border:false,autoHeight:true}
                ,items: [
                    {
                        xtype: 'textfield'
                        ,id: 'tpc-advanced-settings'
                        ,name: 'settings'
                        ,grow: true
                        ,growMin: 250
                        ,growMax: 1000
                        ,fieldLabel: _('themepackagercomponent.advanced.settings')
                        ,regex: /^[a-zA-Z0-9_\s\.\-]+\s*(,\s*[a-zA-Z0-9_\s\.\-]+\s*)*$/
                        ,regexText: _('themepackagercomponent.advanced.settings_invalid')
                        ,msgTarget: 'under'
                    },{
                        html: '' + _('themepackagercomponent.advanced.settings_desc') + ''
                        ,style: {
                            marginBottom: '35px'
                            ,marginLeft: '15px'
                        }
                    },{
                        xtype: 'textfield'
                        ,fieldLabel: _('themepackagercomponent.resources_field')
                        ,name: 'resources'
                        ,id: 'tp-resource-list'
                        ,value: ''
                        ,regex: /^[0-9]+\s*(,\s*[0-9]+\s*)*$/
                        ,regexText: _('themepackagercomponent.resources_field_invalid')
                        ,msgTarget: 'under'
                    },{
                        html: '' + _('themepackagercomponent.resources_field_desc') + ''
                        ,style: {
                            marginBottom: '35px'
                            ,marginLeft: '17px'
                        }
                    }
                ]
            }]
        }]
    });
    TP.panel.Home.superclass.constructor.call(this,config);
};
Ext.extend(TP.panel.Home,MODx.FormPanel,{
    beforeSubmit: function(o) {
        Ext.apply(o.form.baseParams,{
            templates: Ext.getCmp('tp-tree-templates-selected_ids').getValue()
            ,chunks: Ext.getCmp('tp-tree-chunks-selected_ids').getValue()
            ,plugins: Ext.getCmp('tp-tree-plugins-selected_ids').getValue()
            ,snippets: Ext.getCmp('tp-tree-snippets-selected_ids').getValue()
            ,packages: Ext.getCmp('tp-grid-packages').encode()
            ,directories: Ext.getCmp('tp-grid-directories').encode()
        });
    }
    ,success: function(o) {
        if (o.result.success) {
            var name = o.result.message;

            Ext.getCmp('tp-btn-export').setDisabled(false);
            Ext.getCmp('tp-grid-packages').getStore().commitChanges();
            Ext.getCmp('tp-grid-directories').getStore().commitChanges();

            location.href = TP.config.connector_url+'?action=build&download='+name+'&HTTP_MODAUTH='+MODx.siteId;
        }
    }
});
Ext.reg('tp-panel-home',TP.panel.Home);<|endoftext|>


<commit_before>/*
 * Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 */

/*jslint vars: true, plusplus: true, devel: true, node: true, nomen: true, indent: 4, maxerr: 50 */

"use strict";

var fs = require("fs");

var _domainManager,
    _watcherMap = {};

/**
 * Watch a file or directory.
 * @param {string} path File or directory to watch.
 */
function watchPath(path) {
    if (_watcherMap.hasOwnProperty(path)) {
        console.warn("Watcher already registered for path: " + path);
        return;
    }

    _watcherMap[path] = fs.watch(path, {persistent: false}, function (event, filename) {
        // File/directory changes are emitted as "change" events on the fileWatcher domain.
        _domainManager.emitEvent("fileWatcher", "change", [path, event, filename]);
    });
}

/**
 * Un-watch a file or directory.
 * @param {string} path File or directory to unwatch.
 */
function unwatchPath(path) {
    var watcher = _watcherMap[path];

    if (watcher) {
        watcher.close();
        delete _watcherMap[path];
    }
}

/**
 * Un-watch all files and directories.
 */
function unwatchAll() {
    var path;

    for (path in _watcherMap) {
        if (_watcherMap.hasOwnProperty(path)) {
            unwatchPath(path);
        }
    }
}

/**
 * Initialize the "fileWatcher" domain.
 * The fileWatcher domain handles watching and un-watching directories.
 */
function init(domainManager) {
    if (!domainManager.hasDomain("fileWatcher")) {
        domainManager.registerDomain("fileWatcher", {major: 0, minor: 1});
    }
    domainManager.registerCommand(
        "fileWatcher",
        "watchPath",
        watchPath,
        false,
        "Start watching a file or directory",
        [{
            name: "path",
            type: "string",
            description: "absolute filesystem path of the file or directory to watch"
        }]
    );
    domainManager.registerCommand(
        "fileWatcher",
        "unwatchPath",
        unwatchPath,
        false,
        "Stop watching a file or directory",
        [{
            name: "path",
            type: "string",
            description: "absolute filesystem path of the file or directory to unwatch"
        }]
    );
    domainManager.registerCommand(
        "fileWatcher",
        "unwatchAll",
        unwatchAll,
        false,
        "Stop watching all files and directories"
    );
    domainManager.registerEvent(
        "fileWatcher",
        "change",
        [
            {name: "path", type: "string"},
            {name: "event", type: "string"},
            {name: "filename", type: "string"}
        ]
    );

    _domainManager = domainManager;
}

exports.init = init;

<commit_msg>Remove superfluous warning message<commit_after>/*
 * Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 */

/*jslint vars: true, plusplus: true, devel: true, node: true, nomen: true, indent: 4, maxerr: 50 */

"use strict";

var fs = require("fs");

var _domainManager,
    _watcherMap = {};

/**
 * Watch a file or directory.
 * @param {string} path File or directory to watch.
 */
function watchPath(path) {
    if (_watcherMap.hasOwnProperty(path)) {
        return;
    }

    _watcherMap[path] = fs.watch(path, {persistent: false}, function (event, filename) {
        // File/directory changes are emitted as "change" events on the fileWatcher domain.
        _domainManager.emitEvent("fileWatcher", "change", [path, event, filename]);
    });
}

/**
 * Un-watch a file or directory.
 * @param {string} path File or directory to unwatch.
 */
function unwatchPath(path) {
    var watcher = _watcherMap[path];

    if (watcher) {
        watcher.close();
        delete _watcherMap[path];
    }
}

/**
 * Un-watch all files and directories.
 */
function unwatchAll() {
    var path;

    for (path in _watcherMap) {
        if (_watcherMap.hasOwnProperty(path)) {
            unwatchPath(path);
        }
    }
}

/**
 * Initialize the "fileWatcher" domain.
 * The fileWatcher domain handles watching and un-watching directories.
 */
function init(domainManager) {
    if (!domainManager.hasDomain("fileWatcher")) {
        domainManager.registerDomain("fileWatcher", {major: 0, minor: 1});
    }
    domainManager.registerCommand(
        "fileWatcher",
        "watchPath",
        watchPath,
        false,
        "Start watching a file or directory",
        [{
            name: "path",
            type: "string",
            description: "absolute filesystem path of the file or directory to watch"
        }]
    );
    domainManager.registerCommand(
        "fileWatcher",
        "unwatchPath",
        unwatchPath,
        false,
        "Stop watching a file or directory",
        [{
            name: "path",
            type: "string",
            description: "absolute filesystem path of the file or directory to unwatch"
        }]
    );
    domainManager.registerCommand(
        "fileWatcher",
        "unwatchAll",
        unwatchAll,
        false,
        "Stop watching all files and directories"
    );
    domainManager.registerEvent(
        "fileWatcher",
        "change",
        [
            {name: "path", type: "string"},
            {name: "event", type: "string"},
            {name: "filename", type: "string"}
        ]
    );

    _domainManager = domainManager;
}

exports.init = init;

<|endoftext|>


<commit_before>/*
  SortTable
  version 2
  7th April 2007
  Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/

  Instructions:
  Download this file
  Add <script src="sorttable.js"></script> to your HTML
  Add class="sortable" to any table you'd like to make sortable
  Click on the headers to sort

  Thanks to many, many people for contributions and suggestions.
  Licenced as X11: http://www.kryogenix.org/code/browser/licence.html
  This basically means: do what you want with it.
*/

sorttable = {
  numberRegExp: /^-?[$]?[\d,.]+%?$/,

  makeSortable: function(table) {
    var i, j;

    if (table.getElementsByTagName('thead').length === 0) {
      // table doesn't have a tHead. Since it should have, create one and
      // put the first table row in it.
      the = document.createElement('thead');
      the.appendChild(table.rows[0]);
      table.insertBefore(the,table.firstChild);
    }
    // Safari doesn't support table.tHead, sigh
    if (table.tHead === null) table.tHead = table.getElementsByTagName('thead')[0];

    if (table.tHead.rows.length != 1) return; // can't cope with two header rows

    // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as
    // "total" rows, for example). This is B&R, since what you're supposed
    // to do is put them in a tfoot. So, if there are sortbottom rows,
    // for backwards compatibility, move them to tfoot (creating it if needed).
    sortbottomrows = [];
    for (i = 0; i<table.rows.length; i++) {
      if (table.rows[i].className.search(/\bsortbottom\b/) != -1) {
        sortbottomrows[sortbottomrows.length] = table.rows[i];
      }
    }
    if (sortbottomrows) {
      if (table.tFoot === null) {
        // table doesn't have a tfoot. Create one.
        tfo = document.createElement('tfoot');
        table.appendChild(tfo);
      }
      for (i = 0; i<sortbottomrows.length; i++) {
        tfo.appendChild(sortbottomrows[i]);
      }
      delete sortbottomrows;
    }

    // work through each column and calculate its type
    headrow = table.tHead.rows[0].cells;
    for (i = 0; i<headrow.length; i++) {
      // manually override the type with a sorttable_type attribute
      if (!headrow[i].className.match(/\bsorttable_nosort\b/)) { // skip this col
        mtch = headrow[i].className.match(/\bsorttable_([a-z0-9]+)\b/);
        if (mtch) { override = mtch[1]; }
        if (mtch && typeof sorttable["sort_"+override] == 'function') {
          headrow[i].sorttable_sortfunction = sorttable["sort_"+override];
        } else {
          headrow[i].sorttable_sortfunction = sorttable.guessType(table,i);
        }
        // make it clickable to sort
        headrow[i].sorttable_columnindex = i;
        headrow[i].sorttable_tbody = table.tBodies[0];
        headrow[i].addEventListener('click', sorttable.innerSortFunction = function(e) {

          if (this.className.search(/\bsorttable_sorted\b/) != -1) {
            // if we're already sorted by this column, just
            // reverse the table, which is quicker
            sorttable.reverse(this.sorttable_tbody);
            this.className = this.className.replace('sorttable_sorted',
                                                    'sorttable_sorted_reverse');
            this.removeChild(document.getElementById('sorttable_sortfwdind'));
            sortrevind = document.createElement('span');
            sortrevind.id = "sorttable_sortrevind";
            sortrevind.innerHTML = ' ▴';
            this.appendChild(sortrevind);
            return;
          }
          if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) {
            // if we're already sorted by this column in reverse, just
            // re-reverse the table, which is quicker
            sorttable.reverse(this.sorttable_tbody);
            this.className = this.className.replace('sorttable_sorted_reverse',
                                                    'sorttable_sorted');
            this.removeChild(document.getElementById('sorttable_sortrevind'));
            sortfwdind = document.createElement('span');
            sortfwdind.id = "sorttable_sortfwdind";
            sortfwdind.innerHTML = ' ▾';
            this.appendChild(sortfwdind);
            return;
          }

          // remove sorttable_sorted classes
          theadrow = this.parentNode;
          Array.prototype.slice.call(theadrow.childNodes).forEach(function(cell) {
            if (cell.nodeType == 1) { // an element
              cell.className = cell.className.replace('sorttable_sorted_reverse','');
              cell.className = cell.className.replace('sorttable_sorted','');
            }
          });
          sortfwdind = document.getElementById('sorttable_sortfwdind');
          if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); }
          sortrevind = document.getElementById('sorttable_sortrevind');
          if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); }

          this.className += ' sorttable_sorted';
          sortfwdind = document.createElement('span');
          sortfwdind.id = "sorttable_sortfwdind";
          sortfwdind.innerHTML = ' ▾';
          this.appendChild(sortfwdind);

          // build an array to sort. This is a Schwartzian transform thing,
          // i.e., we "decorate" each row with the actual sort key,
          // sort based on the sort keys, and then put the rows back in order
          // which is a lot faster because you only do getCellValue once per row
          row_array = [];
          col = this.sorttable_columnindex;
          rows = this.sorttable_tbody.rows;
          for (var j=0; j<rows.length; j++) {
            row_array[row_array.length] = [sorttable.getCellValue(rows[j].cells[col]), rows[j]];
          }

          row_array.sort(this.sorttable_sortfunction);

          tb = this.sorttable_tbody;
          for (j = 0; j<row_array.length; j++) {
            tb.appendChild(row_array[j][1]);
          }

          delete row_array;
        });
      }
    }
  },

  guessType: function(table, column) {
    var i, sortfn;

    sortfn = sorttable.sortAlpha;

    for (i = 0; i < table.tBodies[0].rows.length; i++) {
      text = sorttable.getCellValue(table.tBodies[0].rows[i].cells[column]);

      if (text !== '' && text.match(sorttable.numberRegExp)) {
        return sorttable.sortNumeric;
      }
    }

    return sortfn;
  },

  getCellValue: function(node) {
    if (!node) return '';

    if (node.getAttribute('data-value') !== null) {
      return node.getAttribute('data-value');
    }

    return node.innerText.replace(/^\s+|\s+$/g, '');
  },

  reverse: function(tbody) {
    // reverse the rows in a tbody
    var i;
    newrows = [];
    for (i=0; i<tbody.rows.length; i++) {
      newrows[newrows.length] = tbody.rows[i];
    }
    for (i=newrows.length-1; i>=0; i--) {
       tbody.appendChild(newrows[i]);
    }
    delete newrows;
  },

  /* sort functions
     each sort function takes two parameters, a and b
     you are comparing a[0] and b[0] */
  sortNumeric: function(a,b) {
    var aa = parseFloat(a[0].replace(/[^0-9.-]/g, '')),
        bb = parseFloat(b[0].replace(/[^0-9.-]/g, ''))
    ;
    if (isNaN(aa)) aa = 0;
    if (isNaN(bb)) bb = 0;
    return aa - bb;
  },

  sortAlpha: function(a, b) {
    var aa = a[0].toLowerCase(),
        bb = b[0].toLowerCase()
    ;
    if (aa === bb) return 0;
    if (aa < bb) return -1;
    return 1;
  }
};<commit_msg>Remove unneeded function assignment<commit_after>/*
  SortTable
  version 2
  7th April 2007
  Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/

  Instructions:
  Download this file
  Add <script src="sorttable.js"></script> to your HTML
  Add class="sortable" to any table you'd like to make sortable
  Click on the headers to sort

  Thanks to many, many people for contributions and suggestions.
  Licenced as X11: http://www.kryogenix.org/code/browser/licence.html
  This basically means: do what you want with it.
*/

sorttable = {
  numberRegExp: /^-?[$]?[\d,.]+%?$/,

  makeSortable: function(table) {
    var i, j;

    if (table.getElementsByTagName('thead').length === 0) {
      // table doesn't have a tHead. Since it should have, create one and
      // put the first table row in it.
      the = document.createElement('thead');
      the.appendChild(table.rows[0]);
      table.insertBefore(the,table.firstChild);
    }
    // Safari doesn't support table.tHead, sigh
    if (table.tHead === null) table.tHead = table.getElementsByTagName('thead')[0];

    if (table.tHead.rows.length != 1) return; // can't cope with two header rows

    // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as
    // "total" rows, for example). This is B&R, since what you're supposed
    // to do is put them in a tfoot. So, if there are sortbottom rows,
    // for backwards compatibility, move them to tfoot (creating it if needed).
    sortbottomrows = [];
    for (i = 0; i<table.rows.length; i++) {
      if (table.rows[i].className.search(/\bsortbottom\b/) != -1) {
        sortbottomrows[sortbottomrows.length] = table.rows[i];
      }
    }
    if (sortbottomrows) {
      if (table.tFoot === null) {
        // table doesn't have a tfoot. Create one.
        tfo = document.createElement('tfoot');
        table.appendChild(tfo);
      }
      for (i = 0; i<sortbottomrows.length; i++) {
        tfo.appendChild(sortbottomrows[i]);
      }
      delete sortbottomrows;
    }

    // work through each column and calculate its type
    headrow = table.tHead.rows[0].cells;
    for (i = 0; i<headrow.length; i++) {
      // manually override the type with a sorttable_type attribute
      if (!headrow[i].className.match(/\bsorttable_nosort\b/)) { // skip this col
        mtch = headrow[i].className.match(/\bsorttable_([a-z0-9]+)\b/);
        if (mtch) { override = mtch[1]; }
        if (mtch && typeof sorttable["sort_"+override] == 'function') {
          headrow[i].sorttable_sortfunction = sorttable["sort_"+override];
        } else {
          headrow[i].sorttable_sortfunction = sorttable.guessType(table,i);
        }
        // make it clickable to sort
        headrow[i].sorttable_columnindex = i;
        headrow[i].sorttable_tbody = table.tBodies[0];
        headrow[i].addEventListener('click', function(e) {

          if (this.className.search(/\bsorttable_sorted\b/) != -1) {
            // if we're already sorted by this column, just
            // reverse the table, which is quicker
            sorttable.reverse(this.sorttable_tbody);
            this.className = this.className.replace('sorttable_sorted',
                                                    'sorttable_sorted_reverse');
            this.removeChild(document.getElementById('sorttable_sortfwdind'));
            sortrevind = document.createElement('span');
            sortrevind.id = "sorttable_sortrevind";
            sortrevind.innerHTML = ' ▴';
            this.appendChild(sortrevind);
            return;
          }
          if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) {
            // if we're already sorted by this column in reverse, just
            // re-reverse the table, which is quicker
            sorttable.reverse(this.sorttable_tbody);
            this.className = this.className.replace('sorttable_sorted_reverse',
                                                    'sorttable_sorted');
            this.removeChild(document.getElementById('sorttable_sortrevind'));
            sortfwdind = document.createElement('span');
            sortfwdind.id = "sorttable_sortfwdind";
            sortfwdind.innerHTML = ' ▾';
            this.appendChild(sortfwdind);
            return;
          }

          // remove sorttable_sorted classes
          theadrow = this.parentNode;
          Array.prototype.slice.call(theadrow.childNodes).forEach(function(cell) {
            if (cell.nodeType == 1) { // an element
              cell.className = cell.className.replace('sorttable_sorted_reverse','');
              cell.className = cell.className.replace('sorttable_sorted','');
            }
          });
          sortfwdind = document.getElementById('sorttable_sortfwdind');
          if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); }
          sortrevind = document.getElementById('sorttable_sortrevind');
          if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); }

          this.className += ' sorttable_sorted';
          sortfwdind = document.createElement('span');
          sortfwdind.id = "sorttable_sortfwdind";
          sortfwdind.innerHTML = ' ▾';
          this.appendChild(sortfwdind);

          // build an array to sort. This is a Schwartzian transform thing,
          // i.e., we "decorate" each row with the actual sort key,
          // sort based on the sort keys, and then put the rows back in order
          // which is a lot faster because you only do getCellValue once per row
          row_array = [];
          col = this.sorttable_columnindex;
          rows = this.sorttable_tbody.rows;
          for (var j=0; j<rows.length; j++) {
            row_array[row_array.length] = [sorttable.getCellValue(rows[j].cells[col]), rows[j]];
          }

          row_array.sort(this.sorttable_sortfunction);

          tb = this.sorttable_tbody;
          for (j = 0; j<row_array.length; j++) {
            tb.appendChild(row_array[j][1]);
          }

          delete row_array;
        });
      }
    }
  },

  guessType: function(table, column) {
    var i, sortfn;

    sortfn = sorttable.sortAlpha;

    for (i = 0; i < table.tBodies[0].rows.length; i++) {
      text = sorttable.getCellValue(table.tBodies[0].rows[i].cells[column]);

      if (text !== '' && text.match(sorttable.numberRegExp)) {
        return sorttable.sortNumeric;
      }
    }

    return sortfn;
  },

  getCellValue: function(node) {
    if (!node) return '';

    if (node.getAttribute('data-value') !== null) {
      return node.getAttribute('data-value');
    }

    return node.innerText.replace(/^\s+|\s+$/g, '');
  },

  reverse: function(tbody) {
    // reverse the rows in a tbody
    var i;
    newrows = [];
    for (i=0; i<tbody.rows.length; i++) {
      newrows[newrows.length] = tbody.rows[i];
    }
    for (i=newrows.length-1; i>=0; i--) {
       tbody.appendChild(newrows[i]);
    }
    delete newrows;
  },

  /* sort functions
     each sort function takes two parameters, a and b
     you are comparing a[0] and b[0] */
  sortNumeric: function(a,b) {
    var aa = parseFloat(a[0].replace(/[^0-9.-]/g, '')),
        bb = parseFloat(b[0].replace(/[^0-9.-]/g, ''))
    ;
    if (isNaN(aa)) aa = 0;
    if (isNaN(bb)) bb = 0;
    return aa - bb;
  },

  sortAlpha: function(a, b) {
    var aa = a[0].toLowerCase(),
        bb = b[0].toLowerCase()
    ;
    if (aa === bb) return 0;
    if (aa < bb) return -1;
    return 1;
  }
};<|endoftext|>


<commit_before>var Widgets = {
	connections : [
		{
			id : 1,
			dir1 : "is my classmate",
			dir2 : "is my classmate"
		},
		{
			id: 2,
			dir1 : "is my supervisor",
			dir2 : "is being supervised by me"
		},
		{
			id: 3,
			dir1 : "is being supervised by me",
			dir2 : "is my supervisor"
		},
		{
			id: 4,
			dir1 : "is my lecturer",
			dir2 : "is my student"
		},
		{
			id: 5,
			dir1 : "is my student",
			dir2 : "is my lecturer"
		},
		{
			id: 6,
			dir1 : "is my colleague",
			dir2 : "is my colleague"
		},
		{
			id: 7,
			dir1 : "is my college mate",
			dir2 : "is my college mate"
		},
		{
			id: 8,
			dir1 : "shares an interest with me",
			dir2 : "shares an interest with me"
		},
		{
			id: 9,
			dir1 : "is something else",
			dir2 : "is something else"
		}
	],
	groups:[
		"Administrators",
		"Lecturers & Supervisors",
		"Researchers",
		"Students"],
	layouts : {
		onecolumn :
		{
			name:"One column",
			widths:[100]
		},
		dev :
		{
			name:"Dev Layout",
			widths:[50,50]
		},
		threecolumn :
		{
			name:"Three equal columns",
			widths:[33,33,33]
		},
		fourcolumn :
		{
			name:"Four equal columns",
			widths:[25,25,25,25]
		},
		fivecolumn :
		{
			name:"Five equal columns",
			widths:[20,20,20,20,20]
		}
	},
	widgets: {
		changepic :
		{
			description:"",
			iframe:0,
			url:"/devwidgets/changepic/changepic.html",
			name:"changepic",
			id:"changepic",
			personalportal:0,
			siteportal:0,
			img:"/dev/img/sites.png"
		},
		sites :
		{
			description:"Listing of the sites I'm a member of\r\n",
			iframe:0,
			url:"/devwidgets/sites/sites.html",
			name:"My Courses & Sites",
			id:"sites",
			personalportal:1,
			siteportal:0,
			img:"/dev/img/sites.png"
		},
		myprofile :
		{
			description:"My Personal Profile\r\n",
			iframe:0,
			url:"/devwidgets/myprofile/myprofile.html",
			name:"My Profile",
			id:"myprofile",
			personalportal:1,
			siteportal:0,
			img:"/dev/img/myprofile.png"
		},
		discussion :
		{
			description:"Discussion widget\r\n",
			iframe:0,
			url:"/devwidgets/discussion/discussion.html",
			name:"Discussion",
			id:"discussion",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:0,
			showinsakaigoodies:1,
			img:"/dev/img/myprofile.png"
		},
		poll :
		{
			description:"Poll widget\r\n",
			iframe:0,
			url:"/devwidgets/poll/poll.html",
			name:"Poll",
			id:"poll",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:0,
			showinsakaigoodies:1,
			img:"/dev/img/myprofile.png"
		},
		wookiechat :
		{
			description:"wookiechat\r\n",
			iframe:0,
			url:"/devwidgets/wookiechat/wookiechat.html",
			name:"Chat",
			id:"wookiechat",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:0,
			showinsakaigoodies:1,
			img:"/dev/img/myprofile.png"
		},
		wookieforum :
		{
			description:"wookieforum\r\n",
			iframe:0,
			url:"/devwidgets/wookieforum/wookieforum.html",
			name:"Wookie Forum",
			id:"wookieforum",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:0,
			showinsakaigoodies:0,
			img:"/dev/img/myprofile.png"
		},
		helloworld :
		{
			description:"Sakai Hackathon Example\r\n",
			iframe:0,
			url:"/devwidgets/helloworld/helloworld.html",
			name:"Hello World",
			id:"helloworld",
			personalportal:1,
			siteportal:0,
			hasSettings: 1,
			img:"/dev/img/myprofile.png"
		},
		sparkline :
		{
			description:"Sparkline\r\n",
			iframe:0,
			url:"/devwidgets/sparkline/sparkline.html",
			name:"Sparkline",
			id:"sparkline",
			personalportal:0,
			siteportal:1,
			img:"/dev/img/sparkline.png"
		},
		createsite :
		{
			description:"Create site\r\n",
			iframe:0,
			url:"/devwidgets/createsite/createsite.html",
			name:"Create Site",
			id:"createsite",
			personalportal:0,
			siteportal:0,
			img:"/dev/img/sites.png"
		},
		sendmessage :
		{
			description:"Send a message\r\n",
			iframe:0,
			url:"/devwidgets/sendmessage/sendmessage.html",
			name:"Send a message",
			id:"sendmessage",
			personalportal:0,
			siteportal:0,
			img:"/dev/img/sites.png"
		},
		myfriends :
		{
			description:"A list of my connections\r\n",
			iframe:0,
			url:"/devwidgets/myfriends/myfriends.html",
			name:"My Contacts",
			id:"myfriends",
			personalportal:1,
			siteportal:0,
			img:"/dev/img/myprofile.png",
			multipleinstance: false
		},
		announcementupdates :
		{
			description:"A list of Announcements & Updates\r\n",
			iframe:0,
			url:"/devwidgets/announcementupdates/announcementupdates.html",
			name:"Announcements & Updates",
			id:"announcementupdates",
			personalportal:0,
			siteportal:1,
			img:"/dev/img/myprofile.png",
			multipleinstance: false
		},
		pagemanagement :
		{
			description:"pagemanagement",
			iframe:0,
			url:"/devwidgets/pagemanagement/pagemanagement.html",
			name:"pagemanagement",
			id:"pagemanagement",
			personalportal:0,
			siteportal:0
		},
		mypreferences :
		{
			description:"mypreferences",
			iframe:0,
			url:"/devwidgets/mypreferences/mypreferences.html",
			name:"mypreferences",
			id:"mypreferences",
			personalportal:0,
			siteportal:0
		},
		myinbox :
		{
			description:"myinbox",
			iframe:0,
			url:"/devwidgets/myinbox/myinbox.html",
			name:"myinbox",
			id:"myinbox",
			personalportal:0,
			siteportal:0
		},
		sitemembers :
		{
			description:"Shows a list of all of the members of this site",
			iframe:0,
			url:"/devwidgets/sitemembers/sitemembers.html",
			name:"Site Members",
			id:"sitemembers",
			personalportal:0,
			siteportal:1,
			img:"/devwidgets/sitemembers/images/icon.png"
		},
		chat :
		{
			description:"chat",
			iframe:0,
			url:"/devwidgets/chat/chat.html",
			name:"chat",
			id:"chat",
			personalportal:0,
			siteportal:0
		},
		siterecentactivity :
		{
			description:"Site Recent Activity",
			iframe:0,
			url:"/devwidgets/siterecentactivity/siterecentactivity.html",
			name:"Recent Activity",
			id:"siterecentactivity",
			personalportal:0,
			siteportal:0,
			ca:1,
			img:"/devwidgets/siterecentactivity/images/icon.png"
		},
		navigation :
		{
			description:"Navigation Widgets",
			iframe:0,
			url:"/devwidgets/navigation/navigation.html",
			name:"Navigation",
			id:"navigation",
			personalportal:0,
			siteportal:0,
			ca:1,
			img:"/devwidgets/navigation/images/icon.png"
		},
		youtubevideo :
		{
			description:"YouTube Video",
			iframe:0,
			url:"/devwidgets/youtubevideo/youtubevideo.html",
			name:"YouTube Video",
			id:"youtubevideo",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:0,
			showinsakaigoodies:0,
			img:"/devwidgets/youtubevideo/images/icon.png"
		},
		rss :
		{
			description:"RSS Feed",
			iframe:0,
			url:"/devwidgets/rss/rss.html",
			name:"RSS Feed",
			id:"rss",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:0,
			showinsakaigoodies:1,
			img:"/devwidgets/youtubevideo/images/icon.png"
		},
		video :
		{
			description:"Video",
			iframe:0,
			url:"/devwidgets/video/video.html",
			name:"Video",
			id:"video",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:1,
			showinsakaigoodies:0,
			img:"/devwidgets/youtubevideo/images/icon.png"
		},
		comments :
		{
			description:"Comments",
			iframe:0,
			url:"/devwidgets/comments/commentswow.html",
			name:"Comments",
			id:"comments",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:0,
			showinsakaigoodies:1,
			img:"/devwidgets/youtubevideo/images/icon.png"
		},
		remotecontent :
		{
			description:"Remote Content",
			iframe:0,
			url:"/devwidgets/remotecontent/remotecontent.html",
			name:"Remote Content",
			id:"remotecontent",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:0,
			showinsakaigoodies:1,
			img:"/devwidgets/youtubevideo/images/icon.png"
		},
		tangler :
		{
			description:"Tangler Forum",
			iframe:0,
			url:"/devwidgets/tangler/tangler.html",
			name:"Tangler Forum",
			id:"tangler",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:0,
			showinsakaigoodies:1,
			img:"/devwidgets/tangler/images/tangler.png"
		},
		singlefile :
		{
			description:"Single File Reference",
			iframe:0,
			url:"/devwidgets/singlefile/singlefile.html",
			name:"Single File Reference",
			id:"singlefile",
			personalportal:0,
			siteportal:0,
			ca:0,
			img:"/devwidgets/singlefile/images/singlefile.png"
		},
		Resources :
		{
			description:"Resources tool",
			iframe:"0",
			url:"/devwidgets/Resources/Resources.html",
			name:"Resources",
			id:"resources",
			personalportal:0,
			siteportal:0,
			history : {"init":"Resources.initHistory","nav":"Resources.browser.printResources",tag:"Resources.tagging.showTagViewReal"}
		},
		polltracker :
		{
			description:"Track the results of all of the polls on the sites you are a member of",
			iframe:0,
			url:"/devwidgets/polltracker/polltracker.html",
			name:"Poll Tracker",
			id:"polltracker",
			personalportal:1,
			siteportal:0,
			multipleinstance: true,
			img:"/devwidgets/polltracker/images/poll_icon.gif"
		}
	},
	orders:[
		{
			grouptype:"General",
			widgets: ["mycoursesandprojects","messageoftheday","recentactivity"],
			id:1,
			layout: "twocolumnspecial"
		},
		{
			grouptype:"Administrators",
			widgets: ["mycoursesandprojects","messageoftheday","quickannouncement"],
			id:1,
			layout: "twocolumn"
		},
		{
			grouptype:"Lecturers & Supervisors",
			widgets:["mycoursesandprojects","recentactivity"],
			id:2,
			layout: "twocolumnspecial"
		},
		{
			grouptype:"Researchers",
			widgets:["recentactivity","mycoursesandprojects","messageoftheday"],
			id:3,
			layout: "threecolumn"
		},
		{
			grouptype:"Students",
			widgets:["recentactivity","mycoursesandprojects","quickannouncement","messageoftheday","myrssfeed"],
			id:4,
			layout: "fourcolumn"
		}
	]
};<commit_msg>NOJIRA Adding in the linktool to the configuration file<commit_after>var Widgets = {
	connections : [
		{
			id : 1,
			dir1 : "is my classmate",
			dir2 : "is my classmate"
		},
		{
			id: 2,
			dir1 : "is my supervisor",
			dir2 : "is being supervised by me"
		},
		{
			id: 3,
			dir1 : "is being supervised by me",
			dir2 : "is my supervisor"
		},
		{
			id: 4,
			dir1 : "is my lecturer",
			dir2 : "is my student"
		},
		{
			id: 5,
			dir1 : "is my student",
			dir2 : "is my lecturer"
		},
		{
			id: 6,
			dir1 : "is my colleague",
			dir2 : "is my colleague"
		},
		{
			id: 7,
			dir1 : "is my college mate",
			dir2 : "is my college mate"
		},
		{
			id: 8,
			dir1 : "shares an interest with me",
			dir2 : "shares an interest with me"
		},
		{
			id: 9,
			dir1 : "is something else",
			dir2 : "is something else"
		}
	],
	groups:[
		"Administrators",
		"Lecturers & Supervisors",
		"Researchers",
		"Students"],
	layouts : {
		onecolumn :
		{
			name:"One column",
			widths:[100]
		},
		dev :
		{
			name:"Dev Layout",
			widths:[50,50]
		},
		threecolumn :
		{
			name:"Three equal columns",
			widths:[33,33,33]
		},
		fourcolumn :
		{
			name:"Four equal columns",
			widths:[25,25,25,25]
		},
		fivecolumn :
		{
			name:"Five equal columns",
			widths:[20,20,20,20,20]
		}
	},
	widgets: {
		changepic :
		{
			description:"",
			iframe:0,
			url:"/devwidgets/changepic/changepic.html",
			name:"changepic",
			id:"changepic",
			personalportal:0,
			siteportal:0,
			img:"/dev/img/sites.png"
		},
		sites :
		{
			description:"Listing of the sites I'm a member of\r\n",
			iframe:0,
			url:"/devwidgets/sites/sites.html",
			name:"My Courses & Sites",
			id:"sites",
			personalportal:1,
			siteportal:0,
			img:"/dev/img/sites.png"
		},
		myprofile :
		{
			description:"My Personal Profile\r\n",
			iframe:0,
			url:"/devwidgets/myprofile/myprofile.html",
			name:"My Profile",
			id:"myprofile",
			personalportal:1,
			siteportal:0,
			img:"/dev/img/myprofile.png"
		},
		discussion :
		{
			description:"Discussion widget\r\n",
			iframe:0,
			url:"/devwidgets/discussion/discussion.html",
			name:"Discussion",
			id:"discussion",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:0,
			showinsakaigoodies:1,
			img:"/dev/img/myprofile.png"
		},
		poll :
		{
			description:"Poll widget\r\n",
			iframe:0,
			url:"/devwidgets/poll/poll.html",
			name:"Poll",
			id:"poll",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:0,
			showinsakaigoodies:1,
			img:"/dev/img/myprofile.png"
		},
		wookiechat :
		{
			description:"wookiechat\r\n",
			iframe:0,
			url:"/devwidgets/wookiechat/wookiechat.html",
			name:"Chat",
			id:"wookiechat",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:0,
			showinsakaigoodies:1,
			img:"/dev/img/myprofile.png"
		},
		wookieforum :
		{
			description:"wookieforum\r\n",
			iframe:0,
			url:"/devwidgets/wookieforum/wookieforum.html",
			name:"Wookie Forum",
			id:"wookieforum",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:0,
			showinsakaigoodies:0,
			img:"/dev/img/myprofile.png"
		},
		helloworld :
		{
			description:"Sakai Hackathon Example\r\n",
			iframe:0,
			url:"/devwidgets/helloworld/helloworld.html",
			name:"Hello World",
			id:"helloworld",
			personalportal:1,
			siteportal:0,
			hasSettings: 1,
			img:"/dev/img/myprofile.png"
		},
		sparkline :
		{
			description:"Sparkline\r\n",
			iframe:0,
			url:"/devwidgets/sparkline/sparkline.html",
			name:"Sparkline",
			id:"sparkline",
			personalportal:0,
			siteportal:1,
			img:"/dev/img/sparkline.png"
		},
		createsite :
		{
			description:"Create site\r\n",
			iframe:0,
			url:"/devwidgets/createsite/createsite.html",
			name:"Create Site",
			id:"createsite",
			personalportal:0,
			siteportal:0,
			img:"/dev/img/sites.png"
		},
		sendmessage :
		{
			description:"Send a message\r\n",
			iframe:0,
			url:"/devwidgets/sendmessage/sendmessage.html",
			name:"Send a message",
			id:"sendmessage",
			personalportal:0,
			siteportal:0,
			img:"/dev/img/sites.png"
		},
		myfriends :
		{
			description:"A list of my connections\r\n",
			iframe:0,
			url:"/devwidgets/myfriends/myfriends.html",
			name:"My Contacts",
			id:"myfriends",
			personalportal:1,
			siteportal:0,
			img:"/dev/img/myprofile.png",
			multipleinstance: false
		},
		announcementupdates :
		{
			description:"A list of Announcements & Updates\r\n",
			iframe:0,
			url:"/devwidgets/announcementupdates/announcementupdates.html",
			name:"Announcements & Updates",
			id:"announcementupdates",
			personalportal:0,
			siteportal:1,
			img:"/dev/img/myprofile.png",
			multipleinstance: false
		},
		pagemanagement :
		{
			description:"pagemanagement",
			iframe:0,
			url:"/devwidgets/pagemanagement/pagemanagement.html",
			name:"pagemanagement",
			id:"pagemanagement",
			personalportal:0,
			siteportal:0
		},
		mypreferences :
		{
			description:"mypreferences",
			iframe:0,
			url:"/devwidgets/mypreferences/mypreferences.html",
			name:"mypreferences",
			id:"mypreferences",
			personalportal:0,
			siteportal:0
		},
		myinbox :
		{
			description:"myinbox",
			iframe:0,
			url:"/devwidgets/myinbox/myinbox.html",
			name:"myinbox",
			id:"myinbox",
			personalportal:0,
			siteportal:0
		},
		sitemembers :
		{
			description:"Shows a list of all of the members of this site",
			iframe:0,
			url:"/devwidgets/sitemembers/sitemembers.html",
			name:"Site Members",
			id:"sitemembers",
			personalportal:0,
			siteportal:1,
			img:"/devwidgets/sitemembers/images/icon.png"
		},
		chat :
		{
			description:"chat",
			iframe:0,
			url:"/devwidgets/chat/chat.html",
			name:"chat",
			id:"chat",
			personalportal:0,
			siteportal:0
		},
		siterecentactivity :
		{
			description:"Site Recent Activity",
			iframe:0,
			url:"/devwidgets/siterecentactivity/siterecentactivity.html",
			name:"Recent Activity",
			id:"siterecentactivity",
			personalportal:0,
			siteportal:0,
			ca:1,
			img:"/devwidgets/siterecentactivity/images/icon.png"
		},
		navigation :
		{
			description:"Navigation Widgets",
			iframe:0,
			url:"/devwidgets/navigation/navigation.html",
			name:"Navigation",
			id:"navigation",
			personalportal:0,
			siteportal:0,
			ca:1,
			img:"/devwidgets/navigation/images/icon.png"
		},
		youtubevideo :
		{
			description:"YouTube Video",
			iframe:0,
			url:"/devwidgets/youtubevideo/youtubevideo.html",
			name:"YouTube Video",
			id:"youtubevideo",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:0,
			showinsakaigoodies:0,
			img:"/devwidgets/youtubevideo/images/icon.png"
		},
		rss :
		{
			description:"RSS Feed",
			iframe:0,
			url:"/devwidgets/rss/rss.html",
			name:"RSS Feed",
			id:"rss",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:0,
			showinsakaigoodies:1,
			img:"/devwidgets/youtubevideo/images/icon.png"
		},
		video :
		{
			description:"Video",
			iframe:0,
			url:"/devwidgets/video/video.html",
			name:"Video",
			id:"video",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:1,
			showinsakaigoodies:0,
			img:"/devwidgets/youtubevideo/images/icon.png"
		},
		comments :
		{
			description:"Comments",
			iframe:0,
			url:"/devwidgets/comments/commentswow.html",
			name:"Comments",
			id:"comments",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:0,
			showinsakaigoodies:1,
			img:"/devwidgets/youtubevideo/images/icon.png"
		},
		remotecontent :
		{
			description:"Remote Content",
			iframe:0,
			url:"/devwidgets/remotecontent/remotecontent.html",
			name:"Remote Content",
			id:"remotecontent",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:0,
			showinsakaigoodies:1,
			img:"/devwidgets/youtubevideo/images/icon.png"
		},
		linktool :
		{
			description:"Link Tool",
			iframe:0,
			url:"/devwidgets/linktool/linktool.html",
			name:"Link Tool",
			id:"linktool",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:0,
			showinsakaigoodies:1,
			img:"/devwidgets/youtubevideo/images/icon.png"
		},
		tangler :
		{
			description:"Tangler Forum",
			iframe:0,
			url:"/devwidgets/tangler/tangler.html",
			name:"Tangler Forum",
			id:"tangler",
			personalportal:0,
			siteportal:0,
			ca:1,
			showinmedia:0,
			showinsakaigoodies:1,
			img:"/devwidgets/tangler/images/tangler.png"
		},
		singlefile :
		{
			description:"Single File Reference",
			iframe:0,
			url:"/devwidgets/singlefile/singlefile.html",
			name:"Single File Reference",
			id:"singlefile",
			personalportal:0,
			siteportal:0,
			ca:0,
			img:"/devwidgets/singlefile/images/singlefile.png"
		},
		Resources :
		{
			description:"Resources tool",
			iframe:"0",
			url:"/devwidgets/Resources/Resources.html",
			name:"Resources",
			id:"resources",
			personalportal:0,
			siteportal:0,
			history : {"init":"Resources.initHistory","nav":"Resources.browser.printResources",tag:"Resources.tagging.showTagViewReal"}
		},
		polltracker :
		{
			description:"Track the results of all of the polls on the sites you are a member of",
			iframe:0,
			url:"/devwidgets/polltracker/polltracker.html",
			name:"Poll Tracker",
			id:"polltracker",
			personalportal:1,
			siteportal:0,
			multipleinstance: true,
			img:"/devwidgets/polltracker/images/poll_icon.gif"
		}
	},
	orders:[
		{
			grouptype:"General",
			widgets: ["mycoursesandprojects","messageoftheday","recentactivity"],
			id:1,
			layout: "twocolumnspecial"
		},
		{
			grouptype:"Administrators",
			widgets: ["mycoursesandprojects","messageoftheday","quickannouncement"],
			id:1,
			layout: "twocolumn"
		},
		{
			grouptype:"Lecturers & Supervisors",
			widgets:["mycoursesandprojects","recentactivity"],
			id:2,
			layout: "twocolumnspecial"
		},
		{
			grouptype:"Researchers",
			widgets:["recentactivity","mycoursesandprojects","messageoftheday"],
			id:3,
			layout: "threecolumn"
		},
		{
			grouptype:"Students",
			widgets:["recentactivity","mycoursesandprojects","quickannouncement","messageoftheday","myrssfeed"],
			id:4,
			layout: "fourcolumn"
		}
	]
};<|endoftext|>