PageSourceSearch

https://www.stromroku.cz/CMSScripts/Custom/Strom%20roku%20new/hlasovani.js?v=59

js stromroku.cz collected 2026-10-02 10:30:09 UTC 8,009 bytes, 265 lines download raw bytes

1var srModule = angular.module('srApp', ['vcRecaptcha', 'bootstrapLightbox']);
2
3srModule.controller('srController', function ($scope, $http, $timeout, Lightbox) {
4
5  $scope.displayed_tree_index = -1; // displayed tree index
6  $scope.displayed_tree_url = ""; // displayed tree detail url
7  $scope.trees = [];//all trees
8  $scope.trees_images = {};//trees images
9  $scope.trees_images2 = {};//trees images for detail
10  $scope.imgsrc = [];
11  $scope.show_info = false; //show nomination info
12  $scope.show_detail_DMS = false; // toggle long info on DMS on vote page
13  $scope.show_detail_sheet = false; // toggle long info on voting sheets on vote page
14  $scope.selected_tree_index = -1; // index of tree selected in map
15  $scope.vote_send_response = null; // response of vote_send request
16
17  $scope.init = function (culture) {
18  }
19
20  $scope.init_trees = function (trees) {
21    $scope.trees = trees;
22  }
23
24  $scope.init_trees_images = function (images) {
25    $scope.trees_images = images;
26  }
27
28  $scope.init_trees_images2 = function (images) {
29    $scope.trees_images2 = images;
30  }
31
32  $scope.format_votes = function (votes) {
33    return votes.toLocaleString();
34  }
35
36  $scope.animate_tree_image = function (index1, index2) {
37    return $scope.imgsrc[index1] == $scope.trees_images2[index2].filename;
38  }
39
40  $scope.display_tree_detail = function (nodeid, index, url, event, followLink) {
41    followLink = (followLink == undefined) ? true : followLink;
42    if (event.view.isMobile && followLink) {
43      window.location.href = url;
44    }
45    else {
46      const el = event.target;
47      /*				if (el.tagName != "BUTTON" && !angular.element(el).hasClass('tick')) {*/
48      if ($scope.displayed_tree_index === index) {
49        $scope.displayed_tree = undefined;
50        $scope.displayed_tree_index = -1;
51        $scope.displayed_tree_url = "";
52      }
53      else {
54        $scope.displayed_tree = $scope.trees.find(function (x) { return x.nodeid === nodeid });
55        $scope.displayed_tree_index = index;
56        $scope.displayed_tree_url = url;
57      }
58      /*				}*/
59    }
60  }
61
62  $scope.tree_detail_displayed = function (nodeid, index1, index2) {
63    return (nodeid !== undefined && Math.floor(index1 / 3) === Math.floor(index2 / 3))
64  }
65
66
67  $scope.trim_tree_name = function (name, event) {
68    if (name != undefined) {
69      var splt = name.split(' ');
70      var trimmed_name = splt.length > 3 ? splt.slice(0, 4).join(' ') : name;
71      if (trimmed_name.length < name.length) trimmed_name += ' ...';
72      return trimmed_name;
73    }
74    else {
75      return "";
76    }
77  }
78
79  $scope.openLightboxModal = function (index) {
80    Lightbox.openModal($scope.award_images, index);
81  };
82
83  $scope.init_award_images = function (images) {
84    $scope.award_images = images;
85  };
86
87  $scope.show_votes = function (tree) {
88    return ($scope.trees_votes[tree] == undefined || $scope.trees_votes[tree].votes > 4 ? 'hlasĹŻ' : ($scope.trees_votes[tree].votes == 1 ? 'hlas' : 'hlasy'));
89  }
90
91  $scope.selected_tree = 0; //selected trees node ids
92  $scope.stl = [];//selected trees list
93  $scope.imgsrc = [];
94  $scope.trees_votes = {};//trees votes		
95  $scope.email_template_id = 1016;
96  $scope.vote_result = false; //result of process
97  $scope.show_rules = false; //show vote rules
98  $scope.show_terms = false; //show terms & conditions
99
100
101  $scope.openLightboxModal = function (index) {
102    Lightbox.openModal($scope.award_images, index);
103  };
104
105  $scope.init_trees_votes = function (votes) {
106    $scope.trees_votes = votes;
107  }
108
109  //dodělat - předělat
110  $scope.select_tree = function (nodeid, event) {
111    const el = event.target;
112    if (el.tagName != "A" && !angular.element(el).hasClass('tree-img')) {
113      event.preventDefault();
114
115      nodeid = parseInt(nodeid);
116
117      $scope.selected_tree = (nodeid);
118
119      //update stl
120      $scope.update_stl();
121      //console.log($scope.selected_tree);
122      localStorage.setItem('selected_tree', JSON.stringify($scope.selected_tree));
123    }
124
125  }
126
127  $scope.tree_selected = function (nodeid) {
128    ret = false;
129    if ($scope.selected_tree == nodeid) ret = true;
130    return ret;
131  }
132
133  $scope.show_vote_dialog = function (event) {
134    event.preventDefault();
135    //$scope.selected_tree = $scope.trees[index];			
136    /*			$scope.selected_tree = $scope.trees.find(function(x) {
137            return parseInt(x.nodeid) === nodeid}
138            );*/
139    $('#myModal').modal('show');
140    $('.page-content').classList.add('test');
141  }
142
143  $scope.vote_button_enabled = function () {
144    ret = false;
145    if ($scope.selected_tree != 0) ret = true;
146    return ret;
147  }
148
149  $scope.update_stl = function () {
150    $scope.stl = [];
151    var ret;
152
153    $scope.stl = _.filter($scope.trees, function (t) {
154      ret = false;
155      if (t.nodeid == $scope.selected_tree) { ret = true; }
156      return ret;
157    });
158  }
159
160  /*Recaptcha*/
161  $scope.captcha_not_used = false;
162  $scope.response = null;
163  $scope.widgetId = null;
164  $scope.model = {
165    key: '6LdPTdkmAAAAAJUOOfJUP-4P0Cwn2LMazjuideX4'
166  };
167  $scope.setResponse = function (response) {
168    // console.info('Response available: %s', response);
169    $scope.response = response;
170  };
171  $scope.setWidgetId = function (widgetId) {
172    //console.info('Created widget ID: %s', widgetId);
173    $scope.widgetId = widgetId;
174  };
175
176  $scope.vote_send = function () {
177    $scope.vote_result = false;
178    
179    const savedQueryString = localStorage.getItem('savedQueryString');    
180    
181    $http({
182      url: '/vote',
183      method: "POST",
184      data: { 'captcha': $scope.response, 'email': $scope.email, 'templateid':$scope.email_template_id, 'tree': $scope.selected_tree, 'newsletter': $scope.newsletter, 'queryString': savedQueryString },
185    })
186      .then(function (response) {
187        // success
188        if (response.data) {
189          // handle response failed
190          if (response.data === -1 || response.data === "-1") {
191            $scope.vote_result = -1;
192            return;
193          }
194          $scope.vote_result = JSON.parse(response.data);
195        };
196        $('#myModal').modal('hide');
197        //$('#myModal2').modal('show');
198        window.dataLayer.push({
199          'event': 'vote_success',
200          'tree': {
201            'tree_name': $scope.stl[0].name,
202            'newsletter_subscribe': $scope.newsletter,
203          },
204          _clear: true
205        });
206        
207        // if newsletter send contact to brevo, wait for response, then redirect
208
209
210
211        if (savedQueryString) {
212          // Okamžité smazání z localStorage, aby byla hodnota dostupná pouze jednou
213          localStorage.removeItem('savedQueryString');
214        }
215       
216        document.location.href = '/hlasovani/dekujeme-za-hlas';
217        
218        //document.location.href = '/hlasovani/dekujeme-za-hlas';
219        //$scope.clear();	
220      },
221        function (response) { // optional
222          // failed
223          $('#myModal').modal('hide');
224          //$('#myModal2').modal('show');
225          //$scope.clear();
226        });
227  }
228
229  $scope.vote_submit = function (event) {
230    event.preventDefault();
231    $scope.submitted = true;
232
233    if ($scope.vote_form.$valid) {
234      $scope.captcha_not_used = false;
235      $scope.vote_send();
236    }
237    else {
238      var el = angular.element("[name='" + $scope.vote_form.$name + "']").find('.ng-invalid:visible:first');
239      $timeout(function () { angular.element("[name='" + $scope.vote_form.$name + "']").find('.ng-invalid:visible:first').focus(); })
240      //				  if($scope.vote_form.email.$valid) $scope.captcha_not_used = true;				  
241    }
242  };
243
244  $scope.get_language = function (culture) {
245    ret = _.findWhere($scope.languages, { culture: culture });
246    if (ret == undefined) ret = { 'culture': 'en-US', 'lang': 'English' };
247    return ret.lang;
248  }
249
250  $scope.init_trees_votes = function (votes) {
251    $scope.trees_votes = votes;
252  }
253
254
255  /*$scope.get_votes = function(tree_id){
256
257    if(_.isEmpty($scope.trees_votes[treeid])) ret = 0;
258    else ret = $scope.trees_votes[treeid].votes;
259
260    return ret;		
261  }*/
262
263
264
265});

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.