1investagramsAngularApp.controller('rankingsSnippetController', 2 function ($scope, $rootScope, stockTradingGroundsApiService) { 3 4 $scope.TFrame = { 5 Hourly: "ShortTerm", 6 Daily: "MediumTerm", 7 AllTime: "AllTime", 8 Custom: "Custom" 9 }; 10 11 $scope.IsLoading = false; 12 13 $scope.AuthenticatedUserId = gaAuthenticatedUserId; 14 15 16 $scope.RankingsList = { 17 ShortTerm: [], 18 ShortTermPage: 0, 19 ShortTermReachEnd: false, 20 MediumTerm: [], 21 MediumTermPage: 0, 22 MediumTermReachEnd: false, 23 AllTime: [], 24 AllTimePage: 0, 25 AllTimeReachEnd: false, 26 CustomRanking: [], 27 CustomRankingPage: 0, 28 CustomRankingReachEnd: false 29 }; 30 31 32 $scope.DisplayedList = { 33 List: [], 34 CurrentSelected: "MediumTerm", 35 ReachEnd: false, 36 MaxData: 20 37 }; 38 39 $scope.isCustomRankingView = true; 40 41 $scope.CustomTournament = { 42 StartDate: new Date(2022, 2, 31, 9, 0, 0), 43 EndDate: new Date(2022, 3, 7, 15, 0, 0), 44 45 46 tick: function () { 47 setTimeout(function () { 48 $scope.CustomTournament.countdown(); 49 }, 1000); 50 }, 51 52 countdown: function () { 53 54 var ds = $scope.CustomTournament; 55 56 var days, hours, minutes, seconds; 57 58 var endDate = new Date(); 59 endDate.setHours(23, 59, 59); 60 61 endDate = new Date(endDate).getTime(); 62 63 var startDate = new Date(); 64 startDate = startDate.getTime(); 65 66 var timeRemaining = parseInt((endDate - startDate) / 1000); 67 68 if (timeRemaining >= 0) { 69 days = parseInt(timeRemaining / 86400); 70 timeRemaining = (timeRemaining % 86400); 71 72 hours = parseInt(timeRemaining / 3600); 73 timeRemaining = (timeRemaining % 3600); 74 75 minutes = parseInt(timeRemaining / 60); 76 timeRemaining = (timeRemaining % 60); 77 78 seconds = parseInt(timeRemaining); 79 80 ds.Days = parseInt(days, 10); 81 ds.Hours = ("0" + hours).slice(-2); 82 ds.Minutes = ("0" + minutes).slice(-2); 83 ds.Seconds = ("0" + seconds).slice(-2); 84 85 $scope.$digest(); 86 87 ds.tick(); 88 89 } else { 90 return; 91 } 92 }, 93 94 init: function () { 95 if ($scope.isDailyBlitzActive()) { 96 $scope.DisplayedList.CurrentSelected = $scope.TFrame.Custom; 97 $scope.CustomTournament.DisplayITG = true; 98 $scope.CustomTournament.IsActive = true; 99 $scope.getInitialValues(); 100 $scope.CustomTournament.tick(); 101 } 102 } 103 }; 104 105 $scope.setCustomRankingView = function (display) { 106 107 $scope.isCustomRankingView = display; 108 if (display) { 109 $scope.selectTimeframe($scope.TFrame.Custom); 110 } 111 else { 112 $scope.selectTimeframe($scope.DisplayedList.PreviousSelected); 113 } 114 }; 115 116 117 118 $scope.selectTimeframe = function (timeframe) { 119 120 if (timeframe == $scope.TFrame.Custom) 121 $scope.DisplayedList.PreviousSelected = $scope.DisplayedList.CurrentSelected; 122 else 123 $scope.DisplayedList.PreviousSelected = timeframe; 124 125 $scope.DisplayedList.CurrentSelected = timeframe; 126 127 $scope.DisplayedList.List = []; 128 $scope.DisplayedList.ReachEnd = true; 129 130 switch ($scope.DisplayedList.CurrentSelected) { 131 case $scope.TFrame.Hourly: 132 if ($scope.RankingsList.ShortTerm.length == 0) { 133 $scope.getMoreData(); 134 } 135 else { 136 $scope.DisplayedList.List = $scope.RankingsList.ShortTerm; 137 $scope.DisplayedList.ReachEnd = $scope.RankingsList.ShortTermReachEnd; 138 } 139 break; 140 141 case $scope.TFrame.Daily: 142 if ($scope.RankingsList.MediumTerm.length == 0) { 143 $scope.getMoreData(); 144 } 145 else { 146 $scope.DisplayedList.List = $scope.RankingsList.MediumTerm; 147 $scope.DisplayedList.ReachEnd = $scope.RankingsList.MediumTermReachEnd; 148 } 149 break; 150 151 case $scope.TFrame.AllTime: 152 if ($scope.RankingsList.AllTime.length == 0) { 153 $scope.getMoreData(); 154 } 155 else { 156 $scope.DisplayedList.List = $scope.RankingsList.AllTime; 157 $scope.DisplayedList.ReachEnd = $scope.RankingsList.AllTimeReachEnd; 158 } 159 break; 160 case $scope.TFrame.Custom: 161 if ($scope.RankingsList.CustomRanking.length == 0) { 162 $scope.getMoreData(); 163 } 164 else { 165 $scope.DisplayedList.List = $scope.RankingsList.CustomRanking; 166 $scope.DisplayedList.ReachEnd = $scope.RankingsList.CustomRankingReachEnd; 167 } 168 break; 169 }; 170 171 if ($scope.PopOver) { 172 $scope.PopOver.closeAll(); 173 $scope.PopOver.activateAll(); 174 } 175 }; 176 177 178 179 180 $scope.getMoreData = function () { 181 switch ($scope.DisplayedList.CurrentSelected) { 182 case $scope.TFrame.Hourly: 183 $scope.getRankingsShortTerm(); 184 break; 185 186 case $scope.TFrame.Daily: 187 $scope.getRankingsMediumTerm(); 188 break; 189 190 case $scope.TFrame.AllTime: 191 $scope.getRankingsAllTime(); 192 break; 193 case $scope.TFrame.Custom: 194 $scope.getRankingsCustom(); 195 break; 196 }; 197 }; 198 199 200 $scope.getRankingsShortTerm = function () { 201 202 if (!$scope.IsLoading && !$scope.RankingsList.ShortTermReachEnd) { 203 $scope.IsLoading = true; 204 205 showHeaderLoader(); 206 207 stockTradingGroundsApiService.getRankingsShortTerm($scope.RankingsList.ShortTermPage).then(function (result) { 208 209 210 if (result.data != null && result.data.length > 0) { 211 212 $scope.RankingsList.ShortTerm = $scope.RankingsList.ShortTerm.concat(result.data); 213 214 $scope.RankingsList.ShortTermPage++; 215 216 $scope.RankingsList.ShortTermReachEnd = $scope.RankingsList.ShortTerm.length >= $scope.DisplayedList.MaxData; 217 218 $scope.DisplayedList.List = $scope.RankingsList.ShortTerm; 219 220 } 221 else { 222 $scope.RankingsList.ShortTermReachEnd = true; 223 } 224 225 $scope.DisplayedList.ReachEnd = $scope.RankingsList.ShortTermReachEnd; 226 227 228 $scope.IsLoading = false; 229 hideHeaderLoader(); 230 231 232 }, 233 function (error) { 234 $scope.IsLoading = false; 235 hideHeaderLoader(); 236 showErrorResponse(error); 237 }); 238 239 } 240 241 }; 242 243 244 245 246 247 $scope.getRankingsMediumTerm = function () { 248 249 if (!$scope.IsLoading && !$scope.RankingsList.MediumTermReachEnd) { 250 $scope.IsLoading = true; 251 252 showHeaderLoader(); 253 254 stockTradingGroundsApiService.getRankingsMediumTerm($scope.RankingsList.MediumTermPage).then(function (result) { 255 256 257 if (result.data != null && result.data.length > 0) { 258 259 $scope.RankingsList.MediumTerm = $scope.RankingsList.MediumTerm.concat(result.data); 260 261 $scope.RankingsList.MediumTermPage++; 262 263 $scope.RankingsList.MediumTermReachEnd = $scope.RankingsList.MediumTerm.length >= $scope.DisplayedList.MaxData; 264 265 $scope.DisplayedList.List = $scope.RankingsList.MediumTerm; 266 267 } 268 else { 269 $scope.RankingsList.MediumTermReachEnd = true; 270 } 271 272 $scope.DisplayedList.ReachEnd = $scope.RankingsList.MediumTermReachEnd; 273 274 275 $scope.IsLoading = false; 276 hideHeaderLoader(); 277 278 279 }, 280 function (error) { 281 $scope.IsLoading = false; 282 hideHeaderLoader(); 283 showErrorResponse(error); 284 }); 285 286 } 287 288 }; 289 290 291 292 $scope.getRankingsAllTime = function () { 293 294 if (!$scope.IsLoading && !$scope.RankingsList.AllTimeReachEnd) { 295 $scope.IsLoading = true; 296 297 showHeaderLoader(); 298 299 stockTradingGroundsApiService.getRankingsAllTime($scope.RankingsList.AllTimePage).then(function (result) { 300 301 302 if (result.data != null && result.data.length > 0) { 303 304 $scope.RankingsList.AllTime = $scope.RankingsList.AllTime.concat(result.data); 305 306 $scope.RankingsList.AllTimePage++; 307 308 $scope.RankingsList.AllTimeReachEnd = $scope.RankingsList.AllTime.length >= $scope.DisplayedList.MaxData; 309 310 $scope.DisplayedList.List = $scope.RankingsList.AllTime; 311 312 } 313 else { 314 $scope.RankingsList.AllTimeReachEnd = true; 315 } 316 317 $scope.DisplayedList.ReachEnd = $scope.RankingsList.AllTimeReachEnd; 318 319 320 $scope.IsLoading = false; 321 hideHeaderLoader(); 322 323 324 }, 325 function (error) { 326 $scope.IsLoading = false; 327 hideHeaderLoader(); 328 showErrorResponse(error); 329 }); 330 331 } 332 333 }; 334 335 $scope.getRankingsCustom = function () { 336 if (!$scope.IsLoading && !$scope.RankingsList.CustomRankingReachEnd) { 337 $scope.IsLoading = true; 338 339 showHeaderLoader(); 340 341 stockTradingGroundsApiService.getRankingsCustom($scope.RankingsList.CustomRankingPage).then(function (result) { 342 343 344 if (result.data != null && result.data.length > 0) { 345 346 $scope.RankingsList.CustomRanking = $scope.RankingsList.CustomRanking.concat(result.data); 347 348 $scope.RankingsList.CustomRankingPage++; 349 350 $scope.RankingsList.CustomRankingReachEnd = $scope.RankingsList.CustomRanking.length >= $scope.DisplayedList.MaxData; 351 352 $scope.DisplayedList.List = $scope.RankingsList.CustomRanking; 353 354 } 355 else { 356 $scope.RankingsList.CustomRankingReachEnd = true; 357 } 358 359 $scope.DisplayedList.ReachEnd = $scope.RankingsList.CustomRankingReachEnd; 360 361 362 $scope.IsLoading = false; 363 hideHeaderLoader(); 364 365 366 }, 367 function (error) { 368 $scope.IsLoading = false; 369 hideHeaderLoader(); 370 showErrorResponse(error); 371 }); 372 373 } 374 375 }; 376 377 var tournamentDates = [ 378 //new Date(2022, 4, 4), 379 //new Date(2022, 4, 5), 380 //new Date(2022, 4, 6), 381 //new Date(2022, 4, 9), 382 new Date(2022, 4, 10), 383 new Date(2022, 4, 11), 384 new Date(2022, 4, 12), 385 new Date(2022, 4, 13), 386 new Date(2022, 4, 14) 387 ]; 388 389 var globalCurrentDate = new Date(); 390 globalCurrentDate = new Date(globalCurrentDate.getFullYear(), globalCurrentDate.getMonth(), globalCurrentDate.getDate()); 391 392 $scope.isDailyBlitzActive = function () { 393 for (var x = 0; x < tournamentDates.length; x++) { 394 if (tournamentDates[x].getTime() == globalCurrentDate.getTime()) 395 return true; 396 } 397 398 return false; 399 }; 400 401 402 $scope.getInitialValues = function () { 403 if ($scope.isDailyBlitzActive()) { 404 $scope.selectTimeframe($scope.TFrame.Custom); 405 } 406 else { 407 $scope.selectTimeframe($scope.DisplayedList.CurrentSelected); 408 } 409 410 }; 411 } 412);
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.