1// Stylist JS 2 3var payment_in_progress = false; 4console.clear(); 5 6$(document).on('click', '#show_plaa', show_plaa); 7$(document).on('click', '#plaa_terms', show_plaa); 8 9$(document).on('click', '#show_tos', show_tos); 10$(document).on('click', '#back_btn', go_back); 11$(document).on('click', '#continue_to_step2', submit_step1); 12$(document).on('click', '#continue_to_step3', make_payment); 13$(document).on('click', '#send_btn', send_link); 14$(document).on('click', '#add_to_favorite', add_to_favorite); 15$(document).on('click', '.my_favorite', remove_favorite); 16$(document).on('click', '.cart', add_to_cart); 17$(document).on('click', '.resend', resend_link); 18$(document).on('click', '.remove', remove_link); 19$(document).on('click', '#send_recruit_link_btn', send_recruit); 20$(document).on('click', '.resend_recruit', resend_recruit_link); 21$(document).on('click', '.remove_recruit', remove_recruit_link); 22$(document).on('change', '#wcd', reload_wcd_report); 23$(document).on('click', '#search_btn', search_rep_by_keyword); 24$(document).on('click', '#update_btn', update_bank); 25$(document).on('click', '#update_cc_btn', update_cc); 26$(document).on('change', '#fees', show_summary); 27 28 29function show_summary() { 30 31 var fees = $('#fees').val(); 32 33 var tax = parseFloat(ROLLER_AMOUNT) * TAX_RATE; 34 var total = parseFloat(fees) + parseFloat(ROLLER_AMOUNT) + parseFloat(tax); 35 var shipping = parseFloat(SHIPPING); 36 37 var summary = "Total due: $" + parseFloat(total).toFixed(2); 38 39 var extra = ''; 40 41 if (tax > 0) 42 extra = '<br><span style="font-size: 0.6em;">(includes tax: $' + tax.toFixed(2); 43 44 if (shipping > 0) 45 extra += ' shipping: $' . shipping.toFixed(2); 46 else 47 extra += ' shipping: FREE'; 48 49 extra += ')'; 50 51 if (ROLLER_AMOUNT) 52 summary += extra; 53 54 $('#summary').html(summary); 55 56} 57 58 59function search_rep_by_keyword() { 60 61 return search_reps(null); 62} 63 64function search_reps(id) { 65 66 var keyword = $('#keyword').val(); 67 68 if (keyword.length < 2) { 69 alertify.notify('Sorry, try a longer name', function(){ }); 70 return false; 71 } 72 73 $.post("/stylist/find_rep", { keyword : keyword}, function(response){ 74 75 if (response.status == 'FAIL') { 76 77 alertify.notify('Sorry, no match!', function(){ }); 78 return false; 79 80 } else { 81 82 html = '<select id="recruiter_id" name="recruiter_id">'; 83 html += '<option>Select a manager</option>'; 84 85 for(i=0; i<response.results.length; i++) { 86 var label = response.results[i].first_name + ' ' + response.results[i].last_name + ' (#' + response.results[i].id + ')'; 87 88 if (id != null && response.results[i].id == id) 89 html += '<option selected value="'+ response.results[i].id +'">' + label + '</option>'; 90 else 91 html += '<option value="'+ response.results[i].id +'">' + label + '</option>'; 92 } 93 94 html += '</select>'; 95 $('.search_results').html(html); 96 $('.search_results').show(); 97 } 98 99 }, "json" ); 100 101} 102 103function reload_wcd_report() { 104 105 var wcd = $('#wcd').val(); 106 window.location.href = '/stylist/report?wcd=' + wcd; 107 108} 109 110 111function send_recruit() { 112 113 var data = $('#recruit_form').serialize(); 114 115 if ($('#name').val().length < 2) { 116 alertify.notify('Please enter name. ', 'warning', 3, function(){ }); 117 $('#name').focus(); 118 return false; 119 } 120 121 if ($('#phone').val().length < 10) { 122 alertify.notify('Please enter a 10-digit phone number. ', 'warning', 3, function(){ }); 123 $('#phone').focus(); 124 return false; 125 } 126 127 if ($('#message').val().indexOf('##LINK##') == -1) { 128 129 alertify.notify('Must have ##LINK## in the message', 'warning', 3, function(){ }); 130 return false; 131 } 132 133 $.post('/stylist/send_to_recruit', {data : data}, function(response){ 134 135 alertify.notify(response.message, 'message', 3, function(){ 136 137 window.location.reload(); 138 139 }); 140 141 }, 'json'); 142 143 return false; 144 145} 146 147function remove_recruit_link() { 148 149 var id = $(this).data('id'); 150
151 alertify.confirm('Confirm Delete', 'Are you sure you want to delete this recruit invite?', function(){ 152 153 $.post('/stylist/remove_recruit_invite', { id : id}, function(response){ 154 155 if (response.status == 'OK') { 156 $('#' + id).remove(); 157 if ($('#invites tr').length == 1) { 158 $('#invites').hide(); 159 } 160 } 161 162 alertify.notify(response.message, 'message', 3, function(){ }); 163 164 },"json"); 165 166 167 }, function(){}); 168 169} 170 171 172function remove_link() { 173 174 var id = $(this).data('id'); 175 176 alertify.confirm('Confirm Delete', 'Are you sure you want to delete this invite?', function(){ 177 178 $.post('/stylist/remove_invite', { id : id}, function(response){ 179 180 if (response.status == 'OK') { 181 $('#' + id).remove(); 182 if ($('#invites tr').length == 1) { 183 $('#invites').hide(); 184 } 185 } 186 187 alertify.notify(response.message, 'message', 3, function(){ }); 188 189 },"json"); 190 191 192 }, function(){}); 193 194} 195 196function resend_recruit_link() { 197 198 var id = $(this).data('id'); 199 200 $.post('/stylist/resend_recruit_invite', { id : id}, function(response){ 201 202 alertify.notify(response.message, 'message', 3, function(){ }); 203 204 },"json"); 205 206} 207 208 209function resend_link() { 210 211 var id = $(this).data('id'); 212 213 $.post('/stylist/resend_invite', { id : id}, function(response){ 214 215 alertify.notify(response.message, 'message', 3, function(){ }); 216 217 },"json"); 218 219} 220 221 222function get_cart() { 223 224 var cart = new Array(); 225 226 $('.cart').each(function(index, value){ 227 228 var e = $(value); 229 230 if (e.data('status') == 1) { 231 cart.push(e.data('sku')); 232 } 233 }); 234 235 return cart; 236} 237 238function add_to_cart() { 239 240 var sku = $(this).data('sku'); 241 var status = $(this).data('status'); 242 243 if (status === undefined || status == "0") { 244 $(this).css("border", "5px solid red"); 245 $(this).css("opacity", "0.5"); 246 $(this).data('status', "1"); 247 248 } else { 249 250 $(this).css("border", "1px solid black"); 251 $(this).data('status', "0"); 252 } 253 254} 255 256function load_favorites(class_name) { 257 258 var class_name = (class_name === undefined) ? 'my_favorite' : class_name; 259 260 $.get("/stylist/load_favorites", {}, function(response){ 261 262 var html = ""; 263 if(response.status == 'FOUND') { 264 265 total = response.favorites.length; 266 267 for(i=0; i<total; i++) { 268 var sku = response.favorites[i].sku 269 html += '<img class="' + class_name +'" data-sku="' + sku + '" style="width: 150px;margin: 5px; border: 1px solid #ccc;" ' + 270 ' src="' + CATALOG_IMAGES + sku + '/400x400.jpg">'; 271 } 272 273 $('.favorites').html(html); 274 } 275 276 }, "json"); 277 278} 279 280 281function remove_favorite() { 282 283 var sku = $(this).data('sku'); 284 285 alertify.confirm('Confirm Delete', 'Are you sure you want to delete this sku #' + sku + ' from favorites', function(){ 286 287 $.post("/stylist/delete_from_favorite", { sku : sku}, function(response){ 288 289 load_favorites(); 290 291 }, "json"); 292 293 } 294 , function(){}); 295 296} 297 298 299function add_to_favorite() { 300 301 var sku = $('#sku').val(); 302 303 if (sku.length < 3) { 304 305 alertify.notify('Please enter a valid sku. ', 'warning', 3, function(){ }); 306 $('#sku').focus(); 307 return false; 308 } 309 310 $.post("/stylist/add_to_favorite", { sku : sku}, function(response){ 311 312 313 if (response.status == 'OK') { 314 315 var html = '<img class="my_favorite" data-sku="' + sku+ '" style="width: 150px; margin: 3px; border: 1px solid black;" src="' + CATALOG_IMAGES + sku + '/400x400.jpg">'; 316 var cur =$('.favorites').html(); 317 $('.favorites').html(cur + html); 318 319 } 320 321 alertify.notify(response.message, 'message', 3, function(){ }); 322 323 324 },'json'); 325 326 327 328} 329 330 331function send_link() { 332JK 333 334 $.post('/stylist/send_to_recruit', {data : data}, function(response){ 335 336 alertify.notify(response.message, 'message', 3, function(){ 337 338 window.location.reload(); 339 340 }); 341 342 }, 'json'); 343 344 return false;
345 346} 347 348function update_bank() { 349 350 if ($('#bank_name').val().length < 2) 351 return bad_input('bank_name', 'Bank Name is too small or missing'); 352 353 if ($('#bank_acc').val().length < 8) 354 return bad_input('bank_acc', 'Bank Number is too small or missing'); 355 356 if ($('#bank_routing').val().length != 9) 357 return bad_input('bank_routing', 'Bank Rounting number is incorrect'); 358 359 var data = $('#update_bank').serialize(); 360 361 $.post('/stylist/update_bank_info', {data : data}, function(response){ 362 363 alertify.notify(response.message, 'message', 3, function(){ 364 365 }); 366 367 }, 'json'); 368 369 return false; 370 371} 372 373function update_cc() { 374 375 var data = $('#update_cc').serialize(); 376 377 $.post('/stylist/update_cc_info', {data : data}, function(response){ 378 379 alertify.notify(response.message, 'message', 3, function(){ 380 381 }); 382 383 }, 'json'); 384 385 return false; 386 387} 388 389function remove_link() { 390 391 var id = $(this).data('id'); 392 393 alertify.confirm('Confirm Delete', 'Are you sure you want to delete this invite?', function(){ 394 395 $.post('/stylist/remove_invite', { id : id}, function(response){ 396 397 if (response.status == 'OK') { 398 $('#' + id).remove(); 399 if ($('#invites tr').length == 1) { 400 $('#invites').hide(); 401 } 402 } 403 404 alertify.notify(response.message, 'message', 3, function(){ }); 405 406 },"json"); 407 408 409 }, function(){}); 410 411} 412 413function resend_link() { 414 415 var id = $(this).data('id'); 416 417 $.post('/stylist/resend_invite', { id : id}, function(response){ 418 419 alertify.notify(response.message, 'message', 3, function(){ }); 420 421 },"json"); 422 423} 424 425 426function get_cart() { 427 428 var cart = new Array(); 429 430 $('.cart').each(function(index, value){ 431 432 var e = $(value); 433 434 if (e.data('status') == 1) { 435 cart.push(e.data('sku')); 436 } 437 }); 438 439 return cart; 440} 441 442function add_to_cart() { 443 444 var sku = $(this).data('sku'); 445 var status = $(this).data('status'); 446 447 if (status === undefined || status == "0") { 448 $(this).css("border", "5px solid red"); 449 $(this).css("opacity", "0.5"); 450 $(this).data('status', "1"); 451 452 } else { 453 454 $(this).css("border", "1px solid black"); 455 $(this).data('status', "0"); 456 } 457 458} 459 460function load_favorites(class_name) { 461 462 var class_name = (class_name === undefined) ? 'my_favorite' : class_name; 463 464 $.get("/stylist/load_favorites", {}, function(response){ 465 466 var html = ""; 467 if(response.status == 'FOUND') { 468 469 total = response.favorites.length; 470 471 for(i=0; i<total; i++) { 472 var sku = response.favorites[i].sku 473 html += '<img class="' + class_name +'" data-sku="' + sku + '" style="width: 150px;margin: 5px; border: 1px solid #ccc;" ' + 474 ' src="' + CATALOG_IMAGES + sku + '/400x400.jpg">'; 475 } 476 477 $('.favorites').html(html); 478 } 479 480 }, "json"); 481 482} 483 484 485function remove_favorite() { 486 487 var sku = $(this).data('sku'); 488 489 alertify.confirm('Confirm Delete', 'Are you sure you want to delete this sku #' + sku + ' from favorites', function(){ 490 491 $.post("/stylist/delete_from_favorite", { sku : sku}, function(response){ 492 493 load_favorites(); 494 495 }, "json"); 496 497 } 498 , function(){}); 499 500} 501 502 503function add_to_favorite() { 504 505 var sku = $('#sku').val(); 506 507 if (sku.length < 3) { 508 509 alertify.notify('Please enter a valid sku. ', 'warning', 3, function(){ }); 510 $('#sku').focus(); 511 return false; 512 } 513 514 $.post("/stylist/add_to_favorite", { sku : sku}, function(response){ 515 516 517 if (response.status == 'OK') { 518 519 var html = '<img class="my_favorite" data-sku="' + sku+ '" style="width: 150px; margin: 3px; border: 1px solid black;" src="' + CATALOG_IMAGES + sku + '/400x400.jpg">'; 520 var cur =$('.favorites').html(); 521 $('.favorites').html(cur + html); 522 523 } 524 525 alertify.notify(response.message, 'message', 3, function(){ }); 526 527 528 },'json'); 529 530 531 532} 533 534 535function send_link() { 536 537 if ($('#name').val().length < 2) { 538 alertify.notify('Please enter name. ', 'warning', 3, function(){ }); 539 $('#name').focus(); 540 return false;
541 } 542 543 if ($('#phone').val().length < 10) { 544 alertify.notify('Please enter a 10-digit phone number. ', 'warning', 3, function(){ }); 545 $('#phone').focus(); 546 return false; 547 } 548 549 if ($('#message').val().indexOf('##LINK##') == -1) { 550 551 alertify.notify('Must have ##LINK## in the message', 'warning', 3, function(){ }); 552 return false; 553 } 554 555 var data = $('#send_link').serialize(); 556 var cart = get_cart(); 557 558 $.post('/stylist/sendlink', {data : data, cart : cart}, function(response){ 559 560 alertify.notify(response.message, 'message', 3, function(){ 561 562 if (response.status == 'OK') 563 window.location.href = '/stylist/dashboard'; 564 }); 565 566 567 }, 'json'); 568 569} 570 571function not_ready() { 572 var msg = 'This feature is NOT READY yet.'; 573 alertify.notify(msg, 'error', 3, function(){}); 574} 575 576function go_back() { 577 window.history.go(-1); 578} 579 580 581 582function show_plaa() { 583 584 showSignaturePad(); 585 console.log('Show agreenment as a popup using foundation dialog'); 586 } 587 588function show_tos() { 589 console.log('Show TOS as a popup using foundation dialog'); 590} 591 592function submit_step1() { 593 594 $('.bad_input').removeClass('bad_input'); 595 596 // Step specific validation here 597 if ($('#fname').val().length < 2) 598 return bad_input('fname', 'First name too small or missing'); 599 600 if ($('#lname').val().length < 2) 601 return bad_input('lname', 'Last name too small or missing'); 602 603 if ($('#email').val().length < 5) 604 return bad_input('email', 'Email too small or missing'); 605 606 if ($('#ssn').val().length < 9) 607 return bad_input('ssn', 'Social Security # is too small or missing'); 608 609 if ($('#street').val().length < 5) 610 return bad_input('street', 'Address is too small or missing'); 611 612 if ($('#zip').val().length < 5) 613 return bad_input('zip', 'Zip Code is too small or missing'); 614 615 if ($('#city').val().length < 3) 616 return bad_input('city', 'City is too small or missing'); 617 618 if ($('#state').val().length < 1) 619 return bad_input('state', 'State is too small or missing'); 620 621 if ($('#phone').val().length < 9) 622 return bad_input('phone', 'Phone is too small or missing'); 623 624 if ($('#bank_name').val().length < 2) 625 return bad_input('bank_name', 'Bank Name is too small or missing'); 626 627 if ($('#bank_acc').val().length < 8) 628 return bad_input('bank_acc', 'Bank Number is too small or missing'); 629 630 if ($('#bank_routing').val().length != 9) 631 return bad_input('bank_routing', 'Bank Rounting number is incorrect'); 632 633 // More validation to follow here 634 // all other fields that are required 635 636 if (!$('#agrees_to_tos').prop('checked')) 637 return bad_input('agrees_to_tos', 'You must agree to T.O.S.'); 638 639 var recruiter_id = $('#recruiter_id').val(); 640 641 if (recruiter_id == undefined || recruiter_id == "" || recruiter_id == 'Select a manager'){ 642 var html = '<input id="recruiter_id" name="recruiter_id" type=text value="6">'; 643 $('.search_results').html(html); 644 } 645 646 return submit_form('signup_step1', 2); 647} 648 649function make_payment() { 650 651 if (payment_method == null) 652 return bad_input('payment', 'You must select a payment option'); 653 654 $(this).html('<i class="fa fa-spinner fa-spin"></i> Please Wait...'); 655 656 if (payment_in_progress == true) 657 return false; 658 659 payment_in_progress = true; 660 console.log("Came to process"); 661 662 return submit_form('signup_step2', 3); 663} 664 665 666function bad_input(id, msg) { 667 668 var e = $('#' + id); 669 670 e.addClass('bad_input'); 671 e.focus(); 672 673 alertify.alert('Error', msg, function(){}); 674 675} 676 677function submit_form(form_id, next_step) { 678 679 var data = $('#' + form_id).serialize(); 680 681 $.post('/stylist/signup/savestep' + (next_step - 1) , { data : data}, function(response){ 682 683 if (response.status == 'OK') 684 window.location.href = '/stylist/signup/step' + next_step; 685 else{ 686 alertify.notify(response.message, 'error', 3, function(){}); 687 if(form_id == "signup_step2") { 688 payment_in_progress = false;
689 $('#continue_to_step3').html('Continue'); 690 } 691 } 692 }, 'json'); 693 694}
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.