Skip to content

Instantly share code, notes, and snippets.

@emreerkan
Created June 30, 2020 01:15
Show Gist options
  • Select an option

  • Save emreerkan/17d7c8922bb34dca7eff975e918c53c3 to your computer and use it in GitHub Desktop.

Select an option

Save emreerkan/17d7c8922bb34dca7eff975e918c53c3 to your computer and use it in GitHub Desktop.
(function($) {
var female = female_percentage = male = male_percentage = 0, list = $('.col-md-6.col-sm-6 .panel-title a').map(function(i, item) { return item.href.replace('https://yokatlas.yok.gov.tr/lisans.php?y=', ''); });
$.when.apply($, list.map(function(i, item) {
var url = [ 'https://yokatlas.yok.gov.tr/content/lisans-dynamic/1010.php?y=', item ].join('');
return $.get(url, function(data) {
var $data = $(data);
female += parseInt('0'+$data.find('tbody tr:first td:eq(1)').text(), 10);
male += parseInt('0'+$data.find('tbody tr:last td:eq(1)').text(), 10);
}).promise();
}).get()).then(function() {
var total = female + male;
female_percentage = female * 100 / total;
male_percentage = male * 100 / total;
console.log('Kadın: ' + female + ' - %' + Math.round(female_percentage) + ` %c ${Array(Math.round(female_percentage)).join('█')}`, 'color: crimson');
console.log('Erkek: ' + male + ' - %' + Math.round(male_percentage) + ` %c ${Array(Math.round(male_percentage)).join('█')}`, 'color: navy');
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment