<commit_before>/**
enyo.TouchScrollStrategy is a helper kind that implments a touch based scroller that integrates the scrolling simulation provided
by enyo.ScrollMath into an enyo.Scroller.

enyo.TouchScrollStrategy is not typically created in application code.
*/
enyo.kind({
	name: "enyo.TouchScrollStrategy",
	kind: "ScrollStrategy",
	/**
		If true, the scroller will not propagate dragstart events that cause it to start scrolling (defaults to true)
	*/
	preventDragPropagation: true,
	published: {
		/**
			Specifies how to horizontally scroll. Acceptable values are:

			* "scroll": Always scrolls.
			* "auto":  Scroll only if the content overflows the scroller.
			* "hidden": Never scroll.
			* "default": In touch environments, the default vertical scrolling behavior is to always scroll. If the content does not
			overflow the scroller, the scroller will overscroll and snap back.
		*/
		vertical: "default",
		/**
			Specifies how to vertically scroll. Acceptable values are:

			* "scroll": Always scrolls.
			* "auto":  Scroll only if the content overflows the scroller.
			* "hidden": Never scroll.
			* "default": Same as auto.
		*/
		horizontal: "default",
		//* set to true to display a scroll thumb
		thumb: true,
		//* set to true to display a transparent overlay while scrolling; can help improve performance of complex, large scroll regions
		//* on some platforms, notably Android.
		scrim: false
	},
	events: {
		onShouldDrag: ""
	},
	//* @protected
	handlers: {
		onscroll: "domScroll",
		onflick: "flick",
		onhold: "hold",
		ondragstart: "dragstart",
		onShouldDrag: "shouldDrag",
		ondrag: "drag",
		ondragfinish: "dragfinish",
		onmousewheel: "mousewheel"
	},
	tools: [
		{kind: "ScrollMath", onScrollStart: "scrollMathStart", onScroll: "scrollMathScroll", onScrollStop: "scrollMathStop"},
		{name: "vthumb", kind: "ScrollThumb", axis: "v", showing: false},
		{name: "hthumb", kind: "ScrollThumb", axis: "h", showing: false}
	],
	scrimTools: [{name: "scrim", classes: "enyo-fit", style: "z-index: 1;", showing: false}],
	components: [
		{name: "client", attributes: {"onscroll": enyo.bubbler}, classes: "enyo-touch-scroller"}
	],
	create: function() {
		this.inherited(arguments);
		this.accel = enyo.dom.canAccelerate();
		var containerClasses = "enyo-touch-strategy-container";
		// note: needed for ios to avoid incorrect clipping of thumb
		// and need to avoid on Android as it causes problems hiding the thumb
		if (enyo.platform.ios && this.accel) {
			containerClasses += " enyo-composite";
		}
		this.scrimChanged();
		this.container.addClass(containerClasses);
		this.translation = this.accel ? "translate3d" : "translate";
	},
	initComponents: function() {
		this.createChrome(this.tools);
		this.inherited(arguments);
	},
	destroy: function() {
		this.container.removeClass("enyo-touch-strategy-container");
		this.inherited(arguments);
	},
	rendered: function() {
		this.inherited(arguments);
		this.calcBoundaries();
		this.syncScrollMath();
		if (this.thumb) {
			this.alertThumbs();
		}
	},
	scrimChanged: function() {
		if (this.scrim && !this.$.scrim) {
			this.makeScrim();
		}
		if (!this.scrim && this.$.scrim) {
			this.$.scrim.destroy();
		}
	},
	makeScrim: function() {
		// reset control parent so scrim doesn't go into client.
		var cp = this.controlParent;
		this.controlParent = null;
		this.createChrome(this.scrimTools);
		this.controlParent = cp;
		var cn = this.container.hasNode();
		// render scrim in container, strategy has no dom.
		if (cn) {
			this.$.scrim.parentNode = cn;
			this.$.scrim.render();
		}
	},
	isScrolling: function() {
		return this.$.scrollMath.isScrolling();
	},
	isOverscrolling: function() {
		return this.$.scrollMath.isInOverScroll();
	},
	domScroll: function() {
		if (!this.isScrolling()) {
			this.calcBoundaries();
			this.syncScrollMath();
			if (this.thumb) {
				this.alertThumbs();
			}
		}
	},
	horizontalChanged: function() {
		this.$.scrollMath.horizontal = (this.horizontal != "hidden");
	},
	verticalChanged: function() {
		this.$.scrollMath.vertical = (this.vertical != "hidden");
	},
	maxHeightChanged: function() {
		this.$.client.applyStyle("max-height", this.maxHeight);
		// note: previously used enyo-fit here but IE would reset scroll position when the scroll thumb
		// was hidden; in general IE resets scrollTop when there are 2 abs position siblings, one has
		// scrollTop and the other is hidden.
		this.$.client.addRemoveClass("enyo-scrollee-fit", !this.maxHeight);
	},
	thumbChanged: function() {
		this.hideThumbs();
	},
	stop: function() {
		if (this.isScrolling()) {
			this.$.scrollMath.stop(true);
		}
	},
	scrollTo: function(inX, inY) {
		this.stop();
		this.$.scrollMath.scrollTo(inY || inY === 0 ? inY : null, inX);
	},
	scrollIntoView: function() {
		this.stop();
		this.inherited(arguments);
	},
	setScrollLeft: function() {
		this.stop();
		this.inherited(arguments);
	},
	setScrollTop: function() {
		this.stop();
		this.inherited(arguments);
	},
	getScrollLeft: function() {
		return this.isScrolling() ? this.scrollLeft : this.inherited(arguments);
	},
	getScrollTop: function() {
		return this.isScrolling() ? this.scrollTop : this.inherited(arguments);
	},
	calcScrollNode: function() {
		return this.$.client.hasNode();
	},
	calcAutoScrolling: function() {
		var v = (this.vertical == "auto");
		var h = (this.horizontal == "auto") || (this.horizontal == "default");
		if ((v || h) && this.scrollNode) {
			var b = this.getScrollBounds();
			if (v) {
				this.$.scrollMath.vertical = b.height > b.clientHeight;
			}
			if (h) {
				this.$.scrollMath.horizontal = b.width > b.clientWidth;
			}
		}
	},
	shouldDrag: function(inSender, e) {
		this.calcAutoScrolling();
		var requestV = e.vertical;
		var canH = this.$.scrollMath.horizontal && !requestV;
		var canV = this.$.scrollMath.vertical && requestV;
		var down = e.dy < 0, right = e.dx < 0;
		var oobV = (!down && this.startEdges.top || down && this.startEdges.bottom);
		var oobH = (!right && this.startEdges.left || right && this.startEdges.right);
		// we would scroll if not at a boundary
		if (!e.boundaryDragger && (canH || canV)) {
			e.boundaryDragger = this;
		}
		// include boundary exclusion
		if ((!oobV && canV) || (!oobH && canH)) {
			e.dragger = this;
			return true;
		}
	},
	flick: function(inSender, e) {
		var onAxis = Math.abs(e.xVelocity) > Math.abs(e.yVelocity) ? this.$.scrollMath.horizontal : this.$.scrollMath.vertical;
		if (onAxis && this.dragging) {
			this.$.scrollMath.flick(e);
			return this.preventDragPropagation;
		}
	},
	hold: function(inSender, e) {
		if (this.isScrolling() && !this.isOverscrolling()) {
			this.$.scrollMath.stop(e);
			return true;
		}
	},
	// special synthetic DOM events served up by the Gesture system
	dragstart: function(inSender, inEvent) {
		// note: allow drags to propagate to parent scrollers via data returned in the shouldDrag event.
		this.doShouldDrag(inEvent);
		this.dragging = (inEvent.dragger == this || (!inEvent.dragger && inEvent.boundaryDragger == this));
		if (this.dragging) {
			inEvent.preventDefault();
			// note: needed because show/hide changes
			// the position so sync'ing is required when
			// dragging begins (needed because show/hide does not trigger onscroll)
			this.syncScrollMath();
			this.$.scrollMath.startDrag(inEvent);
			if (this.preventDragPropagation) {
				return true;
			}
		}
	},
	drag: function(inSender, inEvent) {
		if (this.dragging) {
			inEvent.preventDefault();
			this.$.scrollMath.drag(inEvent);
			if (this.scrim) {
				this.$.scrim.show();
			}
		}
	},
	dragfinish: function(inSender, inEvent) {
		if (this.dragging) {
			inEvent.preventTap();
			this.$.scrollMath.dragFinish();
			this.dragging = false;
			if (this.scrim) {
				this.$.scrim.hide();
			}
		}
	},
	mousewheel: function(inSender, e) {
		if (!this.dragging && this.$.scrollMath.mousewheel(e)) {
			e.preventDefault();
			return true;
		}
	},
	scrollMathStart: function(inSender) {
		if (this.scrollNode) {
			this.calcBoundaries();
			if (this.thumb) {
				this.showThumbs();
			}
		}
	},
	scrollMathScroll: function(inSender) {
		this.effectScroll(-inSender.x, -inSender.y);
		if (this.thumb) {
			this.updateThumbs();
		}
	},
	scrollMathStop: function(inSender) {
		this.effectScrollStop();
		if (this.thumb) {
			this.delayHideThumbs(100);
		}
	},
	calcBoundaries: function() {
		var s = this.$.scrollMath, b = this._getScrollBounds();
		s.bottomBoundary = b.clientHeight - b.height;
		s.rightBoundary = b.clientWidth - b.width;
	},
	syncScrollMath: function() {
		var m = this.$.scrollMath;
		m.setScrollX(-this.getScrollLeft());
		m.setScrollY(-this.getScrollTop());
	},
	effectScroll: function(inX, inY) {
		if (this.scrollNode) {
			this.scrollLeft = this.scrollNode.scrollLeft = inX;
			this.scrollTop = this.scrollNode.scrollTop = inY;
			this.effectOverscroll(Math.round(inX), Math.round(inY));
		}
	},
	effectScrollStop: function() {
		this.effectOverscroll(null, null);
	},
	effectOverscroll: function(inX, inY) {
		var n = this.scrollNode;
		var x = "0,", y = "0", z = this.accel ? ",0" : "";
		if (inY !== null && Math.abs(inY - n.scrollTop) > 1) {
			y = (n.scrollTop - inY) + "px";
		}
		if (inX !== null && Math.abs(inX - n.scrollLeft) > 1) {
			x = (n.scrollLeft - inX) + "px,";
		}
		enyo.dom.transformValue(this.$.client, this.translation, x + y + z);
	},
	getOverScrollBounds: function() {
		var m = this.$.scrollMath;
		return {
			overleft: Math.min(m.leftBoundary - m.x, 0) || Math.max(m.rightBoundary - m.x, 0),
			overtop: Math.min(m.topBoundary - m.y, 0) || Math.max(m.bottomBoundary - m.y, 0)
		};
	},
	_getScrollBounds: function() {
		var r = this.inherited(arguments);
		enyo.mixin(r, this.getOverScrollBounds());
		return r;
	},
	getScrollBounds: function() {
		this.stop();
		return this.inherited(arguments);
	},
	// thumb processing
	alertThumbs: function() {
		this.showThumbs();
		this.delayHideThumbs(500);
	},
	syncThumbs: function() {
		this.$.vthumb.sync(this);
		this.$.hthumb.sync(this);
	},
	updateThumbs: function() {
		this.$.vthumb.update(this);
		this.$.hthumb.update(this);
	},
	showThumbs: function() {
		this.syncThumbs();
		this.$.vthumb.show();
		this.$.hthumb.show();
	},
	hideThumbs: function() {
		this.$.vthumb.hide();
		this.$.hthumb.hide();
	},
	delayHideThumbs: function(inDelay) {
		this.$.vthumb.delayHide(inDelay);
		this.$.hthumb.delayHide(inDelay);
	}
});
<commit_msg>* TouchScrollStrategy: override default move event handling. No need to disable prevention.<commit_after>/**
enyo.TouchScrollStrategy is a helper kind that implments a touch based scroller that integrates the scrolling simulation provided
by enyo.ScrollMath into an enyo.Scroller.

enyo.TouchScrollStrategy is not typically created in application code.
*/
enyo.kind({
	name: "enyo.TouchScrollStrategy",
	kind: "ScrollStrategy",
	/**
		If true, the scroller will not propagate dragstart events that cause it to start scrolling (defaults to true)
	*/
	preventDragPropagation: true,
	published: {
		/**
			Specifies how to horizontally scroll. Acceptable values are:

			* "scroll": Always scrolls.
			* "auto":  Scroll only if the content overflows the scroller.
			* "hidden": Never scroll.
			* "default": In touch environments, the default vertical scrolling behavior is to always scroll. If the content does not
			overflow the scroller, the scroller will overscroll and snap back.
		*/
		vertical: "default",
		/**
			Specifies how to vertically scroll. Acceptable values are:

			* "scroll": Always scrolls.
			* "auto":  Scroll only if the content overflows the scroller.
			* "hidden": Never scroll.
			* "default": Same as auto.
		*/
		horizontal: "default",
		//* set to true to display a scroll thumb
		thumb: true,
		//* set to true to display a transparent overlay while scrolling; can help improve performance of complex, large scroll regions
		//* on some platforms, notably Android.
		scrim: false
	},
	events: {
		onShouldDrag: ""
	},
	//* @protected
	handlers: {
		onscroll: "domScroll",
		onflick: "flick",
		onhold: "hold",
		ondragstart: "dragstart",
		onShouldDrag: "shouldDrag",
		ondrag: "drag",
		ondragfinish: "dragfinish",
		onmousewheel: "mousewheel"
	},
	tools: [
		{kind: "ScrollMath", onScrollStart: "scrollMathStart", onScroll: "scrollMathScroll", onScrollStop: "scrollMathStop"},
		{name: "vthumb", kind: "ScrollThumb", axis: "v", showing: false},
		{name: "hthumb", kind: "ScrollThumb", axis: "h", showing: false}
	],
	scrimTools: [{name: "scrim", classes: "enyo-fit", style: "z-index: 1;", showing: false}],
	components: [
		{name: "client", attributes: {"onscroll": enyo.bubbler}, classes: "enyo-touch-scroller"}
	],
	create: function() {
		this.inherited(arguments);
		this.accel = enyo.dom.canAccelerate();
		var containerClasses = "enyo-touch-strategy-container";
		// note: needed for ios to avoid incorrect clipping of thumb
		// and need to avoid on Android as it causes problems hiding the thumb
		if (enyo.platform.ios && this.accel) {
			containerClasses += " enyo-composite";
		}
		this.scrimChanged();
		this.container.addClass(containerClasses);
		this.translation = this.accel ? "translate3d" : "translate";
	},
	initComponents: function() {
		this.createChrome(this.tools);
		this.inherited(arguments);
	},
	destroy: function() {
		this.container.removeClass("enyo-touch-strategy-container");
		this.inherited(arguments);
	},
	rendered: function() {
		this.inherited(arguments);
		this.calcBoundaries();
		this.syncScrollMath();
		if (this.thumb) {
			this.alertThumbs();
		}
	},
	scrimChanged: function() {
		if (this.scrim && !this.$.scrim) {
			this.makeScrim();
		}
		if (!this.scrim && this.$.scrim) {
			this.$.scrim.destroy();
		}
	},
	makeScrim: function() {
		// reset control parent so scrim doesn't go into client.
		var cp = this.controlParent;
		this.controlParent = null;
		this.createChrome(this.scrimTools);
		this.controlParent = cp;
		var cn = this.container.hasNode();
		// render scrim in container, strategy has no dom.
		if (cn) {
			this.$.scrim.parentNode = cn;
			this.$.scrim.render();
		}
	},
	isScrolling: function() {
		return this.$.scrollMath.isScrolling();
	},
	isOverscrolling: function() {
		return this.$.scrollMath.isInOverScroll();
	},
	domScroll: function() {
		if (!this.isScrolling()) {
			this.calcBoundaries();
			this.syncScrollMath();
			if (this.thumb) {
				this.alertThumbs();
			}
		}
	},
	horizontalChanged: function() {
		this.$.scrollMath.horizontal = (this.horizontal != "hidden");
	},
	verticalChanged: function() {
		this.$.scrollMath.vertical = (this.vertical != "hidden");
	},
	maxHeightChanged: function() {
		this.$.client.applyStyle("max-height", this.maxHeight);
		// note: previously used enyo-fit here but IE would reset scroll position when the scroll thumb
		// was hidden; in general IE resets scrollTop when there are 2 abs position siblings, one has
		// scrollTop and the other is hidden.
		this.$.client.addRemoveClass("enyo-scrollee-fit", !this.maxHeight);
	},
	thumbChanged: function() {
		this.hideThumbs();
	},
	stop: function() {
		if (this.isScrolling()) {
			this.$.scrollMath.stop(true);
		}
	},
	scrollTo: function(inX, inY) {
		this.stop();
		this.$.scrollMath.scrollTo(inY || inY === 0 ? inY : null, inX);
	},
	scrollIntoView: function() {
		this.stop();
		this.inherited(arguments);
	},
	setScrollLeft: function() {
		this.stop();
		this.inherited(arguments);
	},
	setScrollTop: function() {
		this.stop();
		this.inherited(arguments);
	},
	getScrollLeft: function() {
		return this.isScrolling() ? this.scrollLeft : this.inherited(arguments);
	},
	getScrollTop: function() {
		return this.isScrolling() ? this.scrollTop : this.inherited(arguments);
	},
	calcScrollNode: function() {
		return this.$.client.hasNode();
	},
	calcAutoScrolling: function() {
		var v = (this.vertical == "auto");
		var h = (this.horizontal == "auto") || (this.horizontal == "default");
		if ((v || h) && this.scrollNode) {
			var b = this.getScrollBounds();
			if (v) {
				this.$.scrollMath.vertical = b.height > b.clientHeight;
			}
			if (h) {
				this.$.scrollMath.horizontal = b.width > b.clientWidth;
			}
		}
	},
	shouldDrag: function(inSender, e) {
		this.calcAutoScrolling();
		var requestV = e.vertical;
		var canH = this.$.scrollMath.horizontal && !requestV;
		var canV = this.$.scrollMath.vertical && requestV;
		var down = e.dy < 0, right = e.dx < 0;
		var oobV = (!down && this.startEdges.top || down && this.startEdges.bottom);
		var oobH = (!right && this.startEdges.left || right && this.startEdges.right);
		// we would scroll if not at a boundary
		if (!e.boundaryDragger && (canH || canV)) {
			e.boundaryDragger = this;
		}
		// include boundary exclusion
		if ((!oobV && canV) || (!oobH && canH)) {
			e.dragger = this;
			return true;
		}
	},
	flick: function(inSender, e) {
		var onAxis = Math.abs(e.xVelocity) > Math.abs(e.yVelocity) ? this.$.scrollMath.horizontal : this.$.scrollMath.vertical;
		if (onAxis && this.dragging) {
			this.$.scrollMath.flick(e);
			return this.preventDragPropagation;
		}
	},
	hold: function(inSender, e) {
		if (this.isScrolling() && !this.isOverscrolling()) {
			this.$.scrollMath.stop(e);
			return true;
		}
	},
	move: function(inSender, inEvent) {
	},
	// special synthetic DOM events served up by the Gesture system
	dragstart: function(inSender, inEvent) {
		// note: allow drags to propagate to parent scrollers via data returned in the shouldDrag event.
		this.doShouldDrag(inEvent);
		this.dragging = (inEvent.dragger == this || (!inEvent.dragger && inEvent.boundaryDragger == this));
		if (this.dragging) {
			inEvent.preventDefault();
			// note: needed because show/hide changes
			// the position so sync'ing is required when
			// dragging begins (needed because show/hide does not trigger onscroll)
			this.syncScrollMath();
			this.$.scrollMath.startDrag(inEvent);
			if (this.preventDragPropagation) {
				return true;
			}
		}
	},
	drag: function(inSender, inEvent) {
		if (this.dragging) {
			inEvent.preventDefault();
			this.$.scrollMath.drag(inEvent);
			if (this.scrim) {
				this.$.scrim.show();
			}
		}
	},
	dragfinish: function(inSender, inEvent) {
		if (this.dragging) {
			inEvent.preventTap();
			this.$.scrollMath.dragFinish();
			this.dragging = false;
			if (this.scrim) {
				this.$.scrim.hide();
			}
		}
	},
	mousewheel: function(inSender, e) {
		if (!this.dragging && this.$.scrollMath.mousewheel(e)) {
			e.preventDefault();
			return true;
		}
	},
	scrollMathStart: function(inSender) {
		if (this.scrollNode) {
			this.calcBoundaries();
			if (this.thumb) {
				this.showThumbs();
			}
		}
	},
	scrollMathScroll: function(inSender) {
		this.effectScroll(-inSender.x, -inSender.y);
		if (this.thumb) {
			this.updateThumbs();
		}
	},
	scrollMathStop: function(inSender) {
		this.effectScrollStop();
		if (this.thumb) {
			this.delayHideThumbs(100);
		}
	},
	calcBoundaries: function() {
		var s = this.$.scrollMath, b = this._getScrollBounds();
		s.bottomBoundary = b.clientHeight - b.height;
		s.rightBoundary = b.clientWidth - b.width;
	},
	syncScrollMath: function() {
		var m = this.$.scrollMath;
		m.setScrollX(-this.getScrollLeft());
		m.setScrollY(-this.getScrollTop());
	},
	effectScroll: function(inX, inY) {
		if (this.scrollNode) {
			this.scrollLeft = this.scrollNode.scrollLeft = inX;
			this.scrollTop = this.scrollNode.scrollTop = inY;
			this.effectOverscroll(Math.round(inX), Math.round(inY));
		}
	},
	effectScrollStop: function() {
		this.effectOverscroll(null, null);
	},
	effectOverscroll: function(inX, inY) {
		var n = this.scrollNode;
		var x = "0,", y = "0", z = this.accel ? ",0" : "";
		if (inY !== null && Math.abs(inY - n.scrollTop) > 1) {
			y = (n.scrollTop - inY) + "px";
		}
		if (inX !== null && Math.abs(inX - n.scrollLeft) > 1) {
			x = (n.scrollLeft - inX) + "px,";
		}
		enyo.dom.transformValue(this.$.client, this.translation, x + y + z);
	},
	getOverScrollBounds: function() {
		var m = this.$.scrollMath;
		return {
			overleft: Math.min(m.leftBoundary - m.x, 0) || Math.max(m.rightBoundary - m.x, 0),
			overtop: Math.min(m.topBoundary - m.y, 0) || Math.max(m.bottomBoundary - m.y, 0)
		};
	},
	_getScrollBounds: function() {
		var r = this.inherited(arguments);
		enyo.mixin(r, this.getOverScrollBounds());
		return r;
	},
	getScrollBounds: function() {
		this.stop();
		return this.inherited(arguments);
	},
	// thumb processing
	alertThumbs: function() {
		this.showThumbs();
		this.delayHideThumbs(500);
	},
	syncThumbs: function() {
		this.$.vthumb.sync(this);
		this.$.hthumb.sync(this);
	},
	updateThumbs: function() {
		this.$.vthumb.update(this);
		this.$.hthumb.update(this);
	},
	showThumbs: function() {
		this.syncThumbs();
		this.$.vthumb.show();
		this.$.hthumb.show();
	},
	hideThumbs: function() {
		this.$.vthumb.hide();
		this.$.hthumb.hide();
	},
	delayHideThumbs: function(inDelay) {
		this.$.vthumb.delayHide(inDelay);
		this.$.hthumb.delayHide(inDelay);
	}
});
<|endoftext|>


<commit_before>function support(){
    if(bowser.blink){
        return true;
    }
    if(bowser.chrome){
        return true;
    }
    return false;
}
if(!support()){
    document.body.innerHTML = '
请使用最新版的Chrome浏览器
';
};

<commit_msg>wx notice<commit_after>function support(){
    if(/micromessenger/.test(navigator.userAgent.toLowerCase())){
        return false;
    }
    if(bowser.blink){
        return true;
    }
    if(bowser.chrome){
        return true;
    }
    return false;
}
if(!support()){
    body.style.backgroundImage = "none";
    document.body.innerHTML = '
请使用Chrome浏览器
';
};

<|endoftext|>


<commit_before>var printWin;
function printPage()
{
   var html="";
   html += "";
   html += document.getElementsByTagName('title')[0].outerHTML;
   html += document.getElementsByTagName('meta')[0].outerHTML;
   var htmlString = ""
   for(var i = 0; i < document.getElementsByTagName("link").length; i++){
     htmlString = document.getElementsByTagName("link")[i].outerHTML;
     html += htmlString;
   }
   html += "";
   html += "";
   html += "
Data Analyzer
";
   html += "
";
   html += "
Data Analyzer Graph

";
   html += "
";
   html += document.getElementById('summaryBox').innerHTML;
   html += "

Data Table
";
   html += "
";
   var s = "
";
   if(type === "bar"){
      var counter = 0;
      for(var j = 0; j<(chart.datasets[0].bars.length/10); j++){
         s+="
";
         for(var i = 0; (i<chart.datasets[0].bars.length && counter<10 && chart.datasets[0].bars[(10*j)+i]!= undefined); i++){
            s+="" + chart.datasets[0].bars[(10*j)+i].label + "	";
            counter++;
         }
         s+="
";
         counter = 0;
         for (var i = 0; i < chart.datasets.length; i++) {
            s+="
";
            for(var k = 0; (k<chart.datasets[i].bars.length && counter<10 && chart.datasets[i].bars[(10*j)+k]!= undefined); k++) {
               s+= "" + chart.datasets[i].bars[(10*j) + k].value + "	";
               counter++;
            }
            counter = 0;
            s += "
";
         }

         s+="

";
         counter = 0;
      }
   }
   else{
      var counter = 0;
      for(var j = 0; j<(chart.datasets[0].points.length/10); j++){
         s+="
";
         for(var i = 0; (i<chart.datasets[0].points.length && counter<10 && chart.datasets[0].points[(10*j)+i]!= undefined); i++){
            s+="" + chart.datasets[0].points[(10*j)+i].label + "	";
            counter++;
         }
         s+="
";
         counter = 0;
         for (var i = 0; i < chart.datasets.length; i++) {
            s+="
";
            for(var k = 0; (k<chart.datasets[i].points.length && counter<10 && chart.datasets[i].points[(10*j)+k]!= undefined); k++) {
               s+= "" + chart.datasets[i].points[(10*j) + k].value + "	";
               counter++;
            }
            counter = 0;
            s += "
";
         }

         s+="

";
         counter = 0;
      }
   }
   html += s;
   html += "

";
   html += "</content>";
   html += "";
   printWin = window.open("about:blank");
   printWin.document.write(html);
   printWin.document.close();
   printWin.document.getElementById("colors").style.maxHeight = "none";
   var inputs = printWin.document.getElementsByTagName("input");

   for(var i = 0; i < inputs.length; i++) {
     inputs[i].style.display = "none";
   }
  var sumBox = printWin.document.getElementById("summaryBox");
  var paragraphs = sumBox.getElementsByTagName("p");
  for(var i = 0; i < paragraphs.length; i++) {
    paragraphs[i].style.background = "rgba(0,0,0,0)";
  }
   //var div = "squaredTwo";
   var divArr = printWin.document.getElementsByClassName("squaredTwo");
   for(var i = 0; i < divArr.length; i++){
      divArr[i].style.display = "none";
   }
   var brArray = printWin.document.getElementsByTagName("br");
   for(var i = 0; i < brArray.length; i ++){
      if(brArray[i].parentNode.nodeName === "LI"){
         brArray[i].style.display="none";
      }
   }

   var colorBoxes = printWin.document.getElementsByClassName("colorblock")
   var image = new Image();
   var length = colorBoxes.length;
   for(var i = 0; i < length; i++){
     /*
     image.src = colorBoxes[i].toDataURL("image/png");
     var myImg = printWin.document.createElement("img");
     myImg = image;
     colorBoxes[i].parentNode.replaceChild(myImg, colorBoxes[i]);
     */
     var imgHTML = printWin.document.write('');
     imgHTML.setAttribute("src",colorBoxes[0].toDataURL("image/png"));
     imgHTML.setAttribute("alt","Color Box");
     imgHTML.setAttribute("width",65);
     imgHTML.setAttribute("height",24);
     colorBoxes[0].parentNode.replaceChild(imgHTML, colorBoxes[0]);
   }

   var redTriangles = printWin.document.getElementsByClassName("fa fa-exclamation-triangle");
   for(var i = 0; i <redTriangles.length; i ++){
    redTriangles[i].parentNode.remove(redTriangles[i]);
   }
   //printWin.document.styleSheets[0].insertRule('.colorblock {-webkit-print-color-adjust:exact;}',printWin.document.styleSheets[0].length);

   printWin.focus();
   setTimeout(function(){printWin.print();},100);
}
<commit_msg>Colors for print page #125 & 126<commit_after>var printWin;
function printPage()
{
   var html="";
   html += "";
   html += document.getElementsByTagName('title')[0].outerHTML;
   html += document.getElementsByTagName('meta')[0].outerHTML;
   var htmlString = ""
   for(var i = 0; i < document.getElementsByTagName("link").length; i++){
     htmlString = document.getElementsByTagName("link")[i].outerHTML;
     html += htmlString;
   }
   var bg = document.getElementById("graphCC").style.background;
   if(bg===""){
    bg = "url('stylesheets/halftone/halftone.png')";
   }
   html += "";
   html += "";
   html += "
Data Analyzer
";
   html += "
";
   html += "
Data Analyzer Graph

";
   html += "
";
   html += document.getElementById('summaryBox').innerHTML;
   html += "

Data Table
";
   html += "
";
   var s = "
";
   if(type === "bar"){
      var counter = 0;
      for(var j = 0; j<(chart.datasets[0].bars.length/10); j++){
         s+="
";
         for(var i = 0; (i<chart.datasets[0].bars.length && counter<10 && chart.datasets[0].bars[(10*j)+i]!= undefined); i++){
            s+="" + chart.datasets[0].bars[(10*j)+i].label + "	";
            counter++;
         }
         s+="
";
         counter = 0;
         for (var i = 0; i < chart.datasets.length; i++) {
            s+="
";
            for(var k = 0; (k<chart.datasets[i].bars.length && counter<10 && chart.datasets[i].bars[(10*j)+k]!= undefined); k++) {
               s+= "" + chart.datasets[i].bars[(10*j) + k].value + "	";
               counter++;
            }
            counter = 0;
            s += "
";
         }

         s+="

";
         counter = 0;
      }
   }
   else{
      var counter = 0;
      for(var j = 0; j<(chart.datasets[0].points.length/10); j++){
         s+="
";
         for(var i = 0; (i<chart.datasets[0].points.length && counter<10 && chart.datasets[0].points[(10*j)+i]!= undefined); i++){
            s+="" + chart.datasets[0].points[(10*j)+i].label + "	";
            counter++;
         }
         s+="
";
         counter = 0;
         for (var i = 0; i < chart.datasets.length; i++) {
            s+="
";
            for(var k = 0; (k<chart.datasets[i].points.length && counter<10 && chart.datasets[i].points[(10*j)+k]!= undefined); k++) {
               s+= "" + chart.datasets[i].points[(10*j) + k].value + "	";
               counter++;
            }
            counter = 0;
            s += "
";
         }

         s+="

";
         counter = 0;
      }
   }
   html += s;
   html += "

";
   html += "</content>";
   html += "";
   printWin = window.open("about:blank");
   printWin.document.write(html);
   printWin.document.close();
   printWin.document.getElementById("colors").style.maxHeight = "none";
   var inputs = printWin.document.getElementsByTagName("input");

   for(var i = 0; i < inputs.length; i++) {
     inputs[i].style.display = "none";
   }
  var sumBox = printWin.document.getElementById("summaryBox");
  var paragraphs = sumBox.getElementsByTagName("p");
  for(var i = 0; i < paragraphs.length; i++) {
    paragraphs[i].style.background = "rgba(0,0,0,0)";
  }
   //var div = "squaredTwo";
   var divArr = printWin.document.getElementsByClassName("squaredTwo");
   for(var i = 0; i < divArr.length; i++){
      divArr[i].style.display = "none";
   }
   var brArray = printWin.document.getElementsByTagName("br");
   for(var i = 0; i < brArray.length; i ++){
      if(brArray[i].parentNode.nodeName === "LI"){
         brArray[i].style.display="none";
      }
   }

   var colorBoxes = printWin.document.getElementsByClassName("colorblock")
   var image = new Image();
   var length = colorBoxes.length;
   for(var i = 0; i < length; i++){
     /*
     image.src = colorBoxes[i].toDataURL("image/png");
     var myImg = printWin.document.createElement("img");
     myImg = image;
     colorBoxes[i].parentNode.replaceChild(myImg, colorBoxes[i]);
     */
     var imgHTML = printWin.document.write('');
     imgHTML.setAttribute("src",colorBoxes[0].toDataURL("image/png"));
     imgHTML.setAttribute("alt","Color Box");
     imgHTML.setAttribute("width",65);
     imgHTML.setAttribute("height",24);
     colorBoxes[0].parentNode.replaceChild(imgHTML, colorBoxes[0]);
   }

   var redTriangles = printWin.document.getElementsByClassName("fa fa-exclamation-triangle");
   for(var i = 0; i <redTriangles.length; i ++){
    redTriangles[i].parentNode.remove(redTriangles[i]);
   }
   printWin.document.getElementsByTagName('body')[0].style.background = document.getElementsByTagName("body")[0].style.background;
   printWin.document.getElementsByTagName("body")[0].style.color = document.getElementsByTagName("body")[0].style.color ;
   printWin.document.getElementsByClassName("printTable")[0].style.border = "1px solid " + findContrastor(convertRGBtoHex(document.getElementsByTagName("body")[0].style.background));
   var ths = printWin.document.getElementsByTagName("th");
   var trs = printWin.document.getElementsByTagName("tr");
   var tds = printWin.document.getElementsByTagName("td");
   for(var i =0; i <ths.length; i++){
    ths[i].style.border = "1px solid " + findContrastor(convertRGBtoHex(document.getElementsByTagName("body")[0].style.background));
   }
   for(var i =0; i <trs.length; i++){
    trs[i].style.border = "1px solid " + findContrastor(convertRGBtoHex(document.getElementsByTagName("body")[0].style.background));
   }
   for(var i =0; i <tds.length; i++){
    tds[i].style.border = "1px solid " + findContrastor(convertRGBtoHex(document.getElementsByTagName("body")[0].style.background));
   }
   printWin.focus();
   setTimeout(function(){printWin.print();},100);
}
<|endoftext|>


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

  angular.module('app', ['ui.router']);
})();
<commit_msg>add ngStorage dependency<commit_after>(function() {
  'use strict';

  angular.module('app', ['ui.router', 'ngStorage']);
})();
<|endoftext|>


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

( function(){
var detectWindow, detectDOM;
detectWindow = function( W, detect ){
    var navi = W['navigator'], agent = navi.userAgent.toLowerCase(),
        platform = navi.platform.toLowerCase(),
        app = navi.appVersion.toLowerCase(),
        flash = 0, device = 'pc', browser, bv, os, osv, i, t0,
        ie = function(){
            if( agent.indexOf('msie') < 0 && agent.indexOf('trident') < 0 ) return;
            if( agent.indexOf('iemobile') > -1 ) os = 'winMobile';
            return browser = 'ie', bv = agent.indexOf('msie 7') > -1 && agent.indexOf('trident') > -1 ? -1 : agent.indexOf('msie') < 0 ? 11 : parseFloat(/msie ([\d]+)/.exec(agent)[1]);
        },
        chrome = function(){
            if( agent.indexOf( i = 'chrome' ) < 0 && agent.indexOf( i = 'crios' ) < 0 ) return;
            return browser = 'chrome', bv = parseFloat( ( i == 'chrome' ? /chrome\/([\d]+)/ : /crios\/([\d]+)/ ).exec(agent)[1] );
        },
        firefox = function(){return agent.indexOf('firefox') < 0 ? 0 : ( browser = 'firefox', bv = parseFloat(/firefox\/([\d]+)/.exec(agent)[1]) );},
        safari = function(){return agent.indexOf('safari') < 0 ? 0 : ( browser = 'safari', bv = parseFloat(/safari\/([\d]+)/.exec(agent)[1]) );},
        opera = function(){var i; return (agent.indexOf( i = 'opera') < 0 && agent.indexOf( i = 'opr' ) < 0 ) ? 0 : ( browser = 'opera', bv = ( i == 'opera' ) ? parseFloat(/version\/([\d]+)/.exec(agent)[1]) : parseFloat(/opr\/([\d]+)/.exec(agent)[1]) );},
        naver = function(){return agent.indexOf('naver') < 0 ? 0 : browser = 'naver';};
    if( !detect ) detect = {};
    if( agent.indexOf('android') > -1 ){
        browser = os = 'android';
        if( agent.indexOf('mobile') == -1 ) browser += 'Tablet', device = 'tablet';
        else device = 'mobile';
        if( i = /android ([\d.]+)/.exec(agent) ) i = i[1].split('.'), osv = parseFloat( i[0] + '.' + i[1] );
        else osv = 0;
        if( i = /safari\/([\d.]+)/.exec(agent) ) bv = parseFloat(i[1]);
        naver() || opera() || chrome() || firefox();
    }else if( agent.indexOf( i = 'ipad' ) > -1 || agent.indexOf( i = 'iphone' ) > -1 ){
        device = i == 'ipad' ? 'tablet' : 'mobile', browser = os = i;
        if( i = /os ([\d_]+)/.exec(agent) ) i = i[1].split('_'), osv = parseFloat( i[0] + '.' + i[1] );
        else osv = 0;
        if( i = /mobile\/([\S]+)/.exec(agent) ) bv = parseFloat(i[1]);
        naver() || opera() || chrome() || firefox();
    }else{
        if( platform.indexOf('win') > -1 ){
            os = 'win', i = 'windows nt ';
            if( agent.indexOf( i + '5.1' ) > -1 ) osv = 'xp';
            else if( agent.indexOf( i + '6.0' ) > -1 ) osv = 'vista';
            else if( agent.indexOf( i + '6.1' ) > -1 ) osv = '7';
            else if( agent.indexOf( i + '6.2' ) > -1 ) osv = '8';
            else if( agent.indexOf( i + '6.3' ) > -1 ) osv = '8.1';
            ie() || opera() || chrome() || firefox() || safari();
        }else if( platform.indexOf('mac') > -1 ){
            os = 'mac',
                i = /os x ([\d._]+)/.exec(agent)[1].replace( '_', '.' ).split('.'),
                osv = parseFloat( i[0] + '.' + i[1] ),
                opera() || chrome() || firefox() || safari();
        }else{
            os = app.indexOf('x11') > -1 ? 'unix' : app.indexOf('linux') > -1 ? 'linux' : 0,
                chrome() || firefox();
        }
    }
    (function(){
        var plug, t0;
        plug = navi.plugins;
        if( browser == 'ie' ) try{t0 = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').substr(4).split(','), flash = parseFloat( t0[0] + '.' + t0[1] );}catch(e){}
        else if( ( t0 = plug['Shockwave Flash 2.0'] ) || ( t0 = plug['Shockwave Flash'] ) ) t0 = t0.description.split(' ')[2].split('.'), flash = parseFloat( t0[0] + '.' + t0[1] );
        else if( agent.indexOf('webtv') > -1 ) flash = agent.indexOf('webtv/2.6') > -1 ? 4 : agent.indexOf("webtv/2.5") > -1 ? 3 : 2;
    })();
    for( i in t0 = {
        'device':device, 'browser':browser, 'browserVer':bv, 'os':os, 'osVer':osv, 'flash':flash, 'sony':agent.indexOf('sony') > -1 ? 1 : 0
    } ) if( t0.hasOwnProperty(i) ) detect[i] = t0[i];
    return detect;
};
detectDOM = function( W, detect ){
    var doc = W['document'], cssPrefix, stylePrefix, transform3D, keyframe = W['CSSRule'], docMode = 0,
        b = doc.body, bStyle = b.style, div = doc.createElement('div'),
        c = doc.createElement('canvas'), a = doc.createElement('audio'), v = doc.createElement('video'), k, t0;

    if( !detect ) detect = {};
    if( !doc ) return detect;
    div.innerHTML = '
a
',
        div = div.getElementsByTagName( 'div' )[0];
    switch( detect.browser ){
        case'ie':
            if( detect.browserVer == -1 ) detect.browserVer = !c['getContext'] ? 8 : !( 'msTransition' in bStyle ) && !( 'transition' in bStyle ) ? 9 : c.getContext('webgl') || c.getContext('experimental-webgl') ? 11 : 10;
            cssPrefix = '-ms-', stylePrefix = 'ms'; transform3D = detect.browserVer > 9 ? 1 : 0;
            docMode = doc['documentMode'] || 0;
            if( detect.browserVer == 6 ) doc.execCommand( 'BackgroundImageCache', false, true ), bStyle.position = 'relative';
            break;
        case'firefox': cssPrefix = '-moz-', stylePrefix = 'Moz'; transform3D = 1; break;
        case'opera': cssPrefix = '-o-', stylePrefix = 'O'; transform3D = 1; break;
        default: cssPrefix = '-webkit-', stylePrefix = 'webkit'; transform3D = detect.os == 'android' ? ( detect.osv < 4 ? 0 : 1 ) : 1;
    }
    if( keyframe ){
        if( keyframe.WEBKIT_KEYFRAME_RULE ) keyframe = '-webkit-keyframes';
        else if( keyframe.MOZ_KEYFRAME_RULE ) keyframe = '-moz-keyframes';
        else if( keyframe.KEYFRAME_RULE ) keyframe = 'keyframes';
        else keyframe = null;
    }
    for( k in t0 = {
        //dom
        root:b.scrollHeight ? b : doc.documentElement,
        scroll:doc.documentElement && typeof doc.documentElement.scrollLeft == 'number' ? 'scroll' : 'page', insertBefore:div.insertBefore ? 1 : 0,
        text:div.textContent ? 'textContent' : div.innerText ? 'innerText' : 'innerHTML',
        cstyle:( doc.defaultView && doc.defaultView.getComputedStyle ) ? 1 : 0,
        customData:( div.dataset && div.dataset.testOk == '234' ) ? 1 : 0,
        docMode:docMode,
        //css3
        cssPrefix:cssPrefix, stylePrefix:stylePrefix,
        transition:( stylePrefix + 'Transition' in bStyle || 'transition' in bStyle ) ? 1 : 0, transform3D:transform3D, keyframe:keyframe ? 1 : 0,
        transform:( stylePrefix + 'Transform' in bStyle || 'transform' in bStyle ) ? 1 : 0,
        //html5
        canvas:c ? 1 : 0, canvasText:c && c['getContext'] && c.getContext('2d').fillText,
        audio:a ? 1 : 0,
        audioMp3:a && a['canPlayType'] && a.canPlayType('audio/mpeg;').indexOf('no') < 0 ? 1 : 0,
        audioOgg:a && a['canPlayType'] && a.canPlayType('audio/ogg;').indexOf('no') < 0 ? 1 : 0,
        audioWav:a && a['canPlayType'] && a.canPlayType('audio/wav;').indexOf('no') < 0 ? 1 : 0,
        audioMp4:a && a['canPlayType'] && a.canPlayType('audio/mp4;').indexOf('no') < 0 ? 1 : 0,
        video:v ? 1 : 0,
        videoCaption:'track' in doc.createElement('track') ? 1 : 0,
        videoPoster:v && 'poster' in v ? 1 : 0,
        videoWebm:v && v['canPlayType'] && v.canPlayType( 'video/webm; codecs="vp8,mp4a.40.2"' ).indexOf( 'no' ) == -1 ? 1 : 0,
        videH264:v && v['canPlayType'] && v.canPlayType( 'video/mp4; codecs="avc1.42E01E,m4a.40.2"' ).indexOf( 'no' ) == -1 ? 1 : 0,
        videoTeora:v && v['canPlayType'] && v.canPlayType( 'video/ogg; codecs="theora,vorbis"' ).indexOf( 'no' ) == -1 ? 1 : 0,
        local:( W['localStorage'] && 'setItem' in localStorage ) ? 1 : 0,
        geo:( navigator['geolocation'] ) ? 1 : 0, worker:W['Worker'] ? 1 : 0, file:W['FileReader'] ? 1 : 0, message:W['postMessage'] ? 1 : 0,
        history:( 'pushState' in history ) ? 1 : 0, offline:W['applicationCache'] ? 1 : 0,
        db:W['openDatabase'] ? 1 : 0, socket:W['WebSocket'] ? 1 : 0
    } ) if( t0.hasOwnProperty(k) ) detect[k] = t0[k];
    return detect;
};

// @test
bs.detectWindow = detectWindow;
bs.detectDOM = detectDOM;
} )();<commit_msg>bsDetect<commit_after>var bs = bs || {};

( function(){
var detectWindow, detectDOM;
detectWindow = function( W, detect ){
    var navi = W['navigator'], agent = navi.userAgent.toLowerCase(),
        platform = navi.platform.toLowerCase(),
        app = navi.appVersion.toLowerCase(),
        flash = 0, device = 'pc', browser, bv, os, osv, i, t0,
        ie = function(){
            if( agent.indexOf('msie') < 0 && agent.indexOf('trident') < 0 ) return;
            if( agent.indexOf('iemobile') > -1 ) os = 'winMobile';
            return browser = 'ie', bv = agent.indexOf('msie 7') > -1 && agent.indexOf('trident') > -1 ? -1 : agent.indexOf('msie') < 0 ? 11 : parseFloat(/msie ([\d]+)/.exec(agent)[1]);
        },
        chrome = function(){
            if( agent.indexOf( i = 'chrome' ) < 0 && agent.indexOf( i = 'crios' ) < 0 ) return;
            return browser = 'chrome', bv = parseFloat( ( i == 'chrome' ? /chrome\/([\d]+)/ : /crios\/([\d]+)/ ).exec(agent)[1] );
        },
        firefox = function(){return agent.indexOf('firefox') < 0 ? 0 : ( browser = 'firefox', bv = parseFloat(/firefox\/([\d]+)/.exec(agent)[1]) );},
        safari = function(){return agent.indexOf('safari') < 0 ? 0 : ( browser = 'safari', bv = parseFloat(/safari\/([\d]+)/.exec(agent)[1]) );},
        opera = function(){var i; return (agent.indexOf( i = 'opera') < 0 && agent.indexOf( i = 'opr' ) < 0 ) ? 0 : ( browser = 'opera', bv = ( i == 'opera' ) ? parseFloat(/version\/([\d]+)/.exec(agent)[1]) : parseFloat(/opr\/([\d]+)/.exec(agent)[1]) );},
        naver = function(){return agent.indexOf('naver') < 0 ? 0 : browser = 'naver';};
    if( !detect ) detect = {};
    if( agent.indexOf('android') > -1 ){
        browser = os = 'android';
        if( agent.indexOf('mobile') == -1 ) browser += 'Tablet', device = 'tablet';
        else device = 'mobile';
        if( i = /android ([\d.]+)/.exec(agent) ) i = i[1].split('.'), osv = parseFloat( i[0] + '.' + i[1] );
        else osv = 0;
        if( i = /safari\/([\d.]+)/.exec(agent) ) bv = parseFloat(i[1]);
        naver() || opera() || chrome() || firefox();
    }else if( agent.indexOf( i = 'ipad' ) > -1 || agent.indexOf( i = 'iphone' ) > -1 ){
        device = i == 'ipad' ? 'tablet' : 'mobile', browser = os = i;
        if( i = /os ([\d_]+)/.exec(agent) ) i = i[1].split('_'), osv = parseFloat( i[0] + '.' + i[1] );
        else osv = 0;
        if( i = /mobile\/([\S]+)/.exec(agent) ) bv = parseFloat(i[1]);
        naver() || opera() || chrome() || firefox();
    }else{
        if( platform.indexOf('win') > -1 ){
            os = 'win', i = 'windows nt ';
            if( agent.indexOf( i + '5.1' ) > -1 ) osv = 'xp';
            else if( agent.indexOf( i + '6.0' ) > -1 ) osv = 'vista';
            else if( agent.indexOf( i + '6.1' ) > -1 ) osv = '7';
            else if( agent.indexOf( i + '6.2' ) > -1 ) osv = '8';
            else if( agent.indexOf( i + '6.3' ) > -1 ) osv = '8.1';
            ie() || opera() || chrome() || firefox() || safari();
        }else if( platform.indexOf('mac') > -1 ){
            os = 'mac',
                i = /os x ([\d._]+)/.exec(agent)[1].replace( '_', '.' ).split('.'),
                osv = parseFloat( i[0] + '.' + i[1] ),
                opera() || chrome() || firefox() || safari();
        }else{
            os = app.indexOf('x11') > -1 ? 'unix' : app.indexOf('linux') > -1 ? 'linux' : 0,
                chrome() || firefox();
        }
    }
    (function(){
        var plug, t0;
        plug = navi.plugins;
        if( browser == 'ie' ) try{t0 = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').substr(4).split(','), flash = parseFloat( t0[0] + '.' + t0[1] );}catch(e){}
        else if( ( t0 = plug['Shockwave Flash 2.0'] ) || ( t0 = plug['Shockwave Flash'] ) ) t0 = t0.description.split(' ')[2].split('.'), flash = parseFloat( t0[0] + '.' + t0[1] );
        else if( agent.indexOf('webtv') > -1 ) flash = agent.indexOf('webtv/2.6') > -1 ? 4 : agent.indexOf("webtv/2.5") > -1 ? 3 : 2;
    })();
    for( i in t0 = {
        'device':device, 'browser':browser, 'browserVer':bv, 'os':os, 'osVer':osv, 'flash':flash, 'sony':agent.indexOf('sony') > -1 ? 1 : 0
    } ) if( t0.hasOwnProperty(i) ) detect[i] = t0[i];
    return detect;
};
detectDOM = function( W, detect ){
    var doc = W['document'], cssPrefix, stylePrefix, transform3D, keyframe = W['CSSRule'], docMode = 0,
        b = doc.body, bStyle = b.style, div = doc.createElement('div'),
        c = doc.createElement('canvas'), a = doc.createElement('audio'), v = doc.createElement('video'), k, t0;

    if( !detect ) detect = {};
    if( !doc ) return detect;
    div.innerHTML = '
a
',
        div = div.getElementsByTagName( 'div' )[0];
    switch( detect.browser ){
        case'ie':
            if( detect.browserVer == -1 ) detect.browserVer = !c['getContext'] ? 8 : !( 'msTransition' in bStyle ) && !( 'transition' in bStyle ) ? 9 : c.getContext('webgl') || c.getContext('experimental-webgl') ? 11 : 10;
            cssPrefix = '-ms-', stylePrefix = 'ms'; transform3D = detect.browserVer > 9 ? 1 : 0;
            docMode = doc['documentMode'] || 0;
            if( detect.browserVer == 6 ) doc.execCommand( 'BackgroundImageCache', false, true ), bStyle.position = 'relative';
            break;
        case'firefox': cssPrefix = '-moz-', stylePrefix = 'Moz'; transform3D = 1; break;
        case'opera': cssPrefix = '-o-', stylePrefix = 'O'; transform3D = 1; break;
        default: cssPrefix = '-webkit-', stylePrefix = 'webkit'; transform3D = detect.os == 'android' ? ( detect.osv < 4 ? 0 : 1 ) : 1;
    }
    if( keyframe ){
        if( keyframe.WEBKIT_KEYFRAME_RULE ) keyframe = '-webkit-keyframes';
        else if( keyframe.MOZ_KEYFRAME_RULE ) keyframe = '-moz-keyframes';
        else if( keyframe.KEYFRAME_RULE ) keyframe = 'keyframes';
        else keyframe = null;
    }
    for( k in t0 = {
        //dom
        root:b.scrollHeight ? b : doc.documentElement,
        scroll:doc.documentElement && typeof doc.documentElement.scrollLeft == 'number' ? 'scroll' : 'page', insertBefore:div.insertBefore ? 1 : 0,
        text:div.textContent ? 'textContent' : div.innerText ? 'innerText' : 'innerHTML',
        cstyle:( doc.defaultView && doc.defaultView.getComputedStyle ) ? 1 : 0,
        customData:( div.dataset && div.dataset.testOk == '234' ) ? 1 : 0,
        docMode:docMode,
        //css3
        cssPrefix:cssPrefix, stylePrefix:stylePrefix,
        transition:( stylePrefix + 'Transition' in bStyle || 'transition' in bStyle ) ? 1 : 0, transform3D:transform3D, keyframe:keyframe ? 1 : 0,
        transform:( stylePrefix + 'Transform' in bStyle || 'transform' in bStyle ) ? 1 : 0,
        //html5
        canvas:c ? 1 : 0, canvasText:c && c['getContext'] && c.getContext('2d').fillText,
        audio:a ? 1 : 0,
        audioMp3:a && a['canPlayType'] && a.canPlayType('audio/mpeg;').indexOf('no') < 0 ? 1 : 0,
        audioOgg:a && a['canPlayType'] && a.canPlayType('audio/ogg;').indexOf('no') < 0 ? 1 : 0,
        audioWav:a && a['canPlayType'] && a.canPlayType('audio/wav;').indexOf('no') < 0 ? 1 : 0,
        audioMp4:a && a['canPlayType'] && a.canPlayType('audio/mp4;').indexOf('no') < 0 ? 1 : 0,
        video:v ? 1 : 0,
        videoCaption:'track' in doc.createElement('track') ? 1 : 0,
        videoPoster:v && 'poster' in v ? 1 : 0,
        videoWebm:v && v['canPlayType'] && v.canPlayType( 'video/webm; codecs="vp8,mp4a.40.2"' ).indexOf( 'no' ) == -1 ? 1 : 0,
        videoH264:v && v['canPlayType'] && v.canPlayType( 'video/mp4; codecs="avc1.42E01E,m4a.40.2"' ).indexOf( 'no' ) == -1 ? 1 : 0,
        videoTeora:v && v['canPlayType'] && v.canPlayType( 'video/ogg; codecs="theora,vorbis"' ).indexOf( 'no' ) == -1 ? 1 : 0,
        local:( W['localStorage'] && 'setItem' in localStorage ) ? 1 : 0,
        geo:( navigator['geolocation'] ) ? 1 : 0, worker:W['Worker'] ? 1 : 0, file:W['FileReader'] ? 1 : 0, message:W['postMessage'] ? 1 : 0,
        history:( 'pushState' in history ) ? 1 : 0, offline:W['applicationCache'] ? 1 : 0,
        db:W['openDatabase'] ? 1 : 0, socket:W['WebSocket'] ? 1 : 0
    } ) if( t0.hasOwnProperty(k) ) detect[k] = t0[k];
    return detect;
};

// @test
bs.detectWindow = detectWindow;
bs.detectDOM = detectDOM;
} )();<|endoftext|>


<commit_before>var $text = $('.poster blockquote p, .source');

// Change straight quotes to curly and double hyphens to em-dashes.
function smarten(a) {
  a = a.replace(/(^|[-\u2014\s(\["])'/g, "$1\u2018");       // opening singles
  a = a.replace(/'/g, "\u2019");                            // closing singles & apostrophes
  a = a.replace(/(^|[-\u2014/\[(\u2018\s])"/g, "$1\u201c"); // opening doubles
  a = a.replace(/"/g, "\u201d");                            // closing doubles
  a = a.replace(/--/g, "\u2014");                           // em-dashes
  return a;
}

function process_text(){
    $text.each(function(){
        var raw_text = $(this).html();

        $(this).html(smarten(raw_text));
    });
}

$('#save').on('click', function(){
    $('canvas').remove();
    process_text();

    html2canvas($('.poster'), {
      onrendered: function(canvas) {
        document.body.appendChild(canvas);
        window.oCanvas = document.getElementsByTagName("canvas");
        window.oCanvas = window.oCanvas[0];
        var strDataURI = window.oCanvas.toDataURL();

        var a = $("").attr("href", strDataURI).attr("download", "quote.png").appendTo("body");

        a[0].click();

        a.remove();

        $('#download').attr('href', strDataURI).attr('target', '_blank');
        $('#download').trigger('click');
      }
    });
});

$('#news').on('click', function(){
    $(this).toggleClass('btn-primary btn-default');
    $('#music').toggleClass('btn-primary btn-default');
    $('.poster').toggleClass('music');
});

$('#music').on('click', function(){
    $(this).toggleClass('btn-primary btn-default');
    $('#news').toggleClass('btn-primary btn-default');
    $('.poster').toggleClass('music');
});

$('#quote').on('click', function(){
    $(this).find('button').toggleClass('btn-primary btn-default');
    $('.poster').toggleClass('quote');
});

$('#fontsize').on('change', function(){
    var font_size = $(this).val().toString() + 'px';
    $('.poster').css('font-size', font_size);
});

$('#show').on('keyup', function(){
    var input_text = $(this).val();
    $('.source').find('em, span').remove();
    $('.source')
        .text($.trim($('.source').text()))
        .append(', ' + input_text + '');
});

var editable = document.querySelectorAll('.poster blockquote, .source');
var editor = new MediumEditor(editable, {
    buttons: ['italic']
});

$('.poster, .source').on('blur', function(){
    process_text();
});

document.querySelector(".poster").addEventListener("paste", function(e) {
    e.preventDefault();
    var text = e.clipboardData.getData("text/plain");
    document.execCommand("insertHTML", false, smarten(text));
});
<commit_msg>Fix double paste issue.<commit_after>var $text = $('.poster blockquote p, .source');

// Change straight quotes to curly and double hyphens to em-dashes.
function smarten(a) {
  a = a.replace(/(^|[-\u2014\s(\["])'/g, "$1\u2018");       // opening singles
  a = a.replace(/'/g, "\u2019");                            // closing singles & apostrophes
  a = a.replace(/(^|[-\u2014/\[(\u2018\s])"/g, "$1\u201c"); // opening doubles
  a = a.replace(/"/g, "\u201d");                            // closing doubles
  a = a.replace(/--/g, "\u2014");                           // em-dashes
  return a;
}

function process_text(){
    $text.each(function(){
        var raw_text = $(this).html();

        $(this).html(smarten(raw_text));
    });
}

$('#save').on('click', function(){
    $('canvas').remove();
    process_text();

    html2canvas($('.poster'), {
      onrendered: function(canvas) {
        document.body.appendChild(canvas);
        window.oCanvas = document.getElementsByTagName("canvas");
        window.oCanvas = window.oCanvas[0];
        var strDataURI = window.oCanvas.toDataURL();

        var a = $("").attr("href", strDataURI).attr("download", "quote.png").appendTo("body");

        a[0].click();

        a.remove();

        $('#download').attr('href', strDataURI).attr('target', '_blank');
        $('#download').trigger('click');
      }
    });
});

$('#news').on('click', function(){
    $(this).toggleClass('btn-primary btn-default');
    $('#music').toggleClass('btn-primary btn-default');
    $('.poster').toggleClass('music');
});

$('#music').on('click', function(){
    $(this).toggleClass('btn-primary btn-default');
    $('#news').toggleClass('btn-primary btn-default');
    $('.poster').toggleClass('music');
});

$('#quote').on('click', function(){
    $(this).find('button').toggleClass('btn-primary btn-default');
    $('.poster').toggleClass('quote');
});

$('#fontsize').on('change', function(){
    var font_size = $(this).val().toString() + 'px';
    $('.poster').css('font-size', font_size);
});

$('#show').on('keyup', function(){
    var input_text = $(this).val();
    $('.source').find('em, span').remove();
    $('.source')
        .text($.trim($('.source').text()))
        .append(', ' + input_text + '');
});

var editable = document.querySelectorAll('.poster blockquote, .source');
var editor = new MediumEditor(editable, {
    buttons: ['italic']
});

$('.poster, .source').on('blur', function(){
    process_text();
});

// document.querySelector(".poster blockquote, .source").addEventListener("paste", function(e) {
//     e.preventDefault();
//     var text = e.clipboardData.getData("text/plain");
//     document.execCommand("insertHTML", false, smarten(text));
// });
<|endoftext|>


<commit_before>function	sync_sv()
{
	socket.emit("get seated players");
	socket.on("seated players info", function(seat, seat_idx)
	{
		$("#qr" + seat_idx).css("visibility", "hidden");
		$("#qr_spot" + seat_idx).css("visibility", "hidden");
		$("#scan_msg" + seat_idx).css("visibility", "hidden");
		$("#player_name" + seat_idx).css("visibility", "visible");
		$("#player_name" + seat_idx).text(seat.player.nickname);
		$("#player_bankroll" + seat_idx).css("visibility", "visible");
		$("#player_bankroll" + seat_idx).text((Math.floor(+seat.player.bankroll * 100)) / 100 + "$");
		$("#player_cards"+ seat_idx).css("visibility", "visible");
	});
	socket.on("new player", function(player)
	{
		$("#qr" + player.seat_nb).css("visibility", "hidden");
		$("#qr_spot" + player.seat_nb).css("visibility", "hidden");
		$("#scan_msg" + player.seat_nb).css("visibility", "hidden");
		$("#player_name" + player.seat_nb).css("visibility", "visible");
		$("#player_name" + player.seat_nb).text(player.nickname);
		$("#player_bankroll" + player.seat_nb).css("visibility", "visible");
		$("#player_bankroll" + player.seat_nb).text((Math.floor(+player.bankroll * 100)) / 100 + "$");
		$("#player_cards"+ player.seat_nb).css("visibility", "visible");
	});
	socket.on("kick player", function(seat_nb)
	{
		$("#qr" + seat_nb).css("visibility", "visible");
		$("#qr_spot" + seat_nb).css("visibility", "visible");
		$("#scan_msg" + seat_nb).css("visibility", "visible");
		$("#player_name" + seat_nb).css("visibility", "hidden");
		$("#player_name" + seat_nb).text("");
		$("#player_bankroll" + seat_nb).css("visibility", "hidden");
		$("#player_bankroll" + seat_nb).text("");
		$("#player_cards"+ seat_nb).css("visibility", "hidden");
		$("#btn" + seat_nb).attr("src", "");
		$("#btn" + seat_nb).css("visibility", "hidden");
	});
	socket.emit("ask buttons");
	socket.on("place button", function(type, seat_nb)
	{
		if (seat_nb <= 0 || seat_nb >= 7)
			return ;
		if (type == "dealer")
		{
			$("#btn" + seat_nb).attr("src", "../img/Dealer.png")
			$("#btn" + seat_nb).css("visibility", "visible");
		}
		else if (type == "sb")
		{
			$("#btn" + seat_nb).attr("src", "../img/sb.png")
			$("#btn" + seat_nb).css("visibility", "visible");
		}
		else if (type == "bb")
		{
			$("#btn" + seat_nb).attr("src", "../img/bb.png")
			$("#btn" + seat_nb).css("visibility", "visible");
		}
		$("#player_cards" + seat_nb).attr("src", "../img/hidden_cards.png");
	});
	socket.on("give cards", function(seat_nb)
	{
		$("#player_cards" + seat_nb).attr("src", "../img/hidden_cards.png");
	});
	socket.on("highlights", function(seat_idx, new_state)
	{
		if (new_state == "off")
			$("#seat" + seat_idx).css("background-color", "#006F60");
		else if (new_state == "on")
			$("#seat" + seat_idx).css("background-color", "#FE554C");
	});
	socket.on("bankroll modification", function(seat_idx, player)
	{
		if (player.bankroll == "ALL IN")
			$("#player_bankroll" + seat_idx).text("ALL IN");
		else
			$("#player_bankroll" + seat_idx).text((Math.floor(player.bankroll * 100)) / 100 + "$");
	});
	socket.on("pot modification", function(pot_amount)
	{
		$("#pot").text(Math.floor(+pot_amount * 100) / 100 + "$");
	});
	socket.on("bet", function(seat_idx, amount)
	{
		if (!amount)
			$("#bet_val" + seat_idx).text('');
		else {
			$("#bet_val" + seat_idx).text((Math.floor(amount * 100)) / 100 + "$");
		}
	});

	socket.on("last action", function(decision, seat_nb)
	{
		$("#last_action" + seat_nb).text(decision);
	});
	socket.on("fold", function(seat_nb)
	{
		$("#btn" + seat_nb).css("visibility", "hidden");
		$("#bet_val" + seat_nb).text('');
		$("#player_cards" + seat_nb).attr("src", "../img/avatar.png");
		$("#last_action" + seat_nb).text('');
	});
	socket.emit("get board");
	socket.on("send flop", function(card1, card2, card3)
	{
		$("#b1").attr("src", "img/cards/" + card1 + ".png");
		$("#b2").attr("src", "img/cards/" + card2 + ".png");
		$("#b3").attr("src", "img/cards/" + card3 + ".png");
		$("#b1, #b2, #b3").css("visibility", "visible");
	});
	socket.on("send turn", function(card4)
	{
		$("#b4").attr("src", "img/cards/" + card4 + ".png");
		$("#b4").css("visibility", "visible");
	});
	socket.on("send river", function(card5)
	{
		$("#b5").attr("src", "img/cards/" + card5 + ".png");
		$("#b5").css("visibility", "visible");
	});
	socket.on("remove last actions", function()
	{
		for (var idx = 1; idx <= 6; ++idx)
			$("#last_action" + idx).remove();
	});
	socket.on("remove board", function()
	{
		$("#b1, #b2, #b3, #b4, #b5").css("visibility", "hidden");
		for (var idx = 1; idx <= 6; ++idx)
			$("#player_cards" + idx).attr("src", "../img/avatar.png");
	});
	socket.on("remove emplacements", function()
	{
		for (var idx = 1; idx <= 6; ++idx)
			$("#btn" + idx).css("visibility", "hidden");
	});
	socket.on("show down", function(card1, card2, seat_nb)
	{
		if ($('#qr_spot' + seat_nb).css('visibility') == 'hidden') {
			$("#card1_" + seat_nb).attr("src", "../img/cards/" + card1 + ".png");
			$("#card2_" + seat_nb).attr("src", "../img/cards/" + card2 + ".png");
			$("#card1_" + seat_nb).css("visibility", "visible");
			$("#card2_" + seat_nb).css("visibility", "visible");
		}
	});
	socket.on("show down off", function(seat_nb)
	{
		$("#card1_" + seat_nb).css("visibility", "hidden");
		$("#card2_" + seat_nb).css("visibility", "hidden");
	});
	socket.on("winner", function(seat_nb, rank_name)
	{
		var disconnect = '
' + $("#player_name" + seat_nb).text() + ' won because player ' + rank_name + ' or folded
';
		var won = '
' + $("#player_name" + seat_nb).text() + ' won with ' + rank_name + '
';

		if (rank_name == 'disconnected') {
			//$("#winner_msg").text($("#player_name" + seat_nb).text());
			$('#histoContent').empty();
			$('#histoContent').append(disconnect);
		}
		else if (seat_nb == 42 && rank_name == 'null') {
			//$("#winner_msg").text("Split!");
			$('#histoContent').empty();
			$('#histoContent').append('
Split !
');
		}
		else {
			$('#histoContent').empty();
			$('#histoContent').append(won);
		}
		//$("#winner").css("visibility", "visible");
	});
	socket.on("win off", function()
	{
		$("#winner, #card1_1, #card2_1, #card1_2, #card2_2, #card1_3, #card2_3, #card1_4, #card2_4, #card1_5, #card2_5, #card1_6, #card2_6").css("visibility", "hidden");
	});
}

var aTable = [];
var aGame = [];

var tableId;
socket.on('table ID', function(id) {
	tableId = id;
	console.log(tableId);
});

function restart() {
	//fonction reinitialiser la game
	console.log(tableId);
	io.to(tableId).emit('get table', tableId);
	socket.on('your table', function(table, game){
		aTable = table;
		aGame = game;
	});
	console.log(aTable, aGame);
}
/*
socket.on('refresh game', function(){
	console.log('Ca refresh');
});
*/
<commit_msg>little error<commit_after>function	sync_sv()
{
	socket.emit("get seated players");
	socket.on("seated players info", function(seat, seat_idx)
	{
		$("#qr" + seat_idx).css("visibility", "hidden");
		$("#qr_spot" + seat_idx).css("visibility", "hidden");
		$("#scan_msg" + seat_idx).css("visibility", "hidden");
		$("#player_name" + seat_idx).css("visibility", "visible");
		$("#player_name" + seat_idx).text(seat.player.nickname);
		$("#player_bankroll" + seat_idx).css("visibility", "visible");
		$("#player_bankroll" + seat_idx).text((Math.floor(+seat.player.bankroll * 100)) / 100 + "$");
		$("#player_cards"+ seat_idx).css("visibility", "visible");
	});
	socket.on("new player", function(player)
	{
		$("#qr" + player.seat_nb).css("visibility", "hidden");
		$("#qr_spot" + player.seat_nb).css("visibility", "hidden");
		$("#scan_msg" + player.seat_nb).css("visibility", "hidden");
		$("#player_name" + player.seat_nb).css("visibility", "visible");
		$("#player_name" + player.seat_nb).text(player.nickname);
		$("#player_bankroll" + player.seat_nb).css("visibility", "visible");
		$("#player_bankroll" + player.seat_nb).text((Math.floor(+player.bankroll * 100)) / 100 + "$");
		$("#player_cards"+ player.seat_nb).css("visibility", "visible");
	});
	socket.on("kick player", function(seat_nb)
	{
		$("#qr" + seat_nb).css("visibility", "visible");
		$("#qr_spot" + seat_nb).css("visibility", "visible");
		$("#scan_msg" + seat_nb).css("visibility", "visible");
		$("#player_name" + seat_nb).css("visibility", "hidden");
		$("#player_name" + seat_nb).text("");
		$("#player_bankroll" + seat_nb).css("visibility", "hidden");
		$("#player_bankroll" + seat_nb).text("");
		$("#player_cards"+ seat_nb).css("visibility", "hidden");
		$("#btn" + seat_nb).attr("src", "");
		$("#btn" + seat_nb).css("visibility", "hidden");
	});
	socket.emit("ask buttons");
	socket.on("place button", function(type, seat_nb)
	{
		if (seat_nb <= 0 || seat_nb >= 7)
			return ;
		if (type == "dealer")
		{
			$("#btn" + seat_nb).attr("src", "../img/Dealer.png")
			$("#btn" + seat_nb).css("visibility", "visible");
		}
		else if (type == "sb")
		{
			$("#btn" + seat_nb).attr("src", "../img/sb.png")
			$("#btn" + seat_nb).css("visibility", "visible");
		}
		else if (type == "bb")
		{
			$("#btn" + seat_nb).attr("src", "../img/bb.png")
			$("#btn" + seat_nb).css("visibility", "visible");
		}
		$("#player_cards" + seat_nb).attr("src", "../img/hidden_cards.png");
	});
	socket.on("give cards", function(seat_nb)
	{
		$("#player_cards" + seat_nb).attr("src", "../img/hidden_cards.png");
	});
	socket.on("highlights", function(seat_idx, new_state)
	{
		if (new_state == "off")
			$("#seat" + seat_idx).css("background-color", "#006F60");
		else if (new_state == "on")
			$("#seat" + seat_idx).css("background-color", "#FE554C");
	});
	socket.on("bankroll modification", function(seat_idx, player)
	{
		if (player.bankroll == "ALL IN")
			$("#player_bankroll" + seat_idx).text("ALL IN");
		else
			$("#player_bankroll" + seat_idx).text((Math.floor(player.bankroll * 100)) / 100 + "$");
	});
	socket.on("pot modification", function(pot_amount)
	{
		$("#pot").text(Math.floor(+pot_amount * 100) / 100 + "$");
	});
	socket.on("bet", function(seat_idx, amount)
	{
		if (!amount)
			$("#bet_val" + seat_idx).text('');
		else {
			$("#bet_val" + seat_idx).text((Math.floor(amount * 100)) / 100 + "$");
		}
	});

	socket.on("last action", function(decision, seat_nb)
	{
		$("#last_action" + seat_nb).text(decision);
	});
	socket.on("fold", function(seat_nb)
	{
		$("#btn" + seat_nb).css("visibility", "hidden");
		$("#bet_val" + seat_nb).text('');
		$("#player_cards" + seat_nb).attr("src", "../img/avatar.png");
		$("#last_action" + seat_nb).text('');
	});
	socket.emit("get board");
	socket.on("send flop", function(card1, card2, card3)
	{
		$("#b1").attr("src", "img/cards/" + card1 + ".png");
		$("#b2").attr("src", "img/cards/" + card2 + ".png");
		$("#b3").attr("src", "img/cards/" + card3 + ".png");
		$("#b1, #b2, #b3").css("visibility", "visible");
	});
	socket.on("send turn", function(card4)
	{
		$("#b4").attr("src", "img/cards/" + card4 + ".png");
		$("#b4").css("visibility", "visible");
	});
	socket.on("send river", function(card5)
	{
		$("#b5").attr("src", "img/cards/" + card5 + ".png");
		$("#b5").css("visibility", "visible");
	});
	socket.on("remove last actions", function()
	{
		for (var idx = 1; idx <= 6; ++idx)
			$("#last_action" + idx).remove();
	});
	socket.on("remove board", function()
	{
		$("#b1, #b2, #b3, #b4, #b5").css("visibility", "hidden");
		for (var idx = 1; idx <= 6; ++idx)
			$("#player_cards" + idx).attr("src", "../img/avatar.png");
	});
	socket.on("remove emplacements", function()
	{
		for (var idx = 1; idx <= 6; ++idx)
			$("#btn" + idx).css("visibility", "hidden");
	});
	socket.on("show down", function(card1, card2, seat_nb)
	{
		if ($('#qr_spot' + seat_nb).css('visibility') == 'hidden') {
			$("#card1_" + seat_nb).attr("src", "../img/cards/" + card1 + ".png");
			$("#card2_" + seat_nb).attr("src", "../img/cards/" + card2 + ".png");
			$("#card1_" + seat_nb).css("visibility", "visible");
			$("#card2_" + seat_nb).css("visibility", "visible");
		}
	});
	socket.on("show down off", function(seat_nb)
	{
		$("#card1_" + seat_nb).css("visibility", "hidden");
		$("#card2_" + seat_nb).css("visibility", "hidden");
	});
	socket.on("winner", function(seat_nb, rank_name)
	{
		var disconnect = '
' + $("#player_name" + seat_nb).text() + ' won because player ' + rank_name + ' or folded
';
		var won = '
' + $("#player_name" + seat_nb).text() + ' won with ' + rank_name + '
';

		if (rank_name == 'disconnected') {
			//$("#winner_msg").text($("#player_name" + seat_nb).text());
			$('#histoContent').empty();
			$('#histoContent').append(disconnect);
		}
		else if (seat_nb == 42 && rank_name == 'null') {
			//$("#winner_msg").text("Split!");
			$('#histoContent').empty();
			$('#histoContent').append('
Split !
');
		}
		else {
			$('#histoContent').empty();
			$('#histoContent').append(won);
		}
		//$("#winner").css("visibility", "visible");
	});
	socket.on("win off", function()
	{
		$("#winner, #card1_1, #card2_1, #card1_2, #card2_2, #card1_3, #card2_3, #card1_4, #card2_4, #card1_5, #card2_5, #card1_6, #card2_6").css("visibility", "hidden");
	});
}

var aTable = [];
var aGame = [];

var tableId;
socket.on('table ID', function(id) {
	tableId = id;
	console.log(tableId);
});

function restart() {
	//fonction reinitialiser la game
	console.log(tableId);
	socket.emit('get table', tableId);
	socket.on('your table', function(table, game){
		aTable = table;
		aGame = game;
	});
	console.log(aTable, aGame);
}
/*
socket.on('refresh game', function(){
	console.log('Ca refresh');
});
*/
<|endoftext|>


<commit_before>/**
 * Extend module's NODE_PATH
 * HACK: temporary solution
 */

require('node-path')(module);

/**
 * Module dependencies.
 */

var mongoose = require('mongoose');
var Comment = mongoose.model('Comment');
var utils = require('lib/utils');
var pluck = utils.pluck;
var log = require('debug')('democracyos:db-api:comment');

/**
 * Get all comments
 *
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comments' list items found or `undefined`
 * @return {Module} `comment` module
 * @api public
 */

exports.all = function all(fn) {
  log('Looking for all comments.')

  Comment.find(function (err, comments) {
    if (err) {
      log('Found error %j', err);
      return fn(err);
    };

    log('Delivering comments %j', pluck(comments, 'id'));
    fn(null, proposals);
  });

  return this;
};

/**
 * Create comment for `proposal` by `author`
 * with `text`
 *
 * @param {String} proposal to submit comment
 * @param {Object} comment comment vars like `text` and `author`
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comments' list items found or `undefined`
 * @api public
 */

exports.create = function create(comment, fn) {
  log('Creating new comment %j for %s %s', comment.text, comment.context, comment.reference);

  var comment = new Comment(comment);

  comment.save(function (err) {
    if (err) {
      log('Found error %s', err);
      return fn(err);
    };
    comment.populate('author', function(err) {
      if (err) {
        log('Found error %s', err)
        return fn(err);
      };

      log('Delivering comment %j', comment.id);
      fn(null, comment);
    });
  });
};

/**
 * Get comments for proposal
 *
 * @param {String} proposal to get comments from
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comments' list items found or `undefined`
 * @api public
 */

exports.getFor = function getFor(query, paging, fn) {
  log('Looking for comments for %s %s', query.context, query.reference);

  paging = paging || { page: 0, limit: 0, sort: 'score' };

  Comment
  .find(query)
  .populate('author', 'id firstName lastName fullName email')
  .sort(paging.sort)
  .skip(paging.page * paging.limit)
  .limit(paging.limit)
  .exec(function(err, comments) {
    if (err) {
      log('Found error %j', err);
      return fn(err);
    };

    log('Delivering comments %j', pluck(comments, 'id'));
    fn(null, comments);
  });
};

/**
 * Get replies for comment
 *
 * @param {String} id
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comments' list items found or `undefined`
 * @api public
 */

exports.replies = function replies(id, fn) {
  log('Looking for replies for comment %s', id);

  Comment
  .findOne({ _id: id })
  .populate('replies.author', 'id firstName lastName fullName email')
  .exec(function(err, comment) {
    if (err) {
      log('Found error %j', err);
      return fn(err);
    };

    var replies = comment && comment.replies ? comment.replies : [];

    log('Delivering replies %j', pluck(replies, 'id'));
    fn(null, replies);
  });
};

/**
 * Reply to comment
 *
 * @param {String} commentId to attach reply
 * @param {Object} reply object with params
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comments' list items found or `undefined`
 * @api public
 */

exports.reply = function reply(commentId, reply, fn) {
  log('Looking for comment %s to reply with %j', commentId, reply);

  Comment.findById(commentId, function(err, comment) {
    if (err) {
      log('Found error %j', err);
      return fn(err);
    };

    log('Creating reply %j for comment %j', reply, comment);
    var doc = comment.replies.create(reply);
    comment.replies.push(doc);

    comment.save(function(err, saved) {
      if (err) {
        log('Found error %j', err)
      };

      comment
      .populate('replies.author', 'id firstName lastName fullName email', function(err) {
        if (err) {
          log('Found error %j', err);
          return fn(err);
        };

        reply = comment.replies.id(doc.id);

        log('Delivering reply %s', reply.id);
        fn(null, reply);
      });

    });
  });
};

/**
 * Edit a reply
 *
 * @param {Object} comment to attach reply
 * @param {Object} reply object with params
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comments' list items found or `undefined`
 * @api public
 */

exports.editReply = function editReply(comment, reply, fn) {
  log('Looking for comment %s to reply with %s', comment.id, reply.id);

  reply.editedAt = Date.now();

  Comment.update(
    { _id: comment.id, 'replies._id': reply.id },
    { $set: { 'replies.$.text': reply.text, 'replies.$.editedAt': reply.editedAt } },
    function (err) {
      if (err) {
        log('Found error %j', err);
        return fn(err);
      }

      log('Delivering reply %s', reply.id);
      fn(null, reply);
  });
};

/**
 * Upvote comment
 *
 * @param {String} id
 * @param {Citizen|ObjectId|String} citizen
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comment' list items found or `undefined`
 * @api public
 */

exports.upvote = function upvote(id, citizen, fn) {
  Comment.findById(id, function(err, comment) {
    if (err) return log('Found error %s', err), fn(err);

    log('Upvoting comment %s', comment.id);
    comment.vote(citizen, 'positive', function(err) {
      if (err) return log('Found error %s', err), fn(err);

      log('Delivering comment %s', comment.id);
      fn(null, comment);
    });
  });
};

/**
 * Downvote comment
 *
 * @param {String} id
 * @param {Citizen|ObjectId|String} citizen
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comments' list items found or `undefined`
 * @api public
 */

exports.downvote = function downvote(id, citizen, fn) {
  Comment.findById(id, function(err, comment) {
    if (err) return log('Found error %s', err), fn(err);

    log('Downvoting comment %s', comment.id);
    comment.vote(citizen, 'negative', function(err) {
      if (err) return log('Found error %s', err), fn(err);

      log('Delivering comment %s', comment.id);
      fn(null, comment);
    });
  });
};

/**
 * Flag comment as spam
 *
 * @param {String} id
 * @param {Citizen|ObjectId|String} citizen
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comment' list items found or `undefined`
 * @api public
 */

exports.flag = function flag(id, citizen, fn) {
  Comment.findById(id, function(err, comment) {
    if (err) return log('Found error %s', err), fn(err);

    log('Upvoting comment %s', comment.id);
    comment.flag(citizen, 'spam', function(err) {
      if (err) return log('Found error %s', err), fn(err);

      log('Delivering comment %s', comment.id);
      fn(null, comment);
    });
  });
};

/**
 * Unflag comment as spam
 *
 * @param {String} id
 * @param {Citizen|ObjectId|String} citizen
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comments' list items found or `undefined`
 * @api public
 */

exports.unflag = function unflag(id, citizen, fn) {
  Comment.findById(id, function(err, comment) {
    if (err) return log('Found error %s', err), fn(err);

    log('Downvoting comment %s', comment.id);
    comment.unflag(citizen, function(err) {
      if (err) return log('Found error %s', err), fn(err);

      log('Delivering comment %s', comment.id);
      fn(null, comment);
    });
  });
};

/**
 * Edit comment
 *
 * @param {String} id
 * @param {Citizen|ObjectId|String} citizen
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 * @api public
 */

exports.edit = function edit(comment, fn) {
  log('Updating comment %s', comment.id);

  comment.save(function (err, comment) {
    if (!err) return log('Updated comment %s', comment.id), fn(null, comment);
    return log('Found error %s', err), fn(err);
  });

  return this;
};

/**
 * Remove comment
 *
 * @param {String} id
 * @param {Citizen|ObjectId|String} citizen
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 * @api public
 */

exports.remove = function remove(comment, fn) {
  comment.remove(function(err) {
    if (err) return log('Found error %s', err), fn(err);

    log('Comment %s removed', comment.id);
    fn(null);
  });
};<commit_msg>[db-api:comment] - Fix getting comments per page limit from config when not requested #322<commit_after>/**
 * Extend module's NODE_PATH
 * HACK: temporary solution
 */

require('node-path')(module);

/**
 * Module dependencies.
 */

var mongoose = require('mongoose');
var Comment = mongoose.model('Comment');
var utils = require('lib/utils');
var pluck = utils.pluck;
var log = require('debug')('democracyos:db-api:comment');

/**
 * Get all comments
 *
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comments' list items found or `undefined`
 * @return {Module} `comment` module
 * @api public
 */

exports.all = function all(fn) {
  log('Looking for all comments.')

  Comment.find(function (err, comments) {
    if (err) {
      log('Found error %j', err);
      return fn(err);
    };

    log('Delivering comments %j', pluck(comments, 'id'));
    fn(null, proposals);
  });

  return this;
};

/**
 * Create comment for `proposal` by `author`
 * with `text`
 *
 * @param {String} proposal to submit comment
 * @param {Object} comment comment vars like `text` and `author`
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comments' list items found or `undefined`
 * @api public
 */

exports.create = function create(comment, fn) {
  log('Creating new comment %j for %s %s', comment.text, comment.context, comment.reference);

  var comment = new Comment(comment);

  comment.save(function (err) {
    if (err) {
      log('Found error %s', err);
      return fn(err);
    };
    comment.populate('author', function(err) {
      if (err) {
        log('Found error %s', err)
        return fn(err);
      };

      log('Delivering comment %j', comment.id);
      fn(null, comment);
    });
  });
};

/**
 * Get comments for proposal
 *
 * @param {String} proposal to get comments from
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comments' list items found or `undefined`
 * @api public
 */

exports.getFor = function getFor(query, paging, fn) {
  log('Looking for comments for %s %s', query.context, query.reference);

  paging = paging || { page: 0, limit: config('comments per page'), sort: 'score' };

  Comment
  .find(query)
  .populate('author', 'id firstName lastName fullName email')
  .sort(paging.sort)
  .skip(paging.page * paging.limit)
  .limit(paging.limit)
  .exec(function(err, comments) {
    if (err) {
      log('Found error %j', err);
      return fn(err);
    };

    log('Delivering comments %j', pluck(comments, 'id'));
    fn(null, comments);
  });
};

/**
 * Get replies for comment
 *
 * @param {String} id
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comments' list items found or `undefined`
 * @api public
 */

exports.replies = function replies(id, fn) {
  log('Looking for replies for comment %s', id);

  Comment
  .findOne({ _id: id })
  .populate('replies.author', 'id firstName lastName fullName email')
  .exec(function(err, comment) {
    if (err) {
      log('Found error %j', err);
      return fn(err);
    };

    var replies = comment && comment.replies ? comment.replies : [];

    log('Delivering replies %j', pluck(replies, 'id'));
    fn(null, replies);
  });
};

/**
 * Reply to comment
 *
 * @param {String} commentId to attach reply
 * @param {Object} reply object with params
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comments' list items found or `undefined`
 * @api public
 */

exports.reply = function reply(commentId, reply, fn) {
  log('Looking for comment %s to reply with %j', commentId, reply);

  Comment.findById(commentId, function(err, comment) {
    if (err) {
      log('Found error %j', err);
      return fn(err);
    };

    log('Creating reply %j for comment %j', reply, comment);
    var doc = comment.replies.create(reply);
    comment.replies.push(doc);

    comment.save(function(err, saved) {
      if (err) {
        log('Found error %j', err)
      };

      comment
      .populate('replies.author', 'id firstName lastName fullName email', function(err) {
        if (err) {
          log('Found error %j', err);
          return fn(err);
        };

        reply = comment.replies.id(doc.id);

        log('Delivering reply %s', reply.id);
        fn(null, reply);
      });

    });
  });
};

/**
 * Edit a reply
 *
 * @param {Object} comment to attach reply
 * @param {Object} reply object with params
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comments' list items found or `undefined`
 * @api public
 */

exports.editReply = function editReply(comment, reply, fn) {
  log('Looking for comment %s to reply with %s', comment.id, reply.id);

  reply.editedAt = Date.now();

  Comment.update(
    { _id: comment.id, 'replies._id': reply.id },
    { $set: { 'replies.$.text': reply.text, 'replies.$.editedAt': reply.editedAt } },
    function (err) {
      if (err) {
        log('Found error %j', err);
        return fn(err);
      }

      log('Delivering reply %s', reply.id);
      fn(null, reply);
  });
};

/**
 * Upvote comment
 *
 * @param {String} id
 * @param {Citizen|ObjectId|String} citizen
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comment' list items found or `undefined`
 * @api public
 */

exports.upvote = function upvote(id, citizen, fn) {
  Comment.findById(id, function(err, comment) {
    if (err) return log('Found error %s', err), fn(err);

    log('Upvoting comment %s', comment.id);
    comment.vote(citizen, 'positive', function(err) {
      if (err) return log('Found error %s', err), fn(err);

      log('Delivering comment %s', comment.id);
      fn(null, comment);
    });
  });
};

/**
 * Downvote comment
 *
 * @param {String} id
 * @param {Citizen|ObjectId|String} citizen
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comments' list items found or `undefined`
 * @api public
 */

exports.downvote = function downvote(id, citizen, fn) {
  Comment.findById(id, function(err, comment) {
    if (err) return log('Found error %s', err), fn(err);

    log('Downvoting comment %s', comment.id);
    comment.vote(citizen, 'negative', function(err) {
      if (err) return log('Found error %s', err), fn(err);

      log('Delivering comment %s', comment.id);
      fn(null, comment);
    });
  });
};

/**
 * Flag comment as spam
 *
 * @param {String} id
 * @param {Citizen|ObjectId|String} citizen
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comment' list items found or `undefined`
 * @api public
 */

exports.flag = function flag(id, citizen, fn) {
  Comment.findById(id, function(err, comment) {
    if (err) return log('Found error %s', err), fn(err);

    log('Upvoting comment %s', comment.id);
    comment.flag(citizen, 'spam', function(err) {
      if (err) return log('Found error %s', err), fn(err);

      log('Delivering comment %s', comment.id);
      fn(null, comment);
    });
  });
};

/**
 * Unflag comment as spam
 *
 * @param {String} id
 * @param {Citizen|ObjectId|String} citizen
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 *   - 'comments' list items found or `undefined`
 * @api public
 */

exports.unflag = function unflag(id, citizen, fn) {
  Comment.findById(id, function(err, comment) {
    if (err) return log('Found error %s', err), fn(err);

    log('Downvoting comment %s', comment.id);
    comment.unflag(citizen, function(err) {
      if (err) return log('Found error %s', err), fn(err);

      log('Delivering comment %s', comment.id);
      fn(null, comment);
    });
  });
};

/**
 * Edit comment
 *
 * @param {String} id
 * @param {Citizen|ObjectId|String} citizen
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 * @api public
 */

exports.edit = function edit(comment, fn) {
  log('Updating comment %s', comment.id);

  comment.save(function (err, comment) {
    if (!err) return log('Updated comment %s', comment.id), fn(null, comment);
    return log('Found error %s', err), fn(err);
  });

  return this;
};

/**
 * Remove comment
 *
 * @param {String} id
 * @param {Citizen|ObjectId|String} citizen
 * @param {Function} fn callback function
 *   - 'err' error found while process or `null`
 * @api public
 */

exports.remove = function remove(comment, fn) {
  comment.remove(function(err) {
    if (err) return log('Found error %s', err), fn(err);

    log('Comment %s removed', comment.id);
    fn(null);
  });
};<|endoftext|>