slitaz-pizza view web/lib/functions.js @ rev 9

Edit pizza
author Paul Issott <paul@slitaz.org>
date Sun Mar 25 00:44:53 2012 +0000 (2012-03-25)
parents 8b324cb2c5e2
children 3163fd557f92
line source
1 // SliTaz Pizza Javascript functions.
2 //
4 // Check form to avoid empty values and bad email.
5 function checkForm() {
6 if(document.forms["pizza"]["flavor"].value == "")
7 {
8 alert("Please enter SliTaz pizza flavor name");
9 document.forms["pizza"]["flavor"].focus();
10 return false;
11 }
12 if(document.forms["pizza"]["desc"].value == "")
13 {
14 alert("Please fill in the flavor description");
15 document.forms["pizza"]["desc"].focus();
16 return false;
17 }
18 var x=document.forms["pizza"]["mail"].value;
19 var atpos=x.indexOf("@");
20 var dotpos=x.lastIndexOf(".");
21 if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
22 {
23 alert("Missing or not a valid email address");
24 return false;
25 }
26 }
28 // Notification messages
29 function setOpacity(notifyId, opacityLevel) {
30 var notifyStyle = document.getElementById(notifyId).style;
31 notifyStyle.opacity = opacityLevel / 100;
32 notifyStyle.filter = 'alpha(opacity='+opacityLevel+')';
33 }
35 function fadeNotify(notifyId, startOpacity, stopOpacity, duration) {
36 var speed = Math.round(duration / 100);
37 var timer = 2000;
38 for (var i=startOpacity; i>=stopOpacity; i--) {
39 setTimeout("setOpacity('"+notifyId+"',"+i+")", timer * speed);
40 timer++;
41 }
42 }
44 function hideNotify() {
45 document.getElementById('notify').style.display = 'none';
46 }