<commit_before>var CRDT = (function () {

    return {
        newCounter: function (id) {

            var initialIncrement = new VectorClock({});
            var initialDecrement = new VectorClock({});

            return new Counter(id, initialIncrement, initialDecrement);
        },

        newCounterFromJSON: function (id, jsonBag) {
            if (typeof jsonBag === "string") {
                jsonBag = JSON.parse(jsonBag);
            }

            log("JSON BAG on counter building:", jsonBag);

            var increment = {};
            if (jsonBag['increment']) {
                if (typeof jsonBag['increment'] === "string"){
                    jsonBag['increment'] = JSON.parse(jsonBag['increment']);
                }
                increment = new VectorClock(jsonBag['increment']);
            }

            var decrement = {};
            if (jsonBag['decrement']) {
                if (typeof jsonBag['decrement'] === "string"){
                    jsonBag['decrement'] = JSON.parse(jsonBag['decrement']);
                }
                decrement = new VectorClock(jsonBag['decrement']);
            }

            if (id === 0) {
                id = jsonBag['id'];
            }

            return new Counter(id, increment, decrement);
        },

        newRegister: function () {

        },

        newRegisterFromJSON: function () {

        }
    }
})();<commit_msg>Added code so the CRDT factory can also build MVRegisters and RegisterValues.<commit_after>var CRDT = (function () {

    return {
        newCounter: function (id) {

            var initialIncrement = new VectorClock({});
            var initialDecrement = new VectorClock({});

            return new Counter(id, initialIncrement, initialDecrement);
        },

        newCounterFromJSON: function (id, jsonBag) {
            if (typeof jsonBag === "string") {
                jsonBag = JSON.parse(jsonBag);
            }

            var increment = {};
            if (jsonBag['increment']) {
                if (typeof jsonBag['increment'] === "string"){
                    jsonBag['increment'] = JSON.parse(jsonBag['increment']);
                }
                increment = new VectorClock(jsonBag['increment']);
            }

            var decrement = {};
            if (jsonBag['decrement']) {
                if (typeof jsonBag['decrement'] === "string"){
                    jsonBag['decrement'] = JSON.parse(jsonBag['decrement']);
                }
                decrement = new VectorClock(jsonBag['decrement']);
            }

            if (id === 0) {
                id = jsonBag['id'];
            }

            return new Counter(id, increment, decrement);
        },

        newRegister: function (id) {
            return new MVRegister(id, []);
        },

        newRegisterFromJSON: function (id, jsonBag) {
            if (typeof jsonBag === "string") {
                jsonBag = JSON.parse(jsonBag);
            }

            var data = [];
            if (typeof jsonBag['data'] != 'undefined'){
                jsonBag['data'].forEach(function (element){
                    data[data.length] = CRDT.newRegisterValueFromSimpleObject(element);
                });
            }

            if (id === 0) {
                id = jsonBag['id'];
            }

            return new MVRegister(id, data);
        },

        newRegisterValueFromSimpleObject: function (data){
            if (!data.hasOwnProperty('value') || !data['vectorClock']){
                log("A register value cannot be created without a value and a vectorClock!!");
                return false;
            }
            return new RegisterValue(new VectorClock(data['vectorClock']), data['value']);
        }
    }
})();<|endoftext|>


<commit_before>import React from 'react'
import Link from 'next/link'

const WPPage = (props) => {
  return (

{props.name}

{props.bio}

        {props.location}

  )
}

export default WPPage
<commit_msg>closed #5<commit_after>import React from 'react'
import Link from 'next/link'

const GithubUser = (props) => {
  return (

{props.name}

{props.bio}

        {props.location}

  )
}

export default GithubUser
<|endoftext|>


<commit_before>//=====================================//
//        SERVER CONFIGURATION         //
//=====================================//
//if( process.env ) {                  // TOGGLE ON FOR OPENSHIFT DEPLOY
//=====================================//
//IP ADDRESS                           //
  var SERVER_IP =                      //
  'localhost';                         // toggle on for local testing
//process.env.OPENSHIFT_NODEJS_IP;     // toggle on for openshift deploy
//=====================================//
//PORT NUMBER                          //
  var SERVER_PORT =                    //
  8080;                                // toggle on for local testing
//process.env.OPENSHIFT_NODEJS_PORT;   // toggle on for openshift deploy
//=====================================//
//}                                    // TOGGLE ON FOR OPENSHIFT DEPLOY
//=====================================//

//=====================================//
//         CLIENT CONFIGURATION        //
//=====================================//
//IP ADDRESS                           //
  var CLIENT_IP =                      //
  'localhost';                         // toggle on for local testing
//'435-teamnoname.rhcloud.com';        // toggle on for openshift deploy
//=====================================//
//PORT NUMBER                          //
  var CLIENT_PORT =                    //
  8080;                                // toggle on for local testing
//8000;                                // neccessary for openshift, as websockets is restricted to this port
//=====================================//

if( process == 'SERVER' || process.env ) {
	module.exports.CLIENT_IP   = CLIENT_IP;
	module.exports.CLIENT_PORT = CLIENT_PORT;
	module.exports.SERVER_IP   = SERVER_IP;
	module.exports.SERVER_PORT = SERVER_PORT;
}
<commit_msg>switched to deploy mode<commit_after>//=====================================//
//        SERVER CONFIGURATION         //
//=====================================//
  if( process.env ) {                  // TOGGLE ON FOR OPENSHIFT DEPLOY
//=====================================//
//IP ADDRESS                           //
  var SERVER_IP =                      //
//'localhost';                         // toggle on for local testing
  process.env.OPENSHIFT_NODEJS_IP;     // toggle on for openshift deploy
//=====================================//
//PORT NUMBER                          //
  var SERVER_PORT =                    //
//8080;                                // toggle on for local testing
  process.env.OPENSHIFT_NODEJS_PORT;   // toggle on for openshift deploy
//=====================================//
  }                                    // TOGGLE ON FOR OPENSHIFT DEPLOY
//=====================================//

//=====================================//
//         CLIENT CONFIGURATION        //
//=====================================//
//IP ADDRESS                           //
  var CLIENT_IP =                      //
//'localhost';                         // toggle on for local testing
  '435-teamnoname.rhcloud.com';        // toggle on for openshift deploy
//=====================================//
//PORT NUMBER                          //
  var CLIENT_PORT =                    //
//8080;                                // toggle on for local testing
  8000;                                // neccessary for openshift, as websockets is restricted to this port
//=====================================//

if( process == 'SERVER' || process.env ) {
	module.exports.CLIENT_IP   = CLIENT_IP;
	module.exports.CLIENT_PORT = CLIENT_PORT;
	module.exports.SERVER_IP   = SERVER_IP;
	module.exports.SERVER_PORT = SERVER_PORT;
}
<|endoftext|>


<commit_before>var config = {};

config.upload_dir = require('path').join(__dirname,'..','public','cdn');

config.sendgrid_user = 'app2952775@heroku.com';
config.sendgrid_key = 'a0oui08x';
config.systemEmail = 'maagal@sheatufim.org.il';
config.systemEmailName = 'SHEATUFIM';

config.DB_URL = process.env['MONGOLAB_URI'] || 'mongodb://localhost/idemos';
config.ROOT_PATH = process.env.ROOT_PATH || 'http://dev.empeeric.com';

// facebook app params
config.fb_auth_params = {
    appId : process.env['FACEBOOK_APPID'] || '',
    appSecret: process.env['FACEBOOK_SECRET'] || '',
    appName: process.env['FACEBOOK_APPNAME'] || '',
    callback: config.ROOT_PATH + '/account/facebooklogin',
    scope: 'email,publish_actions',
    failedUri: '/noauth'
};

config.fb_general_params = {
    fb_title: '',
    fb_description:  '',
    fb_image: ''
}

/**
 * Static fils configuration
 */
config.headConfigs = {
    css_includes:{
        type:'css',
        name:'includes',
        src:[
            '/css/reset.css',
            '/css/style.css',
            '/css/feedback.css',
            '/css/colorbox.css',
            '/css/loginpop.css',
            '/css/myuruproxy.css',
            '/css/jquery.tooltip.css',
            '/css/select2.css'
        ]
    },
    js_includes:{
        type:'js',
        name:'includes',
        src:[

            '/js/jquerypp/jquery-1.10.2.js',
            '/js/jquerypp/jquery-ui-1.9.1.custom.min.js',
            '/js/lib/dust-full-0.3.0.js',
           // '/js/InfoBox.js',
            '/js/lib/fileuploader.js',
            '/js/upload.js',
            '/js/imgscale.jquery.min.js',
            '/js/jquerypp/jqtouch.min.js',
            '/js/jquerypp/jquery-fieldselection.js',
            '/js/jquerypp/jquery.autoellipsis-1.0.8.min.js',
            '/js/jquerypp/jquery.colorbox-min.js',
            '/js/jquerypp/jquery.cycle.all.js',
            '/js/jquerypp/jquery.easing.1.3.js',
            '/js/jquerypp/jquery.placeholder.min.js',
            '/js/jquerypp/jquery.tools.min.js',
            '/js/jquerypp/jquery.tooltip.min.js',
            '/js/jquerypp/jquery.validate.min.js',
            '/js/jquerypp/jquery.compare.js',
            '/js/jquerypp/jquery.range.js',
            '/js/jquerypp/jquery.selection.js',
            '/js/jquerypp/jquery.truncate.js',

            '/js/jquery.cookie.js',
            '/js/lib/date.format.js',
            '/js/select2.js',

            /*'/plugins/ckeditor/ckeditor.js',
             '/plugins/ckeditor/adapters/jquery.js',*/

            '/js/common.js',
            '/js/compiled_templates.js',
            '/js/db.js',
            '/js/fb.js',
            '/js/lib/search.js',
            '/js/timeline-min.js',
            '/js/storyjs-embed.js',
            '/js/tokensbar_model.js',
            '/js/listCommon.js',
            '/js/popupProvider.js',
            '/js/proxy_common.js',
            '/js/lib/maps.js',

            '/js/jquerypp/jquery.movingboxes.js',
            '/js/jquerypp/jquery.dotdotdot-1.5.6-packed.js',
            '/js/timeline.js',
            '/js/countdown.js',
            '/js/custom/script.js',
            '/js/custom/links_and_info_items.js'

            /*'/js/jquerypp/jquery.dotdotdot-1.5.6-packed.js'*/
        ]
    }
};

module.exports = config;
<commit_msg>add description<commit_after>var config = {};

config.upload_dir = require('path').join(__dirname,'..','public','cdn');

config.sendgrid_user = 'app2952775@heroku.com';
config.sendgrid_key = 'a0oui08x';
config.systemEmail = 'maagal@sheatufim.org.il';
config.systemEmailName = 'SHEATUFIM';

config.DB_URL = process.env['MONGOLAB_URI'] || 'mongodb://localhost/idemos';
config.ROOT_PATH = process.env.ROOT_PATH || 'http://dev.empeeric.com';

// facebook app params
config.fb_auth_params = {
    appId : process.env['FACEBOOK_APPID'] || '',
    appSecret: process.env['FACEBOOK_SECRET'] || '',
    appName: process.env['FACEBOOK_APPNAME'] || '',
    callback: config.ROOT_PATH + '/account/facebooklogin',
    scope: 'email,publish_actions',
    failedUri: '/noauth'
};

config.fb_general_params = {
    fb_title: '',
    fb_description:  'אתר "מעגלי השיח" מבית שיתופים נועד לתמוך בתהליכי שיח רבי משתתפים באמצעות סביבה אינטרנטית נגישה, המותאמת לכל תהליך ופתוחה למשתמשים מורשים בלבד.',
    fb_image: ''
}

/**
 * Static fils configuration
 */
config.headConfigs = {
    css_includes:{
        type:'css',
        name:'includes',
        src:[
            '/css/reset.css',
            '/css/style.css',
            '/css/feedback.css',
            '/css/colorbox.css',
            '/css/loginpop.css',
            '/css/myuruproxy.css',
            '/css/jquery.tooltip.css',
            '/css/select2.css'
        ]
    },
    js_includes:{
        type:'js',
        name:'includes',
        src:[

            '/js/jquerypp/jquery-1.10.2.js',
            '/js/jquerypp/jquery-ui-1.9.1.custom.min.js',
            '/js/lib/dust-full-0.3.0.js',
           // '/js/InfoBox.js',
            '/js/lib/fileuploader.js',
            '/js/upload.js',
            '/js/imgscale.jquery.min.js',
            '/js/jquerypp/jqtouch.min.js',
            '/js/jquerypp/jquery-fieldselection.js',
            '/js/jquerypp/jquery.autoellipsis-1.0.8.min.js',
            '/js/jquerypp/jquery.colorbox-min.js',
            '/js/jquerypp/jquery.cycle.all.js',
            '/js/jquerypp/jquery.easing.1.3.js',
            '/js/jquerypp/jquery.placeholder.min.js',
            '/js/jquerypp/jquery.tools.min.js',
            '/js/jquerypp/jquery.tooltip.min.js',
            '/js/jquerypp/jquery.validate.min.js',
            '/js/jquerypp/jquery.compare.js',
            '/js/jquerypp/jquery.range.js',
            '/js/jquerypp/jquery.selection.js',
            '/js/jquerypp/jquery.truncate.js',

            '/js/jquery.cookie.js',
            '/js/lib/date.format.js',
            '/js/select2.js',

            /*'/plugins/ckeditor/ckeditor.js',
             '/plugins/ckeditor/adapters/jquery.js',*/

            '/js/common.js',
            '/js/compiled_templates.js',
            '/js/db.js',
            '/js/fb.js',
            '/js/lib/search.js',
            '/js/timeline-min.js',
            '/js/storyjs-embed.js',
            '/js/tokensbar_model.js',
            '/js/listCommon.js',
            '/js/popupProvider.js',
            '/js/proxy_common.js',
            '/js/lib/maps.js',

            '/js/jquerypp/jquery.movingboxes.js',
            '/js/jquerypp/jquery.dotdotdot-1.5.6-packed.js',
            '/js/timeline.js',
            '/js/countdown.js',
            '/js/custom/script.js',
            '/js/custom/links_and_info_items.js'

            /*'/js/jquerypp/jquery.dotdotdot-1.5.6-packed.js'*/
        ]
    }
};

module.exports = config;
<|endoftext|>


<commit_before>import React from 'react'
import {Glyphicon} from 'react-bootstrap'
import style from '../css/Style'
import {selectionArray, occurrencesInString, normalizeString} from '../utils/selectionHelpers'
import MyLanguageModal from './MyLanguageModal'

class SelectArea extends React.Component {
  constructor() {
    super();
    this.state = {
      inBox: false,
      modalVisibility: false
    }
  }
/*
 * @description
 * Implementation notes on why you can't just use the window.getSelection()
 * getSelection is limited by same innerText node, and does not include span siblings
 * indexOfTextSelection is broken by any other previous selection since it only knows its innerText node.
 */
  getSelectionText() {
    if (!this.props.loginReducer.loggedInUser) {
      this.props.actions.selectModalTab(1, 1, true);
      this.props.actions.openAlertDialog("You must be logged in to make a selection");
      return;
    }
    // windowSelection is an object with lots of data
    let windowSelection = window.getSelection();
    // get the current text selected
    let selectedText = windowSelection.toString();

    // do nothing since an empty space was selected
    if (selectedText === '') {} else {
      // get the text after the presceding selection and current span selection is in.
      let selectionRange = windowSelection.getRangeAt(0)
      // get the character index of what is selected in context of the span it is in.
      let indexOfTextSelection = selectionRange.startOffset;
      // get the container of the selection, this is a strange object, that logs as a string.
      let textContainer = selectionRange.commonAncestorContainer;
      // get the parent span that contains the textContainer.
      let textSpan = textContainer ? textContainer.parentElement : undefined;
      // get all of the text in the selection's container similar to the span's innerText.
      let textSpanContent = textSpan.innerText;
      // get the text presceding the selection but after the selection just prior to it.
      let postPrescedingText = textContainer ? textSpanContent.slice(0,indexOfTextSelection) : '';
      // start with an empty string to prepend to for text presceding current span selection is in.
      let prescedingText = '';
      // if we have a span that holds text, see what presceding text we can extract.
      if (textSpan) {
        // get the previous sibling to start the loop
        let previousSibling = textSpan.previousSibling;
        // loop through previous spans to get their text
        while (previousSibling) {
          // prepend the spans innerText to the prescedingText
          prescedingText = previousSibling.innerText + prescedingText;
          // move to the previous span, if none, it ends the loop
          previousSibling = previousSibling.previousSibling;
        }
      }

      // There can be a gap between prescedingText and current selection
      let textBeforeSelection = prescedingText + postPrescedingText + selectedText;
      // get the occurrence of the selection
      let occurrence = occurrencesInString(textBeforeSelection, selectedText);
      // verseText is used to get all of the occurrences
      let verseText = this.props.verseText;
      // replace more than one contiguous space with a single one since HTML/selection only renders 1
      verseText = normalizeString(verseText);
      // get the total occurrences from the verse
      let occurrences = occurrencesInString(verseText, selectedText);
      let selection = {
        text: selectedText,
        occurrence: occurrence,
        occurrences: occurrences
      };
      // add the selection to the selections
      this.addSelection(selection);
    }
  }

  addSelection(selection) {
    let selections = this.props.selectionsReducer.selections;
    if (selections.length >= 4) {
      this.props.actions.openAlertDialog('Click a previous selection to remove it before adding a new one. To select more than 4 words, highlight phrases instead of individual words.')
      return false
    } else {
      selections.push(selection);
    }
    this.props.actions.changeSelections(selections);
  }

  removeSelection(selection) {
    let selections = this.props.selectionsReducer.selections;
    selections = selections.filter(_selection =>
      _selection.occurrence !== selection.occurrence || _selection.text !== selection.text
    )
    this.props.actions.changeSelections(selections);
  }

  displayText() {
    let { selections } = this.props.selectionsReducer;
    let verseText = this.props.verseText;
    // normalize whitespace for text rendering in order to display highlights with more than one space since html selections show one space
    verseText = normalizeString(verseText);
    let verseTextSpans = {verseText};
    if (selections && selections.length > 0) {
      let _selectionArray = selectionArray(verseText, selections);
      verseTextSpans = _selectionArray.map((selection, index) =>
         this.removeSelection(selection) : () => { }}>
          {selection.text}

      )
    }

    if (this.props.mode == "select") {
      return (

 this.getSelectionText()} onMouseLeave={()=>this.inDisplayBox(false)} onMouseEnter={()=>this.inDisplayBox(true)}>
          {verseTextSpans}

      );
    } else {
      return (

          {verseTextSpans}

      )
    }

  }

  inDisplayBox(insideDisplayBox) {
    this.setState({ inBox: insideDisplayBox });
    if (!insideDisplayBox && Math.abs(window.getSelection().extentOffset - window.getSelection().baseOffset) > 0) {
      this.getSelectionText()
    }
    window.getSelection().empty();
  }

  render() {
    let {verseText, projectDetailsReducer} = this.props
    // normalize whitespace, since html selections will not include more than 1 contiguous space
    verseText = normalizeString(verseText);
    // validate selections and remove ones that do not apply
    this.props.actions.validateSelections(verseText);
    const { manifest, bookName } = projectDetailsReducer;

    let reference = this.props.contextIdReducer.contextId.reference;
    let bibles = this.props.resourcesReducer.bibles;
    let languageName = manifest.target_language ? manifest.target_language.name : null;
    let modal =
;

    let dir = manifest.target_language ? manifest.target_language.direction : null;

    if (this.state.modalVisibility) {
      modal = (
        <MyLanguageModal
          show={this.state.modalVisibility}
          targetLangBible={bibles.targetLanguage}
          chapter={reference.chapter}
          currentVerse={reference.verse}
          dir = {dir ? dir : "ltr"}
          onHide={
            () => {
              this.setState({modalVisibility: false})
            }
          }
        />
      )
    }

    return (

                {languageName}

                {bookName} {reference.chapter + ':' + reference.verse}

 {
            this.setState({modalVisibility: true})
          }}>
            <Glyphicon glyph="fullscreen" style={{cursor: "pointer"}}/>
            {modal}

          {this.displayText()}

    )
  }
}

export default SelectArea
<commit_msg>issue 1522, add tool tip<commit_after>import React from 'react'
import {Glyphicon} from 'react-bootstrap'
import style from '../css/Style'
import {selectionArray, occurrencesInString, normalizeString} from '../utils/selectionHelpers'
import MyLanguageModal from './MyLanguageModal'

class SelectArea extends React.Component {
  constructor() {
    super();
    this.state = {
      inBox: false,
      modalVisibility: false
    }
  }
/*
 * @description
 * Implementation notes on why you can't just use the window.getSelection()
 * getSelection is limited by same innerText node, and does not include span siblings
 * indexOfTextSelection is broken by any other previous selection since it only knows its innerText node.
 */
  getSelectionText() {
    if (!this.props.loginReducer.loggedInUser) {
      this.props.actions.selectModalTab(1, 1, true);
      this.props.actions.openAlertDialog("You must be logged in to make a selection");
      return;
    }
    // windowSelection is an object with lots of data
    let windowSelection = window.getSelection();
    // get the current text selected
    let selectedText = windowSelection.toString();

    // do nothing since an empty space was selected
    if (selectedText === '') {} else {
      // get the text after the presceding selection and current span selection is in.
      let selectionRange = windowSelection.getRangeAt(0)
      // get the character index of what is selected in context of the span it is in.
      let indexOfTextSelection = selectionRange.startOffset;
      // get the container of the selection, this is a strange object, that logs as a string.
      let textContainer = selectionRange.commonAncestorContainer;
      // get the parent span that contains the textContainer.
      let textSpan = textContainer ? textContainer.parentElement : undefined;
      // get all of the text in the selection's container similar to the span's innerText.
      let textSpanContent = textSpan.innerText;
      // get the text presceding the selection but after the selection just prior to it.
      let postPrescedingText = textContainer ? textSpanContent.slice(0,indexOfTextSelection) : '';
      // start with an empty string to prepend to for text presceding current span selection is in.
      let prescedingText = '';
      // if we have a span that holds text, see what presceding text we can extract.
      if (textSpan) {
        // get the previous sibling to start the loop
        let previousSibling = textSpan.previousSibling;
        // loop through previous spans to get their text
        while (previousSibling) {
          // prepend the spans innerText to the prescedingText
          prescedingText = previousSibling.innerText + prescedingText;
          // move to the previous span, if none, it ends the loop
          previousSibling = previousSibling.previousSibling;
        }
      }

      // There can be a gap between prescedingText and current selection
      let textBeforeSelection = prescedingText + postPrescedingText + selectedText;
      // get the occurrence of the selection
      let occurrence = occurrencesInString(textBeforeSelection, selectedText);
      // verseText is used to get all of the occurrences
      let verseText = this.props.verseText;
      // replace more than one contiguous space with a single one since HTML/selection only renders 1
      verseText = normalizeString(verseText);
      // get the total occurrences from the verse
      let occurrences = occurrencesInString(verseText, selectedText);
      let selection = {
        text: selectedText,
        occurrence: occurrence,
        occurrences: occurrences
      };
      // add the selection to the selections
      this.addSelection(selection);
    }
  }

  addSelection(selection) {
    let selections = this.props.selectionsReducer.selections;
    if (selections.length >= 4) {
      this.props.actions.openAlertDialog('Click a previous selection to remove it before adding a new one. To select more than 4 words, highlight phrases instead of individual words.')
      return false
    } else {
      selections.push(selection);
    }
    this.props.actions.changeSelections(selections);
  }

  removeSelection(selection) {
    let selections = this.props.selectionsReducer.selections;
    selections = selections.filter(_selection =>
      _selection.occurrence !== selection.occurrence || _selection.text !== selection.text
    )
    this.props.actions.changeSelections(selections);
  }

  displayText() {
    let { selections } = this.props.selectionsReducer;
    let verseText = this.props.verseText;
    // normalize whitespace for text rendering in order to display highlights with more than one space since html selections show one space
    verseText = normalizeString(verseText);
    let verseTextSpans = {verseText};
    if (selections && selections.length > 0) {
      let _selectionArray = selectionArray(verseText, selections);
      verseTextSpans = _selectionArray.map((selection, index) =>
         this.removeSelection(selection) : () => { }}>
          {selection.text}

      )
    }

    if (this.props.mode == "select") {
      return (

 this.getSelectionText()} onMouseLeave={()=>this.inDisplayBox(false)} onMouseEnter={()=>this.inDisplayBox(true)}>
          {verseTextSpans}

      );
    } else {
      return (

          {verseTextSpans}

      )
    }

  }

  inDisplayBox(insideDisplayBox) {
    this.setState({ inBox: insideDisplayBox });
    if (!insideDisplayBox && Math.abs(window.getSelection().extentOffset - window.getSelection().baseOffset) > 0) {
      this.getSelectionText()
    }
    window.getSelection().empty();
  }

  render() {
    let {verseText, projectDetailsReducer} = this.props
    // normalize whitespace, since html selections will not include more than 1 contiguous space
    verseText = normalizeString(verseText);
    // validate selections and remove ones that do not apply
    this.props.actions.validateSelections(verseText);
    const { manifest, bookName } = projectDetailsReducer;

    let reference = this.props.contextIdReducer.contextId.reference;
    let bibles = this.props.resourcesReducer.bibles;
    let languageName = manifest.target_language ? manifest.target_language.name : null;
    let modal =
;

    let dir = manifest.target_language ? manifest.target_language.direction : null;

    if (this.state.modalVisibility) {
      modal = (
        <MyLanguageModal
          show={this.state.modalVisibility}
          targetLangBible={bibles.targetLanguage}
          chapter={reference.chapter}
          currentVerse={reference.verse}
          dir = {dir ? dir : "ltr"}
          onHide={
            () => {
              this.setState({modalVisibility: false})
            }
          }
        />
      )
    }

    return (

                {languageName}

                {bookName} {reference.chapter + ':' + reference.verse}

 {
            this.setState({modalVisibility: true})
          }}>
            <Glyphicon glyph="fullscreen" title="Click to show expanded verses" style={{cursor: "pointer"}}/>
            {modal}

          {this.displayText()}

    )
  }
}

export default SelectArea
<|endoftext|>


<commit_before>import React, {Component, PropTypes} from 'react';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {fetchUnits} from '../../unit/actions';
import {getVisibleUnits} from '../../unit/selectors';
import {DefaultFilters} from '../../unit/constants';
//import {Map, Marker, Popup, TileLayer} from 'react-leaflet';
import {MapView} from '../../unit/components/MapView.js';
import UnitBrowser from '../../unit/components/UnitBrowser.js';
import SingleUnitModalContainer from '../../unit/components/SingleUnitModalContainer';
import {locations, views} from '../constants.js';
import {arrayifyQueryValue} from '../../common/helpers';

const Footer = ({children}) =>
{children}
;

export class HomeContainer extends Component {
  static propTypes = {
    fetchUnits: PropTypes.func.isRequired,
    position: PropTypes.array.isRequired,
    selectedView: PropTypes.string.isRequired,
    unitData: PropTypes.array,
    filter: PropTypes.any.isRequired
  };

  static defaultProps = {
    unitData: [],
    position: locations.HELSINKI,
    selectedView: views.MAP,
    filter: DefaultFilters
  };

  constructor(props) {
    super(props);
    this.state = {
      selectedView: props.selectedView
    };

    this.state = {modalOpen: false};

    this.handleMapMove = this.handleMapMove.bind(this);
    this.toggleView = this.toggleView.bind(this);
    this.toggleModal = this.toggleModal.bind(this);
  }

  toggleView() {
    this.setState({selectedView: this.state['selectedView'] === views.MAP ? views.LIST : views.MAP});
  }

  componentWillMount() {
    // Fetch ice rinks in 10km radius from the passed position
    this.props.fetchUnits();
  }

  handleMapMove(): void {
    //
  }

  toggleModal() {
    if (this.state.modalOpen === false) {
      this.setState({modalOpen: true});
    } else {
      this.setState({modalOpen: false});
    }
  }

  render() {
    const {unitData, position, params, location: {query: {filter}}} = this.props;
    const {selectedView} = this.state;
<<<<<<>>>>>> bdec91571c78d5e3fbeeea65f2ba27bf5d9ede9a

    return (

        {/*
        {/*<ListView selected={selectedView === views.LIST} units={unitData}/>*/}
<<<<<<< HEAD
        <UnitBrowser units={unitData} handleClick={this.toggleModal} />
=======
        <UnitBrowser units={unitData} activeFilter={activeFilter} />
>>>>>>> bdec91571c78d5e3fbeeea65f2ba27bf5d9ede9a
        <MapView handleMoveend={this.handleMapMove} selected={selectedView === views.MAP} position={position} units={unitData}/>
        <SingleUnitModalContainer isOpen={this.state.modalOpen} units={unitData} params={params} handleClick={this.toggleModal} />

    );
  }
}

const mapStateToProps = (state, props) => ({
  unitData: getVisibleUnits(state, props.location.query && props.location.query.filter && arrayifyQueryValue(props.location.query.filter)),
  selectedView: state.selectedView
});

const mapDispatchToProps = (dispatch) =>
  bindActionCreators({fetchUnits, singleUnitSelect}, dispatch);

export default connect(mapStateToProps, mapDispatchToProps)(
  HomeContainer
);
<commit_msg>Resolve merge conflict<commit_after>import React, {Component, PropTypes} from 'react';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {fetchUnits} from '../../unit/actions';
import {getVisibleUnits} from '../../unit/selectors';
import {DefaultFilters} from '../../unit/constants';
//import {Map, Marker, Popup, TileLayer} from 'react-leaflet';
import {MapView} from '../../unit/components/MapView.js';
import UnitBrowser from '../../unit/components/UnitBrowser.js';
import SingleUnitModalContainer from '../../unit/components/SingleUnitModalContainer';
import {locations, views} from '../constants.js';
import {arrayifyQueryValue} from '../../common/helpers';

const Footer = ({children}) =>
{children}
;

export class HomeContainer extends Component {
  static propTypes = {
    fetchUnits: PropTypes.func.isRequired,
    position: PropTypes.array.isRequired,
    selectedView: PropTypes.string.isRequired,
    unitData: PropTypes.array,
    filter: PropTypes.any.isRequired
  };

  static defaultProps = {
    unitData: [],
    position: locations.HELSINKI,
    selectedView: views.MAP,
    filter: DefaultFilters
  };

  constructor(props) {
    super(props);
    this.state = {
      selectedView: props.selectedView
    };

    this.state = {modalOpen: false};

    this.handleMapMove = this.handleMapMove.bind(this);
    this.toggleView = this.toggleView.bind(this);
    this.toggleModal = this.toggleModal.bind(this);
  }

  toggleView() {
    this.setState({selectedView: this.state['selectedView'] === views.MAP ? views.LIST : views.MAP});
  }

  componentWillMount() {
    // Fetch ice rinks in 10km radius from the passed position
    this.props.fetchUnits();
  }

  handleMapMove(): void {
    //
  }

  toggleModal() {
    if (this.state.modalOpen === false) {
      this.setState({modalOpen: true});
    } else {
      this.setState({modalOpen: false});
    }
  }

  render() {
    const {unitData, position, params, location: {query: {filter}}} = this.props;
    const {selectedView} = this.state;
    const activeFilter = arrayifyQueryValue(filter);

    return (

        {/*
        {/*<ListView selected={selectedView === views.LIST} units={unitData}/>*/}
        <UnitBrowser units={unitData} activeFilter={activeFilter} handleClick={this.toggleModal} />
        <MapView handleMoveend={this.handleMapMove} selected={selectedView === views.MAP} position={position} units={unitData}/>
        <SingleUnitModalContainer isOpen={this.state.modalOpen} units={unitData} params={params} handleClick={this.toggleModal} />

    );
  }
}

const mapStateToProps = (state, props) => ({
  unitData: getVisibleUnits(state, props.location.query && props.location.query.filter && arrayifyQueryValue(props.location.query.filter)),
  selectedView: state.selectedView
});

const mapDispatchToProps = (dispatch) =>
  bindActionCreators({fetchUnits, singleUnitSelect}, dispatch);

export default connect(mapStateToProps, mapDispatchToProps)(
  HomeContainer
);
<|endoftext|>


<commit_before>
describe('Database tests', function() {

  it('Create table', function() {
    browser.get('#/database');

    var EC = protractor.ExpectedConditions;

    $('a.btn-primary').click();

    browser.wait(EC.visibilityOf($('div.modal-body')), 5000);

    element(by.model('table.name')).sendKeys('foobar');

    element.all(by.css('button.btn-default')).first().click();
    element.all(by.css('button.btn-default')).first().click();
    element.all(by.css('button.btn-default')).first().click();

    var columns = element.all(by.repeater('column in table.columns'));
    columns.get(0).element(by.model('column.name')).clear().sendKeys('id');
    columns.get(0).element(by.cssContainingText('option', 'integer')).click();
    columns.get(1).element(by.model('column.name')).clear().sendKeys('name');
    columns.get(1).element(by.cssContainingText('option', 'string')).click();
    columns.get(2).element(by.model('column.name')).clear().sendKeys('content');
    columns.get(2).element(by.cssContainingText('option', 'text')).click();
    columns.get(3).element(by.model('column.name')).clear().sendKeys('date');
    columns.get(3).element(by.cssContainingText('option', 'datetime')).click();

    $('button.btn-primary').click();

    browser.wait(EC.visibilityOf($('div.alert-success')), 5000);

    expect($('div.alert-success > div').getText()).toEqual('Table successful created');
  });

  it('List table', function() {
    browser.get('#/database');

    var tables = element.all(by.repeater('table in tables'));
    expect(tables.count()).toEqual(2);
    expect(tables.get(0).getText()).toEqual('app_news');
    expect(tables.get(1).getText()).toEqual('foobar');
  });

  it('Table update', function() {
    browser.get('#/database');

    var EC = protractor.ExpectedConditions;

    var tables = element.all(by.repeater('table in tables'));
    tables.get(1).click().then(function(){
        element.all(by.css('a.btn-default')).get(1).click();

        browser.wait(EC.visibilityOf($('div.modal-body')), 5000);

        expect(element(by.model('table.name')).getAttribute('value')).toEqual('foobar');

        var columns = element.all(by.model('column.name'));
        expect(columns.count()).toEqual(4);
        expect(columns.get(0).getAttribute('value')).toEqual('id');
        expect(columns.get(1).getAttribute('value')).toEqual('name');
        expect(columns.get(2).getAttribute('value')).toEqual('content');
        expect(columns.get(3).getAttribute('value')).toEqual('date');

        element.all(by.css('.fusio-options a.btn-default')).get(2).click();

        $('button.btn-primary').click();

        var queries = element.all(by.repeater('query in response.queries'));
        expect(queries.count()).toEqual(1);
        expect(queries.get(0).getText()).toMatch(/^ALTER TABLE foobar DROP content|CREATE TEMPORARY TABLE __temp__app_news AS SELECT id, title, date FROM app_news$/);

        $('button.btn-danger').click();

        browser.wait(EC.visibilityOf($('div.alert-success')), 5000);

        expect($('div.alert-success > div').getText()).toEqual('Table successful updated');
    });
  });

  it('Table delete', function() {
    browser.get('#/database');

    var EC = protractor.ExpectedConditions;

    var tables = element.all(by.repeater('table in tables'));
    tables.get(1).click().then(function(){
        element.all(by.css('a.btn-danger')).first().click();

        browser.wait(EC.visibilityOf($('div.modal-body')), 5000);

        expect(element(by.model('table.name')).getAttribute('value')).toEqual('foobar');

        $('button.btn-primary').click();

        var queries = element.all(by.repeater('query in response.queries'));
        expect(queries.count()).toEqual(1);
        expect(queries.get(0).getText()).toEqual('DROP TABLE foobar');

        $('button.btn-danger').click();

        browser.wait(EC.visibilityOf($('div.alert-success')), 5000);

        expect($('div.alert-success > div').getText()).toEqual('Table successful deleted');
    });
  });

});
<commit_msg>database test wait for table load<commit_after>
describe('Database tests', function() {

  it('Create table', function() {
    browser.get('#/database');

    var EC = protractor.ExpectedConditions;

    $('a.btn-primary').click();

    browser.wait(EC.visibilityOf($('div.modal-body')), 5000);

    element(by.model('table.name')).sendKeys('foobar');

    element.all(by.css('button.btn-default')).first().click();
    element.all(by.css('button.btn-default')).first().click();
    element.all(by.css('button.btn-default')).first().click();

    var columns = element.all(by.repeater('column in table.columns'));
    columns.get(0).element(by.model('column.name')).clear().sendKeys('id');
    columns.get(0).element(by.cssContainingText('option', 'integer')).click();
    columns.get(1).element(by.model('column.name')).clear().sendKeys('name');
    columns.get(1).element(by.cssContainingText('option', 'string')).click();
    columns.get(2).element(by.model('column.name')).clear().sendKeys('content');
    columns.get(2).element(by.cssContainingText('option', 'text')).click();
    columns.get(3).element(by.model('column.name')).clear().sendKeys('date');
    columns.get(3).element(by.cssContainingText('option', 'datetime')).click();

    $('button.btn-primary').click();

    browser.wait(EC.visibilityOf($('div.alert-success')), 5000);

    expect($('div.alert-success > div').getText()).toEqual('Table successful created');
  });

  it('List table', function() {
    browser.get('#/database');

    var tables = element.all(by.repeater('table in tables'));
    expect(tables.count()).toEqual(2);
    expect(tables.get(0).getText()).toEqual('app_news');
    expect(tables.get(1).getText()).toEqual('foobar');
  });

  it('Table update', function() {
    browser.get('#/database');

    var EC = protractor.ExpectedConditions;

    var tables = element.all(by.repeater('table in tables'));
    tables.get(1).$('a').click();
    browser.wait(EC.textToBePresentInElement($('h4'), 'foobar'), 5000);

    element.all(by.css('a.btn-default')).get(1).click();

    browser.wait(EC.visibilityOf($('div.modal-body')), 5000);

    expect(element(by.model('table.name')).getAttribute('value')).toEqual('foobar');

    var columns = element.all(by.model('column.name'));
    expect(columns.count()).toEqual(4);
    expect(columns.get(0).getAttribute('value')).toEqual('id');
    expect(columns.get(1).getAttribute('value')).toEqual('name');
    expect(columns.get(2).getAttribute('value')).toEqual('content');
    expect(columns.get(3).getAttribute('value')).toEqual('date');

    element.all(by.css('.fusio-options a.btn-default')).get(2).click();

    $('button.btn-primary').click();

    var queries = element.all(by.repeater('query in response.queries'));
    expect(queries.count()).toEqual(1);
    expect(queries.get(0).getText()).toMatch(/^ALTER TABLE foobar DROP content|CREATE TEMPORARY TABLE __temp__app_news AS SELECT id, title, date FROM app_news$/);

    $('button.btn-danger').click();

    browser.wait(EC.visibilityOf($('div.alert-success')), 5000);

    expect($('div.alert-success > div').getText()).toEqual('Table successful updated');
  });

  it('Table delete', function() {
    browser.get('#/database');

    var EC = protractor.ExpectedConditions;

    var tables = element.all(by.repeater('table in tables'));
    tables.get(1).$('a').click();
    browser.wait(EC.textToBePresentInElement($('h4'), 'foobar'), 5000);

    element.all(by.css('a.btn-danger')).first().click();

    browser.wait(EC.visibilityOf($('div.modal-body')), 5000);

    expect(element(by.model('table.name')).getAttribute('value')).toEqual('foobar');

    $('button.btn-primary').click();

    var queries = element.all(by.repeater('query in response.queries'));
    expect(queries.count()).toEqual(1);
    expect(queries.get(0).getText()).toEqual('DROP TABLE foobar');

    $('button.btn-danger').click();

    browser.wait(EC.visibilityOf($('div.alert-success')), 5000);

    expect($('div.alert-success > div').getText()).toEqual('Table successful deleted');
  });

});
<|endoftext|>


<commit_before>//
// Created by charlesking on 7/18/15.
//
/**
 * The client JS file that brings in React and bootstraps the app into the page from the server state.
 */
import React from "react"

//components
import App from "./app"

//put React into the global scope for chrome dev tool support
window.React = React;

//grab the app node
const mountNode = document.getElementById('app');

//render our app component into that node
React.render(<App/>, mountNode);<commit_msg>fix import<commit_after>//
// Created by charlesking on 7/18/15.
//
/**
 * The client JS file that brings in React and bootstraps the app into the page from the server state.
 */
import React from "react"

//components
import App from "./components/app"

//put React into the global scope for chrome dev tool support
window.React = React;

//grab the app node
const mountNode = document.getElementById('app');

//render our app component into that node
React.render(<App/>, mountNode);<|endoftext|>


<commit_before>// # Ghost Configuration
// Setup your Ghost install for various environments
// Documentation can be found at http://support.ghost.org/config/

var path = require('path'),
    config;

config = {
    // ### Development **(default)**
    development: {
        // The url to use when providing links to the site, E.g. in RSS and email.
        url: 'http://my-ghost-blog.com',

        // Example mail config
        // Visit http://support.ghost.org/mail for instructions
        // ```
        //  mail: {
        //      transport: 'SMTP',
        //      options: {
        //          service: 'Mailgun',
        //          auth: {
        //              user: '', // mailgun username
        //              pass: ''  // mailgun password
        //          }
        //      }
        //  },
        // ```

        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-dev.db')
            },
            debug: false
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: '127.0.0.1',
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: '2368'
        },
        paths: {
            contentPath: path.join(__dirname, '/content/')
        }
    },

    // ### Production
    // When running Ghost in the wild, use the production environment
    // Configure your URL and mail settings here
    production: {
        url: 'http://'+process.env.OPENSHIFT_APP_DNS,
        mail: {
					transport: 'SMTP',
						options: {
							service: 'Mailgun',
							auth: {
								user: ''+process.env.MAILGUN_USER,
								pass: ''+process.env.MAILGUN_PASS
							}
						}
				},
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: process.env.OPENSHIFT_NODEJS_IP,
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: process.env.OPENSHIFT_NODEJS_PORT
        }
    },

    // **Developers only need to edit below here**

    // ### Testing
    // Used when developing Ghost to run tests and check the health of Ghost
    // Uses a different port number
    testing: {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-test.db')
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        },
        logging: false
    },

    // ### Testing MySQL
    // Used by Travis - Automated testing run through GitHub
    'testing-mysql': {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'mysql',
            connection: {
                host     : '127.0.0.1',
                user     : 'root',
                password : '',
                database : 'ghost_testing',
                charset  : 'utf8'
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        },
        logging: false
    },

    // ### Testing pg
    // Used by Travis - Automated testing run through GitHub
    'testing-pg': {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'pg',
            connection: {
                host     : '127.0.0.1',
                user     : 'postgres',
                password : '',
                database : 'ghost_testing',
                charset  : 'utf8'
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        },
        logging: false
    }
};

// Export config
module.exports = config;
<commit_msg>fix mailgun credentials<commit_after>// # Ghost Configuration
// Setup your Ghost install for various environments
// Documentation can be found at http://support.ghost.org/config/

var path = require('path'),
    config;

config = {
    // ### Development **(default)**
    development: {
        // The url to use when providing links to the site, E.g. in RSS and email.
        url: 'http://my-ghost-blog.com',

        // Example mail config
        // Visit http://support.ghost.org/mail for instructions
        // ```
        //  mail: {
        //      transport: 'SMTP',
        //      options: {
        //          service: 'Mailgun',
        //          auth: {
        //              user: '', // mailgun username
        //              pass: ''  // mailgun password
        //          }
        //      }
        //  },
        // ```

        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-dev.db')
            },
            debug: false
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: '127.0.0.1',
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: '2368'
        },
        paths: {
            contentPath: path.join(__dirname, '/content/')
        }
    },

    // ### Production
    // When running Ghost in the wild, use the production environment
    // Configure your URL and mail settings here
    production: {
        url: 'http://'+process.env.OPENSHIFT_APP_DNS,
        mail: {
					transport: 'SMTP',
						options: {
							service: 'Mailgun',
							auth: {
								user: process.env.MAILGUN_USER,
								pass: process.env.MAILGUN_PASS
							}
						}
				},
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: process.env.OPENSHIFT_NODEJS_IP,
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: process.env.OPENSHIFT_NODEJS_PORT
        }
    },

    // **Developers only need to edit below here**

    // ### Testing
    // Used when developing Ghost to run tests and check the health of Ghost
    // Uses a different port number
    testing: {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-test.db')
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        },
        logging: false
    },

    // ### Testing MySQL
    // Used by Travis - Automated testing run through GitHub
    'testing-mysql': {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'mysql',
            connection: {
                host     : '127.0.0.1',
                user     : 'root',
                password : '',
                database : 'ghost_testing',
                charset  : 'utf8'
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        },
        logging: false
    },

    // ### Testing pg
    // Used by Travis - Automated testing run through GitHub
    'testing-pg': {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'pg',
            connection: {
                host     : '127.0.0.1',
                user     : 'postgres',
                password : '',
                database : 'ghost_testing',
                charset  : 'utf8'
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        },
        logging: false
    }
};

// Export config
module.exports = config;
<|endoftext|>


<commit_before>function _createURL( utility, params ) {
	return baseUrl + "/wizard/entrezProxy?_utility=" + utility + "&" + params;
}
sourcePubMed = function( chooserObject, searchterm, response ) {
    // Search for every term in both title and author fields
    var searchFor = [];
    var terms = searchterm.split( " " );
    for( var i = 0; i < terms.length; i++ ) {
        searchFor[ searchFor.length ] = "(" + $.trim( terms[i] ) + "[title]" + " OR " + $.trim( terms[i] ) + "[author]" + ")";
    }

    // The fetching of the data is done using a proxy, because in IE it is not allowed to retrieve
    // XML data from another domain.
    var utility = 'esearch.fcgi';
    var params = "db=pubmed&term=" + searchFor.join( " AND " ) + "&usehistory=y";
    var url = _createURL( utility, params );

    // Fetch it from Pubmed
    // This has to be done in two steps: first find IDs, and second, find information
    $.ajax({
            url: url,
            dataType: "xml",
            success: function(xmlResponse) {
                var xmlDoc = $(xmlResponse);
                var WebEnv = $("WebEnv", xmlDoc ).text();
                var query_key = $("QueryKey", xmlDoc ).text();

                var utility = 'esummary.fcgi';
                var params = "db=pubmed&retmax=" + chooserObject.maxResults + "&query_key=" + query_key + "&WebEnv=" + WebEnv;
                var url = _createURL( utility, params );

                $.ajax({
                    url: url,
                    dataType: "xml",
                    success: function(summaryResponse) {
                        // Parse the response
                        var parsedData = parsePubmedData( summaryResponse )

                        // Save in cache
                        chooserObject.cache[ chooserObject.database ][ searchterm ] = parsedData;

                        // Return it to jquery
                        response( parsedData );
                    },
                    error: function() {
                            response( null );
                    }
                })
            },
            error: function() {
                response( null );
            }
    })

};

// Handler that handles the select of a publication
selectPubMedAdd = function( chooserObject, inputElement, event, ui ) {

    // option selected, set hidden fields
    var element = inputElement;

    // set hidden fields
    chooserObject.setInputValue(element, 'title', ui.item.title);
    chooserObject.setInputValue(element, 'authorsList', ui.item.authors.join( ', ' ));
    chooserObject.setInputValue(element, 'pubMedID', ui.item.id);
    chooserObject.setInputValue(element, 'doi', ui.item.doi);

    // remove error class (if present)
    element.removeClass('error');
};

// Handler that handles the closing of the autocomplete
closePubMedAdd  = function( chooserObject, inputElement, event, ui ) {
    // no he didn't, clear the field(s)
    var element = inputElement;

    // set fields
    inputElement.val('');
    chooserObject.setInputValue(element, 'title', '');
    chooserObject.setInputValue(element, 'authorsList', '');
    chooserObject.setInputValue(element, 'pubMedID', '');
    chooserObject.setInputValue(element, 'doi', '');

    // add error class
    element.addClass('error');
};

//renderPubMed = function( chooserObject, ul, item ) {};

/**
 * Parse the result data from pubmed
 *
 * Data is in the format described on
 * http://www.ncbi.nlm.nih.gov/bookshelf/br.fcgi?book=helpeutils&part=chapter1#chapter1.Downloading_Document_Summaries
 *
 * @param data
 * @return array
 */
function parsePubmedData(responseData) {
    var data = [];
    data = $("DocSum", responseData).map(function() {
            var title = $("Item[Name=Title]", this).text();
            var authors = buildAuthorList( $("Item[Name=AuthorList]", this ) );

            // Also search for the DOI
            var doi = '';
            var idsXML = $("Item[Name=ArticleIds]", this );
            var doiXML = idsXML.find("Item[Name=doi]");
            if( doiXML ) {
                doi = doiXML.text();
            }
            return {
                  value: title + " (" + authors.join( ', ' ) + ")",
                  title: title,
                  authors: authors,
                  doi: doi,
                  id: $("Id", this).text()
            };
    }).get();

    return data;
}

/**
 * Builds an array of authors from the XML source.
 *
 * @param   xmlAuthors  XML element from esearch with Item[Name=AuthorList]
 * @return  Array       Names of authors
 */
function buildAuthorList( xmlAuthors ) {
    var authorList = xmlAuthors.find( "Item" ).map(function() {
          return $(this).text();
    }).get();

    return authorList;
}

// Only the source method should be used for all pubmed autocompletes
// The select and close handlers that are defined here, should only be used
// on the add publication page. They can be overridden in the initialization
// of the publication chooser class
PublicationChooser.prototype.availableDBs[ "pubmed" ] = {
    'source': sourcePubMed,
    'select': selectPubMedAdd,
    'close':  closePubMedAdd
};

<commit_msg>Making it possible to search on pubmed ID (#212)<commit_after>function _createURL( utility, params ) {
	return baseUrl + "/wizard/entrezProxy?_utility=" + utility + "&" + params;
}
sourcePubMed = function( chooserObject, searchterm, response ) {
    // Search for every term in both title and author fields
    var searchFor = [];
    var terms = searchterm.split( " " );
    for( var i = 0; i < terms.length; i++ ) {
        searchFor[ searchFor.length ] = "(" + $.trim( terms[i] ) + "[title]" + " OR " + $.trim( terms[i] ) + "[author]" + " OR " + $.trim( terms[i] ) + "[pmid]" + ")";
    }

    // The fetching of the data is done using a proxy, because in IE it is not allowed to retrieve
    // XML data from another domain.
    var utility = 'esearch.fcgi';
    var params = "db=pubmed&term=" + searchFor.join( " AND " ) + "&usehistory=y";
    var url = _createURL( utility, params );

    // Fetch it from Pubmed
    // This has to be done in two steps: first find IDs, and second, find information
    $.ajax({
            url: url,
            dataType: "xml",
            success: function(xmlResponse) {
                var xmlDoc = $(xmlResponse);
                var WebEnv = $("WebEnv", xmlDoc ).text();
                var query_key = $("QueryKey", xmlDoc ).text();

                var utility = 'esummary.fcgi';
                var params = "db=pubmed&retmax=" + chooserObject.maxResults + "&query_key=" + query_key + "&WebEnv=" + WebEnv;
                var url = _createURL( utility, params );

                $.ajax({
                    url: url,
                    dataType: "xml",
                    success: function(summaryResponse) {
                        // Parse the response
                        var parsedData = parsePubmedData( summaryResponse )

                        // Save in cache
                        chooserObject.cache[ chooserObject.database ][ searchterm ] = parsedData;

                        // Return it to jquery
                        response( parsedData );
                    },
                    error: function() {
                            response( null );
                    }
                })
            },
            error: function() {
                response( null );
            }
    })

};

// Handler that handles the select of a publication
selectPubMedAdd = function( chooserObject, inputElement, event, ui ) {

    // option selected, set hidden fields
    var element = inputElement;

    // set hidden fields
    chooserObject.setInputValue(element, 'title', ui.item.title);
    chooserObject.setInputValue(element, 'authorsList', ui.item.authors.join( ', ' ));
    chooserObject.setInputValue(element, 'pubMedID', ui.item.id);
    chooserObject.setInputValue(element, 'doi', ui.item.doi);

    // remove error class (if present)
    element.removeClass('error');
};

// Handler that handles the closing of the autocomplete
closePubMedAdd  = function( chooserObject, inputElement, event, ui ) {
    // no he didn't, clear the field(s)
    var element = inputElement;

    // set fields
    inputElement.val('');
    chooserObject.setInputValue(element, 'title', '');
    chooserObject.setInputValue(element, 'authorsList', '');
    chooserObject.setInputValue(element, 'pubMedID', '');
    chooserObject.setInputValue(element, 'doi', '');

    // add error class
    element.addClass('error');
};

//renderPubMed = function( chooserObject, ul, item ) {};

/**
 * Parse the result data from pubmed
 *
 * Data is in the format described on
 * http://www.ncbi.nlm.nih.gov/bookshelf/br.fcgi?book=helpeutils&part=chapter1#chapter1.Downloading_Document_Summaries
 *
 * @param data
 * @return array
 */
function parsePubmedData(responseData) {
    var data = [];
    data = $("DocSum", responseData).map(function() {
            var title = $("Item[Name=Title]", this).text();
            var authors = buildAuthorList( $("Item[Name=AuthorList]", this ) );

            // Also search for the DOI
            var doi = '';
            var idsXML = $("Item[Name=ArticleIds]", this );
            var doiXML = idsXML.find("Item[Name=doi]");
            if( doiXML ) {
                doi = doiXML.text();
            }
            return {
                  value: title + " (" + authors.join( ', ' ) + ")",
                  title: title,
                  authors: authors,
                  doi: doi,
                  id: $("Id", this).text()
            };
    }).get();

    return data;
}

/**
 * Builds an array of authors from the XML source.
 *
 * @param   xmlAuthors  XML element from esearch with Item[Name=AuthorList]
 * @return  Array       Names of authors
 */
function buildAuthorList( xmlAuthors ) {
    var authorList = xmlAuthors.find( "Item" ).map(function() {
          return $(this).text();
    }).get();

    return authorList;
}

// Only the source method should be used for all pubmed autocompletes
// The select and close handlers that are defined here, should only be used
// on the add publication page. They can be overridden in the initialization
// of the publication chooser class
PublicationChooser.prototype.availableDBs[ "pubmed" ] = {
    'source': sourcePubMed,
    'select': selectPubMedAdd,
    'close':  closePubMedAdd
};

<|endoftext|>


<commit_before>/**
 * TODO: configuration profiles
 */

module.exports = function config(ninja, app) {

	if((!ninja) || !ninja.opts) {

		return false;
	}

	// default arduino device path
	if(!ninja.opts.client || ninja.opts.client == 'beagle') {

		ninja.opts.device = '/dev/ttyO1';
	}

	/**
	 * Load ninja cape & arduino modules if present
	 */
	if(ninja.opts.device) {

		// serial device
		ninja.loadModule(

			'serial'
			, { device : ninja.opts.device, id : 'arduino' }
			, app
		);

		// arduino controller
		ninja.loadModule(

			'platform'
			, { id : 'arduino' }
			, app
		);
/*
		// ninja onboard components
		ninja.loadModule(

			'embedded'
			, { components : [ 'rgbled' ] }
			, app
		);
*/
	}

	ninja.emit('loaded'); // done loading modules
	ninja.connect();

	return ninja;
};
<commit_msg>Module load order shuffle.<commit_after>/**
 * TODO: configuration profiles
 */

module.exports = function config(ninja, app) {

	if((!ninja) || !ninja.opts) {

		return false;
	}

	// default arduino device path
	if(!ninja.opts.client || ninja.opts.client == 'beagle') {

		ninja.opts.device = '/dev/ttyO1';
	}

	/**
	 * Load ninja cape & arduino modules if present
	 */
	if(ninja.opts.device) {

		// arduino controller
		ninja.loadModule(

			'platform'
			, { id : 'arduino' }
			, app
		);

		// serial device
		ninja.loadModule(

			'serial'
			, { device : ninja.opts.device, id : 'arduino' }
			, app
		);

		ninja.loadModule(

			'network'
			, { }
			, app
		);
	}

	ninja.emit('loaded'); // done loading modules
	ninja.connect();

	return ninja;
};
<|endoftext|>


<commit_before>// Default dummy values exist in order to allow unit tests to run
const logger = require('winston')
logger.level = process.env.LOG_LEVEL || 'debug'

module.exports = {
  accountSid: process.env.TWILIO_ACCOUNT_SID || 'TWILIO_ACCOUNT_SID',
  authToken: process.env.TWILIO_AUTH_TOKEN || 'TWILIO_AUTH_TOKEN',
  sendingNumber: process.env.TWILIO_NUMBER || 'TWILIO_NUMBER',
  mongodbUri: process.env.MONGODB_URI || 'MONGODB_URI',
  remindersListKey: 'reminders'
}
<commit_msg>try customizing logging<commit_after>// Default dummy values exist in order to allow unit tests to run
const logger = require('winston')
logger.level = process.env.LOG_LEVEL || 'debug'
logger.colorize = true

module.exports = {
  accountSid: process.env.TWILIO_ACCOUNT_SID || 'TWILIO_ACCOUNT_SID',
  authToken: process.env.TWILIO_AUTH_TOKEN || 'TWILIO_AUTH_TOKEN',
  sendingNumber: process.env.TWILIO_NUMBER || 'TWILIO_NUMBER',
  mongodbUri: process.env.MONGODB_URI || 'MONGODB_URI',
  remindersListKey: 'reminders'
}
<|endoftext|>


<commit_before>// # Ghost Configuration
// Setup your Ghost install for various environments
// Documentation can be found at http://support.ghost.org/config/

var path = require('path'),
    config;

config = {
    // ### Development **(default)**
    development: {
        // The url to use when providing links to the site, E.g. in RSS and email.
        url: 'http://my-ghost-blog.com',

        // Example mail config
        // Visit http://support.ghost.org/mail for instructions
        // ```
        //  mail: {
        //      transport: 'SMTP',
        //      options: {
        //          service: 'Mailgun',
        //          auth: {
        //              user: '', // mailgun username
        //              pass: ''  // mailgun password
        //          }
        //      }
        //  },
        // ```

        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-dev.db')
            },
            debug: false
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: '127.0.0.1',
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: '2368'
        },
        paths: {
            contentPath: path.join(__dirname, '/content/')
        }
    },

    // ### Production
    // When running Ghost in the wild, use the production environment
    // Configure your URL and mail settings here
    production: {
      url: 'http://'+process.env.OPENSHIFT_APP_DNS,
      mail: {
              transport: 'SMTP',
              options: {
                service: 'Mailgun',
                auth: {
                    user: 'postmaster@sandbox3ba96916ca1a4a598a04610e77dba5e5.mailgun.org', // mailgun username
                    pass: 'e471965d4bed3e705409dbef67818dbf'  // mailgun password
                }
            }
        },
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: process.env.OPENSHIFT_NODEJS_IP,
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: process.env.OPENSHIFT_NODEJS_PORT
        }
    },

    // **Developers only need to edit below here**

    // ### Testing
    // Used when developing Ghost to run tests and check the health of Ghost
    // Uses a different port number
    testing: {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-test.db')
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        },
        logging: false
    },

    // ### Testing MySQL
    // Used by Travis - Automated testing run through GitHub
    'testing-mysql': {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'mysql',
            connection: {
                host     : '127.0.0.1',
                user     : 'root',
                password : '',
                database : 'ghost_testing',
                charset  : 'utf8'
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        },
        logging: false
    },

    // ### Testing pg
    // Used by Travis - Automated testing run through GitHub
    'testing-pg': {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'pg',
            connection: {
                host     : '127.0.0.1',
                user     : 'postgres',
                password : '',
                database : 'ghost_testing',
                charset  : 'utf8'
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        },
        logging: false
    }
};

// Export config
module.exports = config;
<commit_msg>mailgun credentials removed<commit_after>// # Ghost Configuration
// Setup your Ghost install for various environments
// Documentation can be found at http://support.ghost.org/config/

var path = require('path'),
    config;

config = {
    // ### Development **(default)**
    development: {
        // The url to use when providing links to the site, E.g. in RSS and email.
        url: 'http://my-ghost-blog.com',

        // Example mail config
        // Visit http://support.ghost.org/mail for instructions
        // ```
        //  mail: {
        //      transport: 'SMTP',
        //      options: {
        //          service: 'Mailgun',
        //          auth: {
        //              user: '', // mailgun username
        //              pass: ''  // mailgun password
        //          }
        //      }
        //  },
        // ```

        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-dev.db')
            },
            debug: false
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: '127.0.0.1',
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: '2368'
        },
        paths: {
            contentPath: path.join(__dirname, '/content/')
        }
    },

    // ### Production
    // When running Ghost in the wild, use the production environment
    // Configure your URL and mail settings here
    production: {
      url: 'http://'+process.env.OPENSHIFT_APP_DNS,
      mail: {
              transport: 'SMTP',
              options: {
                service: 'Mailgun',
                auth: {
                    user: 'USER', // mailgun username
                    pass: 'PASS'  // mailgun password
                }
            }
        },
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: process.env.OPENSHIFT_NODEJS_IP,
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: process.env.OPENSHIFT_NODEJS_PORT
        }
    },

    // **Developers only need to edit below here**

    // ### Testing
    // Used when developing Ghost to run tests and check the health of Ghost
    // Uses a different port number
    testing: {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-test.db')
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        },
        logging: false
    },

    // ### Testing MySQL
    // Used by Travis - Automated testing run through GitHub
    'testing-mysql': {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'mysql',
            connection: {
                host     : '127.0.0.1',
                user     : 'root',
                password : '',
                database : 'ghost_testing',
                charset  : 'utf8'
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        },
        logging: false
    },

    // ### Testing pg
    // Used by Travis - Automated testing run through GitHub
    'testing-pg': {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'pg',
            connection: {
                host     : '127.0.0.1',
                user     : 'postgres',
                password : '',
                database : 'ghost_testing',
                charset  : 'utf8'
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        },
        logging: false
    }
};

// Export config
module.exports = config;
<|endoftext|>


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

    /**
     * @param {typeof Base} Base
     * @param {$rootScope.Scope} $scope
     * @param {ModalManager} modalManager
     * @param {Waves} waves
     * @param {BalanceWatcher} balanceWatcher
     * @param {User} user
     * @param {app.utils} utils
     */
    const controller = function (Base, $scope, modalManager, waves, balanceWatcher, user, utils) {

        const { SIGN_TYPE } = require('@waves/signature-adapter');
        const { WAVES_ID } = require('@waves/signature-generator');
        const ds = require('data-service');
        const $ = require('jquery');
        const BASE_64_PREFIX = 'base64:';

        class TokensCtrl extends Base {

            /**
             * Link to angular form object
             * @type {form.FormController}
             */
            createForm = null;
            /**
             * @type {string}
             */
            assetId = '';
            /**
             * Token name
             * @type {string}
             */
            name = '';
            /**
             * Token description
             * @type {string}
             */
            description = '';
            /**
             * Can reissue this token
             * @type {boolean}
             */
            issue = true;
            /**
             * Count of generated tokens
             * @type {BigNumber}
             */
            count = null;
            /**
             * Precision of token
             * @type {number}
             */
            precision = 0;
            /**
             * @type {BigNumber}
             */
            maxCoinsCount = WavesApp.maxCoinsCount;
            /**
             * Has money for fee
             * @type {boolean}
             */
            invalid = false;
            /**
             * @type {string}
             */
            script = '';
            /**
             * @type {boolean}
             */
            isValidScript = true;
            /**
             * @type {boolean}
             */
            scriptPending = false;
            /**
             * @type {Money}
             */
            fee = null;
            /**
             * @type {boolean}
             */
            hasAssetScript = false;
            /**
             * @type {Signable}
             */
            signable = null;
            /**
             * @type {JQueryXHR | null}
             * @private
             */
            _scriptValidationXHR = null;
            /**
             * @type {Money}
             * @private
             */
            _balance;
            /**
             * @type {boolean}
             */
            isNFT = false;

            constructor() {
                super($scope);

                this.receive(balanceWatcher.change, this._onChangeBalance, this);

                this.observe('precision', this._onChangePrecision);
                this.observe('script', this._onChangeScript);
                this.observe([
                    'name',
                    'count',
                    'script',
                    'precision',
                    'description',
                    'issue',
                    'hasAssetScript'
                ], this.createSignable);

                this.observe([
                    'count',
                    'precision',
                    'issue'
                ], this._setIsNFT);

                this._getFee();
                this.observe('isNFT', () => {
                    this._getFee();
                });

                this.observeOnce('createForm', () => {
                    this.receive(utils.observe(this.createForm, '$valid'), this.createSignable, this);
                });
            }

            generate(signable) {
                return modalManager.showConfirmTx(signable)
                    .then(() => this._reset());
            }

            sendAnalytics() {
                analytics.send({ name: 'Token Generation Info Show', target: 'ui' });
            }

            getSignable() {
                return this.signable;
            }

            createSignable() {

                if (!this.name || !this.createForm || !this.createForm.$valid) {
                    this.assetId = '';
                    return null;
                }

                const precision = Number(this.precision.toString());
                const quantity = (this.count || new BigNumber(0)).times(Math.pow(10, precision));
                const script = this.hasAssetScript && this.script ? `${BASE_64_PREFIX}${this.script}` : '';

                const tx = waves.node.transactions.createTransaction({
                    type: SIGN_TYPE.ISSUE,
                    name: this.name,
                    description: this.description,
                    reissuable: this.issue,
                    quantity,
                    precision,
                    script,
                    fee: this.fee
                });

                this.signable = ds.signature.getSignatureApi().makeSignable({ type: tx.type, data: tx });

                this.signable.getId().then(id => {
                    this.assetId = id;
                    utils.safeApply($scope);
                });
            }

            /**
             * @return {null}
             * @private
             */
            _onChangeScript() {
                if (this._scriptValidationXHR) {
                    this._scriptValidationXHR.abort();
                    this.scriptPending = false;
                }
                const script = this.script.replace(BASE_64_PREFIX, '');

                if (!script) {
                    this.isValidScript = true;
                    this.scriptPending = false;
                    return null;
                }

                this.isValidScript = true;
                this.scriptPending = true;
                this._scriptValidationXHR = $.ajax({
                    method: 'POST',
                    url: `${user.getSetting('network.node')}/utils/script/estimate`,
                    data: script
                });

                this._scriptValidationXHR
                    .then(() => {
                        this.isValidScript = true;
                    })
                    .catch(() => {
                        this.isValidScript = false;
                    })
                    .always(() => {
                        this.scriptPending = false;
                        $scope.$apply();
                    });
            }

            /**
             * @param {BigNumber} value
             * @private
             */
            _onChangePrecision({ value }) {
                if (value && value <= 8) {
                    this.maxCoinsCount = WavesApp.maxCoinsCount.div(Math.pow(10, Number(value)));
                }
            }

            /**
             * Current can i send transaction (balance gt fee)
             * @private
             */
            _onChangeBalance() {
                this._balance = balanceWatcher.getBalance()[WAVES_ID];

                this.invalid = (!this.fee || !this._balance) ||
                    this._balance.getTokens().lt(this.fee.getTokens());

                $scope.$apply();
            }

            /**
             * @private
             */
            _reset() {

                this.name = '';
                this.description = '';
                this.issue = true;
                this.count = new BigNumber(0);
                this.precision = 0;
                this.maxCoinsCount = WavesApp.maxCoinsCount;
                this.script = '';
                this.hasAssetScript = false;

                this.createForm.$setPristine();
                this.createForm.$setUntouched();

                $scope.$apply();
            }

            /**
             * @private
             */
            _setIsNFT() {
                const { count, precision, issue } = this;
                const nftCount = count && count.eq(1);
                const nftPrecision = precision === 0;
                this.isNFT = !issue && nftCount && nftPrecision;
            }

            /**
             * @private
             */
            _getFee() {
                waves.node.getFee({
                    type: SIGN_TYPE.ISSUE,
                    reissue: this.issue,
                    precision: this.precision,
                    quantity: this.count
                })
                    .then(money => {
                        this.fee = money;
                        this._onChangeBalance();
                        $scope.$apply();
                    });
            }

        }

        return new TokensCtrl();
    };

    controller.$inject = ['Base', '$scope', 'modalManager', 'waves', 'balanceWatcher', 'user', 'utils'];

    angular.module('app.tokens')
        .controller('TokensCtrl', controller);
})();

<commit_msg>DEXW-1897: refactor<commit_after>(function () {
    'use strict';

    /**
     * @param {typeof Base} Base
     * @param {$rootScope.Scope} $scope
     * @param {ModalManager} modalManager
     * @param {Waves} waves
     * @param {BalanceWatcher} balanceWatcher
     * @param {User} user
     * @param {app.utils} utils
     */
    const controller = function (Base, $scope, modalManager, waves, balanceWatcher, user, utils) {

        const { SIGN_TYPE } = require('@waves/signature-adapter');
        const { WAVES_ID } = require('@waves/signature-generator');
        const ds = require('data-service');
        const $ = require('jquery');
        const BASE_64_PREFIX = 'base64:';

        class TokensCtrl extends Base {

            /**
             * Link to angular form object
             * @type {form.FormController}
             */
            createForm = null;
            /**
             * @type {string}
             */
            assetId = '';
            /**
             * Token name
             * @type {string}
             */
            name = '';
            /**
             * Token description
             * @type {string}
             */
            description = '';
            /**
             * Can reissue this token
             * @type {boolean}
             */
            issue = true;
            /**
             * Count of generated tokens
             * @type {BigNumber}
             */
            count = null;
            /**
             * Precision of token
             * @type {number}
             */
            precision = 0;
            /**
             * @type {BigNumber}
             */
            maxCoinsCount = WavesApp.maxCoinsCount;
            /**
             * Has money for fee
             * @type {boolean}
             */
            invalid = false;
            /**
             * @type {string}
             */
            script = '';
            /**
             * @type {boolean}
             */
            isValidScript = true;
            /**
             * @type {boolean}
             */
            scriptPending = false;
            /**
             * @type {Money}
             */
            fee = null;
            /**
             * @type {boolean}
             */
            hasAssetScript = false;
            /**
             * @type {Signable}
             */
            signable = null;
            /**
             * @type {JQueryXHR | null}
             * @private
             */
            _scriptValidationXHR = null;
            /**
             * @type {Money}
             * @private
             */
            _balance;
            /**
             * @type {boolean}
             */
            isNFT = false;

            constructor() {
                super($scope);

                this.receive(balanceWatcher.change, this._onChangeBalance, this);

                this.observe('precision', this._onChangePrecision);
                this.observe('script', this._onChangeScript);
                this.observe([
                    'name',
                    'count',
                    'script',
                    'precision',
                    'description',
                    'issue',
                    'hasAssetScript'
                ], this.createSignable);

                this.observe([
                    'count',
                    'precision',
                    'issue'
                ], this._setIsNFT);

                this._getFee();
                this.observe('isNFT', this._getFee);

                this.observeOnce('createForm', () => {
                    this.receive(utils.observe(this.createForm, '$valid'), this.createSignable, this);
                });
            }

            generate(signable) {
                return modalManager.showConfirmTx(signable)
                    .then(() => this._reset());
            }

            sendAnalytics() {
                analytics.send({ name: 'Token Generation Info Show', target: 'ui' });
            }

            getSignable() {
                return this.signable;
            }

            createSignable() {

                if (!this.name || !this.createForm || !this.createForm.$valid) {
                    this.assetId = '';
                    return null;
                }

                const precision = Number(this.precision.toString());
                const quantity = (this.count || new BigNumber(0)).times(Math.pow(10, precision));
                const script = this.hasAssetScript && this.script ? `${BASE_64_PREFIX}${this.script}` : '';

                const tx = waves.node.transactions.createTransaction({
                    type: SIGN_TYPE.ISSUE,
                    name: this.name,
                    description: this.description,
                    reissuable: this.issue,
                    quantity,
                    precision,
                    script,
                    fee: this.fee
                });

                this.signable = ds.signature.getSignatureApi().makeSignable({ type: tx.type, data: tx });

                this.signable.getId().then(id => {
                    this.assetId = id;
                    utils.safeApply($scope);
                });
            }

            /**
             * @return {null}
             * @private
             */
            _onChangeScript() {
                if (this._scriptValidationXHR) {
                    this._scriptValidationXHR.abort();
                    this.scriptPending = false;
                }
                const script = this.script.replace(BASE_64_PREFIX, '');

                if (!script) {
                    this.isValidScript = true;
                    this.scriptPending = false;
                    return null;
                }

                this.isValidScript = true;
                this.scriptPending = true;
                this._scriptValidationXHR = $.ajax({
                    method: 'POST',
                    url: `${user.getSetting('network.node')}/utils/script/estimate`,
                    data: script
                });

                this._scriptValidationXHR
                    .then(() => {
                        this.isValidScript = true;
                    })
                    .catch(() => {
                        this.isValidScript = false;
                    })
                    .always(() => {
                        this.scriptPending = false;
                        $scope.$apply();
                    });
            }

            /**
             * @param {BigNumber} value
             * @private
             */
            _onChangePrecision({ value }) {
                if (value && value <= 8) {
                    this.maxCoinsCount = WavesApp.maxCoinsCount.div(Math.pow(10, Number(value)));
                }
            }

            /**
             * Current can i send transaction (balance gt fee)
             * @private
             */
            _onChangeBalance() {
                this._balance = balanceWatcher.getBalance()[WAVES_ID];

                this.invalid = (!this.fee || !this._balance) ||
                    this._balance.getTokens().lt(this.fee.getTokens());

                $scope.$apply();
            }

            /**
             * @private
             */
            _reset() {

                this.name = '';
                this.description = '';
                this.issue = true;
                this.count = new BigNumber(0);
                this.precision = 0;
                this.maxCoinsCount = WavesApp.maxCoinsCount;
                this.script = '';
                this.hasAssetScript = false;

                this.createForm.$setPristine();
                this.createForm.$setUntouched();

                $scope.$apply();
            }

            /**
             * @private
             */
            _setIsNFT() {
                const { count, precision, issue } = this;
                const nftCount = count && count.eq(1);
                const nftPrecision = precision === 0;
                this.isNFT = !issue && nftCount && nftPrecision;
            }

            /**
             * @private
             */
            _getFee() {
                waves.node.getFee({
                    type: SIGN_TYPE.ISSUE,
                    reissue: this.issue,
                    precision: this.precision,
                    quantity: this.count
                })
                    .then(money => {
                        this.fee = money;
                        this._onChangeBalance();
                        $scope.$apply();
                    });
            }

        }

        return new TokensCtrl();
    };

    controller.$inject = ['Base', '$scope', 'modalManager', 'waves', 'balanceWatcher', 'user', 'utils'];

    angular.module('app.tokens')
        .controller('TokensCtrl', controller);
})();

<|endoftext|>


<commit_before>// # Ghost Configuration
// Setup your Ghost install for various environments

var path = require('path'),
    config;

config = {
    // ### Development **(default)**
    development: {
        // The url to use when providing links to the site, E.g. in RSS and email.
        // must not contain a path suffix after the hostname - "subdirs" are not (yet) supported!
        url: 'http://my-ghost-blog.com',

        // Example mail config
        // Visit http://docs.ghost.org/mail for instructions
        // ```
        //  mail: {
        //      transport: 'SMTP',
        //      options: {
        //          service: 'Mailgun',
        //          auth: {
        //              user: '', // mailgun username
        //              pass: ''  // mailgun password
        //          }
        //      }
        //  },
        // ```

        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-dev.db')
            },
            debug: false
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: '127.0.0.1',
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: '2368'
        }
    },

    // ### Production
    // When running Ghost in the wild, use the production environment
    // Configure your URL and mail settings here
    production: {
        // must not contain a path suffix after the hostname - "subdirs" are not (yet) supported!
        url: 'http://pup-pg.azurewebsites.net',
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: '127.0.0.1',
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: 'process.env.PORT'
        },
        mail: {
			transport: 'SMTP',
				options: {
					service: 'Gmail',
					auth: {
						user: 'leonmagsisi@gmail.com',
						pass: 'google_Password???'
					}
				}
		}
    },

    // **Developers only need to edit below here**

    // ### Testing
    // Used when developing Ghost to run tests and check the health of Ghost
    // Uses a different port number
    testing: {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-test.db')
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        }
    },

    // ### Travis
    // Automated testing run through GitHub
    'travis-sqlite3': {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-travis.db')
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        }
    },

    // ### Travis
    // Automated testing run through GitHub
    'travis-mysql': {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'mysql',
            connection: {
                host     : '127.0.0.1',
                user     : 'travis',
                password : '',
                database : 'ghost_travis',
                charset  : 'utf8'
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        }
    },

    // ### Travis
    // Automated testing run through GitHub
    'travis-pg': {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'pg',
            connection: {
                host     : '127.0.0.1',
                user     : 'postgres',
                password : '',
                database : 'ghost_travis',
                charset  : 'utf8'
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        }
    }
};

// Export config
module.exports = config;
<commit_msg>update url<commit_after>// # Ghost Configuration
// Setup your Ghost install for various environments

var path = require('path'),
    config;

config = {
    // ### Development **(default)**
    development: {
        // The url to use when providing links to the site, E.g. in RSS and email.
        // must not contain a path suffix after the hostname - "subdirs" are not (yet) supported!
        url: 'http://progguild.azurewebsites.net/',

        // Example mail config
        // Visit http://docs.ghost.org/mail for instructions
        // ```
        //  mail: {
        //      transport: 'SMTP',
        //      options: {
        //          service: 'Mailgun',
        //          auth: {
        //              user: '', // mailgun username
        //              pass: ''  // mailgun password
        //          }
        //      }
        //  },
        // ```

        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-dev.db')
            },
            debug: false
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: '127.0.0.1',
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: '2368'
        }
    },

    // ### Production
    // When running Ghost in the wild, use the production environment
    // Configure your URL and mail settings here
    production: {
        // must not contain a path suffix after the hostname - "subdirs" are not (yet) supported!
        url: 'http://progguild.azurewebsites.net/',
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: '127.0.0.1',
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: 'process.env.PORT'
        },
        mail: {
			transport: 'SMTP',
				options: {
					service: 'Gmail',
					auth: {
						user: 'leonmagsisi@gmail.com',
						pass: 'google_Password???'
					}
				}
		}
    },

    // **Developers only need to edit below here**

    // ### Testing
    // Used when developing Ghost to run tests and check the health of Ghost
    // Uses a different port number
    testing: {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-test.db')
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        }
    },

    // ### Travis
    // Automated testing run through GitHub
    'travis-sqlite3': {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost-travis.db')
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        }
    },

    // ### Travis
    // Automated testing run through GitHub
    'travis-mysql': {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'mysql',
            connection: {
                host     : '127.0.0.1',
                user     : 'travis',
                password : '',
                database : 'ghost_travis',
                charset  : 'utf8'
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        }
    },

    // ### Travis
    // Automated testing run through GitHub
    'travis-pg': {
        url: 'http://127.0.0.1:2369',
        database: {
            client: 'pg',
            connection: {
                host     : '127.0.0.1',
                user     : 'postgres',
                password : '',
                database : 'ghost_travis',
                charset  : 'utf8'
            }
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        }
    }
};

// Export config
module.exports = config;
<|endoftext|>