tollfileTmp.js 3.21 KB
var urlarr = JSON.parse(sessionStorage.getItem("threemenulist"));
console.log(urlarr)
var _html = '';
for(var i=0;i<urlarr.length;i++){
    if(i==0){
        _html  += '<li data-url="'+urlarr[i].url+'" id="button-'+urlarr[i].url+'" class="ITD-topbar-clickactive"><a href="#/'+urlarr[i].url+'"><div >'+urlarr[i].name+'</div></a></li>'
    }else{
        _html  += '<li data-url="'+urlarr[i].url+'" id="button-'+urlarr[i].url+'" ><a href="#/'+urlarr[i].url+'"><div >'+urlarr[i].name+'</div></a></li>'
    }
}
$('#button-btn').html(_html);
function Router(){
    this.routes = {};
    this.curUrl = '';

    this.route = function(path, callback){
        this.routes[path] = callback || function(){};
    };

    this.refresh = function(){
        this.curUrl = location.hash.slice(1) || '/'+urlarr[0].url;
        console.log(this.curUrl)
        this.routes[this.curUrl]();
    };

    this.init = function(){
        window.addEventListener('load', this.refresh.bind(this), false);
        window.addEventListener('hashchange', this.refresh.bind(this), false);
    }
}
var R = new Router();
R.init();
var res = $('#main-con');
R.route('/tollcollector', function() {
    $("#pageCssLink").attr("href",'../../assets/pages/scripts/tollFile/tollCollector/tollcollector.css');
    res.load('../../assets/pages/scripts/tollFile/tollCollector/tollcollector.html');
    $('.ITD-topbar-wrap li').removeClass('ITD-topbar-clickactive');
    $('#button-tollcollector').addClass('ITD-topbar-clickactive');
});
R.route('/chargegroup', function() {
    $("#pageCssLink").attr("href",'../../assets/pages/scripts/tollFile/chargeGroup/chargegroup.css');
    res.load('../../assets/pages/scripts/tollFile/chargeGroup/chargegroup.html');
    $('.ITD-topbar-wrap li').removeClass('ITD-topbar-clickactive');
    $('#button-chargegroup').addClass('ITD-topbar-clickactive');

});
R.route('/cashieraudit', function() {
    $("#pageCssLink").attr("href",'../../assets/pages/scripts/tollFile/cashierAudit/cashieraudit.css');
    res.load('../../assets/pages/scripts/tollFile/cashierAudit/cashieraudit.html');
    $('.ITD-topbar-wrap li').removeClass('ITD-topbar-clickactive');
    $('#button-cashieraudit').addClass('ITD-topbar-clickactive');
});
R.route('/tollchecker', function() {
    $("#pageCssLink").attr("href",'../../assets/pages/scripts/tollFile/tollChecker/tollchecker.css');
    res.load('../../assets/pages/scripts/tollFile/tollChecker/tollchecker.html');
    $('.ITD-topbar-wrap li').removeClass('ITD-topbar-clickactive');
    $('#button-tollchecker').addClass('ITD-topbar-clickactive');
});
R.route('/auditoftoll', function() {
    $("#pageCssLink").attr("href",'../../assets/pages/scripts/tollFile/auditofToll/auditoftoll.css');
    res.load('../../assets/pages/scripts/tollFile/auditofToll/auditoftoll.html');
    $('.ITD-topbar-wrap li').removeClass('ITD-topbar-clickactive');
    $('#button-auditoftoll').addClass('ITD-topbar-clickactive');
});
R.route('/chargesign', function() {
    $("#pageCssLink").attr("href",'../../assets/pages/scripts/tollFile/chargeFile/chargesign.css');
    res.load('../../assets/pages/scripts/tollFile/chargeFile/chargesign.html');
    $('.ITD-topbar-wrap li').removeClass('ITD-topbar-clickactive');
    $('#button-chargesign').addClass('ITD-topbar-clickactive');
});