Tag Archive for 'Javascript'

Page 2 of 2

Convertir de Celsius a Fahrenheit Online

Debido a que estuve bastantes visitas en mi versión wxWidgets del conversor de Celsius a Fahrenheit, decidí preparar una versión online que permita realizar fácilmente la conversión.

Celsius:
Fahrenheit:



GNU GPL v3 Convert Celsius to Fahrenheit Online está liberado bajo la licencia GNU GPL v3

Acá está el código fuente completo:

<script type="text/javascript">
// *****************************************************************************
// Description: Convertir de Celsius a Fahrenheit Online by NeoEGM
// Author: Ezequiel Miravalles
// Last modification: 16/08/2009
// URL: http://www.neoegm.com/es/tech/online-tools/convert-celsius-to-fahrenheit-online/
// *****************************************************************************

/*******************************************************************************
	Copyright (C) 2009 Ezequiel Gastón Miravalles

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/

function isNumber(x)
{ 
  return ( (typeof x === typeof 1) && (null !== x) && isFinite(x) );	//From http://snippets.dzone.com/posts/show/6937
}

function Round(number, digits)
{
	return Math.round(number * Math.pow(10,digits)) / Math.pow(10, digits);
}

function CelsiusToFahrenheit(celsius, fahrenheit)
{
	var num = celsius.value;
	
	if (num == "" || !isNumber(Number(num)))
		alert("Por favor ingresar un número");
	else
		fahrenheit.value=Round((9/5)*num+32, 2);
}

function FahrenheitToCelsius(fahrenheit, celsius)
{
	var num = fahrenheit.value;
	
	if (num == "" || !isNumber(Number(num)))
		alert("Por favor ingresar un número");
	else
		celsius.value=Round((5/9)*(num-32), 2);
}
</script>

<table>
<tr>
<td>Celsius:</td>
<td><input type="text" name="celsius_field" id="celsius_field" style="width:100px" /></td>
<td><input type="button" value="A Fahrenheit" onclick="CelsiusToFahrenheit($('celsius_field'), $('fahrenheit_field'))" /></td>
</tr>
<tr>
<td>Fahrenheit:</td>
<td><input type="text" name="fahrenheit_field" id="fahrenheit_field" style="width:100px" /></td>
<td><input type="button" value="A Celsius" onclick="FahrenheitToCelsius($('fahrenheit_field'), $('celsius_field'))" /></td>
</tr>
</table>

Incoming search terms for the article:

Mover el Recuadro de Eventos de Facebook hacia Arriba

Facebook tiene algunas funcionalidades muy interesantes… Una de ellas es la posibilidad de tener un recordatorio de los cumpleaños de tus amigos y de los eventos a los que te suscribiste…

Pero (siempre hay un pero 8-))… No están en un lugar muy cómodo…

Así que… Decidí hacer un script para moverlos a arriba de todo :)

FacebookEventsToTop

¿¿Cómo lo instalo??

Incoming search terms for the article:

Generador de contraseñas aleatorias

Como una alternativa simple y rápida de usar al Generador de contraseñas aleatorias para Excel, hice esta adaptación Javascript del código de la función de generación aleatoria de contraseñas… Podés ver el código fuente más abajo…

Caracteres


Mayúsculas Minúsculas Números

Contraseña Aleatoria


GNU GPL v3El código está liberado bajo la licencia GNU GPL v3
En caso de que quieras ver el código de la función sin tener que buscar en el código fuente de la página:

/*************************************************************************************************
Random Password Generator by NeoEGM

Copyright (C) 2009 Ezequiel Gastón Miravalles

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*************************************************************************************************/

/*************************************************************************************************
Software: Random Password Generator by NeoEGM
Author: Ezequiel Gastón Miravalles
Website: http://www.neoegm.com/software/random-password-generator/
License: GNU GPL v3 (read above)
*************************************************************************************************/

function RandomPassword(Length, Upper, Numbers, Lower)
{
	Upper = typeof(Upper) != 'undefined' ? Upper : true;
	Numbers = typeof(Numbers) != 'undefined' ? Numbers : true;
	Lower = typeof(Lower) != 'undefined' ? Lower : true;
	
    if (!Upper && !Lower && !Numbers)
		return "";

    var Ret = "";
    var Num;
    var Repeat;

    Chars = 26 * 2 + 10;	//26 (a-z) + 26 (A-Z) + 10 (0-9)
	//a-z = 97-122
	//A-Z = 65-90
	//0-9 = 48-57

    for (i = 1; i <= Length; i++)
	{
        Repeat = false;

        Num = Math.floor(Math.random()*Chars);

        if (Num < 26)
            if (Lower)
                Ret = Ret + String.fromCharCode(Num + 97);
            else
                Repeat = true;
        else if (Num < 52)
            if (Upper)
                Ret = Ret + String.fromCharCode(Num - 26 + 65);
            else
                Repeat = true;
        else if (Num < 62)
            if (Numbers)
                Ret = Ret + String.fromCharCode(Num - 52 + 48);
            else
                Repeat = true;

        if (Repeat)
            i--;
	}

    return Ret;
}

Incoming search terms for the article: