<commit_before>(function(red) {
var cjs = red.cjs, _ = red._;
var event_types = {};
var dom_events = ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mousemove", "mouseout",
					"keydown", "keypress", "keyup", "load", "unload", "abort", "error", "resize",
					"scroll", "select", "change", "submit", "reset", "focus", "blur", "DOMFocusIn",
					"DOMFocusOut", "DOMActivate", "DOMSubtreeModified", "DOMNodeInserted", "DOMNodeRemoved",
					"DOMNodeRemovedFromDocument", "DOMNodeInsertedIntoDocument", "DOMAttrModified",
					"DOMCharacterDataModified", "cut", "copy", "paste", "beforecut", "beforecopy",
					"beforepaste", "afterupdate", "beforeupdate", "cellchange", "dataavailable",
					"datasetchanged", "datasetcomplete", "errorupdate", "rowenter", "rowexit", "rowsdelete",
					"rowinserted", "contextmenu", "drag", "dragstart", "dragenter", "dragover", "dragleave",
					"dragend", "drop", "selectstart", "help", "beforeunload", "stop", "beforeeditfocus",
					"start", "finish", "bounce", "beforeprint", "afterprint", "propertychange",
					"filterchange", "readystatechange", "losecapture", "touchstart", "touchend",
					"touchmove", "touchenter", "touchleave", "touchcancel"];
var esprima = window.esprima;

_.forEach(dom_events, function(dom_event) {
	event_types[dom_event] = function(parent) {
		var context = _.last(arguments);
		if(arguments.length === 1) {
			parent = window; // Ex: mouseup() <-> mouseup(window)
		}

		if(!(context instanceof red.RedContext)) {
			context = red.create("context");
		}

		if(parent) {
			var dom_elem;
			if(_.isElement(parent) || parent === window) {
				dom_elem = parent;
			} else if(parent instanceof red.RedDict) {
				var parent_context = parent.get_default_context();
				var manifestations = parent.get_manifestation_objs(parent_context);
				var dom_attachments;

				if(_.isArray(manifestations)) {
					dom_attachments = [];
					_.each(manifestations, function(manifestation) {
						var manifestation_context = parent_context.push(manifestation);
						var dom_attachment = parent.get_attachment_instance("dom", manifestation_context);
						if(dom_attachment) {
							dom_attachments.push(dom_attachment);
						}
					});
				} else {
					var dom_attachment = parent.get_attachment_instance("dom", context);
					if(dom_attachment) {
						dom_attachments = [dom_attachment];
					}
				}

				dom_elem = _.map(dom_attachments, function(dom_attachment) {
					return dom_attachment.get_dom_obj();
				});
			}

			if(dom_elem) {
				return red.create_event("dom_event", dom_event, dom_elem);
			}
		}
	};
});

event_types["on_transition"] = function(sc_obj, event_spec) {
	if(!_.isArray(sc_obj)) {
		sc_obj = [sc_obj];
	}
	sc_obj = _	.chain(sc_obj)
				.map(function(obj) {
					if(obj instanceof red.RedGroup) {
						return obj.get(obj.get_default_context());
					} else {
						return obj;
					}
				})
				.filter(function(obj) {
					return obj instanceof red.RedStatefulObj;
				})
				.map(function(obj) {
					return obj.get_statecharts(obj.get_default_context());
				})
				.flatten()
				.value();
	return red.create_event("statechart", sc_obj, event_spec);
};

var get_event = function(node, parent, context) {
	if(_.isUndefined(node)) { return undefined; }

	var type = node.type;
	if(type === "ExpressionStatement") {
		return get_event(node.expression, parent, context);
	} else if(type === "CallExpression") {
		var callee = get_event(node.callee, parent, context);
		var args = node.arguments;

		var args_got = _.map(args, function(arg) {
			var arg_val = get_event(arg, parent, context);
			return red.get_contextualizable(arg_val, context);
		});
		args_got.push(context);
		var callee_got = red.get_contextualizable(callee, context);
		return callee_got.apply(this, args_got);
	} else if(type === "Identifier") {
		var name = node.name;

		if(_.has(event_types, name)) {
			return event_types[name];
		} else if(name === "root") {
			return context.first();
		} else if(name === "window") {
			return window;
		} else {
			var curr_context = context;
			if(!context) { return; }
			var context_item = curr_context.last();
			while(!curr_context.is_empty()) {
				if(context_item instanceof red.RedDict) {
					if(context_item._has_direct_prop(name)) {
						return context_item._get_direct_prop(name, curr_context);
					}
				}
				curr_context = curr_context.pop();
				context_item = curr_context.last();
			}
		}
	} else if(type === "MemberExpression") {
		var object = get_event(node.object, parent, context);
		var object_got = cjs.get(object);
		if(object_got instanceof red.RedDict) {
			// More cases here
			variable_context = red.create("context", {stack: [object_got]});
			if(!variable_context) { return undefined; }
			var property = get_event(node.property, parent, variable_context);
			return property;
		} else {
			return(object_got[node.property.name]);
		}
	} else if(type === "ArrayExpression") {
		return _.map(node.elements, function(element) {
			return eval_tree(element, context, ignore_inherited_in_contexts);
		});
	} else if(type === "ThisExpression") {
		return parent;
	} else if(type === "Literal") {
		return node.value;
	} else if(type === "BinaryExpression") {
		var operator = node.operator;
		if(_.indexOf(["==", "===", "<", "<=", ">", ">="], operator) >= 0) {
			var left_identifier = get_event(node.left, parent, context);
			var right_identifier = get_event(node.right, parent, context);

			return red.create_event("constraint_event", operator, left_identifier, right_identifier);
		}
	} else if(type === "XXXXXXX") {
	} else {
		//console.log(type, node, parent);
	}
};

var ParsedEvent = red._create_event_type("parsed");
red.ParsedEvent = ParsedEvent;
var id  = 0;
(function(my) {
	var proto = my.prototype;
	proto.on_create = function(options) {
		this.id = id++;
		this.options = options;
		this._str = cjs.is_constraint(options.str) ? options.str : cjs(options.str);
		if(options.inert_super_event !== true) {
			var SOandC = red.find_stateful_obj_and_context(options.context);
			var context = SOandC.context;
			var parent = SOandC.stateful_obj;

			var self = this;
			this._tree = cjs(function() {
				return esprima.parse(self.get_str());
			});

			this.$child_fired = _.bind(this.child_fired, this);

			this._old_event = null;
			this._live_event_creator = cjs.liven(function() {
				if(this._old_event) {
					this._old_event.off_fire(this.$child_fired);
					this._old_event.destroy();
				}

				var tree = this._tree.get();
				cjs.wait();
				var event = get_event(tree.body[0], parent, context);
				cjs.signal();

				if(event) {
					event.on_fire(this.$child_fired);
					//console.log("re-constituted event", event);
				}

				this._old_event = event;
			}, {
				context: this
			});
		}
	};
	proto.child_fired = function() { this.fire.apply(this, arguments); };
	proto.get_str = function() { return this._str.get(); };
	proto.set_str = function(str) { this._str.set(str); };
	proto.create_shadow = function(parent_statechart, context) {
		return red.create_event("parsed", {str: this._str, context: context});
	};
	proto.destroy = function() {
		if(this._live_event_creator) {
			this._live_event_creator.destroy();
		}
	};
	proto.stringify = function() { return "'" + this.get_str() + "'"; };
	proto.serialize = function() { return { str: this.get_str() }; };
	my.deserialize = function(obj) { return red.create_event("parsed", obj.str); };
}(ParsedEvent));
}(red));
<commit_msg>Working on parsed events<commit_after>(function(red) {
var cjs = red.cjs, _ = red._;
var on_event = function(event_type) {
	var targets;
	if(arguments.length <= 1) { // Ex: mouseup() <-> mouseup(window)
		targets = window;
	} else {
		targets = _.rest(arguments);
	}
	return red.create_event("dom_event", event_type, targets);
};
/*
var event_types = {};
var dom_events = ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mousemove", "mouseout",
					"keydown", "keypress", "keyup", "load", "unload", "abort", "error", "resize",
					"scroll", "select", "change", "submit", "reset", "focus", "blur", "DOMFocusIn",
					"DOMFocusOut", "DOMActivate", "DOMSubtreeModified", "DOMNodeInserted", "DOMNodeRemoved",
					"DOMNodeRemovedFromDocument", "DOMNodeInsertedIntoDocument", "DOMAttrModified",
					"DOMCharacterDataModified", "cut", "copy", "paste", "beforecut", "beforecopy",
					"beforepaste", "afterupdate", "beforeupdate", "cellchange", "dataavailable",
					"datasetchanged", "datasetcomplete", "errorupdate", "rowenter", "rowexit", "rowsdelete",
					"rowinserted", "contextmenu", "drag", "dragstart", "dragenter", "dragover", "dragleave",
					"dragend", "drop", "selectstart", "help", "beforeunload", "stop", "beforeeditfocus",
					"start", "finish", "bounce", "beforeprint", "afterprint", "propertychange",
					"filterchange", "readystatechange", "losecapture", "touchstart", "touchend",
					"touchmove", "touchenter", "touchleave", "touchcancel"];
var esprima = window.esprima;

_.forEach(dom_events, function(dom_event) {
	event_types[dom_event] = function(parent) {
		var context = _.last(arguments);
		if(arguments.length === 1) {
			parent = window; // Ex: mouseup() <-> mouseup(window)
		}

		if(!(context instanceof red.RedContext)) {
			context = red.create("context");
		}

		if(parent) {
			var dom_elem;
			if(_.isElement(parent) || parent === window) {
				dom_elem = parent;
			} else if(parent instanceof red.RedDict) {
				var parent_context = parent.get_default_context();
				var manifestations = parent.get_manifestation_objs(parent_context);
				var dom_attachments;

				if(_.isArray(manifestations)) {
					dom_attachments = [];
					_.each(manifestations, function(manifestation) {
						var manifestation_context = parent_context.push(manifestation);
						var dom_attachment = parent.get_attachment_instance("dom", manifestation_context);
						if(dom_attachment) {
							dom_attachments.push(dom_attachment);
						}
					});
				} else {
					var dom_attachment = parent.get_attachment_instance("dom", context);
					if(dom_attachment) {
						dom_attachments = [dom_attachment];
					}
				}

				dom_elem = _.map(dom_attachments, function(dom_attachment) {
					return dom_attachment.get_dom_obj();
				});
			}

			if(dom_elem) {
				return red.create_event("dom_event", dom_event, dom_elem);
			}
		}
	};
});

event_types["on_transition"] = function(sc_obj, event_spec) {
	if(!_.isArray(sc_obj)) {
		sc_obj = [sc_obj];
	}
	sc_obj = _	.chain(sc_obj)
				.map(function(obj) {
					if(obj instanceof red.RedGroup) {
						return obj.get(obj.get_default_context());
					} else {
						return obj;
					}
				})
				.filter(function(obj) {
					return obj instanceof red.RedStatefulObj;
				})
				.map(function(obj) {
					return obj.get_statecharts(obj.get_default_context());
				})
				.flatten()
				.value();
	return red.create_event("statechart", sc_obj, event_spec);
};

var get_event = function(node, parent, context) {
	if(_.isUndefined(node)) { return undefined; }

	var type = node.type;
	if(type === "ExpressionStatement") {
		return get_event(node.expression, parent, context);
	} else if(type === "CallExpression") {
		var callee = get_event(node.callee, parent, context);
		var args = node.arguments;

		var args_got = _.map(args, function(arg) {
			var arg_val = get_event(arg, parent, context);
			return red.get_contextualizable(arg_val, context);
		});
		args_got.push(context);
		var callee_got = red.get_contextualizable(callee, context);
		return callee_got.apply(this, args_got);
	} else if(type === "Identifier") {
		var name = node.name;

		if(_.has(event_types, name)) {
			return event_types[name];
		} else if(name === "root") {
			return context.first();
		} else if(name === "window") {
			return window;
		} else {
			var curr_context = context;
			if(!context) { return; }
			var context_item = curr_context.last();
			while(!curr_context.is_empty()) {
				if(context_item instanceof red.RedDict) {
					if(context_item._has_direct_prop(name)) {
						return context_item._get_direct_prop(name, curr_context);
					}
				}
				curr_context = curr_context.pop();
				context_item = curr_context.last();
			}
		}
	} else if(type === "MemberExpression") {
		var object = get_event(node.object, parent, context);
		var object_got = cjs.get(object);
		if(object_got instanceof red.RedDict) {
			// More cases here
			variable_context = red.create("context", {stack: [object_got]});
			if(!variable_context) { return undefined; }
			var property = get_event(node.property, parent, variable_context);
			return property;
		} else {
			return(object_got[node.property.name]);
		}
	} else if(type === "ArrayExpression") {
		return _.map(node.elements, function(element) {
			return eval_tree(element, context, ignore_inherited_in_contexts);
		});
	} else if(type === "ThisExpression") {
		return parent;
	} else if(type === "Literal") {
		return node.value;
	} else if(type === "BinaryExpression") {
		var operator = node.operator;
		if(_.indexOf(["==", "===", "<", "<=", ">", ">="], operator) >= 0) {
			var left_identifier = get_event(node.left, parent, context);
			var right_identifier = get_event(node.right, parent, context);

			return red.create_event("constraint_event", operator, left_identifier, right_identifier);
		}
	} else if(type === "XXXXXXX") {
	} else {
		//console.log(type, node, parent);
	}
};
*/

var ParsedEvent = red._create_event_type("parsed");
red.ParsedEvent = ParsedEvent;
var id  = 0;
(function(my) {
	var proto = my.prototype;
	proto.on_create = function(options) {
		this.id = id++;
		this.options = options;
		this._str = cjs.is_constraint(options.str) ? options.str : cjs(options.str);
		if(options.inert_super_event !== true) {
			var SOandC = red.find_stateful_obj_and_context(options.context);
			var context = SOandC.context;
			var parent = SOandC.stateful_obj;

			var self = this;
			this._tree = cjs(function() {
				return esprima.parse(self.get_str());
			});

			this.$child_fired = _.bind(this.child_fired, this);

			this._old_event = null;
			this._live_event_creator = cjs.liven(function() {
				if(this._old_event) {
					this._old_event.off_fire(this.$child_fired);
					this._old_event.destroy();
				}

				var tree = this._tree.get();
				cjs.wait();
				var event = get_event(tree, parent, context);
				cjs.signal();

				if(event) {
					event.on_fire(this.$child_fired);
				}

				this._old_event = event;
			}, {
				context: this
			});
		}
	};
	proto.child_fired = function() { this.fire.apply(this, arguments); };
	proto.get_str = function() { return this._str.get(); };
	proto.set_str = function(str) { this._str.set(str); };
	proto.create_shadow = function(parent_statechart, context) {
		return red.create_event("parsed", {str: this._str, context: context});
	};
	proto.destroy = function() {
		if(this._old_event) {
			this._old_event.off_fire(this.$child_fired);
			this._old_event.destroy();
		}
		if(this._live_event_creator) {
			this._live_event_creator.destroy();
		}
	};
	proto.stringify = function() { return "'" + this.get_str() + "'"; };
	proto.serialize = function() { return { str: this.get_str() }; };
	my.deserialize = function(obj) { return red.create_event("parsed", obj.str); };
}(ParsedEvent));
}(red));
<|endoftext|>


<commit_before>"use strict"

// Dependencies
const EngineTools = require("engine-tools")
    , SameTime = require("same-time")
    , EngineParser = require("engine-parser")
    ;

class EngineParserGen {

    constructor (app) {
        if (typeof app !== "string" || !app) {
            throw new TypeError("The app parameter should be a string.");
        }
        this.app = app;
        this.path = EngineTools.getAppPath(this.app);
    }

    // Read the instances
    parse (cb) {

        // Read the instances
        EngineTools.getComposition(this.app, { iName: true }, (err, data) => {
            if (err) { return cb(err); }

            // Parse the raw json
            EngineParser(data, {}, {}, (err, data) => {
                this.parsed = data.prepare();
                cb(err, data, this.parsed);
            });
        });
    }

    renameInstance (oldName, newName, cb) {
        this.parse((err) => {
            if (err) { return cb(err); }
            debugger
        });
    }
}

module.exports = EngineParserGen;
<commit_msg>JSDoc comments<commit_after>"use strict"

// Dependencies
const EngineTools = require("engine-tools")
    , SameTime = require("same-time")
    , EngineParser = require("engine-parser")
    ;

class EngineParserGen {

    constructor (app) {
        if (typeof app !== "string" || !app) {
            throw new TypeError("The app parameter should be a string.");
        }
        this.app = app;
        this.path = EngineTools.getAppPath(this.app);
    }

    // Read the instances
    parse (cb) {

        // Read the instances
        EngineTools.getComposition(this.app, { iName: true }, (err, data) => {
            if (err) { return cb(err); }

            // Parse the raw json
            EngineParser(data, {}, {}, (err, data) => {
                this.parsed = data.prepare();
                cb(err, data, this.parsed);
            });
        });
    }

    /**
     * renameInstance
     * Renames an instance.
     *
     * @name renameInstance
     * @function
     * @param {String} oldName The old instance name.
     * @param {String} newName The new instance name.
     * @param {Function} cb The callback function.
     * @return {EngineParserGen} The `EngineParserGen` instance.
     */
    renameInstance (oldName, newName, cb) {
        this.parse((err) => {
            if (err) { return cb(err); }
            debugger
        });
        return this;
    }
}

module.exports = EngineParserGen;
<|endoftext|>


<commit_before>app.controller('mapController', function($scope, $stateParams, communityDataService) {
    //Obtain lat and lng for searched city
    var lat = parseFloat($stateParams.lat),
        lng = parseFloat($stateParams.lng);

    //Hard code bound for Chicago
    var NW = {lat: 41.9786, lng: -87.9047},
        SE = {lat: 41.6600, lng: -87.5500};

    var bounds = new google.maps.LatLngBounds(NW, SE);
    var center = bounds.getCenter();

    var map = new google.maps.Map(document.getElementById('map'), {
        disableDefaultUI: true,
        center : {lat: center.lat(), lng: center.lng()},
        zoom: 8,
        scaleControl: false
    });

    map.fitBounds(bounds);

    $scope.preferences = [];
    //Populate map with preferences from database
    communityDataService.preferences()
        .done(function(result){
            for (var i = 0; i < 5; i++){
                $scope.preferences.push(result[i]);
                $scope.preferences[i].isCollapsed = true;
            }
            $scope.$apply();
            mapPreferences();
        })
        .fail(function(){
            console.log("Unable to retrieve preferences");
        });

    var mapPreferences = function(){

        var infoWindow = new google.maps.InfoWindow();

        for (var i = 0; i < $scope.preferences.length; i++) {

            var center = $scope.preferences[i].latLng.split(",");
            center = { lat: parseFloat(center[0]), lng: parseFloat(center[1])};

            var circle = new google.maps.Circle({
                strokeOpacity: 0,
                fillColor: '#428BCA',
                fillOpacity: 0.2 + (0.1 * i),
                map: map,
                center: center,
                radius: $scope.preferences[i].radius,
                name: $scope.preferences[i].name
            });

            google.maps.event.addListener(circle, 'click', function(event) {
                this.setOptions({fillColor: '#00d39e'});
                infoWindow.setContent("" + this.name + "");
                infoWindow.setPosition(this.center);
                infoWindow.open(map);
            });
        }
    };
});<commit_msg>use dark blue and 10 communities, possibly change this later but committing now to have in the repo<commit_after>app.controller('mapController', function($scope, $stateParams, communityDataService) {
    //Obtain lat and lng for searched city
    var lat = parseFloat($stateParams.lat),
        lng = parseFloat($stateParams.lng);

    //Hard code bound for Chicago
    var NW = {lat: 41.9786, lng: -87.9047},
        SE = {lat: 41.6600, lng: -87.5500};

    var bounds = new google.maps.LatLngBounds(NW, SE);
    var center = bounds.getCenter();

    var map = new google.maps.Map(document.getElementById('map'), {
        disableDefaultUI: true,
        center : {lat: center.lat(), lng: center.lng()},
        zoom: 8,
        scaleControl: false
    });

    map.fitBounds(bounds);

    $scope.preferences = [];
    //Populate map with preferences from database
    communityDataService.preferences()
        .done(function(result){
            for (var i = 0; i < 10; i++){
                $scope.preferences.push(result[i]);
                $scope.preferences[i].isCollapsed = true;
            }
            $scope.$apply();
            mapPreferences();
        })
        .fail(function(){
            console.log("Unable to retrieve preferences");
        });

    var mapPreferences = function(){

        var infoWindow = new google.maps.InfoWindow();

        for (var i = 0; i < $scope.preferences.length; i++) {

            var center = $scope.preferences[i].latLng.split(",");
            center = { lat: parseFloat(center[0]), lng: parseFloat(center[1])};

            // border color for when user hovers over sidebar community
            var strokeColor = '#D50000';

            var circle = new google.maps.Circle({
                strokeOpacity: 0,
                fillColor: '#0D47A1',
                fillOpacity: 0.7 - (0.05 * i),
                map: map,
                center: center,
                radius: $scope.preferences[i].radius,
                name: $scope.preferences[i].name
            });

            google.maps.event.addListener(circle, 'click', function(event) {
                this.setOptions({fillColor: '#00d39e'});
                infoWindow.setContent("" + this.name + "");
                infoWindow.setPosition(this.center);
                infoWindow.open(map);
            });
        }
    };
});<|endoftext|>


<commit_before>/*
*     (C) Copyright 2008 Telefonica Investigacion y Desarrollo
*     S.A.Unipersonal (Telefonica I+D)
*
*     This file is part of Morfeo EzWeb Platform.
*
*     Morfeo EzWeb Platform is free software: you can redistribute it and/or modify
*     it under the terms of the GNU Affero General Public License as published by
*     the Free Software Foundation, either version 3 of the License, or
*     (at your option) any later version.
*
*     Morfeo EzWeb Platform is distributed in the hope that it will be useful,
*     but WITHOUT ANY WARRANTY; without even the implied warranty of
*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*     GNU Affero General Public License for more details.
*
*     You should have received a copy of the GNU Affero General Public License
*     along with Morfeo EzWeb Platform.  If not, see <http://www.gnu.org/licenses/>.
*
*     Info about members and contributors of the MORFEO project
*     is available at
*
*     http://morfeo-project.org
 */

/**
 * abstract
 * @author aarranz
 */
function UserPref(varName_, label_, desc_, defaultValue_) {
	this.varName = null;
	this.label = null;
	this.desc = null;
	this.defaultValue = null;
}

UserPref.prototype.UserPref = function (varName_, label_, desc_, defaultValue_) {
	this.varName = varName_;
	this.label = label_;
	this.desc = desc_;

	if ((defaultValue_ == null) || (defaultValue_ == undefined))
		this.defaultValue = "";
	else
		this.defaultValue = defaultValue_;
}

UserPref.prototype.getVarName = function () {
	return this.varName;
}

UserPref.prototype.validate = function (newValue) {
	return true;
}

UserPref.prototype.getCurrentValue = function (varManager, iGadgetId) {
	var variable = varManager.getVariableByName(iGadgetId, this.varName);
	return variable.get();
}

//Set value and invoke callback function
UserPref.prototype.setValue = function (varManager, iGadgetId, newValue) {
	if (this.validate(newValue)) {
		var variable = varManager.getVariableByName(iGadgetId, this.varName);
		variable.set(newValue);
	}
}

//Set new variable but it doesn't invoke callback function
UserPref.prototype.annotate = function (varManager, iGadgetId, newValue) {
	if (this.validate(newValue)) {
		var variable = varManager.getVariableByName(iGadgetId, this.varName);
		variable.annotate(newValue);
	}
}

UserPref.prototype.setToDefault = function (varManager, iGadgetId) {
	this.setValue(varManager, this.defaultValue);
}

UserPref.prototype.getValueFromInterface = function (element) {
	return element.value;
}

UserPref.prototype.setDefaultValueInInterface = function (element) {
	element.value = this.defaultValue;
}

UserPref.prototype.getLabel = function () {
	var label = document.createElement("label");
	label.appendChild(document.createTextNode(this.label));
	label.setAttribute("title", this.desc);
	label.setAttribute("for", this.varName);

	return label;
}

//////////////////////////////////////////////
// PUBLIC CONSTANTS
//////////////////////////////////////////////
UserPref.prototype.TEXT    = "S"; // "S"tring
UserPref.prototype.INTEGER = "N"; // "N"umber
UserPref.prototype.DATE    = "D"; // "D"ate
UserPref.prototype.LIST    = "L"; // "L"ist
UserPref.prototype.BOOLEAN = "B"; // "B"oolean
UserPref.prototype.PASSWORD = "P"; // "P"assword

/**
 * extends UserPref
 * @author aarranz
 */
function ListUserPref(name_, label_, desc_, defaultValue_, ValueOptions_) {
	UserPref.prototype.UserPref.call(this, name_, label_, desc_, defaultValue_);
	this.options = ValueOptions_;
	this.optionHash = null;
}

ListUserPref.prototype = new UserPref();

ListUserPref.prototype.makeInterface = function (varManager, iGadgetId) {
	var select;

	select = document.createElement("select");
	select.setAttribute("name", this.varName);

	var currentValue = this.getCurrentValue(varManager, iGadgetId);
	var output = "";
	for (var i = 0; i < this.options.length; i++) {
		output += "<option value=\"" + this.options[i][0] + "\"";

		if (currentValue == this.options[i][0]) output += " selected=\"selected\"";

		output += ">" + this.options[i][1] + "</option>";
	}

	select.innerHTML = output;

	return select;
}

ListUserPref.prototype.validate = function (newValue) {
	if (this.optionHash == null) {
		this.optionHash = new Hash();
		for (var i = 0; i < this.options.length; i++)
			this.optionHash[this.options[i][0]] = true;
	}

	return this.optionHash[newValue] != undefined;
}

/**
 * extends UserPref
 * @autor aarranz
 */
function IntUserPref(name_, label_, desc_, defaultValue_) {
	UserPref.prototype.UserPref.call(this, name_, label_, desc_, defaultValue_);
}

IntUserPref.prototype = new UserPref();

IntUserPref.prototype.makeInterface = function (varManager, IGadgetId) {
	var element;

	element = document.createElement("input");
	element.setAttribute("name", this.varName);
	element.setAttribute("type", "text");

	var currentValue = this.getCurrentValue(varManager, IGadgetId);
	if (currentValue != null)
		element.setAttribute("value", currentValue);

	return element;
}

IntUserPref.prototype.validate = function (newValue) {
	return !isNaN(Number(newValue));
}

/**
 * extends UserPref
 * @author aarranz
 */
function TextUserPref(name_, label_, desc_, defaultValue_) {
	UserPref.prototype.UserPref.call(this, name_, label_, desc_, defaultValue_);
}

TextUserPref.prototype = new UserPref();

TextUserPref.prototype.makeInterface = function (varManager, IGadgetId) {
	var element;

	element = document.createElement("input");
	element.setAttribute("name", this.varName);
	element.setAttribute("type", "text");

	var currentValue = this.getCurrentValue(varManager, IGadgetId);
	if (currentValue != null)
		element.setAttribute("value", currentValue);

	return element;
}

/**
 * extends UserPref
 * @author aarranz
 */
function DateUserPref(name_, label_, desc_, defaultValue_) {
	UserPref.prototype.UserPref.call(this, name_, label_, desc_, defaultValue_);
}

DateUserPref.prototype = new UserPref();

DateUserPref.prototype.makeInterface = function (varManager, IGadgetId) {
	var element;

	element = document.createElement("input");
	element.setAttribute("name", this.varName);
	element.setAttribute("type", "text");

	var currentValue = this.getCurrentValue(IGadgetId);
	if (currentValue != null)
		element.setAttribute("value", currentValue);

	return element;
}

/**
 * extends UserPref
 * @author aarranz
 */
function BoolUserPref(name_, label_, desc_, defaultValue_) {
	UserPref.prototype.UserPref.call(this, name_, label_, desc_, defaultValue_);
}

BoolUserPref.prototype = new UserPref();

BoolUserPref.prototype.makeInterface = function (varManager, IGadgetId) {
	var element;

	element = document.createElement("input");
	element.setAttribute("name", this.varName);
	element.setAttribute("type", "checkbox");

	var currentValue = this.getCurrentValue(varManager, IGadgetId);
	if (currentValue.strip().toLowerCase() == "true")
		element.setAttribute("checked", "true");

	return element;
}

BoolUserPref.prototype.getValueFromInterface = function(element) {
	return element.checked ? "true" : "false";
}

/**
 * extends UserPref
 * @author fabio
 */
function PasswordUserPref(name_, label_, desc_, defaultValue_) {
	UserPref.prototype.UserPref.call(this, name_, label_, desc_, defaultValue_);
}

PasswordUserPref.prototype = new UserPref();

PasswordUserPref.prototype.makeInterface = function (varManager, IGadgetId) {
	var element;

	element = document.createElement("input");
	element.setAttribute("name", this.varName);
	element.setAttribute("type", "password");

	var currentValue = this.getCurrentValue(varManager, IGadgetId);
	if (currentValue != null)
		element.setAttribute("value", currentValue);

	return element;
}

<commit_msg>refs #286. error solved with the list preferences.<commit_after>/*
*     (C) Copyright 2008 Telefonica Investigacion y Desarrollo
*     S.A.Unipersonal (Telefonica I+D)
*
*     This file is part of Morfeo EzWeb Platform.
*
*     Morfeo EzWeb Platform is free software: you can redistribute it and/or modify
*     it under the terms of the GNU Affero General Public License as published by
*     the Free Software Foundation, either version 3 of the License, or
*     (at your option) any later version.
*
*     Morfeo EzWeb Platform is distributed in the hope that it will be useful,
*     but WITHOUT ANY WARRANTY; without even the implied warranty of
*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*     GNU Affero General Public License for more details.
*
*     You should have received a copy of the GNU Affero General Public License
*     along with Morfeo EzWeb Platform.  If not, see <http://www.gnu.org/licenses/>.
*
*     Info about members and contributors of the MORFEO project
*     is available at
*
*     http://morfeo-project.org
 */

/**
 * abstract
 * @author aarranz
 */
function UserPref(varName_, label_, desc_, defaultValue_) {
	this.varName = null;
	this.label = null;
	this.desc = null;
	this.defaultValue = null;
}

UserPref.prototype.UserPref = function (varName_, label_, desc_, defaultValue_) {
	this.varName = varName_;
	this.label = label_;
	this.desc = desc_;

	if ((defaultValue_ == null) || (defaultValue_ == undefined))
		this.defaultValue = "";
	else
		this.defaultValue = defaultValue_;
}

UserPref.prototype.getVarName = function () {
	return this.varName;
}

UserPref.prototype.validate = function (newValue) {
	return true;
}

UserPref.prototype.getCurrentValue = function (varManager, iGadgetId) {
	var variable = varManager.getVariableByName(iGadgetId, this.varName);
	return variable.get();
}

//Set value and invoke callback function
UserPref.prototype.setValue = function (varManager, iGadgetId, newValue) {
	if (this.validate(newValue)) {
		var variable = varManager.getVariableByName(iGadgetId, this.varName);
		variable.set(newValue);
	}
}

//Set new variable but it doesn't invoke callback function
UserPref.prototype.annotate = function (varManager, iGadgetId, newValue) {
	if (this.validate(newValue)) {
		var variable = varManager.getVariableByName(iGadgetId, this.varName);
		variable.annotate(newValue);
	}
}

UserPref.prototype.setToDefault = function (varManager, iGadgetId) {
	this.setValue(varManager, this.defaultValue);
}

UserPref.prototype.getValueFromInterface = function (element) {
	return element.value;
}

UserPref.prototype.setDefaultValueInInterface = function (element) {
	element.value = this.defaultValue;
}

UserPref.prototype.getLabel = function () {
	var label = document.createElement("label");
	label.appendChild(document.createTextNode(this.label));
	label.setAttribute("title", this.desc);
	label.setAttribute("for", this.varName);

	return label;
}

//////////////////////////////////////////////
// PUBLIC CONSTANTS
//////////////////////////////////////////////
UserPref.prototype.TEXT    = "S"; // "S"tring
UserPref.prototype.INTEGER = "N"; // "N"umber
UserPref.prototype.DATE    = "D"; // "D"ate
UserPref.prototype.LIST    = "L"; // "L"ist
UserPref.prototype.BOOLEAN = "B"; // "B"oolean
UserPref.prototype.PASSWORD = "P"; // "P"assword

/**
 * extends UserPref
 * @author aarranz
 */
function ListUserPref(name_, label_, desc_, defaultValue_, ValueOptions_) {
	UserPref.prototype.UserPref.call(this, name_, label_, desc_, defaultValue_);
	this.options = ValueOptions_;
	this.optionHash = null;
}

ListUserPref.prototype = new UserPref();

ListUserPref.prototype.makeInterface = function (varManager, iGadgetId) {
	var select;

	select = document.createElement("select");
	Element.extend(select);
	select.setAttribute("name", this.varName);

	var currentValue = this.getCurrentValue(varManager, iGadgetId);

	for (var i = 0; i < this.options.length; i++) {
		var option = document.createElement("option");
		option.setAttribute("value", this.options[i][0])

		if (currentValue == this.options[i][0])
			option.selected = "selected";

		option.innerHTML = this.options[i][1];
		select.appendChild(option);
	}

	return select;
}

ListUserPref.prototype.validate = function (newValue) {
	if (this.optionHash == null) {
		this.optionHash = new Hash();
		for (var i = 0; i < this.options.length; i++)
			this.optionHash[this.options[i][0]] = true;
	}

	return this.optionHash[newValue] != undefined;
}

/**
 * extends UserPref
 * @autor aarranz
 */
function IntUserPref(name_, label_, desc_, defaultValue_) {
	UserPref.prototype.UserPref.call(this, name_, label_, desc_, defaultValue_);
}

IntUserPref.prototype = new UserPref();

IntUserPref.prototype.makeInterface = function (varManager, IGadgetId) {
	var element;

	element = document.createElement("input");
	element.setAttribute("name", this.varName);
	element.setAttribute("type", "text");

	var currentValue = this.getCurrentValue(varManager, IGadgetId);
	if (currentValue != null)
		element.setAttribute("value", currentValue);

	return element;
}

IntUserPref.prototype.validate = function (newValue) {
	return !isNaN(Number(newValue));
}

/**
 * extends UserPref
 * @author aarranz
 */
function TextUserPref(name_, label_, desc_, defaultValue_) {
	UserPref.prototype.UserPref.call(this, name_, label_, desc_, defaultValue_);
}

TextUserPref.prototype = new UserPref();

TextUserPref.prototype.makeInterface = function (varManager, IGadgetId) {
	var element;

	element = document.createElement("input");
	element.setAttribute("name", this.varName);
	element.setAttribute("type", "text");

	var currentValue = this.getCurrentValue(varManager, IGadgetId);
	if (currentValue != null)
		element.setAttribute("value", currentValue);

	return element;
}

/**
 * extends UserPref
 * @author aarranz
 */
function DateUserPref(name_, label_, desc_, defaultValue_) {
	UserPref.prototype.UserPref.call(this, name_, label_, desc_, defaultValue_);
}

DateUserPref.prototype = new UserPref();

DateUserPref.prototype.makeInterface = function (varManager, IGadgetId) {
	var element;

	element = document.createElement("input");
	element.setAttribute("name", this.varName);
	element.setAttribute("type", "text");

	var currentValue = this.getCurrentValue(IGadgetId);
	if (currentValue != null)
		element.setAttribute("value", currentValue);

	return element;
}

/**
 * extends UserPref
 * @author aarranz
 */
function BoolUserPref(name_, label_, desc_, defaultValue_) {
	UserPref.prototype.UserPref.call(this, name_, label_, desc_, defaultValue_);
}

BoolUserPref.prototype = new UserPref();

BoolUserPref.prototype.makeInterface = function (varManager, IGadgetId) {
	var element;

	element = document.createElement("input");
	element.setAttribute("name", this.varName);
	element.setAttribute("type", "checkbox");

	var currentValue = this.getCurrentValue(varManager, IGadgetId);
	if (currentValue.strip().toLowerCase() == "true")
		element.setAttribute("checked", "true");

	return element;
}

BoolUserPref.prototype.getValueFromInterface = function(element) {
	return element.checked ? "true" : "false";
}

/**
 * extends UserPref
 * @author fabio
 */
function PasswordUserPref(name_, label_, desc_, defaultValue_) {
	UserPref.prototype.UserPref.call(this, name_, label_, desc_, defaultValue_);
}

PasswordUserPref.prototype = new UserPref();

PasswordUserPref.prototype.makeInterface = function (varManager, IGadgetId) {
	var element;

	element = document.createElement("input");
	element.setAttribute("name", this.varName);
	element.setAttribute("type", "password");

	var currentValue = this.getCurrentValue(varManager, IGadgetId);
	if (currentValue != null)
		element.setAttribute("value", currentValue);

	return element;
}

<|endoftext|>


<commit_before>//Imports
import React from "react";
import { Container, Row, Col } from "reactstrap";
import i18n from "/imports/both/i18n/en/";
import DCSBalloon from '/imports/client/ui/components/DCSBalloon/index.js'

const Content = (props) => {
  return (
    <React.Fragment>

      <Container className="mt-5">

The World Needs a Public Happiness Economy Because:

Short

      </Container>
      {i18n.Whitepaper.Why.faq.map((item, index) => {
        return (
          <Col key={index} className="ml-5 pl-5 mt-5" xs={11}>

{item.heading}

{item.text}

            <DCSBalloon title=" " subtitle="discuss" balloonId="bal1" display="inline" dcsTags={props.dcsTags} />
          </Col>
        );
      })}
      {i18n.Whitepaper.Why.faq.map((item, index) => {
        return (

Longer

          <Col key={index} className="ml-5 pl-5 mt-5" xs={11}>

{item.heading2}

{item.text2}

            <DCSBalloon title=" " subtitle="discuss" balloonId="bal2" display="inline" dcsTags={props.dcsTags} />
          </Col>
        );
      })}

    </React.Fragment>
  );
};

export default Content;
<commit_msg>trying to fix error again<commit_after>//Imports
import React from "react";
import { Container, Row, Col } from "reactstrap";
import i18n from "/imports/both/i18n/en/";
import DCSBalloon from '/imports/client/ui/components/DCSBalloon/index.js'

const Content = (props) => {
  return (
    <React.Fragment>
      <Container className="mt-5">

The World Needs a Public Happiness Economy Because:

Short

      </Container>
      {i18n.Whitepaper.Why.faq.map((item, index) => {
        return (

          <Col key={index} className="ml-5 pl-5 mt-5" xs={11}>

{item.heading}

{item.text}

            <DCSBalloon title=" " subtitle="discuss" balloonId="bal1" display="inline" dcsTags={props.dcsTags} />
          </Col>

        );
      })}

      {i18n.Whitepaper.Why.faq.map((item, index) => {
        return (

Longer

          <Col key={index} className="ml-5 pl-5 mt-5" xs={11}>

{item.heading2}

{item.text2}

            <DCSBalloon title=" " subtitle="discuss" balloonId="bal2" display="inline" dcsTags={props.dcsTags} />
          </Col>
        );
      })}

    </React.Fragment>
  );
};

export default Content;
<|endoftext|>


<commit_before>(function () {
    const THEN_SCRIPT_KEY = 'thenScript',
        EXPECTED_FORM = {
            path: 'add/stub/test/path',
            description: 'casper test for adding stub',
            method: 'GET',
            query: 'query',
            remoteAddress: '127.0.0.1',
            requestContentType: 'application/xml',
            statusCode: '200',
            reason: 'OK',
            responseContentType: 'text/xml'
        },
        EXPECTED_EDITORS = {
            content: '<node></node>',
            whenScript: '(function(){return true;})();',
            content2: 'response'
        };

    var swivelUtils = require('../lib/swivelUtils');
    casper.test.begin('Add Stub', function (test) {
        casper.start(swivelUtils.HOME_URL, function () {
            swivelUtils.reset();
        });

        casper.then(function () {
            casper.open(swivelUtils.EDIT_STUB_URL);
            casper.waitUntilVisible('.content');
        });

        casper.then(function () {
            var key;

            casper.click('#staticThen');
            casper.fill('form', EXPECTED_FORM);

            for (key in EXPECTED_EDITORS) {
                if (key !== THEN_SCRIPT_KEY && EXPECTED_EDITORS.hasOwnProperty(key)) {
                    swivelUtils.setEditorText(['#', key].join(''), EXPECTED_EDITORS[key]);
                }
            }

            casper.click('#submit');
        });

        casper.then(function () {
            casper.waitForUrl(swivelUtils.HOME_URL, function () {
                swivelUtils.whenConfigLoaded(function () {
                    test.assertSelectorHasText('.path', EXPECTED_FORM.path, 'stub path listed');
                    test.assertSelectorHasText('.stub', EXPECTED_FORM.description, 'stub description listed');
                });
            });
        });

        casper.then(function () {
            casper.click('.stub button.edit');
        });

        casper.then(function () {
            casper.waitUntilVisible('.content', function () {
                var form = casper.getFormValues('form'), key;

                test.assertExists('#path.ui-state-disabled', 'Path has ui-state-disabled class');
                test.assertExists('#path[readonly]', 'path is read only');

                for (key in EXPECTED_FORM) {
                    if (EXPECTED_FORM.hasOwnProperty(key)) {
                        test.assertEquals(form[key], EXPECTED_FORM[key], [key, 'is populated as expected'].join(' '));
                    }
                }

                for (key in EXPECTED_EDITORS) {
                    if (key !== THEN_SCRIPT_KEY && EXPECTED_EDITORS.hasOwnProperty(key)) {
                        test.assertEquals(swivelUtils.getEditorText(['#', key].join('')),
                            EXPECTED_EDITORS[key],
                            [key, 'editor is populated as expected'].join(' '));
                    }
                }
            });
        });

        casper.run(function () {
            test.done();
        });
    });
})();<commit_msg>Cleaned up test - can test forms if I include the radio button status<commit_after>(function () {
    const THEN_SCRIPT_KEY = 'thenScript',
        EXPECTED_FORM = {
            path: 'add/stub/test/path',
            description: 'casper test for adding stub',
            method: 'GET',
            query: 'query',
            remoteAddress: '127.0.0.1',
            requestContentType: 'application/xml',
            thenType: 'static',
            statusCode: '200',
            reason: 'OK',
            responseContentType: 'text/xml'
        },
        EXPECTED_EDITORS = {
            content: '<node></node>',
            whenScript: '(function(){return true;})();',
            content2: 'response'
        };

    var swivelUtils = require('../lib/swivelUtils');
    casper.test.begin('Add Stub', function (test) {
        casper.start(swivelUtils.HOME_URL, function () {
            swivelUtils.reset();
        });

        casper.then(function () {
            casper.open(swivelUtils.EDIT_STUB_URL);
            casper.waitUntilVisible('.content');
        });

        casper.then(function () {
            var key;

            casper.fill('form', EXPECTED_FORM);

            for (key in EXPECTED_EDITORS) {
                if (key !== THEN_SCRIPT_KEY && EXPECTED_EDITORS.hasOwnProperty(key)) {
                    swivelUtils.setEditorText(['#', key].join(''), EXPECTED_EDITORS[key]);
                }
            }

            casper.click('#submit');
        });

        casper.then(function () {
            casper.waitForUrl(swivelUtils.HOME_URL, function () {
                swivelUtils.whenConfigLoaded(function () {
                    test.assertSelectorHasText('.path', EXPECTED_FORM.path, 'stub path listed');
                    test.assertSelectorHasText('.stub', EXPECTED_FORM.description, 'stub description listed');
                });
            });
        });

        casper.then(function () {
            casper.click('.stub button.edit');
        });

        casper.then(function () {
            casper.waitUntilVisible('.content', function () {
                var form = casper.getFormValues('form'), key;

                test.assertExists('#path.ui-state-disabled', 'Path has ui-state-disabled class');
                test.assertExists('#path[readonly]', 'path is read only');
                test.assertEquals(form, EXPECTED_FORM, 'form is populated as expected');

                for (key in EXPECTED_EDITORS) {
                    if (key !== THEN_SCRIPT_KEY && EXPECTED_EDITORS.hasOwnProperty(key)) {
                        test.assertEquals(swivelUtils.getEditorText(['#', key].join('')),
                            EXPECTED_EDITORS[key],
                            [key, 'editor is populated as expected'].join(' '));
                    }
                }
            });
        });

        casper.run(function () {
            test.done();
        });
    });
})();<|endoftext|>


<commit_before>//'use strict';

'use strict';

angular.module('demoApp')
    .controller('demoRenderCtrl', function($scope,$mdDialog,User){

        // ----------------------------------------------------------------------------------------------------
        // ---- PARAMS CATALOGUE
        // ----------------------------------------------------------------------------------------------------

        $scope.params = [{
            /**
             * Default
             */
            case        : 'Default Case',
            user        : undefined,
            callback    : undefined
        },{
            /**
             * Case user
             */
            case       : 'Case user',
            user    : {
                name : 'toto',
                photo : 'http://127.0.0.1:9100/images/photos/F60.png',
                birthDate : "2000-01-01"
            },
            callback : {
                valid : function(user){
                    displayCode('onValid', user)
                }
            }
        }];

        $scope.chooseParams = function(index){
            // --- Define current status
            $scope.myUser    = $scope.params[index].user;
            $scope.myCallback = $scope.params[index].callback;

            $scope.index          = index;
            $scope.refresh        = moment().valueOf();
            $scope.haveResult     = false;
        };

        // --- Init
        $scope.chooseParams(1);

        // --- Update result viewer
        var displayCode = function(from,code,isError){

            $scope.haveResult   = true;

            $scope.result       = {
                code : code,
                isError : isError,
                title : from
            };
        };
        // ----------------------------------------------------------------------------------------------------
        // ---- DISPLAY CODE MODE
        // ----------------------------------------------------------------------------------------------------
        $scope.displayCode  = false;
        $scope.maxHeight    = $(window).height() - 250;

        $scope.showCode = function(){
            $scope.displayCode = !$scope.displayCode;
        };

        /**
         * Page description
         * @type {{title: string, icon: string, haveCodeSource: boolean}}
         */
        $scope.page         = {
            title : 'directive render',
            haveCodeSource : true,
            code : [{
                link : 'pages/demoRender/code/directive.html',
                language : 'html',
                title : 'Code HTML de la directive demo-user'
            },{
                link : 'pages/demoRender/code/contract.json',
                language : 'json',
                title : 'Params available for the directive demo-user'
            }]
        };

        /**
         * MODE Fullscreen
         */
        $scope.fullScreenMode = true;
        $scope.hideParams     = false;
        $scope.fullScreen = function(){
            $scope.hideParams = !$scope.hideParams;
        };

    });<commit_msg>ajout renderCtrl<commit_after>//'use strict';

'use strict';

angular.module('demoApp')
    .controller('demoRenderCtrl', function($scope, User){

        // ----------------------------------------------------------------------------------------------------
        // ---- PARAMS CATALOGUE
        // ----------------------------------------------------------------------------------------------------

/**     +
-         * Here test use case
-         *
-         * Needed use case to valid the project :
-         *      - Default
-         *      - Inject an user
-         *      - Inject an userId
-         *      - Inject responsive design
-         * @type {*[]}
-         */
        $scope.params = [{
            /**
             * Default
             */
            case        : 'Default Case',
            user        : undefined,
            callback    : undefined
        },{
            /**
             * Case user
             */
            case       : 'Case user',
            user    : {
                name : 'toto',
                photo : 'http://127.0.0.1:9100/images/photos/F60.png',
                birthDate : "2000-01-01"
            },
            callback : {
                valid : function(user){
                    displayCode('onValid', user)
                }
            }
        }];

        $scope.chooseParams = function(index){
            // --- Define current status

            // $scope.myOptions    = $scope.params[index].options;
           // $scope.myJson       = $scope.params[index].json;
           // $scope.myCallback   = $scope.params[index].callback;
           // $scope.myListener   = $scope.params[index].listeners;
            $scope.myUser    = $scope.params[index].user;
            $scope.myCallback = $scope.params[index].callback;

            $scope.index          = index;
            $scope.refresh        = moment().valueOf();
            $scope.haveResult     = false;
        };

        // --- Init
        $scope.chooseParams(1);

        // --- Update result viewer
        var displayCode = function(from,code,isError){

            $scope.haveResult   = true;

            $scope.result       = {
                code : code,
                isError : isError,
                title : from
            };
        };
        // ----------------------------------------------------------------------------------------------------
        // ---- DISPLAY CODE MODE
        // ----------------------------------------------------------------------------------------------------
        $scope.displayCode  = false;
        $scope.maxHeight    = $(window).height() - 250;

        $scope.showCode = function(){
            $scope.displayCode = !$scope.displayCode;
        };

        /**
         * Page description
         * @type {{title: string, icon: string, haveCodeSource: boolean}}
         */
        $scope.page         = {
            title : 'directive paris1-user-render',
            haveCodeSource : true,
            code : [{
                link : 'pages/demoRender/code/directive.html',
                language : 'html',
                title : 'Code HTML de la directive paris1-user-render'
            },{
                link : 'pages/demoRender/code/contract.json',
                language : 'json',
                title : 'Params available for the directive paris1-user-render'
            }]
        };

        /**
         * MODE Fullscreen
         */
        $scope.fullScreenMode = true;
        $scope.hideParams     = false;
        $scope.fullScreen = function(){
            $scope.hideParams = !$scope.hideParams;
        };

 /**
-         * Update result viewer
-         * @param from
-         * @param code
-         * @param isError
-         */
       var displayCode = function(from,code,isError){

            $scope.haveResult   = true;

            $scope.result       = {
                code : code,
                isError : isError,
                title : from
            };
        };
    });<|endoftext|>


<commit_before>/*
 * Copyright (C) 2015 SUSE Linux
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE.txt file for details.
 */

(function () {
  'use strict';

  angular.module('janusHangouts')
    .factory('ConnectionConfig', connectionConfigFactory);

  connectionConfigFactory.$inject = ['$timeout'];

  /**
   * Handles the status of the configuration flags (audio and video) of the
   * connection to Janus keeping them synced client and server side.
   *
   * It handles correctly several consequent changes of the flag values
   * keeping the number of requests to a minimum.
   */
  function connectionConfigFactory($timeout) {
    return function(pluginHandle, wantedInit, jsep, ok) {
      var current = {};
      var requested = null;
      var wanted = {audio: false, video: true};
      var okCallback = null;
      _.assign(wanted, wantedInit);
      // Initial configure
      configure({jsep: jsep, ok: ok});

      /**
       * Gets the current value of the configuration flags
       *
       * @returns {object} values of the audio and video flags
       */
      this.get = function() {
        return current;
      };

      /**
       * Sets the desired value of the configuration flags.
       *
       * It sends a configure request to the Janus server to sync the values
       * if needed (and updates the local representation according).
       *
       * @param {object} options - object containing
       *        * values: object with the wanted values for the flags
       *        * ok: callback to execute on confirmation from Janus
       */
      this.set = function(options) {
        options = options || {};
        options.values = options.values || {};
        var oldWanted = {};
        _.assign(oldWanted, current, wanted);
        _.assign(wanted, current, options.values);

        if (requested === null && differsFromWanted(oldWanted)) {
          configure({ok: options.ok});
        }
      };

      /**
       * Processes the confirmation (received from Janus) of the ongoing
       * config request
       */
      this.confirm = function() {
        $timeout(function() {
          if (requested === null) {
            console.error("I haven't sent a config. Where does this confirmation come from?");
          } else {
            current = requested;
            requested = null;
            console.log("Connection configured", current);
            if (okCallback) { okCallback(); }
            if (differsFromWanted(current)) {
              configure();
            }
          }
        });
      };

      function differsFromWanted(obj) {
        return (obj.video !== wanted.video || obj.audio !== wanted.audio);
      }

      function configure(options) {
        options = options || {};
        var config = {request: "configure"};
        requested = {};

        _.assign(requested, current, wanted);
        _.assign(config, requested);

        pluginHandle.send({
          "message": config,
          jsep: options.jsep,
          success: function() {
            okCallback = options.ok;
          },
          error: function() {
            requested = null;
            console.error("Config request not sent");
          }
        });
      }
    };
  }
})();
<commit_msg>revert change from previous commit<commit_after>/*
 * Copyright (C) 2015 SUSE Linux
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE.txt file for details.
 */

(function () {
  'use strict';

  angular.module('janusHangouts')
    .factory('ConnectionConfig', connectionConfigFactory);

  connectionConfigFactory.$inject = ['$timeout'];

  /**
   * Handles the status of the configuration flags (audio and video) of the
   * connection to Janus keeping them synced client and server side.
   *
   * It handles correctly several consequent changes of the flag values
   * keeping the number of requests to a minimum.
   */
  function connectionConfigFactory($timeout) {
    return function(pluginHandle, wantedInit, jsep, ok) {
      var current = {};
      var requested = null;
      var wanted = {audio: true, video: true};
      var okCallback = null;
      _.assign(wanted, wantedInit);
      // Initial configure
      configure({jsep: jsep, ok: ok});

      /**
       * Gets the current value of the configuration flags
       *
       * @returns {object} values of the audio and video flags
       */
      this.get = function() {
        return current;
      };

      /**
       * Sets the desired value of the configuration flags.
       *
       * It sends a configure request to the Janus server to sync the values
       * if needed (and updates the local representation according).
       *
       * @param {object} options - object containing
       *        * values: object with the wanted values for the flags
       *        * ok: callback to execute on confirmation from Janus
       */
      this.set = function(options) {
        options = options || {};
        options.values = options.values || {};
        var oldWanted = {};
        _.assign(oldWanted, current, wanted);
        _.assign(wanted, current, options.values);

        if (requested === null && differsFromWanted(oldWanted)) {
          configure({ok: options.ok});
        }
      };

      /**
       * Processes the confirmation (received from Janus) of the ongoing
       * config request
       */
      this.confirm = function() {
        $timeout(function() {
          if (requested === null) {
            console.error("I haven't sent a config. Where does this confirmation come from?");
          } else {
            current = requested;
            requested = null;
            console.log("Connection configured", current);
            if (okCallback) { okCallback(); }
            if (differsFromWanted(current)) {
              configure();
            }
          }
        });
      };

      function differsFromWanted(obj) {
        return (obj.video !== wanted.video || obj.audio !== wanted.audio);
      }

      function configure(options) {
        options = options || {};
        var config = {request: "configure"};
        requested = {};

        _.assign(requested, current, wanted);
        _.assign(config, requested);

        pluginHandle.send({
          "message": config,
          jsep: options.jsep,
          success: function() {
            okCallback = options.ok;
          },
          error: function() {
            requested = null;
            console.error("Config request not sent");
          }
        });
      }
    };
  }
})();
<|endoftext|>


<commit_before>'use strict';

// Service for the spec config.
// We keep this separate so that changes are kept even if the spec changes.
angular.module('vleApp')
  .factory('Config', function(vl) {
    var Config = {};

    Config.schema = vl.schema.schema.properties.cfg;
    Config.config = vl.schema.util.instantiate(Config.schema);

    Config.large = function() {
      return vl.merge({}, Config.config, {
        singleWidth: 500,
        singleHeight: 500,
        largeBandMaxCardinality: 20
      });
    };

    Config.small = function() {
      return vl.merge({}, Config.config);
    };

    Config.updateDataset = function(dataset) {
      Config.config.dataUrl = dataset.url;
      Config.config.vegaServerTable = dataset.table;
    };

    return Config;
  });
<commit_msg>use separate config for each vlPlot<commit_after>'use strict';

// Service for the spec config.
// We keep this separate so that changes are kept even if the spec changes.
angular.module('vleApp')
  .factory('Config', function(vl) {
    var Config = {};

    Config.schema = vl.schema.schema.properties.cfg;
    Config.config = vl.schema.util.instantiate(Config.schema);

    Config.large = function() {
      var config = vl.merge({}, Config.config, {
        singleWidth: 500,
        singleHeight: 500,
        largeBandMaxCardinality: 20
      });

      return vl.duplicate(config);
    };

    Config.small = function() {
      var config = vl.merge({}, Config.config);
      return vl.duplicate(config);
    };

    Config.updateDataset = function(dataset) {
      Config.config.dataUrl = dataset.url;
      Config.config.vegaServerTable = dataset.table;
    };

    return Config;
  });
<|endoftext|>


<commit_before>define(['app',
        '/app/views/search/measure-matrix-elements-derective.html.js',
        '/app/services/search-service.js', '/app/services/app-config-service.js','/app/views/directives/party-status.js'
    ], function (app) {

app.directive("viewMeasure", [function () {
	return {
		restrict   : "EAC",
		templateUrl: "/app/views/forms/view/view-measure.directive.html",
		replace    : true,
		transclude : false,
		scope: {
			document    : "=ngModel",
			locale      : "=",
			target      : "@linkTarget",
			allowDrafts : "@",
			hide		: "@"
		},
		controller : ["$scope", "IStorage","$filter", "searchService", "$q", "appConfigService",
         function ($scope, storage, $filter, searchService, $q, appConfigService)
		{
			//====================
			//
			//====================
			$scope.display = function(field) {

				if(!$scope.hide) return true; //show all fields

				return( $scope.hide.indexOf(field) >= 0 ? false : false);
			}

			//====================
			//
			//====================
			$scope.$watch("document.amendedMeasures", function(_new)
			{
				if ($scope.document && $scope.document.amendedMeasures) {
					$scope.amendedMeasures = angular.fromJson(angular.toJson($scope.document.amendedMeasures));

					if ($scope.amendedMeasures)
						$scope.loadReferences($scope.amendedMeasures, false);
				}
			});

			//====================
			//
			//====================
			$scope.$watch("document.registeredMeasures", function (_new) {
				if ($scope.document && $scope.document.registeredMeasures) {
					$scope.registeredMeasures = angular.fromJson(angular.toJson($scope.document.registeredMeasures));

					if ($scope.registeredMeasures)
						$scope.loadReferences($scope.registeredMeasures, false);
				}
			});

			//====================
			//
			//====================
			$scope.$watch("document.linkedMeasures", function(_new)
			{
				if ($scope.document && $scope.document.linkedMeasures) {
					$scope.linkedMeasures = angular.fromJson(angular.toJson($scope.document.linkedMeasures));

					if ($scope.linkedMeasures)
						$scope.loadReferences($scope.linkedMeasures, false);
				}
			});

            $scope.$watch("document", function (_new) {
				if ($scope.document && $scope.document.header
                    && $scope.document.header.identifier) {
                        var queries = [];
                        if(!$scope.document.measureAmendedBy){
                            var listQuery = {
                                query: 'realm_ss:' + appConfigService.currentRealm.toLowerCase() +
                                 ' AND schema_s:measure AND amendedMeasures_ss:'  + $scope.document.header.identifier
                            };
                            queries.push(searchService.list(listQuery));
                        }
                        if(!$scope.document.measureRelatedTo){
                            var listQuery = {
                                query: 'realm_ss:' + appConfigService.currentRealm.toLowerCase() +
                                 ' AND schema_s:measure AND linkedMeasures_ss:'  + $scope.document.header.identifier
                            };
                            queries.push(searchService.list(listQuery));
                        }
                        $q.all(queries)
                          .then(function(data){
                              $scope.document.measureAmendedBy = data[0].data.response.docs;
                              $scope.document.measureRelatedTo = data[1].data.response.docs;
                              $scope.measureMatrixApi.reloadMatrix(true);
                          });
				}
			});

			$scope.showLanguage = function(model, type){

				if(type=='file'){
					return $filter("term")(model);
				}
				else
					return model;
			}

			//====================
			//
			//====================
			$scope.loadReferences = function(targets, infoOnly) {

				angular.forEach(targets, function(ref) {

					var oOptions = { cache: true };

					if (infoOnly)
						oOptions.info = true;

					storage.documents.get(ref.identifier, oOptions)
						.success(function(data){
							ref.document = data;
						})
						.error(function(error, code){
							if (code == 404 && $scope.allowDrafts == "true") {

								storage.drafts.get(ref.identifier, oOptions)
									.success(function(data){
										ref.document = data;
									})
									.error(function(draftError, draftCode){
										ref.document  = undefined;
										ref.error     = error;
										ref.errorCode = code;
									});
							}

							ref.document  = undefined;
							ref.error     = error;
							ref.errorCode = code;

						});
				});
			};
		}]
	};
}]);

});
<commit_msg>skip virtual records when showing related/amended by MSR for regional Measures<commit_after>define(['app',
        '/app/views/search/measure-matrix-elements-derective.html.js',
        '/app/services/search-service.js', '/app/services/app-config-service.js','/app/views/directives/party-status.js'
    ], function (app) {

app.directive("viewMeasure", [function () {
	return {
		restrict   : "EAC",
		templateUrl: "/app/views/forms/view/view-measure.directive.html",
		replace    : true,
		transclude : false,
		scope: {
			document    : "=ngModel",
			locale      : "=",
			target      : "@linkTarget",
			allowDrafts : "@",
			hide		: "@"
		},
		controller : ["$scope", "IStorage","$filter", "searchService", "$q", "appConfigService",
         function ($scope, storage, $filter, searchService, $q, appConfigService)
		{
			//====================
			//
			//====================
			$scope.display = function(field) {

				if(!$scope.hide) return true; //show all fields

				return( $scope.hide.indexOf(field) >= 0 ? false : false);
			}

			//====================
			//
			//====================
			$scope.$watch("document.amendedMeasures", function(_new)
			{
				if ($scope.document && $scope.document.amendedMeasures) {
					$scope.amendedMeasures = angular.fromJson(angular.toJson($scope.document.amendedMeasures));

					if ($scope.amendedMeasures)
						$scope.loadReferences($scope.amendedMeasures, false);
				}
			});

			//====================
			//
			//====================
			$scope.$watch("document.registeredMeasures", function (_new) {
				if ($scope.document && $scope.document.registeredMeasures) {
					$scope.registeredMeasures = angular.fromJson(angular.toJson($scope.document.registeredMeasures));

					if ($scope.registeredMeasures)
						$scope.loadReferences($scope.registeredMeasures, false);
				}
			});

			//====================
			//
			//====================
			$scope.$watch("document.linkedMeasures", function(_new)
			{
				if ($scope.document && $scope.document.linkedMeasures) {
					$scope.linkedMeasures = angular.fromJson(angular.toJson($scope.document.linkedMeasures));

					if ($scope.linkedMeasures)
						$scope.loadReferences($scope.linkedMeasures, false);
				}
			});

            $scope.$watch("document", function (_new) {
				if ($scope.document && $scope.document.header
                    && $scope.document.header.identifier) {
                        var queries = [];
                        if(!$scope.document.measureAmendedBy){
                            var listQuery = {
                                query: 'realm_ss:' + appConfigService.currentRealm.toLowerCase() +
                                 ' AND schema_s:measure AND NOT virtual_b:* AND amendedMeasures_ss:'  + $scope.document.header.identifier
                            };
                            queries.push(searchService.list(listQuery));
                        }
                        if(!$scope.document.measureRelatedTo){
                            var listQuery = {
                                query: 'realm_ss:' + appConfigService.currentRealm.toLowerCase() +
                                 ' AND schema_s:measure AND NOT virtual_b:* AND linkedMeasures_ss:'  + $scope.document.header.identifier
                            };
                            queries.push(searchService.list(listQuery));
                        }
                        $q.all(queries)
                          .then(function(data){
                              $scope.document.measureAmendedBy = data[0].data.response.docs;
                              $scope.document.measureRelatedTo = data[1].data.response.docs;
                              $scope.measureMatrixApi.reloadMatrix(true);
                          });
				}
			});

			$scope.showLanguage = function(model, type){

				if(type=='file'){
					return $filter("term")(model);
				}
				else
					return model;
			}

			//====================
			//
			//====================
			$scope.loadReferences = function(targets, infoOnly) {

				angular.forEach(targets, function(ref) {

					var oOptions = { cache: true };

					if (infoOnly)
						oOptions.info = true;

					storage.documents.get(ref.identifier, oOptions)
						.success(function(data){
							ref.document = data;
						})
						.error(function(error, code){
							if (code == 404 && $scope.allowDrafts == "true") {

								storage.drafts.get(ref.identifier, oOptions)
									.success(function(data){
										ref.document = data;
									})
									.error(function(draftError, draftCode){
										ref.document  = undefined;
										ref.error     = error;
										ref.errorCode = code;
									});
							}

							ref.document  = undefined;
							ref.error     = error;
							ref.errorCode = code;

						});
				});
			};
		}]
	};
}]);

});
<|endoftext|>


<commit_before>// Copyright (c) E5R Development Team. All rights reserved.
// Licensed under the MIT License. See LICENSE file for license information.

(function(){ 'use strict'
  var web = sys.require('webutils.js'),
      fs = sys.require('fsutils.js');

  function _getCmd(cmd){
    var _path = fs.combine(sys.product.meta.installPath, 'command', '{c}.js'.replace('{c}',cmd)),
        _url = sys.product.meta.makeUrl('/scripts/command/{c}.js'.replace('{c}', cmd));
        command = {},
        content;
    if(!fs.fileExists(_path)){
      web.download(_url, _path, function(error){
        sys.log('#' + error.name + ':', error.message, 'on get command <{c}>.'.replace('{c}', cmd));
      })
    }
    if(fs.fileExists(_path)){
      content = _fso.OpenTextFile(_path, 1).ReadAll();
      eval(content);
    }
    return command.api;
  }

  module.exports = {
    getCmd: _getCmd
  }
})();
<commit_msg>Added checkApi method<commit_after>// Copyright (c) E5R Development Team. All rights reserved.
// Licensed under the MIT License. See LICENSE file for license information.

(function(){ 'use strict'
  var web = sys.require('webutils.js'),
      fs = sys.require('fsutils.js');

  function _getCmd(cmd){
    var _path = fs.combine(sys.product.meta.installPath, 'command', '{c}.js'.replace('{c}',cmd)),
        _url = sys.product.meta.makeUrl('/scripts/command/{c}.js'.replace('{c}', cmd));
        command = {},
        content;
    if(!fs.fileExists(_path)){
      web.download(_url, _path, function(error){
        sys.log('#' + error.name + ':', error.message, 'on get command <{c}>.'.replace('{c}', cmd));
      })
    }
    if(fs.fileExists(_path)){
      content = _fso.OpenTextFile(_path, 1).ReadAll();
      eval(content);
    }
    return command.api;
  }

  /**
   * Checks the integrity of the plugin api
   *
   * @param {object} plugin Object of plugin, returned by _getCmd
   *
   * @return TRUE if ok, throw exception if not ok
   */
  function _checkApi(plugin){
    if(typeof plugin != 'object')
      throw new Error('Plugin must be an object');

    if(typeof plugin.setup != 'function')
      throw new Error('Plugin does not contain the [Setup] method');

    if(typeof plugin.getHelpFile != 'function')
      throw new Error('Plugin does not contain the [GetHelpFile] method');

    if(typeof plugin.run != 'function')
      throw new Error('Plugin does not contain the [Run] method');

    return true;
  }

  module.exports = {
    getCmd: _getCmd,
    checkApi: _checkApi
  }
})();
<|endoftext|>