<commit_before>'use strict';

var assign            = require('es5-ext/object/assign')
  , primitiveSet      = require('es5-ext/object/primitive-set')
  , d                 = require('d/d')
  , lazy              = require('d/lazy')
  , Map               = require('es6-map/primitive')
  , ee                = require('event-emitter/lib/core')
  , ObjectsSet        = require('./objects-set')
  , DbjsError             = require('./error')
  , History           = require('./history')
  , unserializeObject = require('./unserialize/object')

  , setupProp         = require('./1.property')
  , setupMultiple     = require('./2.multiple-item')
  , setupDescProp     = require('./3.descriptor-property')
  , setupType         = require('./4.type')
  , setupDescMeta     = require('./5.descriptor-meta-properties')
  , validDbjsObject   = require('../valid-dbjs-object')

  , create = Object.create, defineProperty = Object.defineProperty
  , defineProperties = Object.defineProperties
  , getPrototypeOf = Object.getPrototypeOf
  , idDesc = d('', undefined)
  , objDesc = d('', undefined)
  , masterDesc = d('', undefined)
  , initDesc = { __id__: idDesc, object: objDesc, master: masterDesc }
  , accessCollector = ee()
  , nativeTypes = primitiveSet('Base', 'Boolean', 'Number', 'String',
	'DateTime', 'RegExp', 'Function', 'Object')
  , deleteObject, Constructor, protoProperties;

deleteObject = function (obj) {
	validDbjsObject(obj);
	if (obj._kind_ === 'object') {
		if (typeof obj === 'function') {
			// Type
			if (nativeTypes[obj.__id__]) {
				throw new DbjsError("Cannot delete native dbjs type",
					'DELETE_NATIVE_TYPE');
			}
		} else if (obj.constructor.prototype === obj) {
			throw new DbjsError("Cannot delete prototype (delete type instead)",
				'DELETE_PROTOTYPE');
		}
	}
	obj.database._postponed_ += 1;
	obj._destroy_();
	obj.database._postponed_ -= 1;
};

Constructor = function (id, object, master) {
	if (!object) {
		object = this;
		if (!master) master = this;
	} else if (!master) {
		master = object.master;
	}
	idDesc.value = id;
	objDesc.value = object;
	masterDesc.value = master;
	defineProperties(this, initDesc);
	objDesc.value = masterDesc.value = null;
};

protoProperties = assign({
	_lastOwnEvent_: d.gs(function () {
		if (!this.hasOwnProperty('__history__')) return null;
		return this.__history__[0] || null;
	}),
	_lastOwnModified_: d.gs(function () {
		var event = this._lastOwnEvent_;
		if (!event) return 0;
		return event.stamp;
	}),
	_lastEvent_: d.gs(function () {
		var obj = this;
		while (!obj.hasOwnProperty('_value_')) {
			obj = getPrototypeOf(obj);
			if (!obj.object) return null;
		}
		return obj._lastOwnEvent_;
	}),
	lastModified: d.gs(function () {
		var event = this._lastEvent_;
		if (!event) return 0;
		return event.stamp;
	})
}, lazy({
	_descendants_: d(function () { return new ObjectsSet(); },
		{ cacheName: '__descendants__', desc: '' }),
	_history_: d(function () { return new History(); },
		{ cacheName: '__history__', desc: '' })
}));

module.exports = function (db) {
	var createObj, createProto, objects, object, descriptor, item
	  , descriptorDescriptor;

	// 0. Empty space
	objects = new ObjectsSet();
	defineProperty(db, 'objects', d(objects));

	// 1. Proto constructor
	createProto = function (proto, id, kind, object) {
		proto = create(proto);
		if (!object) object = proto;
		return defineProperties(proto, assign({
			__id__: d('', id),
			master: d('', object),
			object: d('', object),
			_kind_: d('', kind),
			database: d('', db),
			toString: d('c', function () { return '[dbjs ' + this.__id__ + ']'; })
		}, protoProperties));
	};

	// 2. Value constructor
	createObj = function (proto, id, object, master) {
		var obj;
		Constructor.prototype = proto;
		obj = new Constructor(id, object, master);
		objects._add(obj);
		proto._descendants_._add(obj);
		return obj;
	};

	object = createProto(Map.prototype, 'Base#', 'object');
	descriptor = createProto(Map.prototype, '$', 'descriptor', object);
	item = createProto(Object.prototype, '*', 'item', object);
	descriptorDescriptor = createProto(Object.prototype, '/', 'sub-descriptor',
		object);

	setupProp(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);
	setupMultiple(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);
	setupDescProp(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);
	setupType(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);
	setupDescMeta(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);

	defineProperties(objects, {
		unserialize: d(unserializeObject(db)),
		delete: d(deleteObject)
	});
};
<commit_msg>-- style<commit_after>'use strict';

var assign            = require('es5-ext/object/assign')
  , primitiveSet      = require('es5-ext/object/primitive-set')
  , d                 = require('d/d')
  , lazy              = require('d/lazy')
  , Map               = require('es6-map/primitive')
  , ee                = require('event-emitter/lib/core')
  , ObjectsSet        = require('./objects-set')
  , DbjsError             = require('./error')
  , History           = require('./history')
  , unserializeObject = require('./unserialize/object')

  , setupProp         = require('./1.property')
  , setupMultiple     = require('./2.multiple-item')
  , setupDescProp     = require('./3.descriptor-property')
  , setupType         = require('./4.type')
  , setupDescMeta     = require('./5.descriptor-meta-properties')
  , validDbjsObject   = require('../valid-dbjs-object')

  , create = Object.create, defineProperty = Object.defineProperty
  , defineProperties = Object.defineProperties
  , getPrototypeOf = Object.getPrototypeOf
  , idDesc = d('', undefined)
  , objDesc = d('', undefined)
  , masterDesc = d('', undefined)
  , initDesc = { __id__: idDesc, object: objDesc, master: masterDesc }
  , accessCollector = ee()
  , nativeTypes = primitiveSet('Base', 'Boolean', 'Number', 'String',
	'DateTime', 'RegExp', 'Function', 'Object')
  , deleteObject, Constructor, protoProperties;

deleteObject = function (obj) {
	validDbjsObject(obj);
	if (obj._kind_ === 'object') {
		if (typeof obj === 'function') {
			// Type
			if (nativeTypes[obj.__id__]) {
				throw new DbjsError("Cannot delete native dbjs type",
					'DELETE_NATIVE_TYPE');
			}
		} else if (obj.constructor.prototype === obj) {
			throw new DbjsError("Cannot delete prototype (delete type instead)",
				'DELETE_PROTOTYPE');
		}
	}
	obj.database._postponed_ += 1;
	obj._destroy_();
	obj.database._postponed_ -= 1;
};

Constructor = function (id, object, master) {
	if (!object) {
		object = this;
		if (!master) master = this;
	} else if (!master) {
		master = object.master;
	}
	idDesc.value = id;
	objDesc.value = object;
	masterDesc.value = master;
	defineProperties(this, initDesc);
	objDesc.value = masterDesc.value = null;
};

protoProperties = assign({
	_lastOwnEvent_: d.gs(function () {
		if (!this.hasOwnProperty('__history__')) return null;
		return this.__history__[0] || null;
	}),
	_lastOwnModified_: d.gs(function () {
		var event = this._lastOwnEvent_;
		if (!event) return 0;
		return event.stamp;
	}),
	_lastEvent_: d.gs(function () {
		var obj = this;
		while (!obj.hasOwnProperty('_value_')) {
			obj = getPrototypeOf(obj);
			if (!obj.object) return null;
		}
		return obj._lastOwnEvent_;
	}),
	lastModified: d.gs(function () {
		var event = this._lastEvent_;
		if (!event) return 0;
		return event.stamp;
	})
}, lazy({
	_descendants_: d(function () { return new ObjectsSet(); },
		{ cacheName: '__descendants__', desc: '' }),
	_history_: d(function () { return new History(); },
		{ cacheName: '__history__', desc: '' })
}));

module.exports = function (db) {
	var createObj, createProto, objects, object, descriptor, item
	  , descriptorDescriptor;

	// 0. Empty space
	objects = new ObjectsSet();
	defineProperty(db, 'objects', d(objects));

	// 1. Proto constructor
	createProto = function (proto, id, kind, object) {
		proto = create(proto);
		if (!object) object = proto;
		return defineProperties(proto, assign({
			__id__: d('', id),
			_kind_: d('', kind),
			master: d('', object),
			object: d('', object),
			database: d('', db),
			toString: d('c', function () { return '[dbjs ' + this.__id__ + ']'; })
		}, protoProperties));
	};

	// 2. Value constructor
	createObj = function (proto, id, object, master) {
		var obj;
		Constructor.prototype = proto;
		obj = new Constructor(id, object, master);
		objects._add(obj);
		proto._descendants_._add(obj);
		return obj;
	};

	object = createProto(Map.prototype, 'Base#', 'object');
	descriptor = createProto(Map.prototype, '$', 'descriptor', object);
	item = createProto(Object.prototype, '*', 'item', object);
	descriptorDescriptor = createProto(Object.prototype, '/', 'sub-descriptor',
		object);

	setupProp(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);
	setupMultiple(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);
	setupDescProp(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);
	setupType(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);
	setupDescMeta(db, createObj, object, descriptor, item, descriptorDescriptor,
		accessCollector);

	defineProperties(objects, {
		unserialize: d(unserializeObject(db)),
		delete: d(deleteObject)
	});
};
<|endoftext|>


<commit_before>/*
 * Application
 */
$(function () {
    // Background Video
    var $backgroundVideo = new $.backgroundVideo(
        $('body'), {
        "align": "centerXY",
        "width": 854,
        "height": 480,
        "path": "vids/",
        "filename": "enactus",
        "types": ["webm", "mp4", "ogv"]
    });
    // Image Fallback
    if (!Modernizr.video)
        $('body').addClass('body--noVid');

    // Simple Text Rotator
    $(".js-rotate").Morphext({
        animation: "fadeInRight",
        separator: ";",
        speed: 3000
    });

    // Horizontal and vertical centering
    var $window = $(window);
    var $headerObj = $('.header');

    var $centreMarginObj = $('.js-centre');
    var $centreMarginHeight;
    var centreMargin = function () {
        $centreMarginHeight = $window.outerHeight() - $headerObj.outerHeight() - $centreMarginObj.outerHeight();
        if ($centreMarginHeight <= 20)
            $centreMarginHeight = 20;
        $centreMarginObj.css('margin', $centreMarginHeight / 2 + 'px auto');
    }
    centreMargin();
    $window.resize(centreMargin);
});<commit_msg>Fixing background fallback for mobile devices<commit_after>/*
 * Application
 */
$(function () {
    // Background Video
    var $backgroundVideo = new $.backgroundVideo(
        $('body'), {
        "align": "centerXY",
        "width": 854,
        "height": 480,
        "path": "vids/",
        "filename": "enactus",
        "types": ["webm", "mp4", "ogv"]
    });
    // Image Fallback
    if (!Modernizr.video || Modernizr.touch)
        $('body').addClass('body--noVid');

    // Simple Text Rotator
    $(".js-rotate").Morphext({
        animation: "fadeInRight",
        separator: ";",
        speed: 3000
    });

    // Horizontal and vertical centering
    var $window = $(window);
    var $headerObj = $('.header');

    var $centreMarginObj = $('.js-centre');
    var $centreMarginHeight;
    var centreMargin = function () {
        $centreMarginHeight = $window.outerHeight() - $headerObj.outerHeight() - $centreMarginObj.outerHeight();
        if ($centreMarginHeight <= 20)
            $centreMarginHeight = 20;
        $centreMarginObj.css('margin', $centreMarginHeight / 2 + 'px auto');
    }
    centreMargin();
    $window.resize(centreMargin);
});<|endoftext|>


<commit_before>
const deleteByDot = require('./delete-by-dot');
const _transformItems = require('./_transform-items');

module.exports = function (items /* modified */, fieldNames) {
  _transformItems(items, fieldNames, (item, fieldName, value) => {
    if (value !== undefined) {
      deleteByDot(item, fieldName);
    }
  });
};
<commit_msg>Enable _remove to delete fields containing dots.<commit_after>
const deleteByDot = require('./delete-by-dot');
const _transformItems = require('./_transform-items');

module.exports = function (items /* modified */, fieldNames) {
  _transformItems(items, fieldNames, (item, fieldName, value) => {
    if (value !== undefined) {
      // Delete fields like item['contactPerson.name']. This is a typical patch format for MongoDB.
      if(item[fieldName]) delete item[fieldName];
      // Delete fields like item.contactPerson.name
      deleteByDot(item, fieldName);
    }
  });
};
<|endoftext|>


<commit_before>//Hämtar inloggningsformet
function getFormData(){
localStorage.anv=document.getElementById("username").value;
localStorage.pass=document.getElementById("password").value;
console.log("Den skickar inloggningen");
hamta();
//loadtvatta('tvatta/tvatta.html');
}

//hämta marknad
function hamta() {
	$.getJSON("http://marknad.sgsstudentbostader.se/API/Service/AuthorizationServiceHandler.ashx?&syndicateNo=1&syndicateObjectMainGroupNo=1&username=" +localStorage.anv+ "&password=" +localStorage.pass+ "&Method=APILoginSGS&callback=?",
	  function(result) {
		console.log(result);
		$.each(result, function (newsItem,news)
		{
		localStorage[newsItem]=news
			//$("#newsfeed").append(newsItem + "=" + news + "
");
			console.log("Detta lagras för tillfället " + localStorage[newsItem])

		});
	  loggain()
	  });

};

//logga in
function loggain(){
//localStorage.removeItem(localStorage.urlen);
var str1="_=1366895108402&customer_name=" + localStorage.SGS_CustomerName + "&customerid=" + localStorage.UserName + "&isresident=" + localStorage.SGS_LivesAtSgs + "&loggedin=" + localStorage.LoggedIn + "&token=" + localStorage.SecurityTokenId + "&tvattstuga=" + localStorage.SGS_Laundry;
localStorage.urlen="http://www.sgsstudentbostader.se/Assets/Handlers/Momentum.ashx?" + str1;
console.log("Logga in delen, nuvarande sgs.se URL  " + localStorage.urlen);
console.log("Användare sparad från form " + localStorage.anv);
console.log("Logga in delen " + localStorage.UserName);
hiddenbrowser();
}
//alt med iframe
function bytiframe(){
	  var hej1 = document.getElementById('hej1').src=localStorage.urlen
	  console.log("Nu sätts iframe adressen till inlogg");
}

//alt med hidden InAppBrowser
function hiddenbrowser(){
	console.log("Går in i funktionen hiddenbrowser");
	 var ref = window.open(localStorage.urlen, '_blank', 'hidden=yes');
 //Denna skall in i loadstop funktionen.
	 console.log(ref);
		 ref.addEventListener('loadstop', function(event) {
			 alert('background window loaded');
			 loadtvatta('http://www.sgsstudentbostader.se/ext_gw.aspx?module=wwwash&lang=se#lblPanelName');
			 console.log("www.google.se är laddad i bakgrunden");

})

}
function byggnad(){
	skapabyggnadtable();
	document.getElementById("topploga").src = " ";
	$.ajax({
			url: 'http://www.sgsstudentbostader.se/ext_gw.aspx?module=wwwash&lang=se#lblPanelName',
			success: function(data) {
				var table5 = document.getElementById('byggnad');
				var indifiera;
				var byggnadlank;
				var byggnadnamn;
				var nastafem;
				var delabyggnadlank;
				indifiera = $(data).find("#lblHeaderText");
				console.log(indifiera[0].id);
				if(indifiera[0].id == "lblHeaderText"){
					byggnadlank = $(data).find("td .headerColor");
					console.log(byggnadlank.length);
					var d = 0;

					for(var i = 0; i < byggnadlank.length; i++){
						var byggnadtable = table5.insertRow(-1);
						var byggnadcell = byggnadtable.insertCell(-1);
						byggnadcell.innerHTML = byggnadlank[d].innerHTML;
						console.log(byggnadlank[d].innerHTML);
						if(byggnadlank[d].onmousedown != null){
							delabyggnadlank = String(byggnadlank[d].onmousedown).split("'");
							byggnadcell.innerHTML = ""+ byggnadlank[d].innerHTML + "";

						}
						d++;

					}
					//lank till bokningsfönster
					console.log(byggnadlank[1].onmousedown);
					//visar byggnadsnamn
					console.log(byggnadlank[1].childNodes[0].childNodes[1].textContent);

				}
				else{
					loadtvatta('http://www.sgsstudentbostader.se/ext_gw.aspx?module=wwwash&lang=se#lblPanelName');
				}

	}
	})

}

//Vi laddar in hela tvatta.sgsstudentbostader.se
function loadtvatta(urlfranlankar){

	skapatvattatable();
	document.getElementById("topploga").src = " ";
	var tvattaimg;
	var antaltider;
	var nummer;
	var dagar;
	var tiderdygnet;
	var lankartvatta;

	var c = 0;

	var table = document.getElementById('tvatta');
	$.ajax({
			url: urlfranlankar,
			success: function(data) {
				var root2 = document.getElementById('mydiv2');
				var tab2=document.createElement('table');
				tvattaimg = $(data).find("#tbl1 [src]");
				nummer = $(data).find("#tbl1 a");
				antaltider = $(data).find( "#tbl1 tr:contains('-')");
				dagar = $(data).find("#tbl1 th");
				lank = $(data).find("#tbl1 [onmousedown]");
				tiderdygnet = $(data).find("#tbl1 td:contains(':')");
				lankartvatta = $(data).find("#tblNav td.periodLinkColor");
				console.log(lankartvatta[0].innerText);
				var antal = antaltider.length;
				console.log(tiderdygnet[4].innerHTML);

				//Här byggs tabellen upp

				//navigerings knappar
				var navrow = table.insertRow(-1);
				var nasta = 0;
				//navrow.insertCell(-1);
				for(n = 0; n < lankartvatta.length; n++){
				nastavecka = String(lankartvatta[nasta].onmousedown).split("'");
				nastavecka = "http://tvatta.sgsstudentbostader.se/" + nastavecka[1];
				var navcell = navrow.insertCell(-1);
				console.log(nastavecka[1]);
				navcell.innerHTML = ''+ lankartvatta[nasta].innerText +'';
				nasta++;
				}

				//header med tider
				var f = 0;
				var headrow = table.insertRow(-1);
				headrow.insertCell(-1);
				for (h = 0; h < antal; h++){
						var headcell = headrow.insertCell(-1);
						headcell.innerHTML = "
" + tiderdygnet[f].innerHTML + "
";

						f++
						console.log(f);
						}

				//Här byggs tvatta tabeln upp
				var smart = 0;
				var extra = 6;
				var q = 1;
				var nollstall = ((antal * 7)-1);
				//Datum och dagar
				for (var b = 0; b < 7; b++){
					var row = table.insertRow(-1)

					var cell2 = row.insertCell(-1);
					cell2.innerHTML = "
" + dagar[q].innerHTML + "
"
					q++;
						if(b >= 1){
						smart = (smart - nollstall)
									}

				for (var i = 0; i < antal; i++){

					var cell = row.insertCell(-1)
					cell.innerHTML = "" + tvattaimg[smart].outerHTML + "";
					//kollar så att inte onmousedown är null

						if(tvattaimg[smart].parentNode.onmousedown != null){

							//splittar upp och tar ut endast värdet ur funktionen
							split = String(tvattaimg[smart].parentNode.onmousedown).split("'");
							cell.innerHTML =
							"" + tvattaimg[smart].outerHTML + "";
							//console.log(res);
							console.log("Testar att splitta stringen	 " + split[1]);
							}

					console.log("CELLER	" + smart);
					smart = (smart + extra);
					smart++

								}
								}

			}
			})
			}<commit_msg>framåt och bakåt med index<commit_after>//Hämtar inloggningsformet
function getFormData(){
localStorage.anv=document.getElementById("username").value;
localStorage.pass=document.getElementById("password").value;
console.log("Den skickar inloggningen");
hamta();
//loadtvatta('tvatta/tvatta.html');
}

//hämta marknad
function hamta() {
	$.getJSON("http://marknad.sgsstudentbostader.se/API/Service/AuthorizationServiceHandler.ashx?&syndicateNo=1&syndicateObjectMainGroupNo=1&username=" +localStorage.anv+ "&password=" +localStorage.pass+ "&Method=APILoginSGS&callback=?",
	  function(result) {
		console.log(result);
		$.each(result, function (newsItem,news)
		{
		localStorage[newsItem]=news
			//$("#newsfeed").append(newsItem + "=" + news + "
");
			console.log("Detta lagras för tillfället " + localStorage[newsItem])

		});
	  loggain()
	  });

};

//logga in
function loggain(){
//localStorage.removeItem(localStorage.urlen);
var str1="_=1366895108402&customer_name=" + localStorage.SGS_CustomerName + "&customerid=" + localStorage.UserName + "&isresident=" + localStorage.SGS_LivesAtSgs + "&loggedin=" + localStorage.LoggedIn + "&token=" + localStorage.SecurityTokenId + "&tvattstuga=" + localStorage.SGS_Laundry;
localStorage.urlen="http://www.sgsstudentbostader.se/Assets/Handlers/Momentum.ashx?" + str1;
console.log("Logga in delen, nuvarande sgs.se URL  " + localStorage.urlen);
console.log("Användare sparad från form " + localStorage.anv);
console.log("Logga in delen " + localStorage.UserName);
hiddenbrowser();
}
//alt med iframe
function bytiframe(){
	  var hej1 = document.getElementById('hej1').src=localStorage.urlen
	  console.log("Nu sätts iframe adressen till inlogg");
}

//alt med hidden InAppBrowser
function hiddenbrowser(){
	console.log("Går in i funktionen hiddenbrowser");
	 var ref = window.open(localStorage.urlen, '_blank', 'hidden=yes');
 //Denna skall in i loadstop funktionen.
	 console.log(ref);
		 ref.addEventListener('loadstop', function(event) {
			 alert('background window loaded');
			 loadtvatta('http://www.sgsstudentbostader.se/ext_gw.aspx?module=wwwash&lang=se#lblPanelName');
			 console.log("www.google.se är laddad i bakgrunden");

})

}
function byggnad(){
	skapabyggnadtable();
	document.getElementById("topploga").src = " ";
	$.ajax({
			url: 'http://www.sgsstudentbostader.se/ext_gw.aspx?module=wwwash&lang=se#lblPanelName',
			success: function(data) {
				var table5 = document.getElementById('byggnad');
				var indifiera;
				var byggnadlank;
				var byggnadnamn;
				var nastafem;
				var delabyggnadlank;
				indifiera = $(data).find("#lblHeaderText");
				console.log(indifiera[0].id);
				if(indifiera[0].id == "lblHeaderText"){
					byggnadlank = $(data).find("td .headerColor");
					console.log(byggnadlank.length);
					var d = 0;

					for(var i = 0; i < byggnadlank.length; i++){
						var byggnadtable = table5.insertRow(-1);
						var byggnadcell = byggnadtable.insertCell(-1);
						byggnadcell.innerHTML = byggnadlank[d].innerHTML;
						console.log(byggnadlank[d].innerHTML);
						if(byggnadlank[d].onmousedown != null){
							delabyggnadlank = String(byggnadlank[d].onmousedown).split("'");
							byggnadcell.innerHTML = ""+ byggnadlank[d].innerHTML + "";

						}
						d++;

					}
					//lank till bokningsfönster
					console.log(byggnadlank[1].onmousedown);
					//visar byggnadsnamn
					console.log(byggnadlank[1].childNodes[0].childNodes[1].textContent);

				}
				else{
					loadtvatta('http://www.sgsstudentbostader.se/ext_gw.aspx?module=wwwash&lang=se#lblPanelName');
				}

	}
	})

}

//Vi laddar in hela tvatta.sgsstudentbostader.se
function loadtvatta(urlfranlankar){

	skapatvattatable();
	document.getElementById("topploga").src = " ";
	var tvattaimg;
	var antaltider;
	var nummer;
	var dagar;
	var tiderdygnet;
	var lankartvatta;

	var c = 0;

	var table = document.getElementById('tvatta');
	$.ajax({
			url: urlfranlankar,
			success: function(data) {
				var root2 = document.getElementById('mydiv2');
				var tab2=document.createElement('table');
				tvattaimg = $(data).find("#tbl1 [src]");
				nummer = $(data).find("#tbl1 a");
				antaltider = $(data).find( "#tbl1 tr:contains('-')");
				dagar = $(data).find("#tbl1 th");
				lank = $(data).find("#tbl1 [onmousedown]");
				tiderdygnet = $(data).find("#tbl1 td:contains(':')");
				lankartvatta = $(data).find("#tblNav td.periodLinkColor");
				console.log(lankartvatta[0].innerText);
				var antal = antaltider.length;
				console.log(tiderdygnet[4].innerHTML);

				//Här byggs tabellen upp

				//Navigerings knappar
				var navrow = table.insertRow(-1);
				var nasta = 0;
				//navrow.insertCell(-1);
				for(n = 0; n < lankartvatta.length; n++){
				nastavecka = String(lankartvatta[nasta].onmousedown).split("'");
				nastavecka = "http://tvatta.sgsstudentbostader.se/" + nastavecka[1];
				var navcell = navrow.insertCell(-1);
				console.log(nastavecka[1]);
				navcell.innerHTML = ''+ lankartvatta[nasta].innerText +'';
				nasta++;
				}

				//header med tider
				var f = 0;
				var headrow = table.insertRow(-1);
				headrow.insertCell(-1);
				for (h = 0; h < antal; h++){
						var headcell = headrow.insertCell(-1);
						headcell.innerHTML = "
" + tiderdygnet[f].innerHTML + "
";

						f++
						console.log(f);
						}

				//Här byggs tvatta tabeln upp
				var smart = 0;
				var extra = 6;
				var q = 1;
				var nollstall = ((antal * 7)-1);
				//Datum och dagar
				for (var b = 0; b < 7; b++){
					var row = table.insertRow(-1)

					var cell2 = row.insertCell(-1);
					cell2.innerHTML = "
" + dagar[q].innerHTML + "
"
					q++;
						if(b >= 1){
						smart = (smart - nollstall)
									}

				for (var i = 0; i < antal; i++){

					var cell = row.insertCell(-1)
					cell.innerHTML = "" + tvattaimg[smart].outerHTML + "";
					//kollar så att inte onmousedown är null

						if(tvattaimg[smart].parentNode.onmousedown != null){

							//splittar upp och tar ut endast värdet ur funktionen
							split = String(tvattaimg[smart].parentNode.onmousedown).split("'");
							cell.innerHTML =
							"" + tvattaimg[smart].outerHTML + "";
							//console.log(res);
							console.log("Testar att splitta stringen	 " + split[1]);
							}

					console.log("CELLER	" + smart);
					smart = (smart + extra);
					smart++

								}
								}

			}
			})
			}<|endoftext|>


<commit_before>/*
---

name: PictureSlider

description: Animated picture slider.

license: MIT-style

authors:
- Peter Kuma

requires:
- core/1.4.3: [Class, Element.Style, Fx.Tween]

provides: PictureSlider

...
*/

var PictureSlider = new Class({
	Implements: [Options,Events],

	options: {
		arrows: 'medium',
		duration: 'short',
		center: true,
		controls: {
			opacity: 0.8,
			duration: 'short',
		},
		caption: {
			opacity: 0.8,
			duration: 'short',
		},
		text: {
			duration: 200,
		}
	},

	initialize: function(obj, images, options) {
		this.setOptions(options);
		var this_ = this;

		this.images = [];
		this.current = null;

		this.obj = obj;
		obj.addClass('picture-slider');

		/* Determine width and height. */
		this.width = obj.getStyle('width').toInt();
		this.height = obj.getStyle('height').toInt();

		/* Sheet. */
		this.sheet = document.createElement('div');
		this.sheet.addClass('ps-sheet');
		this.sheet.setStyle('width', this.width);
		this.sheet.setStyle('height', this.height);
		obj.appendChild(this.sheet);

		/* Place images on the sheet. */
		images.each(function(image) { this_.appendImage(image); });

		/* Bottom description panel. */
		this.caption = document.createElement('div');
		this.caption.addClass('ps-caption');
		this.caption.setStyle('height', 0);
		this.caption.setStyle('opacity', this.options.caption.opacity);
		this.caption.p = document.createElement('p');
		this.caption.p.set('tween', {duration: this.options.caption.duration});
		this.caption.appendChild(this.caption.p);
		this.obj.appendChild(this.caption);

		/* Controls. */
		this.controls = document.createElement('div');
		this.controls.addClass('ps-controls');
		this.controls.setStyle('width', this.width);
		this.controls.setStyle('height', this.height);
		this.controls.setStyle('opacity', 0);
		this.controls.set('tween',  {duration: this.options.controls.duration});
		this.obj.appendChild(this.controls);

		this.leftArrow = document.createElement('div');
		this.leftArrow.addClass('ps-left');
		if (this.options.arrows)
			this.leftArrow.addClass('ps-left-'+this.options.arrows);
		//this.leftArrow.setStyle('width', this.width*0.3);
		this.leftArrow.setStyle('height', this.height);
		this.leftArrow.setStyle('opacity', 0);
		this.leftArrow.addEvent('click', function() { this_.left(); });
		this.controls.appendChild(this.leftArrow);

		this.rightArrow = document.createElement('div');
		this.rightArrow.addClass('ps-right');
		if (this.options.arrows)
			this.rightArrow.addClass('ps-right-'+this.options.arrows);
		//this.rightArrow.setStyle('width', this.width*0.3);
		this.rightArrow.setStyle('height', this.height);
		this.rightArrow.setStyle('opacity', 0);
		this.rightArrow.addEvent('click', function() { this_.right(); });
		this.controls.appendChild(this.rightArrow);

		this.obj.addEvent('mouseover', function() { this_.activateControls(); });
		this.obj.addEvent('mouseout', function() { this_.deactivateControls(); });

		/* Keyboard control. */
		this.kb = null;
		if (typeof Keyboard != 'undefined') {
			this.kb = new Keyboard({
				defaultEventType: 'keydown',
				events: {
					'left': function() { this_.left(); },
					'right': function() { this_.right(); },
				},
			});
			this.kb.activate();
		}

		/* Switch to the first image. */
		this.switchTo(0);
	},

	activateControls: function() {
		this.controls.fade(this.options.controls.opacity);
		/* The last to get focus gets the keyboard. */
		if (this.kb) this.kb.activate();
	},

	deactivateControls: function() {
		this.controls.fade(0);
	},

	/*
	 * Switches to the image number n.
	 */
	switchTo: function(n) {
		if (!(n >= 0 && n < this.images.length))
			return this.current;

		this.current = this.images[n];

		var fx = new Fx.Tween(this.sheet, {
			duration: this.options.duration,
			property: 'left'
		});
		fx.start(-n*this.width);

		/* If at the beginning, hide left arrow. */
		if (n == 0)
			this.leftArrow.fade(0);
		else
			this.leftArrow.fade(1);

		/* If at the end, hide right arrow. */
		if (n == this.images.length - 1)
			this.rightArrow.fade(0);
		else
			this.rightArrow.fade(1);

		this.setCaption(this.current.caption);
		this.n = n;

		this.fireEvent('change', this.current);

		return this.current;
	},

	/*
	 * Switches to the previous image.
	 */
	left: function() {
		return this.switchTo(this.n - 1);
	},

	/*
	 * Switches to the next image.
	 */
	right: function() {
		return this.switchTo(this.n + 1);
	},

	/*
	 * Appends image to the end.
	 */
	appendImage: function(image) {
		var frame;
		if (image.link) {
			frame = document.createElement('a');
			frame.href = image.link;
		} else {
			frame = document.createElement('div');
		}
		frame.addClass('ps-frame');
		frame.setStyle('left', this.width*this.images.length);
		frame.setStyle('width', this.width);
		frame.setStyle('height', this.height);
		this.sheet.appendChild(frame);

		var center = this.options.center;
		if (typeof image.center != 'undefined')
			center = image.center;

		if (image.src) {
			var img = document.createElement('img');
			img.addClass('ps-frame-image');
			img.src = image.src;
			frame.appendChild(img);
			if (img.width/img.height > this.width/this.height) {
				img.setStyle('width', this.width);
			} else {
				img.setStyle('height', this.height);
			}
			if (center) {
				var h = img.getStyle('height').toInt();
				img.setStyle('top', (this.height-h)/2);
			}
		}

		if (image.content) {
			var content = document.createElement('div');
			content.addClass('ps-frame-content');
			frame.appendChild(content);
			if (typeof image.content == 'string') {
				content.innerHTML = image.content;
			}
			var w = content.getStyle('width').toInt();
			var pad = content.getStyle('padding-left').toInt() +
		    		  content.getStyle('padding-right').toInt();
		 	var mar = content.getStyle('margin-left').toInt() +
		   			  content.getStyle('margin-right').toInt();
			content.setStyle('left', (this.width-w-pad-mar)/2);
			if (center) {
				var h = content.getStyle('height').toInt();
				var pad = content.getStyle('padding-top').toInt() +
		    			  content.getStyle('padding-bottom').toInt();
		 		var mar = content.getStyle('margin-top').toInt() +
		   				  content.getStyle('margin-bottom').toInt();
				content.setStyle('top', (this.height-h-pad-mar)/2);
			}
		}

		this.images.push(image);
	},

	/*
	 * Set caption to text.
	 */
	setCaption: function(text) {
		var fx = new Fx.Tween(this.caption, {
			duration: this.options.text.duration,
			property: 'height',
			link: 'chain',
		});

		if (text) {
			this_ = this;
			fx.addEvent('complete', function() {
				this_.caption.p.innerHTML = text;
				this_.caption.p.fade(1);
			});
			this.caption.p.fade(0);
			var tmpcaption = document.createElement('div');
			tmpcaption.addClass('ps-caption');
			tmpcaption.setStyle('visibility', 'hidden');
			tmpcaption.p = document.createElement('p');
			tmpcaption.p.innerHTML = text;
			tmpcaption.appendChild(tmpcaption.p);
			this.obj.appendChild(tmpcaption);
			h = tmpcaption.getStyle('height');
			this.obj.removeChild(tmpcaption);
			fx.start(h);
		} else {
			this.caption.p.innerHTML = '';
			this.caption.p.fade(0);
			fx.start(0);
		}
	},
});

/*
 * Turn obj into an interactive image gallery.
 *
 * Example:
 *
 *

 *
 */
function gallery(obj, options) {
	if (!options.images)
		options.images = new Array();

	obj.addClass('gallery');

	/* Sheet. */
	var sheet = document.createElement('div');
	sheet.addClass('gallery-sheet');

	var width = obj.getStyle('width').toInt();
	var height = obj.getStyle('height').toInt();

	sheet.setStyle('width', width);
	sheet.setStyle('height', height);

	/* Place images on the sheet. */
	var offset = 0;
	options.images.each(function(image) {
		var wrapper = document.createElement('div');
		wrapper.addClass('gallery-wrapper');
		wrapper.setStyle('position', 'absolute');
		wrapper.setStyle('top', 0);
		wrapper.setStyle('left', offset);
		wrapper.setStyle('width', width);
		wrapper.setStyle('height', height);
		sheet.appendChild(wrapper);

		var img = document.createElement('img');
		img.src = image.src;
		img.height = height;
		img.setStyle('display', 'block');
		img.setStyle('margin', '0 auto');
		wrapper.appendChild(img);

		offset += width;
	});
	obj.appendChild(sheet);

	/* Bottom description panel. */
	var desc = document.createElement('div');
	desc.addClass('gallery-desc');
	desc.setStyle('height', 0);
	desc.setStyle('opacity', 0.7);
	desc.p = document.createElement('p');
	desc.set('tween', {duration: 'short'});
	desc.appendChild(desc.p);

	function updateDesc(n) {
		var descFx = new Fx.Tween(desc, {
			duration: 300,
			property: 'height',
			link: 'chain',
		});

		if (options.images.length > n && options.images[n].desc) {
			/* Alter height. */
			descFx.addEvent('complete', function() {
				desc.p.innerHTML = options.images[n].desc;
				desc.p.fade(1);
			});
			desc.p.fade(0);
			var tmpdesc = document.createElement('div');
			tmpdesc.addClass('gallery-desc');
			tmpdesc.setStyle('visibility', 'hidden');
			tmpdesc.p = document.createElement('p');
			tmpdesc.p.innerHTML = options.images[n].desc;
			tmpdesc.appendChild(tmpdesc.p);
			obj.appendChild(tmpdesc);
			h = tmpdesc.getStyle('height');
			obj.removeChild(tmpdesc);
			descFx.start(h);
		} else {
			desc.p.innerHTML = '';
			desc.p.fade(0);
			descFx.start(0);
		}
	}
	updateDesc(0);

	/* Image switching (left and right arrows). */
	var n = 0;

	var mouseover = 0;

	function switchTo(n) {
		var fx = new Fx.Tween(sheet, {
			duration: 'short',
			property: 'left'
		});
		fx.start(-n*width);
		updateDesc(n);
		if (n == 0)
			leftArrow.fade(0);
		else
			leftArrow.fade(mouseover*0.8);
		if (n == options.images.length - 1)
			rightArrow.fade(0);
		else
			rightArrow.fade(mouseover*0.8);
	}

	var leftArrow = document.createElement('div');
	leftArrow.addClass('gallery-left');
	leftArrow.setStyle('width', width*0.3);
	leftArrow.setStyle('height', height);
	leftArrow.setStyle('opacity', 0);
	leftArrow.addEvent('click', function() {
		if (n > 0) switchTo(n = n-1);
	});
	obj.appendChild(leftArrow);

	var rightArrow = document.createElement('div');
	rightArrow.addClass('gallery-right');
	rightArrow.setStyle('width', width*0.3);
	rightArrow.setStyle('height', height);
	rightArrow.setStyle('opacity', 0);
	rightArrow.addEvent('click', function() {
		if (n < options.images.length - 1) switchTo(n = n+1);
	});

	rightArrow.set('tween', {duration: 'short'});
	leftArrow.set('tween',  {duration: 'short'});

	obj.addEvent('mouseover', function() {
		mouseover = 1;
		if (n > 0)
			leftArrow.fade(0.8);
		if (n < options.images.length - 1)
			rightArrow.fade(0.8);
	});

	obj.addEvent('mouseout', function() {
		mouseover = 0;
		leftArrow.fade(0);
		rightArrow.fade(0);
	});

	/* Keyboard control. */
	if (typeof Keyboard != 'undefined') {
		var kb = new Keyboard({
			defaultEventType: 'keydown',
			events: {
				'left': function() {
					if (n > 0) switchTo(n = n-1);
				},
				'right': function() {
					if (n < options.images.length - 1) switchTo(n = n+1);
				}
			}
		});
		kb.activate();
	}

	obj.appendChild(desc);
	obj.appendChild(leftArrow);
	obj.appendChild(rightArrow);
}
<commit_msg>Fix vertical centering of content.<commit_after>/*
---

name: PictureSlider

description: Animated picture slider.

license: MIT-style

authors:
- Peter Kuma

requires:
- core/1.4.3: [Class, Element.Style, Fx.Tween]

provides: PictureSlider

...
*/

var PictureSlider = new Class({
	Implements: [Options,Events],

	options: {
		arrows: 'medium',
		duration: 'short',
		center: true,
		controls: {
			opacity: 0.8,
			duration: 'short',
		},
		caption: {
			opacity: 0.8,
			duration: 'short',
		},
		text: {
			duration: 200,
		}
	},

	initialize: function(obj, images, options) {
		this.setOptions(options);
		var this_ = this;

		this.images = [];
		this.current = null;

		this.obj = obj;
		obj.addClass('picture-slider');

		/* Determine width and height. */
		this.width = obj.getStyle('width').toInt();
		this.height = obj.getStyle('height').toInt();

		/* Sheet. */
		this.sheet = document.createElement('div');
		this.sheet.addClass('ps-sheet');
		this.sheet.setStyle('width', this.width);
		this.sheet.setStyle('height', this.height);
		obj.appendChild(this.sheet);

		/* Place images on the sheet. */
		images.each(function(image) { this_.appendImage(image); });

		/* Bottom description panel. */
		this.caption = document.createElement('div');
		this.caption.addClass('ps-caption');
		this.caption.setStyle('height', 0);
		this.caption.setStyle('opacity', this.options.caption.opacity);
		this.caption.p = document.createElement('p');
		this.caption.p.set('tween', {duration: this.options.caption.duration});
		this.caption.appendChild(this.caption.p);
		this.obj.appendChild(this.caption);

		/* Controls. */
		this.controls = document.createElement('div');
		this.controls.addClass('ps-controls');
		this.controls.setStyle('width', this.width);
		this.controls.setStyle('height', this.height);
		this.controls.setStyle('opacity', 0);
		this.controls.set('tween',  {duration: this.options.controls.duration});
		this.obj.appendChild(this.controls);

		this.leftArrow = document.createElement('div');
		this.leftArrow.addClass('ps-left');
		if (this.options.arrows)
			this.leftArrow.addClass('ps-left-'+this.options.arrows);
		//this.leftArrow.setStyle('width', this.width*0.3);
		this.leftArrow.setStyle('height', this.height);
		this.leftArrow.setStyle('opacity', 0);
		this.leftArrow.addEvent('click', function() { this_.left(); });
		this.controls.appendChild(this.leftArrow);

		this.rightArrow = document.createElement('div');
		this.rightArrow.addClass('ps-right');
		if (this.options.arrows)
			this.rightArrow.addClass('ps-right-'+this.options.arrows);
		//this.rightArrow.setStyle('width', this.width*0.3);
		this.rightArrow.setStyle('height', this.height);
		this.rightArrow.setStyle('opacity', 0);
		this.rightArrow.addEvent('click', function() { this_.right(); });
		this.controls.appendChild(this.rightArrow);

		this.obj.addEvent('mouseover', function() { this_.activateControls(); });
		this.obj.addEvent('mouseout', function() { this_.deactivateControls(); });

		/* Keyboard control. */
		this.kb = null;
		if (typeof Keyboard != 'undefined') {
			this.kb = new Keyboard({
				defaultEventType: 'keydown',
				events: {
					'left': function() { this_.left(); },
					'right': function() { this_.right(); },
				},
			});
			this.kb.activate();
		}

		/* Switch to the first image. */
		this.switchTo(0);
	},

	activateControls: function() {
		this.controls.fade(this.options.controls.opacity);
		/* The last to get focus gets the keyboard. */
		if (this.kb) this.kb.activate();
	},

	deactivateControls: function() {
		this.controls.fade(0);
	},

	/*
	 * Switches to the image number n.
	 */
	switchTo: function(n) {
		if (!(n >= 0 && n < this.images.length))
			return this.current;

		this.current = this.images[n];

		var fx = new Fx.Tween(this.sheet, {
			duration: this.options.duration,
			property: 'left'
		});
		fx.start(-n*this.width);

		/* If at the beginning, hide left arrow. */
		if (n == 0)
			this.leftArrow.fade(0);
		else
			this.leftArrow.fade(1);

		/* If at the end, hide right arrow. */
		if (n == this.images.length - 1)
			this.rightArrow.fade(0);
		else
			this.rightArrow.fade(1);

		this.setCaption(this.current.caption);
		this.n = n;

		this.fireEvent('change', this.current);

		return this.current;
	},

	/*
	 * Switches to the previous image.
	 */
	left: function() {
		return this.switchTo(this.n - 1);
	},

	/*
	 * Switches to the next image.
	 */
	right: function() {
		return this.switchTo(this.n + 1);
	},

	/*
	 * Appends image to the end.
	 */
	appendImage: function(image) {
		var frame;
		if (image.link) {
			frame = document.createElement('a');
			frame.href = image.link;
		} else {
			frame = document.createElement('div');
		}
		frame.addClass('ps-frame');
		frame.setStyle('left', this.width*this.images.length);
		frame.setStyle('width', this.width);
		frame.setStyle('height', this.height);
		this.sheet.appendChild(frame);

		var center = this.options.center;
		if (typeof image.center != 'undefined')
			center = image.center;

		if (image.src) {
			var img = document.createElement('img');
			img.addClass('ps-frame-image');
			img.src = image.src;
			frame.appendChild(img);
			if (img.width/img.height > this.width/this.height) {
				img.setStyle('width', this.width);
			} else {
				img.setStyle('height', this.height);
			}
			if (center) {
				var h = img.getStyle('height').toInt();
				img.setStyle('top', (this.height-h)/2);
			}
		}

		if (image.content) {
			var content = document.createElement('div');
			content.addClass('ps-frame-content');
			frame.appendChild(content);
			if (typeof image.content == 'string') {
				content.innerHTML = image.content;
			}
			var w = content.getStyle('width').toInt();
			var pad = content.getStyle('padding-left').toInt() +
		    		  content.getStyle('padding-right').toInt();
		 	var mar = content.getStyle('margin-left').toInt() +
		   			  content.getStyle('margin-right').toInt();
			content.setStyle('left', (this.width-w-pad-mar)/2);
			if (center) {
				var h = content.getStyle('height').toInt();
				var pad = content.getStyle('padding-top').toInt() +
		    			  content.getStyle('padding-bottom').toInt();
		 		var mar = content.getStyle('margin-top').toInt() +
		   				  content.getStyle('margin-bottom').toInt();
		   		var top = (this.height-h-pad-mar)/2;
		   		if (top > 0)
					content.setStyle('top', (this.height-h-pad-mar)/2);
			}
		}

		this.images.push(image);
	},

	/*
	 * Set caption to text.
	 */
	setCaption: function(text) {
		var fx = new Fx.Tween(this.caption, {
			duration: this.options.text.duration,
			property: 'height',
			link: 'chain',
		});

		if (text) {
			this_ = this;
			fx.addEvent('complete', function() {
				this_.caption.p.innerHTML = text;
				this_.caption.p.fade(1);
			});
			this.caption.p.fade(0);
			var tmpcaption = document.createElement('div');
			tmpcaption.addClass('ps-caption');
			tmpcaption.setStyle('visibility', 'hidden');
			tmpcaption.p = document.createElement('p');
			tmpcaption.p.innerHTML = text;
			tmpcaption.appendChild(tmpcaption.p);
			this.obj.appendChild(tmpcaption);
			h = tmpcaption.getStyle('height');
			this.obj.removeChild(tmpcaption);
			fx.start(h);
		} else {
			this.caption.p.innerHTML = '';
			this.caption.p.fade(0);
			fx.start(0);
		}
	},
});

/*
 * Turn obj into an interactive image gallery.
 *
 * Example:
 *
 *

 *
 */
function gallery(obj, options) {
	if (!options.images)
		options.images = new Array();

	obj.addClass('gallery');

	/* Sheet. */
	var sheet = document.createElement('div');
	sheet.addClass('gallery-sheet');

	var width = obj.getStyle('width').toInt();
	var height = obj.getStyle('height').toInt();

	sheet.setStyle('width', width);
	sheet.setStyle('height', height);

	/* Place images on the sheet. */
	var offset = 0;
	options.images.each(function(image) {
		var wrapper = document.createElement('div');
		wrapper.addClass('gallery-wrapper');
		wrapper.setStyle('position', 'absolute');
		wrapper.setStyle('top', 0);
		wrapper.setStyle('left', offset);
		wrapper.setStyle('width', width);
		wrapper.setStyle('height', height);
		sheet.appendChild(wrapper);

		var img = document.createElement('img');
		img.src = image.src;
		img.height = height;
		img.setStyle('display', 'block');
		img.setStyle('margin', '0 auto');
		wrapper.appendChild(img);

		offset += width;
	});
	obj.appendChild(sheet);

	/* Bottom description panel. */
	var desc = document.createElement('div');
	desc.addClass('gallery-desc');
	desc.setStyle('height', 0);
	desc.setStyle('opacity', 0.7);
	desc.p = document.createElement('p');
	desc.set('tween', {duration: 'short'});
	desc.appendChild(desc.p);

	function updateDesc(n) {
		var descFx = new Fx.Tween(desc, {
			duration: 300,
			property: 'height',
			link: 'chain',
		});

		if (options.images.length > n && options.images[n].desc) {
			/* Alter height. */
			descFx.addEvent('complete', function() {
				desc.p.innerHTML = options.images[n].desc;
				desc.p.fade(1);
			});
			desc.p.fade(0);
			var tmpdesc = document.createElement('div');
			tmpdesc.addClass('gallery-desc');
			tmpdesc.setStyle('visibility', 'hidden');
			tmpdesc.p = document.createElement('p');
			tmpdesc.p.innerHTML = options.images[n].desc;
			tmpdesc.appendChild(tmpdesc.p);
			obj.appendChild(tmpdesc);
			h = tmpdesc.getStyle('height');
			obj.removeChild(tmpdesc);
			descFx.start(h);
		} else {
			desc.p.innerHTML = '';
			desc.p.fade(0);
			descFx.start(0);
		}
	}
	updateDesc(0);

	/* Image switching (left and right arrows). */
	var n = 0;

	var mouseover = 0;

	function switchTo(n) {
		var fx = new Fx.Tween(sheet, {
			duration: 'short',
			property: 'left'
		});
		fx.start(-n*width);
		updateDesc(n);
		if (n == 0)
			leftArrow.fade(0);
		else
			leftArrow.fade(mouseover*0.8);
		if (n == options.images.length - 1)
			rightArrow.fade(0);
		else
			rightArrow.fade(mouseover*0.8);
	}

	var leftArrow = document.createElement('div');
	leftArrow.addClass('gallery-left');
	leftArrow.setStyle('width', width*0.3);
	leftArrow.setStyle('height', height);
	leftArrow.setStyle('opacity', 0);
	leftArrow.addEvent('click', function() {
		if (n > 0) switchTo(n = n-1);
	});
	obj.appendChild(leftArrow);

	var rightArrow = document.createElement('div');
	rightArrow.addClass('gallery-right');
	rightArrow.setStyle('width', width*0.3);
	rightArrow.setStyle('height', height);
	rightArrow.setStyle('opacity', 0);
	rightArrow.addEvent('click', function() {
		if (n < options.images.length - 1) switchTo(n = n+1);
	});

	rightArrow.set('tween', {duration: 'short'});
	leftArrow.set('tween',  {duration: 'short'});

	obj.addEvent('mouseover', function() {
		mouseover = 1;
		if (n > 0)
			leftArrow.fade(0.8);
		if (n < options.images.length - 1)
			rightArrow.fade(0.8);
	});

	obj.addEvent('mouseout', function() {
		mouseover = 0;
		leftArrow.fade(0);
		rightArrow.fade(0);
	});

	/* Keyboard control. */
	if (typeof Keyboard != 'undefined') {
		var kb = new Keyboard({
			defaultEventType: 'keydown',
			events: {
				'left': function() {
					if (n > 0) switchTo(n = n-1);
				},
				'right': function() {
					if (n < options.images.length - 1) switchTo(n = n+1);
				}
			}
		});
		kb.activate();
	}

	obj.appendChild(desc);
	obj.appendChild(leftArrow);
	obj.appendChild(rightArrow);
}
<|endoftext|>


<commit_before>
define(function () {
  return function (c) {
    c.c('Tile', {

//
// Tile component
//
// Responsible for:
//  moving itself down;
//  exploding and removing itself;
//  position existing

      init: function () {
        this.addComponent('2D, Canvas');

        this.w = TILE_WIDTH;
        this.h = TILE_HEIGHT;
      },

//
// Unique ID of the component instance (entity)

      id: function () {
        return this[0];
      },

//
// Tiles can move downwards or sideways
// Presumably, this function will be called on every game loop

      moveTo: function (row, col) {
        console.log(this.id(), 'moveTo', arguments);

        this._tile.row = row;
        this._tile.col = col;

        this.z = row;
        this.attr(this.position());
      },

//
// Explode and remove the tile

      explode: function () {
        console.log(this.id(), 'explode', arguments);
        this.destroy();
      },

//
// Get pixel position based on given ROW/COL

      position: function () {
        var x = this._tile.col * TILE_INNER_WIDTH;
            y = this._tile.row * TILE_INNER_HEIGHT;

        return {
          x: x + 1,
          y: y + 1
        };
      },

//
// Convinient function to create a new component

      create: function (tile) {
        this._tile = tile;

        this.addComponent(tile.ctype());
        this.moveTo(tile.row, tile.col);
        return this;
      }
    });
  };
});

<commit_msg>y position for tiles fixed<commit_after>
define(function () {
  return function (c) {
    c.c('Tile', {

//
// Tile component
//
// Responsible for:
//  moving itself down;
//  exploding and removing itself;
//  position existing

      init: function () {
        this.addComponent('2D, Canvas');

        this.w = TILE_WIDTH;
        this.h = TILE_HEIGHT;
      },

//
// Unique ID of the component instance (entity)

      id: function () {
        return this[0];
      },

//
// Tiles can move downwards or sideways
// Presumably, this function will be called on every game loop

      moveTo: function (row, col) {
        console.log(this.id(), 'moveTo', arguments);

        this._tile.row = row;
        this._tile.col = col;

        this.z = row;
        this.attr(this.position());
      },

//
// Explode and remove the tile

      explode: function () {
        console.log(this.id(), 'explode', arguments);
        this.destroy();
      },

//
// Get pixel position based on given ROW/COL

      position: function () {
        var x = this._tile.col * TILE_INNER_WIDTH;
            y = this._tile.row * TILE_INNER_HEIGHT;

        return {
          x: x + 1,
          y: y
        };
      },

//
// Convinient function to create a new component

      create: function (tile) {
        this._tile = tile;

        this.addComponent(tile.ctype());
        this.moveTo(tile.row, tile.col);
        return this;
      }
    });
  };
});

<|endoftext|>


<commit_before>import React from 'react'
import { useSheet } from '../jss'

import Header from './header'
import Footer from './footer'
import Form from './Form'

const styles = {
}

const App = React.createClass({
  render() {
    return (

              {this.props.children}

    )
  }
})

export default useSheet(App, styles)
<commit_msg>link to form page with params<commit_after>import React from 'react'
import { useSheet } from '../jss'

import Header from './header'
import Footer from './footer'
import Form from './Form'
import { Link } from 'react-router'

const styles = {
}

const App = React.createClass({
  render() {
    return (

                <Link to="/">TOP</Link>

                <Link to="/watilde/issue-json">watilde/issue-json</Link>

              {this.props.children}

    )
  }
})

export default useSheet(App, styles)
<|endoftext|>


<commit_before>var ABILITIES_ADV = [
    'Air Lock',
    'Battle Armor',
    'Blaze',
    'Chlorophyll',
    'Clear Body',
    'Cloud Nine',
    'Drizzle',
    'Drought',
    'Flash Fire',
    'Flash Fire (activated)',
    'Forecast',
    'Guts',
    'Huge Power',
    'Hustle',
    'Hyper Cutter',
    'Intimidate',
    'Levitate',
    'Lightningrod',
    'Marvel Scale',
    'Overgrow',
    'Pure Power',
    'Rain Dish',
    'Sand Stream',
    'Sand Veil',
    'Shell Armor',
    'Soundproof',
    'Swarm',
    'Swift Swim',
    'Thick Fat',
    'Torrent',
    'Volt Absorb',
    'Water Absorb',
    'White Smoke',
    'Wonder Guard'
];

var ABILITIES_DPP = ABILITIES_ADV.concat([
    'Adaptability',
    'Bad Dreams',
    'Download',
    'Dry Skin',
    'Filter',
    'Flower Gift',
    'Heatproof',
    'Ice Body',
    'Iron Fist',
    'Klutz',
    'Magic Guard',
    'Mold Breaker',
    'Motor Drive',
    'Normalize',
    'Poison Heal',
    'Reckless',
    'Scrappy',
    'Simple',
    'Skill Link',
    'Slow Start',
    'Sniper',
    'Snow Cloak',
    'Snow Warning',
    'Solar Power',
    'Solid Rock',
    'Storm Drain',
    'Technician',
    'Tinted Lens',
    'Unaware'
]);

var ABILITIES_BW = ABILITIES_DPP.concat([
    'Analytic',
    'Contrary',
    'Defeatist',
    'Defiant',
    'Flare Boost',
    'Infiltrator',
    'Multiscale',
    'Overcoat',
    'Sand Force',
    'Sand Rush',
    'Sap Sipper',
    'Sheer Force',
    'Teravolt',
    'Toxic Boost',
    'Turboblaze',
    'Unnerve'
]);

var ABILITIES_XY = ABILITIES_BW.concat([
    'Aerilate',
    'Aura Break',
    'Bulletproof',
    'Dark Aura',
    'Fairy Aura',
    'Fur Coat',
    'Mega Launcher',
    'Parental Bond',
    'Pixilate',
    'Protean',
    'Refrigerate',
    'Strong Jaw',
    'Tough Claws'
]);

ABILITIES_XY.splice(ABILITIES_XY.indexOf('Lightningrod'), 1, 'Lightning Rod');
<commit_msg>Don't show Lightningrod or Storm Drain until BW.<commit_after>var ABILITIES_ADV = [
    'Air Lock',
    'Battle Armor',
    'Blaze',
    'Chlorophyll',
    'Clear Body',
    'Cloud Nine',
    'Drizzle',
    'Drought',
    'Flash Fire',
    'Flash Fire (activated)',
    'Forecast',
    'Guts',
    'Huge Power',
    'Hustle',
    'Hyper Cutter',
    'Intimidate',
    'Levitate',
    'Marvel Scale',
    'Overgrow',
    'Pure Power',
    'Rain Dish',
    'Sand Stream',
    'Sand Veil',
    'Shell Armor',
    'Soundproof',
    'Swarm',
    'Swift Swim',
    'Thick Fat',
    'Torrent',
    'Volt Absorb',
    'Water Absorb',
    'White Smoke',
    'Wonder Guard'
];

var ABILITIES_DPP = ABILITIES_ADV.concat([
    'Adaptability',
    'Bad Dreams',
    'Download',
    'Dry Skin',
    'Filter',
    'Flower Gift',
    'Heatproof',
    'Ice Body',
    'Iron Fist',
    'Klutz',
    'Magic Guard',
    'Mold Breaker',
    'Motor Drive',
    'Normalize',
    'Poison Heal',
    'Reckless',
    'Scrappy',
    'Simple',
    'Skill Link',
    'Slow Start',
    'Sniper',
    'Snow Cloak',
    'Snow Warning',
    'Solar Power',
    'Solid Rock',
    'Technician',
    'Tinted Lens',
    'Unaware'
]);

var ABILITIES_BW = ABILITIES_DPP.concat([
    'Analytic',
    'Contrary',
    'Defeatist',
    'Defiant',
    'Flare Boost',
    'Infiltrator',
    'Lightningrod',
    'Multiscale',
    'Overcoat',
    'Sand Force',
    'Sand Rush',
    'Sap Sipper',
    'Sheer Force',
    'Storm Drain',
    'Teravolt',
    'Toxic Boost',
    'Turboblaze',
    'Unnerve'
]);

var ABILITIES_XY = ABILITIES_BW.concat([
    'Aerilate',
    'Aura Break',
    'Bulletproof',
    'Dark Aura',
    'Fairy Aura',
    'Fur Coat',
    'Mega Launcher',
    'Parental Bond',
    'Pixilate',
    'Protean',
    'Refrigerate',
    'Strong Jaw',
    'Tough Claws'
]);

ABILITIES_XY.splice(ABILITIES_XY.indexOf('Lightningrod'), 1, 'Lightning Rod');
<|endoftext|>


<commit_before>/**
 *	@author zz85 / http://twitter.com/blurspline / http://www.lab4games.net/zz85/blog
 *
 *	A general perpose camera, for setting FOV, Lens Focal Length,
 *		and switching between perspective and orthographic views easily.
 *		Use this only if you do not wish to manage
 *		both a Orthographic and Perspective Camera
 *
 */

THREE.CombinedCamera = function ( width, height, fov, near, far, orthoNear, orthoFar ) {

	THREE.Camera.call( this );

	this.fov = fov;
	this.aspect = width / height;

	this.left = - width / 2;
	this.right = width / 2;
	this.top = height / 2;
	this.bottom = - height / 2;

	// We could also handle the projectionMatrix internally, but just wanted to test nested camera objects

	this.cameraO = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 	orthoNear, orthoFar );
	this.cameraP = new THREE.PerspectiveCamera( fov, width / height, near, far );

	this.zoom = 1;

	this.toPerspective();

};

THREE.CombinedCamera.prototype = Object.create( THREE.Camera.prototype );
THREE.CombinedCamera.prototype.constructor = THREE.CombinedCamera;

THREE.CombinedCamera.prototype.toPerspective = function () {

	// Switches to the Perspective Camera

	this.cameraP.near = this.near;
	this.cameraP.far = this.far;

	this.cameraP.fov =  this.fov / this.zoom ;

	this.cameraP.aspect = this.aspect;

	this.cameraP.updateProjectionMatrix();

	this.projectionMatrix = this.cameraP.projectionMatrix;

	this.inPerspectiveMode = true;
	this.inOrthographicMode = false;

};

THREE.CombinedCamera.prototype.toOrthographic = function () {

	// Switches to the Orthographic camera estimating viewport from Perspective

	var fov = this.fov;
	var aspect = this.aspect;
	var near = this.near;
	var far = this.far;

	// The size that we set is the mid plane of the viewing frustum

	var halfHeight = Math.tan( fov * Math.PI / 180 / 2 );
	var halfWidth = halfHeight * aspect;

	halfHeight /= this.zoom;
	halfWidth /= this.zoom;

	this.cameraO.left = - halfWidth;
	this.cameraO.right = halfWidth;
	this.cameraO.top = halfHeight;
	this.cameraO.bottom = - halfHeight;
	this.cameraO.zoom = this.zoom;
	// this.cameraO.left = -farHalfWidth;
	// this.cameraO.right = farHalfWidth;
	// this.cameraO.top = farHalfHeight;
	// this.cameraO.bottom = -farHalfHeight;

	// this.cameraO.left = this.left / this.zoom;
	// this.cameraO.right = this.right / this.zoom;
	// this.cameraO.top = this.top / this.zoom;
	// this.cameraO.bottom = this.bottom / this.zoom;

	this.cameraO.updateProjectionMatrix();

	this.near = this.cameraO.near;
	this.far = this.cameraO.far;
	this.projectionMatrix = this.cameraO.projectionMatrix;

	this.inPerspectiveMode = false;
	this.inOrthographicMode = true;

};

THREE.CombinedCamera.prototype.setSize = function( width, height ) {

	this.cameraP.aspect = width / height;
	this.left = - width / 2;
	this.right = width / 2;
	this.top = height / 2;
	this.bottom = - height / 2;

};

THREE.CombinedCamera.prototype.setFov = function( fov ) {

	this.fov = fov;

	if ( this.inPerspectiveMode ) {

		this.toPerspective();

	} else {

		this.toOrthographic();

	}

};

// For maintaining similar API with PerspectiveCamera

THREE.CombinedCamera.prototype.updateProjectionMatrix = function() {

	if ( this.inPerspectiveMode ) {

		this.toPerspective();

	} else {

		this.toPerspective();
		this.toOrthographic();

	}

};

/*
* Uses Focal Length (in mm) to estimate and set FOV
* 35mm (full frame) camera is used if frame size is not specified;
* Formula based on http://www.bobatkins.com/photography/technical/field_of_view.html
*/
THREE.CombinedCamera.prototype.setLens = function ( focalLength, filmGauge ) {

	if ( filmGauge === undefined ) filmGauge = 35;

	var vExtentSlope = 0.5 * filmGauge /
			( focalLength * Math.max( this.cameraP.aspect, 1 ) );

	var fov = THREE.Math.RAD2DEG * 2 * Math.atan( vExtentSlope );

	this.setFov( fov );

	return fov;

};

THREE.CombinedCamera.prototype.setZoom = function( zoom ) {

	this.zoom = zoom;

	if ( this.inPerspectiveMode ) {

		this.toPerspective();

	} else {

		this.toOrthographic();

	}

};

THREE.CombinedCamera.prototype.toFrontView = function() {

	this.rotation.x = 0;
	this.rotation.y = 0;
	this.rotation.z = 0;

	// should we be modifing the matrix instead?

};

THREE.CombinedCamera.prototype.toBackView = function() {

	this.rotation.x = 0;
	this.rotation.y = Math.PI;
	this.rotation.z = 0;

};

THREE.CombinedCamera.prototype.toLeftView = function() {

	this.rotation.x = 0;
	this.rotation.y = - Math.PI / 2;
	this.rotation.z = 0;

};

THREE.CombinedCamera.prototype.toRightView = function() {

	this.rotation.x = 0;
	this.rotation.y = Math.PI / 2;
	this.rotation.z = 0;

};

THREE.CombinedCamera.prototype.toTopView = function() {

	this.rotation.x = - Math.PI / 2;
	this.rotation.y = 0;
	this.rotation.z = 0;

};

THREE.CombinedCamera.prototype.toBottomView = function() {

	this.rotation.x = Math.PI / 2;
	this.rotation.y = 0;
	this.rotation.z = 0;

};
<commit_msg>add some camera interfaces for combinedcamera<commit_after>/**
 *	@author zz85 / http://twitter.com/blurspline / http://www.lab4games.net/zz85/blog
 *
 *		A general perpose camera, for setting FOV, Lens Focal Length,
 *		and switching between perspective and orthographic views easily.
 *		Use this only if you do not wish to manage
 *		both a Orthographic and Perspective Camera
 *
 */

THREE.CombinedCamera = function ( width, height, fov, near, far) {

	THREE.Camera.call( this );
	// perspective
	this.fov = fov;
	this.far = far;
	this.near = near;
	//orthographic
	this.left = - width / 2;
	this.right = width / 2;
	this.top = height / 2;
	this.bottom = - height / 2;

	this.aspect =  width / height;
	this.zoom = 1;
	this.view = null;
	this.hyperfocusOffset = 0;
	this.hyperfocusScale = 0.5;
	// We could also handle the projectionMatrix internally, but just wanted to test nested camera objects

	this.cameraO = new THREE.OrthographicCamera( this.left, this.right, this.top, this.bottom, this.near, this.far );
	this.cameraP = new THREE.PerspectiveCamera( this.fov, this.aspect, this.near, this.far );

	this.toPerspective();

};

THREE.CombinedCamera.prototype = Object.create( THREE.Camera.prototype );
THREE.CombinedCamera.prototype.constructor = THREE.CombinedCamera;

THREE.CombinedCamera.prototype.toPerspective = function () {

	// Switches to the Perspective Camera

	this.cameraP.near = this.near;
	this.cameraP.far = this.far;
	this.cameraP.aspect = this.aspect;
	this.cameraP.fov =  this.fov;
	this.cameraP.zoom = this.zoom;
	this.cameraP.view = this.view;

	this.cameraP.updateProjectionMatrix();

	this.projectionMatrix = this.cameraP.projectionMatrix;

	this.inPerspectiveMode = true;
	this.inOrthographicMode = false;

};

THREE.CombinedCamera.prototype.toOrthographic = function () {

	// Switches to the Orthographic camera estimating viewport from Perspective

	var fov = this.fov;
	var aspect = this.aspect;

	var halfHeight = Math.tan( fov * Math.PI / 180 / 2 ) * (this.hyperfocusOffset + this.hyperfocusScale * ( this.near + this.far ));
	var halfWidth = halfHeight * aspect;

	this.cameraO.near = this.near;
	this.cameraO.far = this.far;
	this.cameraO.left = - halfWidth;
	this.cameraO.right = halfWidth;
	this.cameraO.top = halfHeight;
	this.cameraO.bottom = - halfHeight;

	this.cameraO.zoom = this.zoom;
	this.cameraO.view = this.view;

	this.cameraO.updateProjectionMatrix();

	this.projectionMatrix = this.cameraO.projectionMatrix;

	this.inPerspectiveMode = false;
	this.inOrthographicMode = true;

};

THREE.CombinedCamera.prototype.setSize = function( width, height ) {

	this.aspect = width / height;
	this.left = - width / 2;
	this.right = width / 2;
	this.top = height / 2;
	this.bottom = - height / 2;

};

THREE.CombinedCamera.prototype.setFov = function( fov ) {

	this.fov = fov;

	if ( this.inPerspectiveMode ) {

		this.toPerspective();

	} else {

		this.toOrthographic();

	}

};

THREE.CombinedCamera.prototype.copy = function ( source ) {

	THREE.Camera.prototype.copy.call( this, source );

	this.fov = source.fov;
	this.far = source.far;
	this.near = source.near;

	this.left = source.left;
	this.right = source.right;
	this.top = source.top;
	this.bottom = source.bottom;

	this.zoom = source.zoom;
	this.view = source.view === null ? null : Object.assign( {}, source.view );
	this.aspect = source.aspect;
	this.hyperfocusOffset = source.hyperfocusOffset;
	this.hyperfocusScale = source.hyperfocusScale;

	this.cameraO = source.cameraO.copy();
	this.cameraP = source.cameraP.copy();

	this.inOrthographicMode = source.inOrthographicMode;
	this.inPerspectiveMode = source.inPerspectiveMode;

	return this;

};

THREE.CombinedCamera.prototype.setViewOffset = function( fullWidth, fullHeight, x, y, width, height ) {

	this.view = {
		fullWidth: fullWidth,
		fullHeight: fullHeight,
		offsetX: x,
		offsetY: y,
		width: width,
		height: height
	};

	if ( this.inPerspectiveMode ) {

		this.aspect = fullWidth / fullHeight;

		this.toPerspective();

	} else {

		this.toOrthographic();

	}

};

THREE.CombinedCamera.prototype.clearViewOffset = function() {

	this.view = null;
	this.updateProjectionMatrix();

};
// For maintaining similar API with PerspectiveCamera

THREE.CombinedCamera.prototype.updateProjectionMatrix = function() {

	if ( this.inPerspectiveMode ) {

		this.toPerspective();

	} else {

		this.toPerspective();
		this.toOrthographic();

	}

};

/*
* Uses Focal Length (in mm) to estimate and set FOV
* 35mm (full frame) camera is used if frame size is not specified;
* Formula based on http://www.bobatkins.com/photography/technical/field_of_view.html
*/
THREE.CombinedCamera.prototype.setLens = function ( focalLength, filmGauge ) {

	if ( filmGauge === undefined ) filmGauge = 35;

	var vExtentSlope = 0.5 * filmGauge /
			( focalLength * Math.max( this.cameraP.aspect, 1 ) );

	var fov = THREE.Math.RAD2DEG * 2 * Math.atan( vExtentSlope );

	this.setFov( fov );

	return fov;

};

THREE.CombinedCamera.prototype.setZoom = function( zoom ) {

	this.zoom = zoom;

	if ( this.inPerspectiveMode ) {

		this.toPerspective();

	} else {

		this.toOrthographic();

	}

};

THREE.CombinedCamera.prototype.toFrontView = function() {

	this.rotation.x = 0;
	this.rotation.y = 0;
	this.rotation.z = 0;

	this.position.x = 0;
	this.position.y = 0;
	this.position.z = -15;
	// should we be modifing the matrix instead?

};

THREE.CombinedCamera.prototype.toBackView = function() {

	this.rotation.x = 0;
	this.rotation.y = Math.PI;
	this.rotation.z = 0;

	this.position.x = 0;
	this.position.y = 0;
	this.position.z = 15;

};

THREE.CombinedCamera.prototype.toLeftView = function() {

	this.rotation.x = 0;
	this.rotation.y = - Math.PI / 2;
	this.rotation.z = 0;

	this.position.x = -15;
	this.position.y = 0;
	this.position.z = 0;

};

THREE.CombinedCamera.prototype.toRightView = function() {

	this.rotation.x = 0;
	this.rotation.y = Math.PI / 2;
	this.rotation.z = 0;

	this.position.x = 15;
	this.position.y = 0;
	this.position.z = 0;

};

THREE.CombinedCamera.prototype.toTopView = function() {

	this.rotation.x = - Math.PI / 2;
	this.rotation.y = 0;
	this.rotation.z = 0;

	this.position.x = 0;
	this.position.y = 15;
	this.position.z = 0;

};

THREE.CombinedCamera.prototype.toBottomView = function() {

	this.rotation.x = Math.PI / 2;
	this.rotation.y = 0;
	this.rotation.z = 0;

	this.position.x = 0;
	this.position.y = -15;
	this.position.z = 0;

};

THREE.CombinedCamera.prototype.toPerspectiveView = function() {

	this.rotation.x = - Math.PI / 4;
	this.rotation.y = - Math.PI / 4;
	this.rotation.z = 0;

	this.position.x = 4;
	this.position.y = 4;
	this.position.z = 4;

};
<|endoftext|>


<commit_before>angular.module('CostSplitter', ['ionic', 'CostSplitter.services', 'CostSplitter.controllers', 'ezfb'])

.constant('FB_CONFIG', {
  FB_APP_ID: '662664923796340',
  LOCALE: 'es_AR',
  PERMISSIONS: 'basic_info email publish_actions'.split(' ')
})

.config(function($stateProvider, $urlRouterProvider, $FBProvider, FB_CONFIG) {

  var _fb_init_config = { appId: FB_CONFIG.FB_APP_ID },
    _defaultLoadSDKFunction;

  if ( typeof cordova !== 'undefined' || typeof Cordova !== 'undefined' ) {
  // Executing on mobile device

    console.log('Executing on mobile device...');

    angular.extend( _fb_init_config, {
      nativeInterface: CDV.FB,
      useCachedDialogs: false // TODO: investigate behaviour
    });

    // Android FB SDK loaded so no need to load JS SDK
    $FBProvider.setLoadSDKFunction(function ($fbAsyncInit) {
      $fbAsyncInit();
    });

  } else { // Executing on browser
    console.log('Executing on browser...');
  };

  $FBProvider.setLocale(FB_CONFIG.LOCALE);
  $FBProvider.setInitParams( _fb_init_config );

  // Ionic uses AngularUI Router which uses the concept of states
  // Learn more here: https://github.com/angular-ui/ui-router
  // Set up the various states which the app can be in.
  // Each state's controller can be found in controllers.js
  $stateProvider

    // the pet tab has its own child nav-view and history
    .state('splitter-index', {
      url: '/splitters',
      templateUrl: 'templates/splitter-index.html',
      controller: 'SplitterIndexCtrl'
    })

    .state('event-detail', {
      url: '/splitters/:splitterId/events/:eventId',
      templateUrl: 'templates/event-detail.html',
      controller: 'EventCtrl'
    });

  // if none of the above states are matched, use this as the fallback
  $urlRouterProvider.otherwise('/splitters');

});

<commit_msg>Removes conflictive .split(' ')<commit_after>angular.module('CostSplitter', ['ionic', 'CostSplitter.services', 'CostSplitter.controllers', 'ezfb'])

.constant('FB_CONFIG', {
  FB_APP_ID: '662664923796340',
  LOCALE: 'es_AR',
  PERMISSIONS: 'basic_info email publish_actions'
})

.config(function($stateProvider, $urlRouterProvider, $FBProvider, FB_CONFIG) {

  var _fb_init_config = { appId: FB_CONFIG.FB_APP_ID },
    _defaultLoadSDKFunction;

  if ( typeof cordova !== 'undefined' || typeof Cordova !== 'undefined' ) {
  // Executing on mobile device

    console.log('Executing on mobile device...');

    angular.extend( _fb_init_config, {
      nativeInterface: CDV.FB,
      useCachedDialogs: false // TODO: investigate behaviour
    });

    // Android FB SDK loaded so no need to load JS SDK
    $FBProvider.setLoadSDKFunction(function ($fbAsyncInit) {
      $fbAsyncInit();
    });

  } else { // Executing on browser
    console.log('Executing on browser...');
  };

  $FBProvider.setLocale(FB_CONFIG.LOCALE);
  $FBProvider.setInitParams( _fb_init_config );

  // Ionic uses AngularUI Router which uses the concept of states
  // Learn more here: https://github.com/angular-ui/ui-router
  // Set up the various states which the app can be in.
  // Each state's controller can be found in controllers.js
  $stateProvider

    // the pet tab has its own child nav-view and history
    .state('splitter-index', {
      url: '/splitters',
      templateUrl: 'templates/splitter-index.html',
      controller: 'SplitterIndexCtrl'
    })

    .state('event-detail', {
      url: '/splitters/:splitterId/events/:eventId',
      templateUrl: 'templates/event-detail.html',
      controller: 'EventCtrl'
    });

  // if none of the above states are matched, use this as the fallback
  $urlRouterProvider.otherwise('/splitters');

});

<|endoftext|>


<commit_before>class Slot {
    /**
     * @param {Array} prizes 奖励数组
     * @param {Number} itemHeight 单个奖项元素的高度，单位 px，默认 100px。
     * @param {Number} initialIndex 初始化时显示的奖项,默认为第一个奖项。
     * @param {Number} loop 抽奖过程中旋转的圈数，默认20圈。
     */
    constructor({prizes, itemHeight = 100, initialIndex = 0, loop = 20}) {
        this.prizes = prizes;
        if (this.prizes.length < 2) {
            console.log('Prizes length must equal or greater than 2!');
            return false;
        }
        this.currentPrizeIndex = initialIndex % prizes.length;     // 当前显示奖项序号
        this.itemHeight = itemHeight;
        this.totalHeight = this.itemHeight * this.prizes.length;    // 所有奖项总高度
        this.loop = loop;
        this.createDoms();
        this.getTimingFunctionGenerator();
    }

    createDoms() {
        let slot = this.dom = document.createElement('div');
        slot.className = 'slot';
        let prizes = this.prizes,
            itemsHtml = '',
            items = [];
        items.push(prizes[prizes.length - 1], ...prizes, ...prizes.slice(0, 2));
        items.forEach(item => {
            itemsHtml += `<li class="prize ${item.class}">${item.value}</li>`;
        });
        slot.innerHTML = `<ul class="prizes-list" style="margin-top: -${this.itemHeight / 2}px; transform: translate3d(0, -${this.itemHeight * this.currentPrizeIndex}px, 0);">${itemsHtml}</ul>`;
        this.prizesList = slot.querySelector('.prizes-list');
    }

    getTimingFunctionGenerator() {
        this.timingFunctionGenerator = function(duration) {
            return d3.easeCubicInOut;
        };
    }

    /**
     * @desc 计算出需要滚动的距离
     */
    calculateDestinedScrollDistance(detinedPrizeIndex) {
        return (detinedPrizeIndex - this.currentPrizeIndex + this.loop * this.prizes.length) * this.itemHeight;
    }

    /**
     * @desc 抽奖，在指定的时间内滚动至指定的奖项。
     * @param {Number} prizeIndex 奖项序号
     * @param {Number} duration 摇奖时间，单位 ms
      */
    draw({prizeIndex, duration = 8000}) {
        prizeIndex = prizeIndex % this.prizes.length;
        let distinedScrollDistance = this.calculateDestinedScrollDistance(prizeIndex);
        let timingFunction = this.timingFunctionGenerator(duration);
        let currentPosition = -this.currentPrizeIndex * this.itemHeight;
        let startTime;
        let frame = () => {
            let deltaTime = Date.now() - startTime;
            if (deltaTime > duration) {
                deltaTime = duration;
            }
            let deltaDistance = distinedScrollDistance * timingFunction(deltaTime / duration);
            let position = (currentPosition - deltaDistance) % this.totalHeight;
            this.prizesList.style.transform = `translate3d(0, ${position}px, 0)`;
            if (deltaTime < duration) {
                window.requestAnimationFrame(frame);
            } else {
                this.currentPrizeIndex = prizeIndex;
            }
        };
        startTime = Date.now();
        frame();
    }
}
<commit_msg>删除无用代码<commit_after>class Slot {
    /**
     * @param {Array} prizes 奖励数组
     * @param {Number} itemHeight 单个奖项元素的高度，单位 px，默认 100px。
     * @param {Number} initialIndex 初始化时显示的奖项,默认为第一个奖项。
     * @param {Number} loop 抽奖过程中旋转的圈数，默认20圈。
     */
    constructor({prizes, itemHeight = 100, initialIndex = 0, loop = 20}) {
        this.prizes = prizes;
        if (this.prizes.length < 2) {
            console.log('Prizes length must equal or greater than 2!');
            return false;
        }
        this.currentPrizeIndex = initialIndex % prizes.length;     // 当前显示奖项序号
        this.itemHeight = itemHeight;
        this.totalHeight = this.itemHeight * this.prizes.length;    // 所有奖项总高度
        this.loop = loop;
        this.createDoms();
        this.getTimingFunctionGenerator();
    }

    createDoms() {
        let slot = this.dom = document.createElement('div');
        slot.className = 'slot';
        let prizes = this.prizes,
            itemsHtml = '',
            items = [];
        items.push(prizes[prizes.length - 1], ...prizes, ...prizes.slice(0, 2));
        items.forEach(item => {
            itemsHtml += `<li class="prize ${item.class}">${item.value}</li>`;
        });
        slot.innerHTML = `<ul class="prizes-list" style="margin-top: -${this.itemHeight / 2}px; transform: translate3d(0, -${this.itemHeight * this.currentPrizeIndex}px, 0);">${itemsHtml}</ul>`;
        this.prizesList = slot.querySelector('.prizes-list');
    }

    getTimingFunctionGenerator() {
        this.timingFunctionGenerator = function() {
            return d3.easeCubicInOut;
        };
    }

    /**
     * @desc 计算出需要滚动的距离
     */
    calculateDestinedScrollDistance(detinedPrizeIndex) {
        return (detinedPrizeIndex - this.currentPrizeIndex + this.loop * this.prizes.length) * this.itemHeight;
    }

    /**
     * @desc 抽奖，在指定的时间内滚动至指定的奖项。
     * @param {Number} prizeIndex 奖项序号
     * @param {Number} duration 摇奖时间，单位 ms
      */
    draw({prizeIndex, duration = 8000}) {
        prizeIndex = prizeIndex % this.prizes.length;
        let distinedScrollDistance = this.calculateDestinedScrollDistance(prizeIndex);
        let timingFunction = this.timingFunctionGenerator();
        let currentPosition = -this.currentPrizeIndex * this.itemHeight;
        let startTime;
        let frame = () => {
            let deltaTime = Date.now() - startTime;
            if (deltaTime > duration) {
                deltaTime = duration;
            }
            let deltaDistance = distinedScrollDistance * timingFunction(deltaTime / duration);
            let position = (currentPosition - deltaDistance) % this.totalHeight;
            this.prizesList.style.transform = `translate3d(0, ${position}px, 0)`;
            if (deltaTime < duration) {
                window.requestAnimationFrame(frame);
            } else {
                this.currentPrizeIndex = prizeIndex;
            }
        };
        startTime = Date.now();
        frame();
    }
}
<|endoftext|>


<commit_before>/**
 *  WebMentions.io JS
 *  A re-tooling of Aaron Parecki’s recommended JS for using the WebMention.io API
 *
 *  Updates Webmentions on a static site immediately when the page is loaded and
 *  in real-time (using WebSockets) as the user engages with the page.
 */

;(function(window){

    if ( !( 'AG' in window ) ){ window.AG = {}; }

    var $webmentions_list = document.querySelectorAll( '.webmentions__list' ),
        elements = {
            a:          document.createElement('a'),
            article:    document.createElement('article'),
            div:        document.createElement('div'),
            photo:      document.createElement('img'),
            li:         document.createElement('li'),
            time:       document.createElement('time')
        },
        months = [
            'January', 'February', 'March', 'April', 'May', 'June',
            'July', 'August', 'September', 'October', 'November', 'December'
        ],
        json_webmentions,
        this_page = window.location.href;

    // bail early
    if ( $webmentions_list.length < 1 ){ return; }
    $webmentions_list = $webmentions_list[0];

    // Set up the markup
    elements.li.className = 'webmentions__item';
    elements.article.className = 'webmention';
    elements.time.className = 'webmention__pubdate';
    elements.author = elements.div.cloneNode();
    elements.author.className = 'webmention__author vcard';
    elements.author_link = elements.a.cloneNode();
    elements.author_link.className = 'fn url';
    elements.photo.className = 'webmention__author__photo photo';
    elements.photo.alt = '';
    elements.title = elements.div.cloneNode();
    elements.title.className = 'webmention__title';
    elements.permalink = elements.a.cloneNode();
    elements.permalink.className = 'webmention__source';
    elements.permalink.appendChild( document.createTextNode('Permalink') );
    elements.content = elements.div.cloneNode();
    elements.content.className = 'webmention__content';
    elements.meta = elements.div.cloneNode();
    elements.meta.className = 'webmention__meta';

    function addMention( mention )
    {
        var streaming = !( 'data' in mention ),
            data = streaming ? mention : mention.data,
            id = streaming ? mention.element_id : mention.id;

        var $existing_mention = document.querySelectorAll( '#webmention-' + id  ),
            $item = elements.li.cloneNode( true ),
            $mention = elements.article.cloneNode( true ),
            $author = elements.author.cloneNode( true ),
            $author_link = elements.author_link.cloneNode( true ),
            $author_photo = elements.photo.cloneNode( true ),
            $meta = elements.meta.cloneNode( true ),
            $pubdate = elements.time.cloneNode( true ),
            $block,
            $link,
            title = data.name,
            content = data.content,
            url = data.url,
            author = data.author.name,
            author_photo = data.author.photo,
            pubdate,
            display_date = '';

        $item.id = 'webmention-' + id;
        $item.appendChild( $mention );

        // no doubling up
        if ( title && content &&
             title == content )
        {
            title = false;
        }

        if ( author )
        {
            $author_link.href = data.author.url;
            if ( author_photo )
            {
                $author_photo.src = author_photo;
                $author_link.appendChild( $author_photo );
            }
            $author_link.appendChild( document.createTextNode( author ) );
            $author.appendChild( $author_link );
            $mention.appendChild( $author );
        }

        if ( data.published )
        {
            $pubdate.setAttribute( 'datetime', data.published );
            pubdate = new Date( data.published );
            display_date += pubdate.getUTCDate() + ' ';
            display_date += months[ pubdate.getUTCMonth() ] + ' ';
            display_date += pubdate.getUTCFullYear();
            $pubdate.appendChild( document.createTextNode( display_date ) );
            $meta.appendChild( $pubdate );
        }

        if ( ( title && title.indexOf(author) === 0 ) ||
             ( content && content.indexOf(author) === 0 ) )
        {
            $mention.className += ' webmention--author-starts';
        }

        if ( title )
        {
            $mention.className += ' webmention--title-only';

            $link = elements.a.cloneNode( true );
            $link.href = url;
            $link.appendChild( document.createTextNode( data.name ) );

            $block = elements.title.cloneNode( true );
            $block.appendChild( $link );
            $mention.appendChild( $block );

            $mention.appendChild( $meta );
        }
        else if ( content )
        {
            $mention.className += ' webmention--content-only';

            $meta.appendChild( document.createTextNode( ' | ' ) );
            $link = elements.permalink.cloneNode( true );
            $link.href = url;
            $meta.appendChild( $link );
            $mention.appendChild( $meta );

            // TODO: Add Markdown
            $block = elements.content.cloneNode( true );
            $block.appendChild( document.createTextNode( content ) );
            $mention.appendChild( $block );
        }

        if ( $existing_mention.length < 1 )
        {
            $webmentions_list.appendChild( $item );
        }
        else
        {
            $webmentions_list.replaceChild( $item, $existing_mention[0] );
        }

        // Release
        $item = null;
        $existing_mention = null;
        $mention = null;
        $author = null;
        $author_link = null;
        $author_photo = null;
        $block = null;
        $link = null;
        $meta = null;
        $pubdate = null;
    }

    window.AG.processWebmentions = function( data ){
        data.links.reverse();
        data.links.forEach( addMention );
    };

    // Load up any unpublished webmentions on load
    json_webmentions = document.createElement('script');
    json_webmentions.async = true;
    json_webmentions.src = 'http://webmention.io/api/mentions?jsonp=window.AG.processWebmentions&target=' + this_page;
    document.getElementsByTagName('head')[0].appendChild( json_webmentions );

    // Listen for new ones
    if ( $webmentions_list.length &&
        "WebSocket" in window )
    {
        var ws = new WebSocket('ws://webmention.io:8080');

        ws.onopen = function( event ){
            // Send the current window URL to the server to register to receive notifications about this URL
            ws.send( this_page );
        };
        ws.onmessage = function( event ){
            addMention( JSON.parse( event.data ) );
        };
    }

}(window));<commit_msg>another minor JS tweak<commit_after>/**
 *  WebMentions.io JS
 *  A re-tooling of Aaron Parecki’s recommended JS for using the WebMention.io API
 *
 *  Updates Webmentions on a static site immediately when the page is loaded and
 *  in real-time (using WebSockets) as the user engages with the page.
 */

;(function(window){

    if ( !( 'AG' in window ) ){ window.AG = {}; }

    var $webmentions_list = document.querySelectorAll( '.webmentions__list' ),
        elements = {
            a:          document.createElement('a'),
            author_name:document.createElement('b'),
            article:    document.createElement('article'),
            div:        document.createElement('div'),
            photo:      document.createElement('img'),
            li:         document.createElement('li'),
            time:       document.createElement('time')
        },
        months = [
            'January', 'February', 'March', 'April', 'May', 'June',
            'July', 'August', 'September', 'October', 'November', 'December'
        ],
        json_webmentions,
        this_page = window.location.href;

    // bail early
    if ( $webmentions_list.length < 1 ){ return; }
    $webmentions_list = $webmentions_list[0];

    // Set up the markup
    elements.li.className = 'webmentions__item';
    elements.article.className = 'webmention';
    elements.time.className = 'webmention__pubdate';
    elements.author = elements.div.cloneNode();
    elements.author.className = 'webmention__author vcard';
    elements.author_name.className = 'fn';
    elements.author_link = elements.a.cloneNode();
    elements.author_link.className = 'url';
    elements.photo.className = 'webmention__author__photo photo';
    elements.photo.alt = '';
    elements.title = elements.div.cloneNode();
    elements.title.className = 'webmention__title';
    elements.permalink = elements.a.cloneNode();
    elements.permalink.className = 'webmention__source';
    elements.permalink.appendChild( document.createTextNode('Permalink') );
    elements.content = elements.div.cloneNode();
    elements.content.className = 'webmention__content';
    elements.meta = elements.div.cloneNode();
    elements.meta.className = 'webmention__meta';

    function addMention( mention )
    {
        var streaming = !( 'data' in mention ),
            data = streaming ? mention : mention.data,
            id = streaming ? mention.element_id : mention.id;

        var $existing_mention = document.querySelectorAll( '#webmention-' + id  ),
            $item = elements.li.cloneNode( true ),
            $mention = elements.article.cloneNode( true ),
            $author = elements.author.cloneNode( true ),
            $author_name = elements.author_name.cloneNode( true ),
            $author_link = elements.author_link.cloneNode( true ),
            $author_photo = elements.photo.cloneNode( true ),
            $meta = elements.meta.cloneNode( true ),
            $pubdate = elements.time.cloneNode( true ),
            $block,
            $link,
            title = data.name,
            content = data.content,
            url = data.url,
            author = data.author.name,
            author_photo = data.author.photo,
            pubdate,
            display_date = '';

        $item.id = 'webmention-' + id;
        $item.appendChild( $mention );

        // no doubling up
        if ( title && content &&
             title == content )
        {
            title = false;
        }

        if ( author )
        {
            $author_link.href = data.author.url;
            if ( author_photo )
            {
                $author_photo.src = author_photo;
                $author_link.appendChild( $author_photo );
            }
            $author_name.appendChild( document.createTextNode( author ) );
            $author_link.appendChild( $author_name );
            $author.appendChild( $author_link );
            $mention.appendChild( $author );
        }

        if ( data.published )
        {
            $pubdate.setAttribute( 'datetime', data.published );
            pubdate = new Date( data.published );
            display_date += pubdate.getUTCDate() + ' ';
            display_date += months[ pubdate.getUTCMonth() ] + ' ';
            display_date += pubdate.getUTCFullYear();
            $pubdate.appendChild( document.createTextNode( display_date ) );
            $meta.appendChild( $pubdate );
        }

        if ( ( title && title.indexOf(author) === 0 ) ||
             ( content && content.indexOf(author) === 0 ) )
        {
            $mention.className += ' webmention--author-starts';
        }

        if ( title )
        {
            $mention.className += ' webmention--title-only';

            $link = elements.a.cloneNode( true );
            $link.href = url;
            $link.appendChild( document.createTextNode( data.name ) );

            $block = elements.title.cloneNode( true );
            $block.appendChild( $link );
            $mention.appendChild( $block );

            $mention.appendChild( $meta );
        }
        else if ( content )
        {
            $mention.className += ' webmention--content-only';

            $meta.appendChild( document.createTextNode( ' | ' ) );
            $link = elements.permalink.cloneNode( true );
            $link.href = url;
            $meta.appendChild( $link );
            $mention.appendChild( $meta );

            // TODO: Add Markdown
            $block = elements.content.cloneNode( true );
            $block.appendChild( document.createTextNode( content ) );
            $mention.appendChild( $block );
        }

        if ( $existing_mention.length < 1 )
        {
            $webmentions_list.appendChild( $item );
        }
        else
        {
            $webmentions_list.replaceChild( $item, $existing_mention[0] );
        }

        // Release
        $item = null;
        $existing_mention = null;
        $mention = null;
        $author = null;
        $author_link = null;
        $author_photo = null;
        $block = null;
        $link = null;
        $meta = null;
        $pubdate = null;
    }

    window.AG.processWebmentions = function( data ){
        data.links.reverse();
        data.links.forEach( addMention );
    };

    // Load up any unpublished webmentions on load
    json_webmentions = document.createElement('script');
    json_webmentions.async = true;
    json_webmentions.src = 'http://webmention.io/api/mentions?jsonp=window.AG.processWebmentions&target=' + this_page;
    document.getElementsByTagName('head')[0].appendChild( json_webmentions );

    // Listen for new ones
    if ( $webmentions_list.length &&
        "WebSocket" in window )
    {
        var ws = new WebSocket('ws://webmention.io:8080');

        ws.onopen = function( event ){
            // Send the current window URL to the server to register to receive notifications about this URL
            ws.send( this_page );
        };
        ws.onmessage = function( event ){
            addMention( JSON.parse( event.data ) );
        };
    }

}(window));<|endoftext|>


<commit_before>function main() {
  var bannerMessage = document.getElementById('bannerMessage');
  var messages = [
    'Your support makes this project possible. Thanks!',
  ];
  var randomMessage = messages[Math.floor(Math.random() * messages.length)];
  bannerMessage.innerHTML = randomMessage;

  var bannerMessageDiv = document.getElementById('bannerMessageDiv');
  bannerMessageDiv.classList.remove('hidden');
}

main();<commit_msg>added link to alert message<commit_after>function main() {
  var bannerMessage = document.getElementById('bannerMessage');
  var messages = [
    'Your support makes this project possible. Thanks!',
  ];
  var randomMessage = messages[Math.floor(Math.random() * messages.length)];
  bannerMessage.innerHTML = randomMessage;

  var bannerMessageDiv = document.getElementById('bannerMessageDiv');
  bannerMessageDiv.classList.remove('hidden');
}

main();<|endoftext|>