Fixed a problem where it would jump up and down the page when
[cocanwiki.git] / html / _js / new_page.js
1 /* $Id: new_page.js,v 1.1 2004/10/24 17:32:54 rich Exp $ */
2
3 var div;
4 var timer;
5
6 function init ()
7 {
8   document.f.title.focus ();
9   document.f.submit.disabled = true;
10   div = document.getElementById ("show_link");
11 }
12
13 function update ()
14 {
15   if (timer) clearTimeout (timer);
16   timer = setTimeout ("update_now ()", 1);
17 }
18
19 function update_now ()
20 {
21   timer = null;
22
23   var title = document.f.title.value;
24   if (title.search (/[a-z0-9]/gi) == -1) {
25     document.f.submit.disabled = true;
26     div.innerHTML = "";
27   } else {
28     document.f.submit.disabled = false;
29     title = title.replace (/&/g, "&");
30     title = title.replace (/</g, "&lt;");
31     title = title.replace (/>/g, "&gt;");
32     title = title.replace (/\"/g, "&quot;");
33     div.innerHTML = "You can create links to this page when editing by putting two square brackets around the page name, like this: <br/><br/> <code>[[" + title + "]]</code>";
34   }
35 }