public/javascripts/site/helpers.js


 

$( document ).ready(function() {
    $(".dropdown-toggle").dropdown();
    var city;
    var lo = currentLocation();

    $('.venus-menu .selected').removeClass('selected');

          $('.venus-menu a').each(function () {
            if (-1 !== lo.indexOf($(this).attr('x-value'))) {
              $(this).addClass('selected');
            }
          })

    $('.types-menu .selected').removeClass('selected');

    $('.types-menu a').each(function () {
      if (-1 !== lo.indexOf($(this).attr('x-value'))) {
        $(this).addClass('selected');

         var b =  $(this).html() + "<b class='caret'></b>";
         $('a.dd-types').html(b);
      }
    });

    if(lo.match(/agra/g) &&  lo.match(/agra/g).length>0){
      city = 'Agra';
    }else if(lo.match(/bengaluru/g) && lo.match(/bengaluru/g).length>0){
      city = 'Bengaluru';
    }else if(lo.match(/chennai/g) && lo.match(/chennai/g).length>0){
      city = 'Chennai';
    }else if(lo.match(/delhi/g) && lo.match(/delhi/g).length>0){
      city = 'Delhi';
    }else if(lo.match(/goa/g) && lo.match(/goa/g).length>0){
      city = 'Goa';
    }else if(lo.match(/gurgaon/g) && lo.match(/gurgaon/g).length>0){
      city = 'Gurgaon';
    }else if(lo.match(/hyderabad/g) && lo.match(/hyderabad/g).length>0){
      city = 'Hyderabad';
    }else if(lo.match(/jaipur/g) && lo.match(/jaipur/g).length>0){
      city = 'Jaipur';
    }else if(lo.match(/kolkata/g) && lo.match(/kolkata/g).length>0){
      city = 'Kolkata';
    }else if(lo.match(/mumbai/g) && lo.match(/mumbai/g).length>0){
      city = 'Mumbai';
    }else if(lo.match(/noida/g) && lo.match(/noida/g).length>0){
      city = 'Noida';
    }else if(lo.match(/pune/g) && lo.match(/pune/g).length>0){
      city = 'Pune';
    }else if(lo.match(/surat/g) && lo.match(/surat/g).length>0){
      city = 'Surat';
    }else if(lo.match(/visakhapatnam/g) && lo.match(/visakhapatnam/g).length>0){
      city = 'Visakhapatnam';
    }else if(lo.match(/kerala/g) && lo.match(/kerala/g).length>0){
      city = 'Kerala';
    }else if(lo.match(/andaman/g) && lo.match(/andaman/g).length>0){
      city = 'Andaman';
    }else if(lo.match(/kashmir/g) && lo.match(/kashmir/g).length>0){
      city = 'Kashmir';
    }else if(lo.match(/puri/g) && lo.match(/puri/g).length>0){
      city = 'Puri';
    }else if(lo.match(/bhubaneshwar/g) && lo.match(/bhubaneshwar/g).length>0){
      city = 'Bhubaneshwar';
    }else if(lo.match(/sikkim/g) && lo.match(/sikkim/g).length>0){
      city = 'Sikkim';
    }else if(lo.match(/indore/g) && lo.match(/indore/g).length>0){
      city = 'Indore';
    }else if(lo.match(/ahmedabad/g) && lo.match(/ahmedabad/g).length>0){
      city = 'Ahmedabad';
    }else if(lo.match(/guwahati/g) && lo.match(/guwahati/g).length>0){
      city = 'Guwahati';
    }else if(lo.match(/chandigarh/g) && lo.match(/chandigarh/g).length>0){
      city = 'Chandigarh';
    }else if(lo.match(/varanasi/g) && lo.match(/varanasi/g).length>0){
      city = 'Varanasi';
    }else if(lo.match(/allahabad/g) && lo.match(/allahabad/g).length>0){
      city = 'Allahabad';
    }else if(lo.match(/bhopal/g) && lo.match(/bhopal/g).length>0){
      city = 'Bhopal';
    }else if(lo.match(/ranchi/g) && lo.match(/ranchi/g).length>0){
      city = 'Ranchi';
    }else if(lo.match(/patna/g) && lo.match(/patna/g).length>0){
      city = 'Patna';
    }else if(lo.match(/lakshadweep/g) && lo.match(/lakshadweep/g).length>0){
      city = 'Lakshadweep';
    }
//+17327628664
    setText(city);
    setTypeUrl();
    setVenueUrl();
    $('li a.venus').click(function(e){
      $('.venus-menu .selected').removeClass('selected');
      $(this).addClass('selected');
        setText($(this).text());
        setTypeUrl();
    });

    $('li a.types').click(function (e) {
      $('.types-menu .selected').removeClass('selected');
      $(this).addClass('selected');
      $('a.dd-types').html($(this).text() + '<b class="caret"></b>');
      setVenueUrl();
    });
});

function currentLocation(){
var lo = location.pathname;
    lo = lo.replace("\/","");
    return lo;
}
function setText(s){

    if(!s){
     s = 'Destinations';
    }

   var b =  s + "<b class='caret'></b>";
   $('a.dd-venus').html(b);
    if(s == 'Agra'){
      s = 'agra';
    }else if(s=='Bengaluru'){
      s='bengaluru';
    }else if(s=='Chennai'){
      s='chennai';
    }else if(s=='Delhi'){
      s='delhi';
    }else if(s=='Goa'){
      s='goa';
    }else if(s=='Gurgaon'){
      s='gurgaon';
    }else if(s=='Hyderabad'){
      s='hyderabad';
    }else if(s=='Jaipur'){
      s='jaipur';
    }else if(s=='Kolkata'){
      s='kolkata';
    }else if(s=='Mumbai'){
      s='mumbai';
    }else if(s=='Noida'){
      s='noida';
    }else if(s=='Pune'){
      s='pune';
    }else if(s=='Ahmedabad'){
      s='ahmedabad';
    }else if(s=='Guwahati'){
      s='guwahati';
    }else if(s=='Chandigarh'){
      s='chandigarh';
    }else if(s=='Varanasi'){
      s='varanasi';
    }else if(s=='Allahabad'){
      s='allahabad';
    }else if(s=='Bhopal'){
      s='bhopal';
    }else if(s=='Patna'){
      s='patna';
    }else if(s=='Kashmir'){
      s='kashmir';
    }else if(s=='Puri'){
      s='puri';
    }else if(s=='Bhubaneshwar'){
      s='bhubaneshwar';
    }else if(s=='Sikkim'){
      s='sikkim';
    }else if(s=='Indore'){
      s='indore';
    }else if(s=='Ranchi'){
      s='ranchi';
    }else if(s=='Surat'){
      s='surat';
    }else if(s=='Visakhapatnam'){
      s='visakhapatnam';
    }else if(s=='India'){
      s='India';
    }
    var k =  $('a.color-venues')[0];
    $(k).attr('href', '/'+s+'/venues');

    k =  $('a.color-offers')[0];
    $(k).attr('href', '/'+s+'/offers');
}

function setTypeUrl() {
  $('a.types').each(function () {
    var xVar = $('.venus-menu .selected').attr('x-value');
    if (xVar === undefined) {
      xVar = 'delhi';
    }
    $(this).attr('href', '/'+ xVar + '/type/' + $(this).attr('x-value'));
  });
}

function setVenueUrl() {
  if ($('.types-menu .selected').length > 0) {
    $('a.venus').each(function () {
      $(this).attr('href', '/' + $(this).attr('x-value') + '/type/' + $('.types-menu .selected').attr('x-value'));
    });
  } else {
    $('a.venus').each(function () {
      $(this).attr('href', '/' + $(this).attr('x-value'));
    });
  }
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *