<commit_before>import store from '../../store';

export default (key, params = null) => {
    if (!store.getters['localisation/isInitialised']) {
        return key;
    }

    let translation = store.getters['localisation/__'](key);

    if (typeof translation === 'undefined' || translation == null) {
        translation = key;

        if (store.state.localisation.keyCollector) {
            store.dispatch('localisation/addMissingKey', key);
        }
    }

    return !!params && typeof params === 'object'
        ? translation.replace(/:(\w*)/g, (e, key) => {
            if (typeof params[key.toLowerCase()] === 'undefined') {
                return key;
            }

            const param = params[key.toLowerCase()];

            if(key === key.toUpperCase()) {
                return param.toUpperCase();
            }

            return key[0] === key[0].toUpperCase()
                ? param.charAt(0).toUpperCase() + param.slice(1)
                : param;
        })
        : translation;
};
<commit_msg>fixes store import in __.js<commit_after>import store from '../../../store';

export default (key, params = null) => {
    if (!store.getters['localisation/isInitialised']) {
        return key;
    }

    let translation = store.getters['localisation/__'](key);

    if (typeof translation === 'undefined' || translation == null) {
        translation = key;

        if (store.state.localisation.keyCollector) {
            store.dispatch('localisation/addMissingKey', key);
        }
    }

    return !!params && typeof params === 'object'
        ? translation.replace(/:(\w*)/g, (e, key) => {
            if (typeof params[key.toLowerCase()] === 'undefined') {
                return key;
            }

            const param = params[key.toLowerCase()];

            if(key === key.toUpperCase()) {
                return param.toUpperCase();
            }

            return key[0] === key[0].toUpperCase()
                ? param.charAt(0).toUpperCase() + param.slice(1)
                : param;
        })
        : translation;
};
<|endoftext|>


<commit_before>/*
 * jQuery Pines Tags (ptags) Plugin 1.0
 *
 * Copyright (c) 2009 Hunter Perrin
 *
 * Licensed (along with all of Pines) under the GNU Affero GPL:
 *	  http://www.gnu.org/licenses/agpl.html
 */

(function($) {
	$.fn.ptags_add = function(textorarray) {
		if (!textorarray)
			return this;
		this.each(function(){
			if (!this.pines_tags)
				return;
			this.pines_tags.ptags_add(textorarray);
		});
		return this;
	};
	$.fn.ptags_remove = function(textorarray) {
		if (!textorarray)
			return this;
		this.each(function(){
			if (!this.pines_tags)
				return;
			this.pines_tags.ptags_remove(textorarray);
		});
		return this;
	};

	$.fn.ptags = function(options) {
		// Build main options before element iteration.
		var opts = $.extend({}, $.fn.ptags.defaults, options);

		// Iterate and transform each matched element.
		var all_elements = this;
		all_elements.each(function() {
			var ptags = $(this);
			ptags.ptags_version = "1.0.0";

			// Check for the ptags class. If it has it, we've already transformed this element.
			if (ptags.hasClass("ui-ptags-tag-box")) return true;
			// Add the ptags class.
			ptags.addClass("ui-ptags-tag-box");

			ptags.extend(ptags, opts);

			ptags.ptags_pages = null;
			ptags.ptags_widget = $("
");
			ptags.ptags_container = $("
");

			// All arrays and objects in our options need to be copied,
			// since they just have a pointer to the defaults if we don't.
			ptags.ptags_tags = ptags.ptags_tags.slice();

			ptags.ptags_add = function(textorarray){
				$.merge(ptags.ptags_tags, (typeof textorarray == "string" ? [textorarray] : textorarray));
				ptags.ptags_unique_check();
				ptags.ptags_update_val();
				ptags.ptags_update_tags();

			};

			ptags.ptags_remove = function(textorarray){
				$.each((typeof textorarray == "string" ? [textorarray] : textorarray), function(){
					var i = $.inArray(""+this, ptags.ptags_tags);
					if (i > -1) {
						ptags.ptags_tags.splice(i, 1);
					}
				});
				ptags.ptags_update_val();
				ptags.ptags_update_tags();
			};

			ptags.ptags_unique_check = function(){
				for (var i = 0; i < ptags.ptags_tags.length; i++) {
					if ($.inArray(ptags.ptags_tags[i], ptags.ptags_tags) < i || ptags.ptags_tags[i] == "") {
						ptags.ptags_tags.splice(i, 1);
						i--;
					}
				}
			};

			ptags.ptags_update_val = function(){
				ptags.val(ptags.ptags_tags.join(ptags.ptags_delimiter).replace(/^,|,$/, ""));
			};

			ptags.ptags_update_tags = function(){
				if (!ptags.ptags_show_tags)
					return;
				ptags.ptags_tag_container.children().remove();
				$.each(ptags.ptags_tags, function(i, val){
					var tag_box = $("
").addClass("ui-state-default ui-corner-all ui-ptags-tag");
					tag_box.append($("
").addClass("ui-ptags-tag-text").html(val).click(function(){
						if (ptags.ptags_editable && ptags.ptags_input_box) {
							input_box.val(tag_box.text()).focus().select();
							ptags.ptags_remove(tag_box.text());
						}
					}));
					if (ptags.ptags_editable && ptags.ptags_input_box) {
						tag_box.hover(function(){
							$(this).addClass("ui-state-hover");
						}, function(){
							$(this).removeClass("ui-state-hover");
						});
					}
					if (ptags.ptags_remover) {
						tag_box.append($("").addClass("ui-ptags-tag-remover ui-icon ui-icon-circle-minus").click(function(){
							ptags.ptags_remove(tag_box.text());
						}));
					}
					ptags.ptags_tag_container.append(tag_box);
				});
			};

			ptags.ptags_widget.addClass("ui-ptags ui-helper-clearfix");
			ptags.wrapAll(ptags.ptags_widget);
			// Update the widget.
			ptags.ptags_widget = ptags.parent();

			ptags.ptags_container.addClass("ui-ptags-tag-box-container");
			ptags.wrapAll(ptags.ptags_container);
			// Update the container.
			ptags.ptags_container = ptags.parent();

			if (ptags.ptags_input_box) {
				var input_box = $(ptags.get(0)).clone().val("").keydown(function(eventObject){
					if (eventObject.keyCode == 13) {
						ptags.ptags_add(this.value.split(ptags.ptags_delimiter));
						this.value = "";
						return false;
					}
				}).blur(function(){
					if (this.value != "") {
						ptags.ptags_add(this.value.split(ptags.ptags_delimiter));
						this.value = "";
					}
				});
				if (input_box.attr("id")) {
					input_box.attr("id", input_box.attr("id") + "_ptags_input");
				}
				if (input_box.attr("name")) {
					input_box.attr("name", input_box.attr("name") + "_ptags_input");
				}
				ptags.ptags_container.append(input_box);
			}

			if (ptags.ptags_current_text) {
				var tmp_tags_arr = this.value.split(ptags.ptags_delimiter);
				$.merge(ptags.ptags_tags, tmp_tags_arr);
				ptags.ptags_unique_check();
				ptags.ptags_update_val();
			}

			if (ptags.ptags_show_box) {
				ptags.blur(function(){
					var tmp_tags_arr = this.value.split(ptags.ptags_delimiter);
					$.merge(ptags.ptags_tags, tmp_tags_arr);
					ptags.ptags_unique_check();
					ptags.ptags_update_val();
					ptags.ptags_update_tags();
				});
			} else {
				ptags.css("display", "none");
			}

			if (ptags.ptags_show_tags) {
				ptags.ptags_tag_container = $("
").addClass("ui-ptags-tag-container");
				ptags.ptags_widget.append(ptags.ptags_tag_container);
				ptags.ptags_update_tags();
			}

			ptags.ptags_widget.append($("
").addClass("ui-helper-clearfix ui-ptags-clear"));

			// Save the ptags object in the DOM, so we can access it.
			this.pines_tags = ptags;
		});

		return all_elements;
	};

	$.fn.ptags.defaults = {
		// The default tags.
		ptags_tags: [],
		// Add the current text of the tag box to the tags array.
		ptags_current_text: true,
		// The delimiter between tags.
		ptags_delimiter: ",",
		// Show tags after the box for easier editing.
		ptags_show_tags: true,
		// Show the tag box. (Not necessary if you show tags.)
		ptags_show_box: false,
		// Provide an input box to let the user add tags. (Clones the original box's styling.)
		ptags_input_box: true,
		// Provide a remover button on each tag.
		ptags_remover: true,
		// Let the user click tags to edit them. (Requires the input box.)
		ptags_editable: true
	};
})(jQuery);<commit_msg>New configuration code and bugfixes in ptags.<commit_after>/*
 * jQuery Pines Tags (ptags) Plugin 1.0
 *
 * Copyright (c) 2009 Hunter Perrin
 *
 * Licensed (along with all of Pines) under the GNU Affero GPL:
 *	  http://www.gnu.org/licenses/agpl.html
 */

(function($) {
	$.fn.ptags_add = function(textorarray) {
		if (!textorarray)
			return this;
		this.each(function(){
			if (!this.pines_tags)
				return;
			this.pines_tags.ptags_add(textorarray);
		});
		return this;
	};
	$.fn.ptags_remove = function(textorarray) {
		if (!textorarray)
			return this;
		this.each(function(){
			if (!this.pines_tags)
				return;
			this.pines_tags.ptags_remove(textorarray);
		});
		return this;
	};

	$.fn.ptags = function(options) {
		// Build main options before element iteration.
		var opts = $.extend({}, $.fn.ptags.defaults, options);

		// Iterate and transform each matched element.
		var all_elements = this;
		all_elements.each(function() {
			var ptags = $(this);
			ptags.ptags_version = "1.0.0";

			// Check for the ptags class. If it has it, we've already transformed this element.
			if (ptags.hasClass("ui-ptags-tag-box")) return true;
			// Add the ptags class.
			ptags.addClass("ui-ptags-tag-box");

			ptags.extend(ptags, opts);

			ptags.ptags_pages = null;
			ptags.ptags_widget = $("
");
			ptags.ptags_container = $("
");

			// All arrays and objects in our options need to be copied,
			// since they just have a pointer to the defaults if we don't.
			ptags.ptags_tags = ptags.ptags_tags.slice();

			ptags.ptags_add = function(textorarray){
				$.merge(ptags.ptags_tags, (typeof textorarray == "string" ? [textorarray] : textorarray));
				ptags.ptags_unique_check();
				ptags.ptags_update_val();
				ptags.ptags_update_tags();

			};

			ptags.ptags_remove = function(textorarray){
				$.each((typeof textorarray == "string" ? [textorarray] : textorarray), function(){
					var i = $.inArray(""+this, ptags.ptags_tags);
					if (i > -1)
						ptags.ptags_tags.splice(i, 1);
				});
				ptags.ptags_update_val();
				ptags.ptags_update_tags();
			};

			ptags.ptags_unique_check = function(){
				for (var i = 0; i < ptags.ptags_tags.length; i++) {
					if ($.inArray(ptags.ptags_tags[i], ptags.ptags_tags) < i || ptags.ptags_tags[i] == "") {
						ptags.ptags_tags.splice(i, 1);
						i--;
					}
				}
			};

			ptags.ptags_update_val = function(){
				ptags.val(ptags.ptags_tags.join(ptags.ptags_delimiter).replace(/^,|,$/, ""));
			};

			ptags.ptags_update_tags = function(){
				if (!ptags.ptags_show_tags) return;
				ptags.ptags_tag_container.children().remove();
				$.each(ptags.ptags_tags, function(i, val){
					var tag_box = $("
").addClass("ui-state-default ui-corner-all ui-ptags-tag");
					tag_box.append($("
").addClass("ui-ptags-tag-text").html(val).click(function(){
						if (ptags.ptags_editable && ptags.ptags_input_box) {
							input_box.val(tag_box.text()).focus().select();
							ptags.ptags_remove(tag_box.text());
						}
					}));
					if (ptags.ptags_editable && ptags.ptags_input_box) {
						tag_box.hover(function(){
							$(this).addClass("ui-state-hover");
						}, function(){
							$(this).removeClass("ui-state-hover");
						});
					}
					if (ptags.ptags_remover) {
						tag_box.append($("").addClass("ui-ptags-tag-remover ui-icon ui-icon-circle-minus").click(function(){
							ptags.ptags_remove(tag_box.text());
						}));
					}
					ptags.ptags_tag_container.append(tag_box);
				});
			};

			ptags.ptags_widget.addClass("ui-ptags ui-helper-clearfix");
			ptags.wrapAll(ptags.ptags_widget);
			// Update the widget.
			ptags.ptags_widget = ptags.parent();

			ptags.ptags_container.addClass("ui-ptags-tag-box-container");
			ptags.wrapAll(ptags.ptags_container);
			// Update the container.
			ptags.ptags_container = ptags.parent();

			if (ptags.ptags_input_box) {
				var input_box = $(ptags.get(0)).clone().val("").keydown(function(e){
					if (e.keyCode == 13 && !e.shiftKey) {
						ptags.ptags_add(input_box.val().split(ptags.ptags_delimiter));
						input_box.val("");
						return false;
					}
				}).blur(function(){
					if (input_box.val() != "") {
						ptags.ptags_add(input_box.val().split(ptags.ptags_delimiter));
						input_box.val("");
					}
				});
				if (input_box.attr("id"))
					input_box.attr("id", input_box.attr("id") + "_ptags_input");
				if (input_box.attr("name"))
					input_box.attr("name", input_box.attr("name") + "_ptags_input");
				ptags.ptags_container.append(input_box);
			}

			if (ptags.ptags_current_text) {
				var tmp_tags_arr = ptags.val().split(ptags.ptags_delimiter);
				$.merge(ptags.ptags_tags, tmp_tags_arr);
				ptags.ptags_unique_check();
				ptags.ptags_update_val();
			}

			if (ptags.ptags_show_box) {
				ptags.blur(function(){
					var tmp_tags_arr = ptags.val().split(ptags.ptags_delimiter);
					$.merge(ptags.ptags_tags, tmp_tags_arr);
					ptags.ptags_unique_check();
					ptags.ptags_update_val();
					ptags.ptags_update_tags();
				});
			} else {
				ptags.css("display", "none");
			}

			if (ptags.ptags_show_tags) {
				ptags.ptags_tag_container = $("
").addClass("ui-ptags-tag-container");
				ptags.ptags_widget.append(ptags.ptags_tag_container);
				ptags.ptags_update_tags();
			}

			ptags.ptags_widget.append($("
").addClass("ui-helper-clearfix ui-ptags-clear"));

			// Save the ptags object in the DOM, so we can access it.
			this.pines_tags = ptags;
		});

		return all_elements;
	};

	$.fn.ptags.defaults = {
		// The default tags.
		ptags_tags: [],
		// Add the current text of the tag box to the tags array.
		ptags_current_text: true,
		// The delimiter between tags.
		ptags_delimiter: ",",
		// Show tags after the box for easier editing.
		ptags_show_tags: true,
		// Show the tag box. (Not necessary if you show tags.)
		ptags_show_box: false,
		// Provide an input box to let the user add tags. (Clones the original box's styling.)
		ptags_input_box: true,
		// Provide a remover button on each tag.
		ptags_remover: true,
		// Let the user click tags to edit them. (Requires the input box.)
		ptags_editable: true
	};
})(jQuery);<|endoftext|>


<commit_before>var Gaffa = require('gaffa');

function createNextStep(action, scope, event, stepIndex){
    stepIndex = stepIndex || 0;

    var callback = function(event){
        if(event.getValue()){
            action.gaffa.gedi.debind(callback);
            if(++stepIndex<action.steps.length){
                createNextStep(action, scope, event, stepIndex);
            }else{
                action.triggerActions('complete', scope, event);
                action.debind();
            }
        }
    };
    action._flowBindings.push(callback);
    action.gaffa.gedi.bind(action.steps[stepIndex], callback);
}

function Flow(actionDefinition){
    this._flowBindings = [];
}
Flow = Gaffa.createSpec(Flow, Gaffa.Action);
Flow.prototype._type = 'flow';
Flow.prototype.cancel = new Gaffa.Property();
Flow.prototype.trigger = function(parent, scope, event){
    var action = this;

    if(!this.steps || !this.steps.length){
        return;
    }

    createNextStep(this, scope, event);

    if(action.cancel.binding){
        var cancelCallback = function(event){
            if(event.getValue()){
                action.triggerActions('cancel', scope, event);
                action.debind();
            }
        };
        action._flowBindings.push(cancelCallback);
        action.gaffa.gedi.bind(action.cancel.binding, cancelCallback);
    }
};
Flow.prototype.debind = function(){
    var gedi = this.gaffa.gedi;
    for(var i = 0; i < this._flowBindings.length; i++) {
        gedi.debind(this._flowBindings[i]);
    }
    Gaffa.Action.prototype.debind.call(this);
};

module.exports = Flow;<commit_msg>passed action parent path to binding, make async<commit_after>var Gaffa = require('gaffa');

function createNextStep(action, scope, event, stepIndex){
    stepIndex = stepIndex || 0;

    var callback = function(event){
        if(event.getValue()){
            action.gaffa.gedi.debind(callback);
            if(++stepIndex<action.steps.length){
                createNextStep(action, scope, event, stepIndex);
            }else{
                action.triggerActions('complete', scope, event);
                action.complete();
            }
        }
    };
    action._flowBindings.push(callback);
    action.gaffa.gedi.bind(action.steps[stepIndex], callback, action.getPath());
}

function Flow(){
    this._flowBindings = [];
}
Flow = Gaffa.createSpec(Flow, Gaffa.Action);
Flow.prototype._type = 'flow';
Flow.prototype._async = true;
Flow.prototype.cancel = new Gaffa.Property();
Flow.prototype.trigger = function(parent, scope, event){
    var action = this;

    if(!this.steps || !this.steps.length){
        return;
    }

    createNextStep(this, scope, event);

    if(action.cancel.binding){
        var cancelCallback = function(event){
            if(event.getValue()){
                action.triggerActions('cancel', scope, event);
                action.complete();
            }
        };
        action._flowBindings.push(cancelCallback);
        action.gaffa.gedi.bind(action.cancel.binding, cancelCallback, action.getPath());
    }
};
Flow.prototype.debind = function(){
    var gedi = this.gaffa.gedi;
    for(var i = 0; i < this._flowBindings.length; i++) {
        gedi.debind(this._flowBindings[i]);
    }
    Gaffa.Action.prototype.debind.call(this);
};

module.exports = Flow;<|endoftext|>


<commit_before>var Mode4D = (function (scope) {
	//Constructor
	function Mode4D(document){
		this.document = document;

	}

	// Creates the scene and everything
	Mode4D.prototype.init = function(div,gui){
		// Create two child divs
		var leftChild = document.createElement("div");
		var rightChild = document.createElement("div");
		div.appendChild(leftChild); leftChild.id = "left-view";
		div.appendChild(rightChild); rightChild.id = "right-view";
		var style = "display:inline-block;"
		leftChild.style = style;
		rightChild.style = style;
		this.leftChild = leftChild; this.rightChild = rightChild;

		var viewWidth = (window.innerWidth-20)/2;
		var leftView = this.createView(leftChild,viewWidth);
		var rightView = this.createView(rightChild,viewWidth);
		this.originalLeftView = leftView;
		this.leftView = leftView;
		this.rightView = rightView;

		// Init gui
	    gui.init("4D",this.callbacks,this);
	    this.gui = gui;

	    // Set up left view
		var camera = leftView.camera({
		  proxy: true, // this alows interactive camera controls to override the position
		  position: [0, 1, 3],
		})
		// need to rotate in 4D to see the 4th axis
		var rot_matrix = [
				1, 0, 0, 0,
		    0, 1, 0, 0,
		    0, 0, 1, 0,
		    0, 0, 0, 1,
			];

		leftView = leftView.transform4({
			matrix: rot_matrix,
			id:'transform4d',
		}).cartesian4({
		  range: [[-10,10], [-10,10],[-10,10], [-10,10]],
		  scale: [1,1,1,1],
		});

		// leftView = leftView.transform({
		//   position: [0, 0, 0,0],
		//   rotation: [0.1,0.3,0]
		// })

		leftView
		  .axis({
		    axis: 1,
		    width: 4,
		    color:'black',
		  })
		  .axis({
		    axis: 2,
		    width: 4,
		    color:'black',
		  })
		  .axis({
		    axis: 3,
		    width: 4,
		    color:'black',
		  })
			.axis({
		    axis: 4,
		    width: 4,
		    color:'black',
		  })
		  .grid({
		    axes: [1,3],
		    width: 1,
		    divideX: 10,
		    divideY: 10
		  });

		 // Add text
		leftView.array({
			data: [[12,0,0,0], [0,12,0,0], [0,0,12,0], [0,0,0,12]],
		  channels: 4, // necessary
		  live: false,
		}).text({
		  data: ["x", "y","z","w"],
		}).label({
		  color: 0x000000,
		});

		var pointsArray = []

		function Eq(x,y,z){
		  return Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2) - 50;
		}

		function DrawCube(size,step){
		  var arr = []
		  for(var x=0;x<=1;x+=step){
		    for(var y=0;y<=1;y+=step){
		      for(var z=0;z<=1;z+=step){
		        //for(var w=-1;w<=1;w++){
		          arr.push([x*size,y*size,z*size])
		        //}

		      }
		    }
		  }
		  return arr;
		}

		function DrawSphere(){
		  var arr = [];
		  var step = 0.5;

		  for(var x=-10;x<=10;x+=step){
		    for(var y=-10;y<=10;y+=step){
		      for(var z=-10;z<=10;z+=step){
		        if(Eq(x,y,z) < 0) arr.push([x/9,y/9,z/9])
		      }
		    }
		  }

		  return arr;
		}

		var cube = DrawCube(10,1);
	    var pointsArray = [];
	    var edges = [];

	    // Move one cube to w=0 and one to w=10
	    for(var i=0;i<cube.length;i++){
	      var p1 = [cube[i][0],cube[i][1],cube[i][2],0]
	      var p2 = [cube[i][0],cube[i][1],cube[i][2],10]
	      pointsArray.push(p1)
	      pointsArray.push(p2)
	    }

	    // Create the edges
	    for(var i=0;i<pointsArray.length;i++){
	      var p = pointsArray[i];
	      for(var j=0;j<pointsArray.length;j++){
	        var p2 = pointsArray[j];
	        // To connect an edge, p and p2 must differ by only one coordinate
	        var diff = 0;
	        for(var k=0;k<p.length;k++){
	          if(p[k] != p2[k]) diff++;
	        }
	        if(diff == 1){
	          edges.push([p,p2])
	        }
	      }
	    }

	    // Define colors for the points (the farther it is on the w, the redder it is)
	    leftView.array({
	      id:'colors',
	      width: pointsArray.length,
	      expr: function (emit,i, time) {
	        var p = pointsArray[i];
	        var x = p[0];
	        var y = p[1];
	        var z = p[2];
	        var w = p[3];

	        emit(w/10, 0, 0, 1);
	      },
	      channels: 4,
	    })
	    // Define colors for the edges
	    leftView.array({
	      id:'edge_colors',
	      width: edges.length,
	      expr: function (emit,i, time) {
	        var p1 = edges[i][0];
	        var p2 = edges[i][1];
	        var w1 = p1[3]/10;
	        var w2 = p2[3]/10;
	        emit((w1+w2)/2, 0, 0, 1);

	      },
	      channels: 4,
	    })

	    // Draw the vertices
	    leftView.array({
	      width: pointsArray.length,
	      expr: function (emit,i, time) {
	        var p = pointsArray[i];
	        var x = p[0];
	        var y = p[1];
	        var z = p[2];
	        var w = p[3];

	        emit(x, y, z, w);
	      },
	      channels: 4,
	    });

	    leftView.point({
	      colors: '#colors',
	      size: 40,
	    });

	    // Draw the edges
	    leftView.array({
	      width: edges.length,
	      expr: function(emit,i,time){
	        var p1 = edges[i][0];
	        var p2 = edges[i][1];
	        emit(p1[0],p1[1],p1[2],p1[3]);
	        emit(p2[0],p2[1],p2[2],p2[3]);
	      },
	      channels:4,
	      items:2,
	    })
	    leftView.vector({
	      colors: '#edge_colors',
	      width:10,
	      start:false
	    })

		leftView.print()

		this.leftView = leftView;

		// Rotate it along the w
		var count = 0;
		var original = this.originalLeftView;
	    setInterval(function(){
	      count += 0.04;
	      rot_matrix[3] = Math.sin(count);
	      rot_matrix[7] = rot_matrix[3];
	      rot_matrix[11] = rot_matrix[3];

	      original.select("#transform4d").set("matrix",rot_matrix)
	      original.print();
	    },1000/60)

		// Set up right view
		rightView = rightView.cartesian({
		  range: [[-10, 10],[-10,10],[-10,10]],
		  scale: [1, 1,1],
		});

		rightView = rightView.transform({
		  position: [0, 0, 0,0],
		  rotation: [0.1,0.3,0]
		});

		rightView.camera({
		  proxy: true, // this alows interactive camera controls to override the position
		  position: [0, 1, 3],
		})
		 .axis({
		    axis: 1,
		    width: 4,
		    color:'black',
		  })
		  .axis({
		    axis: 2,
		    width: 4,
		    color:'black',
		  })
		  .axis({
		    axis: 3,
		    width: 4,
		    color:'black',
		  })
		  .grid({
		    axes: [1,3],
		    width: 1,
		    divideX: 10,
		    divideY: 10
		  })
		  .array({
		  data: [[11,1,0], [0,12,0],[0,0,11]],
		  channels: 3, // necessary
		  live: false,
		}).text({
		  data: ["x", "y","z"],
		}).label({
		  color: 0x000000,
		});

		this.rightView = rightView
	}

	Mode4D.prototype.createView = function(el,width){
		var mathbox = mathBox({
		  element: el,
		  size: {width:width,height:window.innerHeight-50},
	      plugins: ['core', 'controls', 'cursor', 'mathbox'],
	      controls: {
	        // Orbit controls, i.e. Euler angles, with gimbal lock
	        klass: THREE.OrbitControls,
	        // Trackball controls, i.e. Free quaternion rotation
	        //klass: THREE.TrackballControls,
	      },
	    });
	    if (mathbox.fallback) throw "WebGL not supported"
	    // Set the renderer color
		mathbox.three.renderer.setClearColor(new THREE.Color(0xFFFFFF), 1.0);
		return mathbox;
	}

	Mode4D.prototype.callbacks = {

	};

	//Destroys everything created
	Mode4D.prototype.cleanup = function(){
		// Destroy mathbox overlays
		var overlays = this.document.querySelector(".mathbox-overlays");
		overlays.parentNode.removeChild(overlays);
		// Destroy the canvas element
		var canvas = this.document.querySelector("canvas");
		canvas.parentNode.removeChild(canvas);
		// Remove the two child divs
		this.leftChild.parentNode.removeChild(this.leftChild);
		this.rightChild.parentNode.removeChild(this.rightChild);

		// Destroy gui
		this.gui.cleanup();
	}

	scope.Mode4D = Mode4D;
	return Mode4D;

})(typeof exports === 'undefined' ? {} : exports);
<commit_msg>Cleaned up left view. Leaving it empty for now<commit_after>var Mode4D = (function (scope) {
	//Constructor
	function Mode4D(document){
		this.document = document;

	}

	// Creates the scene and everything
	Mode4D.prototype.init = function(div,gui){
		// Create two child divs
		var leftChild = document.createElement("div");
		var rightChild = document.createElement("div");
		div.appendChild(leftChild); leftChild.id = "left-view";
		div.appendChild(rightChild); rightChild.id = "right-view";
		var style = "display:inline-block;"
		leftChild.style = style;
		rightChild.style = style;
		this.leftChild = leftChild; this.rightChild = rightChild;

		var viewWidth = (window.innerWidth-20)/2;
		var leftView = this.createView(leftChild,viewWidth);
		var rightView = this.createView(rightChild,viewWidth);
		this.originalLeftView = leftView;
		this.leftView = leftView;
		this.rightView = rightView;

		// Init gui
	    gui.init("4D",this.callbacks,this);
	    this.gui = gui;

	    // Set up left view
		var camera = leftView.camera({
		  proxy: true, // this alows interactive camera controls to override the position
		  position: [0, 1, 3],
		})

		 var rot_matrix = [
        1, 0, 0, .577,
        0, 1, 0, .577,
        0, 0, 1, .577,
        0, 0, 0, 1,
      ]

		leftView = leftView.transform4({
			matrix: rot_matrix,
		}).cartesian4({
		  range: [[-10,10], [-10,10],[-10,10], [-10,10]],
		  scale: [1,1,1,1],
		});

		leftView
		  .axis({
		    axis: 1,
		    width: 4,
		    color:'black',
		  })
		  .axis({
		    axis: 2,
		    width: 4,
		    color:'black',
		  })
		  .axis({
		    axis: 3,
		    width: 4,
		    color:'black',
		  })
			.axis({
		    axis: 4,
		    width: 4,
		    color:'black',
		  })
		  .grid({
		    axes: [1,3],
		    width: 1,
		    divideX: 10,
		    divideY: 10
		  });

		 // Add text
		leftView.array({
			data: [[12,0,0,0], [0,12,0,0], [0,0,12,0], [0,0,0,12]],
		  channels: 4, // necessary
		  live: false,
		}).text({
		  data: ["x", "y","z","w"],
		}).label({
		  color: 0x000000,
		});

		this.leftView = leftView;

		// Set up right view
		rightView = rightView.cartesian({
		  range: [[-10, 10],[-10,10],[-10,10]],
		  scale: [1, 1,1],
		});

		rightView = rightView.transform({
		  position: [0, 0, 0,0],
		  rotation: [0.1,0.3,0]
		});

		rightView.camera({
		  proxy: true, // this alows interactive camera controls to override the position
		  position: [0, 1, 3],
		})
		 .axis({
		    axis: 1,
		    width: 4,
		    color:'black',
		  })
		  .axis({
		    axis: 2,
		    width: 4,
		    color:'black',
		  })
		  .axis({
		    axis: 3,
		    width: 4,
		    color:'black',
		  })
		  .grid({
		    axes: [1,3],
		    width: 1,
		    divideX: 10,
		    divideY: 10
		  })
		  .array({
		  data: [[11,1,0], [0,12,0],[0,0,11]],
		  channels: 3, // necessary
		  live: false,
		}).text({
		  data: ["x", "y","z"],
		}).label({
		  color: 0x000000,
		});

		this.rightView = rightView
	}

	Mode4D.prototype.createView = function(el,width){
		var mathbox = mathBox({
		  element: el,
		  size: {width:width,height:window.innerHeight-50},
	      plugins: ['core', 'controls', 'cursor', 'mathbox'],
	      controls: {
	        // Orbit controls, i.e. Euler angles, with gimbal lock
	        klass: THREE.OrbitControls,
	        // Trackball controls, i.e. Free quaternion rotation
	        //klass: THREE.TrackballControls,
	      },
	    });
	    if (mathbox.fallback) throw "WebGL not supported"
	    // Set the renderer color
		mathbox.three.renderer.setClearColor(new THREE.Color(0xFFFFFF), 1.0);
		return mathbox;
	}

	Mode4D.prototype.callbacks = {

	};

	//Destroys everything created
	Mode4D.prototype.cleanup = function(){
		// Destroy mathbox overlays
		var overlays = this.document.querySelector(".mathbox-overlays");
		overlays.parentNode.removeChild(overlays);
		// Destroy the canvas element
		var canvas = this.document.querySelector("canvas");
		canvas.parentNode.removeChild(canvas);
		// Remove the two child divs
		this.leftChild.parentNode.removeChild(this.leftChild);
		this.rightChild.parentNode.removeChild(this.rightChild);

		// Destroy gui
		this.gui.cleanup();
	}

	scope.Mode4D = Mode4D;
	return Mode4D;

})(typeof exports === 'undefined' ? {} : exports);
<|endoftext|>


<commit_before>(function() {
  var UI = {
    showComputerMessage: function(callback) {
      $("#Computer").show("fast", function() {
        callback(UI.humanPlay);
      });
    },

    hideComputerMessage: function() {
      $("#Computer").hide();
    },

    showHumanMessage: function() {
      $("#Human").show();
    },

    hideHumanMessage: function() {
      $("#Human").hide();
    },

    clickSpot: function(callback) {
      $("tr td").click(function(e) {
        callback(e.target.id, UI.computerPlay);
      });
    },

    clickButton: function(button, callback) {
      $(button).click(function(e) {
        if (button == ".player") {
          return UI.choiceMark();
        }
        else if (button == ".players") {
          return UI.choiceMark();
        }
        else if (button == "#Xmark" || button == "#Omark") {
          Game.currentPlayer = UI.getTextContents(e.target.id);
          UI.toggleDisplayedButton(".playerMark", ".game");
        }
        else if (button == ".btn-new") {
          UI.hideButton(".game")
          UI.unbindClick("button");
          UI.unbindClick("tr td");
          UI.resetGame();
        }
        else if (button == ".btn-restart") {
          UI.hideButton(".game")
          UI.unbindClick("button");
          UI.resetGame();
        }
        e.stopPropagation();
        callback(e.target);
      });
    },

    unbindClick: function(element) {
      $(element).unbind("click");
    },

    removeText: function(element) {
      $(element).empty();
    },

    getTextContents: function(elementID) {
      return $("#" + elementID).text()
    },

    setTextContents: function(elementID, TextContents) {
      $("#" + elementID).text(TextContents);
    },

    spotErrorMessage: function() {
      alert("That is not an available spot.\nPlease choose a different spot.");
    },

    winMessage: function(winner) {
      alert("Congratulations.\n"+ winner +" win!!");
    },

    tieMessage: function() {
      alert("Game is tied.\nGame Over.");
    },

    inputErrorMessage: function() {
      alert("You have to choose 'y' or 'n'.");
    },

    askFirstMove: function() {
      return prompt("Do you require the first move? (y/n)");
    },

    toggleDisplayedButton: function(hideClass, showClass) {
      $(hideClass).hide();
      $(hideClass).unbind();
      $(showClass).show()
    },

    hideButton: function(hideClass1, hideClass2) {
      $(hideClass1).hide();
      $(hideClass2).hide();
    },

    visualAfterGameOver: function() {
      this.unbindClick("tr td");
      this.toggleDisplayedButton(".btn-new", ".btn-restart");
      this.hideComputerMessage();
      this.hideHumanMessage();
      this.restartGame();
    },

    visualWhenGameOver: function(currentPlayer) {
      if(GameRules.gameWin(GameBoard)) {
        this.winMessage(Game.winner(currentPlayer));
        this.visualAfterGameOver();
      }
      else if(GameRules.gameTie(GameBoard)) {
        this.tieMessage();
        this.visualAfterGameOver();
      }
    },

    choiceMark: function() {
      UI.hideButton(".btn-new", ".btn-restart");
      UI.toggleDisplayedButton(".menu", ".playerMark");
      UI.clickButton("#Xmark", UI.introGame);
      UI.clickButton("#Omark", UI.introGame);
    },

    mainGame: function() {
      UI.toggleDisplayedButton(".btn-start", ".menu");
      UI.clickButton(".player");
      UI.clickButton(".players");
    },

    introGame: function(button) {
      UI.newGame();
      Game.firstMove(button);
      Game.playGame();
    },

    startGame: function() {
      this.hideButton(".menu");
      this.hideButton(".game", ".playerMark");
      this.clickButton(".btn-start", UI.mainGame);
    },

    resetGame: function() {
      this.removeText("tr td");
      GameBoard.resetBoard();
    },

    newGame: function() {
      this.hideComputerMessage();
      this.hideHumanMessage();
      this.clickButton(".btn-new", UI.mainGame);
    },

    restartGame: function() {
      this.clickButton(".btn-restart", UI.mainGame);
    },

    humanPlay: function() {
      UI.showHumanMessage();
      UI.clickSpot(Game.humanChoice)
    },

    computerPlay: function() {
      UI.showComputerMessage(Game.computerChoice);
    }
  };
  window.UI = UI;
})();
<commit_msg>fixed clickButton() in UI<commit_after>(function() {
  var UI = {
    showComputerMessage: function(callback) {
      $("#Computer").show("fast", function() {
        callback(UI.humanPlay);
      });
    },

    hideComputerMessage: function() {
      $("#Computer").hide();
    },

    showHumanMessage: function() {
      $("#Human").show();
    },

    hideHumanMessage: function() {
      $("#Human").hide();
    },

    clickSpot: function(callback) {
      $("tr td").click(function(e) {
        callback(e.target.id, UI.computerPlay);
      });
    },

    clickButton: function(button, callback) {
      $(button).click(function(e) {
        if (button == ".player" || button == ".players") {
          return UI.choiceMark();
        }
        else if (button == "#Xmark" || button == "#Omark") {
          Game.currentPlayer = UI.getTextContents(e.target.id);
          UI.toggleDisplayedButton(".playerMark", ".game");
        }
        else if (button == ".btn-new") {
          UI.hideButton(".game")
          UI.unbindClick("button");
          UI.unbindClick("tr td");
          UI.resetGame();
        }
        else if (button == ".btn-restart") {
          UI.hideButton(".game")
          UI.unbindClick("button");
          UI.resetGame();
        }
        e.stopPropagation();
        callback(e.target);
      });
    },

    unbindClick: function(element) {
      $(element).unbind("click");
    },

    removeText: function(element) {
      $(element).empty();
    },

    getTextContents: function(elementID) {
      return $("#" + elementID).text()
    },

    setTextContents: function(elementID, TextContents) {
      $("#" + elementID).text(TextContents);
    },

    spotErrorMessage: function() {
      alert("That is not an available spot.\nPlease choose a different spot.");
    },

    winMessage: function(winner) {
      alert("Congratulations.\n"+ winner +" win!!");
    },

    tieMessage: function() {
      alert("Game is tied.\nGame Over.");
    },

    inputErrorMessage: function() {
      alert("You have to choose 'y' or 'n'.");
    },

    askFirstMove: function() {
      return prompt("Do you require the first move? (y/n)");
    },

    toggleDisplayedButton: function(hideClass, showClass) {
      $(hideClass).hide();
      $(hideClass).unbind();
      $(showClass).show()
    },

    hideButton: function(hideClass1, hideClass2) {
      $(hideClass1).hide();
      $(hideClass2).hide();
    },

    visualAfterGameOver: function() {
      this.unbindClick("tr td");
      this.toggleDisplayedButton(".btn-new", ".btn-restart");
      this.hideComputerMessage();
      this.hideHumanMessage();
      this.restartGame();
    },

    visualWhenGameOver: function(currentPlayer) {
      if(GameRules.gameWin(GameBoard)) {
        this.winMessage(Game.winner(currentPlayer));
        this.visualAfterGameOver();
      }
      else if(GameRules.gameTie(GameBoard)) {
        this.tieMessage();
        this.visualAfterGameOver();
      }
    },

    choiceMark: function() {
      UI.hideButton(".btn-new", ".btn-restart");
      UI.toggleDisplayedButton(".menu", ".playerMark");
      UI.clickButton("#Xmark", UI.introGame);
      UI.clickButton("#Omark", UI.introGame);
    },

    mainGame: function() {
      UI.toggleDisplayedButton(".btn-start", ".menu");
      UI.clickButton(".player");
      UI.clickButton(".players");
    },

    introGame: function(button) {
      UI.newGame();
      Game.firstMove(button);
      Game.playGame();
    },

    startGame: function() {
      this.hideButton(".menu");
      this.hideButton(".game", ".playerMark");
      this.clickButton(".btn-start", UI.mainGame);
    },

    resetGame: function() {
      this.removeText("tr td");
      GameBoard.resetBoard();
    },

    newGame: function() {
      this.hideComputerMessage();
      this.hideHumanMessage();
      this.clickButton(".btn-new", UI.mainGame);
    },

    restartGame: function() {
      this.clickButton(".btn-restart", UI.mainGame);
    },

    humanPlay: function() {
      UI.showHumanMessage();
      UI.clickSpot(Game.humanChoice)
    },

    computerPlay: function() {
      UI.showComputerMessage(Game.computerChoice);
    }
  };
  window.UI = UI;
})();
<|endoftext|>


<commit_before>/**
 * @module ios-driver
 */

/**
 *
 * @constructor
 */
var Cache = function () {
    this.storage = {};
    this.lastReference = 3;

    this.store = function (element) {
        if (element && element.type && element.type() === "UIAApplication") {
            var id = 1;
            element.id = id;
            return id;
        } else {
            this.lastReference++;
            element.id = this.lastReference;
            this.storage[this.lastReference] = element;
            return element.id;
        }

    };

    this.get = function (reference, opt_checkStale) {
        var checkStale = true;
        if (opt_checkStale === false) {
            checkStale = false;
        }
        if (reference == 0) {
            return UIATarget.localTarget().frontMostApp().mainWindow();
        } else if (reference == 1) {
            return UIATarget.localTarget().frontMostApp();
        } else if (reference == 2) {
            return UIATarget.localTarget();
        } else if (reference == 3) {
            if (this.storage[3]) {
                return this.storage[3];
            } else {
                throw new UIAutomationException("No alert opened", 27);
            }

        }

        var res = this.storage[reference];

        // there is an alert.
        if (this.storage[3]) {

            if (res.isInAlert()) {
                return res;
            } else {
                throw new UIAutomationException("cannot interact with object " + res
                                                    + ". There is an alert.", 26);
            }

        } else {
            // target and app aren't stale.
            if (!res) {
                throw new UIAutomationException("can't find " + reference + " in cache.");
                // window an apps aren't stale ?
            } else if (res.type && (res.type() == "UIAWindow" || res.type() == "UIAApplication")) {
                return res;
                // on arrays, stale doesn't make sense.
            } else if (checkStale && res.isStale && res.isStale()) {
                throw new UIAutomationException("elements ref:" + reference + " is stale", 10);
            } else {
                return res;
            }
        }

    };

    this.getAlert = function () {
        return this.storage[3];
    };
    this.setAlert = function (alert) {
        this.storage[3] = alert;
        log("found alert");
    };

    this.clearAlert = function () {
        log("removed alert");
        this.storage[3] = null;
    }

    this.clear = function () {
        this.storage = {};
        this.storage[0] = UIATarget.localTarget().frontMostApp().mainWindow();
    };

    this.clear();

}<commit_msg>addign comments for the cache.<commit_after>/**
 * @module ios-driver
 */

/**
 *
 * @constructor
 */
var Cache = function () {
    this.storage = {};
    this.lastReference = 3;

    /**
     * Stores a UIElement in the cache. Some special elements have hardcoded values.
     *
     * The mainWindow = 0
     * UIAApplication  frontMostApp() = 1
     * UIATarget = 2
     * If there is an alert, its id = 3. id=3 is reserved for alerts.
     *
     * @param element the element to cache.
     * @return {number} the id of the element in the cache.
     */
    this.store = function (element) {
        if (element && element.type && element.type() === "UIAApplication") {
            var id = 1;
            element.id = id;
            return id;
        } else {
            this.lastReference++;
            element.id = this.lastReference;
            this.storage[this.lastReference] = element;
            return element.id;
        }

    };

    /**
     * return the UIAElement with the given reference.
     *
     * @param {number} reference The reference of the element. ( the id from webdriver )
     * @param opt_checkStale optional. Defaults to true. If true, checks if an element is stale, and
     * if not, scrolls it into view before returning it.
     * @return {UIAElement}
     */
    this.get = function (reference, opt_checkStale) {
        var checkStale = true;
        if (opt_checkStale === false) {
            checkStale = false;
        }
        if (reference == 0) {
            return UIATarget.localTarget().frontMostApp().mainWindow();
        } else if (reference == 1) {
            return UIATarget.localTarget().frontMostApp();
        } else if (reference == 2) {
            return UIATarget.localTarget();
        } else if (reference == 3) {
            if (this.storage[3]) {
                return this.storage[3];
            } else {
                throw new UIAutomationException("No alert opened", 27);
            }

        }

        var res = this.storage[reference];

        // there is an alert.
        if (this.storage[3]) {

            if (res.isInAlert()) {
                return res;
            } else {
                throw new UIAutomationException("cannot interact with object " + res
                                                    + ". There is an alert.", 26);
            }

        } else {
            // target and app aren't stale.
            if (!res) {
                throw new UIAutomationException("can't find " + reference + " in cache.");
                // window an apps aren't stale ?
            } else if (res.type && (res.type() == "UIAWindow" || res.type() == "UIAApplication")) {
                return res;
                // on arrays, stale doesn't make sense.
            } else if (checkStale && res.isStale && res.isStale()) {
                throw new UIAutomationException("elements ref:" + reference + " is stale", 10);
            } else {
                return res;
            }
        }

    };

    /**
     * Return the currently opened alert, and throws if no alert present.
     * @throws  UIAutomationException if there is no alert opened.
     * @return {UIAAlert} the currently opened alert.
     */
    this.getAlert = function () {
        return this.storage[3];
    };

    /**
     * set the current alert.
     * @param {UIAAlert} the alert to set.
     */
    this.setAlert = function (alert) {
        this.storage[3] = alert;
        log("found alert");
    };

    /**
     * remove the current alert.
     */
    this.clearAlert = function () {
        log("removed alert");
        this.storage[3] = null;
    }

    /**
     * empty the cache.
     */
    this.clear = function () {
        this.storage = {};
        this.storage[0] = UIATarget.localTarget().frontMostApp().mainWindow();
    };

    this.clear();

}<|endoftext|>


<commit_before>'use strict';

var m = require('mithril'); // exposes mithril methods, useful for redraw etc.
var $osf = require('js/osfHelpers');
var iconmap = require('js/iconmap');
var lodashFind = require('lodash.find');
var mHelpers = require('js/mithrilHelpers');
var Raven = require('raven-js');

var MAX_PAGES_ON_PAGINATOR = 7;
var MAX_PAGES_ON_PAGINATOR_SIDE = 5;

var withPagination = function(options) {
    return function PaginationWrapper(component) {
        /**
         * Wrapper around another controller to add pagination functionality.
         * options should include a buildUrl function to control how to create a new
         * URL for pagination, and a getNextItems function to handle requests
         */
        return {
            controller: function (ctrlOptions) {
                var self = this;

                self.paginators = m.prop([]);
                self.nextPage = m.prop('');
                self.prevPage = m.prop('');
                self.totalPages = m.prop(0);
                self.currentPage = m.prop(0);
                self.pageToGet = m.prop(0);

                ctrlOptions.updatePagination = function (result, url) {
                    self.nextPage(result.links.next);
                    self.prevPage(result.links.prev);
                    var params = $osf.urlParams(url);
                    var page = params.page || 1;
                    self.currentPage(parseInt(page));
                    self.totalPages(Math.ceil(result.meta.total / result.meta.per_page));
                };

                self.updatePagination = ctrlOptions.updatePagination;
                self.getNextItems = options.getNextItems;
                self.buildUrl = options.buildUrl;
                self.user = ctrlOptions.user._id;
                self.nodeType = ctrlOptions.nodeType;
                self.innerCtrl = new component.controller(ctrlOptions);
            },
            view: function (ctrl) {
                var i;
                ctrl.paginators([]);
                if (ctrl.totalPages() > 1) {
                    // previous page
                    ctrl.paginators().push({
                        url: function () {
                            return ctrl.prevPage();
                        },
                        text: '<'
                    });
                    // first page
                    ctrl.paginators().push({
                        text: 1,
                        url: function () {
                            ctrl.pageToGet(1);
                            if (ctrl.pageToGet() !== ctrl.currentPage()) {
                                return ctrl.buildUrl(ctrl.pageToGet(), ctrl.user, ctrl.nodeType);
                            }
                        }
                    });
                    // no ellipses
                    if (ctrl.totalPages() <= MAX_PAGES_ON_PAGINATOR) {
                        for (i = 2; i < ctrl.totalPages(); i++) {
                            ctrl.paginators().push({
                                text: i,
                                url: function () {
                                    ctrl.pageToGet(parseInt(this.text));
                                    if (ctrl.pageToGet() !== ctrl.currentPage()) {
                                        return ctrl.buildUrl(ctrl.pageToGet(), ctrl.user, ctrl.nodeType);
                                    }
                                }
                            });
                            /* jshint ignore:line */
                            // function defined inside loop
                        }
                    }
                    // one ellipse at the end
                    else if (ctrl.currentPage() < MAX_PAGES_ON_PAGINATOR_SIDE - 1) {
                        for (i = 2; i < MAX_PAGES_ON_PAGINATOR_SIDE; i++) {
                            ctrl.paginators().push({
                                text: i,
                                url: function () {
                                    ctrl.pageToGet(parseInt(this.text));
                                    if (ctrl.pageToGet() !== ctrl.currentPage()) {
                                        return ctrl.buildUrl(ctrl.pageToGet(), ctrl.user, ctrl.nodeType);
                                    }
                                }
                            });
                            /* jshint ignore:line */
                            // function defined inside loop
                        }
                        ctrl.paginators().push({
                            text: '...',
                            url: function () {
                            }
                        });
                    }
                    // one ellipse at the beginning
                    else if (ctrl.currentPage() > ctrl.totalPages() - MAX_PAGES_ON_PAGINATOR_SIDE + 2) {
                        ctrl.paginators().push({
                            text: '...',
                            url: function () {
                            }
                        });
                        for (i = ctrl.totalPages() - MAX_PAGES_ON_PAGINATOR_SIDE + 2; i <= ctrl.totalPages() - 1; i++) {
                            ctrl.paginators().push({
                                text: i,
                                url: function () {
                                    ctrl.pageToGet(parseInt(this.text));
                                    if (ctrl.pageToGet() !== ctrl.currentPage()) {
                                        return ctrl.buildUrl(ctrl.pageToGet(), ctrl.user, ctrl.nodeType);
                                    }
                                }
                            });
                            /* jshint ignore:line */
                            // function defined inside loop
                        }
                    }
                    // two ellipses
                    else {
                        ctrl.paginators().push({
                            text: '...',
                            url: function () {
                            }
                        });
                        for (i = parseInt(ctrl.currentPage()) - 1; i <= parseInt(ctrl.currentPage()) + 1; i++) {
                            ctrl.paginators().push({
                                text: i,
                                url: function () {
                                    ctrl.pageToGet(parseInt(this.text));
                                    if (ctrl.pageToGet() !== ctrl.currentPage()) {
                                        return ctrl.buildUrl(ctrl.pageToGet(), ctrl.user, ctrl.nodeType);
                                    }
                                }
                            });
                            /* jshint ignore:line */
                            // function defined inside loop
                        }
                        ctrl.paginators().push({
                            text: '...',
                            url: function () {
                            }
                        });
                    }
                    // last page
                    ctrl.paginators().push({
                        text: ctrl.totalPages(),
                        url: function () {
                            ctrl.pageToGet(ctrl.totalPages());
                            if (ctrl.pageToGet() !== ctrl.currentPage()) {
                                return ctrl.buildUrl(ctrl.pageToGet(), ctrl.user, ctrl.nodeType);
                            }
                        }
                    });
                    // next page
                    ctrl.paginators().push({
                        url: function () {
                            return ctrl.nextPage();
                        },
                        text: '>'
                    });
                }

                return m('.db-activity-nav.text-center', {style: 'margin-top: 5px; margin-bottom: -10px;'}, [
                    component.view.call(this, ctrl.innerCtrl),
                    ctrl.paginators() ? ctrl.paginators().map(function (page) {
                        return page.url() ? m('.btn.btn-sm.btn-link', {
                            onclick: function () {
                                ctrl.getNextItems(ctrl.innerCtrl, page.url(), ctrl.updatePagination);
                            }
                        }, page.text) : m('.btn.btn-sm.btn-link.disabled', {style: 'color: black'}, page.text);
                    }) : ''

                ]);
            }
        };
    };
};

module.exports = {
    withPagination: withPagination
};
<commit_msg>Only apply center-align to pagination in wrapper<commit_after>'use strict';

var m = require('mithril'); // exposes mithril methods, useful for redraw etc.
var $osf = require('js/osfHelpers');
var iconmap = require('js/iconmap');
var lodashFind = require('lodash.find');
var mHelpers = require('js/mithrilHelpers');
var Raven = require('raven-js');

var MAX_PAGES_ON_PAGINATOR = 7;
var MAX_PAGES_ON_PAGINATOR_SIDE = 5;

var withPagination = function(options) {
    return function PaginationWrapper(component) {
        /**
         * Wrapper around another controller to add pagination functionality.
         * options should include a buildUrl function to control how to create a new
         * URL for pagination, and a getNextItems function to handle requests
         */
        return {
            controller: function (ctrlOptions) {
                var self = this;

                self.paginators = m.prop([]);
                self.nextPage = m.prop('');
                self.prevPage = m.prop('');
                self.totalPages = m.prop(0);
                self.currentPage = m.prop(0);
                self.pageToGet = m.prop(0);

                ctrlOptions.updatePagination = function (result, url) {
                    self.nextPage(result.links.next);
                    self.prevPage(result.links.prev);
                    var params = $osf.urlParams(url);
                    var page = params.page || 1;
                    self.currentPage(parseInt(page));
                    self.totalPages(Math.ceil(result.meta.total / result.meta.per_page));
                };

                self.updatePagination = ctrlOptions.updatePagination;
                self.getNextItems = options.getNextItems;
                self.buildUrl = options.buildUrl;
                self.user = ctrlOptions.user._id;
                self.nodeType = ctrlOptions.nodeType;
                self.innerCtrl = new component.controller(ctrlOptions);
            },
            view: function (ctrl) {
                var i;
                ctrl.paginators([]);
                if (ctrl.totalPages() > 1) {
                    // previous page
                    ctrl.paginators().push({
                        url: function () {
                            return ctrl.prevPage();
                        },
                        text: '<'
                    });
                    // first page
                    ctrl.paginators().push({
                        text: 1,
                        url: function () {
                            ctrl.pageToGet(1);
                            if (ctrl.pageToGet() !== ctrl.currentPage()) {
                                return ctrl.buildUrl(ctrl.pageToGet(), ctrl.user, ctrl.nodeType);
                            }
                        }
                    });
                    // no ellipses
                    if (ctrl.totalPages() <= MAX_PAGES_ON_PAGINATOR) {
                        for (i = 2; i < ctrl.totalPages(); i++) {
                            ctrl.paginators().push({
                                text: i,
                                url: function () {
                                    ctrl.pageToGet(parseInt(this.text));
                                    if (ctrl.pageToGet() !== ctrl.currentPage()) {
                                        return ctrl.buildUrl(ctrl.pageToGet(), ctrl.user, ctrl.nodeType);
                                    }
                                }
                            });
                            /* jshint ignore:line */
                            // function defined inside loop
                        }
                    }
                    // one ellipse at the end
                    else if (ctrl.currentPage() < MAX_PAGES_ON_PAGINATOR_SIDE - 1) {
                        for (i = 2; i < MAX_PAGES_ON_PAGINATOR_SIDE; i++) {
                            ctrl.paginators().push({
                                text: i,
                                url: function () {
                                    ctrl.pageToGet(parseInt(this.text));
                                    if (ctrl.pageToGet() !== ctrl.currentPage()) {
                                        return ctrl.buildUrl(ctrl.pageToGet(), ctrl.user, ctrl.nodeType);
                                    }
                                }
                            });
                            /* jshint ignore:line */
                            // function defined inside loop
                        }
                        ctrl.paginators().push({
                            text: '...',
                            url: function () {
                            }
                        });
                    }
                    // one ellipse at the beginning
                    else if (ctrl.currentPage() > ctrl.totalPages() - MAX_PAGES_ON_PAGINATOR_SIDE + 2) {
                        ctrl.paginators().push({
                            text: '...',
                            url: function () {
                            }
                        });
                        for (i = ctrl.totalPages() - MAX_PAGES_ON_PAGINATOR_SIDE + 2; i <= ctrl.totalPages() - 1; i++) {
                            ctrl.paginators().push({
                                text: i,
                                url: function () {
                                    ctrl.pageToGet(parseInt(this.text));
                                    if (ctrl.pageToGet() !== ctrl.currentPage()) {
                                        return ctrl.buildUrl(ctrl.pageToGet(), ctrl.user, ctrl.nodeType);
                                    }
                                }
                            });
                            /* jshint ignore:line */
                            // function defined inside loop
                        }
                    }
                    // two ellipses
                    else {
                        ctrl.paginators().push({
                            text: '...',
                            url: function () {
                            }
                        });
                        for (i = parseInt(ctrl.currentPage()) - 1; i <= parseInt(ctrl.currentPage()) + 1; i++) {
                            ctrl.paginators().push({
                                text: i,
                                url: function () {
                                    ctrl.pageToGet(parseInt(this.text));
                                    if (ctrl.pageToGet() !== ctrl.currentPage()) {
                                        return ctrl.buildUrl(ctrl.pageToGet(), ctrl.user, ctrl.nodeType);
                                    }
                                }
                            });
                            /* jshint ignore:line */
                            // function defined inside loop
                        }
                        ctrl.paginators().push({
                            text: '...',
                            url: function () {
                            }
                        });
                    }
                    // last page
                    ctrl.paginators().push({
                        text: ctrl.totalPages(),
                        url: function () {
                            ctrl.pageToGet(ctrl.totalPages());
                            if (ctrl.pageToGet() !== ctrl.currentPage()) {
                                return ctrl.buildUrl(ctrl.pageToGet(), ctrl.user, ctrl.nodeType);
                            }
                        }
                    });
                    // next page
                    ctrl.paginators().push({
                        url: function () {
                            return ctrl.nextPage();
                        },
                        text: '>'
                    });
                }

                return m('span', [
                    component.view.call(this, ctrl.innerCtrl),
                    m('.db-activity-nav.text-center', {style: 'margin-top: 5px; margin-bottom: -10px;'}, [
                        ctrl.paginators() ? ctrl.paginators().map(function (page) {
                            return page.url() ? m('.btn.btn-sm.btn-link', {
                                onclick: function () {
                                    ctrl.getNextItems(ctrl.innerCtrl, page.url(), ctrl.updatePagination);
                                }
                            }, page.text) : m('.btn.btn-sm.btn-link.disabled', {style: 'color: black'}, page.text);
                        }) : ''
                    ])
                ]);
            }
        };
    };
};

module.exports = {
    withPagination: withPagination
};
<|endoftext|>


<commit_before>'use strict';
var $ = require('jquery');
var ko = require('knockout');
var bootbox = require('bootbox');
var $osf = require('js/osfHelpers');
var jedit = require('json-editor');

var MetaData = require('../metadata_1.js');
var ctx = window.contextVars;
/**
    * Unblock UI and display error modal
    */
function registration_failed() {
    $osf.unblock();
    bootbox.alert('Registration failed');
}

function registerNode(data) {

    // Block UI until request completes
    $osf.block();

    // POST data
    $.ajax({
        url:  ctx.node.urls.api + 'register/' + ctx.regTemplate + '/',
        type: 'POST',
        data: JSON.stringify(data),
        contentType: 'application/json',
        dataType: 'json'
    }).done(function(response) {
        if (response.status === 'success') {
            window.location.href = response.result;
        }
        else if (response.status === 'error') {
            registration_failed();
        }
    }).fail(function() {
        registration_failed();
    });

    // Stop event propagation
    return false;

}

$(document).ready(function() {

    // Don't submit form on enter; must use $.delegate rather than $.on
    // to catch dynamically created form elements
    $('#registration_template').delegate('input, select', 'keypress', function(event) {
        return event.keyCode !== 13;
    });

    var registrationViewModel = new MetaData.ViewModel(
        ctx.regSchema,
        ctx.registered,
        [ctx.node.id].concat(ctx.node.children)
    );
    // Apply view model
    ko.applyBindings(registrationViewModel, $('#registration_template')[0]);
    registrationViewModel.updateIdx('add', true);

    if (ctx.registered) {
        registrationViewModel.unserialize(ctx.regPayload);
    }

    $('#registration_template form').on('submit', function() {

        // Serialize responses
        var serialized = registrationViewModel.serialize(),
            data = serialized.data,
            complete = serialized.complete;

        // Clear continue text and stop if incomplete
        if (!complete) {
            registrationViewModel.continueText('');
            return false;
        }

        $.ajax({
            url: ctx.node.urls.api + 'beforeregister/',
            contentType: 'application/json',
            success: function(response) {
                if (response.prompts && response.prompts.length) {
                    bootbox.confirm(
                        $osf.joinPrompts(response.prompts, 'Are you sure you want to register this project?'),
                        function(result) {
                            if (result) {
                                registerNode(data);
                            }
                        }
                    );
                } else {
                    registerNode(data);
                }
            }
        });

        return false;

    });
});
<commit_msg>reverted orginal register_1-page.js to original since not being used<commit_after>'use strict';
var $ = require('jquery');
var ko = require('knockout');
var bootbox = require('bootbox');
var $osf = require('js/osfHelpers');

var MetaData = require('../metadata_1.js');
var ctx = window.contextVars;
/**
    * Unblock UI and display error modal
    */
function registration_failed() {
    $osf.unblock();
    bootbox.alert('Registration failed');
}

function registerNode(data) {

    // Block UI until request completes
    $osf.block();

    // POST data
    $.ajax({
        url:  ctx.node.urls.api + 'register/' + ctx.regTemplate + '/',
        type: 'POST',
        data: JSON.stringify(data),
        contentType: 'application/json',
        dataType: 'json'
    }).done(function(response) {
        if (response.status === 'success') {
            window.location.href = response.result;
        }
        else if (response.status === 'error') {
            registration_failed();
        }
    }).fail(function() {
        registration_failed();
    });

    // Stop event propagation
    return false;

}

$(document).ready(function() {

    // Don't submit form on enter; must use $.delegate rather than $.on
    // to catch dynamically created form elements
    $('#registration_template').delegate('input, select', 'keypress', function(event) {
        return event.keyCode !== 13;
    });

    var registrationViewModel = new MetaData.ViewModel(
        ctx.regSchema,
        ctx.registered,
        [ctx.node.id].concat(ctx.node.children)
    );
    // Apply view model
    ko.applyBindings(registrationViewModel, $('#registration_template')[0]);
    registrationViewModel.updateIdx('add', true);

    if (ctx.registered) {
        registrationViewModel.unserialize(ctx.regPayload);
    }

    $('#registration_template form').on('submit', function() {

        // Serialize responses
        var serialized = registrationViewModel.serialize(),
            data = serialized.data,
            complete = serialized.complete;

        // Clear continue text and stop if incomplete
        if (!complete) {
            registrationViewModel.continueText('');
            return false;
        }

        $.ajax({
            url: ctx.node.urls.api + 'beforeregister/',
            contentType: 'application/json',
            success: function(response) {
                if (response.prompts && response.prompts.length) {
                    bootbox.confirm(
                        $osf.joinPrompts(response.prompts, 'Are you sure you want to register this project?'),
                        function(result) {
                            if (result) {
                                registerNode(data);
                            }
                        }
                    );
                } else {
                    registerNode(data);
                }
            }
        });

        return false;

    });
});
<|endoftext|>


<commit_before>'use strict';

var $ = require('jquery');
var bootbox = require('bootbox');
var m = require('mithril');
var Treebeard = require('treebeard');
var $osf = require('js/osfHelpers');
var Fangorn = require('js/fangorn');
require('../css/fangorn.css');

// TODO: Move 'resolveToggle' to a central location
function resolveToggle(item) {
    var toggleMinus = m('i.fa.fa-minus', ' '),
        togglePlus = m('i.fa.fa-plus', ' ');

    if (item.children.length > 0) {
        if (item.open) {
            return toggleMinus;
        }
        return togglePlus;
    }
    item.open = true;
    return '';
}

function expandOnLoad() {
    var tb = this;  // jshint ignore: line
    for (var i = 0; i < tb.treeData.children.length; i++) {
        var parent = tb.treeData.children[i];
        tb.updateFolder(null, parent);
    }
}

function beforeChangePermissions(item, permission){
    var title = item.parent().data.node.title;
    if(permission === 'public'){
        bootbox.dialog({
            title: 'Make publicly editable',
            message: 'Are you sure you want to make the wiki of ' +title+
                ' publicly editable? This will allow any logged in user to edit the content of this wiki. ' +
                'Note: Users without write access will not be able to add, delete, or rename pages.',
            buttons: {
                cancel : {
                    label : 'Cancel',
                    className : 'btn-default',
                    callback : function() {item.notify.update('', 'notify-primary', 1, 10);}
                },
                success: {
                    label: 'Apply',
                    className: 'btn-primary',
                    callback: function() {changePermissions(item, permission);}
                }
            }
        });
    }
    else {
        changePermissions(item, permission);
    }
}

function changePermissions(item, permission) {
    var id = item.parent().data.node.id;

    return $osf.putJSON(
        buildPermissionsURL(item), {'permission': permission}
    ).done(function(){
        item.notify.update('Settings updated', 'notify-success', 1, 2000);
        item.data.select.permission = permission;
    }).fail(function() {
        item.notify.update('Could not update settings', 'notify-danger', 1, 2000);
    });
}

// Helper to build path
function buildPermissionsURL(item) {
    var id = item.parent().data.node.id;
    var permissionsChangePath = '/api/v1/project/'+ id +
        '/wiki/settings/';
    return permissionsChangePath;
}

function ProjectWiki(data) {

    //  Treebeard version
    var tbOptions = {
        divID: 'wgrid',
        filesData: data,
        rowHeight : 33,         // user can override or get from .tb-row height
        resolveToggle: resolveToggle,
        paginate : false,       // Whether the applet starts with pagination or not.
        paginateToggle : false, // Show the buttons that allow users to switch between scroll and paginate.
        uploads : false,         // Turns dropzone on/off.
        resolveIcon : Fangorn.Utils.resolveIconView,
        hideColumnTitles: true,
        columnTitles : function wikiColumnTitles(item, col) {
            return [
                {
                    title: 'Project',
                    width: '60%',
                    sortType : 'text',
                    sort : false
                },
                {
                    title: 'Editing Toggle',
                    width : '40%',
                    sort : false

                }
            ];
        },
        ontogglefolder : function (item){
            var containerHeight = this.select('#tb-tbody').height();
            this.options.showTotal = Math.floor(containerHeight / this.options.rowHeight) + 1;
            this.redraw();
        },
        resolveRows : function wikiResolveRows(item){
            var columns = [];
            var iconcss = '';
            // check if should not get icon
            if(item.children.length < 1 ){
                iconcss = 'tb-no-icon';
            }
            if (item.data.kind === 'heading') {
                if (item.data.children.length === 0) {
                    columns.push({
                        data : 'project',  // Data field name
                        folderIcons : false,
                        filter : true,
                        sortInclude : false,
                        custom : function() {
                            return m('div[style="padding-left:5px"]',
                                        [m ('p', [
                                                m('b', item.data.node.title + ': '),
                                                m('span[class="text-warning"]', ' No configured projects')]
                                        )]
                            );
                        }
                    });
                } else {
                    columns.push({
                        data : 'project',  // Data field name
                        folderIcons : false,
                        filter : true,
                        sortInclude : false,
                        custom : function() {
                            return m('div[style="padding-left:5px"]',
                                    [m('p',
                                        [m('b', item.data.node.title + ':')]
                                )]
                            );
                        }
                    });
                }
            }
            else if (item.data.kind === 'folder' || item.data.kind === 'node') {
                columns.push({
                    data : 'project',  // Data field name
                    folderIcons : true,
                    filter : true,
                    sortInclude : false,
                    custom : function() {
                        if (item.data.node.url !== '') {
                            return m('a', { href : item.data.node.url, target : '_blank' }, item.data.node.title);
                        } else {
                            return m('span', item.data.node.title);
                        }

                    }
                });
            }

            else {
                columns.push(
                {
                    data : 'project',  // Data field name
                    folderIcons : true,
                    filter : true,
                    css : iconcss,
                    sortInclude : false,
                    custom : function() {
                        return 'Who can edit';

                    }
                },
                {
                    data : 'permission',  // Data field name
                    folderIcons : false,
                    filter : false,
                    custom : function() {
                        return  m('div[style="padding-right:10px"]',
                            [m('select.form-control', {
                                onchange: function(ev) {
                                    beforeChangePermissions(item, ev.target.value);
                                }},
                                [
                                    m('option', {value: 'private', selected : item.data.select.permission === 'public' ? 'selected': ''}, 'Contributors (with write access)'),
                                    m('option', {value: 'public', selected : item.data.select.permission === 'public' ? 'selected': '' }, 'All OSF users')
                            ])
                        ]);
                    }
                });
            }

            return columns;
        },
        sortButtonSelector : {
            up : 'i.fa.fa-chevron-up',
            down : 'i.fa.fa-chevron-down'
        },
        showFilter : false,     // Gives the option to filter by showing the filter box.
        allowMove : false,       // Turn moving on or off.
        hoverClass : 'fangorn-hover',
        resolveRefreshIcon : function() {
          return m('i.fa.fa-refresh.fa-spin');
        }
    };
    var wgrid = new Treebeard(tbOptions);
    expandOnLoad.call(wgrid.tbController);
}

module.exports = ProjectWiki;
<commit_msg>Remove irrelevant copied notifications code<commit_after>'use strict';

var $ = require('jquery');
var bootbox = require('bootbox');
var m = require('mithril');
var Treebeard = require('treebeard');
var $osf = require('js/osfHelpers');
var Fangorn = require('js/fangorn');
require('../css/fangorn.css');

// TODO: Move 'resolveToggle' to a central location
function resolveToggle(item) {
    var toggleMinus = m('i.fa.fa-minus', ' '),
        togglePlus = m('i.fa.fa-plus', ' ');

    if (item.children.length > 0) {
        if (item.open) {
            return toggleMinus;
        }
        return togglePlus;
    }
    item.open = true;
    return '';
}

function expandOnLoad() {
    var tb = this;  // jshint ignore: line
    for (var i = 0; i < tb.treeData.children.length; i++) {
        var parent = tb.treeData.children[i];
        tb.updateFolder(null, parent);
    }
}

function beforeChangePermissions(item, permission){
    var title = item.parent().data.node.title;
    if(permission === 'public'){
        bootbox.dialog({
            title: 'Make publicly editable',
            message: 'Are you sure you want to make the wiki of ' +title+
                ' publicly editable? This will allow any logged in user to edit the content of this wiki. ' +
                'Note: Users without write access will not be able to add, delete, or rename pages.',
            buttons: {
                cancel : {
                    label : 'Cancel',
                    className : 'btn-default',
                    callback : function() {item.notify.update('', 'notify-primary', 1, 10);}
                },
                success: {
                    label: 'Apply',
                    className: 'btn-primary',
                    callback: function() {changePermissions(item, permission);}
                }
            }
        });
    }
    else {
        changePermissions(item, permission);
    }
}

function changePermissions(item, permission) {
    var id = item.parent().data.node.id;

    return $osf.putJSON(
        buildPermissionsURL(item), {'permission': permission}
    ).done(function(){
        item.notify.update('Settings updated', 'notify-success', 1, 2000);
        item.data.select.permission = permission;
    }).fail(function() {
        item.notify.update('Could not update settings', 'notify-danger', 1, 2000);
    });
}

// Helper to build path
function buildPermissionsURL(item) {
    var id = item.parent().data.node.id;
    var permissionsChangePath = '/api/v1/project/'+ id +
        '/wiki/settings/';
    return permissionsChangePath;
}

function ProjectWiki(data) {

    //  Treebeard version
    var tbOptions = {
        divID: 'wgrid',
        filesData: data,
        rowHeight : 33,         // user can override or get from .tb-row height
        resolveToggle: resolveToggle,
        paginate : false,       // Whether the applet starts with pagination or not.
        paginateToggle : false, // Show the buttons that allow users to switch between scroll and paginate.
        uploads : false,         // Turns dropzone on/off.
        resolveIcon : Fangorn.Utils.resolveIconView,
        hideColumnTitles: true,
        columnTitles : function wikiColumnTitles(item, col) {
            return [
                {
                    title: 'Project',
                    width: '60%',
                    sortType : 'text',
                    sort : false
                },
                {
                    title: 'Editing Toggle',
                    width : '40%',
                    sort : false

                }
            ];
        },
        ontogglefolder : function (item){
            var containerHeight = this.select('#tb-tbody').height();
            this.options.showTotal = Math.floor(containerHeight / this.options.rowHeight) + 1;
            this.redraw();
        },
        resolveRows : function wikiResolveRows(item){
            var columns = [];
            var iconcss = '';
            // check if should not get icon
            if(item.children.length < 1 ){
                iconcss = 'tb-no-icon';
            }
            if (item.data.kind === 'folder' || item.data.kind === 'node') {
                columns.push({
                    data : 'project',  // Data field name
                    folderIcons : true,
                    filter : true,
                    sortInclude : false,
                    custom : function() {
                        if (item.data.node.url !== '') {
                            return m('a', { href : item.data.node.url, target : '_blank' }, item.data.node.title);
                        } else {
                            return m('span', item.data.node.title);
                        }

                    }
                });
            }

            else {
                columns.push(
                {
                    data : 'project',  // Data field name
                    folderIcons : true,
                    filter : true,
                    css : iconcss,
                    sortInclude : false,
                    custom : function() {
                        return 'Who can edit';

                    }
                },
                {
                    data : 'permission',  // Data field name
                    folderIcons : false,
                    filter : false,
                    custom : function() {
                        return  m('div[style="padding-right:10px"]',
                            [m('select.form-control', {
                                onchange: function(ev) {
                                    beforeChangePermissions(item, ev.target.value);
                                }},
                                [
                                    m('option', {value: 'private', selected : item.data.select.permission === 'public' ? 'selected': ''}, 'Contributors (with write access)'),
                                    m('option', {value: 'public', selected : item.data.select.permission === 'public' ? 'selected': '' }, 'All OSF users')
                            ])
                        ]);
                    }
                });
            }

            return columns;
        },
        sortButtonSelector : {
            up : 'i.fa.fa-chevron-up',
            down : 'i.fa.fa-chevron-down'
        },
        showFilter : false,     // Gives the option to filter by showing the filter box.
        allowMove : false,       // Turn moving on or off.
        hoverClass : 'fangorn-hover',
        resolveRefreshIcon : function() {
          return m('i.fa.fa-refresh.fa-spin');
        }
    };
    var wgrid = new Treebeard(tbOptions);
    expandOnLoad.call(wgrid.tbController);
}

module.exports = ProjectWiki;
<|endoftext|>