<commit_before>/*!
 * clipboard.js v1.5.5
 * https://zenorocha.github.io/clipboard.js
 *
 * Licensed MIT © Zeno Rocha
 */
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Clipboard=t()}}(function(){var t,e,n;return function t(e,n,r){function o(a,c){if(!n[a]){if(!e[a]){var s="function"==typeof require&&require;if(!c&&s)return s(a,!0);if(i)return i(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var l=n[a]={exports:{}};e[a][0].call(l.exports,function(t){var n=e[a][1][t];return o(n?n:t)},l,l.exports,t,e,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(t,e,n){var r=t("matches-selector");e.exports=function(t,e,n){for(var o=n?t:t.parentNode;o&&o!==document;){if(r(o,e))return o;o=o.parentNode}}},{"matches-selector":2}],2:[function(t,e,n){function r(t,e){if(i)return i.call(t,e);for(var n=t.parentNode.querySelectorAll(e),r=0;r<n.length;++r)if(n[r]==t)return!0;return!1}var o=Element.prototype,i=o.matchesSelector||o.webkitMatchesSelector||o.mozMatchesSelector||o.msMatchesSelector||o.oMatchesSelector;e.exports=r},{}],3:[function(t,e,n){function r(t,e,n,r){var i=o.apply(this,arguments);return t.addEventListener(n,i),{destroy:function(){t.removeEventListener(n,i)}}}function o(t,e,n,r){return function(n){n.delegateTarget=i(n.target,e,!0),n.delegateTarget&&r.call(t,n)}}var i=t("closest");e.exports=r},{closest:1}],4:[function(t,e,n){n.node=function(t){return void 0!==t&&t instanceof HTMLElement&&1===t.nodeType},n.nodeList=function(t){var e=Object.prototype.toString.call(t);return void 0!==t&&("[object NodeList]"===e||"[object HTMLCollection]"===e)&&"length"in t&&(0===t.length||n.node(t[0]))},n.string=function(t){return"string"==typeof t||t instanceof String},n.function=function(t){var e=Object.prototype.toString.call(t);return"[object Function]"===e}},{}],5:[function(t,e,n){function r(t,e,n){if(!t&&!e&&!n)throw new Error("Missing required arguments");if(!c.string(e))throw new TypeError("Second argument must be a String");if(!c.function(n))throw new TypeError("Third argument must be a Function");if(c.node(t))return o(t,e,n);if(c.nodeList(t))return i(t,e,n);if(c.string(t))return a(t,e,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function o(t,e,n){return t.addEventListener(e,n),{destroy:function(){t.removeEventListener(e,n)}}}function i(t,e,n){return Array.prototype.forEach.call(t,function(t){t.addEventListener(e,n)}),{destroy:function(){Array.prototype.forEach.call(t,function(t){t.removeEventListener(e,n)})}}}function a(t,e,n){return s(document.body,t,e,n)}var c=t("./is"),s=t("delegate");e.exports=r},{"./is":4,delegate:3}],6:[function(t,e,n){function r(t){var e;if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName)t.focus(),t.setSelectionRange(0,t.value.length),e=t.value;else{t.hasAttribute("contenteditable")&&t.focus();var n=window.getSelection(),r=document.createRange();r.selectNodeContents(t),n.removeAllRanges(),n.addRange(r),e=n.toString()}return e}e.exports=r},{}],7:[function(t,e,n){function r(){}r.prototype={on:function(t,e,n){var r=this.e||(this.e={});return(r[t]||(r[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){function r(){o.off(t,r),e.apply(n,arguments)}var o=this;return r._=e,this.on(t,r,n)},emit:function(t){var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),r=0,o=n.length;for(r;o>r;r++)n[r].fn.apply(n[r].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),r=n[t],o=[];if(r&&e)for(var i=0,a=r.length;a>i;i++)r[i].fn!==e&&r[i].fn._!==e&&o.push(r[i]);return o.length?n[t]=o:delete n[t],this}},e.exports=r},{}],8:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}n.__esModule=!0;var i=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),a=t("select"),c=r(a),s=function(){function t(e){o(this,t),this.resolveOptions(e),this.initSelection()}return t.prototype.resolveOptions=function t(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.action=e.action,this.emitter=e.emitter,this.target=e.target,this.text=e.text,this.trigger=e.trigger,this.selectedText=""},t.prototype.initSelection=function t(){if(this.text&&this.target)throw new Error('Multiple attributes declared, use either "target" or "text"');if(this.text)this.selectFake();else{if(!this.target)throw new Error('Missing required attributes, use either "target" or "text"');this.selectTarget()}},t.prototype.selectFake=function t(){var e=this;this.removeFake(),this.fakeHandler=document.body.addEventListener("click",function(){return e.removeFake()}),this.fakeElem=document.createElement("textarea"),this.fakeElem.style.position="absolute",this.fakeElem.style.left="-9999px",this.fakeElem.style.top=(window.pageYOffset||document.documentElement.scrollTop)+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,document.body.appendChild(this.fakeElem),this.selectedText=c.default(this.fakeElem),this.copyText()},t.prototype.removeFake=function t(){this.fakeHandler&&(document.body.removeEventListener("click"),this.fakeHandler=null),this.fakeElem&&(document.body.removeChild(this.fakeElem),this.fakeElem=null)},t.prototype.selectTarget=function t(){this.selectedText=c.default(this.target),this.copyText()},t.prototype.copyText=function t(){var e=void 0;try{e=document.execCommand(this.action)}catch(n){e=!1}this.handleResult(e)},t.prototype.handleResult=function t(e){e?this.emitter.emit("success",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)}):this.emitter.emit("error",{action:this.action,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})},t.prototype.clearSelection=function t(){this.target&&this.target.blur(),window.getSelection().removeAllRanges()},t.prototype.destroy=function t(){this.removeFake()},i(t,[{key:"action",set:function t(){var e=arguments.length<=0||void 0===arguments[0]?"copy":arguments[0];if(this._action=e,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function t(){return this._action}},{key:"target",set:function t(e){if(void 0!==e){if(!e||"object"!=typeof e||1!==e.nodeType)throw new Error('Invalid "target" value, use a valid Element');this._target=e}},get:function t(){return this._target}}]),t}();n.default=s,e.exports=n.default},{select:6}],9:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function a(t,e){var n="data-clipboard-"+t;if(e.hasAttribute(n))return e.getAttribute(n)}n.__esModule=!0;var c=t("./clipboard-action"),s=r(c),u=t("tiny-emitter"),l=r(u),f=t("good-listener"),d=r(f),h=function(t){function e(n,r){o(this,e),t.call(this),this.resolveOptions(r),this.listenClick(n)}return i(e,t),e.prototype.resolveOptions=function t(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.action="function"==typeof e.action?e.action:this.defaultAction,this.target="function"==typeof e.target?e.target:this.defaultTarget,this.text="function"==typeof e.text?e.text:this.defaultText},e.prototype.listenClick=function t(e){var n=this;this.listener=d.default(e,"click",function(t){return n.onClick(t)})},e.prototype.onClick=function t(e){var n=e.delegateTarget||e.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new s.default({action:this.action(n),target:this.target(n),text:this.text(n),trigger:n,emitter:this})},e.prototype.defaultAction=function t(e){return a("action",e)},e.prototype.defaultTarget=function t(e){var n=a("target",e);return n?document.querySelector(n):void 0},e.prototype.defaultText=function t(e){return a("text",e)},e.prototype.destroy=function t(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)},e}(l.default);n.default=h,e.exports=n.default},{"./clipboard-action":8,"good-listener":5,"tiny-emitter":7}]},{},[9])(9)});<commit_msg>Update clipboard.js<commit_after>/*!
 * clipboard.js v1.5.10
 * https://zenorocha.github.io/clipboard.js
 *
 * Licensed MIT © Zeno Rocha
 */
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Clipboard=t()}}(function(){var t,e,n;return function t(e,n,o){function i(c,a){if(!n[c]){if(!e[c]){var s="function"==typeof require&&require;if(!a&&s)return s(c,!0);if(r)return r(c,!0);var l=new Error("Cannot find module '"+c+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[c]={exports:{}};e[c][0].call(u.exports,function(t){var n=e[c][1][t];return i(n?n:t)},u,u.exports,t,e,n,o)}return n[c].exports}for(var r="function"==typeof require&&require,c=0;c<o.length;c++)i(o[c]);return i}({1:[function(t,e,n){var o=t("matches-selector");e.exports=function(t,e,n){for(var i=n?t:t.parentNode;i&&i!==document;){if(o(i,e))return i;i=i.parentNode}}},{"matches-selector":5}],2:[function(t,e,n){function o(t,e,n,o,r){var c=i.apply(this,arguments);return t.addEventListener(n,c,r),{destroy:function(){t.removeEventListener(n,c,r)}}}function i(t,e,n,o){return function(n){n.delegateTarget=r(n.target,e,!0),n.delegateTarget&&o.call(t,n)}}var r=t("closest");e.exports=o},{closest:1}],3:[function(t,e,n){n.node=function(t){return void 0!==t&&t instanceof HTMLElement&&1===t.nodeType},n.nodeList=function(t){var e=Object.prototype.toString.call(t);return void 0!==t&&("[object NodeList]"===e||"[object HTMLCollection]"===e)&&"length"in t&&(0===t.length||n.node(t[0]))},n.string=function(t){return"string"==typeof t||t instanceof String},n.fn=function(t){var e=Object.prototype.toString.call(t);return"[object Function]"===e}},{}],4:[function(t,e,n){function o(t,e,n){if(!t&&!e&&!n)throw new Error("Missing required arguments");if(!a.string(e))throw new TypeError("Second argument must be a String");if(!a.fn(n))throw new TypeError("Third argument must be a Function");if(a.node(t))return i(t,e,n);if(a.nodeList(t))return r(t,e,n);if(a.string(t))return c(t,e,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function i(t,e,n){return t.addEventListener(e,n),{destroy:function(){t.removeEventListener(e,n)}}}function r(t,e,n){return Array.prototype.forEach.call(t,function(t){t.addEventListener(e,n)}),{destroy:function(){Array.prototype.forEach.call(t,function(t){t.removeEventListener(e,n)})}}}function c(t,e,n){return s(document.body,t,e,n)}var a=t("./is"),s=t("delegate");e.exports=o},{"./is":3,delegate:2}],5:[function(t,e,n){function o(t,e){if(r)return r.call(t,e);for(var n=t.parentNode.querySelectorAll(e),o=0;o<n.length;++o)if(n[o]==t)return!0;return!1}var i=Element.prototype,r=i.matchesSelector||i.webkitMatchesSelector||i.mozMatchesSelector||i.msMatchesSelector||i.oMatchesSelector;e.exports=o},{}],6:[function(t,e,n){function o(t){var e;if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName)t.focus(),t.setSelectionRange(0,t.value.length),e=t.value;else{t.hasAttribute("contenteditable")&&t.focus();var n=window.getSelection(),o=document.createRange();o.selectNodeContents(t),n.removeAllRanges(),n.addRange(o),e=n.toString()}return e}e.exports=o},{}],7:[function(t,e,n){function o(){}o.prototype={on:function(t,e,n){var o=this.e||(this.e={});return(o[t]||(o[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){function o(){i.off(t,o),e.apply(n,arguments)}var i=this;return o._=e,this.on(t,o,n)},emit:function(t){var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),o=0,i=n.length;for(o;i>o;o++)n[o].fn.apply(n[o].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),o=n[t],i=[];if(o&&e)for(var r=0,c=o.length;c>r;r++)o[r].fn!==e&&o[r].fn._!==e&&i.push(o[r]);return i.length?n[t]=i:delete n[t],this}},e.exports=o},{}],8:[function(e,n,o){!function(i,r){if("function"==typeof t&&t.amd)t(["module","select"],r);else if("undefined"!=typeof o)r(n,e("select"));else{var c={exports:{}};r(c,i.select),i.clipboardAction=c.exports}}(this,function(t,e){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=n(e),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},c=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),a=function(){function t(e){o(this,t),this.resolveOptions(e),this.initSelection()}return t.prototype.resolveOptions=function t(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.action=e.action,this.emitter=e.emitter,this.target=e.target,this.text=e.text,this.trigger=e.trigger,this.selectedText=""},t.prototype.initSelection=function t(){this.text?this.selectFake():this.target&&this.selectTarget()},t.prototype.selectFake=function t(){var e=this,n="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandler=document.body.addEventListener("click",function(){return e.removeFake()}),this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="fixed",this.fakeElem.style[n?"right":"left"]="-9999px",this.fakeElem.style.top=(window.pageYOffset||document.documentElement.scrollTop)+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,document.body.appendChild(this.fakeElem),this.selectedText=(0,i.default)(this.fakeElem),this.copyText()},t.prototype.removeFake=function t(){this.fakeHandler&&(document.body.removeEventListener("click"),this.fakeHandler=null),this.fakeElem&&(document.body.removeChild(this.fakeElem),this.fakeElem=null)},t.prototype.selectTarget=function t(){this.selectedText=(0,i.default)(this.target),this.copyText()},t.prototype.copyText=function t(){var e=void 0;try{e=document.execCommand(this.action)}catch(n){e=!1}this.handleResult(e)},t.prototype.handleResult=function t(e){e?this.emitter.emit("success",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)}):this.emitter.emit("error",{action:this.action,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})},t.prototype.clearSelection=function t(){this.target&&this.target.blur(),window.getSelection().removeAllRanges()},t.prototype.destroy=function t(){this.removeFake()},c(t,[{key:"action",set:function t(){var e=arguments.length<=0||void 0===arguments[0]?"copy":arguments[0];if(this._action=e,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function t(){return this._action}},{key:"target",set:function t(e){if(void 0!==e){if(!e||"object"!==("undefined"==typeof e?"undefined":r(e))||1!==e.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&e.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(e.hasAttribute("readonly")||e.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=e}},get:function t(){return this._target}}]),t}();t.exports=a})},{select:6}],9:[function(e,n,o){!function(i,r){if("function"==typeof t&&t.amd)t(["module","./clipboard-action","tiny-emitter","good-listener"],r);else if("undefined"!=typeof o)r(n,e("./clipboard-action"),e("tiny-emitter"),e("good-listener"));else{var c={exports:{}};r(c,i.clipboardAction,i.tinyEmitter,i.goodListener),i.clipboard=c.exports}}(this,function(t,e,n,o){"use strict";function i(t){return t&&t.__esModule?t:{"default":t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function c(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function s(t,e){var n="data-clipboard-"+t;if(e.hasAttribute(n))return e.getAttribute(n)}var l=i(e),u=i(n),f=i(o),d=function(t){function e(n,o){r(this,e);var i=c(this,t.call(this));return i.resolveOptions(o),i.listenClick(n),i}return a(e,t),e.prototype.resolveOptions=function t(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.action="function"==typeof e.action?e.action:this.defaultAction,this.target="function"==typeof e.target?e.target:this.defaultTarget,this.text="function"==typeof e.text?e.text:this.defaultText},e.prototype.listenClick=function t(e){var n=this;this.listener=(0,f.default)(e,"click",function(t){return n.onClick(t)})},e.prototype.onClick=function t(e){var n=e.delegateTarget||e.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new l.default({action:this.action(n),target:this.target(n),text:this.text(n),trigger:n,emitter:this})},e.prototype.defaultAction=function t(e){return s("action",e)},e.prototype.defaultTarget=function t(e){var n=s("target",e);return n?document.querySelector(n):void 0},e.prototype.defaultText=function t(e){return s("text",e)},e.prototype.destroy=function t(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)},e}(u.default);t.exports=d})},{"./clipboard-action":8,"good-listener":4,"tiny-emitter":7}]},{},[9])(9)});<|endoftext|>


<commit_before>$( document ).ready( function() {
    $( '.creature' ).mouseover( function () {
        var ARROW_HEIGHT = 14;
        var ARROW_WIDTH = 30;
        var id = this.getAttribute( 'data-creatureid' );
        var username = this.getAttribute( 'data-username' );
        var x = this.getAttribute( 'data-x' );
        var y = this.getAttribute( 'data-y' );
        var hp = this.getAttribute( 'data-hp' );
        var maxHp = this.getAttribute( 'data-maxHp' );
        var $this = $( this );
        var offsetTop = $this.offset().top - $( '.infobubble' ).height() - 14;
        var $infobubble = $( '.infobubble' );
        var positioning;

        $infobubble.show();
        $( '.player' ).text( username );
        $( '.creatureid' ).text( 'Creature ' + id );
        $( '.location' ).text( x + ', ' + y );
        $( '.numeric' ).text( hp + ' / ' + maxHp );
        $( '.damage' ).css( 'width', Math.floor( 100 * ( maxHp - hp ) / maxHp ) + '%' );
        if ( offsetTop < 0 ) {
            positioning = $this.height() + ARROW_HEIGHT;
            $infobubble.addClass( 'reversed' );
        }
        else {
            positioning = -$infobubble.height() - ARROW_HEIGHT;
        }
        $infobubble.css( 'top', $this.position().top + positioning );
        $infobubble.css( 'left', $this.position().left - $infobubble.width() + ARROW_WIDTH );
    } );
    $( '.creature' ).mouseout( function() {
        var $infobubble = $( '.infobubble' );
        $infobubble.removeClass( 'reversed' );
        $infobubble.hide();
    } );
    $( '.next a' ).click( function() {
        $.getJSON( this.href, function( creatures ) {
            var href = $( '.next a' ).attr( 'href' );
            var roundid;
            var attribute;
            var gameid;
            var maxHp = $( '.creature' ).attr( 'data-maxHp' );

            hrefArray = href.substr( href.indexOf( "?" ) + 1 ).split( "&" );
            for ( var i = 0; i < hrefArray.length; ++i ) {
                attribute = hrefArray[ i ].split( "=" );
                if ( attribute[ 0 ] == 'roundid' ) {
                    roundid = parseInt( attribute[ 1 ] ) + 1;
                }
                else if ( attribute[ 0 ] == 'gameid' ) {
                    gameid = parseInt( attribute[ 1 ] );
                }
            }
            $( '.next a' ).attr( 'href', "game/view?gameid=" + gameid + "&roundid=" + roundid );

            $( '.creature' ).remove();
            for ( var i = 0; i < creatures.length; ++i ) {
                var creature = creatures[ i ];
                if ( creature.hp > 0 ) {
                    var $user = $( '.playerList li[data-id=' + creature.userid + ']' );
                    var username = $user.text();
                    var color = $user.find( 'span.bubble' ).attr( 'data-color' );
                    creatureInfo = {
                        creatureid: creature.id,
                        username: username,
                        x: creature.x,
                        y: creature.y,
                        hp: creature.hp,
                        maxHp: maxHp
                    };
                    $creature = $( '

' );
                    for ( var attribute in creatureInfo ) {
                        var value = creatureInfo[ attribute ];
                        $creature.attr( 'data-' + attribute, value );
                    }
                    $creature.css( {
                        left: creature.x * 20 + 'px',
                        top: creature.y * 20 + 'px'
                    } );
                }
                $( '.gameboard' ).prepend( $creature );
            }
        } );
        return false;
    } );
} );
<commit_msg>Fix roundid for previous button too<commit_after>$( document ).ready( function() {
    $( '.creature' ).mouseover( function () {
        var ARROW_HEIGHT = 14;
        var ARROW_WIDTH = 30;
        var id = this.getAttribute( 'data-creatureid' );
        var username = this.getAttribute( 'data-username' );
        var x = this.getAttribute( 'data-x' );
        var y = this.getAttribute( 'data-y' );
        var hp = this.getAttribute( 'data-hp' );
        var maxHp = this.getAttribute( 'data-maxHp' );
        var $this = $( this );
        var offsetTop = $this.offset().top - $( '.infobubble' ).height() - 14;
        var $infobubble = $( '.infobubble' );
        var positioning;

        $infobubble.show();
        $( '.player' ).text( username );
        $( '.creatureid' ).text( 'Creature ' + id );
        $( '.location' ).text( x + ', ' + y );
        $( '.numeric' ).text( hp + ' / ' + maxHp );
        $( '.damage' ).css( 'width', Math.floor( 100 * ( maxHp - hp ) / maxHp ) + '%' );
        if ( offsetTop < 0 ) {
            positioning = $this.height() + ARROW_HEIGHT;
            $infobubble.addClass( 'reversed' );
        }
        else {
            positioning = -$infobubble.height() - ARROW_HEIGHT;
        }
        $infobubble.css( 'top', $this.position().top + positioning );
        $infobubble.css( 'left', $this.position().left - $infobubble.width() + ARROW_WIDTH );
    } );
    $( '.creature' ).mouseout( function() {
        var $infobubble = $( '.infobubble' );
        $infobubble.removeClass( 'reversed' );
        $infobubble.hide();
    } );
    function fixRoundId( classname ) {
        var href = $( '.' + classname + ' a' ).attr( 'href' );
        var roundid;
        var attribute;
        var gameid;

        hrefArray = href.substr( href.indexOf( "?" ) + 1 ).split( "&" );
        for ( var i = 0; i < hrefArray.length; ++i ) {
            attribute = hrefArray[ i ].split( "=" );
            if ( attribute[ 0 ] == 'roundid' ) {
                roundid = parseInt( attribute[ 1 ] ) + 1;
            }
            else if ( attribute[ 0 ] == 'gameid' ) {
                gameid = parseInt( attribute[ 1 ] );
            }
        }
        $( '.' + classname + ' a' ).attr( 'href', "game/view?gameid=" + gameid + "&roundid=" + roundid );
    }
    $( '.next a' ).click( function() {
        $.getJSON( this.href, function( creatures ) {
            var maxHp = $( '.creature' ).attr( 'data-maxHp' );

            fixRoundId( 'next' );
            fixRoundId( 'previous' );

            $( '.creature' ).remove();
            for ( var i = 0; i < creatures.length; ++i ) {
                var creature = creatures[ i ];
                if ( creature.hp > 0 ) {
                    var $user = $( '.playerList li[data-id=' + creature.userid + ']' );
                    var username = $user.text();
                    var color = $user.find( 'span.bubble' ).attr( 'data-color' );
                    creatureInfo = {
                        creatureid: creature.id,
                        username: username,
                        x: creature.x,
                        y: creature.y,
                        hp: creature.hp,
                        maxHp: maxHp
                    };
                    $creature = $( '

' );
                    for ( var attribute in creatureInfo ) {
                        var value = creatureInfo[ attribute ];
                        $creature.attr( 'data-' + attribute, value );
                    }
                    $creature.css( {
                        left: creature.x * 20 + 'px',
                        top: creature.y * 20 + 'px'
                    } );
                }
                $( '.gameboard' ).prepend( $creature );
            }
        } );
        return false;
    } );
} );
<|endoftext|>


<commit_before>//you must generate user & password credentials in RTWire's console. (in MAINNET!)
var user = "your_user";
var pass = "your_pass";
var root = "https://api.rtwire.com/v1/mainnet"

/*
Using the RTWIRE API we can handle player-to-player transactions off-chain while still providing
a unique bitcoin address to every player so they can deposit.
Players must pay the transaction fee to withdraw to an exernal wallet.

 */

var Bukkit = org.bukkit.Bukkit;
var Inventory = org.bukkit.inventory.Inventory;
var ItemStack = org.bukkit.inventory.ItemStack;
var Material = org.bukkit.Material;
var ItemMeta = org.bukkit.inventory.meta.ItemMeta;

var updateScoreboard = require("./scoreboard.js").updateScoreboard;
var commando = require('../../commando/commando.js').commando

exports.apirequest = function(reqMethod, url, body) {
    // print("Api REQUEST DATA | body:"+body+"request method: "+reqMethod+url) //this is a debug line
    var auth = user + ":" + pass;
    var Base64 = java.util.Base64;
    var bytes = auth.getBytes();
    var encoded = Base64.getEncoder().encodeToString(bytes);
    //HTTP REQUEST
    conn = new java.net.URL(url).openConnection();
    conn.requestMethod = reqMethod;
    conn.doOutput = true;
    conn.instanceFollowRedirects = false;
    conn.setRequestProperty('Authorization', 'Basic ' + encoded)
    conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11");
    if (conn.requestMethod == 'POST' || conn.requestMethod == 'PUT') {
        conn.doInput = true;
        conn.setDoOutput(true);
        // put each parameter in the outputstream
        conn.setRequestProperty('Content-Type', 'application/json');
        conn.setRequestProperty('Accept', 'application/json');
        conn.useCaches = false;
        var wr = new java.io.DataOutputStream(conn.getOutputStream());
        wr.writeBytes(body);
        if (conn.getOutputStream !== null) {
            wr.flush();
            wr.close();
        }
    }
    var rc = conn.responseCode;
    var response;
    var stream;
    if (rc == 200 || rc == 201) {
        try {
            stream = conn.getInputStream();
            response = new java.util.Scanner(stream).useDelimiter("\\A").next();
        } catch (e) {
            response = "nothing"
        }
    }
    var responseInfo = [rc, response];
    return responseInfo;
}

exports.sendTx = function(senderWalletID, destination, amount, isBTCaddress) {
    var n = {
        "n": 1
    }
    var postInfo = JSON.parse(apirequest('POST', root + '/transactions/', JSON.stringify(n))[1]).payload;
    var txID = postInfo[0].id;
    if (isBTCaddress == undefined) {
        var tx = {
            "id": txID, // Unique transaction ID. See docs below.
            "fromAccountID": senderWalletID,
            // Transfer to an RTWire account.
            "toAccountID": destination,

            "value": amount // Value to transfer in Satoshi.
        }
    } else {
        var tx = {
            "id": txID, // Unique transaction ID.
            "fromAccountID": senderWalletID,
            // Transfer to a Bitcoin Address
            "toAddress": destination,

            "value": amount // Value to transfer in Satoshi.
        }
    }
    var TxInfo = apirequest('PUT', root + '/transactions/', JSON.stringify(tx))
    return TxInfo;
}

exports.getNewAccount = function() {
    var req = apirequest('POST', root + '/accounts/')
    var AccountID = JSON.parse(req[1]).payload[0].id;
    return AccountID;
}

exports.getNewBtcAddress = function(accountID) {
    var req = apirequest('POST', root + '/accounts/' + accountID.toString() + '/addresses/')
    var btcAddress = JSON.parse(req[1]).payload[0].address;
    return btcAddress;
}

exports.updateBalance = function(player) {
    var alldata = scload('serverdb.json');
    var playerUUID = player.uniqueId;
    var AccountID = alldata.wallets[playerUUID].AccountID;
    var req = apirequest('GET', root + '/accounts/' + AccountID.toString())
    var newBalance = JSON.parse(req[1]).payload[0].balance / 100;
    return newBalance;
}

commando('send', function(args, player) {
    var alldata = scload('serverdb.json');
    var amount = parseInt(args[0]);
    var sender = player;
    var senderAccountID = alldata.wallets[sender.uniqueId].AccountID;
    var receiverparam = args[1] //playername or btcAddress

    var pReceiver = Bukkit.getServer().getPlayer(receiverparam);
    if (pReceiver != null && pReceiver != sender) {
        var receiverAccountID = alldata.wallets[pReceiver.uniqueId].AccountID;
        echo(sender, "Sending...".yellow())
        var sendInfo = sendTx(senderAccountID, receiverAccountID, amount * 100);
        if (sendInfo[0] == 201 || sendInfo[0] == 200) {
            newBalanceofSender = updateBalance(sender);
            newBalanceofReceiver = updateBalance(pReceiver);
            updateScoreboard(sender, newBalanceofSender);
            updateScoreboard(pReceiver, newBalanceofReceiver);
            echo(sender, "You sent ".green() + amount.toString() + " bits to " + receiverparam + ".");
            echo(pReceiver, "".green() + player.getName() + " sent you " + amount.toString() + " bit(s).");
        } else {
            echo(sender, "Transaction Failed.".red())
        }
    } else {
        echo(player, "Player not found.".red())
    }
});
/* //TRANSFER TO EXTERNAL WALLET IS NOT WORKING YET
commando('transfer', function(args, player) {
    var alldata = scload('serverdb.json');
    var amount = parseInt(args[0]);
    var sender = player;
    var senderAccountID = alldata.wallets[sender.uniqueId].AccountID;
    var receiverparam = args[1] //playername or btcAddress
    var pReceiver = Bukkit.getServer().getPlayer(receiverparam);
    if (pReceiver != null && pReceiver != sender) {
        var receiverBTCaddress = alldata.wallets[pReceiver.uniqueId].BTCaddress;
        echo(sender, "Sending...".yellow())
        var sendInfo = sendTx(senderAccountID, receiverBTCaddress, amount * 100, true);
        if (sendInfo[0] == 201) {
            echo(sender, "You sent ".green() + amount.toString() + " bits to " + receiverparam + ".");
            echo(pReceiver, "".green() + player.getName() + " sent you " + amount.toString() + " bit(s).");
        } else {
            echo(sender, "Transaction Failed. Remember there is a fee of 100 bits.".red())
        }
    } else {
        echo(player, "Player not found.".red())
    }

});
*/

commando('bithelp', function(args, player) {
    echo(player, "Your deposit bitcoin address is: https://blockchain.info/address/".gold() + alldata.wallets[player.uniqueId].BTCaddress)
    echo(player, "Use /send [amount] [player name] to send bits to online players without fees.")
    echo(player, "Use /transfer [amount] [bitcoin address] to transfer bits to external wallet.");
    echo(player, "Players must pay the miner fee to transfer out.");
});
<commit_msg>Update rtwireAPI.js<commit_after>//you must generate user & password credentials in RTWire's console. (in MAINNET!)
var user = "your_user";
var pass = "your_pass";
var root = "https://api.rtwire.com/v1/mainnet"

/*
Using the RTWIRE API we can handle player-to-player transactions off-chain while still providing
a unique bitcoin address to every player so they can deposit.
Players must pay the transaction fee to withdraw to an exernal wallet.

 */

var Bukkit = org.bukkit.Bukkit;
var Inventory = org.bukkit.inventory.Inventory;
var ItemStack = org.bukkit.inventory.ItemStack;
var Material = org.bukkit.Material;
var ItemMeta = org.bukkit.inventory.meta.ItemMeta;

var updateScoreboard = require("./scoreboard.js").updateScoreboard;
var commando = require('../../commando/commando.js').commando

exports.apirequest = function(reqMethod, url, body) {
    // print("Api REQUEST DATA | body:"+body+"request method: "+reqMethod+url) //this is a debug line
    var auth = user + ":" + pass;
    var Base64 = java.util.Base64;
    var bytes = auth.getBytes();
    var encoded = Base64.getEncoder().encodeToString(bytes);
    //HTTP REQUEST
    conn = new java.net.URL(url).openConnection();
    conn.requestMethod = reqMethod;
    conn.doOutput = true;
    conn.instanceFollowRedirects = false;
    conn.setRequestProperty('Authorization', 'Basic ' + encoded)
    conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11");
    if (conn.requestMethod == 'POST' || conn.requestMethod == 'PUT') {
        conn.doInput = true;
        conn.setDoOutput(true);
        // put each parameter in the outputstream
        conn.setRequestProperty('Content-Type', 'application/json');
        conn.setRequestProperty('Accept', 'application/json');
        conn.useCaches = false;
        var wr = new java.io.DataOutputStream(conn.getOutputStream());
        wr.writeBytes(body);
        if (conn.getOutputStream !== null) {
            wr.flush();
            wr.close();
        }
    }
    var rc = conn.responseCode;
    var response;
    var stream;
    if (rc == 200 || rc == 201) {
        try {
            stream = conn.getInputStream();
            response = new java.util.Scanner(stream).useDelimiter("\\A").next();
        } catch (e) {
            response = "nothing"
        }
    }
    var responseInfo = [rc, response];
    return responseInfo;
}

exports.sendTx = function(senderWalletID, destination, amount, isBTCaddress) {
    var n = {
        "n": 1
    }
    var postInfo = JSON.parse(apirequest('POST', root + '/transactions/', JSON.stringify(n))[1]).payload;
    var txID = postInfo[0].id;
    if (isBTCaddress == undefined) {
        var tx = {
            "id": txID, // Unique transaction ID. See docs below.
            "fromAccountID": senderWalletID,
            // Transfer to an RTWire account.
            "toAccountID": destination,

            "value": amount // Value to transfer in Satoshi.
        }
    } else {
        var tx = {
            "id": txID, // Unique transaction ID.
            "fromAccountID": senderWalletID,
            // Transfer to a Bitcoin Address
            "toAddress": destination,

            "value": amount // Value to transfer in Satoshi.
        }
    }
    var TxInfo = apirequest('PUT', root + '/transactions/', JSON.stringify(tx))
    return TxInfo;
}

exports.getNewAccount = function() {
    var req = apirequest('POST', root + '/accounts/')
    var AccountID = JSON.parse(req[1]).payload[0].id;
    return AccountID;
}

exports.getNewBtcAddress = function(accountID) {
    var req = apirequest('POST', root + '/accounts/' + accountID.toString() + '/addresses/')
    var btcAddress = JSON.parse(req[1]).payload[0].address;
    return btcAddress;
}

exports.updateBalance = function(player) {
    var alldata = scload('serverdb.json');
    var playerUUID = player.uniqueId;
    var AccountID = alldata.wallets[playerUUID].AccountID;
    var req = apirequest('GET', root + '/accounts/' + AccountID.toString())
    var newBalance = JSON.parse(req[1]).payload[0].balance / 100;
    return newBalance;
}

commando('send', function(args, player) {
    var alldata = scload('serverdb.json');
    var amount = parseInt(args[0]);
    var sender = player;
    var senderAccountID = alldata.wallets[sender.uniqueId].AccountID;
    var receiverparam = args[1] //playername or btcAddress

    var pReceiver = Bukkit.getServer().getPlayer(receiverparam);
    if (pReceiver != null && pReceiver != sender) {
        var receiverAccountID = alldata.wallets[pReceiver.uniqueId].AccountID;
        echo(sender, "Sending...".yellow())
        var sendInfo = sendTx(senderAccountID, receiverAccountID, amount * 100);
        if (sendInfo[0] == 201 || sendInfo[0] == 200) {
            newBalanceofSender = updateBalance(sender);
            newBalanceofReceiver = updateBalance(pReceiver);
            updateScoreboard(sender, newBalanceofSender);
            updateScoreboard(pReceiver, newBalanceofReceiver);
            echo(sender, "You sent ".green() + amount.toString() + " bits to " + receiverparam + ".");
            echo(pReceiver, "".green() + player.getName() + " sent you " + amount.toString() + " bit(s).");
        } else {
            echo(sender, "Transaction Failed.".red())
        }
    } else {
        echo(player, "Player not found.".red())
    }
});
/* //TRANSFER TO EXTERNAL WALLET IS NOT WORKING YET
commando('transfer', function(args, player) {
    var alldata = scload('serverdb.json');
    var amount = parseInt(args[0]);
    var sender = player;
    var senderAccountID = alldata.wallets[sender.uniqueId].AccountID;
    var receiverparam = args[1] //playername or btcAddress
    var pReceiver = Bukkit.getServer().getPlayer(receiverparam);
    if (pReceiver != null && pReceiver != sender) {
        var receiverBTCaddress = alldata.wallets[pReceiver.uniqueId].BTCaddress;
        echo(sender, "Sending...".yellow())
        var sendInfo = sendTx(senderAccountID, receiverBTCaddress, amount * 100, true);
        if (sendInfo[0] == 201) {
            echo(sender, "You sent ".green() + amount.toString() + " bits to " + receiverparam + ".");
            echo(pReceiver, "".green() + player.getName() + " sent you " + amount.toString() + " bit(s).");
        } else {
            echo(sender, "Transaction Failed. Remember there is a fee of 100 bits.".red())
        }
    } else {
        echo(player, "Player not found.".red())
    }

});
*/

commando('bithelp', function(args, player) {
    var alldata = scload('serverdb.json');
    echo(player, "Your deposit bitcoin address is: https://blockchain.info/address/".gold() + alldata.wallets[player.uniqueId].BTCaddress)
    echo(player, "Use /send [amount] [player name] to send bits to online players without fees.")
    echo(player, "Use /transfer [amount] [bitcoin address] to transfer bits to external wallet.");
    echo(player, "Players must pay the miner fee to transfer out.");
});
<|endoftext|>


<commit_before>import React from 'react';;
import { NavLink } from 'fluxible-router';
import { Grid, Divider, Button, Image, Icon } from 'semantic-ui-react';

import { connectToStores } from 'fluxible-addons-react';
import DeckListStore from '../../stores/DeckListStore';
import DeckViewStore from '../../stores/DeckViewStore';
import ContentLikeStore from '../../stores/ContentLikeStore';
import ContentModulesStore from '../../stores/ContentModulesStore';

import CustomDate from './util/CustomDate';
import { getLanguageName, isEmpty } from '../../common';
import { Microservices } from '../../configs/microservices';

import ReportModal from '../Report/ReportModal';
import TagList from './ContentModulesPanel/TagsPanel/TagList';
import PresentationPanel from './InfoPanel/PresentationsPanel';
import ActivityFeedPanel from './ActivityFeedPanel/ActivityFeedPanel';

class DeckLandingPage extends React.Component {

    render() {
        const deckData = this.props.DeckViewStore.deckData;
        if(!deckData.variants)
            deckData.variants = [];

        const owner = this.props.DeckViewStore.ownerData;
        const creator = this.props.DeckViewStore.creatorData;

        let interestedInDecks = 'No decks to show';
        if(this.props.DeckListStore.featured && this.props.DeckListStore.featured.length >= 1)
            interestedInDecks =  this.props.DeckListStore.featured.map((deck, i) => {
                return <Grid.Column key={i} width={5}><NavLink href={`/deck/${deck._id}`}><Image src={`${Microservices.file.uri}/thumbnail/slide/${deck.firstSlide}`} bordered />
{deck.title}
</NavLink></Grid.Column>;
            });
        interestedInDecks = <Grid stackable> {interestedInDecks} </Grid>;

        return (

              <Divider hidden/>
              <Grid divided='vertically' stackable>
                <Grid.Column mobile={16} tablet={1} computer={2}>
                </Grid.Column>
                <Grid.Column mobile={16} tablet={10} computer={9}>
                  <Grid.Row>
                  <Grid stackable>
                    <Grid.Column width={5}>
                      <Image src={`${Microservices.file.uri}/thumbnail/slide/${deckData.firstSlide}`} bordered size='medium' spaced as='a' href={'/deck/' + deckData._id + '-' + deckData.revision}/>
                    </Grid.Column>
                    <Grid.Column width={11}>

{deckData.title}

                        Owner: <NavLink href={'/user/' + owner.username}>{owner.displayName || owner.username}</NavLink>

                        Original Author: <NavLink href={'/user/' + creator.username}>{creator.displayName || creator.username}</NavLink> (in ???)

                        Last modified: {CustomDate.format(deckData.lastUpdate, 'Do MMMM YYYY')}

                        Description: {deckData.description}

                        Language: {getLanguageName(deckData.language)}

                        Topic: <NavLink href='#'>???</NavLink> / <NavLink href='#'>???</NavLink>

                    </Grid.Column>
                  </Grid>
                  <Divider hidden/>
                  </Grid.Row>
                  <Divider />
                  <Grid.Row>
                    <Grid stackable divided>
                      <Grid.Column width={8}>

More Information

                      Audience: <NavLink href='#'>???</NavLink>

                      Resource Type: ???

                      Created: {CustomDate.format(deckData.timestamp, 'Do MMMM YYYY')}

                      Accessibility Information:
                        <Icon name='star'/>
                        <Icon name='star'/>
                        <Icon name='star half'/>
                        <Icon name='star outline'/>
                        <Icon name='star outline'/> ???

                      Other languages available: {
                        deckData.variants.map((variant, key) => {
                            return <NavLink href={'/deck/' + deckData._id + '-' + deckData.revision + '?language=' + variant.language}>{getLanguageName(variant.language)}</NavLink> (???%),;
                        })
                      }

                      </Grid.Column>
                      <Grid.Column width={8}>

Contains

                        Slides: {this.props.DeckViewStore.slidesData.children.length}

                        Sources: {this.props.ContentModulesStore.moduleCount.datasource}

                        Questions: {this.props.ContentModulesStore.moduleCount.questions}

                        Comments: {this.props.ContentModulesStore.moduleCount.comments}

                        Contributors: {deckData.contributors.length - 1}

                        <NavLink href='#'>
Other versions available ???
</NavLink>
                      </Grid.Column>
                    </Grid>
                  </Grid.Row>
                  <Divider />
                  <Grid.Row>

Tags:

                    {(deckData.tags.length === 0) ?
There are currently no tags.
 : <TagList items={deckData.tags} editable={false}/>}
                  </Grid.Row>
                  <Divider />
                  <Grid.Row>

You may also be interested in:

                    {interestedInDecks}
                    {/*<Icon name='chevron circle right' size='huge' link/>*/}
                  </Grid.Row>
                </Grid.Column>

                <Grid.Column mobile={16} tablet={4} computer={3}>
                  <Grid.Row>
                    <NavLink href={'/deck/' + deckData._id + '-' + deckData.revision}><Button basic fluid icon labelPosition='left' color='grey'><Icon name='folder open' color='yellow'/>Open Deck</Button></NavLink>

                    <Button basic fluid icon labelPosition='left' color='grey'><Icon name='play circle' color='grey'/>Play SlideShow</Button>

                    {/*<NavLink href='#'><Button basic fluid icon labelPosition='left' color='blue'><Icon name='th' color='blue'/>Add to Playlist ???</Button></NavLink>
*/}
                    <PresentationPanel deckPage={true}/>
                  </Grid.Row>
                  <Divider />
                  <Grid.Row>
                    <Button compact color='grey' disabled><Icon name='thumbs up' /> {this.props.ContentLikeStore.usersWhoLikedDeck.length}</Button>
                    <Button compact color='grey' disabled><Icon name='share alternate' /> {deckData.shareCount}</Button>
                    <Button compact color='grey' disabled><Icon name='download' /> {deckData.downloadCount}</Button>
                  </Grid.Row>
                  <Divider />
                  <Grid.Row>
                    <ActivityFeedPanel />
                  </Grid.Row>
                  <Divider />
                  <Grid.Row>
                    <ReportModal id="reportModal" deckpage={true}/>
                  </Grid.Row>
                </Grid.Column>
                <Grid.Column mobile={16} tablet={1} computer={2}>
                </Grid.Column>
              </Grid>

        );
    }
}

DeckLandingPage = connectToStores(DeckLandingPage, [ContentLikeStore, DeckViewStore, ContentModulesStore, DeckListStore], (context, props) => {
    return {
        ContentLikeStore: context.getStore(ContentLikeStore).getState(),
        DeckViewStore: context.getStore(DeckViewStore).getState(),
        ContentModulesStore: context.getStore(ContentModulesStore).getState(),
        DeckListStore : context.getStore(DeckListStore).getState(),
    };
});

export default DeckLandingPage;
<commit_msg>Styling edits to landing page<commit_after>import React from 'react';;
import { NavLink } from 'fluxible-router';
import { Grid, Divider, Button, Image, Icon, Item, Label, Segment } from 'semantic-ui-react';

import { connectToStores } from 'fluxible-addons-react';
import DeckListStore from '../../stores/DeckListStore';
import DeckViewStore from '../../stores/DeckViewStore';
import ContentLikeStore from '../../stores/ContentLikeStore';
import ContentModulesStore from '../../stores/ContentModulesStore';

import CustomDate from './util/CustomDate';
import { getLanguageName, isEmpty } from '../../common';
import { Microservices } from '../../configs/microservices';

import ReportModal from '../Report/ReportModal';
import TagList from './ContentModulesPanel/TagsPanel/TagList';
import PresentationPanel from './InfoPanel/PresentationsPanel';
import ActivityFeedPanel from './ActivityFeedPanel/ActivityFeedPanel';

class DeckLandingPage extends React.Component {

    render() {
        const deckData = this.props.DeckViewStore.deckData;
        if(!deckData.variants)
            deckData.variants = [];

        const owner = this.props.DeckViewStore.ownerData;
        const creator = this.props.DeckViewStore.creatorData;

        let interestedInDecks = 'No decks to show';
        if(this.props.DeckListStore.featured && this.props.DeckListStore.featured.length >= 1)
            interestedInDecks =  this.props.DeckListStore.featured.map((deck, i) => {
                return <Grid.Column key={i} width={5}><NavLink href={`/deck/${deck._id}`}><Image src={`${Microservices.file.uri}/thumbnail/slide/${deck.firstSlide}`} bordered />
{deck.title}
</NavLink></Grid.Column>;
            });
        interestedInDecks = <Grid stackable> {interestedInDecks} </Grid>;

        return (

              <Divider hidden/>
              <Grid divided='vertically' stackable>
                <Grid.Column mobile={16} tablet={1} computer={2}>
                </Grid.Column>
                <Grid.Column mobile={16} tablet={10} computer={9}>
                  <Grid.Row>
                  <Grid stackable>
                        <Grid.Column width={5}>
                            <Image src={`${Microservices.file.uri}/thumbnail/slide/${deckData.firstSlide}`} bordered size='medium' spaced as='a' href={'/deck/' + deckData._id + '-' + deckData.revision} aria-hidden='true'/>
                        </Grid.Column>
                        <Grid.Column width={11}>
                         <Item>
                             <Item.Content>
                            <Item.Header as="h2">{deckData.title + ' '}
                                Published
                            </Item.Header>
                            <Item.Meta>Owner: <NavLink href={'/user/' + owner.username}>{owner.displayName || owner.username}</NavLink></Item.Meta>
                            <Item.Meta>Original Author: <NavLink href={'/user/' + creator.username}>{creator.displayName || creator.username}</NavLink></Item.Meta>
                            <Item.Meta>Last modified: {CustomDate.format(deckData.lastUpdate, 'Do MMMM YYYY')}</Item.Meta>
                            <Item.Meta>Description:</Item.Meta>
                            <Item.Description>{deckData.description}></Item.Description>
                        </Item.Content>
                      </Item>
                     </Grid.Column>
                  </Grid>
                  </Grid.Row>
{/*<Grid.Row>
                    <Grid stackable divided>
                      <Grid.Column width={8}>

More Information

                      Audience: <NavLink href='#'>???</NavLink>

                      Resource Type: ???

                      Created: {CustomDate.format(deckData.timestamp, 'Do MMMM YYYY')}

                      Accessibility Information:
                        <Icon name='star'/>
                        <Icon name='star'/>
                        <Icon name='star half'/>
                        <Icon name='star outline'/>
                        <Icon name='star outline'/> ???

                      Other languages available: {
                        deckData.variants.map((variant, key) => {
                            return <NavLink href={'/deck/' + deckData._id + '-' + deckData.revision + '?language=' + variant.language}>{getLanguageName(variant.language)}</NavLink> (???%),;
                        })
                      }

                      </Grid.Column>
                      <Grid.Column width={8}>

Contains

                        Slides: {this.props.DeckViewStore.slidesData.children.length}

                        Sources: {this.props.ContentModulesStore.moduleCount.datasource}

                        Questions: {this.props.ContentModulesStore.moduleCount.questions}

                        Comments: {this.props.ContentModulesStore.moduleCount.comments}

                        Contributors: {deckData.contributors.length - 1}

                        <NavLink href='#'>
Other versions available ???
</NavLink>
                      </Grid.Column>
                    </Grid>
                  </Grid.Row>
             <Divider />
*/}
                    <Divider hidden />
                  <Grid.Row>

Tags:

                    {(deckData.tags.length === 0) ?
There are currently no tags.
 : <TagList items={deckData.tags} editable={false}/>}
                  </Grid.Row>
                  <Grid.Row>
                      <Divider hidden />

Languages:

                    {(deckData.tags.length === 0) ?
There are currently no tags.
 : <TagList items={deckData.tags} editable={false}/>}
                  </Grid.Row>

                  <Divider  />
                  <Grid.Row>

You may also be interested in:

                    {interestedInDecks}
                    {/*<Icon name='chevron circle right' size='huge' link/>*/}
                  </Grid.Row>
                </Grid.Column>

                <Grid.Column mobile={16} tablet={4} computer={3}>
                  <Grid.Row>
                     <Grid.Row>
                    <NavLink href={'/deck/' + deckData._id + '-' + deckData.revision}><Button fluid icon basic labelPosition='left' size='large' ><Icon name='folder open' color='yellow'/>Open Deck</Button></NavLink>
                    <Button basic fluid icon labelPosition='left' size='large' ><Icon name='play circle' color='grey'/>Play SlideShow</Button>
                    {/*<NavLink href='#'><Button basic fluid icon labelPosition='left' color='blue'><Icon name='th' color='blue'/>Add to Playlist ???</Button></NavLink>
*/}
                    <PresentationPanel deckPage={true}/>
                  </Grid.Row>

                  </Grid.Row>
                  <Divider />
                  <Grid.Row>
                    <Button compact color='grey' disabled><Icon name='thumbs up' /> {this.props.ContentLikeStore.usersWhoLikedDeck.length}</Button>
                    <Button compact color='grey' disabled><Icon name='share alternate' /> {deckData.shareCount}</Button>
                    <Button compact color='grey' disabled><Icon name='download' /> {deckData.downloadCount}</Button>
                  </Grid.Row>
                  <Divider />
                  <Grid.Row>
                    <ActivityFeedPanel />
                  </Grid.Row>
                  <Divider />

                  <Grid.Row>
                    <Segment>
                      <Image alt='Creative Commons License' src='https://i.creativecommons.org/l/by-sa/4.0/88x31.png' as='a' />
                        This work is licensed under a LINK Creative Commons Attribution-ShareAlike 4.0 International License
                      </Segment>
                    </Grid.Row>
                     <Grid.Row>
                    <ReportModal id="reportModal" deckpage={true}/>
                  </Grid.Row>
                </Grid.Column>
                <Grid.Column mobile={16} tablet={1} computer={2}>
                </Grid.Column>
              </Grid>

        );
    }
}

DeckLandingPage = connectToStores(DeckLandingPage, [ContentLikeStore, DeckViewStore, ContentModulesStore, DeckListStore], (context, props) => {
    return {
        ContentLikeStore: context.getStore(ContentLikeStore).getState(),
        DeckViewStore: context.getStore(DeckViewStore).getState(),
        ContentModulesStore: context.getStore(ContentModulesStore).getState(),
        DeckListStore : context.getStore(DeckListStore).getState(),
    };
});

export default DeckLandingPage;
<|endoftext|>


<commit_before>#!/usr/bin/env node

// This file is a shim to execute the bazel binary from the right platform-specific package.
const os = require('os');
const fs = require('fs');
const path = require('path');
const spawnSync = require('child_process').spawnSync;

const warnGlobalInstall = `
  *** WARNING
    The Bazel binary is being run from a global install.

    This means the version may not match the one used in your project.
    We recommend installing the @bazel/bazel package locally in your project.
  ***
  `;

/**
 * @returns the native `bazel` binary for the current platform
 * @throws when the `bazel` executable can not be found
 */
function getNativeBinary() {
  const platform = [os.platform(), os.arch()].join('_');
  const platformPackageJson = `@bazel/bazel-${platform}/package.json`;
  let nativePackage;
  try {
    // First, look for the package locally installed under the current working directory
    nativePackage = require.resolve(platformPackageJson, {paths: [process.cwd()]});
  } catch (e) {
    if (e.code !== 'MODULE_NOT_FOUND') {
      // rethrow other errors
      throw e;
    }
    try {
      // Fall back to resolving the package anywhere, but if it succeeds, warn the user that we
      // don't recommend relying on a global installation.
      nativePackage = require.resolve(platformPackageJson);
      console.error(warnGlobalInstall);
    } catch (e) {
      if (e.code !== 'MODULE_NOT_FOUND') {
        // rethrow other errors
        throw e;
      }
      // Give up on resolving the correct package anywhere
      console.error(
          `FATAL: Bazel has not published an executable for your platform. (${platform})\n` +
          'Consider installing it following instructions at https://bazel.build instead.\n');
      process.exit(1);
    }
  }

  const binary = JSON.parse(fs.readFileSync(nativePackage))['bin']['bazel'];
  return path.resolve(path.dirname(nativePackage), binary);
}

if (require.main === module) {
  /** Starts a new synchronous child process that runs Bazel with the specified arguments. */
  const bazelProcess = spawnSync(getNativeBinary(), process.argv.slice(2), {stdio: 'inherit'});

  // Ensure that this wrapper script exits with the same exit code as the child process.
  process.exit(bazelProcess.status);
}

module.exports = {
  getNativeBinary,
};
<commit_msg>Remove detection logic for warning on global bazel (#801)<commit_after>#!/usr/bin/env node

// This file is a shim to execute the bazel binary from the right platform-specific package.
const os = require('os');
const fs = require('fs');
const path = require('path');
const spawnSync = require('child_process').spawnSync;

/**
 * @returns the native `bazel` binary for the current platform
 * @throws when the `bazel` executable can not be found
 */
function getNativeBinary() {
  const platform = [os.platform(), os.arch()].join('_');
  const platformPackageJson = `@bazel/bazel-${platform}/package.json`;
  let nativePackage;
  try {
    nativePackage = require.resolve(platformPackageJson);
  } catch (e) {
    if (e.code !== 'MODULE_NOT_FOUND') {
      // rethrow other errors
      throw e;
    }
    throw new Error(
        `FATAL: Bazel has not published an executable for your platform (${platform})\n` +
        'Consider installing it following instructions at https://bazel.build instead.\n');
  }

  const binary = JSON.parse(fs.readFileSync(nativePackage))['bin']['bazel'];
  return path.resolve(path.dirname(nativePackage), binary);
}

if (require.main === module) {
  /** Starts a new synchronous child process that runs Bazel with the specified arguments. */
  const bazelProcess = spawnSync(getNativeBinary(), process.argv.slice(2), {stdio: 'inherit'});

  // Ensure that this wrapper script exits with the same exit code as the child process.
  process.exit(bazelProcess.status);
}

module.exports = {
  getNativeBinary,
};
<|endoftext|>


<commit_before>/*
Name:             bolcom.js
Description:      Module for node.js to access Bol.com Open API service.
Author:           Franklin van de Meent (https://frankl.in)
Source:           https://github.com/fvdm/nodejs-bolcom
Bugs & feedback:  https://github.com/fvdm/nodejs-bolcom/issues
License:          Unlicense / Public Domain

Service name:     Bol.com
Service docs:     https://developers.bol.com
*/

var https = require('https')
var api_key = null
var api_timeout = 5000

var app = {
  catalog: {},
  utils: {},
  account: {}
}

// Communicate
function talk( cat, method, params, callback ) {
  if( typeof params === 'function' ) {
    var callback = params
    var params = {}
  }
  params = params instanceof Object ? params : {}

  // check api key
  if( typeof api_key === 'string' && api_key.length > 0 ) {
    params.apikey = api_key
  } else {
    doCallback( new Error('missing apikey') )
    return
  }

  // prevent multiple callbacks
  var complete = false
  function doCallback( err, data ) {
    if( !complete ) {
      complete = true
      callback( err, data || null )
    }
  }

  // build request
  params.format = 'json'

  var options = {
    host: 'api.bol.com',
    path: '/'+ cat +'/v4/'+ method +'?'+ querystring.stringify(params),
    method: 'GET',
    headers: {
      'User-Agent': 'bolcom.js (https://frankl.in)'
    }
  }

  var request = https.request(options)

  // process response
  request.on( 'response', function(response) {
    var data = ''

    response.on( 'data', function(ch) { data += ch })

    response.on( 'close', function() {
      doCallback(new Error('request dropped'))
    })

    response.on( 'end', function() {
      var error = null
      if( response.statusCode != 200 ) {
        error = new Error('API error')
      }

      try {
        data = JSON.parse( data )
      } catch(e) {
        error = new Error('invalid response')
        error.err = e
      }

      if( error ) {
        error.code = response.statusCode
        error.headers = response.headers
        error.api = data instanceof Object ? data : {}
        error.body = data instanceof Object ? null : data
      }

      doCallback( error, data )
    })
  })

  // timeout
  request.on( 'socket', function( socket ) {
    if( api_timeout ) {
      socket.setTimeout( api_timeout )
      socket.on( 'timeout', function() {
        request.abort()
      })
    }
  })

  // error
  request.on( 'error', function( err ) {
    if( err == 'ECONNRESET' ) {
      var error = new Error('request timeout')
    } else {
      var error = new Error('request failed')
    }
    error.err = err
    doCallback( error )
  })

  // do it
  request.end()
}

module.exports = function(apikey, timeout) {
  api_key = apikey
  api_timeout = timeout || api_timeout
  return app
}<commit_msg>Added missing querystring loading<commit_after>/*
Name:             bolcom.js
Description:      Module for node.js to access Bol.com Open API service.
Author:           Franklin van de Meent (https://frankl.in)
Source:           https://github.com/fvdm/nodejs-bolcom
Bugs & feedback:  https://github.com/fvdm/nodejs-bolcom/issues
License:          Unlicense / Public Domain

Service name:     Bol.com
Service docs:     https://developers.bol.com
*/

var https = require('https')
var querystring = require('querystring')
var api_key = null
var api_timeout = 5000

var app = {
  catalog: {},
  utils: {},
  account: {}
}

// Communicate
function talk( cat, method, params, callback ) {
  if( typeof params === 'function' ) {
    var callback = params
    var params = {}
  }
  params = params instanceof Object ? params : {}

  // check api key
  if( typeof api_key === 'string' && api_key.length > 0 ) {
    params.apikey = api_key
  } else {
    doCallback( new Error('missing apikey') )
    return
  }

  // prevent multiple callbacks
  var complete = false
  function doCallback( err, data ) {
    if( !complete ) {
      complete = true
      callback( err, data || null )
    }
  }

  // build request
  params.format = 'json'

  var options = {
    host: 'api.bol.com',
    path: '/'+ cat +'/v4/'+ method +'?'+ querystring.stringify(params),
    method: 'GET',
    headers: {
      'User-Agent': 'bolcom.js (https://frankl.in)'
    }
  }

  var request = https.request(options)

  // process response
  request.on( 'response', function(response) {
    var data = ''

    response.on( 'data', function(ch) { data += ch })

    response.on( 'close', function() {
      doCallback(new Error('request dropped'))
    })

    response.on( 'end', function() {
      var error = null
      if( response.statusCode != 200 ) {
        error = new Error('API error')
      }

      try {
        data = JSON.parse( data )
      } catch(e) {
        error = new Error('invalid response')
        error.err = e
      }

      if( error ) {
        error.code = response.statusCode
        error.headers = response.headers
        error.api = data instanceof Object ? data : {}
        error.body = data instanceof Object ? null : data
      }

      doCallback( error, data )
    })
  })

  // timeout
  request.on( 'socket', function( socket ) {
    if( api_timeout ) {
      socket.setTimeout( api_timeout )
      socket.on( 'timeout', function() {
        request.abort()
      })
    }
  })

  // error
  request.on( 'error', function( err ) {
    if( err == 'ECONNRESET' ) {
      var error = new Error('request timeout')
    } else {
      var error = new Error('request failed')
    }
    error.err = err
    doCallback( error )
  })

  // do it
  request.end()
}

module.exports = function(apikey, timeout) {
  api_key = apikey
  api_timeout = timeout || api_timeout
  return app
}<|endoftext|>


<commit_before>/* jshint node: true */

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'dummy',
    environment: environment,
    baseURL: '/',
    locationType: 'auto',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      }
    },

    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    },

    emberSmartBanner: {
      title: 'App Title',
      description: 'Description',
      linkText: 'Link Text',
    }
  };

  if (environment === 'development') {
    // ENV.APP.LOG_RESOLVER = true;
    // ENV.APP.LOG_ACTIVE_GENERATION = true;
    // ENV.APP.LOG_TRANSITIONS = true;
    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
    // ENV.APP.LOG_VIEW_LOOKUPS = true;
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.baseURL = '/';
    ENV.locationType = 'none';

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;

    ENV.APP.rootElement = '#ember-testing';
  }

  if (environment === 'production') {

  }

  return ENV;
};
<commit_msg>add defaults to config environment<commit_after>/* jshint node: true */

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'dummy',
    environment: environment,
    baseURL: '/',
    locationType: 'auto',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      }
    },

    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    },

    emberSmartBanner: {
      title: 'App Title',
      description: 'Description',
      linkText: 'Link Text',
      iOS: true,
      appIdIOS: '123',
      appStoreLanguage: 'en'
    }
  };

  if (environment === 'development') {
    // ENV.APP.LOG_RESOLVER = true;
    // ENV.APP.LOG_ACTIVE_GENERATION = true;
    // ENV.APP.LOG_TRANSITIONS = true;
    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
    // ENV.APP.LOG_VIEW_LOOKUPS = true;
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.baseURL = '/';
    ENV.locationType = 'none';

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;

    ENV.APP.rootElement = '#ember-testing';
  }

  if (environment === 'production') {

  }

  return ENV;
};
<|endoftext|>


<commit_before>/* eslint-env node */

module.exports = function(environment) {
  const ENV = {
    modulePrefix: 'dummy',
    environment,
    rootURL: '/',
    locationType: 'auto',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      },
      EXTEND_PROTOTYPES: {
        // Prevent Ember Data from overriding Date.parse.
        Date: false
      }
    },

    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    }
  };

  if (environment === 'development') {
    // ENV.APP.LOG_RESOLVER = true;
    // ENV.APP.LOG_ACTIVE_GENERATION = true;
    // ENV.APP.LOG_TRANSITIONS = true;
    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
    // ENV.APP.LOG_VIEW_LOOKUPS = true;
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.locationType = 'none';

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;

    ENV.APP.rootElement = '#ember-testing';
  }

  if (environment === 'production') {
    ENV.locationType = 'hash';
  }

  return ENV;
};
<commit_msg>Add back rootURL<commit_after>/* eslint-env node */

module.exports = function(environment) {
  const ENV = {
    modulePrefix: 'dummy',
    environment,
    rootURL: '/',
    locationType: 'auto',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      },
      EXTEND_PROTOTYPES: {
        // Prevent Ember Data from overriding Date.parse.
        Date: false
      }
    },

    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    }
  };

  if (environment === 'development') {
    // ENV.APP.LOG_RESOLVER = true;
    // ENV.APP.LOG_ACTIVE_GENERATION = true;
    // ENV.APP.LOG_TRANSITIONS = true;
    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
    // ENV.APP.LOG_VIEW_LOOKUPS = true;
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.locationType = 'none';

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;

    ENV.APP.rootElement = '#ember-testing';
  }

  if (environment === 'production') {
    ENV.locationType = 'hash';
    ENV.rootURL = '/ember-math-helpers/';
  }

  return ENV;
};
<|endoftext|>


<commit_before>/* jshint node: true */

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'dummy',
    environment: environment,
    baseURL: '/',
    locationType: 'auto',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      }
    },
    contentSecurityPolicy: {
      'default-src': "'none'",
      'script-src': "'self' maxcdn.bootstrapcdn.com",
      'font-src': "'self' fonts.gstatic.com maxcdn.bootstrapcdn.com",
      'connect-src': "'self'",
      'img-src': "'self'",
      'style-src': "'self' 'unsafe-inline' fonts.googleapis.com maxcdn.bootstrapcdn.com",
      'media-src': "'self'"
    },
    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    }
  };

  if (environment === 'development') {
    // ENV.APP.LOG_RESOLVER = true;
    // ENV.APP.LOG_ACTIVE_GENERATION = true;
    // ENV.APP.LOG_TRANSITIONS = true;
    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
    // ENV.APP.LOG_VIEW_LOOKUPS = true;
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.baseURL = '/';
    ENV.locationType = 'none';

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;

    ENV.APP.rootElement = '#ember-testing';
  }

  if (environment === 'production') {

  }

  return ENV;
};
<commit_msg>updated baseURL for prod<commit_after>/* jshint node: true */

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'dummy',
    environment: environment,
    baseURL: '/',
    locationType: 'auto',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      }
    },
    contentSecurityPolicy: {
      'default-src': "'none'",
      'script-src': "'self' maxcdn.bootstrapcdn.com",
      'font-src': "'self' fonts.gstatic.com maxcdn.bootstrapcdn.com",
      'connect-src': "'self'",
      'img-src': "'self'",
      'style-src': "'self' 'unsafe-inline' fonts.googleapis.com maxcdn.bootstrapcdn.com",
      'media-src': "'self'"
    },
    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    }
  };

  if (environment === 'development') {
    // ENV.APP.LOG_RESOLVER = true;
    // ENV.APP.LOG_ACTIVE_GENERATION = true;
    // ENV.APP.LOG_TRANSITIONS = true;
    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
    // ENV.APP.LOG_VIEW_LOOKUPS = true;
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.baseURL = '/';
    ENV.locationType = 'none';

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;

    ENV.APP.rootElement = '#ember-testing';
  }

  if (environment === 'production') {
    ENV.baseURL = '/ember-sortable-table';
  }

  return ENV;
};
<|endoftext|>


<commit_before>/* jshint node: true */

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'dummy',
    environment: environment,
    baseURL: '/',
    locationType: 'auto',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      }
    },

    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    },

    tml:{
      key: "YOUR TREX KEY",
      token: "YOUR TREX TOKEN",
    }

  };

  if (environment === 'development') {
    // ENV.APP.LOG_RESOLVER = true;
    // ENV.APP.LOG_ACTIVE_GENERATION = true;
    // ENV.APP.LOG_TRANSITIONS = true;
    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
    // ENV.APP.LOG_VIEW_LOOKUPS = true;
    ENV.contentSecurityPolicy = {
      'default-src' : "'none'",
      'script-src'  : "'self' 'unsafe-inline' 'unsafe-eval' *",
      'font-src'    : "'self' data: use.typekit.net",
      'connect-src' : "'self' *",
      'img-src'     : "'self' *",
      'style-src'   : "'self' 'unsafe-inline' use.typekit.net",
      'frame-src'   : "*"
    }
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.baseURL = '/';
    ENV.locationType = 'none';

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;

    ENV.APP.rootElement = '#ember-testing';
  }

  if (environment === 'production') {

  }

  return ENV;
};
<commit_msg>fix for deprecation warning<commit_after>/* jshint node: true */

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'dummy',
    environment: environment,
    baseURL: '/',
    locationType: 'auto',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      }
    },

    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    },

    tml:{
      key: "YOUR TREX KEY",
      token: "YOUR TREX TOKEN"
    }

  };

  if (environment === 'development') {
    // ENV.APP.LOG_RESOLVER = true;
    // ENV.APP.LOG_ACTIVE_GENERATION = true;
    // ENV.APP.LOG_TRANSITIONS = true;
    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
    // ENV.APP.LOG_VIEW_LOOKUPS = true;
    ENV.contentSecurityPolicy = {
      'default-src' : "'none'",
      'script-src'  : "'self' 'unsafe-inline' 'unsafe-eval' *",
      'font-src'    : "'self' data: use.typekit.net",
      'connect-src' : "'self' *",
      'img-src'     : "'self' *",
      'style-src'   : "'self' 'unsafe-inline' use.typekit.net",
      'frame-src'   : "*"
    }
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.baseURL = '/';
    ENV.locationType = 'none';

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;

    ENV.APP.rootElement = '#ember-testing';
  }

  if (environment === 'production') {

  }

  return ENV;
};
<|endoftext|>


<commit_before>/* eslint-env node */
module.exports = function (environment) {
  var ENV = {
    modulePrefix: 'dummy',
    environment: environment,
    locationType: 'hash',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      },
      EXTEND_PROTOTYPES: {
        // Prevent Ember Data from overriding Date.parse.
        Date: false
      }
    },

    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    },

    'ember-cli-notifications': {
      includeFontAwesome: true
    },

    'ember-prop-types': {
      spreadProperty: 'options',
      throwErrors: true,
      validateOnUpdate: true
    }
  }

  if (environment === 'development') {
    // ENV.APP.LOG_RESOLVER = true
    // ENV.APP.LOG_ACTIVE_GENERATION = true
    // ENV.APP.LOG_TRANSITIONS = true
    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true
    // ENV.APP.LOG_VIEW_LOOKUPS = true
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.rootURL = '/'
    ENV.locationType = 'none'

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false
    ENV.APP.LOG_VIEW_LOOKUPS = false

    ENV.APP.rootElement = '#ember-testing'
  }

  if (environment === 'production' || environment === 'pages') {
    ENV.locationType = 'hash'
    ENV.rootURL = '/ember-frost-date-picker'
    ENV.isDemo = true
    ENV['ember-cli-mirage'] = {
      enabled: true
    }
  }

  return ENV
}
<commit_msg>fix /tesets/dummy/config/environment.js<commit_after>/* eslint-env node */
module.exports = function (environment) {
  var ENV = {
    modulePrefix: 'dummy',
    environment: environment,
    rootURL: '/',
    locationType: 'hash',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      },
      EXTEND_PROTOTYPES: {
        // Prevent Ember Data from overriding Date.parse.
        Date: false
      }
    },

    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    },

    'ember-cli-notifications': {
      includeFontAwesome: true
    },

    'ember-prop-types': {
      spreadProperty: 'options',
      throwErrors: true,
      validateOnUpdate: true
    }
  }

  if (environment === 'development') {
    // ENV.APP.LOG_RESOLVER = true
    // ENV.APP.LOG_ACTIVE_GENERATION = true
    // ENV.APP.LOG_TRANSITIONS = true
    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true
    // ENV.APP.LOG_VIEW_LOOKUPS = true
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.locationType = 'none'

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false
    ENV.APP.LOG_VIEW_LOOKUPS = false

    ENV.APP.rootElement = '#ember-testing'
  }

  if (environment === 'production' || environment === 'pages') {
    ENV.locationType = 'hash'
    ENV.rootURL = '/ember-frost-date-picker'
    ENV.isDemo = true
    ENV['ember-cli-mirage'] = {
      enabled: true
    }
  }

  return ENV
}
<|endoftext|>


<commit_before>/* jshint node: true */

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'dummy',
    environment: environment,
    baseURL: '/',
    locationType: 'auto',
    EmberENV: {
      EXTEND_PROTOTYPES: false,
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
        'ember-htmlbars-attribute-syntax': true,
        'ember-htmlbars-inline-if-helper': true,
        'ember-htmlbars-component-generation': true
      }
    },

    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    }
  };

  if (environment === 'development') {
    // ENV.APP.LOG_RESOLVER = true;
    // ENV.APP.LOG_ACTIVE_GENERATION = true;
    // ENV.APP.LOG_TRANSITIONS = true;
    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
    // ENV.APP.LOG_VIEW_LOOKUPS = true;
    ENV.contentSecurityPolicy = {
      'default-src': "'none'",
      'script-src': "'self' 'unsafe-eval'",
      'font-src': "'self'",
      'connect-src': "'self'",
      'img-src': "'self'",
      'style-src': "'self' 'unsafe-inline'",
      'media-src': "'self'"
    }
  }

  // settings for gh-pages
  if (environment === 'production') {
    ENV.location = 'hash';
    ENV.baseURL = '/ember-grid/';
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.baseURL = '/';
    ENV.locationType = 'none';

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;

    ENV.APP.rootElement = '#ember-testing';
  }

  if (environment === 'production') {

  }

  return ENV;
};
<commit_msg>remove angle-bracket feature flags<commit_after>/* jshint node: true */

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'dummy',
    environment: environment,
    baseURL: '/',
    locationType: 'auto',
    EmberENV: {
      EXTEND_PROTOTYPES: false,
      /*
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
        'ember-htmlbars-attribute-syntax': true,
        'ember-htmlbars-inline-if-helper': true,
        'ember-htmlbars-component-generation': true
      }
      */
    },

    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    }
  };

  if (environment === 'development') {
    // ENV.APP.LOG_RESOLVER = true;
    // ENV.APP.LOG_ACTIVE_GENERATION = true;
    // ENV.APP.LOG_TRANSITIONS = true;
    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
    // ENV.APP.LOG_VIEW_LOOKUPS = true;
    ENV.contentSecurityPolicy = {
      'default-src': "'none'",
      'script-src': "'self' 'unsafe-eval'",
      'font-src': "'self'",
      'connect-src': "'self'",
      'img-src': "'self'",
      'style-src': "'self' 'unsafe-inline'",
      'media-src': "'self'"
    }
  }

  // settings for gh-pages
  if (environment === 'production') {
    ENV.location = 'hash';
    ENV.baseURL = '/ember-grid/';
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.baseURL = '/';
    ENV.locationType = 'none';

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;

    ENV.APP.rootElement = '#ember-testing';
  }

  if (environment === 'production') {

  }

  return ENV;
};
<|endoftext|>


<commit_before>/**
 * WordPress dependencies
 */
import { activatePlugin, createURL, visitAdminPage } from '@wordpress/e2e-test-utils';

/**
 * Internal dependencies
 */
import {
	deactivateUtilityPlugins,
	resetSiteKit,
	setSearchConsoleProperty,
	useRequestInterception,
	setAuthToken,
	setSiteVerification,
} from '../utils';

function stubGoogleSignIn( request ) {
	if ( request.url().startsWith( 'https://accounts.google.com/o/oauth2/auth' ) ) {
		request.respond( {
			status: 302,
			headers: {
				location: createURL( '/', 'oauth2callback=1&code=valid-test-code&e2e-site-verification=1' ),
			},
		} );
	} else if ( request.url().match( 'google-site-kit/v1/modules/search-console/data/matched-sites' ) ) {
		request.respond( {
			status: 200,
			contentType: 'application/json',
			body: JSON.stringify( {
				exactMatch: {
					siteURL: process.env.WP_BASE_URL,
				},
			} ),
		} );
	} else {
		request.continue();
	}
}

const disconnectFromSiteKit = async () => {
	await page.waitForSelector( 'button[aria-controls="user-menu"]' );
	await page.click( 'button[aria-controls="user-menu"]' );

	await page.waitForSelector( '#user-menu .mdc-list-item' );
	await page.click( '#user-menu .mdc-list-item' );

	await page.waitForSelector( '.mdc-dialog__container button.mdc-button--danger' );
	await page.click( '.mdc-dialog__container button.mdc-button--danger' );
	await page.waitForNavigation();
};

describe( 'Site Kit set up flow for the first time', () => {
	beforeAll( async () => {
		await setSearchConsoleProperty();
	} );

	beforeEach( async () => {
		await activatePlugin( 'e2e-tests-gcp-credentials-plugin' );
	} );

	afterEach( async () => {
		await deactivateUtilityPlugins();
		await resetSiteKit();
	} );

	it( 'authenticates from splash page', async () => {
		await activatePlugin( 'e2e-tests-oauth-callback-plugin' );
		await visitAdminPage( 'admin.php', 'page=googlesitekit-splash' );
		// Sign in with Google
		await page.setRequestInterception( true );
		useRequestInterception( stubGoogleSignIn );
		await expect( page ).toClick( '.googlesitekit-wizard-step button', { text: /sign in with Google/i } );
		await page.waitForNavigation();

		await expect( page ).toMatchElement( '#js-googlesitekit-dashboard' );
		await expect( page ).toMatchElement( '.googlesitekit-publisher-win__title', { text: /Congrats on completing the setup for Site Kit!/i } );
	} );

	it( 'disconnects user from Site Kit', async () => {
		await setAuthToken();
		await setSiteVerification();
		await setSearchConsoleProperty();
		await visitAdminPage( 'admin.php', 'page=googlesitekit-dashboard' );

		await disconnectFromSiteKit();

		await expect( page ).toMatchElement(
			'.notice-success',
			{ text: /Successfully disconnected from Site Kit by Google./i }
		);
	} );
} );

<commit_msg>update auth-flow assertion<commit_after>/**
 * WordPress dependencies
 */
import { activatePlugin, createURL, visitAdminPage } from '@wordpress/e2e-test-utils';

/**
 * Internal dependencies
 */
import {
	deactivateUtilityPlugins,
	resetSiteKit,
	setSearchConsoleProperty,
	useRequestInterception,
	setAuthToken,
	setSiteVerification,
} from '../utils';

function stubGoogleSignIn( request ) {
	if ( request.url().startsWith( 'https://accounts.google.com/o/oauth2/auth' ) ) {
		request.respond( {
			status: 302,
			headers: {
				location: createURL( '/', 'oauth2callback=1&code=valid-test-code&e2e-site-verification=1' ),
			},
		} );
	} else if ( request.url().match( 'google-site-kit/v1/modules/search-console/data/matched-sites' ) ) {
		request.respond( {
			status: 200,
			contentType: 'application/json',
			body: JSON.stringify( {
				exactMatch: {
					siteURL: process.env.WP_BASE_URL,
				},
			} ),
		} );
	} else {
		request.continue();
	}
}

const disconnectFromSiteKit = async () => {
	await page.waitForSelector( 'button[aria-controls="user-menu"]' );
	await page.click( 'button[aria-controls="user-menu"]' );

	await page.waitForSelector( '#user-menu .mdc-list-item' );
	await page.click( '#user-menu .mdc-list-item' );

	await page.waitForSelector( '.mdc-dialog__container button.mdc-button--danger' );
	await page.click( '.mdc-dialog__container button.mdc-button--danger' );
	await page.waitForNavigation();
};

describe( 'Site Kit set up flow for the first time', () => {
	beforeAll( async () => {
		await setSearchConsoleProperty();
	} );

	beforeEach( async () => {
		await activatePlugin( 'e2e-tests-gcp-credentials-plugin' );
	} );

	afterEach( async () => {
		await deactivateUtilityPlugins();
		await resetSiteKit();
	} );

	it( 'authenticates from splash page', async () => {
		await activatePlugin( 'e2e-tests-oauth-callback-plugin' );
		await visitAdminPage( 'admin.php', 'page=googlesitekit-splash' );
		// Sign in with Google
		await page.setRequestInterception( true );
		useRequestInterception( stubGoogleSignIn );
		await expect( page ).toClick( '.googlesitekit-wizard-step button', { text: /sign in with Google/i } );
		await page.waitForNavigation();

		await expect( page ).toMatchElement( '#js-googlesitekit-dashboard' );
		await expect( page ).toMatchElement( '.googlesitekit-publisher-win__title', { text: /Congrats on completing the setup for Site Kit!/i } );
	} );

	it( 'disconnects user from Site Kit', async () => {
		await setAuthToken();
		await setSiteVerification();
		await setSearchConsoleProperty();
		await visitAdminPage( 'admin.php', 'page=googlesitekit-dashboard' );

		await disconnectFromSiteKit();

		// Ensure the user is on step one of the setup wizard.
		await expect( page ).toMatchElement(
			'.googlesitekit-wizard-progress-step__number-text--inprogress',
			{ text: '1' }
		);
	} );
} );

<|endoftext|>


<commit_before>

export class E2EMails {

    static resetSentMailsDb() {
        server.call('e2e.resetTestMailDB');
    }

    static getAllSentMails() {
        return server.call('e2e.findSentMails');
    }

    /**
     * Returns all recipients of all sent mails
     */
    static getAllRecipients() {
        let mails = E2EMails.getAllSentMails();
        let recipients = [];
        mails.forEach(mail => {
            recipients = recipients.concat(mail.to);
        });
        return recipients;
    }
}<commit_msg>Try to harden E-Mail Tests<commit_after>import {E2EGlobal} from './E2EGlobal';

export class E2EMails {

    static resetSentMailsDb() {
        server.call('e2e.resetTestMailDB');
    }

    static getAllSentMails() {
        E2EGlobal.waitSomeTime(700);
        return server.call('e2e.findSentMails');
    }

    /**
     * Returns all recipients of all sent mails
     */
    static getAllRecipients() {
        let mails = E2EMails.getAllSentMails();
        let recipients = [];
        mails.forEach(mail => {
            recipients = recipients.concat(mail.to);
        });
        return recipients;
    }
}<|endoftext|>