text:
env.modules.AddBuyback10And20 = function () {
  var self = this;
  this.state = 0;
  this.interval = 800;
  this.interval_id = null;
  this.next_func = null;
  this.tries = 0;
  this.run = function (start_url) {
    if (start_url != "") {
      self.view.load(start_url);
    }
    self.interval_id = setInterval(self.event_loop,self.interval);
    return self;
  } // end run
  this.next = function (next_func) {
    self.next_func = next_func;
  }

  this.event_loop = function () {
    print("Add10and20Beginning. State: " + self.state + "\n");
    switch(self.state) {
      /////////////////////////////////////////////
      //  Verify that we are at the POS screen
      ////////////////////////////////////////////
      case 0:
        var input = self.view.getElement("#keyboard_input");
        if (input.isVisible == true) {
          // excellent, we are at the pos screen
          self.state++;
        }
        break;
      /////////////////////////////////////////////
      //  Add an item of 10
      ////////////////////////////////////////////
      case 1:
        self.tries = 0;
        var input = self.view.getElement("#keyboard_input");
        self.view.fill(input,"10.00");
        sendKey(self.view,"Enter");
        self.state++;
        self.tries = 0;
        break;
      case 2:
        var input = self.view.getElement("#keyboard_input");
        self.view.fill(input,"20.00");
        sendKey(self.view,"Enter");
        self.state++;
      break;
      case 3:
        self.state++;
      break;
      // Edit the first item
      case 4:
        var items = self.view.getElements(".pos-item-name");
        var first_item = items["1"];
        if (first_item.isVisible == true) {
          self.view.mouseDown(first_item);
          self.state++;
          self.tries = 0;
        } else {
          self.tries++;
          if (self.tries > 4) {
            fatal("Item never appeared");
          }
        }
      break;
      case 5:
        if (self.view.ready() == true) {
          var item_menu = self.view.getElement("#order_item_edit_name");
          if (item_menu.isVisible == true) {
            var button = self.view.getElement("#item_menu_buyback");
            self.view.click(button);
            var button = self.view.getElement("#item_menu_done");
            self.view.click(button);
            self.tries = 0;
            self.state++;
          } else {
            self.tries++;
            if (self.tries > 4) {
              fatal("item menu div never showed up");
            }
          }
        }
      break;
      case 6:
        if (self.view.ready() == true) {
          var items = self.view.getElements(".pos-item-price");
          var first_item = items["1"];
          if (first_item.isVisible) {
            self.tries = 0;
            if ( self.view.getContentOfElement(first_item.id).indexOf("0.00") == -1) {
              fatal("Item was not changed to buyback");
            } else {
              self.view.click(first_item);
              self.state++;
            }
          } else {
            self.tries++;
            if (self.tries > 4) {
              fatal("couldn't grab pos-item-price");
            }
          }
        }
      break;
      case 7:
         var kbd = self.view.getElement(".ui-keyboard");
         if (kbd.isVisible == false) {
            if (self.tries > 4) {
              fatal("keyboard never showed up");
            } else {
              self.tries++;
            }
         } else {
          self.state++;
         }
         break;
      case 8:
        self.view.executeJS("$(\"input[name='key_2_0']\").trigger('mousedown');");
        self.view.executeJS("$(\"input[name='key_accept']\").trigger('mousedown');");
        self.state++;
      break;
      // Edit the second item
      case 9:
        var items = self.view.getElements(".pos-item-name");
        var first_item = items["0"];
        if (first_item.isVisible == true) {
          print(dump(first_item));
          self.view.mouseDown(first_item);
          self.state++;
          self.tries = 0;
        } else {
          self.tries++;
          if (self.tries > 4) {
            fatal("Item never appeared");
          }
        }
      break;
      case 10:
        if (self.view.ready() == true) {
          var item_menu = self.view.getElement("#order_item_edit_name");
          if (item_menu.isVisible == true) {
            var button = self.view.getElement("#item_menu_buyback");
            self.view.click(button);
            var button = self.view.getElement("#item_menu_done");
            self.view.click(button);
            self.tries = 0;
            self.state++;
          } else {
            self.tries++;
            if (self.tries > 4) {
              fatal("item menu div never showed up");
            }
          }
        }
      break;
      case 11:
        if (self.view.ready() == true) {
          var items = self.view.getElements(".pos-item-price");
          var first_item = items["0"];
          if (first_item.isVisible) {
            self.tries = 0;
            if ( self.view.getContentOfElement(first_item.id).indexOf("0.00") == -1) {
              fatal("Item was not changed to buyback");
            } else {
              self.view.click(first_item);
              self.state++;
            }
          } else {
            self.tries++;
            if (self.tries > 4) {
              fatal("couldn't grab pos-item-price");
            }
          }
        }
      break;
      case 12:
         var kbd = self.view.getElement(".ui-keyboard");
         if (kbd.isVisible == false) {
            if (self.tries > 4) {
              fatal("keyboard never showed up");
            } else {
              self.tries++;
            }
         } else {
          self.state++;
         }
         break;
      case 13:
        self.view.executeJS("$(\"input[name='key_2_1']\").trigger('mousedown');");
        self.view.executeJS("$(\"input[name='key_accept']\").trigger('mousedown');");
        self.state++;
      break;
      // continue on

      case 14:
        var complete_button = self.view.getElement("#print_receipt_button");
        self.view.click(complete_button);
        self.state++;
      break;
      case 15:
        var complete_order_popup = self.view.getElement("#complete_order");
        if (complete_order_popup.isVisible == true) {
          var total = self.view.getContentOfElement("#complete_order_total");
          var change = self.view.getContentOfElement("#complete_order_change");
          if (total.indexOf("-3.00") == -1) {
            fail("Order Total should be -3.00");
          } else if (change.indexOf("3.00") == -1) {
            fail("Change should be 3.00 at case 13");
          }
          var button = self.view.getElement("#confirm_complete_order_button");
          self.view.click(button);
          self.state++;
        } else {
          print("Waiting for complete order popup");
        }
        break;
      case 16:
        if (self.view.ready() == true) {
          self.state++; //just waiting a bit
        }
      case 17:
        var drawer_amount = self.view.getContentOfElement("#header_drawer_amount");
        print("Drawer amount is: " + drawer_amount);
        if (drawer_amount.indexOf("156.00") == -1) {
          // It may take some time for the element to update...
          if (self.tries < 3) {
            self.tries++;
          } else {
            fatal("Add 2 items of buyback item failed or cash drawer failed to update");
          }
        } else {
          var button = self.view.getElement("#cancel_complete_order_button");
          self.view.click(button);
          self.state++;
        }
        break;

      default:
        clearInterval(self.interval_id);
        if (self.next_func) {
          setTimeout(self.next_func,100);
        }
        break;
    } // end switch self.state
  } // end event_loop
}


text:
from ez_setup import use_setuptools
use_setuptools()

import os
from setuptools import setup

README = open(os.path.join(os.path.dirname(__file__), 'README.txt')).read()

# Allow setup.py to be run from any path
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))

setup(
    name='Django-PostBox',
    version='0.1',
    packages=['PostBox'],
    install_requires = [
        'Django == 1.5.1',
        'MySQL-python == 1.2.3',
        ],
    dependency_links = [
        'thirdparty',
        ],
    include_package_data=True,
    license='BSD License',
    description='A simple Django app to share feedback within a team.',
    long_description=README,
    author='Antony M S J',
    author_email='antony_sakkariaz@dell.com',
    classifiers=[
        'Environment :: Web Environment',
        'Framework :: Django',
        'Intended Audience :: Team Members',
        'License :: OSI Approved :: BSD License',
        'Operating System :: OS Independent',
        'Programming Language :: Python',
        'Programming Language :: Python :: 3.3',
        'Topic :: Internet :: WWW/HTTP',
        'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
        ],
    )

redpajama_set_name: RedPajamaGithub


text:
using UnityEngine;
using System.Collections;

public class StampSpace : MonoBehaviour {
	private int ghostCount = 0;

	public bool IsWall { get; private set; }

	public bool Occupied { get; private set; }
	public bool Ghosted { get { return ghostCount > 0; } }

	public Color defaultColor = Color.white;

	private SpriteRenderer _spriteRenderer;
	private SpriteRenderer spriteRenderer {
		get {
			if (_spriteRenderer == null)
				_spriteRenderer = GetComponent<SpriteRenderer> ();
			return _spriteRenderer;
		}
	}

	public StampPlayer Owner { get; private set; }

	public void UpdateColor() {
		Color toColor;
		if (IsWall)
			toColor = Color.black;
		else if (Occupied && Owner != null && Owner.Highlight)
			toColor = Color.gray;
		else
			toColor = defaultColor;

		if (Ghosted && !Occupied)
			toColor.a = .3f;

		spriteRenderer.color = toColor;
	}

	public void SetOccupyingPlayer(StampPlayer player) {
		Occupied = player != null;
		if (Occupied && Owner == null) {
			Owner = player;
			defaultColor = player.playerColor;
			StampManager.SpaceStamped ();
		}
		UpdateColor ();
	}

	public void SetGhost(bool ghostOn) {
		ghostCount = Mathf.Clamp(ghostCount + (ghostOn ? 1 : -1), 0, 4);
		UpdateColor ();
	}

    public void InvokeWall(int wallDuration){
        StartCoroutine(ActiveWall(wallDuration));
    }

    IEnumerator ActiveWall(float wallDuration)
    {
        IsWall = true;
		UpdateColor ();
		yield return new WaitForSeconds (wallDuration);
        IsWall = false;
		UpdateColor ();
    }

    public void InvokeSwingColor(float colorDuration, Color colorToUse){
        StartCoroutine(GhostSwingColor(colorDuration, colorToUse));
    }

    private IEnumerator GhostSwingColor(float colorDuration, Color colorToUse)
    {
        Color startColor = defaultColor;
        defaultColor = colorToUse;
        UpdateColor();
        yield return new WaitForSeconds(colorDuration);
        defaultColor = startColor;
        UpdateColor();
    }
}


text:
import React from 'react';
import { connect } from 'react-redux';
import { projectDetails, selectProject, deselectProject } from 'state/projects';
import { tasksByProject, deleteTask } from 'state/tasks';
import { isNotFound } from 'state/api';
import ProjectDetails from 'scenes/application/scenes/Project/scenes/ProjectDetails/presentation';
import ProjectNotFound from 'scenes/application/scenes/Project/components/ProjectNotFound';
class ProjectDetailsContainer extends React.Component {
  componentDidMount() {
    const projectId = +this.props.match.params.id;
    this.props.selectProject(projectId);
  }
  componentWillUnmount() {
    this.props.deselectProject();
  }

  render() {
    if (isNotFound(this.props.project)) {
      return <ProjectNotFound />;
    }
    return <ProjectDetails project={this.props.project} tasks={this.props.tasks} deleteTask={this.props.deleteTask} />;
  }
}

const mapStateToProps = (state, ownProps) => {
  const projectId = +ownProps.match.params.id;
  return {
    project: projectDetails(state, projectId),
    tasks: tasksByProject(state, projectId),
  };
};

const mapDispatchToProps = dispatch => {
  return {
    selectProject: projectId => dispatch(selectProject(projectId)),
    deleteTask: taskId => dispatch(deleteTask.REQUEST.action(taskId)),
    deselectProject: () => dispatch(deselectProject()),
  };
};

export default connect(mapStateToProps, mapDispatchToProps)(ProjectDetailsContainer);


text:
package role

import (
	"errors"
	"fmt"

	"github.com/uber/ringpop-go"
	"github.com/uber/ringpop-go/forward"
	"github.com/uber/ringpop-go/router"
	"github.com/uber/tchannel-go"
	"github.com/uber/tchannel-go/thrift"
)

type RingpopRoleServiceAdapter struct {
	impl    TChanRoleService
	ringpop ringpop.Interface
	ch      *tchannel.Channel
	config  RoleServiceConfiguration
	router  router.Router
}

// RoleServiceConfiguration contains the forwarding configuration for the RoleService service. It has a field for every endpoint defined in the service. In this field the endpoint specific forward configuration can be stored. Populating these fields is optional, default behaviour is to call the service implementation locally to the process where the call came in.
type RoleServiceConfiguration struct {
	// GetMembers holds the forwarding configuration for the GetMembers endpoint defined in the service
	GetMembers *RoleServiceGetMembersConfiguration
	// SetRole holds the forwarding configuration for the SetRole endpoint defined in the service
	SetRole *RoleServiceSetRoleConfiguration
}

func (c *RoleServiceConfiguration) validate() error {
	if c.GetMembers != nil {
		if c.GetMembers.Key == nil {
			return errors.New("configuration for endpoint GetMembers is missing a Key function")
		}
	}
	if c.SetRole != nil {
		if c.SetRole.Key == nil {
			return errors.New("configuration for endpoint SetRole is missing a Key function")
		}
	}
	return nil
}

// NewRingpopRoleServiceAdapter creates an implementation of the TChanRoleService interface. This specific implementation will use to configuration provided during construction to deterministically route calls to nodes from a ringpop cluster. The channel should be the channel on which the service exposes its endpoints. Forwarded calls, calls to unconfigured endpoints and calls that already were executed on the right machine will be passed on the the implementation passed in during construction.
//
// Example usage:
//  import "github.com/uber/tchannel-go/thrift"
//
//  var server thrift.Server
//  server = ...
//
//  var handler TChanRoleService
//  handler = &YourImplementation{}
//
//  adapter, _ := NewRingpopRoleServiceAdapter(handler, ringpop, channel,
//    RoleServiceConfiguration{
//      GetMembers: &RoleServiceGetMembersConfiguration: {
//        Key: func(ctx thrift.Context, role string) (shardKey string, err error) {
//          return "calculated-shard-key", nil
//        },

//      SetRole: &RoleServiceSetRoleConfiguration: {
//        Key: func(ctx thrift.Context, role string) (shardKey string, err error) {
//          return "calculated-shard-key", nil
//        },
//      },
//    },
//  )
//  server.Register(NewTChanRoleServiceServer(adapter))
func NewRingpopRoleServiceAdapter(
	impl TChanRoleService,
	rp ringpop.Interface,
	ch *tchannel.Channel,
	config RoleServiceConfiguration,
) (TChanRoleService, error) {
	err := config.validate()
	if err != nil {
		return nil, err
	}

	adapter := &RingpopRoleServiceAdapter{
		impl:    impl,
		ringpop: rp,
		ch:      ch,
		config:  config,
	}
	// create ringpop router for routing based on ring membership
	adapter.router = router.New(rp, adapter, ch)

	return adapter, nil
}

// GetLocalClient satisfies the ClientFactory interface of ringpop-go/router
func (a *RingpopRoleServiceAdapter) GetLocalClient() interface{} {
	return a.impl
}

// MakeRemoteClient satisfies the ClientFactory interface of ringpop-go/router
func (a *RingpopRoleServiceAdapter) MakeRemoteClient(client thrift.TChanClient) interface{} {
	return NewTChanRoleServiceClient(client)
}

// RoleServiceGetMembersConfiguration contains the configuration on how to route calls to the thrift endpoint RoleService::GetMembers.
type RoleServiceGetMembersConfiguration struct {
	// Key is a closure that generates a routable key based on the parameters of the incomming request.
	Key func(ctx thrift.Context, role string) (string, error)
}

// GetMembers satisfies the TChanRoleService interface. This function uses the configuration for GetMembers to determine the host to execute the call on. When it decides the call needs to be executed in the current process it will forward the invocation to its local implementation.
func (a *RingpopRoleServiceAdapter) GetMembers(ctx thrift.Context, role string) (r []string, err error) {
	// check if the function should be called locally
	if a.config.GetMembers == nil || forward.DeleteForwardedHeader(ctx) {
		return a.impl.GetMembers(ctx, role)
	}

	// find the key to shard on
	ringpopKey, err := a.config.GetMembers.Key(ctx, role)
	if err != nil {
		return r, fmt.Errorf("could not get key: %q", err)
	}

	clientInterface, isRemote, err := a.router.GetClient(ringpopKey)
	if err != nil {
		return r, err
	}

	client := clientInterface.(TChanRoleService)
	if isRemote {
		ctx = forward.SetForwardedHeader(ctx, []string{ringpopKey})
	}
	return client.GetMembers(ctx, role)
}

// RoleServiceSetRoleConfiguration contains the configuration on how to route calls to the thrift endpoint RoleService::SetRole.
type RoleServiceSetRoleConfiguration struct {
	// Key is a closure that generates a routable key based on the parameters of the incomming request.
	Key func(ctx thrift.Context, role string) (string, error)
}

// SetRole satisfies the TChanRoleService interface. This function uses the configuration for SetRole to determine the host to execute the call on. When it decides the call needs to be executed in the current process it will forward the invocation to its local implementation.
func (a *RingpopRoleServiceAdapter) SetRole(ctx thrift.Context, role string) (err error) {
	// check if the function should be called locally
	if a.config.SetRole == nil || forward.DeleteForwardedHeader(ctx) {
		return a.impl.SetRole(ctx, role)
	}

	// find the key to shard on
	ringpopKey, err := a.config.SetRole.Key(ctx, role)
	if err != nil {
		return fmt.Errorf("could not get key: %q", err)
	}

	clientInterface, isRemote, err := a.router.GetClient(ringpopKey)
	if err != nil {
		return err
	}

	client := clientInterface.(TChanRoleService)
	if isRemote {
		ctx = forward.SetForwardedHeader(ctx, []string{ringpopKey})
	}
	return client.SetRole(ctx, role)
}


text:
/* global Localize */

Localize = window.Localize = {};

Localize.testing = true;
Localize.onstart = true;
Localize.delay = 0;
Localize.path = "./languages/";
Localize.handler = "POEditor";
Localize.fallbacklang = "en";

Localize.langs = {};
Localize.dynamic = {};
Localize.detected = navigator.language || navigator.userLanguage;
Localize.listeners = {get: [], geterror: [], add: [], localized: []};

Localize.handlers = {
  "default": null,
  "POEditor": function(lang, data) {
    var newdata = {};
    for (var ti = 0; ti < data.length; ti++) {
      var term = data[ti];
      if (!term.reference || term.reference.length == 0) {
        continue;
      }
      var subkeys = term.reference.split(".");
      var subkey = "";
      for (var i = 0; i < subkeys.length - 1; i++) {
        subkey += subkeys[i];
        eval("newdata."+subkey+" = newdata."+subkey+" || {}");
        subkey += ".";
      }
      if (term.reference.indexOf("[", subkey.length) > -1) {
        var arrayName = term.reference.substr(0, term.reference.indexOf("[", subkey.length));
        var arrayStr = "newdata."+arrayName;
        var array = eval(arrayStr+" = "+arrayStr+" || []");
        var newLength = parseInt(term.reference.substr(term.reference.indexOf("[", subkey.length) + 1, term.reference.indexOf("[", subkey.length) - 1)) + 1;
        for (var i = array.length; i < newLength; i++) {
          array.push(null);
        }
      }
      if (term.definition.indexOf("[...]") > -1) {
        term.definition = term.definition.split("[...]");
      }
      eval("newdata."+term.reference+" = term.definition");
    }
    return newdata;
  }
};

function localized(key) {
  var val;
  try {
    if ((val = eval("Localize.dynamic."+Localize.detected+"."+key)) != null) {
      return val;
    }
  } catch (e) {};
  try {
    if ((val = eval("Localize.dynamic."+Localize.fallbacklang+"."+key)) != null) {
      return val;
    }
  } catch (e) {};
  try {
    if ((val = eval("Localize.lang."+key)) != null) {
      return val;
    }
  } catch (e) {};
  try {
    if ((val = eval("Localize.fallback."+key)) != null) {
      return val;
    }
  } catch (e) {};
  console.log("localize: not found: ["+key+"]");
  return "["+key+"]";
};

Localize.localizeAll = function() {
  var localize_ = function() {
    //backwards-compatibility
    $("[localize]").each(function() {
      var self = $(this);
      var key = self.attr("localize");
      var attr = self.attr("localize-attr");
      if (!attr) {
        self.text(localized(key));
      } else {
        self.attr(attr, localized(key));
      }
    });
    //new format
    $("[data-localize]").localize();
  };

  if (Localize.lang != null) {
    localize_();
    return;
  }

  Localize.getLanguage(Localize.fallbacklang, function(data) {
    Localize.fallback = data;
    localize_();
  }, function(jqxhr, textStatus, error) {
    console.log("Failed loading locale: "+Localize.fallbacklang);
    console.log(textStatus, error);
    if (!Localize.testing) {
      alert("Failed loading the website texts. Please contact the site administrator.");
    } else {
      localize_();
    }
  });

  Localize.getLanguage(navigator.language || navigator.userLanguage, function(data) {
    Localize.lang = data;
    localize_();
  });
};

Localize.getLanguage = function(lang, cb, fail, handler) {
  Localize.langs[lang] = Localize.langs[lang] || {};
  handler = handler || Localize.handlers[Localize.handler] || Localize.handlers["default"]
  $.getJSON(Localize.path+lang+".json", function(data) {
    data = handler(lang, data);
    Localize.langs[lang] = data;
    if (cb) {
      cb(data);
    }
    Localize.callListeners(Localize.listeners.get, lang, data);
  }).fail(fail || function(jqxhr, textStatus, error) {
    console.log("Failed loading locale: en");
    console.log(textStatus, error);
    Localize.callListeners(Localize.listeners.geterror, lang, jqxhr, textStatus, error);
    if (Localize.testing) {
      if (cb) {
        cb(null);
      }
    }
  });
}

Localize.addTranslation = function(lang, key, value) {
  Localize.dynamic[lang] = Localize.dynamic[lang] || {};

  var subkeys = key.split(".");
  var subkey = "";
  for (var i = 0; i < subkeys.length; i++) {
    subkey += subkeys[i];
    eval("Localize.dynamic."+lang+"."+subkey+" = Localize.dynamic."+lang+"."+subkey+" || {}");
    subkey += ".";
  }
  eval("Localize.dynamic."+lang+"."+key+" = value");

  Localize.callListeners(Localize.listeners.add, lang, key, value);
}

$.fn["localize"] = function() {
  return this.each(function() {
    var self = $(this);
    var data = self.attr("data-localize");
    try {
      data = JSON.parse(data);
      for (var p in data) {
        if (!data.hasOwnProperty(p)) {
          continue;
        }
        if (p == "_text") {
          self.text(localized(data["_text"]));
        } else {
          self.attr(p, localized(data[p]));
        }
        Localize.callListeners(Localize.listeners.localized, self, data, p);
      }
    } catch (e) {
      self.text(localized(data));
    }
  });
}

Localize.callListeners = function() {
  var listeners = arguments[0];

  var args = new Array(arguments.length - 1);
  for (var i = 0; i < args.length; i++) {
    args[i] = arguments[i+1];
  }

  for (var i = 0; i < listeners.length; i++) {
    listeners[i].apply(this, args);
  }
}

if (Localize.onstart) {
  setTimeout(Localize.localizeAll, Localize.delay);
}


text:
import DataFormatter from './data_formatter';
import _ from 'lodash';

describe('DataFormatter', () => {
  let dataFormatter;
  let formattedData: any[] = [];

  describe('when latitude and longitude are given in table data and query type is coordinates', () => {
    beforeEach(() => {
      const ctrl = {
        panel: {
          tableQueryOptions: {
            queryType: 'coordinates',
            latitudeField: 'latitude',
            longitudeField: 'longitude'
          }
        }
      };
      dataFormatter = new DataFormatter(ctrl);
    });

    it('should use latitude and longitude coordinates', () => {
      const tableData = [
        [
          {
            latitude: 1,
            longitude: 2
          },
          {
            latitude: 3,
            longitude: 4
          }
        ]
      ];
      const data: any[] = [];

      dataFormatter.setTableValues(tableData, data);

      expect(data[0].locationLatitude).toEqual(1);
      expect(data[0].locationLongitude).toEqual(2);
      expect(data[1].locationLatitude).toEqual(3);
      expect(data[1].locationLongitude).toEqual(4);
    });
  });

  describe('when geohash in table data and query type is geohash', () => {
    beforeEach(() => {
      const ctrl = {
        panel: {
          tableQueryOptions: {
            queryType: 'geohash',
            geohashField: 'geohash',
          }
        }
      };
      dataFormatter = new DataFormatter(ctrl);
    });

    it('should use the geohash field for the query', () => {
      const tableData = [
        [
          {
            latitude: 1,
            longitude: 2,
            geohash: 'stq4s3x' // 29.9796, 31.1345
          },
          {
            latitude: 3,
            longitude: 4,
            geohash: 'p05010r' // -89.997, 139.273
          }
        ]
      ];
      const data: any[] = [];

      dataFormatter.setTableValues(tableData, data);

      expect(data[0].locationLatitude).toBeCloseTo(29.9796);
      expect(data[0].locationLongitude).toBeCloseTo(31.1345);
      expect(data[1].locationLatitude).toBeCloseTo(-89.998);
      expect(data[1].locationLongitude).toBeCloseTo(139.272);
    });
  });

  describe('when the time series data matches the location', () => {
    beforeEach(() => {
      const ctrl = {
        panel: {
          valueName: 'total'
        },
        locations: [
          {key: 'IE', name: 'Ireland', latitude: 1, longitude: 1},
          {key: 'SE', name: 'Sweden', latitude: 2, longitude: 2},
        ],
        series: [
          {alias: 'IE', datapoints: [1, 2], stats: {total: 3}},
          {alias: 'SE', datapoints: [2, 3], stats: {total: 5}},
        ]
      };
      dataFormatter = new DataFormatter(ctrl);
      dataFormatter.setValues(formattedData);
    });

    it('should format the data and match the serie to a location', () => {
      expect(formattedData[0].key).toEqual('IE');
      expect(formattedData[0].locationName).toEqual('Ireland');
      expect(formattedData[0].locationLatitude).toEqual(1);
      expect(formattedData[0].locationLongitude).toEqual(1);
      expect(formattedData[0].value).toEqual(3);

      expect(formattedData[1].key).toEqual('SE');
      expect(formattedData[1].locationName).toEqual('Sweden');
      expect(formattedData[1].locationLatitude).toEqual(2);
      expect(formattedData[1].locationLongitude).toEqual(2);
      expect(formattedData[1].value).toEqual(5);
    });
  });

  describe('when the time series data has lowercase country codes', () => {
    beforeEach(() => {
      const ctrl = {
        panel: {
          valueName: 'total'
        },
        locations: [
          {key: 'IE', name: 'Ireland', latitude: 1, longitude: 1},
          {key: 'SE', name: 'Sweden', latitude: 2, longitude: 2},
        ],
        series: [
          {alias: 'ie', datapoints: [1, 2], stats: {total: 3}},
          {alias: 'se', datapoints: [2, 3], stats: {total: 5}},
        ]
      };
      dataFormatter = new DataFormatter(ctrl);
      dataFormatter.setValues(formattedData);
    });

    it('should format the data and match the serie to a location', () => {
      expect(formattedData[0].key).toEqual('ie');
      expect(formattedData[0].locationName).toEqual('Ireland');
      expect(formattedData[0].locationLatitude).toEqual(1);
      expect(formattedData[0].locationLongitude).toEqual(1);
      expect(formattedData[0].value).toEqual(3);

      expect(formattedData[1].key).toEqual('se');
      expect(formattedData[1].locationName).toEqual('Sweden');
      expect(formattedData[1].locationLatitude).toEqual(2);
      expect(formattedData[1].locationLongitude).toEqual(2);
      expect(formattedData[1].value).toEqual(5);
    });
  });

  describe('when the time series data does not match any location', () => {
    beforeEach(() => {
      const ctrl = {
        panel: {
          valueName: 'total'
        },
        locations: [{key: 'IE', name: 'Ireland', latitude: 1, longitude: 1}],
        series: [
          {alias: 'SX', datapoints: [1, 2], stats: {total: 3}},
          {alias: 'IE', datapoints: [1, 2], stats: {total: 3}}
        ]
      };
      dataFormatter = new DataFormatter(ctrl);
      dataFormatter.setValues(formattedData);
    });

    it('should ignore the serie', () => {
      expect(formattedData.length).toEqual(1);
    });
  });

  describe('when the time series data has decimals', () => {
    describe('and decimals are specified as an integer', () => {
      beforeEach(() => {
        const ctrl = {
          panel: {
            valueName: 'total',
            decimals: 2
          },
          locations: [
            {key: 'IE', name: 'Ireland', latitude: 1, longitude: 1},
            {key: 'SE', name: 'Sweden', latitude: 2, longitude: 2},
          ],
          series: [
            {alias: 'IE', datapoints: [1.11, 2.22], stats: {total: 3.33}},
            {alias: 'SE', datapoints: [2.221, 3.331], stats: {total: 5.552}},
          ]
        };
        dataFormatter = new DataFormatter(ctrl);
        dataFormatter.setValues(formattedData);
      });

      it('should format the value with 2 decimals', () => {
        expect(formattedData[1].valueRounded).toEqual(5.55);
      });
    });

    describe('and decimals are specified as a string', () => {
      beforeEach(() => {
        const ctrl = {
          panel: {
            valueName: 'total',
            decimals: '2'
          },
          locations: [
            {key: 'IE', name: 'Ireland', latitude: 1, longitude: 1},
            {key: 'SE', name: 'Sweden', latitude: 2, longitude: 2},
          ],
          series: [
            {alias: 'IE', datapoints: [1.11, 2.22], stats: {total: 3.33}},
            {alias: 'SE', datapoints: [2.221, 3.331], stats: {total: 5.552}},
          ]
        };
        dataFormatter = new DataFormatter(ctrl);
        dataFormatter.setValues(formattedData);
      });

      it('should format the value with 2 decimals', () => {
        expect(formattedData[1].valueRounded).toEqual(5.55);
      });
    });
  });

  afterEach(() => {
    formattedData = [];
  });
});


text:
<?php
namespace HcBackend\Data;

use Zf2Libs\Data\DataInterface;
use Zf2Libs\Stdlib\Messages\MessagesInterface;

interface DataMessagesInterface extends DataInterface, MessagesInterface {}


text:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:padding="10dip" >

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Matricula:"
        android:id="@+id/txt_matricola" />

    <EditText
        android:layout_width="300dp"
        android:id="@+id/edit_matricola"
        android:layout_height="wrap_content"
        android:gravity="top"
        android:text="@string/Matricola">
        </EditText>

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="ID Student:"
        android:id="@+id/txt_imei" />

    <EditText
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:id="@+id/edit_imei"
        android:text="@string/Imei"
        android:editable="false" />

<Button
    android:id="@+id/write_tag"
    android:layout_centerHorizontal="true"
   	android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/edit_imei"
    android:text="@string/write_to_tag">
</Button>

</RelativeLayout>