It would be helpful if I could filter the featured questions based on newest, votes, and bounties.
1 Answer
Until this gets implemented, if at all, you can use the following Stack Snippet to filter on votes and bounty amount. The result is ordered by creation date.
(function () {
var api = {
url: 'https://api.stackexchange.com/2.2/',
endpoint: 'questions/featured',
params: {
site: 'stackoverflow',
pagesize: 100,
order: 'desc',
sort: 'creation',
Filter: '!5RCKNPLUeBH1JPtG(3gTdNpmM',
key: 'JBN9WXWxwrcnAj7WEEytmQ(('
}
},
sites = [],
siteIndex = -1;
function createUrl(ap) {
var ep = ap.url + ap.endpoint +'?',
nv = [];
$.each(ap.params, function (k,v) {
nv.push(k + '=' + v);
});
return ep + nv.join('&');
}
function enableLoad(func) {
$('#load').show();
$('#load').one('click', func);
}
function createVotesCell(item) {
return $('<td></td>').html(item.score);
}
function createBountyCell(item) {
return $('<td></td>').html(item.bounty_amount);
}
function createTitleCell(item) {
return $('<td></td>').append($('<a></a>')
.attr('href', item.link)
.attr('title', item.bounty_amount)
.html(item.title));
}
function createRow(item) {
return $('<tr></tr>').append(
createTitleCell(item),
createBountyCell(item),
createVotesCell(item)
);
}
// load a page of featured questions
function load(page, filter) {
api.params.page = page;
$.get(createUrl(api), function (data) {
var i,
list = $('#fav'),
item,
next;
for(i = 0; i < data.items.length; i = i +1) {
item = data.items[i];
if (item.score >= filter.score &&
item.bounty_amount >= filter.bounty) {
list.append(createRow(item));
}
}
if (data.has_more) {
next = function () { load(page + 1, filter); };
if (data.backoff !== undefined) {
window.setTimeout(
next,
data.items.backoff * 1000);
} else {
next();
}
}
});
}
$('#go').click(function() {
$('#fav').empty();
load(
1,
{
bounty: parseInt($('#bounty').val(),10),
score: parseInt($('#score').val(),10)
});
});
}());
#onhold div {
overflow:hidden;
text-overflow: ellipsis;
white-space:nowrap;
}
#load {
padding: 1em;
text-align: center;
cursor: pointer
}
img {
height: 1em;
}
table { border: black solid 1px; border-spacing: 0px; }
td { border: black solid 1px; margin:0px; padding:0px; border-spacing: 0px;}
tr { margin:0px; padding:0px; }
td::nth(2) {text-align:right}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="error" style="display:none">
</div>
<div>
<label>Bounty >= :<input type="text" value="50" id="bounty" /> </label>
<br/>
<label>Score >= :<input type="text" value="0" id="score" /> </label>
<br/>
<button id="go">Search</button>
</div>
<table>
<thead>
<tr>
<th>title</th>
<th>bounty</th>
<th>Score</th>
</tr>
</thead>
<tbody id="fav">
</tbody>
</table>