Advertisement
Guest User

Untitled

a guest
Nov 21st, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function() {
  2.  
  3.   var VOTE_DELAY = 500; // wait 1/2 second between individual votes
  4.   var VOTE_YES_FOR = ['Julian Assange', 'Nigel Farage', 'Donald Trump', 'Marine Le Pen', 'Vladimir Putin'];
  5.  
  6.   function completePoll($scope, voteFor, completedCallback) {
  7.     if($scope.isFinished()) {
  8.       $scope.model.removeAnswers();
  9.       completedCallback();
  10.       return;
  11.     }
  12.  
  13.     if($scope.States.state.name === 'cover')
  14.       $scope.nextSlide();
  15.  
  16.     var slide = $scope.model.getCurrentSlide();
  17.     var candiate = getCandiateForSlide(slide);
  18.     var shouldVoteYes = _.some(voteFor, function(target) { return candiate.match(target) });
  19.     var answerOption =  slide.options[1 - shouldVoteYes | 0];
  20.  
  21.     console.log(candiate + ' -> ' + answerOption.value);
  22.  
  23.     $scope.vote(answerOption);
  24.     $scope.model.nextSlide();
  25.     $scope.$apply();
  26.  
  27.     setTimeout(function() { completePoll($scope, voteFor, completedCallback) }, VOTE_DELAY);
  28.  
  29.   }
  30.  
  31.   function getCandiateForSlide(slide) {
  32.     var titleHtml = slide.title.value;
  33.     return titleHtml.match(/">(.*?)</)[1].trim();    
  34.   }
  35.  
  36.   (function doRigging() {
  37.     completePoll(angular.element(document.body).scope().$$childHead, VOTE_YES_FOR, doRigging);
  38.   })();
  39.  
  40. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement