"use strict";
// Get data from the post.
$.ajax({
'url': 'https://api.stackexchange.com/2.2/answers/295218?order=desc&sort=activity&site=meta.stackoverflow&filter=!SWJ_BpAceOT6L*G2Qa',
'type': 'GET',
'jsonpCallback': 'processReply',
'dataType': 'jsonp'
});
// Process reply.
function processReply(replyData)
{
// Write log for reply data.
if(window && window.console && window.console.log)
{
window.console.log(replyData);
}
// Get HTML of the post.
var htmlString = replyData['items'][0]['body'];
// Define tag info dictionary.
var tagInfoDict = {
// Data comes from revision 144 of the other post.
// https://meta.stackoverflow.com/revisions/295218/144
'gnu': {'closedCount': 115, 'openCount': 1231},
// Data comes from revision 140 of the other post.
// https://meta.stackoverflow.com/revisions/295218/140
'licensing': {'closedCount': 2426, 'openCount': 303},
// Data comes from revision 115 of the other post.
// https://meta.stackoverflow.com/revisions/295218/115
'agpl': {'closedCount': 59, 'openCount': 0},
'apache-license': {'closedCount': 141, 'openCount': 0},
'artistic-license': {'closedCount': 3, 'openCount': 0},
'bsd-license': {'closedCount': 88, 'openCount': 0},
'closed-source': {'closedCount': 68, 'openCount': 0},
'commercial': {'closedCount': 155, 'openCount': 0},
'copyleft': {'closedCount': 18, 'openCount': 0},
'copyright': {'closedCount': 88, 'openCount': 0},
'cpl': {'closedCount': 5, 'openCount': 0},
'creative-commons': {'closedCount': 58, 'openCount': 0},
'disclaimer': {'closedCount': 14, 'openCount': 0},
'eula': {'closedCount': 32, 'openCount': 31},
'gpl': {'closedCount': 824, 'openCount': 0},
'gplv3': {'closedCount': 88, 'openCount': 0},
'intellectual-property': {'closedCount': 64, 'openCount': 0},
'legal': {'closedCount': 429, 'openCount': 0},
'lgpl': {'closedCount': 286, 'openCount': 0},
'mit-license': {'closedCount': 152, 'openCount': 0},
'mpl': {'closedCount': 21, 'openCount': 0},
'mspl': {'closedCount': 18, 'openCount': 0},
'non-gpl': {'closedCount': 10, 'openCount': 0},
'patents': {'closedCount': 37, 'openCount': 0},
'terms-of-use': {'closedCount': 91, 'openCount': 0},
'trademark': {'closedCount': 17, 'openCount': 0},
'truelicense': {'closedCount': 2, 'openCount': 3},
// Data come from search results at 2015-06-17 01:27:00Z
// http://stackoverflow.com/search?q=closed%3Ayes+%5Bproprietary%5D
// http://stackoverflow.com/search?q=closed%3Ano+%5Bproprietary%5D
// http://stackoverflow.com/search?q=closed%3Ayes+%5Bproprietary-software%5D
// http://stackoverflow.com/search?q=closed%3Ano+%5Bproprietary-software%5D
'proprietary': {'closedCount': 19, 'openCount': 0},
'proprietary-software': {'closedCount': 25, 'openCount': 0},
// Late addition [foss]
'foss': {'closedCount': 52, 'openCount': 0},
// Last tag done
'open-source': {'closedCount': 3291, 'openCount': 607},
};
// For each list item...
$('<div/>')
.append(htmlString)
.children('ul')
.children('li')
.each(function()
{
var listItem = $(this);
var links = listItem.find('a');
if(links.length < 3)
{
return; // Should have at least 3 links.
}
// Get info for tag.
var tagName = links.eq(0).text();
var closedCount = parseInt(links.eq(1).text(), 10);
var openCount = parseInt(links.eq(2).text(), 10);
if(isNaN(closedCount))
{
return;
}
if(isNaN(openCount))
{
return;
}
// Update dictionary.
var tagInfo = {
'closedCount': closedCount,
'openCount': openCount,
'isInProgress': true
};
tagInfoDict[tagName] = tagInfo;
})
;
// Write log for tag info dictionary.
if(window && window.console && window.console.log)
{
window.console.log(tagInfoDict);
}
// Get summary.
var totalClosedCount = 0;
var totalOpenInProgressCount = 0;
var totalOpenDoneCount = 0;
var tagCount = 0;
for(var key in tagInfoDict)
{
if(!tagInfoDict.hasOwnProperty(key))
{
continue;
}
var tagInfo = tagInfoDict[key];
totalClosedCount += tagInfo['closedCount'];
if(tagInfo.hasOwnProperty('isInProgress'))
{
totalOpenInProgressCount += tagInfo['openCount'];
}
else
{
totalOpenDoneCount += tagInfo['openCount'];
}
tagCount++;
}
var totalCount = totalClosedCount + totalOpenInProgressCount + totalOpenDoneCount;
// Calculate dates.
var startDate = new Date('2015-05-24T01:31:03Z');
var currentDate = new Date();
var timeElapsed = currentDate.getTime() - startDate.getTime(); // In milliseconds.
var timeRemaining = ((totalClosedCount + totalOpenDoneCount) > 0 ? timeElapsed / (totalClosedCount + totalOpenDoneCount) * totalOpenInProgressCount : 0); // In milliseconds.
var endDate = new Date(currentDate.getTime() + timeRemaining);
// Update UI.
$('.total_count').text(totalCount);
$('.closed_percent').text(formatPercent(totalClosedCount / totalCount));
$('.closed_count').text(totalClosedCount);
$('.open_done_percent').text(formatPercent(totalOpenDoneCount / totalCount));
$('.open_done_count').text(totalOpenDoneCount);
$('.open_in_progress_percent').text(formatPercent(totalOpenInProgressCount / totalCount));
$('.open_in_progress_count').text(totalOpenInProgressCount);
$('.start_date').text(formatDate(startDate));
$('.current_date').text(formatDate(currentDate));
$('.end_date').text(formatDate(endDate));
$('.tag_count').text(tagCount);
$('.progress_percent').text(formatPercent((totalClosedCount + totalOpenDoneCount) / totalCount));
$('.progress_bar').css('width', formatPercent((totalClosedCount + totalOpenDoneCount) / totalCount));
}
function formatPercent(inputValue)
{
return (inputValue * 100.0).toFixed(1) + '%';
}
function formatDate(inputDate)
{
return inputDate.toString();
}
.result_box
{
font-size:150%;
}
.progress_bar_background
{
background-color:#000;
position:relative;
left:0px;
top:0px;
height:10px;
border-radius:5px;
}
.progress_bar
{
background-color:#0f0;
position:absolute;
left:0px;
top:0px;
height:100%;
border-radius:5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<br><br>
<div class='result_box'>Completed: <span class='progress_percent'>Loading...</span></div>
<div class='progress_bar_background'><span class='progress_bar'></span></div>
<br>
<div>Closed: <span class='closed_count'></span> (<span class='closed_percent'></span>)</div>
<div>Open (Done): <span class='open_done_count'></span> (<span class='open_done_percent'></span>)</div>
<div>Open (In Progress): <span class='open_in_progress_count'></span> (<span class='open_in_progress_percent'></span>)</div>
<div>Total: <span class='total_count'></span></div>
<br>
<div>Started: <span class='start_date'></span></div>
<div>Current: <span class='current_date'></span></div>
<div>End: <span class='end_date'></span> <i>(estimated)</i></div>
<br>
<div>Number of tags: <span class='tag_count'></span></div>
truelicensing
is bad per sé. It appears to be a licensing management API, and API usage itself is generally on-topic. Still, might want to check if those questions are about the API use, or are about the licensing decisions