summaryrefslogtreecommitdiff
path: root/dash/js/dash.js
blob: 7fbceac1a254e7c6e1b00b73e3cce51d746c757a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
var xclicks = 0, a;
function jxbtn (e) {
  e.preventDefault();
  $(this).parents().filter('.job').hide(250);
  $.get('headless.php?clicks='+xclicks, function (data) {
    var $newjob = $($.parseHTML(data));
    window.a = $newjob;
    $newjob.find('.jobxbtn').click(jxbtn);
    $newjob.appendTo($('#content'));
  });
  xclicks++;
}
function axbtn (e) {
  e.preventDefault();
  if (window.confirm('Permanently remove this application?')) {
    $(this).parents().filter('.job').hide(250);
    $.get('headless.php?del='+$(this).attr('data-rid'), function (data) {
      if (data != 'OK') window.alert('The application could not be permanently deleted. It has been removed from view for your convenience.');
    });
  }
}
function acbtn (e) {
  e.preventDefault();
  if (window.confirm('Hire this candidate the job?')) {
    $(this).parents().filter('.job').hide(250);
    $.get('headless.php?hire='+$(this).attr('data-rid'), function (data) {
      if (data == 'OK') {
        window.alert('This application has been approved for hire. You can rate your experience with this candidate under the \'Rate\' tab.');
        window.location.href = '/dash/rate.php';
      } else {
        window.alert('We\'ve experienced an error trying to approve this application. Please try again another time.');
        window.location.href = '/dash/';
      }
    });
  }
}
function serveratings ($spaces) {
  $.each($spaces, function (idx, me) {
    var $me = $(me);
    var rating = parseFloat($me.attr('data-rating'));
    if (!rating && rating != 0) {
      $me.html('<img class="norating" src="img/unrated.png" alt="Not Yet Rated" />');
    } else {
      var html = '';
      for (var i = 1; i <= rating; i++) html += '<img class="star" src="img/star_given.png" alt="Full Star" />';
      if (rating-Math.floor(rating) >= 0.5) html += '<img class="star" src="img/star_half.png" alt="Half Star" />'
      i += Math.round(rating-Math.floor(rating));
      for (; i <= 5; i++) html += '<img class="star" src="img/star_empty.png" alt="No Star" />';
      $me.html(html);
    }
  });
}

$(function() {
  $('.jobxbtn').click(jxbtn);
  $('.appxbtn').click(axbtn);
  $('.appcbtn').click(acbtn);
  serveratings($('.ratingdata'));
});