<commit_before>var Util    = require("./util.js");

function Repo (local) {

    this.local = local;

    this.isRepository = function (callback) {
        var b = false;

        Util.execute("git", ["rev-parse", "--is-inside-work-tree"], this.local, function (out) {
            if(out === "true")
                b = true;
        }, function () {
            callback(b);
        });
    };

    this.add = function (filepattern, callback) {
        var success = true;

        Util.execute("git", ["add", filepattern], this.local, function (out) {
            if(Util.startsWith(out.toString(), "fatal")) {
                success = false;
            }
        }, function () {
            callback(success);
        });
    };

    this.commit = function (message, callback) {
        var success = true;

        Util.execute("git", ["commit", "-m", "\"" + message + "\""], this.local, function (out) {
            if(Util.startsWith(out.toString(), "nothing")) {
                success = false;
            }
        }, function () {
            callback(success);
        });
    };

    this.push = function (branch, callback) {
        var success = true;

        Util.execute("git", ["push", "origin", branch], this.local, function (out) {

        }, function () {
            callback(success);
        });
    };

    this.log = function (limit, callback) {
        var success = false;
        var params = ["log", "-p"];

        if(typeof limit === "number")
            params.push("-" + limit);
        else
            callback = limit;

        Util.execute("git", params, this.local, function (out) {
            console.log(out);
        }, function () {
            callback(success);
        });

    };

};

module.exports = Repo;<commit_msg>Updated structure of Repo a bit<commit_after>var Util    = require("./util.js");

module.exports = function Repo (local) {
    this.local = local;

    this.isRepository = function (callback) {
        var b = false;

        Util.execute("git", ["rev-parse", "--is-inside-work-tree"], this.local, function (out) {
            if(out === "true")
                b = true;
        }, function () {
            callback(b);
        });
    };

    this.add = function (filepattern, callback) {
        var success = true;

        Util.execute("git", ["add", filepattern], this.local, function (out) {
            if(Util.startsWith(out.toString(), "fatal")) {
                success = false;
            }
        }, function () {
            callback(success);
        });
    };

    this.commit = function (message, callback) {
        var success = true;

        Util.execute("git", ["commit", "-m", "\"" + message + "\""], this.local, function (out) {
            if(Util.startsWith(out.toString(), "nothing")) {
                success = false;
            }
        }, function () {
            callback(success);
        });
    };

    this.push = function (branch, callback) {
        var success = true;

        Util.execute("git", ["push", "origin", branch], this.local, function (out) {

        }, function () {
            callback(success);
        });
    };

    this.log = function (limit, callback) {
        var success = false;
        var params = ["log", "-p"];

        if(typeof limit === "number")
            params.push("-" + limit);
        else
            callback = limit;

        Util.execute("git", params, this.local, function (out) {
            console.log(out);
        }, function () {
            callback(success);
        });

    };
};
<|endoftext|>


<commit_before>
/**
 * @license Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.html or http://ckeditor.com/license
 */

/**
 * This file was added automatically by CKEditor builder.
 * You may re-use it at any time at http://ckeditor.com/builder to build CKEditor again.
 *
 * NOTE:
 *    This file is not used by CKEditor, you may remove it.
 *    Changing this file will not change your CKEditor configuration.
 */

var CKBUILDER_CONFIG = {
	skin: 'moono',
	preset: 'full',
	ignore: [
		'dev',
		'.gitignore',
		'.gitattributes',
		'README.md',
		'.mailmap'
	],
	plugins : {
		'about' : 1,
		'a11yhelp' : 1,
		'dialogadvtab' : 1,
		'basicstyles' : 1,
		'bidi' : 1,
		'blockquote' : 1,
		'clipboard' : 1,
		'colorbutton' : 1,
		'colordialog' : 1,
		'templates' : 1,
		'contextmenu' : 1,
		'div' : 1,
		'toolbar' : 1,
		'elementspath' : 1,
		'enterkey' : 1,
		'entities' : 1,
		'filebrowser' : 1,
		'find' : 1,
		'flash' : 1,
		'floatingspace' : 1,
		'font' : 1,
		'format' : 1,
		'forms' : 1,
		'htmlwriter' : 1,
		'horizontalrule' : 1,
		'iframe' : 1,
		'wysiwygarea' : 1,
		'image' : 1,
		'indent' : 1,
		'justify' : 1,
		'link' : 1,
		'list' : 1,
		'liststyle' : 1,
		'magicline' : 1,
		'maximize' : 1,
		'newpage' : 1,
		'pagebreak' : 1,
		'pastetext' : 1,
		'pastefromword' : 1,
		'preview' : 1,
		'print' : 1,
		'removeformat' : 1,
		'resize' : 1,
		'save' : 1,
		'selectall' : 1,
		'showblocks' : 1,
		'showborders' : 1,
		'smiley' : 1,
		'sourcearea' : 1,
		'specialchar' : 1,
		'stylescombo' : 1,
		'tab' : 1,
		'table' : 1,
		'tabletools' : 1,
		'undo' : 1,
		'dialog' : 1,
		'dialogui' : 1,
		'panelbutton' : 1,
		'button' : 1,
		'floatpanel' : 1,
		'panel' : 1,
		'menu' : 1,
		'popup' : 1,
		'fakeobjects' : 1,
		'richcombo' : 1,
		'listblock' : 1
	},
	languages : {
		'af' : 1,
		'ar' : 1,
		'eu' : 1,
		'bn' : 1,
		'bs' : 1,
		'bg' : 1,
		'ca' : 1,
		'zh-cn' : 1,
		'zh' : 1,
		'hr' : 1,
		'cs' : 1,
		'da' : 1,
		'nl' : 1,
		'en' : 1,
		'en-au' : 1,
		'en-ca' : 1,
		'en-gb' : 1,
		'eo' : 1,
		'et' : 1,
		'fo' : 1,
		'fi' : 1,
		'fr' : 1,
		'fr-ca' : 1,
		'gl' : 1,
		'ka' : 1,
		'de' : 1,
		'el' : 1,
		'gu' : 1,
		'he' : 1,
		'hi' : 1,
		'hu' : 1,
		'is' : 1,
		'it' : 1,
		'ja' : 1,
		'km' : 1,
		'ko' : 1,
		'ku' : 1,
		'lv' : 1,
		'lt' : 1,
		'mk' : 1,
		'ms' : 1,
		'mn' : 1,
		'no' : 1,
		'nb' : 1,
		'fa' : 1,
		'pl' : 1,
		'pt-br' : 1,
		'pt' : 1,
		'ro' : 1,
		'ru' : 1,
		'sr' : 1,
		'sr-latn' : 1,
		'sk' : 1,
		'sl' : 1,
		'es' : 1,
		'sv' : 1,
		'th' : 1,
		'tr' : 1,
		'ug' : 1,
		'uk' : 1,
		'vi' : 1,
		'cy' : 1,
	}
};<commit_msg>Fix ckeditor config file<commit_after>
/**
 * @license Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.html or http://ckeditor.com/license
 */

/**
 * This file was added automatically by CKEditor builder.
 * You may re-use it at any time at http://ckeditor.com/builder to build CKEditor again.
 *
 * NOTE:
 *    This file is not used by CKEditor, you may remove it.
 *    Changing this file will not change your CKEditor configuration.
 */

var CKBUILDER_CONFIG = {
	skin: 'moono',
	preset: 'full',
	ignore: [
		'dev',
		'.gitignore',
		'.gitattributes',
		'README.md',
		'.mailmap'
	],
	plugins : {
		'about' : 1,
		'a11yhelp' : 1,
		'dialogadvtab' : 1,
		'basicstyles' : 1,
		'bidi' : 1,
		'blockquote' : 1,
		'clipboard' : 1,
		'colorbutton' : 1,
		'colordialog' : 1,
		'templates' : 1,
		'contextmenu' : 1,
		'div' : 1,
		'toolbar' : 1,
		'elementspath' : 1,
		'enterkey' : 1,
		'entities' : 1,
		'filebrowser' : 1,
		'find' : 1,
		'flash' : 1,
		'floatingspace' : 1,
		'font' : 1,
		'format' : 1,
		'forms' : 1,
		'htmlwriter' : 1,
		'horizontalrule' : 1,
		'iframe' : 1,
		'wysiwygarea' : 1,
		'image' : 1,
		'indent' : 1,
		'justify' : 1,
		'link' : 1,
		'list' : 1,
		'liststyle' : 1,
		'magicline' : 1,
		'maximize' : 1,
		'newpage' : 1,
		'pagebreak' : 1,
		'pastetext' : 1,
		'pastefromword' : 1,
		'preview' : 1,
		'print' : 1,
		'removeformat' : 1,
		'resize' : 1,
		'save' : 1,
		'selectall' : 1,
		'showblocks' : 1,
		'showborders' : 1,
		'smiley' : 1,
		'sourcearea' : 1,
		'specialchar' : 1,
		'stylescombo' : 1,
		'tab' : 1,
		'table' : 1,
		'tabletools' : 1,
		'undo' : 1,
		'dialog' : 1,
		'dialogui' : 1,
		'panelbutton' : 1,
		'button' : 1,
		'floatpanel' : 1,
		'panel' : 1,
		'menu' : 1,
		'popup' : 1,
		'fakeobjects' : 1,
		'richcombo' : 1,
		'listblock' : 1
	},
	languages : {
		'af' : 1,
		'ar' : 1,
		'eu' : 1,
		'bn' : 1,
		'bs' : 1,
		'bg' : 1,
		'ca' : 1,
		'zh-cn' : 1,
		'zh' : 1,
		'hr' : 1,
		'cs' : 1,
		'da' : 1,
		'nl' : 1,
		'en' : 1,
		'en-au' : 1,
		'en-ca' : 1,
		'en-gb' : 1,
		'eo' : 1,
		'et' : 1,
		'fo' : 1,
		'fi' : 1,
		'fr' : 1,
		'fr-ca' : 1,
		'gl' : 1,
		'ka' : 1,
		'de' : 1,
		'el' : 1,
		'gu' : 1,
		'he' : 1,
		'hi' : 1,
		'hu' : 1,
		'is' : 1,
		'it' : 1,
		'ja' : 1,
		'km' : 1,
		'ko' : 1,
		'ku' : 1,
		'lv' : 1,
		'lt' : 1,
		'mk' : 1,
		'ms' : 1,
		'mn' : 1,
		'no' : 1,
		'nb' : 1,
		'fa' : 1,
		'pl' : 1,
		'pt-br' : 1,
		'pt' : 1,
		'ro' : 1,
		'ru' : 1,
		'sr' : 1,
		'sr-latn' : 1,
		'sk' : 1,
		'sl' : 1,
		'es' : 1,
		'sv' : 1,
		'th' : 1,
		'tr' : 1,
		'ug' : 1,
		'uk' : 1,
		'vi' : 1,
		'cy' : 1
	}
};
<|endoftext|>


<commit_before>var _ = require('lodash');
var React = require('react');
var API = require('data/api');
var RegionTitleMenu     = require('component/RegionTitleMenu.jsx');
var IndicatorDropdownMenu = require('component/IndicatorDropdownMenu.jsx');
var CampaignDropdownMenu = require('component/CampaignDropdownMenu.jsx');
var DashboardStore    	= require('stores/DashboardStore');
var Modal = require('react-modal');

var appElement = document.getElementById('main');
Modal.setAppElement(appElement);
Modal.injectCSS();

const {
	Datascope, LocalDatascope,
	SimpleDataTable, SimpleDataTableColumn,
	ClearQueryLink,
	Paginator,
	SearchBar,
	FilterPanel, FilterDateRange, FilterInputRadio
	} = require('react-datascope');

var parseSchema = require('ufadmin/utils/parseSchema');

var ReviewTable = React.createClass({
	propTypes: {
		title: React.PropTypes.string.isRequired,
		getMetadata: React.PropTypes.func.isRequired,
		getData: React.PropTypes.func.isRequired,
    loading   : React.PropTypes.bool.isRequired,
		region 		: React.PropTypes.object.isRequired,
		campaign 	: React.PropTypes.object.isRequired,
		doc_tab 	: React.PropTypes.string.isRequired,

	},
	getInitialState: function() {
		return {
			data: null,
			schema: null,
			query: {},
			loading   : false,
		}
	},

	openModal: function() {
		this.setState({modalIsOpen: true});
	},

	closeModal: function() {
		this.setState({modalIsOpen: false});
	},

  getDefaultProps : function () {
    return {
      loading : false
    };
  },

	postMetaMap : function(source_object_map_id) {
		console.log(source_object_map_id)
	},

	mapForm : function(source_object_map_id){ //, source_object_code

		var source_object_name = 'some-fake-metadata'
		var content_type = 'region'
		//
		var dropDown = <RegionTitleMenu
			                     regions={DashboardStore.regions}
													 selected={this.props.region}
			                     sendValue={this.postMetaMap} />
		//

		return
<button className="tiny" onClick={this.openModal}> map! </button>
		        <Modal
		          isOpen={this.state.modalIsOpen}
		          onRequestClose={this.closeModal}
		        >

Mapping for {content_type} - {source_object_name}

		          <form>
							{dropDown}
		          </form>
		        </Modal>

	},

	validateForm : function(id){
			// onclick post to api..
			return <input type="checkbox" checked  />;
	},

	_callApi : function(){
		this.props.getMetadata()
		.then(response => this.setState({
				schema: parseSchema(response)
		}));

		this.props.getData({
				document_id:this.props.doc_id,
				region_id:this.props.region.id,
				campaign_id:this.props.campaign.id
			},null,{'cache-control':'no-cache'})
			.then(response => this.setState({
						data: response.objects
			}));
			this.forceUpdate();
	},

	componentWillMount: function() {
			this._callApi()
		},

	componentWillReceiveProps: function(nextProps) {
		this._callApi()
	},

	componentWillUpdate : function (nextProps, nextState) {
			// FIXME -> needs cleanup
			if (nextProps.region != this.props.region) {
				console.log('updagin with  new regions')
				return;
			}
			if (nextProps.getMetadata != this.props.getMetadata) {
				console.log('bring up a new table')
				return;
			}
			if (nextProps.doc_id != this.props.doc_id) {
				console.log('new doc id')
				return;
			}
		},

	render() {

		const fields = {
			is_valid: {
				title: 'Edit',
				key: 'id',
				renderer: (id) => {
						if (this.props.doc_tab == 'validate') {
							return this.validateForm(id)
					}
						else if (this.props.doc_tab == 'mapping') {
							return this.mapForm(id)
					}
				}
			},
		};

		var isLoaded = _.isArray(this.state.data) && this.state.schema && (!this.state.loading);
		if(!isLoaded) return this.renderLoading();

		var {data, schema} = this.state;

		return

        <LocalDatascope
				 		data={data}
						schema={schema}
						fields={fields}
						pageSize={25}>
	         <Datascope>
	           {this.props.children}
	         </Datascope>
         </LocalDatascope>

	},
	renderLoading() {
		return
 Review Page Loading...

	},
});

module.exports = ReviewTable;
<commit_msg>add style to popup<commit_after>var _ = require('lodash');
var React = require('react');
var API = require('data/api');
var RegionTitleMenu     = require('component/RegionTitleMenu.jsx');
var IndicatorDropdownMenu = require('component/IndicatorDropdownMenu.jsx');
var CampaignDropdownMenu = require('component/CampaignDropdownMenu.jsx');
var DashboardStore    	= require('stores/DashboardStore');
var Modal = require('react-modal');

var appElement = document.getElementById('main');
Modal.setAppElement(appElement);
Modal.injectCSS();

const {
	Datascope, LocalDatascope,
	SimpleDataTable, SimpleDataTableColumn,
	ClearQueryLink,
	Paginator,
	SearchBar,
	FilterPanel, FilterDateRange, FilterInputRadio
	} = require('react-datascope');

var parseSchema = require('ufadmin/utils/parseSchema');

var ReviewTable = React.createClass({
	propTypes: {
		title: React.PropTypes.string.isRequired,
		getMetadata: React.PropTypes.func.isRequired,
		getData: React.PropTypes.func.isRequired,
    loading   : React.PropTypes.bool.isRequired,
		region 		: React.PropTypes.object.isRequired,
		campaign 	: React.PropTypes.object.isRequired,
		doc_tab 	: React.PropTypes.string.isRequired,

	},
	getInitialState: function() {
		return {
			data: null,
			schema: null,
			query: {},
			loading   : false,
		}
	},

	openModal: function() {
		this.setState({modalIsOpen: true});
	},

	closeModal: function() {
		this.setState({modalIsOpen: false});
	},

  getDefaultProps : function () {
    return {
      loading : false
    };
  },

	postMetaMap : function(source_object_map_id) {
		console.log('posting')
		console.log(source_object_map_id)
	},

	mapForm : function(source_object_map_id){ //, source_object_code

		var source_object_name = 'some-fake-metadata'
		var content_type = 'region'
		//
		var dropDown = <RegionTitleMenu
			                     regions={DashboardStore.regions}
													 selected={this.props.region}
			                     sendValue={this.postMetaMap} />
		//

		var modalStyle = {width:400, marginLeft:400}; // rendered as "height:10px"

		return
<button className="tiny" onClick={this.openModal}> map! </button>
		        <Modal
							style={modalStyle}
		          isOpen={this.state.modalIsOpen}
		          onRequestClose={this.closeModal}
		        >

Mapping for {content_type} - {source_object_name}

			          <form>
								{dropDown}
			          </form>
		        </Modal>

	},

	validateForm : function(id){
			// onclick post to api..
			return <input type="checkbox" checked  />;
	},

	_callApi : function(){
		this.props.getMetadata()
		.then(response => this.setState({
				schema: parseSchema(response)
		}));

		this.props.getData({
				document_id:this.props.doc_id,
				region_id:this.props.region.id,
				campaign_id:this.props.campaign.id
			},null,{'cache-control':'no-cache'})
			.then(response => this.setState({
						data: response.objects
			}));
			this.forceUpdate();
	},

	componentWillMount: function() {
			this._callApi()
		},

	componentWillReceiveProps: function(nextProps) {
		this._callApi()
	},

	componentWillUpdate : function (nextProps, nextState) {
			// FIXME -> needs cleanup
			if (nextProps.region != this.props.region) {
				console.log('updagin with  new regions')
				return;
			}
			if (nextProps.getMetadata != this.props.getMetadata) {
				console.log('bring up a new table')
				return;
			}
			if (nextProps.doc_id != this.props.doc_id) {
				console.log('new doc id')
				return;
			}
		},

	render() {

		const fields = {
			is_valid: {
				title: 'Edit',
				key: 'id',
				renderer: (id) => {
						if (this.props.doc_tab == 'validate') {
							return this.validateForm(id)
					}
						else if (this.props.doc_tab == 'mapping') {
							return this.mapForm(id)
					}
				}
			},
		};

		var isLoaded = _.isArray(this.state.data) && this.state.schema && (!this.state.loading);
		if(!isLoaded) return this.renderLoading();

		var {data, schema} = this.state;

		return

        <LocalDatascope
				 		data={data}
						schema={schema}
						fields={fields}
						pageSize={25}>
	         <Datascope>
	           {this.props.children}
	         </Datascope>
         </LocalDatascope>

	},
	renderLoading() {
		return
 Review Page Loading...

	},
});

module.exports = ReviewTable;
<|endoftext|>


<commit_before>sap.ui.jsfragment("SMADJS.view.SubmitFragment", {
	createContent: function(oController) {

		var oText1 = new sap.m.Text({
			text:oController.message
		});

		var oPanel = new sap.m.Panel({
			class:"SapUiResponsiveMargin",
			width:"auto",
			content:[oText1]
		});

		if (oController.status === 200) {
			var text2 = "Registration is not complete until you have paid (cost is $80/child for the week). Payment details:\n\n" +
			"Account Name: CANBERRA BAPTIST CHURCH - SMAD CAMP\nBSB: 062 901\nAccount Number: 1021 7815\nReference: Your child/ren's last name";
		} else if (oController.status === 201) {
			text2 = "You will be contacted if a place becomes available.";
		}	else {
			text2 = "Please email smadcamp@hotmail.com";
		}

		var oText2 = new sap.m.Text({
			text:text2
		});

		var oPanel2 = new sap.m.Panel({
			class:"SapUiResponsiveMargin",
			width:"auto",
			content:[oText2]
		});

		switch (oController.status) {
			case 200: title = "Registration Successful";
				break;
			case 201: title = "Waitlisted Successfully";
				break;
			default: title = "Registration Error";
				break;
		};
		//var title = (oController.status === 200) ? "Registration Successful" : "Registration Error";

		var oSubmitPage = new sap.m.Page({
			title:title,
			content: [oPanel,oPanel2],
			showNavButton:false
		});

		return [oSubmitPage];
	}
});
<commit_msg>Update text after registered<commit_after>sap.ui.jsfragment("SMADJS.view.SubmitFragment", {
	createContent: function(oController) {

		var oText1 = new sap.m.Text({
			text:oController.message
		});

		var oPanel = new sap.m.Panel({
			class:"SapUiResponsiveMargin",
			width:"auto",
			content:[oText1]
		});

		if (oController.status === 200) {
			var text2 = "Congratulations you are now registered. You have one week to pay or we may give your spot away (cost is $80/child for the week). Payment details:\n\n" +
			"Account Name: CANBERRA BAPTIST CHURCH - SMAD CAMP\nBSB: 062 901\nAccount Number: 1021 7815\nReference: Your child/ren's last name" +
			"\n\nYou will receive an email in the next 24 hours. Please do not contact SMAD CAMP before then.";
		} else if (oController.status === 201) {
			text2 = "You will be contacted if a place becomes available.";
		}	else {
			text2 = "Please email smadcamp@hotmail.com";
		}

		var oText2 = new sap.m.Text({
			text:text2
		});

		var oPanel2 = new sap.m.Panel({
			class:"SapUiResponsiveMargin",
			width:"auto",
			content:[oText2]
		});

		switch (oController.status) {
			case 200: title = "Registration Successful";
				break;
			case 201: title = "Waitlisted Successfully";
				break;
			default: title = "Registration Error";
				break;
		};
		//var title = (oController.status === 200) ? "Registration Successful" : "Registration Error";

		var oSubmitPage = new sap.m.Page({
			title:title,
			content: [oPanel,oPanel2],
			showNavButton:false
		});

		return [oSubmitPage];
	}
});
<|endoftext|>


<commit_before>import React, { Component } from 'react';
import { Text } from 'react-native';

import styles from '../../styles/styles.ios';
import InPageImage from '../inPageImage';
import AnimalText from '../animalText';
import AnimalTemplate from '../animalTemplate';

const IMAGES = [
  require('../../images/animals/lachtanMedvedi/01.jpg'),
  require('../../images/animals/lachtanMedvedi/02.jpg'),
// @todo: broken JPG
//  require('../../images/animals/lachtanMedvedi/03.jpg'),
];

const THUMBNAILS = [
  require('../../images/animals/lachtanMedvedi/01-thumb.jpg'),
  require('../../images/animals/lachtanMedvedi/02-thumb.jpg'),
//  require('../../images/animals/lachtanMedvedi/03-thumb.jpg'),
];

var AnimalDetail = React.createClass({
  render() {
    return (
      <AnimalTemplate firstIndex={[1]} thumbnails={THUMBNAILS} images={IMAGES} navigator={this.props.navigator}>
          <AnimalText>
          Seznamte se, zde bydlí <Text style={styles.ctextItalic}>Callorhinus ursinus</Text>, ploutvonožci z čeledi lachtanovitých. Momentálně zde žijí dva, konkrétně samec Sema a samička Vafla. Zdají se vám ta jména zvláštní? Právem, oba lachtani dostali jméno v Rusku, odkud jsme si je přivezli. Z Rostova na Donu k nám dorazili v noci z 19. na 20. prosince 2013.
          </AnimalText>
          <AnimalText>
            Lachtani patří mezi nejoblíbenější zvířata chovaná v zoologických zahradách. Proč? Nelze se nepozastavit nad jejich tak trochu komickým vzhledem, který jen podtrhuje velmi hravá povaha. Jsou navíc velice inteligentní a i díky tomu je lze srovnávat například se psem. Nesnášejí nudu a baví se třeba i tím, že pod vodou vypouštějí bublinky, kolem kterých pak krouží. Taky vynášejí ze dna kameny, jež následně nechávají klesat zpět. Vzhledem k tomu, že se moc rádi předvádějí a milují publikum, pořádáme tady v zoo pravidelná komentovaná krmení, při nichž lachtani vykonávají jednoduché cviky. Cvičení a hra s chovatelem je pro ně velmi důležitá. Zachovává jejich bystrost, přináší jim radost ze života a udržuje dobrý psychický i fyzický stav.
          </AnimalText>
          <AnimalText>
            U tohoto druhu je hodně výrazný pohlavní dimorfismus. To znamená, že se samec a samice liší, a to v tomto případě nejen velikostí. Samci mají načervenalou až zcela černou barvu, mohou dosahovat váhy až 270 kg a jsou 4,5krát těžší než samice, které jsou stříbřitě šedé nebo hnědé se světlou skvrnou na hrudi. Mladí lachtani pak bývají černí se světlým značením kolem nosu a tlamy.
          </AnimalText>
          <AnimalText>
            Lachtanovití obecně jsou dokonale přizpůsobeni životu pod vodou. Dokážou se ponořit až do hloubky 200 metrů a pod hladinou vydrží i 7 minut. Jejich tělo je proti chladu chráněno hustou mastnou srstí, přes kterou nepronikne voda. Předními ploutvemi veslují a extrémně dlouhými zadními ploutvemi kormidlují. Dokonce se poměrně rychle pohybují i po pevnině. Většinu života však tráví právě ve vodě, kde dokonce i spí, a to na hladině, na které přes den plavou na zádech nebo na boku.
          </AnimalText>
          <InPageImage indexes={[0]} thumbnails={THUMBNAILS} images={IMAGES} navigator={this.props.navigator} />
          <AnimalText>
            Domovem lachtanů medvědích je severní část Tichého oceánu, od Beringova moře po jižní Japonsko na západě a pobřeží Kalifornie na východě Pacifiku. Moře a oceán protkávají dlouhými migračními cestami za potravou, kterou tvoří převážně ryby, hlavonožci a korýši. Na pevninu vystupují jen v době rozmnožování, k němuž dochází v početných koloniích. Na konci května samci soupeří o teritoria na skalnatých či písčitých pobřežích ostrovů. Takové boje mohou být velmi násilné a jen největší a nejsilnější z nich se mohou stát vládci harému. Mladší a slabší jedinci obsazují okraje teritorií.
          </AnimalText>
          <AnimalText>
            Během června se na ostrovech postupně objevují samice oplodněné z minulé sezony. Za jeden nebo dva dny každá porodí jedno mládě, které následně tři až čtyři měsíce kojí. Už týden po porodu je však schopna se znovu pářit. Dominantní samec jich v harému může mít až padesát. Kolonie bývají velmi přeplněné a často se stává, že některé potulné samice zabloudí na území jiného samce. Takových příležitostí pak využívají někteří slabší jedinci, kteří se jinak páří výjimečně. Vládci harémů tak nemají klid ani v období páření, své samice si musí hlídat, případně se o ně dohadovat s ostatními samci, a to i přes to, že si prve vybojovali své území. A aby měli větší jistotu, že jejich partnerky nebudou sváděni jinými samci, nejedí a jsou tak schopni ztratit až 20 % své tělesné hmotnosti.
          </AnimalText>
          <InPageImage indexes={[2]} thumbnails={THUMBNAILS} images={IMAGES} navigator={this.props.navigator} />
          <AnimalText>
            Dospělí samci pak opouštějí skalnaté ostrovy přibližně od konce srpna, samice odstavují mláďata na konci října. Na stejné místo se vracejí i několik let po sobě.
          </AnimalText>
      </AnimalTemplate>
    );
  }
});

module.exports = AnimalDetail;
<commit_msg>Update lachtanMedvedi.adult.js<commit_after>import React, { Component } from 'react';
import { Text } from 'react-native';

import styles from '../../styles/styles.ios';
import InPageImage from '../inPageImage';
import AnimalText from '../animalText';
import AnimalTemplate from '../animalTemplate';

const IMAGES = [
  require('../../images/animals/lachtanMedvedi/01.jpg'),
  require('../../images/animals/lachtanMedvedi/02.jpg'),
// @todo: broken JPG
//  require('../../images/animals/lachtanMedvedi/03.jpg'),
];

const THUMBNAILS = [
  require('../../images/animals/lachtanMedvedi/01-thumb.jpg'),
  require('../../images/animals/lachtanMedvedi/02-thumb.jpg'),
//  require('../../images/animals/lachtanMedvedi/03-thumb.jpg'),
];

var AnimalDetail = React.createClass({
  render() {
    return (
      <AnimalTemplate firstIndex={[1]} thumbnails={THUMBNAILS} images={IMAGES} navigator={this.props.navigator}>
          <AnimalText>
          Seznamte se, zde bydlí <Text style={styles.italic}>Callorhinus ursinus</Text>, ploutvonožci z čeledi lachtanovitých. Momentálně zde žijí dva, konkrétně samec Sema a samička Vafla. Zdají se vám ta jména zvláštní? Právem, oba lachtani dostali jméno v Rusku, odkud jsme si je přivezli. Z Rostova na Donu k nám dorazili v noci z 19. na 20. prosince 2013.
          </AnimalText>
          <AnimalText>
            Lachtani patří mezi nejoblíbenější zvířata chovaná v zoologických zahradách. Proč? Nelze se nepozastavit nad jejich tak trochu komickým vzhledem, který jen podtrhuje velmi hravá povaha. Jsou navíc velice inteligentní a i díky tomu je lze srovnávat například se psem. Nesnášejí nudu a baví se třeba i tím, že pod vodou vypouštějí bublinky, kolem kterých pak krouží. Taky vynášejí ze dna kameny, jež následně nechávají klesat zpět. Vzhledem k tomu, že se moc rádi předvádějí a milují publikum, pořádáme tady v zoo pravidelná komentovaná krmení, při nichž lachtani vykonávají jednoduché cviky. Cvičení a hra s chovatelem je pro ně velmi důležitá. Zachovává jejich bystrost, přináší jim radost ze života a udržuje dobrý psychický i fyzický stav.
          </AnimalText>
          <AnimalText>
            U tohoto druhu je hodně výrazný pohlavní dimorfismus. To znamená, že se samec a samice liší, a to v tomto případě nejen velikostí. Samci mají načervenalou až zcela černou barvu, mohou dosahovat váhy až 270 kg a jsou 4,5krát těžší než samice, které jsou stříbřitě šedé nebo hnědé se světlou skvrnou na hrudi. Mladí lachtani pak bývají černí se světlým značením kolem nosu a tlamy.
          </AnimalText>
          <AnimalText>
            Lachtanovití obecně jsou dokonale přizpůsobeni životu pod vodou. Dokážou se ponořit až do hloubky 200 metrů a pod hladinou vydrží i 7 minut. Jejich tělo je proti chladu chráněno hustou mastnou srstí, přes kterou nepronikne voda. Předními ploutvemi veslují a extrémně dlouhými zadními ploutvemi kormidlují. Dokonce se poměrně rychle pohybují i po pevnině. Většinu života však tráví právě ve vodě, kde dokonce i spí, a to na hladině, na které přes den plavou na zádech nebo na boku.
          </AnimalText>
          <InPageImage indexes={[0]} thumbnails={THUMBNAILS} images={IMAGES} navigator={this.props.navigator} />
          <AnimalText>
            Domovem lachtanů medvědích je severní část Tichého oceánu, od Beringova moře po jižní Japonsko na západě a pobřeží Kalifornie na východě Pacifiku. Moře a oceán protkávají dlouhými migračními cestami za potravou, kterou tvoří převážně ryby, hlavonožci a korýši. Na pevninu vystupují jen v době rozmnožování, k němuž dochází v početných koloniích. Na konci května samci soupeří o teritoria na skalnatých či písčitých pobřežích ostrovů. Takové boje mohou být velmi násilné a jen největší a nejsilnější z nich se mohou stát vládci harému. Mladší a slabší jedinci obsazují okraje teritorií.
          </AnimalText>
          <AnimalText>
            Během června se na ostrovech postupně objevují samice oplodněné z minulé sezony. Za jeden nebo dva dny každá porodí jedno mládě, které následně tři až čtyři měsíce kojí. Už týden po porodu je však schopna se znovu pářit. Dominantní samec jich v harému může mít až padesát. Kolonie bývají velmi přeplněné a často se stává, že některé potulné samice zabloudí na území jiného samce. Takových příležitostí pak využívají někteří slabší jedinci, kteří se jinak páří výjimečně. Vládci harémů tak nemají klid ani v období páření, své samice si musí hlídat, případně se o ně dohadovat s ostatními samci, a to i přes to, že si prve vybojovali své území. A aby měli větší jistotu, že jejich partnerky nebudou sváděni jinými samci, nejedí a jsou tak schopni ztratit až 20 % své tělesné hmotnosti.
          </AnimalText>
          <InPageImage indexes={[2]} thumbnails={THUMBNAILS} images={IMAGES} navigator={this.props.navigator} />
          <AnimalText>
            Dospělí samci pak opouštějí skalnaté ostrovy přibližně od konce srpna, samice odstavují mláďata na konci října. Na stejné místo se vracejí i několik let po sobě.
          </AnimalText>
      </AnimalTemplate>
    );
  }
});

module.exports = AnimalDetail;
<|endoftext|>


<commit_before>/**
 * @author Craig Thayer <cthayer@sazze.com>
 * @copyright 2014 Sazze, Inc.
 */

var _ = require('lodash');
var client = require('request');
var async = require('async');
var querystring = require('querystring');

var log = {};
log.debug = require('debug')('@sazze/riak:debug');
log.verbose = require('debug')('@sazze/riak:verbose');

function Riak(options) {
  if (_.isString(options)) {
    options = {
      bucket: options
    };
  }

  if (!_.isPlainObject(options)) {
    options = {};
  }

  this.bucket = options.bucket || '';
  this.host = options.host || process.env.SZ_RIAK_HOST || '127.0.0.1';
  this.port = options.port || process.env.SZ_RIAK_PORT || 8098;
}

Riak.ASYNC_LIMIT = process.env.SZ_RIAK_ASYNC_LIMIT || 20;

//
// static methods
//

Riak.parseHeaders = function (headers) {
  var properties = {
    vclock: '',
    links: [],
    meta: {},
    index: {},
    contentType: ''
  };

  if (_.isEmpty(headers)) {
    return properties;
  }

  _.forEach(headers, function (val, name) {
    switch (name.toLowerCase()) {
      case 'content-type':
        properties.contentType = val;
        break;

      case 'x-riak-vclock':
        properties.vclock = val;
        break;

      case 'link':
        val = val.split(',');

        _.forEach(val, function (l) {
          var parts = l.trim().split(';');
          var link = {link: parts[0].trim().replace('<', '').replace('>', ''), tag: ''};

          if (!_.isUndefined(parts[1])) {
            // skip internal riak headers that are not allowed client requests
            if (_.contains(parts[1], 'rel=')) {
              return;
            }

            link.tag = parts[1].trim().replace('riaktag="', '').replace('"', '');
          }

          properties.links.push(link);
        });

        break;

      default:
        if (_.contains(name, 'x-riak-meta-')) {
          properties.meta[name.replace('x-riak-meta-', '')] = val;
          break;
        }

        if (_.contains(name, 'x-riak-index-')) {
          if (_.contains(name, 'x-riak-index-')) {
            properties.index[name.replace('x-riak-index-', '')] = val;
            break;
          }
        }

        break;
    }
  });

  log.verbose(properties);

  return properties;
};

Riak.prepareHeaders = function (obj) {
  var headers = {};

  if (_.isEmpty(obj)) {
    return headers;
  }

  var links = [];

  _.forEach(obj, function (val, name) {
    switch (name.toLowerCase()) {
      case 'vclock':
        headers['x-riak-vclock'] = val;

        delete obj.vclock;

        break;

      case 'links':
        _.forEach(obj.links, function (link) {
          if (_.isUndefined(link.link)) {
            return;
          }

          if (_.isUndefined(link.tag) || _.isEmpty(link.tag)) {
            links.push('<' + link.link + '>');
          } else {
            links.push('<' + link.link + '>; riaktag="' + link.tag + '"');
          }
        });

        delete obj.links;

        break;

      case 'meta':
        _.forEach(obj.meta, function (val, name) {
          headers['x-riak-meta-' + name] = val;
        });

        delete obj.meta;

        break;

      case 'index':
        _.forEach(obj.index, function (val, name) {
          headers['x-riak-index-' + name] = val;
        });

        delete obj.index;

        break;

      default:
        break;
    }
  });

  if (links.length > 0) {
    headers['link'] = links.join(', ');
  }

  log.verbose(headers);

  return headers;
};

module.exports = Riak;

//
// methods
//

Riak.prototype.getUrl = function (key) {
  return 'http://' + this.host + ':' + this.port + '/buckets/' + this.bucket + '/keys/' + key;
};

Riak.prototype.getSecondaryIndexUrl = function (index, search, options) {
  var url = 'http://' + this.host + ':' + this.port + '/buckets/' + this.bucket + '/index/' + index + '/' + (search.join ? search.join('/') : search);

  if (options && _.isPlainObject(options)) {
    url += '?' + querystring.stringify(options);
  }

  return url;
};

Riak.prototype.mget = function (keys, cb) {
  if (!_.isArray(keys)) {
    cb(new Error('keys must be an array'));
    return;
  }

  async.mapLimit(keys, Riak.ASYNC_LIMIT, function (key, callback) {
    this.get(key, function (err, res, resp) {
      callback(err, {resp: res, rawResp: resp});
    });
  }.bind(this), function (err, results) {
    cb(err, results);
  });
};

Riak.prototype.get = function (key, cb) {
  if (!_.isFunction(cb)) {
    cb = _.noop;
  }

  if (!_.isString(key) || !key) {
    cb(new Error('Invalid key: ' + key));
    return;
  }

  var url = this.getUrl(key);

  log.verbose('riak url: GET ' + url);

  client(url, function (err, resp, body) {
    if (err) {
      cb(err);
      return;
    }

    log.debug('riak response code: ' + resp.statusCode);
    log.verbose('riak headers: ' + JSON.stringify(resp.headers));
    log.verbose('riak response: ' + body);

    if (resp.statusCode == 404) {
      // handle not found response
      cb(null, {}, resp);
      return;
    }

    if (resp.statusCode != 200) {
      cb(new Error('riak returned status code: ' + resp.statusCode), null, resp);
      return;
    }

    if (_.isString(body) && resp.headers['content-type'].toLowerCase() == 'application/json') {
      body = JSON.parse(body);
    }

    _.merge(body, Riak.parseHeaders(resp.headers));

    cb(null, body, resp);
  });
};

Riak.prototype.mput = function (puts, cb) {
  if (!_.isArray(puts)) {
    cb(new Error('puts must be an array of put objects'));
    return;
  }

  async.mapLimit(puts, Riak.ASYNC_LIMIT, function (put, callback) {
    if (!_.isPlainObject(put)) {
      callback(new Error('Invalid request object: ' + put));
      return;
    }

    this.put(put.key, put.body, put.headers, function (err, res, resp) {
      callback(err, {resp: res, rawResp: resp});
    });
  }.bind(this), function (err, results) {
    cb(err, results);
  });
};

Riak.prototype.put = function (key, body, headers, cb) {
  if (_.isUndefined(headers)) {
    headers = {};
  }

  if (_.isFunction(headers)) {
    cb = headers;
    headers = {};
  }

  if (!_.isFunction(cb)) {
    cb = _.noop;
  }

  if (!_.isString(key) || !key) {
    cb(new Error('Invalid key: ' + key));
    return;
  }

  // if the body is not a string, we treat it as an object and store with content-type: application/json
  if (!_.isString(body)) {
    headers['content-type'] = 'application/json';

    if (_.isObject(body)) {
      _.merge(headers, Riak.prepareHeaders(body));
    }

    body = JSON.stringify(body);
  }

  if (_.isUndefined(headers['content-type'])) {
    headers['content-type'] = 'text/plain';
  }

  var url = this.getUrl(key);

  log.verbose('riak url: PUT ' + url);

  client.put({url: url, body: body, headers: headers, qs: {returnbody: true}}, function (err, resp, body) {
    if (err) {
      cb(err);
      return;
    }

    log.debug('riak response code: ' + resp.statusCode);
    log.verbose('riak headers: ' + JSON.stringify(resp.headers));
    log.verbose('riak response: ' + body);

    if (resp.statusCode != 200) {
      cb(new Error('riak returned status code: ' + resp.statusCode), null, resp);
      return;
    }

    if (_.isString(body) && resp.headers['content-type'].toLowerCase() == 'application/json') {
      body = JSON.parse(body);
    }

    _.merge(body, Riak.parseHeaders(resp.headers));

    cb(null, body, resp);
  });
};

Riak.prototype.mdel = function (keys, cb) {
  if (!_.isArray(keys)) {
    cb(new Error('keys must be an array'));
    return;
  }

  async.mapLimit(keys, Riak.ASYNC_LIMIT, this.del.bind(this), function (err) {
    cb(err);
  });
};

Riak.prototype.del = function (key, cb) {
  if (!_.isFunction(cb)) {
    cb = _.noop;
  }

  if (!_.isString(key) || !key) {
    cb(new Error('Invalid key: ' + key));
    return;
  }

  var url = this.getUrl(key);

  log.verbose('riak url: DELETE ' + url);

  client.del(url, function (err, resp) {
    if (err) {
      cb(err);
      return;
    }

    log.debug('riak response code: ' + resp.statusCode);
    log.verbose('riak headers: ' + JSON.stringify(resp.headers));

    if (resp.statusCode == 404) {
      // handle not found response
      cb(null);
      return;
    }

    if (resp.statusCode != 204) {
      cb(new Error('riak returned status code: ' + resp.statusCode));
      return;
    }

    cb(null);
  });
};

Riak.prototype.secondaryIndexSearch = function (index, search, options, cb) {
  if (_.isFunction(options)) {
    cb = options;
    options = undefined;
  }

  if (!_.isFunction(cb)) {
    cb = _.noop;
  }

  if (!_.isString(index) || !index) {
    cb(new Error('Invalid index: ' + index));
    return;
  }

  var url = this.getSecondaryIndexUrl(index, search, options);

  log.verbose('riak url: GET ' + url);

  client(url, function (err, resp, body) {
    if (err) {
      cb(err);
      return;
    }

    log.debug('riak response code: ' + resp.statusCode);
    log.verbose('riak headers: ' + JSON.stringify(resp.headers));
    log.verbose('riak response: ' + body);

    if (resp.statusCode == 404) {
      // handle not found response
      cb(null, {}, resp);
      return;
    }

    if (resp.statusCode != 200) {
      cb(new Error('riak returned status code: ' + resp.statusCode), body, resp);
      return;
    }

    if (_.isString(body) && resp.headers['content-type'].toLowerCase() == 'application/json') {
      body = JSON.parse(body);
    }

    cb(null, body, resp);
  });
};<commit_msg>make riak url logging a debug log instead of a verbose log<commit_after>/**
 * @author Craig Thayer <cthayer@sazze.com>
 * @copyright 2014 Sazze, Inc.
 */

var _ = require('lodash');
var client = require('request');
var async = require('async');
var querystring = require('querystring');

var log = {};
log.debug = require('debug')('@sazze/riak:debug');
log.verbose = require('debug')('@sazze/riak:verbose');

function Riak(options) {
  if (_.isString(options)) {
    options = {
      bucket: options
    };
  }

  if (!_.isPlainObject(options)) {
    options = {};
  }

  this.bucket = options.bucket || '';
  this.host = options.host || process.env.SZ_RIAK_HOST || '127.0.0.1';
  this.port = options.port || process.env.SZ_RIAK_PORT || 8098;
}

Riak.ASYNC_LIMIT = process.env.SZ_RIAK_ASYNC_LIMIT || 20;

//
// static methods
//

Riak.parseHeaders = function (headers) {
  var properties = {
    vclock: '',
    links: [],
    meta: {},
    index: {},
    contentType: ''
  };

  if (_.isEmpty(headers)) {
    return properties;
  }

  _.forEach(headers, function (val, name) {
    switch (name.toLowerCase()) {
      case 'content-type':
        properties.contentType = val;
        break;

      case 'x-riak-vclock':
        properties.vclock = val;
        break;

      case 'link':
        val = val.split(',');

        _.forEach(val, function (l) {
          var parts = l.trim().split(';');
          var link = {link: parts[0].trim().replace('<', '').replace('>', ''), tag: ''};

          if (!_.isUndefined(parts[1])) {
            // skip internal riak headers that are not allowed client requests
            if (_.contains(parts[1], 'rel=')) {
              return;
            }

            link.tag = parts[1].trim().replace('riaktag="', '').replace('"', '');
          }

          properties.links.push(link);
        });

        break;

      default:
        if (_.contains(name, 'x-riak-meta-')) {
          properties.meta[name.replace('x-riak-meta-', '')] = val;
          break;
        }

        if (_.contains(name, 'x-riak-index-')) {
          if (_.contains(name, 'x-riak-index-')) {
            properties.index[name.replace('x-riak-index-', '')] = val;
            break;
          }
        }

        break;
    }
  });

  log.verbose(properties);

  return properties;
};

Riak.prepareHeaders = function (obj) {
  var headers = {};

  if (_.isEmpty(obj)) {
    return headers;
  }

  var links = [];

  _.forEach(obj, function (val, name) {
    switch (name.toLowerCase()) {
      case 'vclock':
        headers['x-riak-vclock'] = val;

        delete obj.vclock;

        break;

      case 'links':
        _.forEach(obj.links, function (link) {
          if (_.isUndefined(link.link)) {
            return;
          }

          if (_.isUndefined(link.tag) || _.isEmpty(link.tag)) {
            links.push('<' + link.link + '>');
          } else {
            links.push('<' + link.link + '>; riaktag="' + link.tag + '"');
          }
        });

        delete obj.links;

        break;

      case 'meta':
        _.forEach(obj.meta, function (val, name) {
          headers['x-riak-meta-' + name] = val;
        });

        delete obj.meta;

        break;

      case 'index':
        _.forEach(obj.index, function (val, name) {
          headers['x-riak-index-' + name] = val;
        });

        delete obj.index;

        break;

      default:
        break;
    }
  });

  if (links.length > 0) {
    headers['link'] = links.join(', ');
  }

  log.verbose(headers);

  return headers;
};

module.exports = Riak;

//
// methods
//

Riak.prototype.getUrl = function (key) {
  return 'http://' + this.host + ':' + this.port + '/buckets/' + this.bucket + '/keys/' + key;
};

Riak.prototype.getSecondaryIndexUrl = function (index, search, options) {
  var url = 'http://' + this.host + ':' + this.port + '/buckets/' + this.bucket + '/index/' + index + '/' + (search.join ? search.join('/') : search);

  if (options && _.isPlainObject(options)) {
    url += '?' + querystring.stringify(options);
  }

  return url;
};

Riak.prototype.mget = function (keys, cb) {
  if (!_.isArray(keys)) {
    cb(new Error('keys must be an array'));
    return;
  }

  async.mapLimit(keys, Riak.ASYNC_LIMIT, function (key, callback) {
    this.get(key, function (err, res, resp) {
      callback(err, {resp: res, rawResp: resp});
    });
  }.bind(this), function (err, results) {
    cb(err, results);
  });
};

Riak.prototype.get = function (key, cb) {
  if (!_.isFunction(cb)) {
    cb = _.noop;
  }

  if (!_.isString(key) || !key) {
    cb(new Error('Invalid key: ' + key));
    return;
  }

  var url = this.getUrl(key);

  log.debug('riak url: GET ' + url);

  client(url, function (err, resp, body) {
    if (err) {
      cb(err);
      return;
    }

    log.debug('riak response code: ' + resp.statusCode);
    log.verbose('riak headers: ' + JSON.stringify(resp.headers));
    log.verbose('riak response: ' + body);

    if (resp.statusCode == 404) {
      // handle not found response
      cb(null, {}, resp);
      return;
    }

    if (resp.statusCode != 200) {
      cb(new Error('riak returned status code: ' + resp.statusCode), null, resp);
      return;
    }

    if (_.isString(body) && resp.headers['content-type'].toLowerCase() == 'application/json') {
      body = JSON.parse(body);
    }

    _.merge(body, Riak.parseHeaders(resp.headers));

    cb(null, body, resp);
  });
};

Riak.prototype.mput = function (puts, cb) {
  if (!_.isArray(puts)) {
    cb(new Error('puts must be an array of put objects'));
    return;
  }

  async.mapLimit(puts, Riak.ASYNC_LIMIT, function (put, callback) {
    if (!_.isPlainObject(put)) {
      callback(new Error('Invalid request object: ' + put));
      return;
    }

    this.put(put.key, put.body, put.headers, function (err, res, resp) {
      callback(err, {resp: res, rawResp: resp});
    });
  }.bind(this), function (err, results) {
    cb(err, results);
  });
};

Riak.prototype.put = function (key, body, headers, cb) {
  if (_.isUndefined(headers)) {
    headers = {};
  }

  if (_.isFunction(headers)) {
    cb = headers;
    headers = {};
  }

  if (!_.isFunction(cb)) {
    cb = _.noop;
  }

  if (!_.isString(key) || !key) {
    cb(new Error('Invalid key: ' + key));
    return;
  }

  // if the body is not a string, we treat it as an object and store with content-type: application/json
  if (!_.isString(body)) {
    headers['content-type'] = 'application/json';

    if (_.isObject(body)) {
      _.merge(headers, Riak.prepareHeaders(body));
    }

    body = JSON.stringify(body);
  }

  if (_.isUndefined(headers['content-type'])) {
    headers['content-type'] = 'text/plain';
  }

  var url = this.getUrl(key);

  log.debug('riak url: PUT ' + url);

  client.put({url: url, body: body, headers: headers, qs: {returnbody: true}}, function (err, resp, body) {
    if (err) {
      cb(err);
      return;
    }

    log.debug('riak response code: ' + resp.statusCode);
    log.verbose('riak headers: ' + JSON.stringify(resp.headers));
    log.verbose('riak response: ' + body);

    if (resp.statusCode != 200) {
      cb(new Error('riak returned status code: ' + resp.statusCode), null, resp);
      return;
    }

    if (_.isString(body) && resp.headers['content-type'].toLowerCase() == 'application/json') {
      body = JSON.parse(body);
    }

    _.merge(body, Riak.parseHeaders(resp.headers));

    cb(null, body, resp);
  });
};

Riak.prototype.mdel = function (keys, cb) {
  if (!_.isArray(keys)) {
    cb(new Error('keys must be an array'));
    return;
  }

  async.mapLimit(keys, Riak.ASYNC_LIMIT, this.del.bind(this), function (err) {
    cb(err);
  });
};

Riak.prototype.del = function (key, cb) {
  if (!_.isFunction(cb)) {
    cb = _.noop;
  }

  if (!_.isString(key) || !key) {
    cb(new Error('Invalid key: ' + key));
    return;
  }

  var url = this.getUrl(key);

  log.debug('riak url: DELETE ' + url);

  client.del(url, function (err, resp) {
    if (err) {
      cb(err);
      return;
    }

    log.debug('riak response code: ' + resp.statusCode);
    log.verbose('riak headers: ' + JSON.stringify(resp.headers));

    if (resp.statusCode == 404) {
      // handle not found response
      cb(null);
      return;
    }

    if (resp.statusCode != 204) {
      cb(new Error('riak returned status code: ' + resp.statusCode));
      return;
    }

    cb(null);
  });
};

Riak.prototype.secondaryIndexSearch = function (index, search, options, cb) {
  if (_.isFunction(options)) {
    cb = options;
    options = undefined;
  }

  if (!_.isFunction(cb)) {
    cb = _.noop;
  }

  if (!_.isString(index) || !index) {
    cb(new Error('Invalid index: ' + index));
    return;
  }

  var url = this.getSecondaryIndexUrl(index, search, options);

  log.debug('riak url: GET ' + url);

  client(url, function (err, resp, body) {
    if (err) {
      cb(err);
      return;
    }

    log.debug('riak response code: ' + resp.statusCode);
    log.verbose('riak headers: ' + JSON.stringify(resp.headers));
    log.verbose('riak response: ' + body);

    if (resp.statusCode == 404) {
      // handle not found response
      cb(null, {}, resp);
      return;
    }

    if (resp.statusCode != 200) {
      cb(new Error('riak returned status code: ' + resp.statusCode), body, resp);
      return;
    }

    if (_.isString(body) && resp.headers['content-type'].toLowerCase() == 'application/json') {
      body = JSON.parse(body);
    }

    cb(null, body, resp);
  });
};<|endoftext|>


<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

importScript("Rest.js");

ElasticSearch=function(esquery){
	this.esquery=esquery;
};

//THE CONTENT FOUND AT https://metrics.mozilla.com/bugzilla-analysis IS ACTUALLY
//A PROXY OF WHAT CAN BE FOUND AT http://people.mozilla.com/~klahnakoski/es
//THIS ALLOWS THE BROWSER TO ACCESS METRIC'S ES DOCUMENT STORE.

//OTHERWISE, YOU WILL REQUIRE VPN ACCESS TO MOZILLA-MPT TO MAKE THESE PAGES WORK
if (window.location.hostname=="metrics.mozilla.com"){
	//FROM Daniel Einspanjer  Oct 20, 2012 (for use on website)
	//FOR ANYONE, BUT ONLY THROUGH METRIC'S SERVERS
	ElasticSearch.baseURL="/bugzilla-analysis-es";
	ElasticSearch.queryURL = "/bugzilla-analysis-es/bugs/_search";
}else{
	//FROM Mark Reid Sept 25, 2012 (for use during coding)
	//ONLY WITH MOZILLA_MPT
//	ElasticSearch.baseURL="http://elasticsearch7.metrics.scl3.mozilla.com:9200";
//	ElasticSearch.queryURL = "http://elasticsearch7.metrics.scl3.mozilla.com:9200/bugs/_search";

	ElasticSearch.pushURL="http://localhost:9200";
//	ElasticSearch.pushURL="http://klahnakoski-es.corp.tor1.mozilla.com:9200";
//	ElasticSearch.pushURL="http://elasticsearch7.metrics.scl3.mozilla.com:9200";

	//THESE ARE NOW ALL GOOD NODES!!
	//(2:13:01 PM) mreid: ekyle, if you've still got things set to only hit elasticsearch7, you should probably change it to know about all 4 nodes
	//(2:13:34 PM) ekyle: what are the numbers?
	//(2:13:34 PM) pires [Paulo@moz-13DD0BFB.static.cpe.netcabo.pt] entered the room.
	//(2:17:56 PM) mreid: ekyle, 4,5,7,8
	//(2:18:16 PM) ekyle: thanks, I will see what I can do to distribute load!

//	ElasticSearch.baseURL="http://elasticsearch4.metrics.scl3.mozilla.com:9200";
//	ElasticSearch.baseURL="http://elasticsearch5.metrics.scl3.mozilla.com:9200";
//	ElasticSearch.baseURL="http://elasticsearch7.metrics.scl3.mozilla.com:9200";
//	ElasticSearch.baseURL="http://elasticsearch8.metrics.scl3.mozilla.com:9200";

//	ElasticSearch.baseURL="http://localhost:9292";
	ElasticSearch.baseURL="http://klahnakoski-es.corp.tor1.mozilla.com:9292";
//	ElasticSearch.baseURL="http://klahnakoski-es.corp.tor1.mozilla.com:9200";

//	ElasticSearch.queryURL = "http://localhost:9292/bugs/_search";
	ElasticSearch.queryURL = "http://klahnakoski-es.corp.tor1.mozilla.com:9292/bugs/_search";
//	ElasticSearch.queryURL = "http://klahnakoski-es.corp.tor1.mozilla.com:9200/bugs/_search";
//	ElasticSearch.queryURL = "http://elasticsearch7.metrics.scl3.mozilla.com:9200/bugs/_search";

}//endif

ElasticSearch.search=function(esquery){
	var output=yield (Rest.post({
		url: window.ElasticSearch.queryURL,
		data: CNV.Object2JSON(esquery),
		dataType: "json"
	}));

	yield (output);
};

//RETURN MAPPINGS FOR GIVEN INDEX AND TYPE
ElasticSearch.getSchema=function(indexName, typeName){
	var URL = ElasticSearch.baseURL + "/" + indexName +"/" + "/_mapping";

	var schema = yield(Rest.get({
		"url":URL
	}));

	yield (schema[indexName][typeName]);
};

ElasticSearch.setRefreshInterval=function(indexName, rate){
	var data=yield (Rest.put({
		"url": ElasticSearch.pushURL+"/"+indexName+"/_settings",
		"data":{"index":{"refresh_interval":"1s"}}
	}));
	Log.note("Refresh Interval to "+rate+": "+CNV.Object2JSON(data));
	yield (data);
};//method

//EXPECTING THE DATA ARRAY TO ALREADY HAVE ODD ENTRIES STARTING WITH { "create" : { "_id" : ID } }
ElasticSearch.bulkInsert=function(indexName, typeName, dataArray){
//	try{
		yield (Rest.post({
			"url":ElasticSearch.pushURL+"/"+indexName+"/"+typeName+"/_bulk",
			"data":dataArray.join("\n")+"\n",
			dataType: "text"
		}));
//	} catch(e){
//		Log.warning("problem with _bulk", e)
//	}//try
};

//ONLY BECAUSE I AM TOO LAZY TO ENHANCE THE ESQuery WITH MORE FACETS (A BATTERY OF FACETS PER SELECT COLUMN)
//RETURN ALL BUGS THAT MATCH FILTER ALONG WITH THE TIME RANGE THEY MATCH
//EXPECTING esfilter
ElasticSearch.getMinMax=function(esfilter){

	//MUST CALL ES TWICE BECAUSE WE CAN ONLY HAVE ONE SELECT COLUMN IF WE HAVE EDGES
	var u1 = yield(ESQuery.run({
		"from":"bugs",
		"select": {"name":"min", "value":"modified_ts", "aggregate":"minimum"},
		"edges":[
			"bug_id"
		],
		"esfilter":esfilter
	}));

	var u2 = yield(ESQuery.run({
		"from":"bugs",
		"select": {"name":"max", "value":"expires_on ", "aggregate":"maximum"},
		"edges":[
			"bug_id"
		],
		"esfilter":esfilter
	}));

	//CONVERT TO DATE VALUES (ALSO CONVERTS HIGH DATE VALUE TO null)
	u1.cube.forall(function(v, i){
		u1.cube[i]=Date.newInstance(v);
		if (u1.cube[i]==null) u1.cube[i]=undefined;
	});
	u2.cube.forall(function(v, i){
		u2.cube[i]=Date.newInstance(v);
		if (u2.cube[i]==null) u2.cube[i]=undefined;		//NULL MEANS UNKNOWN, WHEREAS undefined MEANS NOT DEFINED
	});

	var u = CUBE.merge({"cubes":[
		{"from":u1, "edges":["bug_id"]},
		{"from":u2, "edges":["bug_id"]}
	]});
	yield u;
};//method

////////////////////////////////////////////////////////////////////////////////
// THE REST OF THIS FILE IS DEPRECIATED
////////////////////////////////////////////////////////////////////////////////

ElasticSearch.makeBasicQuery=function(esfilter){
	return {
		"query": {
			"filtered": {
			  "query": {"match_all": {}},
			  "filter": {"and": [esfilter]}
			}
		},
		"from": 0,
		"size": 0,
		"sort": [],
		"facets": {}
	};
};

ElasticSearch.injectFilter=function(esquery, filter){
	if (esquery.query.filtered === undefined){
		var filtered = {};
		filtered.filtered = {};
		filtered.filtered.query = esquery.query;
		filtered.filtered.filter = esquery.filter;

		esquery.query = filtered;
		esquery.filter = undefined;
	}//endif

	var and = esquery.query.filtered.filter.and;
	and.push(filter);
};

var ElasticSearchQuery = function(query, successFunction, errorFunction){
	if (query.success!==undefined){
		if (query.query===undefined)
			Log.error("if passing a parameter object, it must have both query and success attributes");
		this.callbackObject = query;
		this.query = query.query;
	}else{
		if (successFunction===undefined)
			Log.error("expecting an object to report back response");
		this.callbackObject = {"success":successFunction, "error":errorFunction};
		this.query = query;
	}//endif
	this.request = undefined;
};

ElasticSearchQuery.DEBUG=false;

ElasticSearchQuery.Run = function(param){
	var q=new ElasticSearchQuery(
		param.query,
		param.success,
		param.error
	);
	q.Run();
	return q;
};//method

//JUST LIKE RUN, BUT INSTEAD OF SENDING QUERY, EXECUTE success() USING data
//JUST COMMENT-OUT A COUPLE OF LINES TO SWITCH BETWEEN LOCAL AND NETORK TESTING
ElasticSearchQuery.Use = function(data, reportBackObj, id, esQuery){
	reportBackObj.success(data);
};//method

ElasticSearchQuery.prototype.Run = function(){
	if (this.callbackObject.success===undefined) Log.error();
	if (ElasticSearchQuery.DEBUG) Log.note(CNV.Object2JSON(this.query));

	var self = this;
	this.request = $.ajax({
		url: window.ElasticSearch.queryURL,
		type: "POST",
		data: CNV.Object2JSON(this.query),
		dataType: "json",

		success: function(data){
			self.success(data);
		},
		error: function(errorData, errorMsg, errorThrown){self.error(errorData, errorMsg, errorThrown);}
	});
};

ElasticSearchQuery.prototype.success = function(data){
	if (data==null){
		Log.action("Not connected?");
		Log.warning("Maybe you are not connected to Mozilla-MPT?");
		if (data==null && this.callbackObject===undefined) return;	//CAN HAPPEN WHEN REQUEST HAS NOT BEEN SENT, YET HAS BEEN KILLED
		try{
			this.callbackObject.success(data);
		}catch(e){
			Log.warning("Problem calling success()", e);
		}//try
		return;
	}//endif
	if (this.callbackObject===undefined) return;
	if (this.callbackObject.success===undefined) Log.error("ElasticSearchQuery - Can not report back success!!");

	if (data._shards.failed>0){
		Log.warning("Must resend query...");
		var self=this;
		self.timeout=nvl(self.timeout, 1000)*2;
		setTimeout(function(){self.Run();}, self.timeout);
//		this.Run();
		return;
	}//endif

	try{
		this.callbackObject.success(data);
	}catch(e){
		Log.warning("Problem calling success()", e);
	}//try
};

ElasticSearchQuery.prototype.error = function(errorData, errorMsg, errorThrown){
	if (this.callbackObject===undefined) return;
	if (this.callbackObject.error===undefined) Log.error(errorMsg);

	try{
		this.callbackObject.error(this, errorData, errorMsg, errorThrown);
	}catch(e){
		Log.warning("Problem with reporting back error: '"+errorMsg+"'", e);
	}//try
};

ElasticSearchQuery.prototype.kill = function(data){
	this.callbackObject=undefined;
	if (ElasticSearchQuery.DEBUG) Log.note("request killed, callback set to undefined");
	if (this.request != undefined){
		try{
			this.request.abort();
		}catch(e){
			//AT LEAST WE TRIED
		}//try
		this.request = undefined;
	}//endif
};

MultiElasticSearchQuery = function(reportBackObj, chartRequests){
	this.callbackObject = reportBackObj;
	this.chartRequests = chartRequests;

	this.ElasticSearchQueryObjs = [];
	this.results = [];

};

MultiElasticSearchQuery.prototype.Run = function(param){

	for(var i=0;i<this.chartRequests.length;i++){
		var self=this;
		(function(i){
			self.ElasticSearchQueryObjs[i]=ElasticSearchQuery.Run({
				"index":i,
				"query":self.chartRequests[i].esQuery,
				"success":function(data){
	Log.note("Success with index="+i);
					self.results[i] = data;
					if (self.isComplete()){
						self.callbackObject.success(self.results);
					}//endif
				},
				"error":function(errorMsg, errorData, errorThrown){
					self.kill();
					Log.error(errorMsg, errorThrown);
				}
			});
		})(i);
	}
};

MultiElasticSearchQuery.prototype.isComplete = function(){
	if (this.results.length != this.chartRequests.length) return false;

	for(var i = 0; i < this.results.length; i++){
		if (this.results[i] == undefined) return false;
	}
	return true;
};

MultiElasticSearchQuery.prototype.kill = function(){
	for(var i = 0; i < this.ElasticSearchQueryObjs.length; i++){
		if (this.ElasticSearchQueryObjs[i] != undefined){
			this.ElasticSearchQueryObjs[i].kill();
		}
	}

	ElasticSearchQueryObjs = [];

	return true;
};

////////////////////////////////////////////////////////////////////////////////
//OLD VERSION IS BACKWARD WRT CONTROLL FLOW
////////////////////////////////////////////////////////////////////////////////
var OldElasticSearchQuery = function(reportBackObj, id, esQuery){
	var output=new ElasticSearchQuery({
		"query":esQuery,
		"success":reportBackObj.success,
		"error":reportBackObj.error
	});
	output.callbackObject=reportBackObj;
	return output;
};

ElasticSearchQuery.OldRun = function(reportBackObj, id, esQuery){
	var q=OldElasticSearchQuery(reportBackObj, id, esQuery);
	q.Run();
	return q;
};//method

<commit_msg>testing if ETL_Review works<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

importScript("Rest.js");

ElasticSearch=function(esquery){
	this.esquery=esquery;
};

//THE CONTENT FOUND AT https://metrics.mozilla.com/bugzilla-analysis IS ACTUALLY
//A PROXY OF WHAT CAN BE FOUND AT http://people.mozilla.com/~klahnakoski/es
//THIS ALLOWS THE BROWSER TO ACCESS METRIC'S ES DOCUMENT STORE.

//OTHERWISE, YOU WILL REQUIRE VPN ACCESS TO MOZILLA-MPT TO MAKE THESE PAGES WORK
if (window.location.hostname=="metrics.mozilla.com"){
	//FROM Daniel Einspanjer  Oct 20, 2012 (for use on website)
	//FOR ANYONE, BUT ONLY THROUGH METRIC'S SERVERS
	ElasticSearch.baseURL="/bugzilla-analysis-es";
	ElasticSearch.queryURL = "/bugzilla-analysis-es/bugs/_search";
}else{
	//FROM Mark Reid Sept 25, 2012 (for use during coding)
	//ONLY WITH MOZILLA_MPT
//	ElasticSearch.baseURL="http://elasticsearch7.metrics.scl3.mozilla.com:9200";
//	ElasticSearch.queryURL = "http://elasticsearch7.metrics.scl3.mozilla.com:9200/bugs/_search";

	ElasticSearch.pushURL="http://localhost:9200";
//	ElasticSearch.pushURL="http://klahnakoski-es.corp.tor1.mozilla.com:9200";
//	ElasticSearch.pushURL="http://elasticsearch7.metrics.scl3.mozilla.com:9200";

	//THESE ARE NOW ALL GOOD NODES!!
	//(2:13:01 PM) mreid: ekyle, if you've still got things set to only hit elasticsearch7, you should probably change it to know about all 4 nodes
	//(2:13:34 PM) ekyle: what are the numbers?
	//(2:13:34 PM) pires [Paulo@moz-13DD0BFB.static.cpe.netcabo.pt] entered the room.
	//(2:17:56 PM) mreid: ekyle, 4,5,7,8
	//(2:18:16 PM) ekyle: thanks, I will see what I can do to distribute load!

//	ElasticSearch.baseURL="http://elasticsearch4.metrics.scl3.mozilla.com:9200";
//	ElasticSearch.baseURL="http://elasticsearch5.metrics.scl3.mozilla.com:9200";
//	ElasticSearch.baseURL="http://elasticsearch7.metrics.scl3.mozilla.com:9200";
//	ElasticSearch.baseURL="http://elasticsearch8.metrics.scl3.mozilla.com:9200";

//	ElasticSearch.baseURL="http://localhost:9292";
	ElasticSearch.baseURL="http://klahnakoski-es.corp.tor1.mozilla.com:9200";
//	ElasticSearch.baseURL="http://klahnakoski-es.corp.tor1.mozilla.com:9200";

//	ElasticSearch.queryURL = "http://localhost:9292/bugs/_search";
	ElasticSearch.queryURL = "http://klahnakoski-es.corp.tor1.mozilla.com:9200/bugs/_search";
//	ElasticSearch.queryURL = "http://klahnakoski-es.corp.tor1.mozilla.com:9200/bugs/_search";
//	ElasticSearch.queryURL = "http://elasticsearch7.metrics.scl3.mozilla.com:9200/bugs/_search";

}//endif

ElasticSearch.search=function(esquery){
	var output=yield (Rest.post({
		url: window.ElasticSearch.queryURL,
		data: CNV.Object2JSON(esquery),
		dataType: "json"
	}));

	yield (output);
};

//RETURN MAPPINGS FOR GIVEN INDEX AND TYPE
ElasticSearch.getSchema=function(indexName, typeName){
	var URL = ElasticSearch.baseURL + "/" + indexName +"/" + "/_mapping";

	var schema = yield(Rest.get({
		"url":URL
	}));

	yield (schema[indexName][typeName]);
};

ElasticSearch.setRefreshInterval=function(indexName, rate){
	var data=yield (Rest.put({
		"url": ElasticSearch.pushURL+"/"+indexName+"/_settings",
		"data":{"index":{"refresh_interval":"1s"}}
	}));
	Log.note("Refresh Interval to "+rate+": "+CNV.Object2JSON(data));
	yield (data);
};//method

//EXPECTING THE DATA ARRAY TO ALREADY HAVE ODD ENTRIES STARTING WITH { "create" : { "_id" : ID } }
ElasticSearch.bulkInsert=function(indexName, typeName, dataArray){
//	try{
		yield (Rest.post({
			"url":ElasticSearch.pushURL+"/"+indexName+"/"+typeName+"/_bulk",
			"data":dataArray.join("\n")+"\n",
			dataType: "text"
		}));
//	} catch(e){
//		Log.warning("problem with _bulk", e)
//	}//try
};

//ONLY BECAUSE I AM TOO LAZY TO ENHANCE THE ESQuery WITH MORE FACETS (A BATTERY OF FACETS PER SELECT COLUMN)
//RETURN ALL BUGS THAT MATCH FILTER ALONG WITH THE TIME RANGE THEY MATCH
//EXPECTING esfilter
ElasticSearch.getMinMax=function(esfilter){

	//MUST CALL ES TWICE BECAUSE WE CAN ONLY HAVE ONE SELECT COLUMN IF WE HAVE EDGES
	var u1 = yield(ESQuery.run({
		"from":"bugs",
		"select": {"name":"min", "value":"modified_ts", "aggregate":"minimum"},
		"edges":[
			"bug_id"
		],
		"esfilter":esfilter
	}));

	var u2 = yield(ESQuery.run({
		"from":"bugs",
		"select": {"name":"max", "value":"expires_on ", "aggregate":"maximum"},
		"edges":[
			"bug_id"
		],
		"esfilter":esfilter
	}));

	//CONVERT TO DATE VALUES (ALSO CONVERTS HIGH DATE VALUE TO null)
	u1.cube.forall(function(v, i){
		u1.cube[i]=Date.newInstance(v);
		if (u1.cube[i]==null) u1.cube[i]=undefined;
	});
	u2.cube.forall(function(v, i){
		u2.cube[i]=Date.newInstance(v);
		if (u2.cube[i]==null) u2.cube[i]=undefined;		//NULL MEANS UNKNOWN, WHEREAS undefined MEANS NOT DEFINED
	});

	var u = CUBE.merge({"cubes":[
		{"from":u1, "edges":["bug_id"]},
		{"from":u2, "edges":["bug_id"]}
	]});
	yield u;
};//method

////////////////////////////////////////////////////////////////////////////////
// THE REST OF THIS FILE IS DEPRECIATED
////////////////////////////////////////////////////////////////////////////////

ElasticSearch.makeBasicQuery=function(esfilter){
	return {
		"query": {
			"filtered": {
			  "query": {"match_all": {}},
			  "filter": {"and": [esfilter]}
			}
		},
		"from": 0,
		"size": 0,
		"sort": [],
		"facets": {}
	};
};

ElasticSearch.injectFilter=function(esquery, filter){
	if (esquery.query.filtered === undefined){
		var filtered = {};
		filtered.filtered = {};
		filtered.filtered.query = esquery.query;
		filtered.filtered.filter = esquery.filter;

		esquery.query = filtered;
		esquery.filter = undefined;
	}//endif

	var and = esquery.query.filtered.filter.and;
	and.push(filter);
};

var ElasticSearchQuery = function(query, successFunction, errorFunction){
	if (query.success!==undefined){
		if (query.query===undefined)
			Log.error("if passing a parameter object, it must have both query and success attributes");
		this.callbackObject = query;
		this.query = query.query;
	}else{
		if (successFunction===undefined)
			Log.error("expecting an object to report back response");
		this.callbackObject = {"success":successFunction, "error":errorFunction};
		this.query = query;
	}//endif
	this.request = undefined;
};

ElasticSearchQuery.DEBUG=false;

ElasticSearchQuery.Run = function(param){
	var q=new ElasticSearchQuery(
		param.query,
		param.success,
		param.error
	);
	q.Run();
	return q;
};//method

//JUST LIKE RUN, BUT INSTEAD OF SENDING QUERY, EXECUTE success() USING data
//JUST COMMENT-OUT A COUPLE OF LINES TO SWITCH BETWEEN LOCAL AND NETORK TESTING
ElasticSearchQuery.Use = function(data, reportBackObj, id, esQuery){
	reportBackObj.success(data);
};//method

ElasticSearchQuery.prototype.Run = function(){
	if (this.callbackObject.success===undefined) Log.error();
	if (ElasticSearchQuery.DEBUG) Log.note(CNV.Object2JSON(this.query));

	var self = this;
	this.request = $.ajax({
		url: window.ElasticSearch.queryURL,
		type: "POST",
		data: CNV.Object2JSON(this.query),
		dataType: "json",

		success: function(data){
			self.success(data);
		},
		error: function(errorData, errorMsg, errorThrown){self.error(errorData, errorMsg, errorThrown);}
	});
};

ElasticSearchQuery.prototype.success = function(data){
	if (data==null){
		Log.action("Not connected?");
		Log.warning("Maybe you are not connected to Mozilla-MPT?");
		if (data==null && this.callbackObject===undefined) return;	//CAN HAPPEN WHEN REQUEST HAS NOT BEEN SENT, YET HAS BEEN KILLED
		try{
			this.callbackObject.success(data);
		}catch(e){
			Log.warning("Problem calling success()", e);
		}//try
		return;
	}//endif
	if (this.callbackObject===undefined) return;
	if (this.callbackObject.success===undefined) Log.error("ElasticSearchQuery - Can not report back success!!");

	if (data._shards.failed>0){
		Log.warning("Must resend query...");
		var self=this;
		self.timeout=nvl(self.timeout, 1000)*2;
		setTimeout(function(){self.Run();}, self.timeout);
//		this.Run();
		return;
	}//endif

	try{
		this.callbackObject.success(data);
	}catch(e){
		Log.warning("Problem calling success()", e);
	}//try
};

ElasticSearchQuery.prototype.error = function(errorData, errorMsg, errorThrown){
	if (this.callbackObject===undefined) return;
	if (this.callbackObject.error===undefined) Log.error(errorMsg);

	try{
		this.callbackObject.error(this, errorData, errorMsg, errorThrown);
	}catch(e){
		Log.warning("Problem with reporting back error: '"+errorMsg+"'", e);
	}//try
};

ElasticSearchQuery.prototype.kill = function(data){
	this.callbackObject=undefined;
	if (ElasticSearchQuery.DEBUG) Log.note("request killed, callback set to undefined");
	if (this.request != undefined){
		try{
			this.request.abort();
		}catch(e){
			//AT LEAST WE TRIED
		}//try
		this.request = undefined;
	}//endif
};

MultiElasticSearchQuery = function(reportBackObj, chartRequests){
	this.callbackObject = reportBackObj;
	this.chartRequests = chartRequests;

	this.ElasticSearchQueryObjs = [];
	this.results = [];

};

MultiElasticSearchQuery.prototype.Run = function(param){

	for(var i=0;i<this.chartRequests.length;i++){
		var self=this;
		(function(i){
			self.ElasticSearchQueryObjs[i]=ElasticSearchQuery.Run({
				"index":i,
				"query":self.chartRequests[i].esQuery,
				"success":function(data){
	Log.note("Success with index="+i);
					self.results[i] = data;
					if (self.isComplete()){
						self.callbackObject.success(self.results);
					}//endif
				},
				"error":function(errorMsg, errorData, errorThrown){
					self.kill();
					Log.error(errorMsg, errorThrown);
				}
			});
		})(i);
	}
};

MultiElasticSearchQuery.prototype.isComplete = function(){
	if (this.results.length != this.chartRequests.length) return false;

	for(var i = 0; i < this.results.length; i++){
		if (this.results[i] == undefined) return false;
	}
	return true;
};

MultiElasticSearchQuery.prototype.kill = function(){
	for(var i = 0; i < this.ElasticSearchQueryObjs.length; i++){
		if (this.ElasticSearchQueryObjs[i] != undefined){
			this.ElasticSearchQueryObjs[i].kill();
		}
	}

	ElasticSearchQueryObjs = [];

	return true;
};

////////////////////////////////////////////////////////////////////////////////
//OLD VERSION IS BACKWARD WRT CONTROLL FLOW
////////////////////////////////////////////////////////////////////////////////
var OldElasticSearchQuery = function(reportBackObj, id, esQuery){
	var output=new ElasticSearchQuery({
		"query":esQuery,
		"success":reportBackObj.success,
		"error":reportBackObj.error
	});
	output.callbackObject=reportBackObj;
	return output;
};

ElasticSearchQuery.OldRun = function(reportBackObj, id, esQuery){
	var q=OldElasticSearchQuery(reportBackObj, id, esQuery);
	q.Run();
	return q;
};//method

<|endoftext|>


<commit_before>var util = require("util");
var EventEmitter = require("events").EventEmitter;

var MAX_DJS = 5;

function Room(buoy, name) {
    this.buoy = buoy;
    this.name = name;
    this.peers = [];
    this.djs = [];
    this.activeDJ = -1; // Val is an index in this.djs
    this.activeTrack = null;

    console.log("[debug] Creating new room "+ name);
}

util.inherits(Room, EventEmitter);

/*
 * Peer object serialization
 */
function peerToIdName(peer) {
    return {
        id: peer.id,
        name: peer.name,
        gravatar: peer.gravatar
    };
}

function peerToId(peer) {
    return peer.id;
}

/*
 * Adds a peer to the room
 */
Room.prototype.join = function(peer) {
    this.peers.push(peer);

    this.sendAllBut(peer, "peerJoined", peerToIdName(peer));

    peer.send("roomData", {
        name: this.name,
        peers: this.peers.map(peerToIdName),
        djs: this.djs.map(peerToId),
        activeDJ: this.activeDJ,
        activeTrack: this.activeTrack
    });
};

/*
 * Removes a peer from the room
 */
Room.prototype.leave = function(peer) {
    var i = this.peers.indexOf(peer);
    this.peers.splice(i, 1);

    i = this.djs.indexOf(peer);
    if (i > -1) {
        this.djs.splice(i, 1);
    }

    console.log("[debug] "+ peer.name +" left "+ this.name);

    // If the last peer left, delete the room
    if(this.peers.length == 0) {
        this.buoy.deleteRoom(this.name);
        return;
    }

    this.sendAllBut(peer, "peerLeft", {
        id: peer.id
    });
}

/*
 * Sends out a chat to all users
 */
Room.prototype.sendChat = function(from, message) {
    this.sendAllBut(from, "chat", { msg: message, from: from.id });
}

/*
 * Sends a message to all peers in the room
 */
Room.prototype.sendAll = function(event, data) {
    for(var i = 0; i < this.peers.length; i++) {
        this.peers[i].send(event, data);
    }
}

/*
 * Sends a message to all peers except for the given ID
 */
Room.prototype.sendAllBut = function(but, event, data) {
    for(var i = 0; i < this.peers.length; i++) {
        if(this.peers[i] == but) continue;
        this.peers[i].send(event, data);
    }
}

/*
 * Adds a peer to the DJ list
 */
Room.prototype.addDJ = function(peer) {
    if (this.djs.indexOf(peer) != -1) return;

    if(this.djs.length >= MAX_DJS) {
        return false;
    }

    this.djs.push(peer);

    // Notify peers
    this.sendAll("newDJ", {
        id: peer.id
    });

    if(this.djs.length == 1) {
        this.setActiveDJ(peer);
    }
};

/*
 * Removes a user from the DJ list
 */
Room.prototype.removeDJ = function(peer) {
    var i = this.djs.indexOf(peer);
    if (i == -1) return;
    this.djs.splice(i, 1);

    // Notify peers
    this.sendAll("removeDJ", {
        id: peer.id
    });

    if(this.activeDJ == i) {
        this.skip();
    }
};

/*
 * Sets the given peer to the active DJ of the room
 */
Room.prototype.setActiveDJ = function(peer) {
    var i = this.djs.indexOf(peer);
    if(i == -1) {
        this.sendAll("setActiveDJ", { peer: null });
        return;
    }

    this.activeDJ = i;
    this.sendAll("setActiveDJ", {
        peer: peer.id,
    });
};

/*
 * Skip the active DJ and their track
 */
Room.prototype.skip = function() {
    var nextDJ = this.djs[this.activeDJ + 1] || this.djs[0];
    this.setActiveDJ(nextDJ);
    this.setActiveTrack(null);
};

/*
 * Get the current DJ of the room
 */
Room.prototype.getActiveDJ = function() {
    return this.djs[this.activeDJ];
};

/*
 * Sets the active track of the room
 */
Room.prototype.setActiveTrack = function(track) {
    this.activeTrack = track;
    this.sendAll("setActiveTrack", {
        track: track
    });

    // Reset user votes
    this.peers.forEach(function(peer) {
        peer.vote = 0;
    });
};

exports.Room = Room;
<commit_msg>When a DJ leaves the room, they must no longer DJ.<commit_after>var util = require("util");
var EventEmitter = require("events").EventEmitter;

var MAX_DJS = 5;

function Room(buoy, name) {
    this.buoy = buoy;
    this.name = name;
    this.peers = [];
    this.djs = [];
    this.activeDJ = -1; // Val is an index in this.djs
    this.activeTrack = null;

    console.log("[debug] Creating new room "+ name);
}

util.inherits(Room, EventEmitter);

/*
 * Peer object serialization
 */
function peerToIdName(peer) {
    return {
        id: peer.id,
        name: peer.name,
        gravatar: peer.gravatar
    };
}

function peerToId(peer) {
    return peer.id;
}

/*
 * Adds a peer to the room
 */
Room.prototype.join = function(peer) {
    this.peers.push(peer);

    this.sendAllBut(peer, "peerJoined", peerToIdName(peer));

    peer.send("roomData", {
        name: this.name,
        peers: this.peers.map(peerToIdName),
        djs: this.djs.map(peerToId),
        activeDJ: this.activeDJ,
        activeTrack: this.activeTrack
    });
};

/*
 * Removes a peer from the room
 */
Room.prototype.leave = function(peer) {
    var i = this.peers.indexOf(peer);
    this.peers.splice(i, 1);

    console.log("[debug] "+ peer.name +" left "+ this.name);

    this.removeDJ(peer);

    // If the last peer left, delete the room
    if(this.peers.length == 0) {
        this.buoy.deleteRoom(this.name);
        return;
    }

    this.sendAllBut(peer, "peerLeft", {
        id: peer.id
    });
}

/*
 * Sends out a chat to all users
 */
Room.prototype.sendChat = function(from, message) {
    this.sendAllBut(from, "chat", { msg: message, from: from.id });
}

/*
 * Sends a message to all peers in the room
 */
Room.prototype.sendAll = function(event, data) {
    for(var i = 0; i < this.peers.length; i++) {
        this.peers[i].send(event, data);
    }
}

/*
 * Sends a message to all peers except for the given ID
 */
Room.prototype.sendAllBut = function(but, event, data) {
    for(var i = 0; i < this.peers.length; i++) {
        if(this.peers[i] == but) continue;
        this.peers[i].send(event, data);
    }
}

/*
 * Adds a peer to the DJ list
 */
Room.prototype.addDJ = function(peer) {
    if (this.djs.indexOf(peer) != -1) return;

    if(this.djs.length >= MAX_DJS) {
        return false;
    }

    this.djs.push(peer);

    // Notify peers
    this.sendAll("newDJ", {
        id: peer.id
    });

    if(this.djs.length == 1) {
        this.setActiveDJ(peer);
    }
};

/*
 * Removes a user from the DJ list
 */
Room.prototype.removeDJ = function(peer) {
    var i = this.djs.indexOf(peer);
    if (i == -1) return;
    this.djs.splice(i, 1);

    // Notify peers
    this.sendAll("removeDJ", {
        id: peer.id
    });

    if(this.activeDJ == i) {
        this.skip();
    }
};

/*
 * Sets the given peer to the active DJ of the room
 */
Room.prototype.setActiveDJ = function(peer) {
    var i = this.djs.indexOf(peer);
    if(i == -1) {
        this.sendAll("setActiveDJ", { peer: null });
        return;
    }

    this.activeDJ = i;
    this.sendAll("setActiveDJ", {
        peer: peer.id,
    });
};

/*
 * Skip the active DJ and their track
 */
Room.prototype.skip = function() {
    var nextDJ = this.djs[this.activeDJ + 1] || this.djs[0];
    this.setActiveDJ(nextDJ);
    this.setActiveTrack(null);
};

/*
 * Get the current DJ of the room
 */
Room.prototype.getActiveDJ = function() {
    return this.djs[this.activeDJ];
};

/*
 * Sets the active track of the room
 */
Room.prototype.setActiveTrack = function(track) {
    this.activeTrack = track;
    this.sendAll("setActiveTrack", {
        track: track
    });

    // Reset user votes
    this.peers.forEach(function(peer) {
        peer.vote = 0;
    });
};

exports.Room = Room;
<|endoftext|>


<commit_before>(function ($) {

var loading = false;

function resolveRelativeLink(base, link) {
    if (!(link.match("^(/|http)") !== null)) {
        // link is relative...
        var base_parts = base.split("/");
        base_parts.pop();
        var link_parts = link.split("/");
        var has_base = (base_parts.length > 0);

        for (var i=0; i<link_parts.length; i++) {
            var lp = link_parts[i];
            if (lp == "..") {
                if (has_base) {
                    base_parts.pop();
                    has_base = (base_parts.length > 0);
                } else {
                    base_parts.push("..");
                }
            } else {
                base_parts.push(link_parts[i]);
            }
        }
        ret = base_parts.join("/");
        // $.log("resolveRelativeLink", base, link, ret);
        return ret;
    }
}

$(document).bind("refresh", function (evt) {
    // console.log("refreshing browser links...");
    var context = evt.target;
    $("a[target='browser']", context).click(function () {
        loadbrowserpage($(this).attr("href"));
        return false;
    });
});

function loadbrowserpage (url, targetsel, expandWhenLoaded, success_callback) {
    $("iframe#browser-panel").attr('src', url);
    $("div#tab-this").tabs("select" , "#tab-browse");
    //$("body").layout().open("south");
    //targetsel = targetsel || "#browser";
    //if (expandWhenLoaded === undefined) expandWhenLoaded = true;
    //loading = true;
    //$(targetsel).addClass('loading');
    //// var mitem = menuLinksByURL[url];
    //// $.log("setActive", mitem, url);
    //// setActiveMenuLink(mitem);

    //$(targetsel + " .minipage").load(url+" #minipage", function () {
        //loading = false;
        //$(targetsel).removeClass('loading');
        //window.setTimeout(function () { $(targetsel).scrollTop(0); }, 250);

        //// load for any onload code
        //$(targetsel + " .minipage .minipage_onload").each(function () {
            //var text = $(this).text();
            //// console.log("minipage.onload", text);
            //eval(text);
        //});

        //if (expandWhenLoaded) { $("body").layout().open("south");  }// expand(targetsel);
        //if (success_callback) { success_callback(); }

        //// retarget links
        //$(targetsel+" .minipage a").not("a.directlink").click(function () {
            //loadbrowserpage($(this).attr("href"));
            //return false;
        //});

        //// Fire a refresh at the browser content!
        //$(targetsel).trigger("refresh");

        //// resolve (relative) links
        //[>
        //$(targetsel+" .minipage *[href]").each(function () {
            //$(this).attr("href", resolveRelativeLink(url, $(this).attr("href")));
        //});
        //$(targetsel+" .minipage *[src]").each(function () {
            //$(this).attr("src", resolveRelativeLink(url, $(this).attr("src")));
        //});
        //*/

    //});
}

})(jQuery);
<commit_msg>Opens the side pane on browse<commit_after>(function ($) {

var loading = false;

function resolveRelativeLink(base, link) {
    if (!(link.match("^(/|http)") !== null)) {
        // link is relative...
        var base_parts = base.split("/");
        base_parts.pop();
        var link_parts = link.split("/");
        var has_base = (base_parts.length > 0);

        for (var i=0; i<link_parts.length; i++) {
            var lp = link_parts[i];
            if (lp == "..") {
                if (has_base) {
                    base_parts.pop();
                    has_base = (base_parts.length > 0);
                } else {
                    base_parts.push("..");
                }
            } else {
                base_parts.push(link_parts[i]);
            }
        }
        ret = base_parts.join("/");
        // $.log("resolveRelativeLink", base, link, ret);
        return ret;
    }
}

$(document).bind("refresh", function (evt) {
    // console.log("refreshing browser links...");
    var context = evt.target;
    $("a[target='browser']", context).click(function () {
        loadbrowserpage($(this).attr("href"));
        return false;
    });
});

function loadbrowserpage (url, targetsel, expandWhenLoaded, success_callback) {
    $("iframe#browser-panel").attr('src', url);
    $("div#tab-this").tabs("select" , "#tab-browse");
    $("body").layout().open("west");
    //targetsel = targetsel || "#browser";
    //if (expandWhenLoaded === undefined) expandWhenLoaded = true;
    //loading = true;
    //$(targetsel).addClass('loading');
    //// var mitem = menuLinksByURL[url];
    //// $.log("setActive", mitem, url);
    //// setActiveMenuLink(mitem);

    //$(targetsel + " .minipage").load(url+" #minipage", function () {
        //loading = false;
        //$(targetsel).removeClass('loading');
        //window.setTimeout(function () { $(targetsel).scrollTop(0); }, 250);

        //// load for any onload code
        //$(targetsel + " .minipage .minipage_onload").each(function () {
            //var text = $(this).text();
            //// console.log("minipage.onload", text);
            //eval(text);
        //});

        //if (expandWhenLoaded) { $("body").layout().open("south");  }// expand(targetsel);
        //if (success_callback) { success_callback(); }

        //// retarget links
        //$(targetsel+" .minipage a").not("a.directlink").click(function () {
            //loadbrowserpage($(this).attr("href"));
            //return false;
        //});

        //// Fire a refresh at the browser content!
        //$(targetsel).trigger("refresh");

        //// resolve (relative) links
        //[>
        //$(targetsel+" .minipage *[href]").each(function () {
            //$(this).attr("href", resolveRelativeLink(url, $(this).attr("href")));
        //});
        //$(targetsel+" .minipage *[src]").each(function () {
            //$(this).attr("src", resolveRelativeLink(url, $(this).attr("src")));
        //});
        //*/

    //});
}

})(jQuery);
<|endoftext|>


<commit_before>/**
 * Uruguayan spanish translation for bootstrap-wysihtml5
 */
(function($){
    $.fn.wysihtml5.locale["es-ES"] = {
        font_styles: {
              normal: "Texto normal",
              h1: "Título 1",
              h2: "Título 2",
              h3: "Título 3"
        },
        emphasis: {
              bold: "Negrita",
              italic: "Itálica",
              underline: "Subrayado"
        },
        lists: {
              unordered: "Lista desordenada",
              ordered: "Lista ordenada",
              outdent: "Eliminar sangría",
              indent: "Agregar sangría"
        },
        link: {
              insert: "Insertar enlace",
              cancel: "Cancelar"
        },
        image: {
              insert: "Insertar imágen",
              cancel: "Cancelar"
        },
        html: {
            edit: "Editar HTML"
        },
        colours: {
          black: "Negro",
          silver: "Plata",
          gray: "Gris",
          maroon: "Marrón",
          red: "Rojo",
          purple: "Púrpura",
          green: "Verde",
          olive: "Oliva",
          navy: "Azul Marino",
          blue: "Azul",
          orange: "Naranja"
        }
    };
}(jQuery));
<commit_msg>Fixed es-ES locale<commit_after>/**
 * Uruguayan spanish translation for bootstrap-wysihtml5
 */
(function($){
    $.fn.wysihtml5.locale["es-ES"] = {
        font_styles: {
              normal: "Texto normal",
              h1: "Título 1",
              h2: "Título 2",
              h3: "Título 3"
        },
        emphasis: {
              bold: "Negrita",
              italic: "Itálica",
              underline: "Subrayado"
        },
        lists: {
              unordered: "Lista desordenada",
              ordered: "Lista ordenada",
              outdent: "Eliminar sangría",
              indent: "Agregar sangría"
        },
        link: {
              insert: "Insertar enlace",
              cancel: "Cancelar",
              target: "Abrir enlace en una nueva ventana"
        },
        image: {
              insert: "Insertar imágen",
              cancel: "Cancelar"
        },
        html: {
            edit: "Editar HTML"
        },
        colours: {
          black: "Negro",
          silver: "Plata",
          gray: "Gris",
          maroon: "Marrón",
          red: "Rojo",
          purple: "Púrpura",
          green: "Verde",
          olive: "Oliva",
          navy: "Azul Marino",
          blue: "Azul",
          orange: "Naranja"
        }
    };
}(jQuery));
<|endoftext|>


<commit_before>import Ember from 'ember';

export default Ember.Component.extend({
  classNameBindings: [
    "isCollapsed:collapsed:",
    "top:collapsible-panel--top",
    "right:collapsible-panel--right",
    "bottom:collapsible-panel--bottom",
    "left:collapsible-panel--left",
    "center:collapsible-panel--center"
  ],
  classNames: "collapsible-panel-container",

  actions: {
    collapsePanel(){
      this.set('isCollapsed', true);

      let layout_el = this.$(".collapsible-panel-container").closest("collapsible-layout");
      layout_el.addClass(`${this.get("region")}-collapsed`);

      this.$(".collapsible-panel--center", layout_el).css(this.get("region"), 0);

      this.sendAction('collapsePanel');
    },
    expandPanel(){
      this.set('isCollapsed', false);

      let layout_el = this.$(".collapsible-panel-container").closest("collapsible-layout");
      layout_el.removeClass(`${this.get("region")}-collapsed`);

      this.$(".collapsible-panel--center", layout_el).css(this.get("region"), this.get("sizeValue"));

      this.sendAction('expandPanel');
    }
  },

  init(){
    this._super(...arguments);

    let config = this.get("config");
    this.set(config.region, true);
    this.set("region", config.region);

    let height = config.height || 0;
    let width = config.width || 0;

    if(config.region == "top" || config.region == "bottom")
      this.set("sizeValue", `${height}px`);
    else
      this.set("sizeValue", `${width}px`);
  }
});
<commit_msg>fix jquery issues<commit_after>import Ember from 'ember';

export default Ember.Component.extend({
  classNameBindings: [
    "isCollapsed:collapsed:",
    "top:collapsible-panel--top",
    "right:collapsible-panel--right",
    "bottom:collapsible-panel--bottom",
    "left:collapsible-panel--left",
    "center:collapsible-panel--center"
  ],
  classNames: "collapsible-panel-container",

  actions: {
    collapsePanel(){
      this.set('isCollapsed', true);
      this.updateLayout();
      this.sendAction('collapsePanel');
    },
    expandPanel(){
      this.set('isCollapsed', false);
      this.updateLayout();
      this.sendAction('expandPanel');
    }
  },

  updateLayout(){
    let layout_el = this.$().closest(".collapsible-layout");
    let position_value = 0;

    if(this.get('isCollapsed')){
      layout_el.addClass(`${this.get("region")}-collapsed`);
    }
    else{
      layout_el.removeClass(`${this.get("region")}-collapsed`);
      position_value = this.get("sizeValue");
    }

    if(this.get("region") == "top" || this.get("region") == "bottom"){
      $(".collapsible-panel--left .collapsible-panel, .collapsible-panel--right .collapsible-panel", layout_el).css(this.get("region"), position_value);
    }

    $(".collapsible-panel--center .collapsible-panel", layout_el).css(this.get("region"), position_value);
  },

  init(){
    this._super(...arguments);

    let config = this.get("config");
    this.set(config.region, true);
    this.set("region", config.region);

    let height = config.height || 0;
    let width = config.width || 0;

    if(config.region == "top" || config.region == "bottom")
      this.set("sizeValue", `${height}px`);
    else
      this.set("sizeValue", `${width}px`);
  }
});
<|endoftext|>


<commit_before>/**
 * Brazilian portuguese translation for bootstrap-wysihtml5
 */
(function($){
    $.fn.wysihtml5.locale["pt-BR"] = {
        font_styles: {
            normal: "Texto normal",
            h1: "Título 1",
            h2: "Título 2",
            h3: "Título 3"
        },
        emphasis: {
            bold: "Negrito",
            italic: "Itálico",
            underline: "Sublinhado"
        },
        lists: {
            unordered: "Lista",
            ordered: "Lista numerada",
            outdent: "Remover indentação",
            indent: "Indentar"
        },
        link: {
            insert: "Inserir link",
            cancel: "Cancelar"
        },
        image: {
            insert: "Inserir imagem",
            cancel: "Cancelar"
        },
        html: {
            edit: "Editar HTML"
        },
        colours: {
            black: "Preto",
            silver: "Prata",
            gray: "Cinza",
            maroon: "Marrom",
            red: "Vermelho",
            purple: "Roxo",
            green: "Verde",
            olive: "Oliva",
            navy: "Marinho",
            blue: "Azul",
            orange: "Laranja"
        }
    };
}(jQuery));<commit_msg>Updated brazilian portuguese translation<commit_after>/**
 * Brazilian portuguese translation for bootstrap-wysihtml5
 */
(function($){
    $.fn.wysihtml5.locale["pt-BR"] = {
        font_styles: {
            normal: "Texto normal",
            h1: "Título 1",
            h2: "Título 2",
            h3: "Título 3",
            h4: "Título 4",
            h5: "Título 5",
            h6: "Título 6"
        },
        emphasis: {
            bold: "Negrito",
            italic: "Itálico",
            underline: "Sublinhado"
        },
        lists: {
            unordered: "Lista",
            ordered: "Lista numerada",
            outdent: "Remover indentação",
            indent: "Indentar"
        },
        link: {
            insert: "Inserir link",
            cancel: "Cancelar",
            target: "Abrir link em um nova janela"
        },
        image: {
            insert: "Inserir imagem",
            cancel: "Cancelar"
        },
        html: {
            edit: "Editar HTML"
        },
        colours: {
            black: "Preto",
            silver: "Prata",
            gray: "Cinza",
            maroon: "Marrom",
            red: "Vermelho",
            purple: "Roxo",
            green: "Verde",
            olive: "Oliva",
            navy: "Marinho",
            blue: "Azul",
            orange: "Laranja"
        }
    };
}(jQuery));<|endoftext|>