NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name GreyCampus // @namespace http://your.homepage/ // @version 0.1 // @include http://www.greycampus.com/* // @description Quiz Module in greycampus.com // @author Ashish // @match http://wiki.greasespot.net/GM_setValue // @grant GM_getValue // @grant GM_setValue // @grant GM_log // @require http://code.jquery.com/jquery-latest.js // ==/UserScript== // when the user reached the correct url then add the done button at the top of the page // if the user says that it is done save it as it is to done. // if the user says that it is not done then save it as not done. $('.carousel').carousel({ interval: 3000 }); $('.open_campus_courses img').attr('class','img-responsive'); /* The below code is used to render google recaptcha Note: Please remove unused element ID's to avoid error. */ var recaptcha1; var recaptcha2; var myCallBack = function() { //Render the recaptcha1 on the element with ID "recaptcha1" var contribute = document.querySelector("#contribute-recaptcha"); if(contribute) recaptcha1 = grecaptcha.render('contribute-recaptcha', { 'sitekey' : '6LfJFQwTAAAAAPTTp3QAnifnHtyfsZY013iIMvUl', 'theme' : 'light' }); //Render the recaptcha2 on the element with ID "recaptcha2" var saveFeedback = document.querySelector("#save-feedback-recaptcha"); if(saveFeedback) recaptcha2 = grecaptcha.render('save-feedback-recaptcha', { 'sitekey' : '6LfJFQwTAAAAAPTTp3QAnifnHtyfsZY013iIMvUl', 'theme' : 'light' }); }; /* @params No @return set the current window address to hidden input in contribute form */ function setCurrentURL(){ $("#current_url").val(window.location.href); } $(window).scroll(function() { if ($(".navbar").offset().top > 50) { //console.log('50 crossed'); $(".onepage-header").addClass("top-nav-collapse"); $('.navbar-fixed-top .open_brand').show(); } else { $(".onepage-header").removeClass("top-nav-collapse"); $('.navbar-fixed-top .open_brand').hide(); } }); $('.open_nav li a').click(function() { $('.open_collapse.in').collapse('hide'); $('.open-collapse.in').collapse('hide'); }); $('.navbar-toggle').click(function() { $(".open_collapse").collapse({"toggle": true, 'parent': '#navbarcollapse'}); }); /* The below code is used to avoid csrf token mismatch error while we submit form through ajax */ $.ajaxSetup({ headers: { 'X-CSRF-Token': $('input[name="_token"]').val() } }); /* Submitting RequestFeedBack form through ajax */ $("#feedback-submit").click(function(event){ event.preventDefault(); $("#feedback_current_url").val(window.location.href); $.ajax({ type:"post", url:"/opencampus/feedback", data:$('#feedback-form').serialize(), success:function(data){ if(data=="error"){ $("#error-message").removeAttr('style'); $("#error-message").text("Please enter valid information"); }else{ $("#feedback-form").trigger("reset"); $("#error-message").attr('style','display:none;'); $(".open-feedback-modal").modal('show'); $("#save-feedback-recaptcha").empty(); grecaptcha.reset(recaptcha2); } } }); }); /* hiding the error message div on edit of input fields */ $("#email,#message,#captcha").keyup(function(){ $("#error-message").attr('style','display:none;'); }); /* Submitting rss feed subscriptions form through AJAX */ $("#rss-submit").click(function(event){ event.preventDefault(); if($("#rss_email").val()=="") { $("#msg").removeAttr('style'); $("#msg").text("Please enter email"); } else { $.ajax({ type:"POST", url:"/opencampus/rss-feed", data:{ email:$("#rss_email").val(), from_url:window.location.href, }, success:function(data){ if(data=="error"){ $("#msg").removeAttr('style'); $("#msg").text("Please enter valid Email"); }else if(data=="existed"){ $("#msg").removeAttr('style'); $("#msg").text("Already subscribed"); } else{ $("#rss_email").val(""); $(".open-rss-modal").modal('show'); } } }); } }); /* Hiding the error message div while editing the mail text box in rss feed subscriptions... */ $("#rss_email").keyup(function(){ $("#msg").attr('style','display:none;'); }); $('#open_course_name').html($('#quote_course').val()); $("#requestQuote").submit(function(event){ var errors = ''; $('.errorsOutPut').hide(); if($('#quote_name').prop('value').trim() == '') { $('#quote_name').addClass('error-placeholder').attr('placeholder', 'Please enter your name'); errors += " Please enter your name. <br/>"; } if($('#quote_number').prop('value').trim() == '') { $('#quote_number').addClass('error-placeholder').attr('placeholder', 'Please enter your number'); errors += " Please enter your number. <br/>"; } if($('#location').prop('value').trim() == '') { $('#location').addClass('error-placeholder').attr('placeholder', 'Please enter your City'); errors += " Please enter your City. <br/>"; } if($('#quote_email').prop('value').trim() == '') { $('#quote_email').addClass('error-placeholder').attr('placeholder', 'Please enter your email'); errors += " Please enter your email. <br/>"; } if($('#quote_email').prop('value') != '') { var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (!filter.test($('#quote_email').prop('value'))) { $('#quote_email').addClass('error-placeholder').val('').attr('placeholder', 'Please enter a valid email'); errors += " Please enter a valid email. <br/>"; } var em = $('#quote_email').prop('value'); } if (errors != '') { // $('#quote_errors').after("<span class='text-danger errorsOutPut'>"+errors+"</span>"); return false; } var data = $('#requestQuote').serialize(); $.ajax({ url:'/request-quote', type: "POST", data:data, async:false, beforeSend : function(){ $('#img-loader').html('<i class="fa fa-refresh fa-spin"></i>'); }, success:function(result){ if(result) { window.location = "/request-thank-you"; } else { $('.callback_error').show(); } }, error:function(err,errmsg){ alert(err+' - -'+errmsg); } }); event.preventDefault(); });