<commit_before>if("undefined"==typeof OGX)var OGX=function(){};OGX.prototype.MobileActivityCalendar=function(t){"use strict";function a(t){return t.hasOwnProperty("originalEvent")?t.originalEvent.changedTouches[0]:t}function i(t){t?$(window).on("resize",function(){var t=$(window).innerWidth(),a=_(G);G.css({transform:"translate3D("+(Number(a[0])-Math.abs(B.width-t))+"px, 0px, 0px)"}),B.width=t,$(".ogx_mobile_activity_calendar_days").css("width",3*B.width),$(".ogx_mobile_activity_calendar_day").css("width",B.width)}):$(window).off("resize")}function e(t){t?G.on(k,function(t){Y=!1,I=0,q=(new Date).getTime(),t=a(t),z.x=t.pageX,z.y=t.pageY+G.parent(0).scrollTop(),e(!1),n(!0),r(!0)}):G.off(k)}function n(t){t?G.on(N,function(t){n(!1),r(!1),F||e(!0)}):G.off(N)}function o(t){t?A.on(N,".ogx_mobile_activity_calendar_block",function(t){if(t=a(t),Math.abs(z.x-t.pageX)<2&&(new Date).getTime()-qMath.abs(t.pageY-z.y)&&(Y=Math.abs(t.pageX-z.x),I=t.pageX-z.x>0?1:-1)})):(c(!1),G.off(S))}function c(t){t?R||(R=setInterval(l,10)):R&&(clearInterval(R),R=null)}function l(){if(Y&&I&&Y>B.minX){L=B.width,L*=I,r(!1),d(!0),e(!1),F=!0,G.addClass("ogx_mobile_activity_anim");var t=_(G);G.css({transform:"translate3D("+(Number(t[0])+L)+"px, 0px, 0px)"})}}function d(t){t?G.on("transitionend",function(t){d(!1),A.trigger(OGX.MobileActivityCalendar.DAY_CHANGE,B.date),G.removeClass("ogx_mobile_activity_anim"),I===-1?h():g(),F=!1,e(!0)}):G.off("transitionend")}function _(t){var a=t.css("-webkit-transform").match(/matrix(?:(3d)\(-{0,1}\d+(?:, -{0,1}\d+)*(?:, (-{0,1}\d+))(?:, (-{0,1}\d+))(?:, (-{0,1}\d+)), -{0,1}\d+\)|\(-{0,1}\d+(?:, -{0,1}\d+)*(?:, (-{0,1}\d+))(?:, (-{0,1}\d+))\))/);return a?"3d"==a[1]?a.slice(2,5):(a.push(0),a.slice(5,8)):[0,0,0]}function s(t,a){var i=t.split(":"),e=Number(i[0]),n=Number(i[1]),o=G.find('.ogx_mobile_activity_calendar_hour[data-hour="'+e+'"]:first').position().top;o+=Math.round(n/60*T);var r=Math.ceil(Number(a.length)/60*T);return{y:o,h:r}}function v(t){var a={};return a.type=t.data("type"),a.category=B.data.categories[a.type],a.label=t.find("span:first").text(),a.start=t.data("start"),a.length=t.data("length"),a}function f(t,a){return Math.max(t.top,a.top)<Math.min(t.bottom,a.bottom)}function y(t,a){var i,e,n,o,r,c,l,d,_,s;if(i=t.find(".ogx_mobile_activity_calendar_grid:first").height(),n=t.children(".ogx_mobile_activity_calendar_content:first"),e=n.children(".ogx_mobile_activity_calendar_stripe").length,e>0)for(var v=0;v<e;v++){if(o=n.children(".ogx_mobile_activity_calendar_stripe:eq("+v+")"),c=o.children(".ogx_mobile_activity_calendar_block").length,s=!0,!(c>0))return o;for(var y=0;y<c;y++)r=o.children(".ogx_mobile_activity_calendar_block:eq("+y+")"),l=r.position().top,d=r.height(),_=f({top:a.y,bottom:a.y+a.h},{top:l,bottom:l+d}),_&&(s=!1);if(s)return o}return n.append('

'),n.children(".ogx_mobile_activity_calendar_stripe:last")}function g(){var t=b(B.date);B.date=t;var a=G.find(".ogx_mobile_activity_calendar_day:last").detach(),i=b(B.date);a.children(".ogx_mobile_activity_calendar_nav:first").text(i.toString().substr(0,15)),a.find(".ogx_mobile_activity_calendar_content:first").empty(),G.prepend(a);var e=u(i);e&&x(e,i.getDay(),G.find(".ogx_mobile_activity_calendar_day:first"));var n=_(G);G.css({transform:"translate3D("+(Number(n[0])-B.width)+"px, 0px, 0px)"})}function h(){var t=m(B.date);B.date=t;var a=G.find(".ogx_mobile_activity_calendar_day:first").detach(),i=m(B.date);a.children(".ogx_mobile_activity_calendar_nav:first").text(i.toString().substr(0,15)),a.find(".ogx_mobile_activity_calendar_content:first").empty(),G.append(a);var e=u(i);e&&x(e,i.getDay(),G.find(".ogx_mobile_activity_calendar_day:last"));var n=_(G);G.css({transform:"translate3D("+(Math.abs(n[0])-B.width)*-1+"px, 0px, 0px)"})}function m(t){var a=new Date(t.toString());return new Date(a.getFullYear(),a.getMonth(),a.getDate()+1)}function b(t){var a=new Date(t.toString());return new Date(a.getFullYear(),a.getMonth(),a.getDate()-1)}function u(t){var a,i;for(var e in B.data.calendar)if(a=e.split("_"),a[0]=new Date(a[0]).getTime(),a[1]=new Date(a[1]).getTime(),i=t.getTime(),i>=a[0]&&i<=a[1])return B.data.calendar[e];return!1}function p(){$(".ogx_mobile_activity_calendar_content").empty();var t=B.date.getDay(),a=u(B.date);if(a){var i,e=t-1;e<0?e=5:null;for(var n=0;n<3;n++)i=A.children(".ogx_mobile_activity_calendar_days:first").children(".ogx_mobile_activity_calendar_day:eq("+n+")"),e++,e>6?e=0:null,x(a,e,i)}P.el.trigger(OGX.MobileActivityCalendar.RENDER)}function x(t,a,i){var e,n,o,r,c;for(var l in t[a])for(var d=0;d<t[a][l].length;d++)o=t[a][l][d],e=s(l,o),r=y(i,e),c=B.data.categories[o.type].color,n='
'+o.label+"
",r.append(n);var _=i.find(".ogx_mobile_activity_calendar_content:first").children(".ogx_mobile_activity_calendar_stripe").length,v=Math.floor(B.width/_);i.find(".ogx_mobile_activity_calendar_content:first").children(".ogx_mobile_activity_calendar_stripe").each(function(t,a){$(a).css("width",v+"px")})}function w(){switch(B.mode){case OGX.MobileActivityCalendar.MODE_MOBILE:k="touchstart",N="touchend",S="touchmove";break;case OGX.MobileActivityCalendar.MODE_DESKTOP:k="mousedown",N="mouseup",S="mousemove"}}function M(){for(var t=0;t<3;t++)O(t)}function D(t,a){switch(a){case 1:t<=12?t+="am":t=t-12+"pm";break;case 2:t<10?t="0"+t:null}return t}function O(t){for(var a,i,e=A.height()-G.find(".ogx_mobile_activity_calendar_nav:first").height(),n=B.day_end-B.day_start+1,o=Math.floor(e/n),r="",c=G.children(".ogx_mobile_activity_calendar_day:eq("+t+")").children(".ogx_mobile_activity_calendar_grid:first"),l=0;l<n;l++)a=B.day_start+l,i=B.ampm?D(a,1):D(a,2),r+='
'+i+"
";c.html(r),T=c.find(".ogx_mobile_activity_calendar_hour:first").height()}function C(){for(var t=A.width(),a=0,i=[b(B.date),B.date,m(B.date)],e='
',n=0;n<3;n++)e+='
',e+='
'+i[n].toString().substr(0,15)+"
",e+='

',e+='

',e+="
",a+=t;e+="
",A.append(e),G=A.find(".ogx_mobile_activity_calendar_days:first"),G.css({transform:"translate3D("+-B.width+"px, 0, 0)"})}function X(){for(var t in H)B.hasOwnProperty(t)||(B[t]=H[t]);B.width=$(B.container).innerWidth(),B.height=$(B.container).innerHeight(),P.el=A=$(B.container),A.addClass("ogx_mobile_activity_calendar ogx_hw")}function E(){X(),w(),C(),M(),B.data&&setTimeout(p,250),e(!0),o(!0),i(!0)}var A,G,T,k,N,S,Y,I,L,R,q,P=this,B=t,H={day_start:6,day_end:21,date:new Date,ampm:!0,data:!1,mode:OGX.MobileActivityCalendar.MODE_MOBILE,minX:60,maxY:5,maxT:100},z={},F=!1;this.el=null,this.setData=function(t){B.data=t,p()},this.destroy=function(){e(!1),n(!1),r(!1),d(!1),i(!1)},E()},OGX.MobileActivityCalendar=function(t){"use strict";return new OGX.prototype.MobileActivityCalendar(t)},OGX.MobileActivityCalendar.MODE_DESKTOP="desktop",OGX.MobileActivityCalendar.MODE_MOBILE="mobile",OGX.MobileActivityCalendar.SELECT="MobileActivityCalendarSelect",OGX.MobileActivityCalendar.DAY_CHANGE="MobileActivityCalendarDayChange",OGX.MobileActivityCalendar.RENDER="MobileActivityCalendarRender";<commit_msg>Fix 12am/pm<commit_after>if("undefined"==typeof OGX)var OGX=function(){};OGX.prototype.MobileActivityCalendar=function(t){"use strict";function a(t){return t.hasOwnProperty("originalEvent")?t.originalEvent.changedTouches[0]:t}function i(t){t?$(window).on("resize",function(){var t=$(window).innerWidth(),a=_(G);G.css({transform:"translate3D("+(Number(a[0])-Math.abs(B.width-t))+"px, 0px, 0px)"}),B.width=t,$(".ogx_mobile_activity_calendar_days").css("width",3*B.width),$(".ogx_mobile_activity_calendar_day").css("width",B.width)}):$(window).off("resize")}function e(t){t?G.on(k,function(t){Y=!1,I=0,q=(new Date).getTime(),t=a(t),z.x=t.pageX,z.y=t.pageY+G.parent(0).scrollTop(),e(!1),n(!0),r(!0)}):G.off(k)}function n(t){t?G.on(N,function(t){n(!1),r(!1),F||e(!0)}):G.off(N)}function o(t){t?A.on(N,".ogx_mobile_activity_calendar_block",function(t){if(t=a(t),Math.abs(z.x-t.pageX)<2&&(new Date).getTime()-qMath.abs(t.pageY-z.y)&&(Y=Math.abs(t.pageX-z.x),I=t.pageX-z.x>0?1:-1)})):(c(!1),G.off(S))}function c(t){t?R||(R=setInterval(l,10)):R&&(clearInterval(R),R=null)}function l(){if(Y&&I&&Y>B.minX){L=B.width,L*=I,r(!1),d(!0),e(!1),F=!0,G.addClass("ogx_mobile_activity_anim");var t=_(G);G.css({transform:"translate3D("+(Number(t[0])+L)+"px, 0px, 0px)"})}}function d(t){t?G.on("transitionend",function(t){d(!1),A.trigger(OGX.MobileActivityCalendar.DAY_CHANGE,B.date),G.removeClass("ogx_mobile_activity_anim"),I===-1?h():g(),F=!1,e(!0)}):G.off("transitionend")}function _(t){var a=t.css("-webkit-transform").match(/matrix(?:(3d)\(-{0,1}\d+(?:, -{0,1}\d+)*(?:, (-{0,1}\d+))(?:, (-{0,1}\d+))(?:, (-{0,1}\d+)), -{0,1}\d+\)|\(-{0,1}\d+(?:, -{0,1}\d+)*(?:, (-{0,1}\d+))(?:, (-{0,1}\d+))\))/);return a?"3d"==a[1]?a.slice(2,5):(a.push(0),a.slice(5,8)):[0,0,0]}function s(t,a){var i=t.split(":"),e=Number(i[0]),n=Number(i[1]),o=G.find('.ogx_mobile_activity_calendar_hour[data-hour="'+e+'"]:first').position().top;o+=Math.round(n/60*T);var r=Math.ceil(Number(a.length)/60*T);return{y:o,h:r}}function v(t){var a={};return a.type=t.data("type"),a.category=B.data.categories[a.type],a.label=t.find("span:first").text(),a.start=t.data("start"),a.length=t.data("length"),a}function f(t,a){return Math.max(t.top,a.top)<Math.min(t.bottom,a.bottom)}function y(t,a){var i,e,n,o,r,c,l,d,_,s;if(i=t.find(".ogx_mobile_activity_calendar_grid:first").height(),n=t.children(".ogx_mobile_activity_calendar_content:first"),e=n.children(".ogx_mobile_activity_calendar_stripe").length,e>0)for(var v=0;v<e;v++){if(o=n.children(".ogx_mobile_activity_calendar_stripe:eq("+v+")"),c=o.children(".ogx_mobile_activity_calendar_block").length,s=!0,!(c>0))return o;for(var y=0;y<c;y++)r=o.children(".ogx_mobile_activity_calendar_block:eq("+y+")"),l=r.position().top,d=r.height(),_=f({top:a.y,bottom:a.y+a.h},{top:l,bottom:l+d}),_&&(s=!1);if(s)return o}return n.append('

'),n.children(".ogx_mobile_activity_calendar_stripe:last")}function g(){var t=b(B.date);B.date=t;var a=G.find(".ogx_mobile_activity_calendar_day:last").detach(),i=b(B.date);a.children(".ogx_mobile_activity_calendar_nav:first").text(i.toString().substr(0,15)),a.find(".ogx_mobile_activity_calendar_content:first").empty(),G.prepend(a);var e=u(i);e&&x(e,i.getDay(),G.find(".ogx_mobile_activity_calendar_day:first"));var n=_(G);G.css({transform:"translate3D("+(Number(n[0])-B.width)+"px, 0px, 0px)"})}function h(){var t=m(B.date);B.date=t;var a=G.find(".ogx_mobile_activity_calendar_day:first").detach(),i=m(B.date);a.children(".ogx_mobile_activity_calendar_nav:first").text(i.toString().substr(0,15)),a.find(".ogx_mobile_activity_calendar_content:first").empty(),G.append(a);var e=u(i);e&&x(e,i.getDay(),G.find(".ogx_mobile_activity_calendar_day:last"));var n=_(G);G.css({transform:"translate3D("+(Math.abs(n[0])-B.width)*-1+"px, 0px, 0px)"})}function m(t){var a=new Date(t.toString());return new Date(a.getFullYear(),a.getMonth(),a.getDate()+1)}function b(t){var a=new Date(t.toString());return new Date(a.getFullYear(),a.getMonth(),a.getDate()-1)}function u(t){var a,i;for(var e in B.data.calendar)if(a=e.split("_"),a[0]=new Date(a[0]).getTime(),a[1]=new Date(a[1]).getTime(),i=t.getTime(),i>=a[0]&&i<=a[1])return B.data.calendar[e];return!1}function p(){$(".ogx_mobile_activity_calendar_content").empty();var t=B.date.getDay(),a=u(B.date);if(a){var i,e=t-1;e<0?e=5:null;for(var n=0;n<3;n++)i=A.children(".ogx_mobile_activity_calendar_days:first").children(".ogx_mobile_activity_calendar_day:eq("+n+")"),e++,e>6?e=0:null,x(a,e,i)}P.el.trigger(OGX.MobileActivityCalendar.RENDER)}function x(t,a,i){var e,n,o,r,c;for(var l in t[a])for(var d=0;d<t[a][l].length;d++)o=t[a][l][d],e=s(l,o),r=y(i,e),c=B.data.categories[o.type].color,n='
'+o.label+"
",r.append(n);var _=i.find(".ogx_mobile_activity_calendar_content:first").children(".ogx_mobile_activity_calendar_stripe").length,v=Math.floor(B.width/_);i.find(".ogx_mobile_activity_calendar_content:first").children(".ogx_mobile_activity_calendar_stripe").each(function(t,a){$(a).css("width",v+"px")})}function w(){switch(B.mode){case OGX.MobileActivityCalendar.MODE_MOBILE:k="touchstart",N="touchend",S="touchmove";break;case OGX.MobileActivityCalendar.MODE_DESKTOP:k="mousedown",N="mouseup",S="mousemove"}}function M(){for(var t=0;t<3;t++)O(t)}function D(t,a){switch(a){case 1:t<=11?t+="am":t=t-12+"pm";break;case 2:t<10?t="0"+t:null}return t}function O(t){for(var a,i,e=A.height()-G.find(".ogx_mobile_activity_calendar_nav:first").height(),n=B.day_end-B.day_start+1,o=Math.floor(e/n),r="",c=G.children(".ogx_mobile_activity_calendar_day:eq("+t+")").children(".ogx_mobile_activity_calendar_grid:first"),l=0;l<n;l++)a=B.day_start+l,i=B.ampm?D(a,1):D(a,2),r+='
'+i+"
";c.html(r),T=c.find(".ogx_mobile_activity_calendar_hour:first").height()}function C(){for(var t=A.width(),a=0,i=[b(B.date),B.date,m(B.date)],e='
',n=0;n<3;n++)e+='
',e+='
'+i[n].toString().substr(0,15)+"
",e+='

',e+='

',e+="
",a+=t;e+="
",A.append(e),G=A.find(".ogx_mobile_activity_calendar_days:first"),G.css({transform:"translate3D("+-B.width+"px, 0, 0)"})}function X(){for(var t in H)B.hasOwnProperty(t)||(B[t]=H[t]);B.width=$(B.container).innerWidth(),B.height=$(B.container).innerHeight(),P.el=A=$(B.container),A.addClass("ogx_mobile_activity_calendar ogx_hw")}function E(){X(),w(),C(),M(),B.data&&setTimeout(p,250),e(!0),o(!0),i(!0)}var A,G,T,k,N,S,Y,I,L,R,q,P=this,B=t,H={day_start:6,day_end:21,date:new Date,ampm:!0,data:!1,mode:OGX.MobileActivityCalendar.MODE_MOBILE,minX:60,maxY:5,maxT:100},z={},F=!1;this.el=null,this.setData=function(t){B.data=t,p()},this.destroy=function(){e(!1),n(!1),r(!1),d(!1),i(!1)},E()},OGX.MobileActivityCalendar=function(t){"use strict";return new OGX.prototype.MobileActivityCalendar(t)},OGX.MobileActivityCalendar.MODE_DESKTOP="desktop",OGX.MobileActivityCalendar.MODE_MOBILE="mobile",OGX.MobileActivityCalendar.SELECT="MobileActivityCalendarSelect",OGX.MobileActivityCalendar.DAY_CHANGE="MobileActivityCalendarDayChange",OGX.MobileActivityCalendar.RENDER="MobileActivityCalendarRender";<|endoftext|>


<commit_before>/*
Copyright 2015 OpenMarket Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

'use strict';

var React = require('react');
var classNames = require('classnames');

var RoomTileController = require('matrix-react-sdk/lib/controllers/molecules/RoomTile')

var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');

var sdk = require('matrix-react-sdk')

module.exports = React.createClass({
    displayName: 'RoomTile',
    mixins: [RoomTileController],

    getInitialState: function() {
        return( { hover : false });
    },

    onMouseEnter: function() {
        this.setState( { hover : true });
    },

    onMouseLeave: function() {
        this.setState( { hover : false });
    },

    render: function() {
        var myUserId = MatrixClientPeg.get().credentials.userId;
        var classes = classNames({
            'mx_RoomTile': true,
            'mx_RoomTile_selected': this.props.selected,
            'mx_RoomTile_unread': this.props.unread,
            'mx_RoomTile_highlight': this.props.highlight,
            'mx_RoomTile_invited': this.props.room.currentState.members[myUserId].membership == 'invite'
        });

        var name;
        if (this.props.isInvite) {
            name = this.props.room.getMember(MatrixClientPeg.get().credentials.userId).events.member.getSender();
        }
        else {
            name = this.props.room.name;
        }

        name = name.replace(":", ":\u200b"); // add a zero-width space to allow linewrapping after the colon
        var badge;
        if (this.props.highlight) {
            badge =
;
        }
        /*
        if (this.props.highlight) {
            badge =
!
;
        }
        else if (this.props.unread) {
            badge =
1
;
        }
        var nameCell;
        if (badge) {
            nameCell =

{name}

{badge}

;
        }
        else {
            nameCell =
{name}
;
        }
        */

        var label;
        if (!this.props.collapsed) {
            var className = 'mx_RoomTile_name' + (this.props.isInvite ? ' mx_RoomTile_invite' : '');
            label =
{name}
;
        }
        else if (this.state.hover) {
            var RoomTooltip = sdk.getComponent("molecules.RoomTooltip");
            label = <RoomTooltip room={this.props.room}/>;
        }

        var RoomAvatar = sdk.getComponent('atoms.RoomAvatar');
        return (

                    <RoomAvatar room={this.props.room} width="24" height="24" />
                    { badge }

                { label }

        );
    }
});
<commit_msg>avoid racey NPE on first login<commit_after>/*
Copyright 2015 OpenMarket Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

'use strict';

var React = require('react');
var classNames = require('classnames');

var RoomTileController = require('matrix-react-sdk/lib/controllers/molecules/RoomTile')

var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');

var sdk = require('matrix-react-sdk')

module.exports = React.createClass({
    displayName: 'RoomTile',
    mixins: [RoomTileController],

    getInitialState: function() {
        return( { hover : false });
    },

    onMouseEnter: function() {
        this.setState( { hover : true });
    },

    onMouseLeave: function() {
        this.setState( { hover : false });
    },

    render: function() {
        var myUserId = MatrixClientPeg.get().credentials.userId;
        var me = this.props.room.currentState.members[myUserId];
        var classes = classNames({
            'mx_RoomTile': true,
            'mx_RoomTile_selected': this.props.selected,
            'mx_RoomTile_unread': this.props.unread,
            'mx_RoomTile_highlight': this.props.highlight,
            'mx_RoomTile_invited': (me && me.membership == 'invite'),
        });

        var name;
        if (this.props.isInvite) {
            name = this.props.room.getMember(MatrixClientPeg.get().credentials.userId).events.member.getSender();
        }
        else {
            name = this.props.room.name;
        }

        name = name.replace(":", ":\u200b"); // add a zero-width space to allow linewrapping after the colon
        var badge;
        if (this.props.highlight) {
            badge =
;
        }
        /*
        if (this.props.highlight) {
            badge =
!
;
        }
        else if (this.props.unread) {
            badge =
1
;
        }
        var nameCell;
        if (badge) {
            nameCell =

{name}

{badge}

;
        }
        else {
            nameCell =
{name}
;
        }
        */

        var label;
        if (!this.props.collapsed) {
            var className = 'mx_RoomTile_name' + (this.props.isInvite ? ' mx_RoomTile_invite' : '');
            label =
{name}
;
        }
        else if (this.state.hover) {
            var RoomTooltip = sdk.getComponent("molecules.RoomTooltip");
            label = <RoomTooltip room={this.props.room}/>;
        }

        var RoomAvatar = sdk.getComponent('atoms.RoomAvatar');
        return (

                    <RoomAvatar room={this.props.room} width="24" height="24" />
                    { badge }

                { label }

        );
    }
});
<|endoftext|>


<commit_before>import React from 'react';
import Relay from 'react-relay';
import Radium from 'radium';
import {LinearProgress} from 'material-ui';

// This just handles rendering and interacting with a BSD survey in an iFrame
@Radium
class BSDSurvey extends React.Component {
  styles = {
    container: {
//      width: '100%',
    },
    progress: {
      width: '50%',
      marginLeft: 'auto',
      marginRight: 'auto',
      marginTop: '30px',
      marginBottom: '30px',
      textAlign: 'center',
    },
    progressHeader: {
      marginBottom: '10px',
    },
    frame: {
      display: 'block',
      border: 'none',
      width: '100%',
      height: 0,
      opacity: 0,
      transition: 'opacity 0.7s',
    }
  }

  static propTypes = {
    onSubmitted : React.PropTypes.func,
  }

  state = {
    frameStyle : {height: 0},
    surveyFields: {}
  }

  submit = () => {
    this.sendFrameMessage({message: 'getFieldValues'})
  }

  setFieldValue(fieldId, value) {
    this.sendFrameMessage({
    message: 'setInputValue',
    details: {
      inputId: fieldId,
      value: value
    }})
  }

  frameMessageHandler = (event) => {
    if (event.origin !== this.frameHost())
      return;

    if (event.data.message == 'documentLoaded') {
      if (event.data.details.location === this.props.survey.fullURL) {
        this.sendFrameMessage({
          message: 'setInputValue',
          details: {
            inputId: 'email',
            value: this.props.interviewee.email
          }})
        this.sendFrameMessage({message: 'getHeight'});
      }
      else {
        this.props.onSubmitted(this.state.surveyFields);
      }
    }

    else if (event.data.message === 'fieldValues') {
      this.setState({surveyFields: event.data.details})
      console.log(this.state)
      this.sendFrameMessage({message: 'submit'})
    }

    else if (event.data.message == 'documentHeight')
      this.setState({
        frameStyle: {
          height: event.data.details.height,
          opacity: '1',
        },
        loadingStyle: {
          display: 'none',
        }
      })
  }

  sendFrameMessage(message) {
    this.refs.frame.contentWindow.postMessage(message, this.frameHost())
  }

  componentDidMount() {
    window.addEventListener('message', this.frameMessageHandler)
  }

  componentWillUnmount() {
    window.removeEventListener('message', this.frameMessageHandler);
  }

  hostFromURLString(URLString) {
    return URLString.split('/').slice(0, 3).join('/');
  }

  frameHost() {
    return this.hostFromURLString(this.props.survey.fullURL);
  }

  render() {
    let cacheBreak = '?cacheBreak=' + Math.random().toString(36).substring(6);
    let source = this.props.survey.fullURL + cacheBreak;
    let loading = (

Loading survey...

        <LinearProgress mode="indeterminate" />

    )
    let frame = (

    )

    return (

        {loading}
        {frame}

    )
  }
}

export default Relay.createContainer(BSDSurvey, {
  fragments: {
    survey: () => Relay.QL`
      fragment on Survey {
        fullURL
      }
    `,
    interviewee: () => Relay.QL`
      fragment on Person {
        email
      }
    `
  }
})<commit_msg>Fix cache issue for real<commit_after>import React from 'react';
import Relay from 'react-relay';
import Radium from 'radium';
import {LinearProgress} from 'material-ui';

// This just handles rendering and interacting with a BSD survey in an iFrame
@Radium
class BSDSurvey extends React.Component {
  styles = {
    container: {
//      width: '100%',
    },
    progress: {
      width: '50%',
      marginLeft: 'auto',
      marginRight: 'auto',
      marginTop: '30px',
      marginBottom: '30px',
      textAlign: 'center',
    },
    progressHeader: {
      marginBottom: '10px',
    },
    frame: {
      display: 'block',
      border: 'none',
      width: '100%',
      height: 0,
      opacity: 0,
      transition: 'opacity 0.7s',
    }
  }

  static propTypes = {
    onSubmitted : React.PropTypes.func,
  }

  state = {
    frameStyle : {height: 0},
    surveyFields: {},
    cacheBreakValue: Math.random().toString(36).substring(7)
  }

  submit = () => {
    this.sendFrameMessage({message: 'getFieldValues'})
  }

  setFieldValue(fieldId, value) {
    this.sendFrameMessage({
    message: 'setInputValue',
    details: {
      inputId: fieldId,
      value: value
    }})
  }

  frameMessageHandler = (event) => {
    if (event.origin !== this.frameHost())
      return;

    if (event.data.message == 'documentLoaded') {
      if (event.data.details.location.indexOf(this.props.survey.fullURL) !== -1) {
        this.sendFrameMessage({
          message: 'setInputValue',
          details: {
            inputId: 'email',
            value: this.props.interviewee.email
          }})
        this.sendFrameMessage({message: 'getHeight'});
      }
      else {
        this.props.onSubmitted(this.state.surveyFields);
      }
    }

    else if (event.data.message === 'fieldValues') {
      console.log('got field values')
      this.setState({surveyFields: event.data.details})
      this.sendFrameMessage({message: 'submit'})
    }

    else if (event.data.message == 'documentHeight') {
      console.log('got height', event.data.details.height)
      this.setState({
        frameStyle: {
          height: event.data.details.height,
          opacity: '1',
        },
        loadingStyle: {
          display: 'none',
        }
      })
    }
  }

  sendFrameMessage(message) {
    this.refs.frame.contentWindow.postMessage(message, this.frameHost())
  }

  componentDidMount() {
    window.addEventListener('message', this.frameMessageHandler)
  }

  componentWillUnmount() {
    window.removeEventListener('message', this.frameMessageHandler);
  }

  hostFromURLString(URLString) {
    return URLString.split('/').slice(0, 3).join('/');
  }

  frameHost() {
    return this.hostFromURLString(this.props.survey.fullURL);
  }

  render() {
    let cacheBreak = '?cacheBreak=' + this.state.cacheBreakValue;
    let source = this.props.survey.fullURL + cacheBreak;
    let loading = (

Loading survey...

        <LinearProgress mode="indeterminate" />

    )
    let frame = (

    )

    return (

        {loading}
        {frame}

    )
  }
}

export default Relay.createContainer(BSDSurvey, {
  fragments: {
    survey: () => Relay.QL`
      fragment on Survey {
        fullURL
      }
    `,
    interviewee: () => Relay.QL`
      fragment on Person {
        email
      }
    `
  }
})<|endoftext|>


<commit_before>if("undefined"==typeof OGX)var OGX=function(){};OGX.prototype.MobileActivityCalendar=function(t){"use strict";function a(t){return t.hasOwnProperty("originalEvent")?t.originalEvent.changedTouches[0]:t}function i(t){t?$(window).on("resize",function(){var t=$(window).innerWidth(),a=_(G);G.css({transform:"translate3D("+(Number(a[0])-Math.abs(H.width-t))+"px, 0px, 0px)"}),H.width=t,$(".ogx_mobile_activity_calendar_days").css("width",3*H.width),$(".ogx_mobile_activity_calendar_day").css("width",H.width)}):$(window).off("resize")}function e(t){t?G.on(k,function(t){Y=!1,I=0,P=(new Date).getTime(),t=a(t),F.x=t.pageX,F.y=t.pageY+G.parent(0).scrollTop(),e(!1),n(!0),r(!0)}):G.off(k)}function n(t){t?G.on(S,function(t){n(!1),r(!1),K||e(!0)}):G.off(S)}function o(t){t?A.on(S,".ogx_mobile_activity_calendar_block",function(t){if(console.log("item up",(new Date).getTime()-P),(new Date).getTime()-P<H.maxT){console.log("block was clicked");var a=v($(this));A.trigger(OGX.MobileActivityCalendar.SELECT,a)}}):A.off(S,".ogx_mobile_activity_calendar_block")}function r(t){t?(c(!0),G.on(N,function(t){t=a(t),Y=!1,I=0,Math.abs(t.pageX-F.x)>Math.abs(t.pageY-F.y)&&(Y=Math.abs(t.pageX-F.x),I=t.pageX-F.x>0?1:-1)})):(c(!1),G.off(N))}function c(t){t?q||(q=setInterval(d,10)):q&&(clearInterval(q),q=null)}function d(){if(Y&&I&&Y>H.minX){L=H.width,L*=I,r(!1),l(!0),e(!1),K=!0,G.addClass("ogx_mobile_activity_anim");var t=_(G);G.css({transform:"translate3D("+(Number(t[0])+L)+"px, 0px, 0px)"})}}function l(t){t?G.on("transitionend",function(t){l(!1),A.trigger(OGX.MobileActivityCalendar.DAY_CHANGE,H.date),G.removeClass("ogx_mobile_activity_anim"),I===-1?y():h(),K=!1,e(!0)}):G.off("transitionend")}function _(t){var a=t.css("-webkit-transform").match(/matrix(?:(3d)\(-{0,1}\d+(?:, -{0,1}\d+)*(?:, (-{0,1}\d+))(?:, (-{0,1}\d+))(?:, (-{0,1}\d+)), -{0,1}\d+\)|\(-{0,1}\d+(?:, -{0,1}\d+)*(?:, (-{0,1}\d+))(?:, (-{0,1}\d+))\))/);return a?"3d"==a[1]?a.slice(2,5):(a.push(0),a.slice(5,8)):[0,0,0]}function s(t,a){var i=t.split(":"),e=Number(i[0]),n=Number(i[1]),o=G.find('.ogx_mobile_activity_calendar_hour[data-hour="'+e+'"]:first').position().top;o+=Math.round(n/60*T);var r=Math.ceil(Number(a.length)/60*T);return{y:o,h:r}}function v(t){var a={};return a.type=t.data("type"),a.category=H.data.categories[a.type],a.label=t.find("span:first").text(),a.start=t.data("start"),a.length=t.data("length"),a}function f(t,a){return Math.max(t.top,a.top)<Math.min(t.bottom,a.bottom)}function g(t,a){var i,e,n,o,r,c,d,l,_,s;if(i=t.find(".ogx_mobile_activity_calendar_grid:first").height(),n=t.children(".ogx_mobile_activity_calendar_content:first"),e=n.children(".ogx_mobile_activity_calendar_stripe").length,e>0)for(var v=0;v<e;v++){if(o=n.children(".ogx_mobile_activity_calendar_stripe:eq("+v+")"),c=o.children(".ogx_mobile_activity_calendar_block").length,s=!0,!(c>0))return o;for(var g=0;g<c;g++)r=o.children(".ogx_mobile_activity_calendar_block:eq("+g+")"),d=r.position().top,l=r.height(),_=f({top:a.y,bottom:a.y+a.h},{top:d,bottom:d+l}),_&&(s=!1);if(s)return o}return n.append('

'),n.children(".ogx_mobile_activity_calendar_stripe:last")}function h(){var t=u(H.date);H.date=t;var a=G.find(".ogx_mobile_activity_calendar_day:last").detach(),i=u(H.date);a.children(".ogx_mobile_activity_calendar_nav:first").text(i.toString().substr(0,15)),a.find(".ogx_mobile_activity_calendar_content:first").empty(),G.prepend(a);var e=b(i);e&&x(e,i.getDay(),G.find(".ogx_mobile_activity_calendar_day:first"));var n=_(G);G.css({transform:"translate3D("+(Number(n[0])-H.width)+"px, 0px, 0px)"})}function y(){var t=m(H.date);H.date=t;var a=G.find(".ogx_mobile_activity_calendar_day:first").detach(),i=m(H.date);a.children(".ogx_mobile_activity_calendar_nav:first").text(i.toString().substr(0,15)),a.find(".ogx_mobile_activity_calendar_content:first").empty(),G.append(a);var e=b(i);e&&x(e,i.getDay(),G.find(".ogx_mobile_activity_calendar_day:last"));var n=_(G);G.css({transform:"translate3D("+(Math.abs(n[0])-H.width)*-1+"px, 0px, 0px)"})}function m(t){var a=new Date(t.toString());return new Date(a.getFullYear(),a.getMonth(),a.getDate()+1)}function u(t){var a=new Date(t.toString());return new Date(a.getFullYear(),a.getMonth(),a.getDate()-1)}function b(t){var a,i;for(var e in H.data.calendar)if(a=e.split("_"),a[0]=new Date(a[0]).getTime(),a[1]=new Date(a[1]).getTime(),i=t.getTime(),i>=a[0]&&i<=a[1])return H.data.calendar[e];return!1}function p(){var t=H.date.getDay(),a=b(H.date);if(a){var i;t-=2,t<0?t=6-(t-2):null;for(var e=0;e<3;e++)i=A.children(".ogx_mobile_activity_calendar_days:first").children(".ogx_mobile_activity_calendar_day:eq("+e+")"),x(a,t+e,i)}}function x(t,a,i){var e,n,o,r,c;for(var d in t[a])for(var l=0;l<t[a][d].length;l++)o=t[a][d][l],e=s(d,o),r=g(i,e),c=H.data.categories[o.type].color,n='
'+o.label+"
",r.append(n);var _=i.find(".ogx_mobile_activity_calendar_content:first").children(".ogx_mobile_activity_calendar_stripe").length,v=Math.floor(H.width/_);i.find(".ogx_mobile_activity_calendar_content:first").children(".ogx_mobile_activity_calendar_stripe").each(function(t,a){$(a).css("width",v+"px")})}function w(){switch(H.mode){case OGX.MobileActivityCalendar.MODE_MOBILE:k="touchstart",S="touchend",N="touchmove";break;case OGX.MobileActivityCalendar.MODE_DESKTOP:k="mousedown",S="mouseup",N="mousemove"}}function M(){for(var t=0;t<3;t++)O(t)}function D(t,a){switch(a){case 1:t<=12?t+="am":t=t-12+"pm";break;case 2:t<10?t="0"+t:null}return t}function O(t){for(var a,i,e=A.height()-G.find(".ogx_mobile_activity_calendar_nav:first").height(),n=H.day_end-H.day_start+1,o=Math.floor(e/n),r="",c=G.children(".ogx_mobile_activity_calendar_day:eq("+t+")").children(".ogx_mobile_activity_calendar_grid:first"),d=0;d<n;d++)a=H.day_start+d,i=H.ampm?D(a,1):D(a,2),r+='
'+i+"
";c.html(r),T=c.find(".ogx_mobile_activity_calendar_hour:first").height()}function C(){for(var t=A.width(),a=0,i=[u(H.date),H.date,m(H.date)],e='
',n=0;n<3;n++)e+='
',e+='
'+i[n].toString().substr(0,15)+"
",e+='

',e+='

',e+="
",a+=t;e+="
",A.append(e),G=A.find(".ogx_mobile_activity_calendar_days:first"),G.css({transform:"translate3D("+-H.width+"px, 0, 0)"})}function X(){for(var t in z)H.hasOwnProperty(t)||(H[t]=z[t]);H.width=$(H.container).innerWidth(),H.height=$(H.container).innerHeight(),B.el=A=$(H.container),A.addClass("ogx_mobile_activity_calendar ogx_hw")}function E(){X(),w(),C(),M(),H.data&&setTimeout(p,100),e(!0),o(!0),i(!0)}var A,G,T,k,S,N,Y,I,L,q,P,B=this,H=t,z={day_start:6,day_end:21,date:new Date,ampm:!0,data:!1,mode:OGX.MobileActivityCalendar.MODE_MOBILE,minX:60,maxY:5,maxT:100},F={},K=!1;this.el=null,this.setData=function(t){H.data=t,p()},this.destroy=function(){e(!1),n(!1),r(!1),l(!1),i(!1)},E()},OGX.MobileActivityCalendar=function(t){"use strict";return new OGX.prototype.MobileActivityCalendar(t)},OGX.MobileActivityCalendar.MODE_DESKTOP="desktop",OGX.MobileActivityCalendar.MODE_MOBILE="mobile",OGX.MobileActivityCalendar.SELECT="select",OGX.MobileActivityCalendar.DAY_CHANGE="dayChange";<commit_msg>Added render event<commit_after>if("undefined"==typeof OGX)var OGX=function(){};OGX.prototype.MobileActivityCalendar=function(t){"use strict";function a(t){return t.hasOwnProperty("originalEvent")?t.originalEvent.changedTouches[0]:t}function i(t){t?$(window).on("resize",function(){var t=$(window).innerWidth(),a=_(G);G.css({transform:"translate3D("+(Number(a[0])-Math.abs(B.width-t))+"px, 0px, 0px)"}),B.width=t,$(".ogx_mobile_activity_calendar_days").css("width",3*B.width),$(".ogx_mobile_activity_calendar_day").css("width",B.width)}):$(window).off("resize")}function e(t){t?G.on(k,function(t){Y=!1,I=0,q=(new Date).getTime(),t=a(t),z.x=t.pageX,z.y=t.pageY+G.parent(0).scrollTop(),e(!1),n(!0),r(!0)}):G.off(k)}function n(t){t?G.on(N,function(t){n(!1),r(!1),F||e(!0)}):G.off(N)}function o(t){t?A.on(N,".ogx_mobile_activity_calendar_block",function(t){if(console.log("item up",(new Date).getTime()-q),(new Date).getTime()-qMath.abs(t.pageY-z.y)&&(Y=Math.abs(t.pageX-z.x),I=t.pageX-z.x>0?1:-1)})):(c(!1),G.off(S))}function c(t){t?R||(R=setInterval(l,10)):R&&(clearInterval(R),R=null)}function l(){if(Y&&I&&Y>B.minX){L=B.width,L*=I,r(!1),d(!0),e(!1),F=!0,G.addClass("ogx_mobile_activity_anim");var t=_(G);G.css({transform:"translate3D("+(Number(t[0])+L)+"px, 0px, 0px)"})}}function d(t){t?G.on("transitionend",function(t){d(!1),A.trigger(OGX.MobileActivityCalendar.DAY_CHANGE,B.date),G.removeClass("ogx_mobile_activity_anim"),I===-1?h():y(),F=!1,e(!0)}):G.off("transitionend")}function _(t){var a=t.css("-webkit-transform").match(/matrix(?:(3d)\(-{0,1}\d+(?:, -{0,1}\d+)*(?:, (-{0,1}\d+))(?:, (-{0,1}\d+))(?:, (-{0,1}\d+)), -{0,1}\d+\)|\(-{0,1}\d+(?:, -{0,1}\d+)*(?:, (-{0,1}\d+))(?:, (-{0,1}\d+))\))/);return a?"3d"==a[1]?a.slice(2,5):(a.push(0),a.slice(5,8)):[0,0,0]}function s(t,a){var i=t.split(":"),e=Number(i[0]),n=Number(i[1]),o=G.find('.ogx_mobile_activity_calendar_hour[data-hour="'+e+'"]:first').position().top;o+=Math.round(n/60*T);var r=Math.ceil(Number(a.length)/60*T);return{y:o,h:r}}function v(t){var a={};return a.type=t.data("type"),a.category=B.data.categories[a.type],a.label=t.find("span:first").text(),a.start=t.data("start"),a.length=t.data("length"),a}function f(t,a){return Math.max(t.top,a.top)<Math.min(t.bottom,a.bottom)}function g(t,a){var i,e,n,o,r,c,l,d,_,s;if(i=t.find(".ogx_mobile_activity_calendar_grid:first").height(),n=t.children(".ogx_mobile_activity_calendar_content:first"),e=n.children(".ogx_mobile_activity_calendar_stripe").length,e>0)for(var v=0;v<e;v++){if(o=n.children(".ogx_mobile_activity_calendar_stripe:eq("+v+")"),c=o.children(".ogx_mobile_activity_calendar_block").length,s=!0,!(c>0))return o;for(var g=0;g<c;g++)r=o.children(".ogx_mobile_activity_calendar_block:eq("+g+")"),l=r.position().top,d=r.height(),_=f({top:a.y,bottom:a.y+a.h},{top:l,bottom:l+d}),_&&(s=!1);if(s)return o}return n.append('

'),n.children(".ogx_mobile_activity_calendar_stripe:last")}function y(){var t=b(B.date);B.date=t;var a=G.find(".ogx_mobile_activity_calendar_day:last").detach(),i=b(B.date);a.children(".ogx_mobile_activity_calendar_nav:first").text(i.toString().substr(0,15)),a.find(".ogx_mobile_activity_calendar_content:first").empty(),G.prepend(a);var e=u(i);e&&x(e,i.getDay(),G.find(".ogx_mobile_activity_calendar_day:first"));var n=_(G);G.css({transform:"translate3D("+(Number(n[0])-B.width)+"px, 0px, 0px)"})}function h(){var t=m(B.date);B.date=t;var a=G.find(".ogx_mobile_activity_calendar_day:first").detach(),i=m(B.date);a.children(".ogx_mobile_activity_calendar_nav:first").text(i.toString().substr(0,15)),a.find(".ogx_mobile_activity_calendar_content:first").empty(),G.append(a);var e=u(i);e&&x(e,i.getDay(),G.find(".ogx_mobile_activity_calendar_day:last"));var n=_(G);G.css({transform:"translate3D("+(Math.abs(n[0])-B.width)*-1+"px, 0px, 0px)"})}function m(t){var a=new Date(t.toString());return new Date(a.getFullYear(),a.getMonth(),a.getDate()+1)}function b(t){var a=new Date(t.toString());return new Date(a.getFullYear(),a.getMonth(),a.getDate()-1)}function u(t){var a,i;for(var e in B.data.calendar)if(a=e.split("_"),a[0]=new Date(a[0]).getTime(),a[1]=new Date(a[1]).getTime(),i=t.getTime(),i>=a[0]&&i<=a[1])return B.data.calendar[e];return!1}function p(){var t=B.date.getDay(),a=u(B.date);if(a){var i;t-=2,t<0?t=6-(t-2):null;for(var e=0;e<3;e++)i=A.children(".ogx_mobile_activity_calendar_days:first").children(".ogx_mobile_activity_calendar_day:eq("+e+")"),x(a,t+e,i)}P.el.trigger(OGX.MobileActivityCalendar.RENDER)}function x(t,a,i){var e,n,o,r,c;for(var l in t[a])for(var d=0;d<t[a][l].length;d++)o=t[a][l][d],e=s(l,o),r=g(i,e),c=B.data.categories[o.type].color,n='
'+o.label+"
",r.append(n);var _=i.find(".ogx_mobile_activity_calendar_content:first").children(".ogx_mobile_activity_calendar_stripe").length,v=Math.floor(B.width/_);i.find(".ogx_mobile_activity_calendar_content:first").children(".ogx_mobile_activity_calendar_stripe").each(function(t,a){$(a).css("width",v+"px")})}function w(){switch(B.mode){case OGX.MobileActivityCalendar.MODE_MOBILE:k="touchstart",N="touchend",S="touchmove";break;case OGX.MobileActivityCalendar.MODE_DESKTOP:k="mousedown",N="mouseup",S="mousemove"}}function M(){for(var t=0;t<3;t++)O(t)}function D(t,a){switch(a){case 1:t<=12?t+="am":t=t-12+"pm";break;case 2:t<10?t="0"+t:null}return t}function O(t){for(var a,i,e=A.height()-G.find(".ogx_mobile_activity_calendar_nav:first").height(),n=B.day_end-B.day_start+1,o=Math.floor(e/n),r="",c=G.children(".ogx_mobile_activity_calendar_day:eq("+t+")").children(".ogx_mobile_activity_calendar_grid:first"),l=0;l<n;l++)a=B.day_start+l,i=B.ampm?D(a,1):D(a,2),r+='
'+i+"
";c.html(r),T=c.find(".ogx_mobile_activity_calendar_hour:first").height()}function C(){for(var t=A.width(),a=0,i=[b(B.date),B.date,m(B.date)],e='
',n=0;n<3;n++)e+='
',e+='
'+i[n].toString().substr(0,15)+"
",e+='

',e+='

',e+="
",a+=t;e+="
",A.append(e),G=A.find(".ogx_mobile_activity_calendar_days:first"),G.css({transform:"translate3D("+-B.width+"px, 0, 0)"})}function E(){for(var t in H)B.hasOwnProperty(t)||(B[t]=H[t]);B.width=$(B.container).innerWidth(),B.height=$(B.container).innerHeight(),P.el=A=$(B.container),A.addClass("ogx_mobile_activity_calendar ogx_hw")}function X(){E(),w(),C(),M(),B.data&&setTimeout(p,100),e(!0),o(!0),i(!0)}var A,G,T,k,N,S,Y,I,L,R,q,P=this,B=t,H={day_start:6,day_end:21,date:new Date,ampm:!0,data:!1,mode:OGX.MobileActivityCalendar.MODE_MOBILE,minX:60,maxY:5,maxT:100},z={},F=!1;this.el=null,this.setData=function(t){B.data=t,p()},this.destroy=function(){e(!1),n(!1),r(!1),d(!1),i(!1)},X()},OGX.MobileActivityCalendar=function(t){"use strict";return new OGX.prototype.MobileActivityCalendar(t)},OGX.MobileActivityCalendar.MODE_DESKTOP="desktop",OGX.MobileActivityCalendar.MODE_MOBILE="mobile",OGX.MobileActivityCalendar.SELECT="MobileActivityCalendarSelect",OGX.MobileActivityCalendar.DAY_CHANGE="MobileActivityCalendarDayChange",OGX.MobileActivityCalendar.RENDER="MobileActivityCalendarRender";<|endoftext|>


<commit_before>"use strict";

var assert = require('assert');

var canSmush = function(a,b) {
  if (a === '') { return false; }

  if (b.indexOf(a) !== -1) {
    return true;
  } else {
    return canSmush(a.substr(1), b);
  }
};

var smushIndex = function(a,b) {
  if (!canSmush(a,b)) throw Error('unsmushable');

  if (b.indexOf(a) === 0) {
    return 0;
  }
  else {
    return 1 + smushIndex(a.substr(1),b);
  }
};

var smush = function(a,b) {
  if (!canSmush(a,b)) throw Error('unsmushable');
  return a.substr(0,smushIndex(a,b)) + b;
};

describe('word smushing', function() {
  describe('can smush', function() {
    it('should deal with single character smushes', function() {
      assert(canSmush('it','to'));
    });

    it('should deal with multiple overlaps', function() {
      assert(canSmush('bea', 'ear'));
    });

    it('shouldn\'t', function() {
      assert(!canSmush('be','to'));
    });
  });

  describe('smush together', function() {
    it('wont smush unsmushable', function() {
      assert.throws(function() { smush('be','to'); });
    });

    it('joins together when 1 character overlaps', function() {
      var smushed = smush('it', 'to');
      assert.equal('ito', smushed);
    });

    it('should smush multiple overlaps', function() {
      var smushed = smush('bea', 'ear');
      assert.equal('bear', smushed);
    });
  });
});<commit_msg>just check!<commit_after>"use strict";

var assert = require('assert');

var canSmush = function(a,b) {
  if (a === '') { return false; }

  if (b.indexOf(a) !== -1) {
    return true;
  } else {
    return canSmush(a.substr(1), b);
  }
};

var smushIndex = function(a,b) {
  if (!canSmush(a,b)) throw Error('unsmushable');

  if (b.indexOf(a) === 0) {
    return 0;
  } else {
    return 1 + smushIndex(a.substr(1),b);
  }
};

var smush = function(a,b) {
  if (!canSmush(a,b)) throw Error('unsmushable');
  return a.substr(0,smushIndex(a,b)) + b;
};

describe('word smushing', function() {
  describe('can smush', function() {
    it('should deal with single character smushes', function() {
      assert(canSmush('it','to'));
    });

    it('should deal with multiple overlaps', function() {
      assert(canSmush('bea', 'ear'));
    });

    it('shouldn\'t', function() {
      assert(!canSmush('be','to'));
    });
  });

  describe('smush together', function() {
    it('wont smush unsmushable', function() {
      assert.throws(function() { smush('be','to'); });
    });

    it('joins together when 1 character overlaps', function() {
      var smushed = smush('it', 'to');
      assert.equal('ito', smushed);
    });

    it('should smush multiple overlaps', function() {
      var smushed = smush('bea', 'ear');
      assert.equal('bear', smushed);
    });

    it('should perform with test data', function() {
      var smushed = smush('testing', 'ginger');
      assert.equal('testinginger',smushed);
    });
  });
});<|endoftext|>


<commit_before>/**
 * This module implements the renderer's specification (tests).
 *
 */

define(['rendererjs'], function(rendererjs) {

  describe('rendererjs', function() {

    window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000;

    // Image file object
    var imgFileObj = {
      baseUrl: 'volumes/nii/',
      imgType: 'vol',
      files: [{url: 'volumes/nii/s34654_df.nii', name: 's34654_df.nii', remote: true}],
      json: {'url': 'json/s34654_df.json', 'remote': true}
    };

    // append a container for the whole renderer
    var container = $('

');
    $(document.body).append(container);

    var r; // renderer

    // renderer options object
    var options = {
      container: container,
      rendererId: 'xtkrenderercont',
      orientation: 'Z'
    };

    describe('rendererjs initialization', function() {

      beforeEach(function() {

        r = new rendererjs.Renderer(options);
        r.imgFileObj = imgFileObj;
      });

      afterEach(function() {

        // Destroy renderer
        r.destroy();
      });

      it('rendererjs.Renderer.prototype.createUI() creates the renderer UI',

        function() {

          r.createUI();

          expect(r.container.hasClass('view-renderer')).toEqual(true);

          // renderer window has a title bar
          expect(r.container.find('.view-renderer-titlebar').length).toEqual(1);

          // renderer window has a content
          var contentDiv = r.container.find('.view-renderer-content');
          expect(contentDiv.length).toEqual(1);
          expect(contentDiv.attr('id')).toEqual(r.rendererId);
        }
      );

      it('rendererjs.Renderer.prototype.createVolume() creates internal XTK volume object',

        function() {

          r.createVolume();
          expect(r.volume.classname).toEqual('volume');
        }
      );

      it('rendererjs.Renderer.prototype.createRenderer() creates internal 2D XTK renderer',

        function() {

          r.createUI();
          r.createRenderer();
          expect(r.renderer.classname).toEqual('renderer2D');
        }
      );

      it('rendererjs.Renderer.prototype.readVolumeFiles() reads the image volume',

        function(done) {

          r.createVolume();

          r.readVolumeFiles(function() {

            //expect(r.volume.filedata).toEqual(window.jasmine.any(Object));
            expect(r.volume.filedata.byteLength).toBeGreaterThan(0);
            done();
          });
        }
      );

      it('rendererjs.Renderer.prototype.renderVolume() renders the volume file',

        function(done) {

          r.createUI();
          r.createRenderer();
          r.createVolume();

          r.readVolumeFiles(function() {

            r.renderVolume(function() {

              expect(r.error).toBeFalsy();
              done();
            });
          });
        }
      );
    });

    describe('rendererjs behaviour', function() {

      beforeEach(function(done) {

        r = new rendererjs.Renderer(options);

        r.init(imgFileObj, function() {

          done();
        });
      });

      afterEach(function() {

        // Destroy renderer
        r.destroy();
      });

      it('rendererjs.Renderer.prototype.getVolProps("Z") returns 2',

        function() {

          expect(r.getVolProps('Z').rangeInd).toEqual(2);
        }
      );

      it('rendererjs.Renderer.prototype.readJSONFile reads a JSON file',

        function(done) {

          r.readJSONFile({'url': 'json/s34654_df.json', 'remote': true}, function(data) {

            expect(data.PatientName).toEqual('Bob');
            done();
          });
        }
      );

      it('rendererjs.Renderer.prototype.readFile reads a file',

        function(done) {

          r.readFile({'url': 'volumes/nii/s34654_df.nii', 'remote': true}, 'readAsArrayBuffer', function(data) {

            expect(data.byteLength).toBeGreaterThan(0);
            done();
          });
        }
      );
    });
  });
});
<commit_msg>Added specs for 8 rendererjs' methods: init, changeOrientation, getTumbnail, zipFiles, unzipFileData, parseJSONData<commit_after>/**
 * This module implements the renderer's specification (tests).
 *
 */

define(['rendererjs'], function(rendererjs) {

  describe('rendererjs', function() {

    window.jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000;

    // Image file object
    var imgFileObj = {
      baseUrl: 'volumes/nii/',
      imgType: 'vol',
      files: [{url: 'volumes/nii/s34654_df.nii', name: 's34654_df.nii', remote: true}],
      json: {'url': 'json/s34654_df.json', name: 's34654_df.json', 'remote': true}
    };

    // append a container for the whole renderer
    var container = $('

');
    $(document.body).append(container);

    var r; // renderer

    // renderer options object
    var options = {
      container: container,
      rendererId: 'xtkrenderercont',
      orientation: 'Z'
    };

    describe('rendererjs initialization', function() {

      beforeEach(function() {

        r = new rendererjs.Renderer(options);
        r.imgFileObj = imgFileObj;
      });

      afterEach(function() {

        // Destroy renderer
        r.destroy();
      });

      it('rendererjs.Renderer.prototype.createUI() creates the renderer UI',

        function() {

          r.createUI();

          expect(r.container.hasClass('view-renderer')).toEqual(true);

          // renderer window has a title bar
          expect(r.container.find('.view-renderer-titlebar').length).toEqual(1);

          // renderer window has a content
          var contentDiv = r.container.find('.view-renderer-content');
          expect(contentDiv.length).toEqual(1);
          expect(contentDiv.attr('id')).toEqual(r.rendererId);
        }
      );

      it('rendererjs.Renderer.prototype.createVolume() creates internal XTK volume object',

        function() {

          r.createVolume();
          expect(r.volume.classname).toEqual('volume');
        }
      );

      it('rendererjs.Renderer.prototype.createRenderer() creates internal 2D XTK renderer',

        function() {

          r.createUI();
          r.createRenderer();
          expect(r.renderer.classname).toEqual('renderer2D');
        }
      );

      it('rendererjs.Renderer.prototype.readVolumeFiles() reads the image volume',

        function(done) {

          r.createVolume();

          r.readVolumeFiles(function() {

            //expect(r.volume.filedata).toEqual(window.jasmine.any(Object));
            expect(r.volume.filedata.byteLength).toBeGreaterThan(0);
            done();
          });
        }
      );

      it('rendererjs.Renderer.prototype.renderVolume() renders the volume file',

        function(done) {

          r.createUI();
          r.createRenderer();
          r.createVolume();

          r.readVolumeFiles(function() {

            r.renderVolume(function() {

              expect(r.error).toBeFalsy();
              done();
            });
          });
        }
      );

      it('rendererjs.Renderer.prototype.init(imgFileObj) initializes the renderer',

        function(done) {

          r.init(imgFileObj, function() {

            expect(r.renderer.classname).toEqual('renderer2D');
            expect(r.volume.filedata.byteLength).toBeGreaterThan(0);
            expect(r.error).toBeFalsy();
            done();
          });
        }
      );
    });

    describe('rendererjs behaviour', function() {

      beforeEach(function(done) {

        r = new rendererjs.Renderer(options);

        r.init(imgFileObj, function() {

          done();
        });
      });

      afterEach(function() {

        // Destroy renderer
        r.destroy();
      });

      it('rendererjs.Renderer.prototype.readJSONFile reads a JSON file',

        function(done) {

          r.readJSONFile(imgFileObj.json, function(data) {

            expect(data.PatientName).toEqual('Bob');
            done();
          });
        }
      );

      it('rendererjs.Renderer.prototype.readFile reads a file',

        function(done) {

          r.readFile(imgFileObj.files[0], 'readAsArrayBuffer', function(data) {

            expect(data.byteLength).toBeGreaterThan(0);
            done();
          });
        }
      );

      it('rendererjs.Renderer.prototype.getVolProps("Z") returns volume properties',

        function() {

          expect(r.getVolProps('Z').rangeInd).toEqual(2);
        }
      );

      it('rendererjs.Renderer.prototype.changeOrientation changes renderer orientation',

        function(done) {

          r.changeOrientation('X', function() {

            expect(r.orientation).toEqual('X');

            r.changeOrientation('Y', function() {

              expect(r.orientation).toEqual('Y');
              done();
            });
          });
        }
      );

      it('rendererjs.Renderer.prototype.getTumbnail creates an image/jpeg DOMString',

        function(done) {

          r.getThumbnail(function(dataUrl) {

            expect(dataUrl).toContain('data:image/jpeg');
            done();
          });
        }
      );

      it('rendererjs.Renderer.prototype.zipFiles concats and zips files',

        function(done) {

          r.zipFiles([imgFileObj.files[0], imgFileObj.files[0]], function(zipArr) {

            expect(zipArr.length).toEqual(1);
            done();
          });
        }
      );

      it('rendererjs.Renderer.prototype.unzipFileData unzips the contents of a zip file',

        function(done) {

          r.zipFiles([imgFileObj.files[0], imgFileObj.json], function(zipArr) {

            var unzipArr = r.unzipFileData(zipArr[0]);

            expect(unzipArr.some(function(el) { return el.name === 's34654_df.nii'; })).toEqual(true);
            expect(unzipArr.some(function(el) { return el.name === 's34654_df.json'; })).toEqual(true);
            done();
          });
        }
      );

      it('rendererjs.Renderer.prototype.parseJSONData parses a JSON obj for requiered properties',

        function(done) {

          r.readJSONFile(imgFileObj.json, function(jsonObj) {

            r.parseJSONData(jsonObj);

            expect(r.mriInfo.patientName).toEqual('Bob');
            expect(r.mriInfo.patientId).toEqual('111111');
            expect(r.mriInfo.patientBirthDate).toEqual('20000101');
            expect(r.mriInfo.patientSex).toEqual('M');
            expect(r.mriInfo.seriesDescription).toEqual('Some MRI Scan');
            expect(r.mriInfo.manufacturer).toEqual('Siemens');
            expect(r.mriInfo.studyDate).toEqual('20160510');
            expect(r.mriInfo.orientation).toEqual('LPS');
            expect(r.mriInfo.primarySliceDirection).toEqual('axial');
            expect(r.mriInfo.dimensions).toEqual('128 x 128 x 52');
            expect(r.mriInfo.voxelSizes).toEqual('2.0000, 2.0000, 2.0000');

            done();
          });
        }
      );
    });
  });
});
<|endoftext|>


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

// version of docker images
const DOCKER_JHIPSTER_REGISTRY = 'jhipster/jhipster-registry:v5.0.2';
const DOCKER_JAVA_JRE = 'adoptopenjdk:11-jre-hotspot';
const DOCKER_MYSQL = 'mysql:8.0.17';
const DOCKER_MARIADB = 'mariadb:10.4.7';
const DOCKER_POSTGRESQL = 'postgres:11.5';
const DOCKER_MONGODB = 'mongo:4.0.12';
const DOCKER_COUCHBASE = 'couchbase:6.0.0';
const DOCKER_CASSANDRA = 'cassandra:3.11.4';
const DOCKER_MSSQL = 'microsoft/mssql-server-linux:latest';
const DOCKER_HAZELCAST_MANAGEMENT_CENTER = 'hazelcast/management-center:3.12.4';
const DOCKER_MEMCACHED = 'memcached:1.5.16-alpine';
const DOCKER_KEYCLOAK = 'jboss/keycloak:6.0.1';
const DOCKER_ELASTICSEARCH = 'docker.elastic.co/elasticsearch/elasticsearch:6.4.3'; // The version should be coerent with the one from spring-data-elasticsearch project
const DOCKER_KAFKA = 'confluentinc/cp-kafka:5.3.0';
const DOCKER_ZOOKEEPER = 'confluentinc/cp-zookeeper:5.3.0';
const DOCKER_SONAR = 'sonarqube:7.9.1-community';
const DOCKER_JHIPSTER_CONSOLE = 'jhipster/jhipster-console:v4.1.0';
const DOCKER_JHIPSTER_CURATOR = 'jhipster/jhipster-curator:v4.1.0';
const DOCKER_JHIPSTER_ELASTICSEARCH = 'jhipster/jhipster-elasticsearch:v4.1.0';
const DOCKER_JHIPSTER_LOGSTASH = 'jhipster/jhipster-logstash:v4.1.0';
const DOCKER_JHIPSTER_IMPORT_DASHBOARDS = 'jhipster/jhipster-import-dashboards:v4.1.0';
const DOCKER_JHIPSTER_ZIPKIN = 'jhipster/jhipster-zipkin:v4.1.0';
const DOCKER_TRAEFIK = 'traefik:1.7.13';
const DOCKER_CONSUL = 'consul:1.5.3';
const DOCKER_CONSUL_CONFIG_LOADER = 'jhipster/consul-config-loader:v0.3.0';
const DOCKER_PROMETHEUS = 'prom/prometheus:v2.11.1';
const DOCKER_PROMETHEUS_ALERTMANAGER = 'prom/alertmanager:v0.18.0';
const DOCKER_GRAFANA = 'grafana/grafana:6.3.2';
const DOCKER_JENKINS = 'jenkins:latest';
const DOCKER_SWAGGER_EDITOR = 'swaggerapi/swagger-editor:latest';
const DOCKER_COMPOSE_FORMAT_VERSION = '2';
const DOCKER_PROMETHEUS_OPERATOR = 'quay.io/coreos/prometheus-operator:v0.31.1';
const DOCKER_GRAFANA_WATCHER = 'quay.io/coreos/grafana-watcher:v0.0.8';

// Kubernetes versions
const KUBERNETES_CORE_API_VERSION = 'v1';
const KUBERNETES_BATCH_API_VERSION = 'batch/v1';
const KUBERNETES_DEPLOYMENT_API_VERSION = 'apps/v1';
const KUBERNETES_STATEFULSET_API_VERSION = 'apps/v1';
const KUBERNETES_INGRESS_API_VERSION = 'extensions/v1beta1';
const KUBERNETES_ISTIO_NETWORKING_API_VERSION = 'networking.istio.io/v1alpha3';
const KUBERNETES_RBAC_API_VERSION = 'rbac.authorization.k8s.io/v1';

// Version of Java
const JAVA_VERSION = '1.8'; // Java version is forced to be 1.8. We keep the variable as it might be useful in the future.

// version of Node, Yarn, NPM
const NODE_VERSION = '10.16.3';
const YARN_VERSION = '1.17.3';
const NPM_VERSION = '6.11.2';

// Libraries version
const JIB_VERSION = '1.5.0';

// all constants used throughout all generators

const MAIN_DIR = 'src/main/';
const TEST_DIR = 'src/test/';

// Note: this will be prepended with 'target/classes' for Maven, or with 'build/resources/main' for Gradle.
const CLIENT_DIST_DIR = 'static/';

const SUPPORTED_VALIDATION_RULES = ['required', 'unique', 'max', 'min', 'maxlength', 'minlength', 'maxbytes', 'minbytes', 'pattern'];

// documentation constants
const JHIPSTER_DOCUMENTATION_URL = 'https://www.jhipster.tech';
const JHIPSTER_DOCUMENTATION_ARCHIVE_PATH = '/documentation-archive/';

const SQL_DB_OPTIONS = [
    {
        value: 'mysql',
        name: 'MySQL'
    },
    {
        value: 'mariadb',
        name: 'MariaDB'
    },
    {
        value: 'postgresql',
        name: 'PostgreSQL'
    },
    {
        value: 'oracle',
        name: 'Oracle (Please follow our documentation to use the Oracle proprietary driver)'
    },
    {
        value: 'mssql',
        name: 'Microsoft SQL Server'
    }
];

const LANGUAGES = [
    {
        name: 'Albanian',
        dispName: 'Shqip',
        value: 'al',
        momentLocaleId: 'sq'
    },
    {
        name: 'Arabic (Libya)',
        dispName: 'العربية',
        value: 'ar-ly',
        rtl: true,
        skipForLocale: true
    },
    {
        name: 'Armenian',
        dispName: 'Հայերեն',
        value: 'hy',
        momentLocaleId: 'hy-am'
    },
    {
        name: 'Belorussian',
        dispName: 'Беларускі',
        value: 'by',
        momentLocaleId: 'be-by'
    },
    {
        name: 'Bengali',
        dispName: 'বাংলা',
        value: 'bn',
        momentLocaleId: 'bn-bd'
    },
    {
        name: 'Catalan',
        dispName: 'Català',
        value: 'ca'
    },
    {
        name: 'Chinese (Simplified)',
        dispName: '中文（简体）',
        value: 'zh-cn',
        localeId: 'zh-Hans'
    },
    {
        name: 'Chinese (Traditional)',
        dispName: '繁體中文',
        value: 'zh-tw',
        localeId: 'zh-Hant'
    },
    { name: 'Czech', dispName: 'Český', value: 'cs' },
    { name: 'Danish', dispName: 'Dansk', value: 'da' },
    { name: 'Dutch', dispName: 'Nederlands', value: 'nl' },
    { name: 'English', dispName: 'English', value: 'en' },
    { name: 'Estonian', dispName: 'Eesti', value: 'et' },
    {
        name: 'Farsi',
        dispName: 'فارسی',
        value: 'fa',
        rtl: true
    },
    { name: 'Finnish', dispName: 'Suomi', value: 'fi' },
    { name: 'French', dispName: 'Français', value: 'fr' },
    { name: 'Galician', dispName: 'Galego', value: 'gl' },
    { name: 'German', dispName: 'Deutsch', value: 'de' },
    { name: 'Greek', dispName: 'Ελληνικά', value: 'el' },
    { name: 'Hindi', dispName: 'हिंदी', value: 'hi' },
    { name: 'Hungarian', dispName: 'Magyar', value: 'hu' },
    {
        name: 'Indonesian',
        dispName: 'Bahasa Indonesia',
        /*
           To fix a nasty bug in the JDK ("Indonesian Locale does not comply with ISO 639")
           The locale is set to "in" for Indonesia
           See https://bugs.openjdk.java.net/browse/JDK-6457127
           And https://github.com/jhipster/generator-jhipster/issues/9494
        */
        value: 'in',
        localeId: 'id',
        momentLocaleId: 'id'
    },
    { name: 'Italian', dispName: 'Italiano', value: 'it' },
    { name: 'Japanese', dispName: '日本語', value: 'ja' },
    { name: 'Korean', dispName: '한국어', value: 'ko' },
    { name: 'Marathi', dispName: 'मराठी', value: 'mr' },
    { name: 'Myanmar', dispName: 'မြန်မာ', value: 'my' },
    { name: 'Polish', dispName: 'Polski', value: 'pl' },
    {
        name: 'Portuguese (Brazilian)',
        dispName: 'Português (Brasil)',
        value: 'pt-br',
        localeId: 'pt'
    },
    {
        name: 'Portuguese',
        dispName: 'Português',
        value: 'pt-pt',
        localeId: 'pt-PT'
    },
    { name: 'Romanian', dispName: 'Română', value: 'ro' },
    { name: 'Russian', dispName: 'Русский', value: 'ru' },
    { name: 'Slovak', dispName: 'Slovenský', value: 'sk' },
    { name: 'Serbian', dispName: 'Srpski', value: 'sr' },
    { name: 'Spanish', dispName: 'Español', value: 'es' },
    { name: 'Swedish', dispName: 'Svenska', value: 'sv' },
    { name: 'Turkish', dispName: 'Türkçe', value: 'tr' },
    { name: 'Tamil', dispName: 'தமிழ்', value: 'ta' },
    { name: 'Telugu', dispName: 'తెలుగు', value: 'te' },
    { name: 'Thai', dispName: 'ไทย', value: 'th' },
    {
        name: 'Ukrainian',
        dispName: 'Українська',
        value: 'ua',
        localeId: 'uk',
        momentLocaleId: 'uk'
    },
    {
        name: 'Uzbek (Cyrillic)',
        dispName: 'Ўзбекча',
        value: 'uz-Cyrl-uz',
        localeId: 'uz-Cyrl'
    },
    {
        name: 'Uzbek (Latin)',
        dispName: 'O`zbekcha',
        value: 'uz-Latn-uz',
        localeId: 'uz-Latn'
    },
    { name: 'Vietnamese', dispName: 'Tiếng Việt', value: 'vi' }
];

const constants = {
    INTERPOLATE_REGEX: /<%:([\s\S]+?)%>/g, // so that tags in templates do not get mistreated as _ templates
    DOCKER_DIR: `${MAIN_DIR}docker/`,
    LINE_LENGTH: 180,
    LANGUAGES,

    MAIN_DIR,
    TEST_DIR,

    CLIENT_MAIN_SRC_DIR: `${MAIN_DIR}webapp/`,
    CLIENT_TEST_SRC_DIR: `${TEST_DIR}javascript/`,
    CLIENT_WEBPACK_DIR: 'webpack/',
    CLIENT_DIST_DIR,
    ANGULAR_DIR: `${MAIN_DIR}webapp/app/`,
    REACT_DIR: `${MAIN_DIR}webapp/app/`,

    SERVER_MAIN_SRC_DIR: `${MAIN_DIR}java/`,
    SERVER_MAIN_RES_DIR: `${MAIN_DIR}resources/`,
    SERVER_TEST_SRC_DIR: `${TEST_DIR}java/`,
    SERVER_TEST_RES_DIR: `${TEST_DIR}resources/`,

    // entity related
    SUPPORTED_VALIDATION_RULES,

    JHIPSTER_DOCUMENTATION_URL,
    JHIPSTER_DOCUMENTATION_ARCHIVE_PATH,

    DOCKER_JHIPSTER_REGISTRY,
    DOCKER_JAVA_JRE,
    DOCKER_MYSQL,
    DOCKER_MARIADB,
    DOCKER_POSTGRESQL,
    DOCKER_MONGODB,
    DOCKER_COUCHBASE,
    DOCKER_CASSANDRA,
    DOCKER_MSSQL,
    DOCKER_HAZELCAST_MANAGEMENT_CENTER,
    DOCKER_MEMCACHED,
    DOCKER_ELASTICSEARCH,
    DOCKER_KEYCLOAK,
    DOCKER_KAFKA,
    DOCKER_ZOOKEEPER,
    DOCKER_SONAR,
    DOCKER_JHIPSTER_CONSOLE,
    DOCKER_JHIPSTER_CURATOR,
    DOCKER_JHIPSTER_ELASTICSEARCH,
    DOCKER_JHIPSTER_LOGSTASH,
    DOCKER_JHIPSTER_IMPORT_DASHBOARDS,
    DOCKER_JHIPSTER_ZIPKIN,
    DOCKER_TRAEFIK,
    DOCKER_CONSUL,
    DOCKER_CONSUL_CONFIG_LOADER,
    DOCKER_PROMETHEUS,
    DOCKER_PROMETHEUS_ALERTMANAGER,
    DOCKER_GRAFANA,
    JAVA_VERSION,
    NODE_VERSION,
    YARN_VERSION,
    NPM_VERSION,

    // Libraries
    JIB_VERSION,

    DOCKER_JENKINS,
    DOCKER_SWAGGER_EDITOR,
    SQL_DB_OPTIONS,
    DOCKER_COMPOSE_FORMAT_VERSION,
    DOCKER_PROMETHEUS_OPERATOR,
    DOCKER_GRAFANA_WATCHER,
    KUBERNETES_CORE_API_VERSION,
    KUBERNETES_BATCH_API_VERSION,
    KUBERNETES_DEPLOYMENT_API_VERSION,
    KUBERNETES_STATEFULSET_API_VERSION,
    KUBERNETES_INGRESS_API_VERSION,
    KUBERNETES_ISTIO_NETWORKING_API_VERSION,
    KUBERNETES_RBAC_API_VERSION
};

module.exports = constants;
<commit_msg>Update jboss/keycloak docker image version to 7.0.0<commit_after>/**
 * Copyright 2013-2019 the original author or authors from the JHipster project.
 *
 * This file is part of the JHipster project, see https://www.jhipster.tech/
 * for more information.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// version of docker images
const DOCKER_JHIPSTER_REGISTRY = 'jhipster/jhipster-registry:v5.0.2';
const DOCKER_JAVA_JRE = 'adoptopenjdk:11-jre-hotspot';
const DOCKER_MYSQL = 'mysql:8.0.17';
const DOCKER_MARIADB = 'mariadb:10.4.7';
const DOCKER_POSTGRESQL = 'postgres:11.5';
const DOCKER_MONGODB = 'mongo:4.0.12';
const DOCKER_COUCHBASE = 'couchbase:6.0.0';
const DOCKER_CASSANDRA = 'cassandra:3.11.4';
const DOCKER_MSSQL = 'microsoft/mssql-server-linux:latest';
const DOCKER_HAZELCAST_MANAGEMENT_CENTER = 'hazelcast/management-center:3.12.4';
const DOCKER_MEMCACHED = 'memcached:1.5.16-alpine';
const DOCKER_KEYCLOAK = 'jboss/keycloak:7.0.0';
const DOCKER_ELASTICSEARCH = 'docker.elastic.co/elasticsearch/elasticsearch:6.4.3'; // The version should be coerent with the one from spring-data-elasticsearch project
const DOCKER_KAFKA = 'confluentinc/cp-kafka:5.3.0';
const DOCKER_ZOOKEEPER = 'confluentinc/cp-zookeeper:5.3.0';
const DOCKER_SONAR = 'sonarqube:7.9.1-community';
const DOCKER_JHIPSTER_CONSOLE = 'jhipster/jhipster-console:v4.1.0';
const DOCKER_JHIPSTER_CURATOR = 'jhipster/jhipster-curator:v4.1.0';
const DOCKER_JHIPSTER_ELASTICSEARCH = 'jhipster/jhipster-elasticsearch:v4.1.0';
const DOCKER_JHIPSTER_LOGSTASH = 'jhipster/jhipster-logstash:v4.1.0';
const DOCKER_JHIPSTER_IMPORT_DASHBOARDS = 'jhipster/jhipster-import-dashboards:v4.1.0';
const DOCKER_JHIPSTER_ZIPKIN = 'jhipster/jhipster-zipkin:v4.1.0';
const DOCKER_TRAEFIK = 'traefik:1.7.13';
const DOCKER_CONSUL = 'consul:1.5.3';
const DOCKER_CONSUL_CONFIG_LOADER = 'jhipster/consul-config-loader:v0.3.0';
const DOCKER_PROMETHEUS = 'prom/prometheus:v2.11.1';
const DOCKER_PROMETHEUS_ALERTMANAGER = 'prom/alertmanager:v0.18.0';
const DOCKER_GRAFANA = 'grafana/grafana:6.3.2';
const DOCKER_JENKINS = 'jenkins:latest';
const DOCKER_SWAGGER_EDITOR = 'swaggerapi/swagger-editor:latest';
const DOCKER_COMPOSE_FORMAT_VERSION = '2';
const DOCKER_PROMETHEUS_OPERATOR = 'quay.io/coreos/prometheus-operator:v0.31.1';
const DOCKER_GRAFANA_WATCHER = 'quay.io/coreos/grafana-watcher:v0.0.8';

// Kubernetes versions
const KUBERNETES_CORE_API_VERSION = 'v1';
const KUBERNETES_BATCH_API_VERSION = 'batch/v1';
const KUBERNETES_DEPLOYMENT_API_VERSION = 'apps/v1';
const KUBERNETES_STATEFULSET_API_VERSION = 'apps/v1';
const KUBERNETES_INGRESS_API_VERSION = 'extensions/v1beta1';
const KUBERNETES_ISTIO_NETWORKING_API_VERSION = 'networking.istio.io/v1alpha3';
const KUBERNETES_RBAC_API_VERSION = 'rbac.authorization.k8s.io/v1';

// Version of Java
const JAVA_VERSION = '1.8'; // Java version is forced to be 1.8. We keep the variable as it might be useful in the future.

// version of Node, Yarn, NPM
const NODE_VERSION = '10.16.3';
const YARN_VERSION = '1.17.3';
const NPM_VERSION = '6.11.2';

// Libraries version
const JIB_VERSION = '1.5.0';

// all constants used throughout all generators

const MAIN_DIR = 'src/main/';
const TEST_DIR = 'src/test/';

// Note: this will be prepended with 'target/classes' for Maven, or with 'build/resources/main' for Gradle.
const CLIENT_DIST_DIR = 'static/';

const SUPPORTED_VALIDATION_RULES = ['required', 'unique', 'max', 'min', 'maxlength', 'minlength', 'maxbytes', 'minbytes', 'pattern'];

// documentation constants
const JHIPSTER_DOCUMENTATION_URL = 'https://www.jhipster.tech';
const JHIPSTER_DOCUMENTATION_ARCHIVE_PATH = '/documentation-archive/';

const SQL_DB_OPTIONS = [
    {
        value: 'mysql',
        name: 'MySQL'
    },
    {
        value: 'mariadb',
        name: 'MariaDB'
    },
    {
        value: 'postgresql',
        name: 'PostgreSQL'
    },
    {
        value: 'oracle',
        name: 'Oracle (Please follow our documentation to use the Oracle proprietary driver)'
    },
    {
        value: 'mssql',
        name: 'Microsoft SQL Server'
    }
];

const LANGUAGES = [
    {
        name: 'Albanian',
        dispName: 'Shqip',
        value: 'al',
        momentLocaleId: 'sq'
    },
    {
        name: 'Arabic (Libya)',
        dispName: 'العربية',
        value: 'ar-ly',
        rtl: true,
        skipForLocale: true
    },
    {
        name: 'Armenian',
        dispName: 'Հայերեն',
        value: 'hy',
        momentLocaleId: 'hy-am'
    },
    {
        name: 'Belorussian',
        dispName: 'Беларускі',
        value: 'by',
        momentLocaleId: 'be-by'
    },
    {
        name: 'Bengali',
        dispName: 'বাংলা',
        value: 'bn',
        momentLocaleId: 'bn-bd'
    },
    {
        name: 'Catalan',
        dispName: 'Català',
        value: 'ca'
    },
    {
        name: 'Chinese (Simplified)',
        dispName: '中文（简体）',
        value: 'zh-cn',
        localeId: 'zh-Hans'
    },
    {
        name: 'Chinese (Traditional)',
        dispName: '繁體中文',
        value: 'zh-tw',
        localeId: 'zh-Hant'
    },
    { name: 'Czech', dispName: 'Český', value: 'cs' },
    { name: 'Danish', dispName: 'Dansk', value: 'da' },
    { name: 'Dutch', dispName: 'Nederlands', value: 'nl' },
    { name: 'English', dispName: 'English', value: 'en' },
    { name: 'Estonian', dispName: 'Eesti', value: 'et' },
    {
        name: 'Farsi',
        dispName: 'فارسی',
        value: 'fa',
        rtl: true
    },
    { name: 'Finnish', dispName: 'Suomi', value: 'fi' },
    { name: 'French', dispName: 'Français', value: 'fr' },
    { name: 'Galician', dispName: 'Galego', value: 'gl' },
    { name: 'German', dispName: 'Deutsch', value: 'de' },
    { name: 'Greek', dispName: 'Ελληνικά', value: 'el' },
    { name: 'Hindi', dispName: 'हिंदी', value: 'hi' },
    { name: 'Hungarian', dispName: 'Magyar', value: 'hu' },
    {
        name: 'Indonesian',
        dispName: 'Bahasa Indonesia',
        /*
           To fix a nasty bug in the JDK ("Indonesian Locale does not comply with ISO 639")
           The locale is set to "in" for Indonesia
           See https://bugs.openjdk.java.net/browse/JDK-6457127
           And https://github.com/jhipster/generator-jhipster/issues/9494
        */
        value: 'in',
        localeId: 'id',
        momentLocaleId: 'id'
    },
    { name: 'Italian', dispName: 'Italiano', value: 'it' },
    { name: 'Japanese', dispName: '日本語', value: 'ja' },
    { name: 'Korean', dispName: '한국어', value: 'ko' },
    { name: 'Marathi', dispName: 'मराठी', value: 'mr' },
    { name: 'Myanmar', dispName: 'မြန်မာ', value: 'my' },
    { name: 'Polish', dispName: 'Polski', value: 'pl' },
    {
        name: 'Portuguese (Brazilian)',
        dispName: 'Português (Brasil)',
        value: 'pt-br',
        localeId: 'pt'
    },
    {
        name: 'Portuguese',
        dispName: 'Português',
        value: 'pt-pt',
        localeId: 'pt-PT'
    },
    { name: 'Romanian', dispName: 'Română', value: 'ro' },
    { name: 'Russian', dispName: 'Русский', value: 'ru' },
    { name: 'Slovak', dispName: 'Slovenský', value: 'sk' },
    { name: 'Serbian', dispName: 'Srpski', value: 'sr' },
    { name: 'Spanish', dispName: 'Español', value: 'es' },
    { name: 'Swedish', dispName: 'Svenska', value: 'sv' },
    { name: 'Turkish', dispName: 'Türkçe', value: 'tr' },
    { name: 'Tamil', dispName: 'தமிழ்', value: 'ta' },
    { name: 'Telugu', dispName: 'తెలుగు', value: 'te' },
    { name: 'Thai', dispName: 'ไทย', value: 'th' },
    {
        name: 'Ukrainian',
        dispName: 'Українська',
        value: 'ua',
        localeId: 'uk',
        momentLocaleId: 'uk'
    },
    {
        name: 'Uzbek (Cyrillic)',
        dispName: 'Ўзбекча',
        value: 'uz-Cyrl-uz',
        localeId: 'uz-Cyrl'
    },
    {
        name: 'Uzbek (Latin)',
        dispName: 'O`zbekcha',
        value: 'uz-Latn-uz',
        localeId: 'uz-Latn'
    },
    { name: 'Vietnamese', dispName: 'Tiếng Việt', value: 'vi' }
];

const constants = {
    INTERPOLATE_REGEX: /<%:([\s\S]+?)%>/g, // so that tags in templates do not get mistreated as _ templates
    DOCKER_DIR: `${MAIN_DIR}docker/`,
    LINE_LENGTH: 180,
    LANGUAGES,

    MAIN_DIR,
    TEST_DIR,

    CLIENT_MAIN_SRC_DIR: `${MAIN_DIR}webapp/`,
    CLIENT_TEST_SRC_DIR: `${TEST_DIR}javascript/`,
    CLIENT_WEBPACK_DIR: 'webpack/',
    CLIENT_DIST_DIR,
    ANGULAR_DIR: `${MAIN_DIR}webapp/app/`,
    REACT_DIR: `${MAIN_DIR}webapp/app/`,

    SERVER_MAIN_SRC_DIR: `${MAIN_DIR}java/`,
    SERVER_MAIN_RES_DIR: `${MAIN_DIR}resources/`,
    SERVER_TEST_SRC_DIR: `${TEST_DIR}java/`,
    SERVER_TEST_RES_DIR: `${TEST_DIR}resources/`,

    // entity related
    SUPPORTED_VALIDATION_RULES,

    JHIPSTER_DOCUMENTATION_URL,
    JHIPSTER_DOCUMENTATION_ARCHIVE_PATH,

    DOCKER_JHIPSTER_REGISTRY,
    DOCKER_JAVA_JRE,
    DOCKER_MYSQL,
    DOCKER_MARIADB,
    DOCKER_POSTGRESQL,
    DOCKER_MONGODB,
    DOCKER_COUCHBASE,
    DOCKER_CASSANDRA,
    DOCKER_MSSQL,
    DOCKER_HAZELCAST_MANAGEMENT_CENTER,
    DOCKER_MEMCACHED,
    DOCKER_ELASTICSEARCH,
    DOCKER_KEYCLOAK,
    DOCKER_KAFKA,
    DOCKER_ZOOKEEPER,
    DOCKER_SONAR,
    DOCKER_JHIPSTER_CONSOLE,
    DOCKER_JHIPSTER_CURATOR,
    DOCKER_JHIPSTER_ELASTICSEARCH,
    DOCKER_JHIPSTER_LOGSTASH,
    DOCKER_JHIPSTER_IMPORT_DASHBOARDS,
    DOCKER_JHIPSTER_ZIPKIN,
    DOCKER_TRAEFIK,
    DOCKER_CONSUL,
    DOCKER_CONSUL_CONFIG_LOADER,
    DOCKER_PROMETHEUS,
    DOCKER_PROMETHEUS_ALERTMANAGER,
    DOCKER_GRAFANA,
    JAVA_VERSION,
    NODE_VERSION,
    YARN_VERSION,
    NPM_VERSION,

    // Libraries
    JIB_VERSION,

    DOCKER_JENKINS,
    DOCKER_SWAGGER_EDITOR,
    SQL_DB_OPTIONS,
    DOCKER_COMPOSE_FORMAT_VERSION,
    DOCKER_PROMETHEUS_OPERATOR,
    DOCKER_GRAFANA_WATCHER,
    KUBERNETES_CORE_API_VERSION,
    KUBERNETES_BATCH_API_VERSION,
    KUBERNETES_DEPLOYMENT_API_VERSION,
    KUBERNETES_STATEFULSET_API_VERSION,
    KUBERNETES_INGRESS_API_VERSION,
    KUBERNETES_ISTIO_NETWORKING_API_VERSION,
    KUBERNETES_RBAC_API_VERSION
};

module.exports = constants;
<|endoftext|>


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

// version of docker images
const DOCKER_JHIPSTER_REGISTRY = 'jhipster/jhipster-registry:v5.0.2';
const DOCKER_JAVA_JRE = 'adoptopenjdk:11-jre-hotspot';
const DOCKER_MYSQL = 'mysql:8.0.16';
const DOCKER_MARIADB = 'mariadb:10.4.6';
const DOCKER_POSTGRESQL = 'postgres:11.4';
const DOCKER_MONGODB = 'mongo:4.0.10';
const DOCKER_COUCHBASE = 'couchbase:6.0.2';
const DOCKER_CASSANDRA = 'cassandra:3.11.4';
const DOCKER_MSSQL = 'microsoft/mssql-server-linux:latest';
const DOCKER_HAZELCAST_MANAGEMENT_CENTER = 'hazelcast/management-center:3.12.2';
const DOCKER_MEMCACHED = 'memcached:1.5.16-alpine';
const DOCKER_KEYCLOAK = 'jboss/keycloak:6.0.1';
const DOCKER_ELASTICSEARCH = 'docker.elastic.co/elasticsearch/elasticsearch:6.4.3'; // The version should be coerent with the one from spring-data-elasticsearch project
const DOCKER_KAFKA = 'confluentinc/cp-kafka:5.3.0';
const DOCKER_ZOOKEEPER = 'confluentinc/cp-zookeeper:5.3.0';
const DOCKER_SONAR = 'sonarqube:7.9.1-community';
const DOCKER_JHIPSTER_CONSOLE = 'jhipster/jhipster-console:v4.1.0';
const DOCKER_JHIPSTER_CURATOR = 'jhipster/jhipster-curator:v4.1.0';
const DOCKER_JHIPSTER_ELASTICSEARCH = 'jhipster/jhipster-elasticsearch:v4.0.0';
const DOCKER_JHIPSTER_LOGSTASH = 'jhipster/jhipster-logstash:v4.0.0';
const DOCKER_JHIPSTER_IMPORT_DASHBOARDS = 'jhipster/jhipster-import-dashboards:v4.0.0';
const DOCKER_JHIPSTER_ZIPKIN = 'jhipster/jhipster-zipkin:v4.0.0';
const DOCKER_TRAEFIK = 'traefik:1.7.12';
const DOCKER_CONSUL = 'consul:1.5.2';
const DOCKER_CONSUL_CONFIG_LOADER = 'jhipster/consul-config-loader:v0.3.0';
const DOCKER_PROMETHEUS = 'prom/prometheus:v2.11.1';
const DOCKER_PROMETHEUS_ALERTMANAGER = 'prom/alertmanager:v0.18.0';
const DOCKER_GRAFANA = 'grafana/grafana:6.2.5';
const DOCKER_JENKINS = 'jenkins:latest';
const DOCKER_SWAGGER_EDITOR = 'swaggerapi/swagger-editor:latest';
const DOCKER_COMPOSE_FORMAT_VERSION = '2';
const DOCKER_PROMETHEUS_OPERATOR = 'quay.io/coreos/prometheus-operator:v0.31.1';
const DOCKER_GRAFANA_WATCHER = 'quay.io/coreos/grafana-watcher:v0.0.8';

// Kubernetes versions
const KUBERNETES_CORE_API_VERSION = 'v1';
const KUBERNETES_BATCH_API_VERSION = 'batch/v1';
const KUBERNETES_DEPLOYMENT_API_VERSION = 'apps/v1';
const KUBERNETES_STATEFULSET_API_VERSION = 'apps/v1';
const KUBERNETES_INGRESS_API_VERSION = 'extensions/v1beta1';
const KUBERNETES_ISTIO_NETWORKING_API_VERSION = 'networking.istio.io/v1alpha3';
const KUBERNETES_RBAC_API_VERSION = 'rbac.authorization.k8s.io/v1';

// Version of Java
const JAVA_VERSION = '1.8'; // Java version is forced to be 1.8. We keep the variable as it might be useful in the future.

// version of Node, Yarn, NPM
const NODE_VERSION = '10.16.0';
const YARN_VERSION = '1.17.3';
const NPM_VERSION = '6.9.2';

// Libraries version
const JIB_VERSION = '1.4.0';

// all constants used throughout all generators

const MAIN_DIR = 'src/main/';
const TEST_DIR = 'src/test/';

// Note: this will be prepended with 'target/classes' for Maven, or with 'build/resources/main' for Gradle.
const CLIENT_DIST_DIR = 'static/';

const SUPPORTED_VALIDATION_RULES = ['required', 'unique', 'max', 'min', 'maxlength', 'minlength', 'maxbytes', 'minbytes', 'pattern'];

// documentation constants
const JHIPSTER_DOCUMENTATION_URL = 'https://www.jhipster.tech';
const JHIPSTER_DOCUMENTATION_ARCHIVE_PATH = '/documentation-archive/';

const SQL_DB_OPTIONS = [
    {
        value: 'mysql',
        name: 'MySQL'
    },
    {
        value: 'mariadb',
        name: 'MariaDB'
    },
    {
        value: 'postgresql',
        name: 'PostgreSQL'
    },
    {
        value: 'oracle',
        name: 'Oracle (Please follow our documentation to use the Oracle proprietary driver)'
    },
    {
        value: 'mssql',
        name: 'Microsoft SQL Server'
    }
];

const LANGUAGES = [
    {
        name: 'Albanian',
        dispName: 'Shqip',
        value: 'al',
        momentLocaleId: 'sq'
    },
    {
        name: 'Arabic (Libya)',
        dispName: 'العربية',
        value: 'ar-ly',
        rtl: true,
        skipForLocale: true
    },
    {
        name: 'Armenian',
        dispName: 'Հայերեն',
        value: 'hy',
        momentLocaleId: 'hy-am'
    },
    {
        name: 'Belorussian',
        dispName: 'Беларускі',
        value: 'by',
        momentLocaleId: 'be-by'
    },
    {
        name: 'Bengali',
        dispName: 'বাংলা',
        value: 'bn',
        momentLocaleId: 'bn-bd'
    },
    {
        name: 'Catalan',
        dispName: 'Català',
        value: 'ca'
    },
    {
        name: 'Chinese (Simplified)',
        dispName: '中文（简体）',
        value: 'zh-cn',
        localeId: 'zh-Hans'
    },
    {
        name: 'Chinese (Traditional)',
        dispName: '繁體中文',
        value: 'zh-tw',
        localeId: 'zh-Hant'
    },
    { name: 'Czech', dispName: 'Český', value: 'cs' },
    { name: 'Danish', dispName: 'Dansk', value: 'da' },
    { name: 'Dutch', dispName: 'Nederlands', value: 'nl' },
    { name: 'English', dispName: 'English', value: 'en' },
    { name: 'Estonian', dispName: 'Eesti', value: 'et' },
    {
        name: 'Farsi',
        dispName: 'فارسی',
        value: 'fa',
        rtl: true
    },
    { name: 'Finnish', dispName: 'Suomi', value: 'fi' },
    { name: 'French', dispName: 'Français', value: 'fr' },
    { name: 'Galician', dispName: 'Galego', value: 'gl' },
    { name: 'German', dispName: 'Deutsch', value: 'de' },
    { name: 'Greek', dispName: 'Ελληνικά', value: 'el' },
    { name: 'Hindi', dispName: 'हिंदी', value: 'hi' },
    { name: 'Hungarian', dispName: 'Magyar', value: 'hu' },
    {
        name: 'Indonesian',
        dispName: 'Bahasa Indonesia',
        /*
           To fix a nasty bug in the JDK ("Indonesian Locale does not comply with ISO 639")
           The locale is set to "in" for Indonesia
           See https://bugs.openjdk.java.net/browse/JDK-6457127
           And https://github.com/jhipster/generator-jhipster/issues/9494
        */
        value: 'in',
        localeId: 'id',
        momentLocaleId: 'id'
    },
    { name: 'Italian', dispName: 'Italiano', value: 'it' },
    { name: 'Japanese', dispName: '日本語', value: 'ja' },
    { name: 'Korean', dispName: '한국어', value: 'ko' },
    { name: 'Marathi', dispName: 'मराठी', value: 'mr' },
    { name: 'Myanmar', dispName: 'မြန်မာ', value: 'my' },
    { name: 'Polish', dispName: 'Polski', value: 'pl' },
    {
        name: 'Portuguese (Brazilian)',
        dispName: 'Português (Brasil)',
        value: 'pt-br',
        localeId: 'pt'
    },
    {
        name: 'Portuguese',
        dispName: 'Português',
        value: 'pt-pt',
        localeId: 'pt-PT'
    },
    { name: 'Romanian', dispName: 'Română', value: 'ro' },
    { name: 'Russian', dispName: 'Русский', value: 'ru' },
    { name: 'Slovak', dispName: 'Slovenský', value: 'sk' },
    { name: 'Serbian', dispName: 'Srpski', value: 'sr' },
    { name: 'Spanish', dispName: 'Español', value: 'es' },
    { name: 'Swedish', dispName: 'Svenska', value: 'sv' },
    { name: 'Turkish', dispName: 'Türkçe', value: 'tr' },
    { name: 'Tamil', dispName: 'தமிழ்', value: 'ta' },
    { name: 'Telugu', dispName: 'తెలుగు', value: 'te' },
    { name: 'Thai', dispName: 'ไทย', value: 'th' },
    {
        name: 'Ukrainian',
        dispName: 'Українська',
        value: 'ua',
        localeId: 'uk',
        momentLocaleId: 'uk'
    },
    {
        name: 'Uzbek (Cyrillic)',
        dispName: 'Ўзбекча',
        value: 'uz-Cyrl-uz',
        localeId: 'uz-Cyrl'
    },
    {
        name: 'Uzbek (Latin)',
        dispName: 'O`zbekcha',
        value: 'uz-Latn-uz',
        localeId: 'uz-Latn'
    },
    { name: 'Vietnamese', dispName: 'Tiếng Việt', value: 'vi' }
];

const constants = {
    INTERPOLATE_REGEX: /<%:([\s\S]+?)%>/g, // so that tags in templates do not get mistreated as _ templates
    DOCKER_DIR: `${MAIN_DIR}docker/`,
    LINE_LENGTH: 180,
    LANGUAGES,

    MAIN_DIR,
    TEST_DIR,

    CLIENT_MAIN_SRC_DIR: `${MAIN_DIR}webapp/`,
    CLIENT_TEST_SRC_DIR: `${TEST_DIR}javascript/`,
    CLIENT_WEBPACK_DIR: 'webpack/',
    CLIENT_DIST_DIR,
    ANGULAR_DIR: `${MAIN_DIR}webapp/app/`,
    REACT_DIR: `${MAIN_DIR}webapp/app/`,

    SERVER_MAIN_SRC_DIR: `${MAIN_DIR}java/`,
    SERVER_MAIN_RES_DIR: `${MAIN_DIR}resources/`,
    SERVER_TEST_SRC_DIR: `${TEST_DIR}java/`,
    SERVER_TEST_RES_DIR: `${TEST_DIR}resources/`,

    // entity related
    SUPPORTED_VALIDATION_RULES,

    JHIPSTER_DOCUMENTATION_URL,
    JHIPSTER_DOCUMENTATION_ARCHIVE_PATH,

    DOCKER_JHIPSTER_REGISTRY,
    DOCKER_JAVA_JRE,
    DOCKER_MYSQL,
    DOCKER_MARIADB,
    DOCKER_POSTGRESQL,
    DOCKER_MONGODB,
    DOCKER_COUCHBASE,
    DOCKER_CASSANDRA,
    DOCKER_MSSQL,
    DOCKER_HAZELCAST_MANAGEMENT_CENTER,
    DOCKER_MEMCACHED,
    DOCKER_ELASTICSEARCH,
    DOCKER_KEYCLOAK,
    DOCKER_KAFKA,
    DOCKER_ZOOKEEPER,
    DOCKER_SONAR,
    DOCKER_JHIPSTER_CONSOLE,
    DOCKER_JHIPSTER_CURATOR,
    DOCKER_JHIPSTER_ELASTICSEARCH,
    DOCKER_JHIPSTER_LOGSTASH,
    DOCKER_JHIPSTER_IMPORT_DASHBOARDS,
    DOCKER_JHIPSTER_ZIPKIN,
    DOCKER_TRAEFIK,
    DOCKER_CONSUL,
    DOCKER_CONSUL_CONFIG_LOADER,
    DOCKER_PROMETHEUS,
    DOCKER_PROMETHEUS_ALERTMANAGER,
    DOCKER_GRAFANA,
    JAVA_VERSION,
    NODE_VERSION,
    YARN_VERSION,
    NPM_VERSION,

    // Libraries
    JIB_VERSION,

    DOCKER_JENKINS,
    DOCKER_SWAGGER_EDITOR,
    SQL_DB_OPTIONS,
    DOCKER_COMPOSE_FORMAT_VERSION,
    DOCKER_PROMETHEUS_OPERATOR,
    DOCKER_GRAFANA_WATCHER,
    KUBERNETES_CORE_API_VERSION,
    KUBERNETES_BATCH_API_VERSION,
    KUBERNETES_DEPLOYMENT_API_VERSION,
    KUBERNETES_STATEFULSET_API_VERSION,
    KUBERNETES_INGRESS_API_VERSION,
    KUBERNETES_ISTIO_NETWORKING_API_VERSION,
    KUBERNETES_RBAC_API_VERSION
};

module.exports = constants;
<commit_msg>Update jhipster/jhipster-elasticsearch docker image to v4.1.0<commit_after>/**
 * Copyright 2013-2019 the original author or authors from the JHipster project.
 *
 * This file is part of the JHipster project, see https://www.jhipster.tech/
 * for more information.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// version of docker images
const DOCKER_JHIPSTER_REGISTRY = 'jhipster/jhipster-registry:v5.0.2';
const DOCKER_JAVA_JRE = 'adoptopenjdk:11-jre-hotspot';
const DOCKER_MYSQL = 'mysql:8.0.16';
const DOCKER_MARIADB = 'mariadb:10.4.6';
const DOCKER_POSTGRESQL = 'postgres:11.4';
const DOCKER_MONGODB = 'mongo:4.0.10';
const DOCKER_COUCHBASE = 'couchbase:6.0.2';
const DOCKER_CASSANDRA = 'cassandra:3.11.4';
const DOCKER_MSSQL = 'microsoft/mssql-server-linux:latest';
const DOCKER_HAZELCAST_MANAGEMENT_CENTER = 'hazelcast/management-center:3.12.2';
const DOCKER_MEMCACHED = 'memcached:1.5.16-alpine';
const DOCKER_KEYCLOAK = 'jboss/keycloak:6.0.1';
const DOCKER_ELASTICSEARCH = 'docker.elastic.co/elasticsearch/elasticsearch:6.4.3'; // The version should be coerent with the one from spring-data-elasticsearch project
const DOCKER_KAFKA = 'confluentinc/cp-kafka:5.3.0';
const DOCKER_ZOOKEEPER = 'confluentinc/cp-zookeeper:5.3.0';
const DOCKER_SONAR = 'sonarqube:7.9.1-community';
const DOCKER_JHIPSTER_CONSOLE = 'jhipster/jhipster-console:v4.1.0';
const DOCKER_JHIPSTER_CURATOR = 'jhipster/jhipster-curator:v4.1.0';
const DOCKER_JHIPSTER_ELASTICSEARCH = 'jhipster/jhipster-elasticsearch:v4.1.0';
const DOCKER_JHIPSTER_LOGSTASH = 'jhipster/jhipster-logstash:v4.0.0';
const DOCKER_JHIPSTER_IMPORT_DASHBOARDS = 'jhipster/jhipster-import-dashboards:v4.0.0';
const DOCKER_JHIPSTER_ZIPKIN = 'jhipster/jhipster-zipkin:v4.0.0';
const DOCKER_TRAEFIK = 'traefik:1.7.12';
const DOCKER_CONSUL = 'consul:1.5.2';
const DOCKER_CONSUL_CONFIG_LOADER = 'jhipster/consul-config-loader:v0.3.0';
const DOCKER_PROMETHEUS = 'prom/prometheus:v2.11.1';
const DOCKER_PROMETHEUS_ALERTMANAGER = 'prom/alertmanager:v0.18.0';
const DOCKER_GRAFANA = 'grafana/grafana:6.2.5';
const DOCKER_JENKINS = 'jenkins:latest';
const DOCKER_SWAGGER_EDITOR = 'swaggerapi/swagger-editor:latest';
const DOCKER_COMPOSE_FORMAT_VERSION = '2';
const DOCKER_PROMETHEUS_OPERATOR = 'quay.io/coreos/prometheus-operator:v0.31.1';
const DOCKER_GRAFANA_WATCHER = 'quay.io/coreos/grafana-watcher:v0.0.8';

// Kubernetes versions
const KUBERNETES_CORE_API_VERSION = 'v1';
const KUBERNETES_BATCH_API_VERSION = 'batch/v1';
const KUBERNETES_DEPLOYMENT_API_VERSION = 'apps/v1';
const KUBERNETES_STATEFULSET_API_VERSION = 'apps/v1';
const KUBERNETES_INGRESS_API_VERSION = 'extensions/v1beta1';
const KUBERNETES_ISTIO_NETWORKING_API_VERSION = 'networking.istio.io/v1alpha3';
const KUBERNETES_RBAC_API_VERSION = 'rbac.authorization.k8s.io/v1';

// Version of Java
const JAVA_VERSION = '1.8'; // Java version is forced to be 1.8. We keep the variable as it might be useful in the future.

// version of Node, Yarn, NPM
const NODE_VERSION = '10.16.0';
const YARN_VERSION = '1.17.3';
const NPM_VERSION = '6.9.2';

// Libraries version
const JIB_VERSION = '1.4.0';

// all constants used throughout all generators

const MAIN_DIR = 'src/main/';
const TEST_DIR = 'src/test/';

// Note: this will be prepended with 'target/classes' for Maven, or with 'build/resources/main' for Gradle.
const CLIENT_DIST_DIR = 'static/';

const SUPPORTED_VALIDATION_RULES = ['required', 'unique', 'max', 'min', 'maxlength', 'minlength', 'maxbytes', 'minbytes', 'pattern'];

// documentation constants
const JHIPSTER_DOCUMENTATION_URL = 'https://www.jhipster.tech';
const JHIPSTER_DOCUMENTATION_ARCHIVE_PATH = '/documentation-archive/';

const SQL_DB_OPTIONS = [
    {
        value: 'mysql',
        name: 'MySQL'
    },
    {
        value: 'mariadb',
        name: 'MariaDB'
    },
    {
        value: 'postgresql',
        name: 'PostgreSQL'
    },
    {
        value: 'oracle',
        name: 'Oracle (Please follow our documentation to use the Oracle proprietary driver)'
    },
    {
        value: 'mssql',
        name: 'Microsoft SQL Server'
    }
];

const LANGUAGES = [
    {
        name: 'Albanian',
        dispName: 'Shqip',
        value: 'al',
        momentLocaleId: 'sq'
    },
    {
        name: 'Arabic (Libya)',
        dispName: 'العربية',
        value: 'ar-ly',
        rtl: true,
        skipForLocale: true
    },
    {
        name: 'Armenian',
        dispName: 'Հայերեն',
        value: 'hy',
        momentLocaleId: 'hy-am'
    },
    {
        name: 'Belorussian',
        dispName: 'Беларускі',
        value: 'by',
        momentLocaleId: 'be-by'
    },
    {
        name: 'Bengali',
        dispName: 'বাংলা',
        value: 'bn',
        momentLocaleId: 'bn-bd'
    },
    {
        name: 'Catalan',
        dispName: 'Català',
        value: 'ca'
    },
    {
        name: 'Chinese (Simplified)',
        dispName: '中文（简体）',
        value: 'zh-cn',
        localeId: 'zh-Hans'
    },
    {
        name: 'Chinese (Traditional)',
        dispName: '繁體中文',
        value: 'zh-tw',
        localeId: 'zh-Hant'
    },
    { name: 'Czech', dispName: 'Český', value: 'cs' },
    { name: 'Danish', dispName: 'Dansk', value: 'da' },
    { name: 'Dutch', dispName: 'Nederlands', value: 'nl' },
    { name: 'English', dispName: 'English', value: 'en' },
    { name: 'Estonian', dispName: 'Eesti', value: 'et' },
    {
        name: 'Farsi',
        dispName: 'فارسی',
        value: 'fa',
        rtl: true
    },
    { name: 'Finnish', dispName: 'Suomi', value: 'fi' },
    { name: 'French', dispName: 'Français', value: 'fr' },
    { name: 'Galician', dispName: 'Galego', value: 'gl' },
    { name: 'German', dispName: 'Deutsch', value: 'de' },
    { name: 'Greek', dispName: 'Ελληνικά', value: 'el' },
    { name: 'Hindi', dispName: 'हिंदी', value: 'hi' },
    { name: 'Hungarian', dispName: 'Magyar', value: 'hu' },
    {
        name: 'Indonesian',
        dispName: 'Bahasa Indonesia',
        /*
           To fix a nasty bug in the JDK ("Indonesian Locale does not comply with ISO 639")
           The locale is set to "in" for Indonesia
           See https://bugs.openjdk.java.net/browse/JDK-6457127
           And https://github.com/jhipster/generator-jhipster/issues/9494
        */
        value: 'in',
        localeId: 'id',
        momentLocaleId: 'id'
    },
    { name: 'Italian', dispName: 'Italiano', value: 'it' },
    { name: 'Japanese', dispName: '日本語', value: 'ja' },
    { name: 'Korean', dispName: '한국어', value: 'ko' },
    { name: 'Marathi', dispName: 'मराठी', value: 'mr' },
    { name: 'Myanmar', dispName: 'မြန်မာ', value: 'my' },
    { name: 'Polish', dispName: 'Polski', value: 'pl' },
    {
        name: 'Portuguese (Brazilian)',
        dispName: 'Português (Brasil)',
        value: 'pt-br',
        localeId: 'pt'
    },
    {
        name: 'Portuguese',
        dispName: 'Português',
        value: 'pt-pt',
        localeId: 'pt-PT'
    },
    { name: 'Romanian', dispName: 'Română', value: 'ro' },
    { name: 'Russian', dispName: 'Русский', value: 'ru' },
    { name: 'Slovak', dispName: 'Slovenský', value: 'sk' },
    { name: 'Serbian', dispName: 'Srpski', value: 'sr' },
    { name: 'Spanish', dispName: 'Español', value: 'es' },
    { name: 'Swedish', dispName: 'Svenska', value: 'sv' },
    { name: 'Turkish', dispName: 'Türkçe', value: 'tr' },
    { name: 'Tamil', dispName: 'தமிழ்', value: 'ta' },
    { name: 'Telugu', dispName: 'తెలుగు', value: 'te' },
    { name: 'Thai', dispName: 'ไทย', value: 'th' },
    {
        name: 'Ukrainian',
        dispName: 'Українська',
        value: 'ua',
        localeId: 'uk',
        momentLocaleId: 'uk'
    },
    {
        name: 'Uzbek (Cyrillic)',
        dispName: 'Ўзбекча',
        value: 'uz-Cyrl-uz',
        localeId: 'uz-Cyrl'
    },
    {
        name: 'Uzbek (Latin)',
        dispName: 'O`zbekcha',
        value: 'uz-Latn-uz',
        localeId: 'uz-Latn'
    },
    { name: 'Vietnamese', dispName: 'Tiếng Việt', value: 'vi' }
];

const constants = {
    INTERPOLATE_REGEX: /<%:([\s\S]+?)%>/g, // so that tags in templates do not get mistreated as _ templates
    DOCKER_DIR: `${MAIN_DIR}docker/`,
    LINE_LENGTH: 180,
    LANGUAGES,

    MAIN_DIR,
    TEST_DIR,

    CLIENT_MAIN_SRC_DIR: `${MAIN_DIR}webapp/`,
    CLIENT_TEST_SRC_DIR: `${TEST_DIR}javascript/`,
    CLIENT_WEBPACK_DIR: 'webpack/',
    CLIENT_DIST_DIR,
    ANGULAR_DIR: `${MAIN_DIR}webapp/app/`,
    REACT_DIR: `${MAIN_DIR}webapp/app/`,

    SERVER_MAIN_SRC_DIR: `${MAIN_DIR}java/`,
    SERVER_MAIN_RES_DIR: `${MAIN_DIR}resources/`,
    SERVER_TEST_SRC_DIR: `${TEST_DIR}java/`,
    SERVER_TEST_RES_DIR: `${TEST_DIR}resources/`,

    // entity related
    SUPPORTED_VALIDATION_RULES,

    JHIPSTER_DOCUMENTATION_URL,
    JHIPSTER_DOCUMENTATION_ARCHIVE_PATH,

    DOCKER_JHIPSTER_REGISTRY,
    DOCKER_JAVA_JRE,
    DOCKER_MYSQL,
    DOCKER_MARIADB,
    DOCKER_POSTGRESQL,
    DOCKER_MONGODB,
    DOCKER_COUCHBASE,
    DOCKER_CASSANDRA,
    DOCKER_MSSQL,
    DOCKER_HAZELCAST_MANAGEMENT_CENTER,
    DOCKER_MEMCACHED,
    DOCKER_ELASTICSEARCH,
    DOCKER_KEYCLOAK,
    DOCKER_KAFKA,
    DOCKER_ZOOKEEPER,
    DOCKER_SONAR,
    DOCKER_JHIPSTER_CONSOLE,
    DOCKER_JHIPSTER_CURATOR,
    DOCKER_JHIPSTER_ELASTICSEARCH,
    DOCKER_JHIPSTER_LOGSTASH,
    DOCKER_JHIPSTER_IMPORT_DASHBOARDS,
    DOCKER_JHIPSTER_ZIPKIN,
    DOCKER_TRAEFIK,
    DOCKER_CONSUL,
    DOCKER_CONSUL_CONFIG_LOADER,
    DOCKER_PROMETHEUS,
    DOCKER_PROMETHEUS_ALERTMANAGER,
    DOCKER_GRAFANA,
    JAVA_VERSION,
    NODE_VERSION,
    YARN_VERSION,
    NPM_VERSION,

    // Libraries
    JIB_VERSION,

    DOCKER_JENKINS,
    DOCKER_SWAGGER_EDITOR,
    SQL_DB_OPTIONS,
    DOCKER_COMPOSE_FORMAT_VERSION,
    DOCKER_PROMETHEUS_OPERATOR,
    DOCKER_GRAFANA_WATCHER,
    KUBERNETES_CORE_API_VERSION,
    KUBERNETES_BATCH_API_VERSION,
    KUBERNETES_DEPLOYMENT_API_VERSION,
    KUBERNETES_STATEFULSET_API_VERSION,
    KUBERNETES_INGRESS_API_VERSION,
    KUBERNETES_ISTIO_NETWORKING_API_VERSION,
    KUBERNETES_RBAC_API_VERSION
};

module.exports = constants;
<|endoftext|>