From a44a0e047a7582fe7e31743e1b03a17cf2987f73 Mon Sep 17 00:00:00 2001 From: Carson Fleming Date: Thu, 9 Mar 2017 00:28:02 -0500 Subject: Created the ability to post ads, rating framework --- dash/js/dash.js | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'dash/js') diff --git a/dash/js/dash.js b/dash/js/dash.js index d3c1a1a..7fbceac 100644 --- a/dash/js/dash.js +++ b/dash/js/dash.js @@ -12,10 +12,48 @@ function jxbtn (e) { } function axbtn (e) { e.preventDefault(); - $(this).parents().filter('.job').hide(250); + 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('Not Yet Rated'); + } else { + var html = ''; + for (var i = 1; i <= rating; i++) html += 'Full Star'; + if (rating-Math.floor(rating) >= 0.5) html += 'Half Star' + i += Math.round(rating-Math.floor(rating)); + for (; i <= 5; i++) html += 'No Star'; + $me.html(html); + } + }); } $(function() { $('.jobxbtn').click(jxbtn); $('.appxbtn').click(axbtn); + $('.appcbtn').click(acbtn); + serveratings($('.ratingdata')); }); -- cgit v1.2.3