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:
Locations are configured under:
Guest Access > Settings > Locations and SSIDs
Guest Access > Configure > Sponsor Groups
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:
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> |