Skip to content

Commit

Permalink
Also fixed clicking on users in channel activity page, and improved h…
Browse files Browse the repository at this point in the history
…andling of datatables arrays
  • Loading branch information
Hal9000 committed Apr 9, 2012
1 parent c6a8df8 commit 901152c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
7 changes: 3 additions & 4 deletions lib/magirc/Magirc.class.php
Expand Up @@ -121,13 +121,12 @@ function checkPermission($type, $target) {
* (Used by the RESTful API)
* @param mixed $data Data
* @param boolean $datatables allow/forbid DataTables format
* @param string $idcolumn Column name to use as index for the DataTables automatic row id
* @param string $idcolumn Column name to use as index for the DataTables automatic row id. If not specified, the first column will be used.
*/
function jsonOutput($data, $datatables = false, $idcolumn = null) {
if ($datatables && @$_GET['format'] == "datatables") {
if ($idcolumn) {
foreach ($data as $key => $val) $data[$key]["DT_RowId"] = $val[$idcolumn];
}
if (!$idcolumn && count($data) > 0) $idcolumn = key($data[0]);
foreach ($data as $key => $val) $data[$key]["DT_RowId"] = $val[$idcolumn];
echo json_encode(array('aaData' => $data));
} else {
echo json_encode($data);
Expand Down
4 changes: 2 additions & 2 deletions rest/denora.php
Expand Up @@ -47,10 +47,10 @@
$magirc->jsonOutput($magirc->denora->getHourlyStats('channelstats'));
});
$magirc->slim->get('/channels/biggest(/:limit)', function($limit = 10) use($magirc) {
$magirc->jsonOutput($magirc->denora->getChannelBiggest((int) $limit), true);
$magirc->jsonOutput($magirc->denora->getChannelBiggest((int) $limit), true, 'channel');
});
$magirc->slim->get('/channels/top(/:limit)', function($limit = 10) use($magirc) {
$magirc->jsonOutput($magirc->denora->getChannelTop((int) $limit), true);
$magirc->jsonOutput($magirc->denora->getChannelTop((int) $limit), true, 'chan');
});
$magirc->slim->get('/channels/activity/:type', function($type) use($magirc) {
$magirc->jsonOutput($magirc->denora->getChannelGlobalActivity($type, @$_GET['format'] == 'datatables'));
Expand Down
3 changes: 1 addition & 2 deletions theme/default/tpl/channel_activity.tpl
Expand Up @@ -58,8 +58,7 @@ $(document).ready(function() {
]
});
$("#tbl_activity tbody tr").live("click", function(event) {
var name = $(event.target.parentNode)[0].cells[0].innerHTML;
window.location = url_base + 'user/nick:' + encodeURIComponent(name) + '/profile#activity';
window.location = url_base + 'user/stats:' + encodeURIComponent(this.id) + '/profile#activity';
});
$("#radio").buttonset();
$("#radio").change(function(event) {
Expand Down
6 changes: 2 additions & 4 deletions theme/default/tpl/network_status.tpl
Expand Up @@ -197,8 +197,7 @@ $(function() {
]
});
$("#tbl_biggestchans tbody tr").live("click", function(event) {
var chan = $(event.target.parentNode)[0].cells[0].innerHTML;
window.location = url_base + 'channel/' + encodeURIComponent(chan) + '/profile';
window.location = url_base + 'channel/' + encodeURIComponent(this.id) + '/profile';
});
oTable2 = $("#tbl_top10chans").dataTable({
"sAjaxSource": "rest/denora.php/channels/top/10?format=datatables",
Expand All @@ -208,8 +207,7 @@ $(function() {
]
});
$("#tbl_top10chans tbody tr").live("click", function(event) {
var chan = $(event.target.parentNode)[0].cells[0].innerHTML;
window.location = url_base + 'channel/' + encodeURIComponent(chan) + '/profile#activity';
window.location = url_base + 'channel/' + encodeURIComponent(this.id) + '/profile#activity';
});
oTable3 = $("#tbl_top10users").dataTable({
"sAjaxSource": "rest/denora.php/users/top/10?format=datatables",
Expand Down

0 comments on commit 901152c

Please sign in to comment.