Files
mythoughts/functions.js
2013-08-07 14:39:34 +02:00

54 lines
1.2 KiB
JavaScript
Executable File

function emptyBox(element, text)
{
//var textarea = $('#thoughts_form textarea[name="thoughts"]');
if(element.value == text)
{
element.value = '';
}
else if(element.value == '')
{
element.value = text;
}
}
function setHeight(element)
{
var padtext = element.value;
var height = Math.max(300, 130 + Math.round((padtext.length / 85 + padtext.split("\n").length) * 20));
//alert(height);
element.style.height = height+'px';
}
function goTo(url)
{
window.location.href = url;
}
function addInput(form, name, type, value)
{
var registerInput = document.createElement('input');
registerInput.setAttribute('type', type);
registerInput.setAttribute('name', name);
registerInput.setAttribute('value', value);
document.forms[form].appendChild(registerInput);
}
/*
texts = new Object();
texts['thoughts'] = 'Talk to me.';
texts['login'] = 'Nickname';
texts['pass'] = 'Password';
window.onload = function ()
{
for (i in texts)
{
var id = document.getElementById(i);
if(id)
{
id.addEventListener('focus', function() {emptyBox(this, texts[this.name]);}, false);
id.addEventListener('blur', function() {emptyBox(this, texts[this.name]);}, false);
}
}
};
*/