Git Product home page Git Product logo

workshop's People

Watchers

 avatar  avatar

workshop's Issues

js.js

`console.log('Workshop final')

/* // Mini Parallax
$(document).ready(function () {
$(document).scroll(function () {
var scrollTop = $(window).scrollTop()
$('#background1').css('top', -(scrollTop * 0.25) + 'px')
$('#background2').css('top', -(scrollTop * 0.75) + 'px')
$('#background3').css('top', -(scrollTop * 2) + 'px')
})
})

// END Mini Parallax */

/* Call API */

console.log('Init')

/* Call API People*/

var url = 'https://swapi.co/api/people'

function ajaxCall (url, cbk) {

$.ajax({
	url: url,
	method: 'GET' 
})
.done(function	(response) {
	cbk(null, response)
})
.fail(function(error) {
	cbk(error)
})
}

/* END Call API People*/

/* Resultado API */

var resultTotal = []

var callback = function(error, response) {

if(error) {
	console.log('Error: ', error)
}	

else {
	resultTotal = resultTotal.concat(response.results)
	if (response.next) {
		
	ajaxCall(response.next, callback)
	// Si hay una paginación nueva, la llama.
	
	}
	else {
	// Si no hay una paginación nueva, muestra el resultado total concatenado. 
	var resultsTotalOrdered = orderByName(resultTotal)
	showName(resultsTotalOrdered)
	
		}
	
	}

}

function showName(results) {
for(var i = 0; i < results.length; i++) {
var item = results[i]
var name = item.name
var height = tHeight(item.height)
var eye_color = translateEye_Color(item.eye_color)
var gender = translateGender(item.gender)

	console.log(name + ' ' + height + ' ' + eye_color + ' ' + gender)
	
}

}

ajaxCall(url, callback)

$('#nav-item nav-link text-warning').click(function(event){
var value = event.target.value
var
})

//function translate(name) {
// if () {

// }

//}

function orderByName (items) {
return items.sort(function (a, b) {
if (a.name > b.name) {
return 1
}
if (a.name < b.name) {
return -1
}
return 0
})
}

function translateGender (gender) {

switch (gender) {
	case 'male':
		return 'Hombre'
			break
	case 'female':
		return 'Mujer'
			break
	case 'hermaphrodite':
		return 'Hermafrodita'
			break
	case 'n/a':
		return 'Desconocido'
			break
}

}

function translateEye_Color (key) {

switch (key) {
	case 'blue':
		return 'Azul'
			break
	case 'dark':
		return 'Oscuro'
			break
	case 'white':
		return 'Blanco'
			break
	case 'blue':
		return 'Azul'
			break		
	case 'black':
		return 'Negro'
			break			
	case 'yellow':
		return 'Amarillo'
			break
	case 'red':
		return 'Rojo'
			break
	case 'brown':
		return 'Marrón'
			break
	case 'green':
		return 'Verde'
			break
	case 'orange':
		return 'Naranja'
			break	
	case 'hazel':
		return 'Avellana'
			break						
	case 'unknown':
		return 'Desconocido'
			break
	case 'pink':
		return 'Rosa'
			break		
	case 'n/a':
		return 'Desconocido'
			break		
	case undefined:
		return 'Desconocido'
			break	
	case 'default':
		return 'Multiple'
			break						
}

}

function tHeight(height) {
if (height != 'unknown') {

var integer = parseInt(height)
return integer
 }

else {
	return 'Desconocida'

}

}

/*if (typeof integer != 'number') {
	return 'Altura desconocida'
}
else {
	return integer
}
	
}*/

/* END Resultado API */
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.