From 01350e0060412e0cb9720c2bed1d3fd0bfb91605 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Thu, 12 Mar 2009 19:04:04 +0000 Subject: [PATCH] add a custom sorter for the address column --- deluge/ui/web/js/deluge-details.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/deluge/ui/web/js/deluge-details.js b/deluge/ui/web/js/deluge-details.js index 11bdf6978..7797eadec 100644 --- a/deluge/ui/web/js/deluge-details.js +++ b/deluge/ui/web/js/deluge-details.js @@ -244,10 +244,22 @@ function peer_progress(value) { return String.format(tpl, progress, '', progress); } +function sort_address(value) { + var m = value.match(/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\:(\d+)/); + var address = 0; + var parts = [m[1], m[2], m[3], m[4]]; + $each(parts, function(part, index) { + part = parseInt(part); + address = address | part << ((3 - index) * 8); + alert("Total: " + address + "\nPart: " + part + "\nIndex: " + index + "\nCalc: " + (part << ((3 - index) * 8))); + }); + return address; +} + Deluge.Details.Peers.Store = new Ext.data.SimpleStore({ fields: [ {name: 'country'}, - {name: 'address'}, + {name: 'address', sortType: sort_address}, {name: 'client'}, {name: 'progress', type: 'float'}, {name: 'downspeed', type: 'int'},