%PDF- %PDF-
Direktori : /var/www/html/zgjedhjet2017/public/js/controller/ |
Current File : /var/www/html/zgjedhjet2017/public/js/controller/voteForElectionsAbIppmController.js |
'use strict'; var app = angular.module('frontendApp', ['ui.bootstrap'], function ($interpolateProvider) { $interpolateProvider.startSymbol('[['); $interpolateProvider.endSymbol(']]'); }); app.controller('voteForElectionsAbIppmController', function ($scope, $filter, $http, $rootScope) { //$rootScope.$on('$viewContentLoading', function (event, viewConfig) { $scope.currentStep = 1; $scope.startTime = ""; $scope.firtTimeSelected = true; $scope.vote = {}; $scope.qarqet = [ {"name": "Berat"}, {"name": "Dibër"}, {"name": "Durrës"}, {"name": "Elbasan"}, {"name": "Fier"}, {"name": "Gjirokastër"}, {"name": "Korçë"}, {"name": "Kukës"}, {"name": "Lezhë"}, {"name": "Shkodër"}, {"name": "Tiranë"}, {"name": "Vlorë"} ]; $scope.parties = [ {"name": "Lëvizja Socialiste për Integrim", "acronym": "LSI", "is_important": true}, {"name": "Partia Socialiste", "acronym": "PS", "is_important": true}, {"name": "Partia Kristian Demokrate", "acronym": "PDK", "is_important": false}, {"name": "Sfida Për Shqipërinë", "acronym": "SFIDA", "is_important": false}, {"name": "Partia Republikane Shqiptare", "acronym": "PR", "is_important": true}, {"name": "Partia Demokratike", "acronym": "PD", "is_important": true}, {"name": "Partia Bashkimi Demokristian Shqiptar", "acronym": "PBDKSH", "is_important": false}, {"name": "Partia Aleanca Demokristiane", "acronym": "ADK", "is_important": false}, {"name": "Partia Socialdemokrate", "acronym": "PSD", "is_important": false}, {"name": "Aleanca Demokratike", "acronym": "AD", "is_important": false}, {"name": "Partia Demokracia Sociale", "acronym": "PDS", "is_important": false}, {"name": "Partia për Drejtësi, Integrim dhe Unitet", "acronym": "PDIU", "is_important": true}, {"name": "Aleanca Arbnore Kombëtare", "acronym": "AAK", "is_important": false}, {"name": "Minoriteti Grek Për Të Ardhmen", "acronym": "MEGA", "is_important": false}, {"name": "Partia Komuniste e Shqipërisë", "acronym": "PKSH", "is_important": false}, {"name": "Aleanca Popullore Për Drejtësi", "acronym": "APD", "is_important": false}, {"name": "Lista Barabartë", "acronym": "Libra", "is_important": false}, ]; $scope.ushtrimiVotes = [ {value: "Gjithmonë", description: "Gjithmonë"}, {value: "Konsiderueshëm", description: "Konsiderueshëm"}, {value: "Pak herë", description: "Pak herë"}, {value: "Asnjëherë", description: "Asnjëherë"} ]; $scope.premtimet_dhe_programi = [ {value: "Luan rol të vogël", description: "Luan rol të vogël"}, {value: "Luan rol të konsiderueshëm", description: "Luan rol të konsiderueshëm"}, {value: "Luan rolin kryesor", description: "Luan rolin kryesor"} ]; $scope.permbushja_pritshmerive = [ {value: "I ka përmbushur në nivel të lartë", description: "I ka përmbushur në nivel të lartë"}, {value: "I ka përmbushur në nivel të mesëm", description: "I ka përmbushur në nivel të mesëm"}, {value: "I ka përmbushur në nivel të ulët", description: "I ka përmbushur në nivel të ulët"} ]; $scope.next = function () { $scope.currentStep = 2; }; $scope.previous = function () { $scope.currentStep = 1; }; $scope.isPreviousEnabled = function () { return $scope.currentStep !== 1; }; $scope.isNextEnabled = function () { if ($scope.currentStep === 2) { return false; } return $scope.vote.gjinia && $scope.vote.mosha && $scope.vote.qarku && $scope.vote.marr_pjese; }; $scope.updateParty = function (flag) { if (flag) { $scope.vote.tjeter = null; } else { $scope.vote.party = null; } }; $scope.willVote = function () { return $scope.vote.marr_pjese === 'true'; }; $scope.startTime = function () { $scope.vote.finishTime = moment().format('hh:mm:ss'); if ($scope.firtTimeSelected) { $scope.firtTimeSelected = false; $scope.vote.startTime = moment().format('hh:mm:ss'); } }; $scope.sentTime = function () { // document.getElementById("startTime").value = $scope.startClock; // document.getElementById("finishTime").value = moment().format('hh:mm:ss'); document.getElementById("votesForm").submit(); }; $scope.isValid = function () { $scope.hasPartySelected = $scope.vote.party; var isVotojNjellojRequired = $scope.vote.marr_pjese === 'false' ? true : $scope.vote.votoj_njelloj; var isPartyRequired = $scope.vote.marr_pjese === 'false' ? true : $scope.hasPartySelected; return $scope.vote.gjinia && $scope.vote.mosha && $scope.vote.qarku && $scope.vote.marr_pjese && isVotojNjellojRequired && $scope.vote.premtimet_dhe_programi && isPartyRequired && $scope.vote.permbushja_pritshmerive; }; function getUserIP (onNewIP) { var myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection; var pc = new myPeerConnection({ iceServers: [] }), noop = function () { }, localIPs = {}, ipRegex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g, key; function iterateIP (ip) { if (!localIPs[ip]) onNewIP(ip); localIPs[ip] = true; } //create a bogus data channel pc.createDataChannel(""); // create offer and set local description pc.createOffer(function (sdp) { sdp.sdp.split('\n').forEach(function (line) { if (line.indexOf('candidate') < 0) return; line.match(ipRegex).forEach(iterateIP); }); pc.setLocalDescription(sdp, noop, noop); }, noop); //listen for candidate events pc.onicecandidate = function (ice) { if (!ice || !ice.candidate || !ice.candidate.candidate || !ice.candidate.candidate.match(ipRegex)) return; ice.candidate.candidate.match(ipRegex).forEach(iterateIP); }; } if (bowser.safari){ $scope.vote.ipPrivate= '192.168.1.1'; } else{ getUserIP(function (ip) { setTimeout(function () { $scope.vote.ipPrivate = ip; }, 500); }); } $scope.vote.loadTime = moment().format('hh:mm:ss'); });