
// tasktoy add task from project page fix
// Version 0.3
// 2005-08-19
// Copyright (c) 2005, Chris Millward
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.  To install it, you need
// Greasemonkey 0.3 or later: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "Tasktoy Add task from project page fix", and click Uninstall.
//
// --------------------------------------------------------------------
//
// Change Log
// Ver 0.3        sets pointer back to text box, for real this time
// Ver 0.2        set focus to 'Add task' text box on page load
// Ver 0.1        fixed 'Enter' in task text box

// ==UserScript==
// @name          Tasktoy Add task from project page fix
// @namespace     http://diveintogreasemonkey.org/download/
// @description   allows hitting 'Enter' in text box on Project view to add task, instead of trying to clear tasks
// @include       http://tasktoy.com/*
// ==/UserScript==

var Box = function(elem,foci) {
    if (document.getElementById(elem) && document.getElementById(foci)) {
	elem = document.getElementById(elem);
	foci = document.getElementById(foci);

	elem.onkeypress = function(event) {
	    if (event && event.which == 13) {
		addTask();
		event.preventDefault();
		foci.focus();
	    }
	    else
	    return true;
	}
    } 
}

var title;
title = document.getElementsByTagName('h1');
for (var i = 0; i < title.length; i++) {
    if (title[i].innerHTML == 'tasktoy') {
	title[i].innerHTML = '<a href="http://tasktoy.com/index_html">tasktoy</a>';
	break;
    }
}

if (document.getElementById('taskdescription')) {

    var elem = document.getElementById('taskdescription');
    elem.focus();
    Box('taskdescription','taskdescription');
    Box('taskactivedate','taskdescription');
    Box('tasklocation','taskdescription');

}

