CurrBuildController.js 9.49 KB
AIA.controller("CurrBuildController", ["$scope", "$rootScope", "pages", "$log", "Modules", "$http", "$compile", "$location",
function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location) {
    
   // $rootScope.currentActiveModuleTitle = pages[6].name;
    $scope.showTabButton = false;
    $scope.listCurriculumBuilder = null;
    $scope.dataPopup = null;
    $scope.countLeftlist;
    $scope.countRightlist;
    $scope.IsVisible = function () {
        $scope.scroll();

    }

    $scope.scroll = function () {
        // $window.scrollTo(0, 0);
        $("html,body").scrollTop(0);
        //alert("scroll");
    }

   /* $scope.openAIAFlexCB = function () {
        var userInfo = ($rootScope.userData);


        var key = CryptoJS.enc.Base64.parse("MTIzNDU2NzgxMjM0NTY3OA");
        var iv = CryptoJS.enc.Base64.parse("EBESExQVFhcYGRobHB0eHw");

        var encryptedUserName = CryptoJS.AES.encrypt(userInfo.LoginId, key, { iv: iv });
        var encryptedPassword = CryptoJS.AES.encrypt(userInfo.Password, key, { iv: iv });
//console.log('userInfo.LoginId = '+userInfo.LoginId+' and userInfo.Password = '+userInfo.Password)
		     //   var Base64 = { _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", encode: function (e) { var t = ""; var n, r, i, s, o, u, a; var f = 0; e = Base64._utf8_encode(e); while (f < e.length) { n = e.charCodeAt(f++); r = e.charCodeAt(f++); i = e.charCodeAt(f++); s = n >> 2; o = (n & 3) << 4 | r >> 4; u = (r & 15) << 2 | i >> 6; a = i & 63; if (isNaN(r)) { u = a = 64 } else if (isNaN(i)) { a = 64 } t = t + this._keyStr.charAt(s) + this._keyStr.charAt(o) + this._keyStr.charAt(u) + this._keyStr.charAt(a) } return t }, decode: function (e) { var t = ""; var n, r, i; var s, o, u, a; var f = 0; e = e.replace(/[^A-Za-z0-9+/=]/g, ""); while (f < e.length) { s = this._keyStr.indexOf(e.charAt(f++)); o = this._keyStr.indexOf(e.charAt(f++)); u = this._keyStr.indexOf(e.charAt(f++)); a = this._keyStr.indexOf(e.charAt(f++)); n = s << 2 | o >> 4; r = (o & 15) << 4 | u >> 2; i = (u & 3) << 6 | a; t = t + String.fromCharCode(n); if (u != 64) { t = t + String.fromCharCode(r) } if (a != 64) { t = t + String.fromCharCode(i) } } t = Base64._utf8_decode(t); return t }, _utf8_encode: function (e) { e = e.replace(/rn/g, "n"); var t = ""; for (var n = 0; n < e.length; n++) { var r = e.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r) } else if (r > 127 && r < 2048) { t += String.fromCharCode(r >> 6 | 192); t += String.fromCharCode(r & 63 | 128) } else { t += String.fromCharCode(r >> 12 | 224); t += String.fromCharCode(r >> 6 & 63 | 128); t += String.fromCharCode(r & 63 | 128) } } return t }, _utf8_decode: function (e) { var t = ""; var n = 0; var r = c1 = c2 = 0; while (n < e.length) { r = e.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r); n++ } else if (r > 191 && r < 224) { c2 = e.charCodeAt(n + 1); t += String.fromCharCode((r & 31) << 6 | c2 & 63); n += 2 } else { c2 = e.charCodeAt(n + 1); c3 = e.charCodeAt(n + 2); t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63); n += 3 } } return t } }
  // var encryptedUserName = Base64.encode(userInfo.LoginId);
  /// var encryptedPassword = Base64.encode(userInfo.Password);
    // console.log('encryptedUserName= '+encryptedUserName+' and encryptedPassword ='+encryptedPassword); // Outputs: "SGVsbG8gV29ybGQh"

        // Decode the String
       // var decodedString = Base64.decode(encodedUname);
       // console.log('decodedString= '+decodedString); // Outputs: "Hello World!"
		
        $location.url('/');

        window.open('http://legacy.interactiveanatomy.com/Default.aspx?un=' + encryptedUserName + '&up=' + encryptedPassword);

    }*/
	
	 $scope.openAIAFlexCB = function () {
        var userInfo;
        var encryptedUserName;
        var encryptedPassword
        var urlPrams;

        var key = CryptoJS.enc.Base64.parse("MTIzNDU2NzgxMjM0NTY3OA");
        var iv = CryptoJS.enc.Base64.parse("EBESExQVFhcYGRobHB0eHw");

        if ($rootScope.isCallFromSite) {

            if ($rootScope.IsCalsCred) {
                encryptedUserName = CryptoJS.AES.encrypt($rootScope.siteUrlInfo.username, key, { iv: iv });
                encryptedPassword = CryptoJS.AES.encrypt($rootScope.siteUrlInfo.password, key, { iv: iv });

                $location.url('/');

                window.open('http://legacy.interactiveanatomy.com/Default.aspx?un=' + encryptedUserName + '&up=' + encryptedPassword + '&mod=7');

            }
            else {

                var siteUrlInfo = JSON.parse(localStorage.getItem("siteUrlInfo"));
                var encryptedSiteIP = CryptoJS.AES.encrypt(siteUrlInfo.siteIP, key, { iv: iv });
                var encryptedAccountNumber = CryptoJS.AES.encrypt(siteUrlInfo.accountNumber, key, { iv: iv });
                var encryptedEdition = siteUrlInfo.edition;
                var encryptedUrlReferer = CryptoJS.AES.encrypt(siteUrlInfo.urlReferer, key, { iv: iv });
                var encryptedSiteId = $rootScope.siteId;
                var encryptedRemoteIPAddress = CryptoJS.AES.encrypt(siteUrlInfo.remoteIPAddress, key, { iv: iv });

                console.log("encryptedSiteIP = " + encryptedSiteIP + ",encryptedAccountNumber= " + encryptedAccountNumber + ",encryptedEdition= " + encryptedEdition + ",encryptedUrlReferer= " + encryptedUrlReferer + ", encryptedSiteId= " + encryptedSiteId + ", encryptedRemoteIPAddress=" + encryptedRemoteIPAddress);
                /* var encryptedSiteIP = CryptoJS.AES.encrypt(siteIp, key, { iv: iv });
                 var encryptedAccountNumber = CryptoJS.AES.encrypt(accountNo, key, { iv: iv });
                 var encryptedEdition = editionId;//CryptoJS.AES.encrypt($rootScope.siteUrlInfo.edition, key, { iv: iv });
                 var encryptedUrlReferer = urlRef ;
                 var encryptedRemoteIPAddress = CryptoJS.AES.encrypt($rootScope.siteUrlInfo.remoteIPAddress, key, { iv: iv });
                 var encryptedSiteId = $rootscope.siteId;*/

                $location.url('/');

                window.open('http://legacy.interactiveanatomy.com/Default.aspx?si=' + encryptedSiteIP + '&ac=' + encryptedAccountNumber + '&ed=' + encryptedEdition + '&rf=' + encryptedUrlReferer + '&rm=' + encryptedRemoteIPAddress + '&mod=7' + '&s=' + encryptedSiteId);

            }
        }
        else {
            userInfo = ($rootScope.userData);
            var encryptedUserName = CryptoJS.AES.encrypt(userInfo.LoginId, key, { iv: iv });
            var encryptedPassword = CryptoJS.AES.encrypt(userInfo.Password, key, { iv: iv });

            $location.url('/');

            window.open('http://legacy.interactiveanatomy.com/Default.aspx?un=' + encryptedUserName + '&up=' + encryptedPassword + '&mod=7');

        }
    }

    //load json data
    $scope.loadCurriculumBuiderData = function () {

        if ($rootScope.refreshcheck == null) {
            $location.path('/');
        }
        //get current path
        var currentURL = $location.path();
        var selectedModuleName = '';
        //set module title
        angular.forEach($rootScope.userModules, function (value, key) {
            if (value.slug === currentURL.replace('/', '')) {
                selectedModuleName = value.name;
            }
            $rootScope.currentActiveModuleTitle = selectedModuleName;
        })

        //get current path
        var currentURL = $location.path();

        $http({ method: 'GET', url: 'content/data/json/cb/cb_list_content.json' }).success(function (data) {

            $scope.listCurriculumBuilder = data;
            //load default body view list 
            $scope.getCBViewList();
        })
        .error(function (data, status, headers, config) {
            console.log(data);
        });
    }
    //get CB body view list
    $scope.getCBViewList = function ($event) {

        $('#leftBodyViewList').empty();
        $scope.countLeftlist = Object.keys($scope.listCurriculumBuilder.slideshows.slideshow).length / 2;
        $scope.loadleftBodyViewList = new jinqJs()
        .from($scope.listCurriculumBuilder.slideshows.slideshow)
        .select();
        for (var i = 0; i < $scope.countLeftlist; i++) {
            console.log($scope.listCurriculumBuilder.slideshows.slideshow[i]._label);
            //alert($scope.listCurriculumBuilder.slideshows.slideshow[i]._label);
            var $el = $('<li class="list-group-item" data-toggle="modal" data-target="#myModal-1" ng-click="loadSlideShowXmldata()"><a  href="#"><i class="fa fa-check"></i>' + $scope.listCurriculumBuilder.slideshows.slideshow[i]._label + '</a></li>').appendTo('#leftBodyViewList');
            $compile($el)($scope);
        }

        $scope.countRightlist = Object.keys($scope.listCurriculumBuilder.slideshows.slideshow).length;
        for (var i = $scope.countLeftlist; i < $scope.countRightlist; i++) {
            console.log($scope.listCurriculumBuilder.slideshows.slideshow[i]._label);
            var $el1 = $('<li class="list-group-item" data-toggle="modal" ng-click="loadSlideShowXmldata()" data-target="#myModal-1"><a href="#"><i class="fa fa-check"></i>' + $scope.listCurriculumBuilder.slideshows.slideshow[i]._label + '</a></li>').appendTo('#rightBodyViewList');
            $compile($el)($scope);
        }

    }

    $scope.loadSlideShowXmldata = function (e) {

       // alert(e);
        $http({ method: 'GET', url: 'content/data/json/cb/SlideShow/AIA_Curriculum_Builder_Guide.sldshw' }).success(function (data) {

            $scope.dataPopup = data;
            alert($scope.dataPopup);
        })
       .error(function (data, status, headers, config) {
           console.log(data);
       });
    }
}]



);