PageSourceSearch

https://www.jednotky.cz/resources/js/public/controller-unit-detail.js

js jednotky.cz collected 2026-10-02 11:42:52 UTC 3,031 bytes, 93 lines download raw bytes

1var root = document.getElementById('rootUrl').getAttribute('value');
2app.controller('unitDetailController', ['$http', '$timeout', '$scope','$location','$window','$compile','$element', function ($http, $timeout, $scope, $location,$window,$compile,$element) {
3	 
4	 $scope.createUnitForm = function(ev) {
5		 var unitId = document.getElementById('unitId').value;
6		 var value = document.getElementById('requestValue').value;
7			$scope.promise = $http.get(root+'createUnitForm/'+unitId).then(function (response) {				
8				$scope.unitForm = response.data.data;
9				$scope.unitForm.value = value;
10		    });					
11	}
12	
13	$scope.createUnitForm();
14	$scope.showUnitPart = false;
15	$scope.showAllResults = false;
16	$scope.listSelectUnits;
17	
18	//zmena hodnoty prevodu
19	 $scope.$watch('unitForm.value', function (newValue, oldValue) {
20	    	if (oldValue != newValue && newValue != null && newValue != '') {
21	    		$scope.conversion();
22	    	}
23	    });
24	 
25	 //zmena jednotky prevodu
26	 
27	 $scope.changeUnit = function(newUnitId) {
28		 var unitId = document.getElementById('unitId').value;
29		 var value = document.getElementById('value').value;
30		 if (newUnitId != null && newUnitId != '' && newUnitId != 'undefined' && newUnitId != unitId) {
31			 $scope.promise = $http.get(root+'redirect/'+newUnitId+'/').then(function (response) {
32	    			var redirectUrl = root+response.data.data;
33	    			if (value != '') {
34	    				redirectUrl = redirectUrl+"?hodnota="+value
35	    			}
36	    			$window.location.href = redirectUrl;
37			    });	
38		 }
39	 }
40
41	$scope.showPart = function () {
42		if ($scope.showUnitPart == false) {
43			$scope.showUnitPart = true;
44			var unitId = $scope.unitForm.unitId;
45			$location.hash('unit-'+unitId);
46			$scope.listSelectUnits = $scope.unitForm.units;
47		} else {
48			$scope.listSelectUnits = null;
49			$scope.showUnitPart = false;
50		}
51	 }
52	
53	$scope.showHideResults = function() {
54		if ($scope.showAllResults == true) {
55			$scope.showAllResults = false;
56			$scope.unitForm.showAllResults = $scope.showAllResults;
57		} else {
58			$scope.showAllResults = true;
59			$scope.unitForm.showAllResults = $scope.showAllResults;
60			$scope.conversion();
61		}
62	}
63	
64	$scope.conversion = function() {
65		var dataObj = $scope.unitForm;
66        var url = root+'unit/conversion';
67        $scope.loading = true;
68        $http({
69            method: 'POST',
70            data: dataObj,
71            url: url,
72            headers: {'Content-Type': 'application/json'}
73        }).then(function successCallback(response) {
74
75            $scope.loading = false;
76            
77            if(response.data.code==0) {
78            	$scope.dataTable = response.data.data;
79            } else {
80            	$scope.dataTable = null;
81            }
82        }, function errorCallback(response) {
83            $scope.loading = false;
84            // TODO some error dialog?
85        });
86	}
87	
88	$scope.renderHtml = function (htmlCode) {
89        return $sce.trustAsHtml(htmlCode);
90    };
91	
92		
93}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.