1(function (window, document) { 2 var $ = window.jQuery; 3 if (!$) { 4 alert('jQuery is not included, Please include first!'); 5 return; 6 } 7 8function nsfRefreshCaptcha() { 9 var img = document.images['captchaimg']; 10 img.src = img.src.substring(0, img.src.lastIndexOf("?")) + "?rand=" + Math.random() * 1000; 11} 12 13function nsfValidateCaptcha(captcha) { 14 15 var dataString = 'captcha=' + captcha; 16 var url = $('.verification').val(); 17 var response = $.ajax({ 18 type: 'POST', 19 async: false, 20 url: url, 21 data: dataString, 22 success: function(response) { 23 24 }, 25 error: function() { 26 alert('Captcha not Mathched'); 27 } 28 }); 29 return response.responseText; 30} 31 32$(document).ready(function () { 33 $('.ns-alert-close').on('click', function(){ 34 $('.ns-alert-wrap').hide(); 35 $('.ns-alert-hp').hide(); 36 $(".ns-submit-form").trigger("reset"); 37 $(".ns-popup-form").trigger("reset"); 38 location.reload(); 39 }); 40 /* $('.ns-alert-close-hp').on('click', function(){ 41 location.reload(); 42 }); */ 43 $('.popup-email-error .alert-danger .close').on('click', function(){ 44 $('.popup-email-error').hide(); 45 }); 46 47 if($('.quick-scoreboard').length > 0){ 48 var yescount = ($('.bar-yes').data('count') ? $('.bar-yes').data('count') : 0) 49 var nocount = ($('.bar-no').data('count') ? $('.bar-no').data('count') : 0) 50 var yesbutcount = ($('.bar-yesbut').data('count') ? $('.bar-yesbut').data('count') : 0) 51 var nobutcount = ($('.bar-nobut').data('count') ? $('.bar-nobut').data('count') : 0) 52 var total = yescount + nocount + yesbutcount + nobutcount; 53 var yesper = 0; 54 var noper = 0; 55 var yesbutper = 0; 56 var nobutper = 0; 57 if(total > 0){ 58 yesper = yescount * 100 / total; 59 noper = nocount * 100 / total; 60 yesbutper = yesbutcount * 100 / total; 61 nobutper = nobutcount * 100 / total; 62 } 63 $('.bar-yes').css({"width": yesper+"%","background-color": nsfBgColor(yesper)}); 64 $('.bar-no').css({"width": noper+"%","background-color": nsfBgColor(noper)}); 65 $('.bar-yesbut').css({"width": yesbutper+"%","background-color": nsfBgColor(yesbutper)}); 66 $('.bar-nobut').css({"width": nobutper+"%","background-color": nsfBgColor(nobutper)}); 67 } 68 69 if($('.rating-score').length > 0){ 70 var fstarc = ($('.bar-5').data('count') ? $('.bar-5').data('count') : 0) 71 var fostarc = ($('.bar-4').data('count') ? $('.bar-4').data('count') : 0) 72 var thstarc = ($('.bar-3').data('count') ? $('.bar-3').data('count') : 0) 73 var tstarc = ($('.bar-2').data('count') ? $('.bar-2').data('count') : 0) 74 var ostarc = ($('.bar-1').data('count') ? $('.bar-1').data('count') : 0) 75 var total = fstarc + fostarc + thstarc + tstarc + ostarc; 76 var fstarp = 0; 77 var fostarp = 0; 78 var thstarp = 0; 79 var tstarp = 0; 80 var ostarp = 0; 81 if(total > 0){ 82 fstarp = fstarc * 100 / total; 83 fostarp = fostarc * 100 / total; 84 thstarp = thstarc * 100 / total; 85 tstarp = tstarc * 100 / total; 86 ostarp = ostarc * 100 / total; 87 } 88 89 $('.bar-5').css({"width": fstarp+"%","background-color":nsfBgColor(fstarp)}); 90 $('.bar-4').css({"width": fostarp+"%","background-color":nsfBgColor(fostarp)}); 91 $('.bar-3').css({"width": thstarp+"%","background-color":nsfBgColor(thstarp)}); 92 $('.bar-2').css({"width": tstarp+"%","background-color":nsfBgColor(tstarp)}); 93 $('.bar-1').css({"width": ostarp+"%","background-color":nsfBgColor(ostarp)}); 94 } 95 96 if($('footer').length > 0 ){ 97 $(".global-ns-feedback").insertBefore( "footer" ); 98 } 99 var effect = $('.animationEffect').val(); 100 var boxid; 101 $('.commentboxbtn').click(function() { 102 103 idClass = $(this).attr('id'); 104 boxid = $(this).data('boxid'); 105 $('.comment-submit-btn').attr({ 106 buttonfor: $(this).data('buttonfor'), 107 qkbtn: $(this).data('qkbtn'), 108 cid: $(this).data('cid'), 109 newsid: $(this).data('newsid') 110 }); 111 $('.commentbox').addClass(boxid); 112 if (effect == 'toggle') { 113 $('.commenttxt').toggle(); 114 } 115 if (effect == 'slide') { 116 $('.commenttxt').slideToggle(); 117 } 118 if (effect == 'fade') { 119 $('.commenttxt').fadeToggle(); 120 } 121 if($(".quick-submit[qkbtn='yes']").length>0){ 122 $(".quick-submit[qkbtn='yes']").toggleClass('disabled-quickBtn'); 123 } 124 if($(".quick-submit[qkbtn='no']").length>0){ 125 $(".quick-submit[qkbtn='no']").toggleClass('disabled-quickBtn'); 126 } 127 128 if($(".commentboxbtn[data-qkbtn='yesbut']").length>0){ 129 if($(".commentboxbtn[data-qkbtn='yesbut']").data('boxid')!=boxid){ 130 131 $(".commentboxbtn[data-qkbtn='yesbut']").toggleClass('disabled-quickBtn'); 132 } 133 } 134 if($(".commentboxbtn[data-qkbtn='nobut']").length>0){ 135 136 if($(".commentboxbtn[data-qkbtn='nobut']").data('boxid')!=boxid){ 137 138 $(".commentboxbtn[data-qkbtn='nobut']").toggleClass('disabled-quickBtn'); 139 } 140 } 141 }); 142 143 $('.quick-submit').click(function (e) { 144 $('.quick-submit').addClass('disabled-quickBtn'); 145 $('.quick-submit').attr('disabled', true); 146 var newsId = 0; 147 var feedbackType = $('.feedbacktype').val(); 148 var cid = $(this).attr('cid'); 149 var buttonfor = $(this).attr('buttonfor'); 150 var qkbutton = $(this).attr('qkbtn'); 151 var commentText = $('.'+boxid).val(); 152 var hp_comment = $('#hp_comment').val(); 153 var honeypot_field_name = $('#honeypot_field_name').val(); 154 newsId = $(this).attr('newsid'); 155 if ($('.'+boxid+":visible").length > 0) { 156 if (commentText == '') { 157 $(".validation").show(); 158 return false;
159 } 160 } 161 var href = $(this).attr('href'); 162 $.ajax({ 163 type: "POST", 164 url: href, 165 data: { 166 "tx_nsfeedback_feedback[result][feedbackType]": feedbackType, 167 "tx_nsfeedback_feedback[result][buttonfor]": buttonfor, 168 "tx_nsfeedback_feedback[result][qkbutton]": qkbutton, 169 "tx_nsfeedback_feedback[result][cid]": cid, 170 "tx_nsfeedback_feedback[result][commentText]": commentText, 171 "tx_nsfeedback_feedback[result][newsId]": newsId, 172 "tx_nsfeedback_feedback[result][hpComment]": hp_comment, 173 "tx_nsfeedback_feedback[result][honeypot_field_name]": honeypot_field_name, 174 }, 175 success: function (data) { 176 if (data['Status'] == 'Success') { 177 $('#ns-c'+cid+' .qckform').html(''); 178 $('.ns-alert-wrap').show(); 179 } 180 else if(data['Status'] == 'ERROR_HP') { 181 $('.ns-alert-hp').show(); 182 }else if (data['Status'] == 'ERROR_AKISMAT'){ 183 $(".tx-ns-feedback .akismat_error").show(); 184 } 185 else if (data['Status'] == 'ERROR_SPAM'){ 186 $(".tx-ns-feedback .akismat_spam").show(); 187 }else { 188 $(".validation").remove(); 189 var somethingWrong = $('#resubmit').val(); 190 $("#feedback-btns").after("<div class='validation' style='color:red;margin-bottom: 20px;'>"+somethingWrong+"</div>"); 191 } 192 }, 193 }); 194 e.preventDefault(); 195 }); 196 197 if ($('.approveFeedback').length) { 198 showFeedbackpopup(); 199 } 200 // Show popup div 201 function showFeedbackpopup() 202 { 203 204 $(".approveFeedback #popup_box").fadeToggle(); 205 $(".approveFeedback #popup_box").css({"visibility":"visible","display":"block"}); 206 } 207 208// Hide popup div 209 function hideFeedbackpopup() 210 { 211 $(".approveFeedback #popup_box").fadeToggle(); 212 $(".approveFeedback #popup_box").css({"visibility":"hidden","display":"none"}); 213 } 214 215 $(document).on('click', '.confirmButton', function (){ 216 url = $("#actionUrl").attr('href'); 217 $.ajax({ 218 url: url, 219 method:'post', 220 data: {'tx_nsfeedback_feedback[confirm]': $(this).data('value'), 'tx_nsfeedback_feedback[accesstoken]' :$(this).data('accesstoken')}, 221 success: function (data) { 222 $('.approveFeedback #popup_box').remove(); 223 $('.approveFeedback').html(data); 224 showFeedbackpopup(); 225 } 226 }) 227 }) 228 $(document).on('click',".approveFeedback #cancel_button", function (){ 229 hideFeedbackpopup(); 230 }); 231 $(document).on('click', ".approveFeedback #close_button", function () { 232 var url = new URL(window.location.href); 233 url.searchParams.delete('acessstoken'); 234 window.location.replace(url); 235 }); 236 $('#form-star-rating').barrating({ 237 theme: 'css-stars', 238 showSelectedRating: false, 239 allowEmpty: true, 240 emptyValue: 0, 241 initialRating:1 242 }); 243 $('#popup-star-rating').barrating({ 244 theme: 'css-stars', 245 showSelectedRating: false, 246 allowEmpty: true, 247 emptyValue: 0, 248 initialRating:1 249 }); 250 $(".validationRequired").hide(); 251 $(".akismat_error").hide(); 252 $(".akismat_spam").hide(); 253 $('.ns-submit-form').on('submit', function(event) { 254 $(".validationRequired").hide(); 255 if (nsfFeedbackValidateField($(this))) { 256 var form_data = new FormData(this); 257 event.preventDefault(); 258 var confirmation = $('#confirmationbox').val(); 259 if(confirmation == '1'){ 260 $('.ns-alert-confirmation').show(); 261 $(".ns-alert-confirmation #agreebtn").on('click', function(){ 262 $(".validationRequired").hide(); 263 $(".tx-ns-feedback .akismat_spam").hide(); 264 $(".tx-ns-feedback .akismat_error").hide(); 265 266 alert 267 $.ajax({ 268 method: 'POST', 269 url: $('#feedback-agreeForm').attr('action'), 270 data: form_data, 271 contentType: false, 272 cache: false, 273 processData:false, 274 success: function (data) { 275 $('.ns-alert-confirmation').hide(); 276 277 if (data['Status'] == 'Success' || data == 'OKOK') { 278 $('.ns-form-wrapper').remove(); 279 $(".validationRequired").hide(); 280 $('.ns-alert-wrap').show(); 281 } 282 else if(data['Status'] == 'ERROR_REQUIRED'){ 283 $(".validationRequired").show(); 284 } 285 else if(data['Status'] == 'ERROR_HP'){ 286 $('.ns-alert-hp').show(); 287 } 288 else if (data['Status'] == 'ERROR_CAPTCHA_MISSING'){ 289 $(".tx-ns-feedback .akismat_error").text(data['text']); 290 $(".tx-ns-feedback .akismat_error").show(); 291 } 292 else if (data['Status'] == 'ERROR_CAPTCHA'){ 293 $(".tx-ns-feedback #captcha_error").text(data['text']); 294 $(".tx-ns-feedback #captcha_error").show(); 295 $(".tx-ns-feedback .frc-captcha").parent().addClass('has-error'); 296 } 297 else if (data['Status'] == 'ERROR_AKISMAT'){ 298 $(".tx-ns-feedback .akismat_error").show(); 299 } 300 else if (data['Status'] == 'ERROR_SPAM'){ 301 $(".tx-ns-feedback .akismat_spam").show(); 302 } 303 }, 304 }); 305 }); 306 $(".ns-alert-confirmation #cancelbtn").on('click', function(e){ 307 e.preventDefault(); 308 $('.ns-alert-confirmation').hide(); 309 $(".ns-submit-form").trigger("reset"); 310 location.reload(); 311 }); 312 } 313 else{ 314 $.ajax({ 315 method: 'POST', 316 url: $(this).attr('action'), 317 data: form_data, 318 contentType: false, 319 cache: false, 320 processData:false, 321 success: function (data) { 322 323 if (data['Status'] == 'Success' || data == 'OKOK') { 324 $('.ns-form-wrapper').remove(); 325 $(".validationRequired").hide(); 326 $('.ns-alert-wrap').show(); 327 } 328 else if(data['Status'] == 'ERROR_REQUIRED'){ 329 $(".validationRequired").show(); 330 } 331 else if(data['Status'] == 'ERROR_HP'){ 332 $('.ns-alert-hp').show(); 333 } 334 else if (data['Status'] == 'ERROR_CAPTCHA_MISSING'){ 335 $(".tx-ns-feedback .akismat_error").text(data['text']); 336 $(".tx-ns-feedback .akismat_error").show(); 337 } 338 else if (data['Status'] == 'ERROR_CAPTCHA'){ 339 340 $(".tx-ns-feedback #captcha_error").text(data['text']); 341 $(".tx-ns-feedback #captcha_error").show(); 342 $(".tx-ns-feedback .frc-captcha").parent().addClass('has-error'); 343 } 344 else if (data['Status'] == 'ERROR_AKISMAT'){ 345 $(".tx-ns-feedback .akismat_error").show(); 346 } 347 else if (data['Status'] == 'ERROR_SPAM'){ 348 $(".tx-ns-feedback .akismat_spam").show(); 349 } 350 351 }, 352 }); 353 } 354 } else { 355 event.preventDefault(); 356 } 357 }); 358 $(document).on('submit', '.ns-popup-form', function(event) { 359 $(".akismat_error").hide(); 360 $(".validationRequired").hide(); 361 let emvalidate = true; 362 let tmvalidate = true; 363 364 if ($("#submitteremail").length > 0) { 365 if (nsfValidateEmail($("#submitteremail").val()) === false) { 366 emvalidate = false;
367 } 368 } 369 var terms = document.getElementById('feedback_terms'); 370 if (terms) { 371 if ($('#feedback_terms:checked').length>0 ) { 372 $(".tx-ns-feedback #terms_error").hide(); 373 } else { 374 $(".tx-ns-feedback #terms_error").show(); 375 tmvalidate = false; 376 } 377 } 378 if (emvalidate && tmvalidate) { 379 var form_data = new FormData(this); 380 event.preventDefault(); 381 var confirmation = $('#agree-pupupbox').val(); 382 if(confirmation == '1'){ 383 $('.ns-alert-confirmation').show(); 384 $(".ns-alert-confirmation #agreebtn").on('click', function(){ 385 $(".validationRequired").hide(); 386 $(".tx-ns-feedback .akismat_spam").hide(); 387 $(".tx-ns-feedback .akismat_error").hide(); 388 389 $.ajax({ 390 method: 'POST', 391 url: $('#popup-agreeForm').attr('action'), 392 data: form_data, 393 contentType: false, 394 cache: false, 395 processData:false, 396 success: function (data) { 397 $('.ns-alert-confirmation').hide(); 398 399 if (data['Status'] == 'Success') { 400 $('.ns-popup-form').hide(); 401 $('.success-msg').show(); 402 $(".validationRequired").hide(); 403 setTimeout(function() { 404 location.reload(); 405 }, 3000); 406 } 407 else if (data['Status'] == 'ERROR_REQUIRED') { 408 $(".validationRequired").show(); 409 } 410 else if(data['Status'] == 'ERROR_HP'){ 411 $('.ns-alert-hp').show(); 412 } 413 else if (data['Status'] == 'ERROR_CAPTCHA_MISSING'){ 414 $(".tx-ns-feedback .akismat_error").text(data['text']); 415 $(".tx-ns-feedback .akismat_error").show(); 416 } 417 else if (data['Status'] == 'ERROR_AKISMAT'){ 418 $(".tx-ns-feedback .akismat_error").show(); 419 } 420 else if (data['Status'] == 'ERROR_SPAM'){ 421 $('.ns-alert-confirmation').hide(); 422 423 $(".tx-ns-feedback .akismat_spam").show(); 424 } 425 else if (data['Status'] == 'ERROR_CAPTCHA'){ 426 427 $(".tx-ns-feedback #captcha_error").text(data['text']); 428 $(".tx-ns-feedback #captcha_error").show(); 429 $(".tx-ns-feedback .frc-captcha").parent().addClass('has-error'); 430 } 431 432 }, 433 }); 434 }); 435 $(".ns-alert-confirmation #cancelbtn").on('click', function(e){ 436 e.preventDefault(); 437 $('.ns-alert-confirmation').hide(); 438 $(".ns-popup-form").trigger("reset"); 439 location.reload(); 440 }); 441 } 442 else{ 443 $.ajax({ 444 method: 'POST', 445 url: $(this).attr('action'), 446 data: form_data, 447 contentType: false, 448 cache: false, 449 processData:false, 450 success: function (data) { 451 if (data['Status'] == 'Success') { 452 $('.ns-popup-form').hide(); 453 $('.success-msg').show(); 454 $(".validationRequired").hide(); 455 setTimeout(function() { 456 location.reload(); 457 }, 3000); 458 } 459 else if (data['Status'] == 'ERROR_REQUIRED') { 460 $('.ns-alert-confirmation').hide(); 461 $(".validationRequired").show(); 462 } 463 else if(data['Status'] == 'ERROR_HP'){ 464 $('.ns-alert-hp').show(); 465 } 466 else if (data['Status'] == 'ERROR_AKISMAT'){ 467 $(".tx-ns-feedback .akismat_error").show(); 468 } 469 else if (data['Status'] == 'ERROR_CAPTCHA_MISSING'){ 470 $(".tx-ns-feedback .akismat_error").text(data['text']); 471 $(".tx-ns-feedback .akismat_error").show(); 472 } 473 else if (data['Status'] == 'ERROR_SPAM'){ 474 $(".tx-ns-feedback .akismat_spam").show(); 475 } 476 else if (data['Status'] == 'ERROR_CAPTCHA'){ 477 478 $(".tx-ns-feedback #captcha_error").text(data['text']); 479 $(".tx-ns-feedback #captcha_error").show(); 480 $(".tx-ns-feedback .frc-captcha").parent().addClass('has-error'); 481 } 482 }, 483 }); 484 } 485 486 }else{ 487 if (!emvalidate){ 488 $(".popup-email-error").show(); 489 } 490 event.preventDefault(); 491 492 } 493 }); 494}); 495 496// Custom Validation 497function nsfFeedbackValidateField(elem) { 498 var flag = 1; 499 var $mail = $('.ns-submit-form #submitteremail'); 500 if ($mail.length > 0 && !nsfValidateEmail($mail.val())) { 501 $(".ns-submit-form #email_error_msg").show(); 502 $(".ns-submit-form #email_error").hide(); 503 $mail.parent().addClass('has-error'); 504 flag = 0; 505 } else { 506 $mail.parent().removeClass('has-error'); 507 flag = 1; 508 } 509 var terms = document.getElementById('feedback_terms'); 510 var captcha = document.getElementById("captcha"); 511 if(captcha){ 512 if (!$('.tx-ns-feedback #captcha').val()) { 513 $(".tx-ns-feedback #captcha").parent().addClass('has-error'); 514 $(".tx-ns-feedback #captcha_error").show(); 515 $(".tx-ns-feedback #captcha_valid_error").hide(); 516 flag = 0; 517 } else { 518 if (nsfValidateCaptcha($('.tx-ns-feedback #captcha').val()) == 'true') { 519 $("#captchaValue").val(1); 520 $(".tx-ns-feedback #captcha").parent().removeClass('has-error'); // remove it 521 } else { 522 $(".tx-ns-feedback #captcha_valid_error").show(); 523 $(".tx-ns-feedback #captcha_error").hide(); 524 $(".tx-ns-feedback #captcha").parent().addClass('has-error'); 525 flag = 0; 526 } 527 } 528 } 529 if (terms) { 530 if ($('#feedback_terms:checked').length>0 ) { 531 $(".tx-ns-feedback #terms_error").hide(); 532 } else { 533 $(".tx-ns-feedback #terms_error").show(); 534 flag = 0; 535 } 536 } 537 if(flag === 1) { 538 return true; 539 } 540 return false;
541} 542 543// Validate Email field 544function nsfValidateEmail($email) { 545 var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; 546 return emailReg.test($email); 547} 548 549function nsfSetRating(rating,formId) { 550 var URL = $('#'+formId).attr('action'); 551 $.ajax({ 552 method:'post', 553 url: URL, 554 data:$('#'+formId).serializeArray(), 555 success: function (data) { 556 if (data['Status'] == 'Success') { 557 $('#'+formId).remove(); 558 559 $('.ns-alert-wrap').show(); 560 }else if (data['Status'] == 'ERROR_AKISMAT'){ 561 $(".tx-ns-feedback .akismat_error").show(); 562 } 563 else if (data['Status'] == 'ERROR_SPAM'){ 564 $(".tx-ns-feedback .akismat_spam").show(); 565 } 566 } 567 }); 568} 569function nsfBgColor(per){ 570 if(per > 0 && per <= 20){ 571 return '#f44336'; 572 } 573 if(per > 20 && per <= 40){ 574 return '#ff9800'; 575 } 576 if(per > 40 && per <= 60) { 577 return '#00bcd4'; 578 } 579 if(per > 60 && per <= 80) { 580 return '#2196F3'; 581 } 582 if(per > 80 && per <= 100) { 583 return '#4CAF50'; 584 } 585} 586 587window.refreshCaptcha = nsfRefreshCaptcha; 588window.setRating = nsfSetRating; 589})(window, document);
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.