<commit_before>Risibot.prototype.choseMove = function() {

	if (!this.pokemon || !this.ennemy)
		return -1;

	var dmgComputation = this.AI.getMaxDamageTaken(this.pokemon, this.ennemy);
	var dmgTaken = movesInterests[4];
	var movesInterests = dmgComputation.slice(0, 4);

	for (var moveType in this.moves) {
		for (var j = 0; j < this.moves[moveType].length; j++) {
			var move = this.moves[moveType][j][0];
			var k = this.moves[moveType][j][1];
			switch (moveType) {
				case 'status':
					movesInterests[k - 1] = this.AI.evalStatus(move, dmgTaken);
					break;
				case 'traps':
					movesInterests[k - 1] = this.AI.evalTraps(move, dmgTaken);
					break;
				case 'heal':
					movesInterests[k - 1] = this.AI.evalHeal(move, dmgTaken);
					break;
				case 'spin':
					movesInterests[k - 1] = this.AI.evalSpin(move, dmgTaken);
					break;
				case 'seeds':
					movesInterests[k - 1] = this.AI.evalSeeds(move, dmgTaken);
					break;
				case 'defog':
					movesInterests[k - 1] = this.AI.evalDefog(move, dmgTaken);
					break;
				case 'roar':
					movesInterests[k - 1] = this.AI.evalRoar(move, dmgTaken);
					break;
				case 'painSplit':
					movesInterests[k - 1] = this.AI.evalPainSplit(move, dmgTaken);
					break;
			}
			console.log("Risibot: choseMove: Move " + move.name + ".");
		}
	}
	console.log("Risibot: choseMove: " + movesInterests);
	choice = getMaxIndex(movesInterests);
	return choice;
};

PokeyI.prototype.evalStatus = function(move, dmgTaken) { // Is this status move worth it ?
	//If we can't status the ennemy then no
	if (this.bot.ennemy.status != "" ||
		(move.status == "par" && this.hasType(this.bot.ennemy, "Electric")) ||
		(move.status == "brn" && this.hasType(this.bot.ennemy, "Fire")) ||
		(move.baseType == "Grass" && this.hasType(this.bot.ennemy, "Grass")) ||
		(move.baseType == "Electric" && this.hasType(this.bot.ennemy, "Ground")) ||
		(move.baseType == "tox" && this.hasType(this.bot.ennemy, "Steel")) ||
		(move.status == "tox" && this.hasType(this.bot.ennemy, "Poison")) ||
		(move.status == "par" && this.hasAbility(this.bot.ennemy, "Limber")) ||
		(move.status == "brn" && this.hasAbility(this.bot.ennemy, "Water Veil")) ||
		(this.hasAbility(this.bot.ennemy, "Magic Bounce")) ||
		(this.hasAbility(this.bot.ennemy, "Synchronize")) ||
		(this.room.battle.yourSide.sideConditions.safeguard)) {
		return 0;
	}
	//Using getStatusInterest to rate the impotance of a given status (the importance is lowered
	//if the ennemy can remove the status
	var isAnnoying = this.getStatusInterest(move.status) / ( (this.canCure(this.bot.ennemy)) ? 2 : 1) ;
	return parseInt( ((isAnnoying + 1) * 30) ); //1 is low priority, 90 is very high one.
};

PokeyI.prototype.getStatusInterest = function(s) {//Rates the importance of giving the status s to a pokemon
	switch (s) {
		case 'par'://The faster it is, the better it is to paralyze
			if (this.bot.ennemy.baseStats["spe"] > 120 || this.bot.ennemy.item == "Choice Scarf")
				return 2;
			if (this.bot.ennemy.baseStats["spe"] > 100)
				return 1;
			return 0;
		case 'tox'://The highest stalling potential the ennemy has the better it is to poison
			var wallCoef = this.getPotentialWall(this.bot.ennemy);
			return ( (wallCoef >= 20) ? 2 : (wallCoef >= 15) ? 1 : 0 );
		case 'brn'://Checks the attack stat to determine if we should burn
			if (this.bot.ennemy.baseStats["atk"] > 120 || this.bot.ennemy.item == "Choice Band")
				return 2;
			if (this.bot.ennemy.baseStats["atk"] > 100)
				return 1;
			return 0;
		case 'slp'://Always good. WARNING CHECK IF THE SLEEP CLAUSE IS ACTIVE
			return 2;
	}
	return 0;
}

PokeyI.prototype.evalSpin = function(move, dmgTaken) { // Is this spin worth it ?

	if ((jQuery.isEmptyObject(this.bot.room.battle.mySide.sideConditions) && !this.bot.pokemon.volatiles.leechseed) ||
		this.hasType(this.bot.ennemy, "Ghost")) {
		return 0;
	}
	return 90;
};

PokeyI.prototype.evalTraps = function(move, dmgTaken) {//Is it woth it to throw entry hazards in the way ?
	//If we are at risk to dying then no
	if (this.getDanger(this.bot.ennemy, this.bot.pokemon) > 100 || this.hasAbility(this.bot.ennemy, "Magic Bounce"))
		return 0;

	switch (move.id) {
		case "stealthrock":
			if (!this.bot.room.battle.yourSide.sideConditions.stealthrock)
				return 150;
			break;
		case "spikes"://WARNING can be worth it to place a few layers of spikes
			if (!this.bot.room.battle.yourSide.sideConditions.spikes)
				return 150;
			break;
		case "stickyweb":
			if (!this.bot.room.battle.yourSide.sideConditions.stickyweb)
				return 150;
			break;
	}
	console.log("Risibot: evalTraps: Entry hazards are already set.");
	return 0;
};

PokeyI.prototype.evalHeal = function(move, dmgTaken) {//Returns the priority of using a healing move
	//WARNING should use xHKO when Maxime codes it huehue
	hp = this.bot.pokemon.hp / this.bot.pokemon.hpmax;
	if (hp < 0.25)
		return 1500;
	if (hp < 0.50)
		return 1000;
	if (hp < 0.60)
		return 500;
	if (hp < 0.75)
		return 100;
	if (hp < 0.90)
		return 30;
	return 0;
};

PokeyI.prototype.evalSeeds = function(move, dmgTaken) {

	if (this.bot.ennemy.volatiles.leechseed || this.hasType(this.bot.ennemy, "Grass") ||
		this.hasAbility(this.bot.ennemy, "Magic Bounce") || this.hasAbility(this.bot.ennemy, "Sap Sipper"))
		return 0;

	var d = this.getDanger(this.bot.ennemy, this.bot.pokemon);//the advantage the ennemy has on us
	if (d < 0.3) // Ennemy could switch
		return 20;
	if (d < 0.8) // Ennemy will probably not switch
		return 60;
	if (d < 1.5) // It's crucial to survive
		return 80;
	return 0 // ABORT MISSION
};

PokeyI.prototype.evalDefog = function(move, dmgTaken) {

  if (!this.bot.room.battle.mySide.sideConditions)
    return 0;

  var indic = 0;
  for (var condition in this.bot.room.battle.mySide.sideConditions) {
    var c = this.bot.room.battle.mySide.sideConditions[condition][0];
    switch (c) {
      case 'toxicspikes':
      case 'spikes':
        indic += 1;
        break;
      case 'stickyweb':
      case 'stealthrock':
        indic += 2;
        break;
      case 'reflect':
      case 'safeguard':
      case 'lightscreen':
        indic -= 2;
        break;
    }
  }
  for (var condition in this.bot.room.battle.yourSide.sideConditions) {
    var c = this.bot.room.battle.yourSide.sideConditions[condition][0];
    switch (c) {
      case 'toxicspikes':
      case 'spikes':
        indic -= 1;
        break;
      case 'stickyweb':
      case 'stealthrock':
        indic -= 2;
        break;
      case 'reflect':
      case 'safeguard':
      case 'lightscreen':
        indic += 2;
        break;
    }
  }

  if (indic < 0) // Terrain is good for the bot
    return 0;
  else
    return 50 * indic;
};

PokeyI.prototype.evalRoar = function(move, dmgTaken) {

  if (this.hasAbility(this.bot.ennemy, "Magic Bounce"))
    return 0;

  coef = 1.0;
  for (c in this.bot.room.battle.yourSide.sideConditions) {
    switch (this.bot.room.battle.yourSide.sideConditions[c]) {
      case 'stealthrock': // Will damage and destabilize
      case 'spikes':
      case 'toxicspikes':
      case 'reflect': // Will temporize
      case 'lightscreen':
      case 'safeguard':
        coef += 1.0;
    }
  }
  for (b in this.bot.ennemy.boosts) {
    coef += this.bot.ennemy.boosts[b];
  }

  coef = Math.max(0.0, coef - this.getDanger(this.bot.ennemy, this.bot.pokemon));

  return 70 * coef;

};

/////////////////// UNSSAFE ZONE //////////////////////////////////////

PokeyI.prototype.evalPainSplit = function(move, dmgTaken) { // NOT TESTED NOW

  expectedDamage = this.getMaxDamageTaken(this.bot.pokemon, this.bot.ennemy)[1];
  ennemyHP = parseInt((parseInt(31 + 2 * this.bot.ennemy.baseStats * this.bot.ennemy.level / 100) + 10 + this.bot.ennemy.level) * this.bot.ennemy.hp / 100);

  if (this.isFaster(this.bot.pokemon, this.bot.ennemy)) { // If I should hit first
    newHP = parseInt((ennemyHP + this.bot.pokemon.hp) / 2); // Hp after pain split

    if (newHP < this.bot.pokemon.hp) // We will lose HP
      return 0;

    if (newHP < expectedDamage) { // We will probably die
      ratio = (this.bot.pokemon.hp / this.bot.pokemon.maxhp);
      return (ratio < 0.25) ? 100 : (ratio < 0.5) ? 50 : 0;
    }

    return (newHP / this.bot.pokemon.hp) * 100;
  }

  // If I will hit in second

  expectedHP = this.bot.pokemon.hp - expectedDamage;
  if (expectedHp < 0) // We will die before having done anything
    return 150; // FINAL GAMBIT

  newHP = parseInt((ennemyHP + expectedHP) / 2);

  if (newHP < expectedHP) // We will lose HP
    return 0;

  return (newHP / expectedHP) * 100;
};

<commit_msg>Update moveEvaluations.js<commit_after>Risibot.prototype.choseMove = function() {

	if (!this.pokemon || !this.ennemy)
		return -1;

	var dmgComputation = this.AI.getMaxDamageTaken(this.pokemon, this.ennemy);
	var dmgTaken = dmgComputation[4];
	var movesInterests = dmgComputation.slice(0, 4);

	for (var moveType in this.moves) {
		for (var j = 0; j < this.moves[moveType].length; j++) {
			var move = this.moves[moveType][j][0];
			var k = this.moves[moveType][j][1];
			switch (moveType) {
				case 'status':
					movesInterests[k - 1] = this.AI.evalStatus(move, dmgTaken);
					break;
				case 'traps':
					movesInterests[k - 1] = this.AI.evalTraps(move, dmgTaken);
					break;
				case 'heal':
					movesInterests[k - 1] = this.AI.evalHeal(move, dmgTaken);
					break;
				case 'spin':
					movesInterests[k - 1] = this.AI.evalSpin(move, dmgTaken);
					break;
				case 'seeds':
					movesInterests[k - 1] = this.AI.evalSeeds(move, dmgTaken);
					break;
				case 'defog':
					movesInterests[k - 1] = this.AI.evalDefog(move, dmgTaken);
					break;
				case 'roar':
					movesInterests[k - 1] = this.AI.evalRoar(move, dmgTaken);
					break;
				case 'painSplit':
					movesInterests[k - 1] = this.AI.evalPainSplit(move, dmgTaken);
					break;
			}
			console.log("Risibot: choseMove: Move " + move.name + ".");
		}
	}
	console.log("Risibot: choseMove: " + movesInterests);
	choice = getMaxIndex(movesInterests);
	return choice;
};

PokeyI.prototype.evalStatus = function(move, dmgTaken) { // Is this status move worth it ?
	//If we can't status the ennemy then no
	if (this.bot.ennemy.status != "" ||
		(move.status == "par" && this.hasType(this.bot.ennemy, "Electric")) ||
		(move.status == "brn" && this.hasType(this.bot.ennemy, "Fire")) ||
		(move.baseType == "Grass" && this.hasType(this.bot.ennemy, "Grass")) ||
		(move.baseType == "Electric" && this.hasType(this.bot.ennemy, "Ground")) ||
		(move.baseType == "tox" && this.hasType(this.bot.ennemy, "Steel")) ||
		(move.status == "tox" && this.hasType(this.bot.ennemy, "Poison")) ||
		(move.status == "par" && this.hasAbility(this.bot.ennemy, "Limber")) ||
		(move.status == "brn" && this.hasAbility(this.bot.ennemy, "Water Veil")) ||
		(this.hasAbility(this.bot.ennemy, "Magic Bounce")) ||
		(this.hasAbility(this.bot.ennemy, "Synchronize")) ||
		(this.room.battle.yourSide.sideConditions.safeguard)) {
		return 0;
	}
	//Using getStatusInterest to rate the impotance of a given status (the importance is lowered
	//if the ennemy can remove the status
	var isAnnoying = this.getStatusInterest(move.status) / ( (this.canCure(this.bot.ennemy)) ? 2 : 1) ;
	return parseInt( ((isAnnoying + 1) * 30) ); //1 is low priority, 90 is very high one.
};

PokeyI.prototype.getStatusInterest = function(s) {//Rates the importance of giving the status s to a pokemon
	switch (s) {
		case 'par'://The faster it is, the better it is to paralyze
			if (this.bot.ennemy.baseStats["spe"] > 120 || this.bot.ennemy.item == "Choice Scarf")
				return 2;
			if (this.bot.ennemy.baseStats["spe"] > 100)
				return 1;
			return 0;
		case 'tox'://The highest stalling potential the ennemy has the better it is to poison
			var wallCoef = this.getPotentialWall(this.bot.ennemy);
			return ( (wallCoef >= 20) ? 2 : (wallCoef >= 15) ? 1 : 0 );
		case 'brn'://Checks the attack stat to determine if we should burn
			if (this.bot.ennemy.baseStats["atk"] > 120 || this.bot.ennemy.item == "Choice Band")
				return 2;
			if (this.bot.ennemy.baseStats["atk"] > 100)
				return 1;
			return 0;
		case 'slp'://Always good. WARNING CHECK IF THE SLEEP CLAUSE IS ACTIVE
			return 2;
	}
	return 0;
}

PokeyI.prototype.evalSpin = function(move, dmgTaken) { // Is this spin worth it ?

	if ((jQuery.isEmptyObject(this.bot.room.battle.mySide.sideConditions) && !this.bot.pokemon.volatiles.leechseed) ||
		this.hasType(this.bot.ennemy, "Ghost")) {
		return 0;
	}
	return 90;
};

PokeyI.prototype.evalTraps = function(move, dmgTaken) {//Is it woth it to throw entry hazards in the way ?
	//If we are at risk to dying then no
	if (this.getDanger(this.bot.ennemy, this.bot.pokemon) > 100 || this.hasAbility(this.bot.ennemy, "Magic Bounce"))
		return 0;

	switch (move.id) {
		case "stealthrock":
			if (!this.bot.room.battle.yourSide.sideConditions.stealthrock)
				return 150;
			break;
		case "spikes"://WARNING can be worth it to place a few layers of spikes
			if (!this.bot.room.battle.yourSide.sideConditions.spikes)
				return 150;
			break;
		case "stickyweb":
			if (!this.bot.room.battle.yourSide.sideConditions.stickyweb)
				return 150;
			break;
	}
	console.log("Risibot: evalTraps: Entry hazards are already set.");
	return 0;
};

PokeyI.prototype.evalHeal = function(move, dmgTaken) {//Returns the priority of using a healing move
	//WARNING should use xHKO when Maxime codes it huehue
	hp = this.bot.pokemon.hp / this.bot.pokemon.hpmax;
	if (hp < 0.25)
		return 1500;
	if (hp < 0.50)
		return 1000;
	if (hp < 0.60)
		return 500;
	if (hp < 0.75)
		return 100;
	if (hp < 0.90)
		return 30;
	return 0;
};

PokeyI.prototype.evalSeeds = function(move, dmgTaken) {

	if (this.bot.ennemy.volatiles.leechseed || this.hasType(this.bot.ennemy, "Grass") ||
		this.hasAbility(this.bot.ennemy, "Magic Bounce") || this.hasAbility(this.bot.ennemy, "Sap Sipper"))
		return 0;

	var d = this.getDanger(this.bot.ennemy, this.bot.pokemon);//the advantage the ennemy has on us
	if (d < 0.3) // Ennemy could switch
		return 20;
	if (d < 0.8) // Ennemy will probably not switch
		return 60;
	if (d < 1.5) // It's crucial to survive
		return 80;
	return 0 // ABORT MISSION
};

PokeyI.prototype.evalDefog = function(move, dmgTaken) {

  if (!this.bot.room.battle.mySide.sideConditions)
    return 0;

  var indic = 0;
  for (var condition in this.bot.room.battle.mySide.sideConditions) {
    var c = this.bot.room.battle.mySide.sideConditions[condition][0];
    switch (c) {
      case 'toxicspikes':
      case 'spikes':
        indic += 1;
        break;
      case 'stickyweb':
      case 'stealthrock':
        indic += 2;
        break;
      case 'reflect':
      case 'safeguard':
      case 'lightscreen':
        indic -= 2;
        break;
    }
  }
  for (var condition in this.bot.room.battle.yourSide.sideConditions) {
    var c = this.bot.room.battle.yourSide.sideConditions[condition][0];
    switch (c) {
      case 'toxicspikes':
      case 'spikes':
        indic -= 1;
        break;
      case 'stickyweb':
      case 'stealthrock':
        indic -= 2;
        break;
      case 'reflect':
      case 'safeguard':
      case 'lightscreen':
        indic += 2;
        break;
    }
  }

  if (indic < 0) // Terrain is good for the bot
    return 0;
  else
    return 50 * indic;
};

PokeyI.prototype.evalRoar = function(move, dmgTaken) {

  if (this.hasAbility(this.bot.ennemy, "Magic Bounce"))
    return 0;

  coef = 1.0;
  for (c in this.bot.room.battle.yourSide.sideConditions) {
    switch (this.bot.room.battle.yourSide.sideConditions[c]) {
      case 'stealthrock': // Will damage and destabilize
      case 'spikes':
      case 'toxicspikes':
      case 'reflect': // Will temporize
      case 'lightscreen':
      case 'safeguard':
        coef += 1.0;
    }
  }
  for (b in this.bot.ennemy.boosts) {
    coef += this.bot.ennemy.boosts[b];
  }

  coef = Math.max(0.0, coef - this.getDanger(this.bot.ennemy, this.bot.pokemon));

  return 70 * coef;

};

/////////////////// UNSSAFE ZONE //////////////////////////////////////

PokeyI.prototype.evalPainSplit = function(move, dmgTaken) { // NOT TESTED NOW

  expectedDamage = this.getMaxDamageTaken(this.bot.pokemon, this.bot.ennemy)[1];
  ennemyHP = parseInt((parseInt(31 + 2 * this.bot.ennemy.baseStats * this.bot.ennemy.level / 100) + 10 + this.bot.ennemy.level) * this.bot.ennemy.hp / 100);

  if (this.isFaster(this.bot.pokemon, this.bot.ennemy)) { // If I should hit first
    newHP = parseInt((ennemyHP + this.bot.pokemon.hp) / 2); // Hp after pain split

    if (newHP < this.bot.pokemon.hp) // We will lose HP
      return 0;

    if (newHP < expectedDamage) { // We will probably die
      ratio = (this.bot.pokemon.hp / this.bot.pokemon.maxhp);
      return (ratio < 0.25) ? 100 : (ratio < 0.5) ? 50 : 0;
    }

    return (newHP / this.bot.pokemon.hp) * 100;
  }

  // If I will hit in second

  expectedHP = this.bot.pokemon.hp - expectedDamage;
  if (expectedHp < 0) // We will die before having done anything
    return 150; // FINAL GAMBIT

  newHP = parseInt((ennemyHP + expectedHP) / 2);

  if (newHP < expectedHP) // We will lose HP
    return 0;

  return (newHP / expectedHP) * 100;
};

<|endoftext|>


<commit_before>$(document).ready(function(){

/* 	Existance checker function */
	$.fn.exists = function(callback) {
		var args = [].slice.call(arguments, 1);
		if (this.length) {
			callback.call(this, args);
		}
		return this;
	};

/* 	Using ECF to check for Video Option Trigger, hiding it, and adding buttons */
	$(function () {
		$("span:contains('HasDemoVideo')").exists(function() {
			$(this).closest('.productAttributeRow').hide();
			var ProductThumb = $('.ProductThumb');
				ProductTinyImageList = $('.ProductTinyImageList ul');
			ProductThumb.append('

');
			ProductTinyImageList.append('

');
			});
		});

/*	Play/Stop button click triggering functionality */
	$('.ProductTinyImageList ul, #videoDemoThumb, #videoDemoBtn').on('click', 'li', function() {
        var playStopBtn = $('#videoDemoThumb, #videoDemoBtn');
        	allThumbLinks = $('.prodThumbImage, .magictoolbox-li');
            if($(this).hasClass('videoPlaying') || $(this).is(allThumbLinks)) {
 		        $(allThumbLinks).removeClass('videoPlaying');
 		        $(playStopBtn).removeClass('videoPlaying');
		        $('#productDemoVideo').hide();
            } else if($(this).is(playStopBtn) && !$(this).hasClass('videoPlaying')) {
				/* Add video container START */
			    var productNumber = $('#productDetailsAddToCartForm').find('input[name=product_id]').attr('value');
			    	videoContainer = '
'+
			    					'<video id="demoVideo" class="video" preload autoplay loop autobuffer muted controls width="100%" height="100%" poster="/content/videos/'+productNumber+'.jpg">'+
			                		'<source src="/content/videos/'+productNumber+'.mp4">'+
			                		'<source src="/content/videos/'+productNumber+'.ogv" type="video/ogg">'+
			                		'
Your browser does not support this video.  Please upgrade your browser!
'+
			                		'</video>'+
			                		'
';
				$('.ProductThumbImage').append(videoContainer);
				$('#productDemoVideo').hide();
				/* Add video container END */
				$(allThumbLinks).addClass('videoPlaying');
				$(playStopBtn).addClass('videoPlaying');
				$('#productDemoVideo').show();
				$('#productDemoVideo').css('height', $('.ProductThumbImage').height()+'px');
/*
				var video = document.getElementById('demoVideo');
				video.addEventListener('click',function(){
					video.play();
				},false);
*/
            } else /* if($(this).is(playStopBtn) || ) || */ {
                console.log("NOTHING IS HAPPENING")
            }
         });
     });
<commit_msg>Removed JS as unnecessary<commit_after><|endoftext|>


<commit_before>//height offset for iphone5
var CARDS_IPHONE5_OFFSET_HEIGHT = 50;
var cardImageTop = IPHONE5 ? 73+CARDS_IPHONE5_OFFSET_HEIGHT : 73;

var cardSelectionListContainer = null;

//Creates the card that acts as a store (e.g. buy more)
function createStoreCard(){
	var storeCardView = Ti.UI.createView({
		top:isIpad ? 60 : IPHONE5? 42 : 30
	});

	var storeCard = Ti.UI.createImageView({
		image:IMAGE_PATH+'card/store/card_buymore.png',
	});

	var imgRestore = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/store/cloud_restore.png',
		left:isIpad ? 155 : 50,
		bottom:isIpad ? 40 : IPHONE5? 50 : 20,
		zIndex:2,
		width:isIpad? 223 :106,
		height:isIpad? 146: 70
	});

	var imgBuy = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/store/cloud_price.png',
		right:isIpad ? 155 : 50,
		bottom:isIpad ? 40 : IPHONE5? 50 : 20,
		zIndex:2,
		width:isIpad? 223 :106,
		height:isIpad? 146: 70
	});

	storeCardView.add(imgRestore);
	storeCardView.add(imgBuy);
	storeCardView.add(storeCard);

	return storeCardView;
}

/*Returns an array with the image views for all the cards available to the app.
 Checks if any purchases have been made and performs accordingly*/
function createCardViews(){
	var cardViews = [];
	var tmpCard = null;
	var tmpCardContainer = null;
	var tmpCardIndexLabel = null;
	var homeButton = null;

	//create arrow images
	/*
	var cardArrowRight = Ti.UI.createImageView({
		image:IMAGE_PATH+'card/arrow-right.png',
		right:2,
		zIndex:10
	});*/

	//If there are no purchases, just add the demo cards
	if(!purchasedPack){
		for(var i=1; i <= 10; i++){

			tmpCard = Ti.UI.createImageView({
				image:IMAGE_PATH+'card/demo/demo'+i+'.png',
				top:isIpad ? 155 : cardImageTop
			});

			cardViews.push(tmpCard);
		}

		//Also add the STORE card
		cardViews.push(createStoreCard());

	} else {

		//create demo cards
		for(var i=1; i <= 10; i++){

			tmpCard = Ti.UI.createImageView({
				image:IMAGE_PATH+'card/demo/demo'+i+'.png',
				top:isIpad ? 155 : cardImageTop
			});

			cardViews.push(tmpCard);
		}

		//create cards for PACK1
		for(var i=1; i <= 100; i++){
			tmpCard = Ti.UI.createImageView({
				image:IMAGE_PATH+'card/pack1_gr/'+i+'.png',
				top:isIpad ? 155 : cardImageTop
			});

			cardViews.push(tmpCard);
		}
	}

	return cardViews;
}

/*Creates the card selection (1-10, 11-20 etc) - available only after purchases are made*/
function createCardSelectionList(){
	var CARD_SELECTION_OFFSET_X = isIpad? 176: 79;
	var CARD_SELECTION_OFFSET_Y = isIpad? 228 : 105;
	var LIST_TOP = isIpad? 150 : IPHONE5? 100 : 70;

	cardSelectionListContainer = Ti.UI.createView({
		top:LIST_TOP
	});

	var cardListButton1 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/demo.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:isIpad? 30 : 3,
		top:5,
		cardIndex:1
	});

	var cardListButton2 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/1-10.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:cardListButton1.left+CARD_SELECTION_OFFSET_X,
		top:5,
		cardIndex:11
	});

	var cardListButton3 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/11-20.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:cardListButton2.left+CARD_SELECTION_OFFSET_X,
		top:5,
		cardIndex:21
	});

	var cardListButton4 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/21-30.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:cardListButton3.left+CARD_SELECTION_OFFSET_X,
		top:5,
		cardIndex:31
	});

	//row2
	var cardListButton5 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/31-40.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:isIpad? 30 : 3,
		top:cardListButton1.top+CARD_SELECTION_OFFSET_Y,
		cardIndex:41
	});

	var cardListButton6 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/41-50.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:cardListButton1.left+CARD_SELECTION_OFFSET_X,
		top:cardListButton1.top+CARD_SELECTION_OFFSET_Y,
		cardIndex:51
	});

	var cardListButton7 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/51-60.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:cardListButton2.left+CARD_SELECTION_OFFSET_X,
		top:cardListButton1.top+CARD_SELECTION_OFFSET_Y,
		cardIndex:61
	});

	var cardListButton8 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/61-70.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:cardListButton3.left+CARD_SELECTION_OFFSET_X,
		top:cardListButton1.top+CARD_SELECTION_OFFSET_Y,
		cardIndex:71
	});

	//row3
	var cardListButton9 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/71-80.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:isIpad? 30 : 3,
		top:cardListButton5.top+CARD_SELECTION_OFFSET_Y,
		cardIndex:81
	});

	var cardListButton10 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/81-90.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:cardListButton1.left+CARD_SELECTION_OFFSET_X,
		top:cardListButton5.top+CARD_SELECTION_OFFSET_Y,
		cardIndex:91
	});

	var cardListButton11 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/91-100.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:cardListButton2.left+CARD_SELECTION_OFFSET_X,
		top:cardListButton5.top+CARD_SELECTION_OFFSET_Y,
		cardIndex:101
	});

	var cardListButton12 = Ti.UI.createImageView({
		image:IMAGE_PATH+'card/selection/more-soon.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:cardListButton3.left+CARD_SELECTION_OFFSET_X,
		top:cardListButton5.top+CARD_SELECTION_OFFSET_Y
	});

	cardSelectionListContainer.add(cardListButton1);
	cardSelectionListContainer.add(cardListButton2);
	cardSelectionListContainer.add(cardListButton3);
	cardSelectionListContainer.add(cardListButton4);
	cardSelectionListContainer.add(cardListButton5);
	cardSelectionListContainer.add(cardListButton6);
	cardSelectionListContainer.add(cardListButton7);
	cardSelectionListContainer.add(cardListButton8);
	cardSelectionListContainer.add(cardListButton9);
	cardSelectionListContainer.add(cardListButton10);
	cardSelectionListContainer.add(cardListButton11);
	cardSelectionListContainer.add(cardListButton12);

	cardListButton1.addEventListener('click', handleCardSelection);
	cardListButton2.addEventListener('click', handleCardSelection);
	cardListButton3.addEventListener('click', handleCardSelection);
	cardListButton4.addEventListener('click', handleCardSelection);
	cardListButton5.addEventListener('click', handleCardSelection);
	cardListButton6.addEventListener('click', handleCardSelection);
	cardListButton7.addEventListener('click', handleCardSelection);
	cardListButton8.addEventListener('click', handleCardSelection);
	cardListButton9.addEventListener('click', handleCardSelection);
	cardListButton10.addEventListener('click', handleCardSelection);
	cardListButton11.addEventListener('click', handleCardSelection);
	cardListButton12.addEventListener('click', handleCardSelection);

	viewCards.add(cardSelectionListContainer);
}

//Event handler for the cards scroll event
function handleCardScroll(e){
	//Ti.API.info('SCROLL EVENT');

	var cardIndex = (e.currentPage+1);

	if(cardIndex <= 10){
		cardIndexLabel.hide();
	} else {

		if(purchasedPack){
			cardIndexLabel.show();
		}

	}

	//subtract the demo cards to align the numbering
	cardIndex -= 10;
	cardIndexLabel.text = cardIndex;
}

//Event handler for selecting a card from the listing
function handleCardSelection(e){
	var scrollToIndex = e.source.cardIndex;
	if(scrollToIndex != null){

		scrollToIndex = scrollToIndex - 1;
		cardSrollableView.setCurrentPage(scrollToIndex);

		//Show/hide the card indicator
		if(scrollToIndex < 10){
			cardIndexLabel.hide();
		} else {
			//subtract the demo cards to align the numbering
			var cardIndex = (scrollToIndex+1) -10;
			cardIndexLabel.text = cardIndex;

			if(purchasedPack){
				cardIndexLabel.show();
			}
		}

		//show the home button
		cardHomeButton.show();

		//show the cards
		cardSelectionListContainer.opacity = 0;
		cardSrollableView.animate(anim_in);
	}
}

//Event handler for the card home button
function handleCardHomeButton(){
	cardHomeButton.hide();
	cardIndexLabel.hide();

	cardSrollableView.opacity = 0;
	cardSelectionListContainer.animate(anim_in);
}

//cards view
var viewCards = Ti.UI.createView({
	backgroundImage:IMAGE_PATH+'card/background_B.jpg',
	bottom:isIpad ? 146 : 65,
	opacity:0
});

win.add(viewCards);

//title popup
var titleCardPopup = Ti.UI.createImageView({
	image:IMAGE_PATH+'card/title_card.png',
	top:0
});

viewCards.add(titleCardPopup);

//title label in the popup
var titleCardLabel = Ti.UI.createLabel({
	text:CARDS_TITLE,
	color:'3bb3e6',
	textAlign:'center',
	width:isIpad ? 350 : 150,
	left:isIpad ? 75 : 28,
	top:isIpad ? 10 : 2,
	font:{fontSize:isIpad ? 70 : 29, fontWeight:'bold', fontFamily:'Aka-AcidGR-Collage'}
});
titleCardPopup.add(titleCardLabel);

//Cards scrollable view
var cardSrollableView = Ti.UI.createScrollableView({
	showPagingControl:false,
	opacity:0
});

//Card index label
var cardIndexLabel = Ti.UI.createLabel({
	color:'77d040',
	text:'1',
	font:{fontSize:isIpad ? 68 : 27, fontWeight:'bold', fontFamily:'Aka-AcidGR-Collage'},
	zIndex:20,
	right:isIpad ? 16:8,
	top:5,
	visible:false
});

//Card home button
var cardHomeButton = Ti.UI.createButton({
	backgroundImage:IMAGE_PATH+'card/home.png',
	width:isIpad? 132:58,
	height:isIpad? 122:54,
	visible:false,
	top:0,
	left:0,
	zIndex:20,
});

//Build cards and scrollable view
var cardViews = createCardViews();
cardSrollableView.setViews(cardViews);

//Add the scrollable list
viewCards.add(cardSrollableView);

viewCards.add(cardIndexLabel);
viewCards.add(cardHomeButton);

//Add event listeners
cardSrollableView.addEventListener('scrollend', handleCardScroll);
cardHomeButton.addEventListener('click', handleCardHomeButton);

//Show tha card selection list, if any purchases have been made
if(purchasedPack){
	createCardSelectionList();
} else {
	cardSrollableView.opacity = 1;
}

<commit_msg>Store buttons simulate purchase<commit_after>//height offset for iphone5
var CARDS_IPHONE5_OFFSET_HEIGHT = 50;
var cardImageTop = IPHONE5 ? 73+CARDS_IPHONE5_OFFSET_HEIGHT : 73;

var cardSelectionListContainer = null;

//Updates the UI after a purchase is completed
function updateUIAfterPurchase(){
	Ti.API.info('updateUIAfterPurchase() called');
	purchasedPack = true;

	cardSrollableView.opacity = 0;

	//recreate the scrollable list so that the purchased cards are visible
	var cardViews = createCardViews();
	cardSrollableView.setViews(cardViews);

	createCardSelectionList(true);
}

//Creates the card that acts as a store (e.g. buy more)
function createStoreCard(){
	var storeCardView = Ti.UI.createView({
		top:isIpad ? 60 : IPHONE5? 42 : 30
	});

	var storeCard = Ti.UI.createImageView({
		image:IMAGE_PATH+'card/store/card_buymore.png',
	});

	var imgRestore = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/store/cloud_restore.png',
		left:isIpad ? 155 : 50,
		bottom:isIpad ? 40 : IPHONE5? 50 : 20,
		zIndex:2,
		width:isIpad? 223 :106,
		height:isIpad? 146: 70
	});

	var imgBuy = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/store/cloud_price.png',
		right:isIpad ? 155 : 50,
		bottom:isIpad ? 40 : IPHONE5? 50 : 20,
		zIndex:2,
		width:isIpad? 223 :106,
		height:isIpad? 146: 70
	});

	storeCardView.add(imgRestore);
	storeCardView.add(imgBuy);
	storeCardView.add(storeCard);

	imgRestore.addEventListener('click', updateUIAfterPurchase);
	imgBuy.addEventListener('click', updateUIAfterPurchase);

	return storeCardView;
}

/*Returns an array with the image views for all the cards available to the app.
 Checks if any purchases have been made and performs accordingly*/
function createCardViews(){
	var cardViews = [];
	var tmpCard = null;
	var tmpCardContainer = null;
	var tmpCardIndexLabel = null;
	var homeButton = null;

	//create arrow images
	/*
	var cardArrowRight = Ti.UI.createImageView({
		image:IMAGE_PATH+'card/arrow-right.png',
		right:2,
		zIndex:10
	});*/

	//If there are no purchases, just add the demo cards
	if(!purchasedPack){
		for(var i=1; i <= 10; i++){

			tmpCard = Ti.UI.createImageView({
				image:IMAGE_PATH+'card/demo/demo'+i+'.png',
				top:isIpad ? 155 : cardImageTop
			});

			cardViews.push(tmpCard);
		}

		//Also add the STORE card
		cardViews.push(createStoreCard());

	} else {

		//create demo cards
		for(var i=1; i <= 10; i++){

			tmpCard = Ti.UI.createImageView({
				image:IMAGE_PATH+'card/demo/demo'+i+'.png',
				top:isIpad ? 155 : cardImageTop
			});

			cardViews.push(tmpCard);
		}

		//create cards for PACK1
		for(var i=1; i <= 100; i++){
			tmpCard = Ti.UI.createImageView({
				image:IMAGE_PATH+'card/pack1_gr/'+i+'.png',
				top:isIpad ? 155 : cardImageTop
			});

			cardViews.push(tmpCard);
		}
	}

	return cardViews;
}

/*Creates the card selection (1-10, 11-20 etc) - available only after purchases are made*/
function createCardSelectionList(afterPurchase){
	var CARD_SELECTION_OFFSET_X = isIpad? 176: 79;
	var CARD_SELECTION_OFFSET_Y = isIpad? 228 : 105;
	var LIST_TOP = isIpad? 150 : IPHONE5? 100 : 70;

	cardSelectionListContainer = Ti.UI.createView({
		top:LIST_TOP,
		opacity:0
	});

	var cardListButton1 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/demo.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:isIpad? 30 : 3,
		top:5,
		cardIndex:1
	});

	var cardListButton2 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/1-10.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:cardListButton1.left+CARD_SELECTION_OFFSET_X,
		top:5,
		cardIndex:11
	});

	var cardListButton3 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/11-20.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:cardListButton2.left+CARD_SELECTION_OFFSET_X,
		top:5,
		cardIndex:21
	});

	var cardListButton4 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/21-30.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:cardListButton3.left+CARD_SELECTION_OFFSET_X,
		top:5,
		cardIndex:31
	});

	//row2
	var cardListButton5 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/31-40.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:isIpad? 30 : 3,
		top:cardListButton1.top+CARD_SELECTION_OFFSET_Y,
		cardIndex:41
	});

	var cardListButton6 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/41-50.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:cardListButton1.left+CARD_SELECTION_OFFSET_X,
		top:cardListButton1.top+CARD_SELECTION_OFFSET_Y,
		cardIndex:51
	});

	var cardListButton7 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/51-60.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:cardListButton2.left+CARD_SELECTION_OFFSET_X,
		top:cardListButton1.top+CARD_SELECTION_OFFSET_Y,
		cardIndex:61
	});

	var cardListButton8 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/61-70.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:cardListButton3.left+CARD_SELECTION_OFFSET_X,
		top:cardListButton1.top+CARD_SELECTION_OFFSET_Y,
		cardIndex:71
	});

	//row3
	var cardListButton9 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/71-80.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:isIpad? 30 : 3,
		top:cardListButton5.top+CARD_SELECTION_OFFSET_Y,
		cardIndex:81
	});

	var cardListButton10 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/81-90.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:cardListButton1.left+CARD_SELECTION_OFFSET_X,
		top:cardListButton5.top+CARD_SELECTION_OFFSET_Y,
		cardIndex:91
	});

	var cardListButton11 = Ti.UI.createButton({
		backgroundImage:IMAGE_PATH+'card/selection/91-100.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:cardListButton2.left+CARD_SELECTION_OFFSET_X,
		top:cardListButton5.top+CARD_SELECTION_OFFSET_Y,
		cardIndex:101
	});

	var cardListButton12 = Ti.UI.createImageView({
		image:IMAGE_PATH+'card/selection/more-soon.png',
		width:isIpad? 175 : 78,
		height:isIpad? 223 : 100,
		left:cardListButton3.left+CARD_SELECTION_OFFSET_X,
		top:cardListButton5.top+CARD_SELECTION_OFFSET_Y
	});

	cardSelectionListContainer.add(cardListButton1);
	cardSelectionListContainer.add(cardListButton2);
	cardSelectionListContainer.add(cardListButton3);
	cardSelectionListContainer.add(cardListButton4);
	cardSelectionListContainer.add(cardListButton5);
	cardSelectionListContainer.add(cardListButton6);
	cardSelectionListContainer.add(cardListButton7);
	cardSelectionListContainer.add(cardListButton8);
	cardSelectionListContainer.add(cardListButton9);
	cardSelectionListContainer.add(cardListButton10);
	cardSelectionListContainer.add(cardListButton11);
	cardSelectionListContainer.add(cardListButton12);

	cardListButton1.addEventListener('click', handleCardSelection);
	cardListButton2.addEventListener('click', handleCardSelection);
	cardListButton3.addEventListener('click', handleCardSelection);
	cardListButton4.addEventListener('click', handleCardSelection);
	cardListButton5.addEventListener('click', handleCardSelection);
	cardListButton6.addEventListener('click', handleCardSelection);
	cardListButton7.addEventListener('click', handleCardSelection);
	cardListButton8.addEventListener('click', handleCardSelection);
	cardListButton9.addEventListener('click', handleCardSelection);
	cardListButton10.addEventListener('click', handleCardSelection);
	cardListButton11.addEventListener('click', handleCardSelection);
	cardListButton12.addEventListener('click', handleCardSelection);

	viewCards.add(cardSelectionListContainer);
	if(afterPurchase){
		cardSelectionListContainer.animate(anim_in);
	} else {
		cardSelectionListContainer.opacity = 1;
	}
}

//Event handler for the cards scroll event
function handleCardScroll(e){
	Ti.API.info('SCROLL EVENT, purchasedPack='+purchasedPack);

	var cardIndex = (e.currentPage+1);

	if(cardIndex <= 10){
		cardIndexLabel.hide();
	} else {

		if(purchasedPack){
			cardIndexLabel.show();
		}

	}

	//subtract the demo cards to align the numbering
	cardIndex -= 10;
	cardIndexLabel.text = cardIndex;
}

//Event handler for selecting a card from the listing
function handleCardSelection(e){
	var scrollToIndex = e.source.cardIndex;
	if(scrollToIndex != null){

		scrollToIndex = scrollToIndex - 1;
		cardSrollableView.setCurrentPage(scrollToIndex);

		//Show/hide the card indicator
		if(scrollToIndex < 10){
			cardIndexLabel.hide();
		} else {
			//subtract the demo cards to align the numbering
			var cardIndex = (scrollToIndex+1) -10;
			cardIndexLabel.text = cardIndex;

			if(purchasedPack){
				cardIndexLabel.show();
			}
		}

		//show the home button
		cardHomeButton.show();

		//show the cards
		cardSelectionListContainer.opacity = 0;
		cardSrollableView.animate(anim_in);
	}
}

//Event handler for the card home button
function handleCardHomeButton(){
	cardHomeButton.hide();
	cardIndexLabel.hide();

	cardSrollableView.opacity = 0;
	cardSelectionListContainer.animate(anim_in);
}

//cards view
var viewCards = Ti.UI.createView({
	backgroundImage:IMAGE_PATH+'card/background_B.jpg',
	bottom:isIpad ? 146 : 65,
	opacity:0
});

win.add(viewCards);

//title popup
var titleCardPopup = Ti.UI.createImageView({
	image:IMAGE_PATH+'card/title_card.png',
	top:0
});

viewCards.add(titleCardPopup);

//title label in the popup
var titleCardLabel = Ti.UI.createLabel({
	text:CARDS_TITLE,
	color:'3bb3e6',
	textAlign:'center',
	width:isIpad ? 350 : 150,
	left:isIpad ? 75 : 28,
	top:isIpad ? 10 : 2,
	font:{fontSize:isIpad ? 70 : 29, fontWeight:'bold', fontFamily:'Aka-AcidGR-Collage'}
});
titleCardPopup.add(titleCardLabel);

//Cards scrollable view
var cardSrollableView = Ti.UI.createScrollableView({
	showPagingControl:false,
	opacity:0
});

//Card index label
var cardIndexLabel = Ti.UI.createLabel({
	color:'77d040',
	text:'1',
	font:{fontSize:isIpad ? 68 : 27, fontWeight:'bold', fontFamily:'Aka-AcidGR-Collage'},
	zIndex:20,
	right:isIpad ? 16:8,
	top:5,
	visible:false
});

//Card home button
var cardHomeButton = Ti.UI.createButton({
	backgroundImage:IMAGE_PATH+'card/home.png',
	width:isIpad? 132:58,
	height:isIpad? 122:54,
	visible:false,
	top:0,
	left:0,
	zIndex:20,
});

//Build cards and scrollable view
var cardViews = createCardViews();
cardSrollableView.setViews(cardViews);

//Add the scrollable list
viewCards.add(cardSrollableView);

viewCards.add(cardIndexLabel);
viewCards.add(cardHomeButton);

//Add event listeners
cardSrollableView.addEventListener('scrollend', handleCardScroll);
cardHomeButton.addEventListener('click', handleCardHomeButton);

//Show tha card selection list, if any purchases have been made
if(purchasedPack){
	createCardSelectionList(false);
} else {
	cardSrollableView.opacity = 1;
}

<|endoftext|>


<commit_before>import React, { Component, PropTypes } from 'react'
import {
    View,
    TouchableOpacity,
    StyleSheet,
    Text
} from 'react-native'

const handleTabPress = (index, multiple, selectedIndex, onTabPress) => {
    if (multiple) {
        onTabPress(index);
    }
    else if (selectedIndex !== index) {
        onTabPress(index);
    }
};

const TabOption = ({
    isTabActive, index, badge, text,
    firstTabStyle, lastTabStyle,
    tabStyle, activeTabStyle,
    tabTextStyle, activeTabTextStyle,
    tabBadgeContainerStyle, activeTabBadgeContainerStyle,
    tabBadgeStyle, activeTabBadgeStyle,
    onTabPress,
}) => {
    return (
        <TouchableOpacity style={[
            styles.tabStyle,
            tabStyle,
            isTabActive ? [styles.activeTabStyle, activeTabStyle] : {},
            firstTabStyle,
            lastTabStyle]}
            onPress={() => onTabPress(index)}
            activeOpacity={1}>
            <View style={{flexDirection:"row"}}>
                <Text style={[
                    styles.textStyle,
                    tabTextStyle,
                    isTabActive ? [styles.activeTabTextStyle, activeTabTextStyle] : {}]}>
                    {text}
                </Text>
                {
                    badge ?
                    <View style={[
                        styles.tabBadgeContainerStyle,
                        tabBadgeContainerStyle,
                        isTabActive ? [styles.activeTabBadgeContainerStyle, activeTabBadgeContainerStyle]: {}]}>
                        <Text style={[
                            styles.tabBadgeStyle,
                            tabBadgeStyle,
                            isTabActive ? [styles.activeTabBadgeStyle, activeTabBadgeStyle]: {}]}>
                            {badge}
                        </Text>
                    </View>: false
                }
            </View>
        </TouchableOpacity>
    );
}

const SegmentedControlTab = ({
    multiple, selectedIndex, selectedIndices, values,
    badges, borderRadius, tabsContainerStyle,
    tabStyle, activeTabStyle,
    tabTextStyle, activeTabTextStyle,
    tabBadgeContainerStyle, activeTabBadgeContainerStyle,
    tabBadgeStyle, activeTabBadgeStyle,
    onTabPress,
}) => {
    const firstTabStyle = [{ borderTopLeftRadius: borderRadius, borderBottomLeftRadius: borderRadius }];
    const lastTabStyle = [{ borderTopRightRadius: borderRadius, borderBottomRightRadius: borderRadius }];

    return (
        <View
            style={[styles.tabsContainerStyle, tabsContainerStyle]}
            removeClippedSubviews={true}>
            {
                values.map((item, index) => {
                    return (
                        <TabOption
                            key={index}
                            index={index}
                            badge={badges && badges[index] ? badges[index] : false}
                            isTabActive={multiple ? selectedIndices.includes(index) : selectedIndex === index}
                            text={item}
                            onTabPress={(index) => handleTabPress(index, multiple, selectedIndex, onTabPress)}
                            firstTabStyle={index === 0 ? firstTabStyle : {}}
                            lastTabStyle={index === values.length - 1 ? lastTabStyle : {}}
                            tabStyle={[tabStyle, index !== 0 && index !== values.length - 1 ? { marginHorizontal: -1 } : {}]}
                            activeTabStyle={activeTabStyle}
                            tabTextStyle={tabTextStyle}
                            activeTabTextStyle={activeTabTextStyle}
                            tabBadgeContainerStyle={tabBadgeContainerStyle}
                            activeTabBadgeContainerStyle={activeTabBadgeContainerStyle}
                            tabBadgeStyle={tabBadgeStyle}
                            activeTabBadgeStyle={activeTabBadgeStyle} />
                    );
                })
            }
        </View>
    );
};

SegmentedControlTab.propTypes = Object.assign({}, Component.propTypes, {
    values: PropTypes.array,
    badges: PropTypes.array,
    multiple: PropTypes.bool,
    onTabPress: PropTypes.func,
    selectedIndex: PropTypes.number,
    selectedIndices: PropTypes.arrayOf(PropTypes.number),
    tabsContainerStyle: View.propTypes.style,
    tabStyle: View.propTypes.style,
    activeTabStyle: View.propTypes.style,
    tabTextStyle: Text.propTypes.style,
    activeTabTextStyle: Text.propTypes.style,
    tabBadgeContainerStyle: Text.propTypes.style,
    activeTabBadgeContainerStyle: Text.propTypes.style,
    tabBadgeStyle: Text.propTypes.style,
    activeTabBadgeStyle: Text.propTypes.style,
    borderRadius: PropTypes.number
})

SegmentedControlTab.defaultProps = Object.assign({}, Component.propTypes, {
    values: ['One', 'Two', 'Three'],
    badges: ['', '', ''],
    multiple: false,
    selectedIndex: 0,
    selectedIndices: [0],
    onTabPress() { },
    tabsContainerStyle: {},
    tabStyle: {},
    activeTabStyle: {},
    textStyle: {},
    activeTextStyle: {},
    tabBadgeContainerStyle: {},
    activeTabBadgeContainerStyle: {},
    tabBadgeStyle: {},
    activeTabBadgeStyle: {},
    borderRadius: 5
})

const styles = StyleSheet.create({
    tabsContainerStyle: {
        backgroundColor: 'transparent',
        flexDirection: 'row',
    },
    tabStyle: {
        paddingVertical: 5,
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        borderColor: '#0076FF',
        borderWidth: 1,
        backgroundColor: 'white',
    },
    activeTabStyle: {
        backgroundColor: '#0076FF'
    },
    tabTextStyle: {
        color: '#0076FF'
    },
    activeTabTextStyle: {
        color: 'white'
    },
    tabBadgeContainerStyle: {
        borderRadius: 20,
        backgroundColor: 'red',
        paddingLeft: 5,
        paddingRight: 5,
        marginLeft: 5,
        marginBottom: 3
    },
    activeTabBadgeContainerStyle: {
        backgroundColor: 'white'
    },
    tabBadgeStyle: {
        color: 'white',
        fontSize: 11,
        fontWeight: 'bold'
    },
    activeTabBadgeStyle: {
        color: 'black'
    }
})

export default SegmentedControlTab
<commit_msg>Fixed RN glitch on iOS<commit_after>import React, { Component, PropTypes } from 'react'
import {
    View,
    TouchableOpacity,
    StyleSheet,
    Text
} from 'react-native'

const handleTabPress = (index, multiple, selectedIndex, onTabPress) => {
    if (multiple) {
        onTabPress(index);
    }
    else if (selectedIndex !== index) {
        onTabPress(index);
    }
};

const TabOption = ({
    isTabActive, index, badge, text,
    firstTabStyle, lastTabStyle,
    tabStyle, activeTabStyle,
    tabTextStyle, activeTabTextStyle,
    tabBadgeContainerStyle, activeTabBadgeContainerStyle,
    tabBadgeStyle, activeTabBadgeStyle,
    onTabPress,
}) => {
    return (
        <TouchableOpacity style={[
            styles.tabStyle,
            tabStyle,
            isTabActive ? [styles.activeTabStyle, activeTabStyle] : {},
            firstTabStyle,
            lastTabStyle]}
            onPress={() => onTabPress(index)}
            activeOpacity={1}>
            <View style={{flexDirection:"row"}}>
                <Text style={[
                    styles.textStyle,
                    tabTextStyle,
                    isTabActive ? [styles.activeTabTextStyle, activeTabTextStyle] : {}]}>
                    {text}
                </Text>
                {
                    badge ?
                    <View style={[
                        styles.tabBadgeContainerStyle,
                        tabBadgeContainerStyle,
                        isTabActive ? [styles.activeTabBadgeContainerStyle, activeTabBadgeContainerStyle]: {}]}>
                        <Text style={[
                            styles.tabBadgeStyle,
                            tabBadgeStyle,
                            isTabActive ? [styles.activeTabBadgeStyle, activeTabBadgeStyle]: {}]}>
                            {badge}
                        </Text>
                    </View>: false
                }
            </View>
        </TouchableOpacity>
    );
}

const SegmentedControlTab = ({
    multiple, selectedIndex, selectedIndices, values,
    badges, borderRadius, tabsContainerStyle,
    tabStyle, activeTabStyle,
    tabTextStyle, activeTabTextStyle,
    tabBadgeContainerStyle, activeTabBadgeContainerStyle,
    tabBadgeStyle, activeTabBadgeStyle,
    onTabPress,
}) => {
    const firstTabStyle = [{ borderTopLeftRadius: borderRadius, borderBottomLeftRadius: borderRadius }];
    const lastTabStyle = [{ borderTopRightRadius: borderRadius, borderBottomRightRadius: borderRadius }];

    return (
        <View
            style={[styles.tabsContainerStyle, tabsContainerStyle]}
            removeClippedSubviews={true}>
            {
                values.map((item, index) => {
                    return (
                        <TabOption
                            key={index}
                            index={index}
                            badge={badges && badges[index] ? badges[index] : false}
                            isTabActive={multiple ? selectedIndices.includes(index) : selectedIndex === index}
                            text={item}
                            onTabPress={(index) => handleTabPress(index, multiple, selectedIndex, onTabPress)}
                            firstTabStyle={index === 0 ? [{ borderRightWidth: 0 }, firstTabStyle ] : {}}
                            lastTabStyle={index === values.length - 1 ? [{ borderLeftWidth: 0 }, lastTabStyle ] : {}}
                            tabStyle={[tabStyle, index !== 0 && index !== values.length - 1 ? { marginHorizontal: -1 } : {}]}
                            activeTabStyle={activeTabStyle}
                            tabTextStyle={tabTextStyle}
                            activeTabTextStyle={activeTabTextStyle}
                            tabBadgeContainerStyle={tabBadgeContainerStyle}
                            activeTabBadgeContainerStyle={activeTabBadgeContainerStyle}
                            tabBadgeStyle={tabBadgeStyle}
                            activeTabBadgeStyle={activeTabBadgeStyle} />
                    );
                })
            }
        </View>
    );
};

SegmentedControlTab.propTypes = Object.assign({}, Component.propTypes, {
    values: PropTypes.array,
    badges: PropTypes.array,
    multiple: PropTypes.bool,
    onTabPress: PropTypes.func,
    selectedIndex: PropTypes.number,
    selectedIndices: PropTypes.arrayOf(PropTypes.number),
    tabsContainerStyle: View.propTypes.style,
    tabStyle: View.propTypes.style,
    activeTabStyle: View.propTypes.style,
    tabTextStyle: Text.propTypes.style,
    activeTabTextStyle: Text.propTypes.style,
    tabBadgeContainerStyle: Text.propTypes.style,
    activeTabBadgeContainerStyle: Text.propTypes.style,
    tabBadgeStyle: Text.propTypes.style,
    activeTabBadgeStyle: Text.propTypes.style,
    borderRadius: PropTypes.number
})

SegmentedControlTab.defaultProps = Object.assign({}, Component.propTypes, {
    values: ['One', 'Two', 'Three'],
    badges: ['', '', ''],
    multiple: false,
    selectedIndex: 0,
    selectedIndices: [0],
    onTabPress() { },
    tabsContainerStyle: {},
    tabStyle: {},
    activeTabStyle: {},
    textStyle: {},
    activeTextStyle: {},
    tabBadgeContainerStyle: {},
    activeTabBadgeContainerStyle: {},
    tabBadgeStyle: {},
    activeTabBadgeStyle: {},
    borderRadius: 5
})

const styles = StyleSheet.create({
    tabsContainerStyle: {
        backgroundColor: 'transparent',
        flexDirection: 'row',
    },
    tabStyle: {
        paddingVertical: 5,
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        borderColor: '#0076FF',
        borderWidth: 1,
        backgroundColor: 'white',
    },
    activeTabStyle: {
        backgroundColor: '#0076FF'
    },
    tabTextStyle: {
        color: '#0076FF'
    },
    activeTabTextStyle: {
        color: 'white'
    },
    tabBadgeContainerStyle: {
        borderRadius: 20,
        backgroundColor: 'red',
        paddingLeft: 5,
        paddingRight: 5,
        marginLeft: 5,
        marginBottom: 3
    },
    activeTabBadgeContainerStyle: {
        backgroundColor: 'white'
    },
    tabBadgeStyle: {
        color: 'white',
        fontSize: 11,
        fontWeight: 'bold'
    },
    activeTabBadgeStyle: {
        color: 'black'
    }
})

export default SegmentedControlTab
<|endoftext|>


<commit_before> function AppComponent() {
        this.notes = [];
        this.addTodo = function(note) {
			if(note.value!=="")
			{
				this.notes.push(note.value);
            note.value = null;
			}
            return false;
        }

    }

	function removeTodo(el)
	{

    el.parentNode.parentNode.parentNode.parentNode.parentNode.style.display="none";
	}
    AppComponent.annotations = [
      new angular.ComponentAnnotation({
        selector: 'sticky'
      }),
      new angular.ViewAnnotation({
        template: '

<input value="{{ note }}" type="text">

<button class="btn-floating btn-small waves-effect waves-light orange accent-3" onclick="removeTodo(this)">X</button>

<textarea id="textarea1" class="materialize-textarea" placeholder="enter your notes here"></textarea>

' +
                  '
<form (submit)="addTodo(notetext)"><input id="input_text" type="text" maxlength="20" placeholder="enter the note title" #notetext><button class="btn waves-effect waves-light orange accent-3" type="submit">+</button></form>
',
        directives: [angular.NgFor]
      })
    ];

    document.addEventListener('DOMContentLoaded', function() {
      angular.bootstrap(AppComponent);
    });
<commit_msg>Update index.js<commit_after> function AppComponent() {
        this.notes = [];
        this.addTodo = function(note) {
			if(note.value!=="")
			{
				this.notes.push(note.value);
            note.value = null;
			}
            return false;
        }

    }

	function removeTodo(el)
	{

    el.parentNode.parentNode.parentNode.parentNode.parentNode.style.display="none";
	}
    AppComponent.annotations = [
      new angular.ComponentAnnotation({
        selector: 'sticky'
      }),
      new angular.ViewAnnotation({
        template: '

<input value="{{ note }}" type="text">

<button class="btn-floating btn-small waves-effect waves-light orange accent-3" onclick="removeTodo(this)">X</button>

<textarea id="textarea1" class="materialize-textarea" placeholder="enter your notes here"></textarea>

' +
                  '

<form (submit)="addTodo(notetext)"><input id="input_text" type="text" maxlength="20" placeholder="enter the note title" #notetext><button class="btn waves-effect waves-light orange accent-3" type="submit">+</button></form>
',
        directives: [angular.NgFor]
      })
    ];

    document.addEventListener('DOMContentLoaded', function() {
      angular.bootstrap(AppComponent);
    });
<|endoftext|>


<commit_before>/**
 * Created by sachinpatney on 6/22/15.
 */

self.onmessage = function (e) {
    task();
    self.postMessage(e.data, []);
    self.close();
};
<commit_msg>Update worker.js<commit_after>/**
 * Created by sachinpatney on 6/22/15.
 */

self.onmessage = function (e) {
    window.task();
    self.postMessage(e.data, []);
    self.close();
};
<|endoftext|>


<commit_before>/**
 * Created by hen on 2/20/14.
 */
    var bbVis, brush, createVis, dataSet, handle, height, margin, svg, svg2, width;

    margin = {
        top: 50,
        right: 50,
        bottom: 50,
        left: 50
    };

    width = 960 - margin.left - margin.right;

    height = 300 - margin.bottom - margin.top;

    bbVis = {
        x: 0 + 100,
        y: 10,
        w: width - 100,
        h: 100
    };

    dataSet = [];

    svg = d3.select("#vis").append("svg").attr({
        width: width + margin.left + margin.right,
        height: height + margin.top + margin.bottom
    }).append("g").attr({
            transform: "translate(" + margin.left + "," + margin.top + ")"
        });

    d3.csv("timeline.csv", function(data) {

        // convert your csv data and add it to dataSet
		console.log(data);

        return createVis();
    });

    createVis = function() {
        var xAxis, xScale, yAxis,  yScale;

          xScale = d3.scale.linear().domain([0,100]).range([0, bbVis.w]);  // define the right domain generically

		  // example that translates to the bottom left of our vis space:
		  var visFrame = svg.append("g").attr({
		      "transform": "translate(" + bbVis.x + "," + (bbVis.y + bbVis.h) + ")",
		  	  //....

		  });

		  visFrame.append("rect");
		  //....

//        yScale = .. // define the right y domain and range -- use bbVis

//        xAxis = ..
//        yAxis = ..
//        // add y axis to svg !

    };
<commit_msg>got axis to display<commit_after>/**
 * Created by hen on 2/20/14.
 */
    var bbVis, brush, createVis, dataSet, handle, height, margin, svg, svg2, width;

    margin = {
        top: 50,
        right: 50,
        bottom: 50,
        left: 50
    };

    width = 960 - margin.left - margin.right;

    height = 300 - margin.bottom - margin.top;

    bbVis = {
        x: 0 + 100,
        y: 10,
        w: width - 100,
        h: 100
    };

    dataSet = [];

    svg = d3.select("#vis").append("svg").attr({
        width: width + margin.left + margin.right,
        height: height + margin.top + margin.bottom
    }).append("g").attr({
            transform: "translate(" + margin.left + "," + margin.top + ")"
        });

    d3.csv("timeline1.csv", function(data) {

        // convert your csv data and add it to dataSet
		console.log(data);
		console.log("hello");

        return createVis();
    });

    createVis = function() {
        var xAxis, xScale, yAxis,  yScale;

		//var width = 100;
		//var height = 100;

          xScale = d3.scale.linear().domain([0,100]).range([0, bbVis.w]);  // define the right domain generically

		  // example that translates to the bottom left of our vis space:

/*
		  var visFrame = svg.append("g").attr({
		      "transform": "translate(" + bbVis.x + "," + (bbVis.y + bbVis.h) + ")",
		  	  //....

		  });

		  visFrame.append("rect");
*/
  //....

//        yScale = .. // define the right y domain and range -- use bbVis

//        xAxis = ..
//        yAxis = ..
//        // add y axis to svg !

		var margin = {top: 20, right: 20, bottom: 30, left: 50},
		width = 960 - margin.left - margin.right,
		height = 500 - margin.top - margin.bottom;

		var x = d3.time.scale()
			.range([0, width]);

		var y = d3.scale.linear()
			.range([height, 0]);

		var xAxis = d3.svg.axis()
			.scale(x)
			.orient("bottom");

		var yAxis = d3.svg.axis()
			.scale(y)
			.orient("left");

		var svg = d3.select("body").append("svg")
		.attr("width", width + margin.left + margin.right)
		.attr("height", height + margin.top + margin.bottom)
		  .append("g")
		.attr("transform", "translate(" + margin.left + "," + margin.top + ")");

		  svg.append("g")
			  .attr("class", "x axis")
			  .attr("transform", "translate(0," + height + ")")
			  .call(xAxis);

		  svg.append("g")
			  .attr("class", "y axis")
			  .call(yAxis)
			.append("text")
			  .attr("transform", "rotate(-90)")
			  .attr("y", 6)
			  .attr("dy", ".71em")
			  .style("text-anchor", "end")
			  .text("Price ($)");

    };
<|endoftext|>


<commit_before>   $(function(){
       if($('#map-input-box').length >= 1){
         loadBaiduMap();
       }
       $('.pill-select').pillSelectBox();
       $('.datepicker').datetimepicker({lang: 'ch'});
       $('select').each(function(){$(this).val($(this).attr('value'))});

       // jquery upload and crop
       if(typeof FlashUploader !== 'undefined'){
          FlashUploader.init();

          $('.upload-photo-button').click(function(){
            FlashUploader.open(function(url){
              $('.image-showcase').append('<input type="hidden" name="images[]" value="'+url+'"/>');
              dispatcher.dispatch('image.uploaded', url);
            });
          });
       }

       if(typeof $.fn.fileupload !== 'undefined'){
         $('.upload-logo').fileupload({
          dataType: 'json',
          url:app_path+'/Util/upload/w/150/h/150/',
          add: function(e, data){
            $('#imgpreview-image').attr('src', app_path+'/Public/img/loading.gif');
            $('#imgpreview-image').show();
            data.submit();
          },
          done: function(e, data){
            $('#imgpreview-image').attr('src', app_path+'/Public/Uploaded/'+data.result.url);
            $('#hidden-input-image').val(data.result.url);
            $('#imgpreview-image').show();
          }
         });
       }

       if($.fn.validate !== undefined){
         $('.add-event-form').validate();
       }
   });
   function loadBaiduMap(){
       var script = document.createElement("script");
       script.src = "http://api.map.baidu.com/api?v=1.5&ak=1m5xok7fCAjkwvynKoxxEnb1&callback=onBaiduMapLoaded";
       document.body.appendChild(script);
   }

   function onBaiduMapLoaded(){
       var map = new BMap.Map('map-input-box');
       map.centerAndZoom(new BMap.Point(121.491, 31.233), 11);
       map.addControl(new BMap.NavigationControl({type: BMAP_NAVIGATION_CONTROL_ZOOM}));
       map_control.init(map);
   }

   // map control
   var map_control = {
       markers: [],
       marker: null,
       init: function(map){
           var self = this;
           var change_timer = null;
           self.map = map;
           self.map.addEventListener('click', function(e){
               var location = self.set_location(e.point, false, function(result){
                   $('.map-address').val(result);
                });
           });
           $('.map-address').keyup(function(){
               if(change_timer !== null){
                   clearTimeout(change_timer);
               }
               change_timer = setTimeout(function(){
                   var myGeo = new BMap.Geocoder();
                   myGeo.getPoint($('.map-address').val(), function(point){
                      if (point) {
                          self.set_location(point, true);
                      }
                      return null;
                   }, "北京市");
               }, 1000);
           });

           $('.add-location-button').click(self.save_location);
       },
       geocode: function(address){

       },
       set_location: function(point, center, callback){
           var self = this;
           if(self.marker === null){
             var redIcon = new BMap.Icon(app_path+"/Public/img/icons/red-marker.png", new BMap.Size(30, 36), {
                offset: new BMap.Size(15, 18)
            });
             var marker = new BMap.Marker(point, {icon: redIcon});
             self.map.addOverlay(marker);
             marker.setTop(true);
             self.marker = marker;
           }
           else{  // alread has a marker
              self.marker.setPosition(point);
           }
           $('.map-longitude').val(point.lng);
           $('.map-latitude').val(point.lat);
           if(center){
               self.map.setCenter(point);
           }
           var myGeo = new BMap.Geocoder();

           myGeo.getLocation(point, function(result){
                 if (result){
                     $('.map-province').val(result.addressComponents.province);
                     $('.map-city').val(result.addressComponents.city);
                     $('.add-location-button').prop('disabled', false);
                    if(callback !== undefined){
                        callback(result.address);
                    }
                 }
           });
       },
       save_location: function(){
          var self = this;
          if($('.map-address').val() == ''){
            return;
          }
          var item_dom = $('
'+
                  '<input type="hidden" name="lngs[]" value="'+$('.map-longitude').val()+'"/>'+
                  '<input type="hidden" name="lats[]" value="'+$('.map-latitude').val()+'"/>'+
                  '<input type="hidden" name="provinces[]" value="'+$('.map-province').val()+'"/>'+
                  '<input type="hidden" name="cities[]" value="'+$('.map-city').val()+'"/>'+
                  '<input type="hidden" name="places[]" value="'+$('.map-address').val()+'"/>'+
                  $('.map-address').val()+' 删除'+
                  '
');
          $('.location-sets').append(item_dom);
          (function(item_dom){  // create a scope to store current position data
            var dom = item_dom;
            var blueIcon = new BMap.Icon(app_path+"/Public/img/icons/blue-marker.png", new BMap.Size(26, 36), {
                offset: new BMap.Size(7, 18),
            });
            var marker = new BMap.Marker(new BMap.Point($('.map-longitude').val(), $('.map-latitude').val()), {icon: blueIcon});
            map_control.map.addOverlay(marker);
            dom.find('.delete-item').click(function(){
              map_control.map.removeOverlay(marker);
              dom.remove();
            });

          })(item_dom);

          $('.add-location-button').prop('disabled', true);
          $('.map-address').val('');
          return false;
       },

       delete_location: function(e){
          $(e.currentTarget).parent().remove();
       }

   };

$(function(){
    var name_check_keyup_timer = null;
    $('#inputName').keyup(function(){
        if(name_check_keyup_timer){
            clearTimeout(name_check_keyup_timer);
        }
        name_check_keyup_timer = setTimeout(function(){
            var name = $('#inputName').val();
            $('.name-checking').html('正在检查机构名称有没有被使用...');
            if(name == ''){
                $('.name-checking').html('请首先填写机构名称');
                $('.other-fields').hide();
                return;
            }
            $.get(app_path+'/User/ajax_check_name/name/'+name, function(res){
                if(!res){
                    $('.name-checking').html('该机构在地图上尚无记录，欢迎入驻公益地图');
                    $('.other-fields').show();
                }
                else{
                    // $('.name-checking').html('该机构已经在地图上注册。您可以申请成为协作者');
                    $('.name-checking').html('该机构已经在地图上注册。');
                    $('.other-fields').hide();
                }
            });
        }, 1000);
    });
})<commit_msg>big fix: marker disappear when editing<commit_after>   $(function(){
       if($('#map-input-box').length >= 1){
         loadBaiduMap();
       }
       $('.pill-select').pillSelectBox();
       $('.datepicker').datetimepicker({lang: 'ch'});
       $('select').each(function(){$(this).val($(this).attr('value'))});

       // jquery upload and crop
       if(typeof FlashUploader !== 'undefined'){
          FlashUploader.init();

          $('.upload-photo-button').click(function(){
            FlashUploader.open(function(url){
              $('.image-showcase').append('<input type="hidden" name="images[]" value="'+url+'"/>');
              dispatcher.dispatch('image.uploaded', url);
            });
          });
       }

       if(typeof $.fn.fileupload !== 'undefined'){
         $('.upload-logo').fileupload({
          dataType: 'json',
          url:app_path+'/Util/upload/w/150/h/150/',
          add: function(e, data){
            $('#imgpreview-image').attr('src', app_path+'/Public/img/loading.gif');
            $('#imgpreview-image').show();
            data.submit();
          },
          done: function(e, data){
            $('#imgpreview-image').attr('src', app_path+'/Public/Uploaded/'+data.result.url);
            $('#hidden-input-image').val(data.result.url);
            $('#imgpreview-image').show();
          }
         });
       }

       if($.fn.validate !== undefined){
         $('.add-event-form').validate();
       }
   });
   function loadBaiduMap(){
       var script = document.createElement("script");
       script.src = "http://api.map.baidu.com/api?v=1.5&ak=1m5xok7fCAjkwvynKoxxEnb1&callback=onBaiduMapLoaded";
       document.body.appendChild(script);
   }

   function onBaiduMapLoaded(){
       var map = new BMap.Map('map-input-box');
       map.centerAndZoom(new BMap.Point(121.491, 31.233), 11);
       map.addControl(new BMap.NavigationControl({type: BMAP_NAVIGATION_CONTROL_ZOOM}));
       map_control.init(map);
   }

   // map control
   var map_control = {
       markers: [],
       marker: null,
       init: function(map){
           var self = this;
           var change_timer = null;
           self.map = map;
           self.map.addEventListener('click', function(e){
               var location = self.set_location(e.point, false, function(result){
                   $('.map-address').val(result);
                });
           });
           $('.map-address').keyup(function(){
               if(change_timer !== null){
                   clearTimeout(change_timer);
               }
               change_timer = setTimeout(function(){
                   var myGeo = new BMap.Geocoder();
                   myGeo.getPoint($('.map-address').val(), function(point){
                      if (point) {
                          self.set_location(point, true);
                      }
                      return null;
                   }, "北京市");
               }, 1000);
           });

           if($('.map-longitude').val() != '' && $('.map-latitude').val() != ''){
              self.set_initial_location();
           }

           $('.add-location-button').click(self.save_location);
       },
       geocode: function(address){

       },
       set_location: function(point, center, callback){
           var self = this;
           if(self.marker === null){
             var redIcon = new BMap.Icon(app_path+"/Public/img/icons/red-marker.png", new BMap.Size(30, 36), {
                offset: new BMap.Size(15, 18)
            });
             var marker = new BMap.Marker(point, {icon: redIcon});
             self.map.addOverlay(marker);
             marker.setTop(true);
             self.marker = marker;
           }
           else{  // alread has a marker
              self.marker.setPosition(point);
           }
           $('.map-longitude').val(point.lng);
           $('.map-latitude').val(point.lat);
           if(center){
               self.map.setCenter(point);
           }
           var myGeo = new BMap.Geocoder();

           myGeo.getLocation(point, function(result){
                 if (result){
                     $('.map-province').val(result.addressComponents.province);
                     $('.map-city').val(result.addressComponents.city);
                     $('.add-location-button').prop('disabled', false);
                    if(callback !== undefined){
                        callback(result.address);
                    }
                 }
           });
       },
       set_initial_location: function(){
          var self = this;
          var lng = $('.map-longitude').val();
          var lat = $('.map-latitude').val();
          var point = new BMap.Point(lng, lat);
          var redIcon = new BMap.Icon(app_path+"/Public/img/icons/red-marker.png", new BMap.Size(30, 36), {
              offset: new BMap.Size(15, 18)
          });
          var marker = new BMap.Marker(point, {icon: redIcon});
          self.map.addOverlay(marker);
          self.map.centerAndZoom(point, 11);
          marker.setTop(true);
          self.marker = marker;
       },
       save_location: function(){
          var self = this;
          if($('.map-address').val() == ''){
            return;
          }
          var item_dom = $('
'+
                  '<input type="hidden" name="lngs[]" value="'+$('.map-longitude').val()+'"/>'+
                  '<input type="hidden" name="lats[]" value="'+$('.map-latitude').val()+'"/>'+
                  '<input type="hidden" name="provinces[]" value="'+$('.map-province').val()+'"/>'+
                  '<input type="hidden" name="cities[]" value="'+$('.map-city').val()+'"/>'+
                  '<input type="hidden" name="places[]" value="'+$('.map-address').val()+'"/>'+
                  $('.map-address').val()+' 删除'+
                  '
');
          $('.location-sets').append(item_dom);
          (function(item_dom){  // create a scope to store current position data
            var dom = item_dom;
            var blueIcon = new BMap.Icon(app_path+"/Public/img/icons/blue-marker.png", new BMap.Size(26, 36), {
                offset: new BMap.Size(7, 18),
            });
            var marker = new BMap.Marker(new BMap.Point($('.map-longitude').val(), $('.map-latitude').val()), {icon: blueIcon});
            map_control.map.addOverlay(marker);
            dom.find('.delete-item').click(function(){
              map_control.map.removeOverlay(marker);
              dom.remove();
            });

          })(item_dom);

          $('.add-location-button').prop('disabled', true);
          $('.map-address').val('');
          return false;
       },

       delete_location: function(e){
          $(e.currentTarget).parent().remove();
       }

   };

$(function(){
    var name_check_keyup_timer = null;
    $('#inputName').keyup(function(){
        if(name_check_keyup_timer){
            clearTimeout(name_check_keyup_timer);
        }
        name_check_keyup_timer = setTimeout(function(){
            var name = $('#inputName').val();
            $('.name-checking').html('正在检查机构名称有没有被使用...');
            if(name == ''){
                $('.name-checking').html('请首先填写机构名称');
                $('.other-fields').hide();
                return;
            }
            $.get(app_path+'/User/ajax_check_name/name/'+name, function(res){
                if(!res){
                    $('.name-checking').html('该机构在地图上尚无记录，欢迎入驻公益地图');
                    $('.other-fields').show();
                }
                else{
                    // $('.name-checking').html('该机构已经在地图上注册。您可以申请成为协作者');
                    $('.name-checking').html('该机构已经在地图上注册。');
                    $('.other-fields').hide();
                }
            });
        }, 1000);
    });
})<|endoftext|>


<commit_before>/**
 * @author Nomura Takahisa
 */

// 初期化
function AlarmWin() {
	var isEdit = false; // 編集中かどうか
	var alarmData = [];
	var Util = require('Util');
	var util = new Util();

	var init = function() {
		// SQLiteでデータを取ってきて、もしなければ初期データをいれる
		Titanium.API.info('好きでよかった');
		var db = Titanium.Database.open('mydb');
		db.execute('CREATE TABLE IF NOT EXISTS D_ALARM (ALARM_DATE INTEGER, VALID BOOL)');

		var rows = db.execute('SELECT * FROM D_ALARM');
		// もしデータがはいってなかったらデータをいれる
		if(!rows.isValidRow()) {
			Titanium.API.info('きー');
			db.execute('INSERT INTO D_ALARM (ALARM_DATE,VALID) VALUES(?,?)', 60 * 9 * 1000, false);
			Titanium.API.info('DateInsert');
		} else {
			Titanium.API.info('ほいさっさ');
			var i=0;
			while(rows.isValidRow()) {
				Titanium.API.info('ARAMA DATE=' + rows.fieldByName('alarm_date') + 'FLAG' + rows.fieldByName('valid'));
				alarmData[i] = {flag:rows.fieldByName('valid'), time:new Date(rows.fieldByName('alarm_date'))};
				rows.next();
				++i;
			}
		}

		rows.close();
		db.close();
	}();

	var self = Titanium.UI.createWindow({
		title : 'アラーム',
		backgroundColor : '#fff'
	});

	// var label1 = Titanium.UI.createLabel({
	// color:'#999',
	// text:'I am Window 2',
	// font:{fontSize:20,fontFamily:'Helvetica Neue'},
	// textAlign:'center',
	// width:'auto'
	// });
	var rowData = [];

	// var row1 = Ti.UI.createTableViewRow({
		// height : 50
	// });
	// var sw1 = Ti.UI.createSwitch({
		// right : 10,
		// value : false
	// });
	// row1.add(sw1);
//
	// var button1 = Ti.UI.createButton({
		// //style: Ti.UI.iPhone.SystemButton.DISCLOSURE,
		// left : 10
	// });
	// //row1.add(button1);
	// row1.className = 'control';
	// var row2 = Ti.UI.createTableViewRow({
		// height : 50
	// });
//
	for (var i = 0; i < alarmData.length; i++ ) {
		Ti.API.info("眠い稲");
		var row =  Ti.UI.createTableViewRow({height : 50});
		 row.color = '#000';
		row.font = {fontWeight:'bold'}
		row.title = util.dateToStr(alarmData[i].time);
		var sw = Ti.UI.createSwitch({
			right : 10,
			value : alarmData[i].flag
		});
		row.add(sw);
		rowData.push(row);
	}
	// rowData.push(row1);
	// rowData.push(row2);

	var tableView = Ti.UI.createTableView({
		data : rowData,
		//style: Ti.UI.iPhone.TableViewStyle.GROUPED
		//top: 50
	});

	var scoreWin = require('scoreWin').win;

	tableView.addEventListener('click', function(e) {
		var index = e.index;
		var section = e.section;
		var row = e.row;
		var rowdata = e.rowdata;
		// Titanium.UI.currentWindow.animate({
		// view: recordWin,
		// transition: Ti.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT
		// });
		// var childWin = Titanium.UI.createWindow({
		// title:'webwindow',
		// backgroundColor:'#333'
		// });

		self.containingTab.open(scoreWin, {
			animated : true
		});
		// Titanium.UI.currentTab.open(scoreWin, {
		// animated : true
		// });
		//childWin.open(true, {animated:true});

		//クリックで子画面を開く
		//navGrp.open(childWin, {animated:true});
	});

	var changeTableViewDisplay = function(isEdit){
		if(isEdit){

		}
	};

	// ナビボタン
	var rightButton = Titanium.UI.createButton({
		systemButton : Titanium.UI.iPhone.SystemButton.REFRESH
	});
	self.leftNavButton = rightButton;
	rightButton.addEventListener('click', function() {
		isEdit? isEdit=false:isEdit=true;
	});
	self.add(tableView);
	return self;
};

module.exports = AlarmWin;
<commit_msg>編集する時表示切り替え<commit_after>/**
 * @author Nomura Takahisa
 */

// 初期化
function AlarmWin() {
	var isEdit = false; // 編集中かどうか
	var alarmData = [];
	var Util = require('Util');
	var util = new Util();

	var init = function() {
		// SQLiteでデータを取ってきて、もしなければ初期データをいれる
		Titanium.API.info('好きでよかった');
		var db = Titanium.Database.open('mydb');
		db.execute('CREATE TABLE IF NOT EXISTS D_ALARM (ALARM_DATE INTEGER, VALID BOOL)');

		var rows = db.execute('SELECT * FROM D_ALARM');
		// もしデータがはいってなかったらデータをいれる
		if(!rows.isValidRow()) {
			Titanium.API.info('きー');
			db.execute('INSERT INTO D_ALARM (ALARM_DATE,VALID) VALUES(?,?)', 60 * 9 * 1000, false);
			Titanium.API.info('DateInsert');
		} else {
			Titanium.API.info('ほいさっさ');
			var i=0;
			while(rows.isValidRow()) {
				Titanium.API.info('ARAMA DATE=' + rows.fieldByName('alarm_date') + 'FLAG' + rows.fieldByName('valid'));
				alarmData[i] = {flag:rows.fieldByName('valid'), time:new Date(rows.fieldByName('alarm_date'))};
				rows.next();
				++i;
			}
		}

		rows.close();
		db.close();
	}();

	var self = Titanium.UI.createWindow({
		title : 'アラーム',
		backgroundColor : '#fff'
	});

	// var label1 = Titanium.UI.createLabel({
	// color:'#999',
	// text:'I am Window 2',
	// font:{fontSize:20,fontFamily:'Helvetica Neue'},
	// textAlign:'center',
	// width:'auto'
	// });
	var rowData = [];

	// var row1 = Ti.UI.createTableViewRow({
		// height : 50
	// });
	// var sw1 = Ti.UI.createSwitch({
		// right : 10,
		// value : false
	// });
	// row1.add(sw1);
//
	// var button1 = Ti.UI.createButton({
		// //style: Ti.UI.iPhone.SystemButton.DISCLOSURE,
		// left : 10
	// });
	// //row1.add(button1);
	// row1.className = 'control';
	// var row2 = Ti.UI.createTableViewRow({
		// height : 50
	// });
//
	for (var i = 0; i < alarmData.length; i++ ) {
		Ti.API.info("眠い稲");
		var row =  Ti.UI.createTableViewRow({height : 50});
		 row.color = '#000';
		row.font = {fontWeight:'bold'}
		row.title = util.dateToStr(alarmData[i].time);
		var sw = Ti.UI.createSwitch({
			right : 10,
			value : alarmData[i].flag
		});
		row.add(sw);
		rowData.push(row);
	}
	// rowData.push(row1);
	// rowData.push(row2);

	var tableView = Ti.UI.createTableView({
		data : rowData,
		//style: Ti.UI.iPhone.TableViewStyle.GROUPED
		//top: 50
	});

	var scoreWin = require('scoreWin').win;

	tableView.addEventListener('click', function(e) {
		var index = e.index;
		var section = e.section;
		var row = e.row;
		var rowdata = e.rowdata;
		// Titanium.UI.currentWindow.animate({
		// view: recordWin,
		// transition: Ti.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT
		// });
		// var childWin = Titanium.UI.createWindow({
		// title:'webwindow',
		// backgroundColor:'#333'
		// });

		self.containingTab.open(scoreWin, {
			animated : true
		});
		// Titanium.UI.currentTab.open(scoreWin, {
		// animated : true
		// });
		//childWin.open(true, {animated:true});

		//クリックで子画面を開く
		//navGrp.open(childWin, {animated:true});
	});

	var changeTableViewDisplay = function(isEdit){
		//if(isEdit){
			for (var i = 0; i < rowData.length; i++ ) {
				rowData[i].children[0].visible = !isEdit;
				rowData[i].hasChild = isEdit;
			}
		//}
	};

	// ナビボタン
	var rightButton = Titanium.UI.createButton({
		systemButton : Titanium.UI.iPhone.SystemButton.REFRESH
	});
	self.leftNavButton = rightButton;
	rightButton.addEventListener('click', function() {
		isEdit? isEdit=false:isEdit=true;
		changeTableViewDisplay(isEdit);
	});
	self.add(tableView);
	return self;
};

module.exports = AlarmWin;
<|endoftext|>


<commit_before>Divvy.Settings = {};

Divvy.Settings.init = function()
{
	/*
	 * Window elements
	 */
	this.win = Ti.UI.createWindow({
		title: 'Settings',
		barColor: Divvy.winBarColor,
		barImage: Divvy.winBarImage,
		modal:true,
		orientationModes: [
			Titanium.UI.PORTRAIT
		],
		backgroundColor: '#d6d8de'
	});
	//Check events done in the window.
	this.win.addEventListener('close', function(){
		Divvy.Settings.save();
	});

	//Create the Button
	this.doneButtonBar = Ti.UI.createButtonBar({
		labels: ['Done'],
		systemButton: Ti.UI.iPhone.SystemButtonStyle.DONE,
		backgroundColor: '5383e4'
	});

	this.doneButtonBar.addEventListener('click', function(e)
	{
		Divvy.Settings.done();
	});

	this.win.rightNavButton = this.doneButtonBar;

	//Start the TableView
	this.tableview = Ti.UI.createTableView({
		style: Ti.UI.iPhone.TableViewStyle.GROUPED,
	});

	//Table view will have sections
	this.general = Ti.UI.createTableViewSection();
	this.general.headerTitle = "General";

	//Create a row in first section
	this.row_name = Ti.UI.createTableViewRow({
		selectionStyle: Ti.UI.iPhone.TableViewCellSelectionStyle.NONE
	});
			//Customize the row
	this.label_name = Ti.UI.createLabel({
		text: 'Name',
		left: 10,
		font: { fontSize: 16, fontWeight: 'bold' }
	});

	this.textarea_name = Ti.UI.createTextField({
		hintText: 'Optional',
		left: 100,
		width: (Ti.Platform.osname == "ipad") ? '570' : '190', height: 24,
		editable: true,
		color: '#385487',
		keyboardType: Ti.UI.KEYBOARD,
		clearButtonMode: Titanium.UI.INPUT_BUTTONMODE_ONFOCUS,
	});

	//Add the row
	this.row_name.add(this.textarea_name);
	this.row_name.add(this.label_name);

	//Create row in first section (1st)
	this.row_push = Ti.UI.createTableViewRow({
		selectionStyle: Ti.UI.iPhone.TableViewCellSelectionStyle.NONE
	});

	//Customize the row
	this.label_push = Ti.UI.createLabel({
		text: 'Push Notifications',
		left: 10,
		font: { fontSize: 16, fontWeight: 'bold' }
	});

	this.switch_push = Ti.UI.createSwitch({
		value: false,
		left: 210
	});

	//Add the row
	this.row_push.add(this.switch_push);
	this.row_push.add(this.label_push);

	//Create row in first section (2nd)
	this.row_save = Ti.UI.createTableViewRow({
		selectionStyle: Ti.UI.iPhone.TableViewCellSelectionStyle.NONE
	});

	//Customize row
	this.label_save = Ti.UI.createLabel({
		text: 'Local Device Save',
		left: 10,
		font: { fontSize: 16, fontWeight: 'bold' }
	});

	this.switch_save = Ti.UI.createSwitch({
		value: false,
		left: 210
	});

	//Add the row
	this.row_save.add(this.switch_save);
	this.row_save.add(this.label_save);

	//Create a row in first section (3rd)
	this.row_cache = Ti.UI.createTableViewRow({
		title: 'Clear Local Device Data',
		hasChild: true
	});

	this.row_cache.addEventListener('click', function(e)
	{

	});

	//this.general.add(this.row_name);
	this.general.add(this.row_push);
	this.general.add(this.row_save);
	this.general.add(this.row_cache);
	this.tableview.add(this.general);

	//Create another section in table view
	this.pro = Ti.UI.createTableViewSection();
	this.pro.headerTitle = "Upgrade";

	//Create a row in second section
	this.row_pro = Ti.UI.createTableViewRow({
		selectionStyle: Ti.UI.iPhone.TableViewCellSelectionStyle.NONE,
		height: 80
	});

	this.image_pro = Ti.UI.createImageView({
		image: 'images/appicon.png',
		hires: true,
		height: 57,
		width: 57,
		top: 10,
		left: 10
	});

	this.row_pro.add(this.image_pro);

	//Customize that row
	this.label_pro = Ti.UI.createLabel({
		text: 'DivvyCam Pro',
		height: 18,
		top: 20,
		left: 80,
		font: { fontSize: 16, fontWeight: 'bold' }
	});

	this.label_price = Ti.UI.createLabel({
		text: '$0.00',
		height: 17,
		top: 38,
		left: 80,
		font:{fontSize: 14}
	});

	this.button_buy = Ti.UI.createButton({
		title: 'Purchase',
		top: 25,
		left: 210,
		height: 30,
		width: 75,
	});

	this.row_pro.add(this.button_buy);
	this.row_pro.add(this.label_price);
	this.row_pro.add(this.label_pro);

	//Create row for second section
	this.row_info = Ti.UI.createTableViewRow({
		selectionStyle: Ti.UI.iPhone.TableViewCellSelectionStyle.NONE,
		height: 80
	});

	//Customize that row
	this.label_info = Ti.UI.createLabel({
		text: 'Description',
		height: 'auto',
		top: 10,
		left: 10,
		font: { fontSize: 14, fontWeight: 'bold' }
	});

	this.label_description = Ti.UI.createLabel({
		text: 'Enables you to have unlimited buckets, better photo quality and no advertisements.',
		height: 'auto',
		top: 10,
		left: 100,
		font: { fontSize: 14 }
	});

	//Checking for previous purchase row
	this.row_purchase = Ti.UI.createTableViewRow({
		hasChild: true,
		title: 'Restore Previous Purchase'
	});

	this.row_purchase.addEventListener('click', function(e)
	{

	});

	this.row_info.add(this.label_info);
	this.row_info.add(this.label_description);

	//Add to the second section
	this.pro.add(this.row_pro);
	this.pro.add(this.row_info);
	this.pro.add(this.row_purchase);
	this.tableview.add(this.pro);

	//Add the sections to the tableview
	tableData = [this.general,this.pro];
	this.tableview.setData(tableData);
	this.win.add(this.tableview);

};

Divvy.Settings.open = function()
{
	this.switch_push.value = Ti.App.Properties.getBool("push_notifications");
	this.switch_save.value = Ti.App.Properties.getBool("save_device");
	this.win.open();
};

Divvy.Settings.done = function()
{
	this.win.close();
};
Divvy.Settings.save = function()
{
	var push_notifications = Divvy.Settings.switch_push.value;
	Ti.App.Properties.setBool("push_notifications", push_notifications);

	var save_device = Divvy.Settings.switch_save.value;
	Ti.App.Properties.setBool("save_device", save_device);

};
Divvy.Settings.clear = function()
{

};

<commit_msg>Whoopsies.<commit_after>Divvy.Settings = {};

Divvy.Settings.init = function()
{
	/*
	 * Window elements
	 */
	this.win = Ti.UI.createWindow({
		title: 'Settings',
		barColor: Divvy.winBarColor,
		barImage: Divvy.winBarImage,
		modal:true,
		orientationModes: [
			Titanium.UI.PORTRAIT
		],
		backgroundColor: '#d6d8de'
	});
	//Check events done in the window.
	this.win.addEventListener('close', function(){
		Divvy.Settings.save();
	});

	//Create the Button
	this.doneButtonBar = Ti.UI.createButtonBar({
		labels: ['Done'],
		systemButton: Ti.UI.iPhone.SystemButtonStyle.DONE,
		backgroundColor: '5383e4'
	});

	this.doneButtonBar.addEventListener('click', function(e)
	{
		Divvy.Settings.done();
	});

	this.win.rightNavButton = this.doneButtonBar;

	//Start the TableView
	this.tableview = Ti.UI.createTableView({
		style: Ti.UI.iPhone.TableViewStyle.GROUPED,
	});

	//Table view will have sections
	this.general = Ti.UI.createTableViewSection();
	this.general.headerTitle = "General";

	//Create a row in first section
	this.row_name = Ti.UI.createTableViewRow({
		selectionStyle: Ti.UI.iPhone.TableViewCellSelectionStyle.NONE
	});
			//Customize the row
	this.label_name = Ti.UI.createLabel({
		text: 'Name',
		left: 10,
		font: { fontSize: 16, fontWeight: 'bold' }
	});

	this.textarea_name = Ti.UI.createTextField({
		hintText: 'Optional',
		left: 100,
		width: (Ti.Platform.osname == "ipad") ? '570' : '190', height: 24,
		editable: true,
		color: '#385487',
		keyboardType: Ti.UI.KEYBOARD,
		clearButtonMode: Titanium.UI.INPUT_BUTTONMODE_ONFOCUS,
	});

	//Add the row
	this.row_name.add(this.textarea_name);
	this.row_name.add(this.label_name);

	//Create row in first section (1st)
	this.row_push = Ti.UI.createTableViewRow({
		selectionStyle: Ti.UI.iPhone.TableViewCellSelectionStyle.NONE
	});

	//Customize the row
	this.label_push = Ti.UI.createLabel({
		text: 'Push Notifications',
		left: 10,
		font: { fontSize: 16, fontWeight: 'bold' }
	});

	this.switch_push = Ti.UI.createSwitch({
		value: false,
		left: 210
	});

	//Add the row
	this.row_push.add(this.switch_push);
	this.row_push.add(this.label_push);

	//Create row in first section (2nd)
	this.row_save = Ti.UI.createTableViewRow({
		selectionStyle: Ti.UI.iPhone.TableViewCellSelectionStyle.NONE
	});

	//Customize row
	this.label_save = Ti.UI.createLabel({
		text: 'Local Device Save',
		left: 10,
		font: { fontSize: 16, fontWeight: 'bold' }
	});

	this.switch_save = Ti.UI.createSwitch({
		value: false,
		left: 210
	});

	//Add the row
	this.row_save.add(this.switch_save);
	this.row_save.add(this.label_save);

	//Create a row in first section (3rd)
	this.row_cache = Ti.UI.createTableViewRow({
		title: 'Clear Local Device Data',
		hasChild: true
	});

	this.row_cache.addEventListener('click', function(e)
	{
		Network.cache.clear();
	});

	//this.general.add(this.row_name);
	this.general.add(this.row_push);
	this.general.add(this.row_save);
	this.general.add(this.row_cache);
	this.tableview.add(this.general);

	//Create another section in table view
	this.pro = Ti.UI.createTableViewSection();
	this.pro.headerTitle = "Upgrade";

	//Create a row in second section
	this.row_pro = Ti.UI.createTableViewRow({
		selectionStyle: Ti.UI.iPhone.TableViewCellSelectionStyle.NONE,
		height: 80
	});

	this.image_pro = Ti.UI.createImageView({
		image: 'images/appicon.png',
		hires: true,
		height: 57,
		width: 57,
		top: 10,
		left: 10
	});

	this.row_pro.add(this.image_pro);

	//Customize that row
	this.label_pro = Ti.UI.createLabel({
		text: 'DivvyCam Pro',
		height: 18,
		top: 20,
		left: 80,
		font: { fontSize: 16, fontWeight: 'bold' }
	});

	this.label_price = Ti.UI.createLabel({
		text: '$0.00',
		height: 17,
		top: 38,
		left: 80,
		font:{fontSize: 14}
	});

	this.button_buy = Ti.UI.createButton({
		title: 'Purchase',
		top: 25,
		left: 210,
		height: 30,
		width: 75,
	});

	this.row_pro.add(this.button_buy);
	this.row_pro.add(this.label_price);
	this.row_pro.add(this.label_pro);

	//Create row for second section
	this.row_info = Ti.UI.createTableViewRow({
		selectionStyle: Ti.UI.iPhone.TableViewCellSelectionStyle.NONE,
		height: 80
	});

	//Customize that row
	this.label_info = Ti.UI.createLabel({
		text: 'Description',
		height: 'auto',
		top: 10,
		left: 10,
		font: { fontSize: 14, fontWeight: 'bold' }
	});

	this.label_description = Ti.UI.createLabel({
		text: 'Enables you to have unlimited buckets, better photo quality and no advertisements.',
		height: 'auto',
		top: 10,
		left: 100,
		font: { fontSize: 14 }
	});

	//Checking for previous purchase row
	this.row_purchase = Ti.UI.createTableViewRow({
		hasChild: true,
		title: 'Restore Previous Purchase'
	});

	this.row_purchase.addEventListener('click', function(e)
	{

	});

	this.row_info.add(this.label_info);
	this.row_info.add(this.label_description);

	//Add to the second section
	this.pro.add(this.row_pro);
	this.pro.add(this.row_info);
	this.pro.add(this.row_purchase);
	this.tableview.add(this.pro);

	//Add the sections to the tableview
	tableData = [this.general,this.pro];
	this.tableview.setData(tableData);
	this.win.add(this.tableview);

};

Divvy.Settings.open = function()
{
	this.switch_push.value = Ti.App.Properties.getBool("push_notifications");
	this.switch_save.value = Ti.App.Properties.getBool("save_device");
	this.win.open();
};

Divvy.Settings.done = function()
{
	this.win.close();
};
Divvy.Settings.save = function()
{
	var push_notifications = Divvy.Settings.switch_push.value;
	Ti.App.Properties.setBool("push_notifications", push_notifications);

	var save_device = Divvy.Settings.switch_save.value;
	Ti.App.Properties.setBool("save_device", save_device);

};
Divvy.Settings.clear = function()
{

};

<|endoftext|>


<commit_before><commit_msg>Delete medea.text.js<commit_after><|endoftext|>