Commit 105bb9a3522adcded79acd2bc2fe8c1e1f3c5526
1 parent
d43a98c6
No longer used.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4355 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
0 additions
and
249 deletions
presentation/lookAndFeel/knowledgeTree/js/misc.js deleted
| 1 | -/** | |
| 2 | - * Displays an alert message and then redirects to the specified url | |
| 3 | - */ | |
| 4 | -function redirectLink(alertMessage, url) { | |
| 5 | - alert(alertMessage); | |
| 6 | - self.location.href=url; | |
| 7 | -} | |
| 8 | - | |
| 9 | -/** | |
| 10 | - * Disables an element by blurring as soon as it focuses | |
| 11 | - */ | |
| 12 | -function disable(elem) { | |
| 13 | - elem.onfocus=elem.blur; | |
| 14 | -} | |
| 15 | - | |
| 16 | -function setActionAndSubmit(newAction) { | |
| 17 | - document.MainForm.action = newAction; | |
| 18 | - document.MainForm.submit(); | |
| 19 | -} | |
| 20 | - | |
| 21 | -function setActionAndSubmitSearch(newAction) { | |
| 22 | - document.MainForm.fForStandardSearch.value = 'yes'; | |
| 23 | - document.MainForm.method = 'GET'; | |
| 24 | - document.MainForm.action = newAction; | |
| 25 | - document.MainForm.submit(); | |
| 26 | -} | |
| 27 | - | |
| 28 | -function isEmailAddr(email) | |
| 29 | -{ | |
| 30 | - var result = false; | |
| 31 | - var theStr = new String(email); | |
| 32 | - var index = theStr.indexOf("@"); | |
| 33 | - if (index > 0) | |
| 34 | - { | |
| 35 | - var pindex = theStr.indexOf(".",index); | |
| 36 | - if ((pindex > index+1) && (theStr.length > pindex+1)) | |
| 37 | - result = true; | |
| 38 | - } | |
| 39 | - return result; | |
| 40 | -} | |
| 41 | - | |
| 42 | -function isBlank(formField) { | |
| 43 | - var result = false; | |
| 44 | - if (formField){ | |
| 45 | - // trim formField.value | |
| 46 | - formField.value = formField.value.replace(/\s+/g," ").replace(/^\s*|\s*$/g,""); | |
| 47 | - switch(formField.type){ | |
| 48 | - case "select-one": | |
| 49 | - if (formField.selectedIndex == 0 || formField.options[formField.selectedIndex].text == "" || formField.options[formField.selectedIndex].text == "None"){ | |
| 50 | - result = true; | |
| 51 | - } | |
| 52 | - break; | |
| 53 | - case "select-multiple": | |
| 54 | - if (formField.selectedIndex == -1){ | |
| 55 | - result = true; | |
| 56 | - } | |
| 57 | - break; | |
| 58 | - case "hidden": | |
| 59 | - case "text": | |
| 60 | - case "textarea": | |
| 61 | - if (formField.value == "" || formField.value == null){ | |
| 62 | - result = true; | |
| 63 | - } | |
| 64 | - break; | |
| 65 | - default: | |
| 66 | - if (formField.value == "" || formField.value == null){ | |
| 67 | - result = true; | |
| 68 | - } | |
| 69 | - } | |
| 70 | - } else { | |
| 71 | - result = true; | |
| 72 | - } | |
| 73 | - return result; | |
| 74 | -} | |
| 75 | - | |
| 76 | -function validRequired(formField,fieldLabel) | |
| 77 | -{ | |
| 78 | - var result = true; | |
| 79 | - if (formField){ | |
| 80 | - switch(formField.type){ | |
| 81 | - case "select-one": | |
| 82 | - if (formField.options[formField.selectedIndex].text == "" || formField.options[formField.selectedIndex].text == "None"){ | |
| 83 | - result = false; | |
| 84 | - } | |
| 85 | - break; | |
| 86 | - case "select-multiple": | |
| 87 | - if (formField.selectedIndex == -1){ | |
| 88 | - result = false; | |
| 89 | - } | |
| 90 | - break; | |
| 91 | - case "text": | |
| 92 | - case "textarea": | |
| 93 | - if (formField.value == "" || formField.value == null){ | |
| 94 | - result = false; | |
| 95 | - } | |
| 96 | - break; | |
| 97 | - default: | |
| 98 | - if (formField.value == "" || formField.value == null){ | |
| 99 | - result = false; | |
| 100 | - } | |
| 101 | - } | |
| 102 | - } | |
| 103 | - | |
| 104 | - if (!result) { | |
| 105 | - if (fieldLabel == "selected") { | |
| 106 | - alert('Please enter a value for the ' + fieldLabel +' field.'); | |
| 107 | - } else { | |
| 108 | - alert('Please enter a value for the "' + fieldLabel + '" field.'); | |
| 109 | - } | |
| 110 | - formField.focus(); | |
| 111 | - } | |
| 112 | - | |
| 113 | - return result; | |
| 114 | -} | |
| 115 | - | |
| 116 | -function allDigits(str) | |
| 117 | -{ | |
| 118 | - return inValidCharSet(str,"0123456789"); | |
| 119 | -} | |
| 120 | - | |
| 121 | -function inValidCharSet(str,charset) | |
| 122 | -{ | |
| 123 | - var result = true; | |
| 124 | - | |
| 125 | - // Note: doesn't use regular expressions to avoid early Mac browser bugs | |
| 126 | - for (var i=0;i<str.length;i++) | |
| 127 | - if (charset.indexOf(str.substr(i,1))<0) | |
| 128 | - { | |
| 129 | - result = false; | |
| 130 | - break; | |
| 131 | - } | |
| 132 | - | |
| 133 | - return result; | |
| 134 | -} | |
| 135 | - | |
| 136 | -function validEmail(formField,fieldLabel,required) | |
| 137 | -{ | |
| 138 | - var result = true; | |
| 139 | - | |
| 140 | - if (required && !validRequired(formField,fieldLabel)) | |
| 141 | - result = false; | |
| 142 | - | |
| 143 | - if (result && ((formField.value.length < 3) || !isEmailAddr(formField.value)) ) | |
| 144 | - { | |
| 145 | - alert("Please enter a complete email address in the form: yourname@yourdomain.com"); | |
| 146 | - formField.focus(); | |
| 147 | - result = false; | |
| 148 | - } | |
| 149 | - | |
| 150 | - return result; | |
| 151 | - | |
| 152 | -} | |
| 153 | - | |
| 154 | -function validNum(formField,fieldLabel,required) | |
| 155 | -{ | |
| 156 | - var result = true; | |
| 157 | - | |
| 158 | - if (required && !validRequired(formField,fieldLabel)) | |
| 159 | - result = false; | |
| 160 | - | |
| 161 | - if (result) | |
| 162 | - { | |
| 163 | - if (!allDigits(formField.value)) | |
| 164 | - { | |
| 165 | - alert('Please enter a number for the "' + fieldLabel +'" field.'); | |
| 166 | - formField.focus(); | |
| 167 | - result = false; | |
| 168 | - } | |
| 169 | - } | |
| 170 | - | |
| 171 | - return result; | |
| 172 | -} | |
| 173 | - | |
| 174 | - | |
| 175 | -function validInt(formField,fieldLabel,required) | |
| 176 | -{ | |
| 177 | - var result = true; | |
| 178 | - | |
| 179 | - if (required && !validRequired(formField,fieldLabel)) | |
| 180 | - result = false; | |
| 181 | - | |
| 182 | - if (result) | |
| 183 | - { | |
| 184 | - var num = parseInt(formField.value,10); | |
| 185 | - if (isNaN(num)) | |
| 186 | - { | |
| 187 | - alert('Please enter a number for the "' + fieldLabel +'" field.'); | |
| 188 | - formField.focus(); | |
| 189 | - result = false; | |
| 190 | - } | |
| 191 | - } | |
| 192 | - | |
| 193 | - return result; | |
| 194 | -} | |
| 195 | - | |
| 196 | - | |
| 197 | -function validDate(formField,fieldLabel,required) | |
| 198 | -{ | |
| 199 | - var result = true; | |
| 200 | - | |
| 201 | - if (required && !validRequired(formField,fieldLabel)) | |
| 202 | - result = false; | |
| 203 | - | |
| 204 | - if (result) | |
| 205 | - { | |
| 206 | - var elems = formField.value.split("-"); | |
| 207 | - | |
| 208 | - result = (elems.length == 3); // should be three components | |
| 209 | - | |
| 210 | - if (result) | |
| 211 | - { | |
| 212 | - var year = parseInt(elems[0],10); | |
| 213 | - var month = parseInt(elems[1],10); | |
| 214 | - var day = parseInt(elems[2],10); | |
| 215 | - result = allDigits(elems[0]) && (month > 0) && (month < 13) && | |
| 216 | - allDigits(elems[1]) && (day > 0) && (day < 32) && | |
| 217 | - allDigits(elems[2]) && ((elems[2].length == 2) || (elems[2].length == 4)); | |
| 218 | - } | |
| 219 | - | |
| 220 | - if (!result) | |
| 221 | - { | |
| 222 | - alert('Please enter a date in the format YYYY-MM-DD for the "' + fieldLabel +'" field.'); | |
| 223 | - formField.focus(); | |
| 224 | - } | |
| 225 | - } | |
| 226 | - | |
| 227 | - return result; | |
| 228 | -} | |
| 229 | - | |
| 230 | -/*function validateForm(theForm) | |
| 231 | -{ | |
| 232 | - // Customize these calls for your form | |
| 233 | - | |
| 234 | - // Start -------> | |
| 235 | - if (!validRequired(theForm.fullname,"Name")) | |
| 236 | - return false; | |
| 237 | - | |
| 238 | - if (!validEmail(theForm.email,"Email Address",true)) | |
| 239 | - return false; | |
| 240 | - | |
| 241 | - if (!validDate(theForm.available,"Date Available",true)) | |
| 242 | - return false; | |
| 243 | - | |
| 244 | - if (!validNum(theForm.yearsexperience,"Years Experience",true)) | |
| 245 | - return false; | |
| 246 | - // <--------- End | |
| 247 | - | |
| 248 | - return true; | |
| 249 | -}*/ |