Advertisement
Guest User

JS Snippet 1

a guest
Sep 27th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(window).scroll(function() {
  2.     if ($(this).scrollTop() > 100){
  3.         $('.nav-row-brand').addClass("sticky");
  4.     }
  5.     else{
  6.         $('.nav-row-brand').removeClass("sticky");
  7.     }
  8. });
  9.  
  10. jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
  11.     return -c * ((t=t/d-1)*t*t*t - 1) + b;
  12. };
  13.  
  14.  
  15.  
  16. $('.sandbox-container').datepicker({
  17.  
  18.     format: "mm-yyyy",
  19.     startView: "months",
  20.     minViewMode: "months"
  21.  
  22. });
  23.  
  24.  
  25. $(document).ready(function(){
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.     $('[data-toggle="tooltip"]').tooltip();
  34.  
  35.     $('#slideshow').serialScroll({
  36.         items:'.cal-item',
  37.         prev: '.als-prev',
  38.         next: '.als-next',
  39.         start:0, //as we are centering it, start at the 2nd
  40.         duration:60,
  41.         force:true,
  42.         stop:true,
  43.         lock:false,
  44.         easing: 'easeOutQuart',
  45.         cycle:false, //don't pull back once you reach the end
  46.         jump: true,
  47.         step: 6
  48.     });
  49.  
  50.     $(".js-example-tokenizer").select2({
  51.         tags: true
  52.     });
  53.  
  54.     $(".js-example-responsive").select2({
  55.         placeholder: "Subcategory"
  56.     });
  57.  
  58.  
  59.  
  60.     $(".js-example-tokenizer").on("select2:select", function (e) {
  61.         console.log("select2:select", $(this).val()[0]);
  62.         var skill = $(this).val()[0];
  63.         $(this).val(null).trigger("change");
  64.         $(this).select2('open');
  65.         //$(this).trigger("open");
  66.         if(skill!='') {
  67.             $("<div class = 'skill-tag' id = 'clonetag' style = 'display: inline-block; margin: 5px;'> <a href='/listings?q=" + skill + "#q=" + skill + "'>" + skill + "</a> <a style='padding-left: 5px;cursor: pointer;' class = 'tagRemove'  tag='" + skill + "' other = '1'>  x</a>  </div>").appendTo($('#skillContainer'));
  68.         }
  69.     });
  70.  
  71.     $(".js-example-tokenizer").on("select2-blur", function (e) {
  72.         console.log("gay");
  73.     });
  74.  
  75.     $(".addSkillBtn2").click(function(e){
  76.         $(".js-example-tokenizer").select2('open');
  77.     });
  78.  
  79.     //$(".select2-results").on('close', function () {
  80.     //    console.log("sheit");
  81.     //    console.log($('.select2-search__field').val());
  82.     //    $('.select2-search__field').attr('tabindex', -1);
  83.     //    return false;
  84.     //   // self.$search.val('');
  85.     //});
  86.     //
  87.     //$('.select2-search__field').on('blur',function(e)
  88.     //{
  89.     //    return false;
  90.     //});
  91.  
  92.  
  93.     $('#rating-input').rating({
  94.         showClear: false,
  95.         showCaption: false,
  96.         step :1
  97.     });
  98.  
  99.     $('.add').click(function(){
  100.         console.log($(this).attr('rating'));
  101.         var cpy = $('#myModal');
  102.         cpy.removeClass('hide');
  103.         $(this).parent().parent().parent().append(cpy);
  104.         $('#rating-input').rating('update', $(this).attr('rating'));
  105.         if(!$(this).attr('rating'))
  106.         {
  107.             $('#rating-input').rating('update', 1);
  108.         }
  109.         $('#review').val($(this).attr('text'));
  110.         $('#submitbtn').attr('for',$(this).attr('for'));
  111.         $('#submitbtn').attr('by',$(this).attr('by'));
  112.         $('#submitbtn').attr('listing',$(this).attr('listing'));
  113.     });
  114.  
  115.     $('.upd').click(function(){
  116.         console.log($(this).attr('rating'));
  117.         var cpy = $('#myModal');
  118.         cpy.removeClass('hide');
  119.         $(this).parent().parent().parent().append(cpy);
  120.         $('#rating-input').rating('update', $(this).attr('rating'));
  121.         $('#review').val($(this).attr('text'));
  122.         $('#submitbtn').attr('for',$(this).attr('for'));
  123.         $('#submitbtn').attr('by',$(this).attr('by'));
  124.         $('#submitbtn').attr('listing',$(this).attr('listing'));
  125.     });
  126.  
  127.  
  128.  
  129.     $('#submitbtn').click(function(e){
  130.  
  131.         e.preventDefault();
  132.         var by = $(this).attr('by');
  133.         var fr = $(this).attr('for');
  134.         var listing = $(this).attr('listing');
  135.         console.log(by+""+fr+""+listing);
  136.         $.ajax({
  137.             url: 'http://'+window.location.href.split('/')[2]+'/addReview',
  138.             type: 'GET',
  139.             data: {
  140.                 rating : $('#rating-input').rating()['0']['value'],
  141.                 text : $('#review').val(),
  142.                 by : by,
  143.                 for : fr,
  144.                 listing : listing
  145.             },
  146.             success: function(response){
  147.                 if(response){
  148.                     if(response==="true"){
  149.                         console.log($('#listing'+listing));
  150.                         $('#listing'+listing).text("Update Review");
  151.                         $('#listing'+listing).addClass('upd');
  152.                         $('#listing'+listing).removeClass('add');
  153.                         $('#listing'+listing).attr('rating',$('#rating-input').rating()['0']['value']);
  154.                         $('#listing'+listing).attr('text',$('#review').val());
  155.                         $('#myModal').addClass('hide');
  156.                     }
  157.                 }
  158.             }});
  159.  
  160.  
  161.     });
  162.  
  163.     $('#cancelbtn').click(function(e){
  164.         $('#myModal').addClass('hide');
  165.     });
  166.  
  167.     $('.rating-container').attr('data-content','★ ★ ★ ★ ★');
  168.     $('.rating-stars').attr('data-content','★ ★ ★ ★ ★');
  169.  
  170.  
  171.     //$('#addSkillBtn').click(function(e){
  172.     //
  173.     //    console.log($('.select2-results__option .select2-results__option--highlighted').text());
  174.     //    //console.log($(".select2-search__field"));
  175.     //    //var skill = $(".select2-search__field").val();
  176.     //    //console.log(skill);
  177.     //    //if(skill!='') {
  178.     //    //    $("<div class = 'skill-tag' id = 'clonetag' style = 'display: inline-block; margin: 5px;'> <a href='/listings?q=" + skill + "#q=" + skill + "'>" + skill + "</a> <a style='padding-left: 5px;cursor: pointer;' class = 'tagRemove'  tag='" + skill + "' other = '1'>  x</a>  </div>").appendTo($('#skillContainer'));
  179.     //    //}
  180.     //    //$(".js-example-tokenizer").val(null).trigger("change");
  181.     //
  182.     //});
  183.  
  184.     $('div').on('click', 'a.tagRemove',function(e){
  185.         $(this).parent().remove();
  186.     });
  187.  
  188.     //$('#sandbox-container').datepicker();
  189.  
  190.     $('#addExp').click(function(e){
  191.         console.log('clicked');
  192.         $("<div class='row timeline-details bottomSep'> <div class = 'row'> <div class = 'col-xs-11'> <input style='width: 250px;' class='form-control' type = 'text' id='companyName' placeholder='Company Name' value=''> </div> <div class = 'col-xs-1'> <a class='pull-right btn shortlist-btn delExp'><i class='fa fa-times'></i></a> </div> </div> <div class='row interviewer-current-work' style='padding-top: 5px!important;'> <div><input style='width: 200px;' class='form-control input-sm' type = 'text' id='workTitle' placeholder='Work Title' value=''></div> </div> <div class='row interviewer-current-work' style='padding-top: 5px!important;'> <div><input style='width: 200px;' class='form-control input-sm' type = 'text' id='location' placeholder='Location' value=''></div> </div> <div class='row interviewer-current-work col-xs-10 pull-left' style='padding-left: 0px!important;padding-top: 5px;'> <div class='input-daterange input-group sandbox-container'> <input type='text' class='input-sm form-control' name='start' value='' placeholder='start date'/> <span class='input-group-addon'>to</span> <input type='text' class='input-sm form-control' name='end' value='' placeholder='end date'/> </div> </div> <div class='row interviewer-current-work col-xs-10 pull-left' style='padding-left: 0px!important;padding-top: 5px;'> <textarea class='form-control' rows='3' id='bioExp' value=' ' placeholder='Bio'></textarea> </div> </div> ").appendTo($('#workExContainer'));
  193.         $('.sandbox-container').datepicker({
  194.  
  195.             format: "mm-yyyy",
  196.             startView: "months",
  197.             minViewMode: "months"
  198.  
  199.         });
  200.     });
  201.  
  202.     $('#addEdu').click(function(e){
  203.         console.log('clicked');
  204.         $("<div class='row timeline-details bottomSep'> <div class = 'row'> <div class = 'col-xs-11'> <input style='width: 250px;' class='form-control' type = 'text' id='institution' placeholder='Institution' value=''> </div> <div class = 'col-xs-1'> <a class='pull-right btn shortlist-btn delEdu'><i class='fa fa-times'></i></a> </div> </div> <div class='row interviewer-current-work' style='padding-top: 5px!important;'> <div><input style='width: 200px;' class='form-control input-sm' type = 'text' id='degree' placeholder='Degree' value=''></div> </div> <div class='row interviewer-current-work col-xs-10 pull-left' style='padding-left: 0px!important;padding-top: 5px;'> <div class='input-daterange input-group sandbox-container'> <input type='text' class='input-sm form-control' name='startEdu' value='' placeholder='start date'/> <span class='input-group-addon'>to</span> <input type='text' class='input-sm form-control' name='endEdu' value='' placeholder='end date'/> </div> </div> </div> ").appendTo($('#eduContainer'));
  205.         $('.sandbox-container').datepicker({
  206.  
  207.             format: "mm-yyyy",
  208.             startView: "months",
  209.             minViewMode: "months"
  210.  
  211.         });
  212.     });
  213.  
  214.     $('#addLis').click(function(e){
  215.         console.log('clicked');
  216.         $("<div class='row timeline-details newLis bottomSep'><div class = 'row'><div class = 'col-xs-11'><input style='width: 250px;' class='form-control' type = 'text' id='listingCat' placeholder='Subcategory Name' value=''></div><div class = 'col-xs-1'><a class='pull-right btn shortlist-btn newdelLis'><i class='fa fa-times'></i></a></div></div><div class='row interviewer-current-work' style='padding-top: 5px!important;'><div><input style='width: 200px;' class='form-control input-sm' type = 'text' id='listingPrice' placeholder='Price' value=''></div></div><div class='row interviewer-current-work col-xs-10 pull-left' style='padding-left: 0px!important;padding-top: 5px;'><textarea class='form-control' rows='3' id='bioListing' placeholder='Description'></textarea> <input type='hidden' value='-1' id='updateCheck'> </div> </div> ").appendTo($('#listingContainer'));
  217.     });
  218.  
  219.     $('div').on('click','a.delExp',function(){
  220.        $(this).parent().parent().parent().remove();
  221.     });
  222.  
  223.     $('div').on('click','a.delEdu',function(){
  224.         $(this).parent().parent().parent().remove();
  225.         //console.log('gay');
  226.     });
  227.  
  228.     $('div').on('click','a.newdelLis',function(){
  229.  
  230.         $(this).parent().parent().parent().remove();
  231.     });
  232.  
  233.     $('div').on('click','a.delLis',function(){
  234.         console.log($(this).parent().parent().parent().find(':input'));
  235.         if($(this).text() == "Enable"){
  236.             $(this).parent().parent().parent().removeClass("disabled");
  237.             $(this).parent().parent().parent().find(':input').each(function() {
  238.                $(this).attr('disabled',false);
  239.             });
  240.             $(this).text('Disable');
  241.             return false;
  242.         }
  243.         else {
  244.             $(this).parent().parent().parent().addClass("disabled");
  245.             $(this).parent().parent().parent().find(':input').removeClass("disabled");
  246.             $(this).text('Enable');
  247.             $(this).parent().parent().parent().find(':input').each(function() {
  248.                 $(this).attr('disabled',true);
  249.             });
  250.             return false;
  251.         }
  252.  
  253.     });
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.     //parens js code for crop
  262.     $("#inputImage").on('change',function () {
  263.         var files = !!this.files ? this.files : [];
  264.         if(!files.length || !window.FileReader) return;
  265.         if(/^image/.test(files[0].type)){
  266.             var reader = new FileReader;
  267.             reader.readAsDataURL(files[0]);
  268.             reader.onloadend = function () {
  269.                 $('#imageToCrop').prop('src', this.result);
  270.                 $('#preview').empty();
  271.                 $('#modal_crop').modal('show');
  272.             }
  273.         }
  274.     });
  275.     var $image = $('#cropper_image > img'),
  276.         cropBoxData,
  277.         canvasData;
  278.  
  279.     var cropdata= 'false';
  280.  
  281.     $('#modal_crop').on('shown.bs.modal', function () {
  282.         $image.cropper({
  283.             aspectRatio: 1 / 1,
  284.             autoCropArea: 0.5,
  285.             preview: ".img-preview",
  286.             movable: false,
  287.             zoomable: false,
  288.             rotatable: false,
  289.             built: function () {
  290.                 // Strict mode: set crop box data first
  291.                 $image.cropper('setCropBoxData', cropBoxData);
  292.                 $image.cropper('setCanvasData', canvasData);
  293.             }
  294.         });
  295.     }).on('hidden.bs.modal', function () {
  296.         cropBoxData = $image.cropper('getCropBoxData');
  297.         canvasData = $image.cropper('getCanvasData');
  298.         var $data = $image.cropper('getData');
  299.         cropdata =  JSON.stringify($data);
  300.         var $img = $('.img-preview').children();
  301.         $image.cropper('destroy');
  302.         $('.img-preview').append($img);
  303.     });
  304.  
  305.  
  306.  
  307.  
  308.     //Remove duplicates, this is a really bad hack
  309.  
  310.     var usedNames = {};
  311.     $("#skillselect> option").each(function () {
  312.         if(usedNames[this.text]) {
  313.             $(this).remove();
  314.         } else {
  315.             usedNames[this.text] = this.value;
  316.         }
  317.     });
  318.  
  319.  
  320.  
  321.  
  322.     $('#pd_newpassword').on('change',function(){
  323.  
  324.         if(pass_check($('#pd_newpassword').val())!='0'){
  325.             //Show tooltip
  326.         }
  327.  
  328.     });
  329.  
  330.  
  331.     $('#pd_confirmnewpassword').on('change',function(){
  332.  
  333.         if(pass_check($('#pd_newpassword').val())!='0' || ($('#pd_newpassword').val()) != ($('#pd_confirmnewpassword').val())){
  334.             //Show tooltip
  335.         }
  336.  
  337.     });
  338.  
  339.  
  340.  
  341.  
  342.  
  343.     $('#saveedit').on('click',function(){
  344.         //Show Progress indicator -- ask chirag
  345.  
  346.  
  347.         var fn = $('#pd_firstname').val();
  348.         var mn = $('#pd_middlename').val();
  349.         var ln = $('#pd_lastname').val();
  350.         var ph = $('#pd_phoneno').val();
  351.         var ct = $('#pd_city').val();
  352.         var bio = $('#pd_bio').val();
  353.         var op = $('#pd_oldpassword').val();
  354.         var np = $('#pd_newpassword').val();
  355.         var ncp = $('#pd_confirmnewpassword').val();
  356.  
  357.         $.ajaxSetup({
  358.             headers: {
  359.                 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
  360.             }
  361.         })
  362.  
  363.         if(np!='' && ncp==np){
  364.             pass_c = pass_check(np);
  365.             if(pass_c===0){
  366.                 //Call Ajax for change password, send user_id, pass, newpass, oldpass
  367.                 $.ajax({
  368.                     url: 'http://'+window.location.href.split('/')[2]+'/changePwd',
  369.                     type: 'POST',
  370.                     data: {
  371.                         op : op,
  372.                         np : np
  373.                     },
  374.                     success: function(response){
  375.                         console.log(response);
  376.                         if(response){
  377.                             if(response==="true"){
  378.                                 console.log("changed");
  379.                             }
  380.                             else{
  381.                                 console.log(" not changed " + response );
  382.                             }
  383.                         }
  384.                     },
  385.                     error: function (response) {
  386.                         console.log('Error:',response);
  387.                     }
  388.                 });
  389.             }
  390.             else{
  391.                 //Show error
  392.                 console.log("pass check failed" + pass_c)
  393.             }
  394.         }
  395.         else if (np!=''){
  396.             console.log("password didn't match")
  397.         }
  398.  
  399.         //Resave personal Info
  400.         $.ajax({
  401.             url: '/resavePersonal',
  402.             type: 'POST',
  403.             data: {
  404.                 fn:fn,
  405.                 mn:mn,
  406.                 ln:ln,
  407.                 ph:ph,
  408.                 ct:ct,
  409.                 bio:bio
  410.             },
  411.             success: function(response){
  412.                 if(response){
  413.                     if(response==="true"){
  414.                         console.log("resaved");
  415.                     }
  416.                     else{
  417.                         console.log(" not resaved");
  418.                     }
  419.                 }
  420.             },
  421.             error: function (response) {
  422.                 console.log('Error:',response);
  423.             }
  424.         });
  425.         //call Ajax to update fn,mn,ln, phone_no, city and bio
  426.  
  427.         var imageFile = !!$('#inputImage').files ? $('#inputImage').files : [];
  428.         var resumeFile = !!$('#inputFile').files ? $('#inputFile').files : [];
  429.  
  430.         if(!imageFile.length){
  431.             sendImage(imageFile[0]);
  432.         }
  433.  
  434.         if(!resumeFile.length){
  435.             sendResume(resumeFile[0]);
  436.         }
  437.  
  438.  
  439.  
  440.  
  441.         //Check Resume and Picture for change
  442.  
  443.         $('.skill-tag').each(function(){
  444.             $this.find("a").first().val();
  445.  
  446.  
  447.         });
  448.  
  449.         //Iterate New added skills
  450.         //ajaxCall to send All Skills, (this deletes old skills, and then inserts new ones)
  451.         var newCompanies = [];
  452.         var newTitles = [];
  453.         var newLocations = [];
  454.         var newStarts = [];
  455.         var newEnds = [];
  456.         var newBios = [];
  457.         $('[id=companyName]').each(function(i,obj){
  458.             newCompanies[i] = $(obj).val();
  459.         });
  460.         $('[id=workTitle]').each(function(i,obj){
  461.             newTitles[i] = $(obj).val();
  462.         });
  463.         $('[id=location]').each(function(i,obj){
  464.             newLocations[i] = $(obj).val();
  465.         });
  466.         $('[name=start]').each(function(i,obj){
  467.             newStarts[i] = $(obj).val();
  468.         });
  469.         $('[name=end]').each(function(i,obj){
  470.             newEnds[i] = $(obj).val();
  471.         });
  472.         $('[id=bioExp]').each(function(i,obj){
  473.             newBios[i] = $(obj).val();
  474.         });
  475.         $.ajax({
  476.             url: '/resaveWorkEx',
  477.             type: 'POST',
  478.             data: {
  479.                 companies : newCompanies,
  480.                 titles    : newTitles,
  481.                 locations : newLocations,
  482.                 starts : newStarts,
  483.                 ends : newEnds,
  484.                 bios : newBios
  485.             },
  486.             success: function(response){
  487.                 if(response){
  488.                     if(response){
  489.                         console.log("saved WorkEx");
  490.                     }
  491.                     else{
  492.                         console.log(" not saved workEx");
  493.                     }
  494.                 }
  495.             },
  496.             error: function (response) {
  497.                 console.log('Error:',response);
  498.             }
  499.         });
  500.  
  501.  
  502.         var newInstitutions = [];
  503.         var newDegrees = [];
  504.         var newStarts = [];
  505.         var newEnds = [];
  506.         $('[id=institution]').each(function(i,obj){
  507.             newInstitutions[i] = $(obj).val();
  508.         });
  509.         $('[id=degree]').each(function(i,obj){
  510.             newDegrees[i] = $(obj).val();
  511.         });
  512.         $('[name=startEdu]').each(function(i,obj){
  513.             newStarts[i] = $(obj).val();
  514.         });
  515.         $('[name=endEdu]').each(function(i,obj){
  516.             newEnds[i] = $(obj).val();
  517.         });
  518.         $.ajax({
  519.             url: '/resaveEdu',
  520.             type: 'POST',
  521.             data: {
  522.                 institutions : newInstitutions,
  523.                 degrees    : newDegrees,
  524.                 starts : newStarts,
  525.                 ends : newEnds,
  526.             },
  527.             success: function(response){
  528.                 if(response){
  529.                     if(response){
  530.                         console.log("saved Education");
  531.                     }
  532.                     else{
  533.                         console.log(" not saved Education");
  534.                     }
  535.                 }
  536.             },
  537.             error: function (response) {
  538.                 console.log('Error:',response);
  539.             }
  540.         });
  541.         //TODO
  542.         /*var newCategories = [];
  543.         var newPrices = [];
  544.         var newListings = [];
  545.         var updates = [];
  546.         $('[id=listingCat]').each(function(i,obj){
  547.             newCategories[i] = $(obj).val();
  548.         });
  549.         $('[id=listingPrice]').each(function(i,obj){
  550.             newPrices[i] = $(obj).val();
  551.         });
  552.         $('[id=bioListing]').each(function(i,obj){
  553.             newListings[i] = $(obj).val();
  554.         });
  555.         $('[id=updateCheck]').each(function(i,obj){
  556.             updates[i] = parseInt($(obj).val());
  557.         });
  558.         console.log(newCategories);
  559.         $.ajax({
  560.             url: '/saveListings',
  561.             type: 'POST',
  562.             data: {
  563.                 categories : newCategories,
  564.                 prices    : newPrices,
  565.                 desc : newListings,
  566.                 updates : updates
  567.             },
  568.             success: function(response){
  569.                 if(response){
  570.                     if(response){
  571.                         console.log("saved Listings");
  572.                     }
  573.                     else{
  574.                         console.log(" not saved Listings");
  575.                     }
  576.                 }
  577.             },
  578.             error: function (response) {
  579.                 console.log('Error:',response);
  580.             }
  581.         });*/
  582.  
  583.         /*var listingsClass = $('.newLis');
  584.         if($('.newLis')){
  585.             $('.newLis').each(function(i,listing){
  586.                 var category = $(listing).find('#select2-gexk-container').val();
  587.                 var price = $(listing).find('#select2-gexk-container').val();
  588.                 listingPrice
  589.             });
  590.         }*/
  591.         //New WorkEx, Edu(class = ), Listing(class = newLis)
  592.  
  593.         //Check all listing for Enable/Disable
  594.     });
  595.  
  596.  
  597.  
  598. });
  599.  
  600.  
  601. $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  602.  
  603.     if($(e.target).attr("href").indexOf('availability')!=-1)
  604.     {
  605.         console.log("Als Event");
  606.  
  607.     }
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616. });
  617.  
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624. //DO NOT SEND TO CHIRAG, ALREADY PRESENT IN HIS AUTHENTICATION.JS
  625.  
  626. function email_check (email) {
  627.     var re = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
  628.     if(!re.test(email)){
  629.         return false;
  630.     }
  631.     return true;
  632. }
  633.  
  634. function pass_check (password) {
  635.     var error = "Your password must ";
  636.     var e = 0
  637.     if(password.length < 8){
  638.         if(e==0 || e==1) {
  639.             error += "be at least 8 characters long"
  640.             e = 1;
  641.         }
  642.     }
  643.     if(password.search(/[a-z]/i)<0){
  644.         if(e==0){
  645.             error += "contain at least one alphabet";
  646.             e = 2;
  647.         }
  648.         else{
  649.             error += ", contain at least one alphabet";
  650.             e = 3;
  651.         }
  652.     }
  653.     if(password.search(/[0-9]/)<0){
  654.         if(e==0){
  655.             error += "contain at least one digit";
  656.         }
  657.         else if(e==1){
  658.             error += ", contain at least one digit";
  659.         }
  660.         else if(e==2||e==3){
  661.             error += "and one digit";
  662.         }
  663.     }
  664.     if(e==0){
  665.         return 0;
  666.     }
  667.     else{
  668.         return error;
  669.     }
  670. }
  671.  
  672. function dob_check (dob) {
  673.     return /^\d\d\/\d\d\/\d\d\d\d$/.test(dob);
  674. }
  675.  
  676. function phone_check (phone) {
  677.     return /^[0-9]{10}$/.test(phone);
  678. }
  679.  
  680. function name_check (name) {
  681.     var re = /^[a-zA-Z]+$/;
  682.     return (re.test(name));
  683. }
  684.  
  685. function bio_check (bio) {
  686.     return /^.{140,500}$/.test(bio);
  687. }
  688.  
  689.  
  690. function sendFile(file) {
  691.     data = new FormData();
  692.     data.append("upload", file);
  693.     $.ajax({
  694.         data: data,
  695.         type: "POST",
  696.         url: 'http://uploads.im/api', //Change
  697.         cache: false,
  698.         contentType: false,
  699.         processData: false,
  700.         success: function (response) {
  701.             image_url = "-1";
  702.             if(response.status_code == 200)
  703.             {
  704.                 image_url=response.data.img_url;
  705.             }
  706.             else
  707.             {
  708.                 //error
  709.             }
  710.             console.log(image_url);
  711.             if(image_url=="-1")
  712.             {
  713.                 //eroor
  714.             }
  715.             else
  716.             {
  717.                 $('#summernote').summernote('editor.insertImage', image_url);
  718.             }
  719.  
  720.         }
  721.     });
  722. }
  723.  
  724. function sendImage(file) {
  725.     data = new FormData();
  726.     data.append("upload", file);
  727.     $.ajax({
  728.         data: data,
  729.         type: "POST",
  730.         url: 'http://'+window.location.href.split('/')[2]+'/sendImage',
  731.         cache: false,
  732.         contentType: false,
  733.         processData: false,
  734.         success: function (response) {
  735.  
  736.             if(response){
  737.                 if(response==="true"){
  738.                     console.log('Image Sent');
  739.                 }
  740.             }
  741.         }
  742.     });
  743. }
  744.  
  745. function sendResume(file) {
  746.     data = new FormData();
  747.     data.append("upload", file);
  748.     $.ajax({
  749.         data: data,
  750.         type: "POST",
  751.         url: 'http://'+window.location.href.split('/')[2]+'/sendResume',
  752.         cache: false,
  753.         contentType: false,
  754.         processData: false,
  755.         success: function (response) {
  756.             if(response){
  757.                 if(response==="true"){
  758.                     console.log('Resume Sent');
  759.                 }
  760.             }
  761.  
  762.         }
  763.     });
  764. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement