cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

Community Helping Community

ISE Sponsor Portal auto location based off sponsor machine time

1073
Views
2
Helpful
0
Comments

Summary

NOTE: This is used for releases prior to ISE 2.2. For 2.2+ this is built into the product.

ISE requires both sponsors and self-registered guests to specify a correct location, which, in turn, maps to a time zone. For customers with a handful of location, it’s trivial to define a few locations and let sponsors choose the correct one from a short list. However, for large global customers, dozens of different locations may need to be defined forcing the end users to scroll through a long list.

The purpose of this customization is to retrieve the local time and time zone from the sponsor’s browser and updating the fields on the sponsor form.

What information do I need to know when working with javascript?

Look at the javascript section of this guide How To: ISE Web Portal Customization Options

Here is a video doing something similar, this video shows what are the steps to inject javascript into a Sponsor Portal under same location.

https://communities.cisco.com/videos/15502

Do you really need to use locations?

ISE Guest Types do i really need locations and timezones?

Setup

Locations

  In ISE, location names are free text and when those locations are displayed on end user forms, there’s no indication what time zone those locations correspond to. It is, therefore, required to create locations using a uniform naming convention as shown on the following screenshot


Sponsor Portal Create Account:


Screen Shot 2016-08-24 at 4.27.10 PM.png

Locations are configured under:

Guest Access > Settings > Locations and SSIDs

Screen Shot 2016-08-24 at 4.05.25 PM.png

Guest Access > Configure > Sponsor Groups

Screen Shot 2016-08-24 at 4.15.39 PM.png

The following script will use your sponsors machine time to automatically choose a location. If the location doesn't exist it will use the top most entry.

This goes in the sponsor portal > Portal Page customization > Create Known Accounts > Instructional text


<script>

(function(){

$( "body" ).one( "accesscreated", function() {

var locations = [{name:”Boston",offset:-4},{name:”Chicago",offset:-5},{name:”San Jose",offset:-7}]

var browserOffset = new Date().getTimezoneOffset()/60;

for(var i=0;i<locations.length;i++){

if(browserOffset == locations[i].offset){

cisco.ise.sponsor.pages.home.setSelectValueAndRefresh('location',locations[i].name);

cisco.ise.sponsor.pages.home.persistClientData('location',locations[i].name);

}

}

  });

})();

</script>



What if i have lots of locations?

If you have a need for more locations then here is another option:

In ISE, location names are free text and when those locations are displayed on end user forms, there’s no indication what time zone those locations correspond to. It is, therefore, required to create locations using a uniform naming convention as shown on the following screenshot:

Picture1.png

Add JavaScript code

Paste the following snippet of code (instead of the one listed before) and click on HTML Source button again.

<script>

function zeroPad(num) {

       return(num<10?'0'+num:num);

}

function setBrowserTime() {

       if($('[name=from-time]').length) {

              var curTime=new Date();

              var tzOffset=0-curTime.getTimezoneOffset();

              var offsetHours=parseInt(tzOffset/60);

              var offsetMinutes=(tzOffset%60);

              var ISELocation='UTC'+(tzOffset>=0?'+':'')+offsetHours+':'+zeroPad(offsetMinutes);

              $('[name=from-date]').val(curTime.getFullYear()+'-'+zeroPad(curTime.getMonth()+1)+'-'+zeroPad(curTime.getDate()));

              $('[name=from-time]').val(zeroPad(curTime.getHours())+':'+zeroPad(curTime.getMinutes()));

              $('[name=to-time]').val('11:59');

              $('[name=from-date]').change();

              $('[name=location]').val(ISELocation);

              $('[name=location]').change();

       } else setTimeout(setBrowserTime,1000,true);

}

setTimeout(setBrowserTime,1000,true);

</script>

CreatePlease to create content
Content for Community-Ad
FusionCharts will render here