1/** 2 * @package AcyMailing for Joomla! 3 * @version 4.6.2 4 * @author acyba.com 5 * @copyright (C) 2009-2014 ACYBA S.A.R.L. All rights reserved. 6 * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html 7 */ 8 9function submitacymailingform(task,formName){ 10 var varform = document[formName]; 11 var filterEmail = /^([a-z0-9_'&\.\-\+=])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,10})+$/i; 12 13 if(!varform.elements){ 14 if(varform[0].elements['user[email]'] && varform[0].elements['user[email]'].value && filterEmail.test(varform[0].elements['user[email]'].value)){ 15 varform = varform[0]; 16 }else{ 17 varform = varform[varform.length - 1]; 18 } 19 } 20 21 if(task != 'optout'){ 22 nameField = varform.elements['user[name]']; 23 if(nameField && (( typeof acymailing != 'undefined' && nameField.value == acymailing['NAMECAPTION'] ) || nameField.value.replace(/ /g,"").length < 2)){ 24 if(typeof acymailing != 'undefined'){ alert(acymailing['NAME_MISSING']); } 25 nameField.className = nameField.className +' invalid'; 26 return false; 27 } 28 } 29 30 var emailField = varform.elements['user[email]']; 31 if(emailField){ 32 if(typeof acymailing == 'undefined' || emailField.value != acymailing['EMAILCAPTION']) emailField.value = emailField.value.replace(/ /g,""); 33 if(!emailField || (typeof acymailing != 'undefined' && emailField.value == acymailing['EMAILCAPTION']) || !filterEmail.test(emailField.value)){ 34 if(typeof acymailing != 'undefined'){ alert(acymailing['VALID_EMAIL']); } 35 emailField.className = emailField.className +' invalid'; 36 return false; 37 } 38 } 39 40 if(varform.elements['hiddenlists'].value.length < 1){ 41 var listschecked = false; 42 var alllists = varform.elements['subscription[]']; 43 if(alllists && (typeof alllists.value == 'undefined' || alllists.value.length == 0)){ 44 for(b=0;b<alllists.length;b++){ 45 if(alllists[b].checked) listschecked = true; 46 } 47 if(!listschecked){ alert(acymailing['NO_LIST_SELECTED']); return false;} 48 } 49 } 50 51 52 if(task != 'optout' && typeof acymailing != 'undefined' && typeof acymailing['reqFields'+formName] != 'undefined' && acymailing['reqFields'+formName].length > 0){ 53 54 for(var i =0;i<acymailing['reqFields'+formName].length;i++){ 55 elementName = 'user['+acymailing['reqFields'+formName][i]+']'; 56 elementToCheck = varform.elements[elementName]; 57 if(elementToCheck){ 58 var isValid = false; 59 if(typeof elementToCheck.value != 'undefined'){ 60 if(elementToCheck.value==' ' && typeof varform[elementName+'[]'] != 'undefined'){ 61 if(varform[elementName+'[]'].checked){ 62 isValid = true; 63 }else{ 64 for(var a=0; a < varform[elementName+'[]'].length; a++){ 65 if((varform[elementName+'[]'][a].checked || varform[elementName+'[]'][a].selected) && varform[elementName+'[]'][a].value.length>0) isValid = true; 66 } 67 } 68 }else{ 69 if(elementToCheck.value.replace(/ /g,"").length>0){ 70 if(typeof acymailing['excludeValues'+formName] == 'undefined' || typeof acymailing['excludeValues'+formName][acymailing['reqFields'+formName][i]] == 'undefined' || acymailing['excludeValues'+formName][acymailing['reqFields'+formName][i]] != elementToCheck.value) isValid = true; 71 } 72 } 73 }else{ 74 for(var a=0; a < elementToCheck.length; a++){ 75 if(elementToCheck[a].checked && elementToCheck[a].value.length>0) isValid = true; 76 } 77 } 78 if(!isValid){ 79 elementToCheck.className = elementToCheck.className +' invalid'; 80 alert(acymailing['validFields'+formName][i]); 81 return false; 82 } 83 }else{ 84 if((varform.elements[elementName+'[day]'] && varform.elements[elementName+'[day]'].value<1) || (varform.elements[elementName+'[month]'] && varform.elements[elementName+'[month]'].value<1) || (varform.elements[elementName+'[year]'] && varform.elements[elementName+'[year]'].value<1902)){ 85 if(varform.elements[elementName+'[day]'] && varform.elements[elementName+'[day]'].value<1) varform.elements[elementName+'[day]'].className = varform.elements[elementName+'[day]'].className + ' invalid'; 86 if(varform.elements[elementName+'[month]'] && varform.elements[elementName+'[month]'].value<1) varform.elements[elementName+'[month]'].
86className = varform.elements[elementName+'[month]'].className + ' invalid'; 87 if(varform.elements[elementName+'[year]'] && varform.elements[elementName+'[year]'].value<1902) varform.elements[elementName+'[year]'].className = varform.elements[elementName+'[year]'].className + ' invalid'; 88 alert(acymailing['validFields'+formName][i]); 89 return false; 90 } 91 92 if((varform.elements[elementName+'[country]'] && varform.elements[elementName+'[country]'].value<1) || (varform.elements[elementName+'[num]'] && varform.elements[elementName+'[num]'].value<3)){ 93 if(varform.elements[elementName+'[country]'] && varform.elements[elementName+'[country]'].value<1) varform.elements[elementName+'[country]'].className = varform.elements[elementName+'[country]'].className + ' invalid'; 94 if(varform.elements[elementName+'[num]'] && varform.elements[elementName+'[num]'].value<3) varform.elements[elementName+'[num]'].className = varform.elements[elementName+'[num]'].className + ' invalid'; 95 alert(acymailing['validFields'+formName][i]); 96 return false; 97 } 98 } 99 } 100 } 101 102 if(task != 'optout' && typeof acymailing != 'undefined' && typeof acymailing['checkFields'+formName] != 'undefined' && acymailing['checkFields'+formName].length > 0){ 103 for(var i =0;i<acymailing['checkFields'+formName].length;i++){ 104 elementName = 'user['+acymailing['checkFields'+formName][i]+']'; 105 elementtypeToCheck = acymailing['checkFieldsType'+formName][i]; 106 elementToCheck = varform.elements[elementName].value; 107 switch(elementtypeToCheck){ 108 case 'number': 109 myregexp = new RegExp('^[0-9]*$'); 110 break; 111 case 'letter': 112 myregexp = new RegExp('^[A-Za-z\u00C0-\u017F ]*$'); 113 break; 114 case 'letnum': 115 myregexp = new RegExp('^[0-9a-zA-Z\u00C0-\u017F ]*$'); 116 break; 117 case 'regexp': 118 myregexp = new RegExp(acymailing['checkFieldsRegexp'+formName][i]); 119 break; 120 } 121 if(!myregexp.test(elementToCheck)){ 122 alert(acymailing['validCheckFields'+formName][i]); 123 return false; 124 } 125 } 126 } 127 128 var captchaField = varform.elements['acycaptcha']; 129 if(captchaField){ 130 if(captchaField.value.length<1){ 131 if(typeof acymailing != 'undefined'){ alert(acymailing['CAPTCHA_MISSING']); } 132 captchaField.className = captchaField.className +' invalid'; 133 return false; 134 } 135 } 136 137 if(task != 'optout'){ 138 var termsandconditions = varform.terms; 139 if(termsandconditions && !termsandconditions.checked){ 140 if(typeof acymailing != 'undefined'){ alert(acymailing['ACCEPT_TERMS']); } 141 termsandconditions.className = termsandconditions.className +' invalid'; 142 return false; 143 } 144 } 145 146 taskField = varform.task; 147 taskField.value = task; 148 149 if(!varform.elements['ajax'] || !varform.elements['ajax'].value || varform.elements['ajax'].value == '0'){ 150 varform.submit(); 151 return false; 152 } 153 154 if(window.jQuery){ 155 var form = jQuery('#'+formName); 156 157 data = form.serialize(); 158 jQuery.ajax({ 159 url: document.getElementById(formName).action, 160 data: data, 161 type: 'POST', 162 async: false, 163 complete: function(){ 164 form.addClass('acymailing_module_loading'); 165 form.css("filter:","alpha(opacity=50)"); 166 form.css("-moz-opacity","0.5"); 167 form.css("-khtml-opacity", "0.5"); 168 form.css("opacity", "0.5"); 169 }, 170 success:function(response){ 171 response = JSON.parse(response); 172 acymailingDisplayAjaxResponseJQuery( unescape(response.message), response.type, formName ); 173 }, 174 error:function(){ 175 acymailingDisplayAjaxResponseJQuery('Ajax Request Failure', 'error', formName); 176 } 177 }); 178 179 } else{ 180 try{ 181 var form = document.id(formName); 182 }catch(err){ 183 var form = $(formName); 184 } 185 data = form.toQueryString(); 186 187 if (typeof Ajax == 'function'){ 188 new Ajax(form.action, { 189 data: data, 190 method: 'post', 191 onRequest: function() 192 { 193 form.addClass('acymailing_module_loading'); 194 form.setStyle("filter:","alpha(opacity=50)"); 195 form.setStyle("-moz-opacity","0.5"); 196 form.setStyle("-khtml-opacity", "0.5"); 197 form.setStyle("opacity", "0.5"); 198 }, 199 onSuccess: function(response) 200 { 201 response = Json.evaluate(response); 202 acymailingDisplayAjaxResponseMootools(unescape(response.message), response.type, formName); 203 }, 204 onFailure: function(){ 205 acymailingDisplayAjaxResponseMootools('Ajax Request Failure', 'error', formName); 206 } 207 }).request(); 208 }else{ 209 new Request.JSON({ 210 url: document.id(formName).action, 211 data: data, 212 method: 'post', 213 onRequest: function() 214 { 215 form.addClass('acymailing_module_loading'); 216 form.setStyle("filter:","alpha(opacity=50)"); 217 form.setStyle("-moz-opacity","0.5"); 218 form.setStyle("-khtml-opacity", "0.5"); 219 form.setStyle("opacity", "0.5"); 220 }, 221 onSuccess: function(response) 222 { 223 acymailingDisplayAjaxResponseMootools(unescape(response.message), response.type, formName); 224 }, 225 onFailure: function(){ 226 acymailingDisplayAjaxResponseMootools('Ajax Request Failure', 'error', formName); 227 } 228 }).send(); 229 } 230 } 231 232 return false; 233} 234 235function acymailingDisplayAjaxResponseJQuery(message, type, formName){ 236 var toggleButton = jQuery('#acymailing_togglemodule_'+formName); 237 238 if (toggleButton && toggleButton.hasClass('acyactive')) { 239 var wrapper = toggleButton.parent().parent().children()[1]; 240 jQuery(wrapper).css('height', ''); 241 }; 242 243 var responseContainer = jQuery('#acymailing_fulldiv_'+formName+' .responseContainer')[0]; 244 245 if (typeof responseContainer == 'undefined'){ 246 responseContainer = document.createElement('div'); 247 var fulldiv = jQuery('#acymailing_fulldiv_'+formName); 248 fulldiv.prepend(responseContainer); 249 oldContainerHeight = '0px'; 250 }else{ 251 oldContainerHeight = jQuery(responseContainer).css('height'); 252 } 253 254 responseContainer.className = 'responseContainer'; 255 256 var form = jQuery('#'+formName); 257 258 form.removeClass('acymailing_module_loading'); 259 260 responseContainer.innerHTML = message; 261 262 if(type == 'success'){ 263 jQuery(responseContainer).addClass('acymailing_module_success'); 264 }else{ 265 jQuery(responseContainer).addClass('acymailing_module_error'); 266 form.css("filter:","alpha(opacity=100)"); 267 form.css("-moz-opacity","1"); 268 form.css("-khtml-opacity", "1"); 269 form.css("opacity", "1"); 270 } 271 272 newContainerHeight = jQuery(responseContainer).css('height'); 273 274 if(type == 'success'){ 275 form.animate({ 276 'height': 0, 277 'opacity': 0 278 }); 279 } 280 281 jQuery(responseContainer).css({
282 'height': oldContainerHeight, 283 'filter:':"alpha(opacity=0)", 284 '-moz-opacity':0, 285 '-khtml-opacity': 0, 286 'opacity': 0 287 }); 288 289 jQuery(responseContainer).animate({ 290 'height': newContainerHeight, 291 'opacity': 1 292 }); 293} 294 295function acymailingDisplayAjaxResponseMootools(message, type, formName) 296{ 297 try{ 298 var toggleButton = document.id('acymailing_togglemodule_'+formName); 299 }catch(err){ 300 var toggleButton = $('acymailing_togglemodule_'+formName); 301 } 302 303 if (toggleButton && toggleButton.hasClass('acyactive')) { 304 var wrapper = toggleButton.getParent().getParent().getChildren()[1]; 305 wrapper.setStyle('height', ''); 306 }; 307 308 try{ 309 var responseContainer = document.getElements('#acymailing_fulldiv_'+formName+' .responseContainer')[0]; 310 }catch(err){ 311 var responseContainer = $$('#acymailing_fulldiv_'+formName+' .responseContainer')[0]; 312 } 313 314 if (typeof responseContainer == 'undefined'){ 315 responseContainer = new Element('div'); 316 try{ 317 var fulldiv = document.id('acymailing_fulldiv_'+formName); 318 }catch(err){ 319 var fulldiv = $('acymailing_fulldiv_'+formName); 320 } 321 responseContainer.inject(fulldiv, 'top'); 322 oldContainerHeight = '0px'; 323 }else{ 324 oldContainerHeight = responseContainer.getStyle('height'); 325 } 326 327 responseContainer.className = 'responseContainer'; 328 329 try{ 330 var form = document.id(formName); 331 }catch(err){ 332 var form = $(formName); 333 } 334 form.removeClass('acymailing_module_loading'); 335 336 responseContainer.innerHTML = message; 337 338 if(type == 'success'){ 339 responseContainer.addClass('acymailing_module_success'); 340 }else{ 341 responseContainer.addClass('acymailing_module_error'); 342 form.setStyle("filter:","alpha(opacity=100)"); 343 form.setStyle("-moz-opacity","1"); 344 form.setStyle("-khtml-opacity", "1"); 345 form.setStyle("opacity", "1"); 346 } 347 348 newContainerHeight = responseContainer.getStyle('height'); 349 350 if (typeof Ajax == 'function') 351 { 352 if(type == 'success'){ 353 var myEffect = new Fx.Styles(form, {duration: 500, transition: Fx.Transitions.linear}); 354 myEffect.start({ 355 'height': [form.getSize().size.y, 0], 356 'opacity': [1, 0] 357 }); 358 } 359 360 try { 361 responseContainer.setStyle('height', oldContainerHeight+'px'); 362 responseContainer.setStyle("filter:","alpha(opacity=0)"); 363 responseContainer.setStyle("-moz-opacity","0"); 364 responseContainer.setStyle("-khtml-opacity", "0"); 365 responseContainer.setStyle("opacity", "0"); 366 } 367 catch (e) {} 368 369 var myEffect2 = new Fx.Styles(responseContainer, {duration: 500, transition: Fx.Transitions.linear}); 370 myEffect2.start({ 371 'height': [oldContainerHeight, newContainerHeight], 372 'opacity': [0, 1] 373 }); 374 375 } 376 else // Mootools >= 1.2 377 { 378 if(type == 'success'){ 379 form.set('morph'); 380 form.morph({ 381 'height': '0px', 382 'opacity': 0 383 }); 384 385 form.setStyles({ 386 'display': 'none' 387 }); 388 } 389 390 if(newContainerHeight != 'auto'){ 391 responseContainer.setStyles({ 392 'height': oldContainerHeight, 393 'opacity': 0 394 }); 395 396 responseContainer.set('morph'); 397 responseContainer.morph({ 398 'height': newContainerHeight, 399 'opacity': 1 400 }); 401 } 402 } 403} 404 405function refreshCaptchaModule(formName){ 406 var captchaLink = document.getElementById('captcha_picture_'+formName).src; 407 myregexp = new RegExp('val[-=]([0-9]+)'); 408 valToChange=captchaLink.match(myregexp)[1]; 409 document.getElementById('captcha_picture_'+formName).src = captchaLink.replace(valToChange,valToChange+'0'); 410}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.