demo20230512/Browser_Local/js/Main.js
2023-05-12 10:20:28 +08:00

80 lines
2.7 KiB
JavaScript

/*
Logic Solution
WeeeCarbonFootprint
AngularJS Core
*/
if(typeof window.components === "undefined") { window.components = []; }
window.components.push('ngRoute');
window.components.push('ngResource');
window.components.push('ngAnimate');
window.components.push('ngCookies');
window.components.push('ui.datepicker');
window.components.push('Resources.Config');
window.components.push('Services');
window.components.push('Utility.UploadFile');
window.components.push('Basic.MultiLanguage.Config');
window.components.push('LCA.Config');
window.components.push('LCA.Survey.Config');
window.components.push('LCA.MultiLanguage.Config');
window.components.push('View.Directive');
window.components.push('listtable.filter');
window.components.push('ui-notification');
angular.module('CarbonFootprint', window.components);
'use strict';
var arr = window.location.href.split("/");
if (arr[3].indexOf('app') == 0)
baseUrl = '';
else
baseUrl = '/' + arr[3];
var carbonApp = angular.module('CarbonFootprint')
.config(function ($routeProvider) {
$routeProvider
.otherwise({
redirectTo: baseUrl+'/Partials/NotFound'
});
})
.controller('MainCtrl', ['$scope', 'SURVEY_TABLE_MODEL', 'CONSTANTS', '$location','$http',
function ($scope, SURVEY_TABLE_MODEL, CONSTANTS, $location, $http) {
$scope.SURVEY_FORM_MODEL = SURVEY_TABLE_MODEL.SURVEY_FORM_CONFIG;
$scope.CONSTANTS = CONSTANTS;
$scope.Header_Keys = Setkeys(SURVEY_TABLE_MODEL.SURVEY_FORM_CONFIG);
$scope.Math = window.Math;
// set $scope.baseUrl
var baseUrl = $scope.baseUrl;
if (typeof (baseUrl) === 'undefined' || baseUrl == null) {
var arr = window.location.href.split("/");
if (arr[3].indexOf('app') == 0)
baseUrl = '';
else
baseUrl = '/' + arr[3];
$scope.baseUrl = baseUrl;
}
//console.log('$scope.baseUrl', $scope.baseUrl);
$http.get($scope.baseUrl + "/api/Company/Get").then(function (response) {
$scope.LogoUrl = /*baseUrl +*/ response.data.LogoUrl;
//console.log('$scope.LogoUrl', $scope.LogoUrl);
//alert($scope.LogoUrl);
if ($scope.LogoUrl) {
angular.element('.survey_form_logo img').attr('src', $scope.LogoUrl);
}
})
$scope.isActive = function (path) {
var currentPath = $location.path().split('/')[1];
return currentPath == path;
};
}])
.controller('CreateAccount', ['$scope', function ($scope) {
console.log('create account');
}]);
//DL-5
carbonApp.config(['$compileProvider', function ($compileProvider) {
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|localhost|data|chrome-extension):/);
$compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|localhost|data|chrome-extension):/);
}]);