Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: sitescripts/filterhits/static/query.js

Issue 4615801646612480: Issue 395 - Filter hits statistics backend (Closed)
Patch Set: Addressed further comments from Wladimir. Created March 27, 2015, 10:12 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sitescripts/filterhits/static/query.js
diff --git a/sitescripts/filterhits/static/query.js b/sitescripts/filterhits/static/query.js
new file mode 100644
index 0000000000000000000000000000000000000000..0554e4cc2d4d3170ab3b65007d758226d2f53284
--- /dev/null
+++ b/sitescripts/filterhits/static/query.js
@@ -0,0 +1,39 @@
+(function () {
+ var table = $("#results").dataTable({
+ serverSide: true,
+ bFilter: false,
+ "columns": [
+ { data: "filter" },
+ { data: "domain" },
+ { data: "frequency" }
+ ],
+ order: [[2, "desc"]],
+ fnServerData: function (source, data, callback, settings) {
+ var sort = settings.aaSorting[0];
+ $.ajax({
+ dataType: "json",
+ type: "GET",
+ url: "/query",
+ data: {
+ echo: settings.iDraw,
+ skip: settings._iDisplayStart,
+ take: settings._iDisplayLength,
+ filter: $('#filter').val(),
+ domain: $('#domain').val(),
+ order: sort[1],
+ order_by: ["filter", "domain", "frequency"][sort[0]]
+ },
+ success: function(data, status, jqxhr) {
+ callback({
+ draw: data.echo,
+ recordsTotal: data.total,
+ recordsFiltered: data.total,
+ data: data.results
+ }, status, jqxhr);
+ }
+ });
+ }
+ });
+
+ $('#filter, #domain').on('input', function () { table.fnDraw(); });
Wladimir Palant 2015/03/28 12:59:19 Style nit: Double quotation marks in JavaScript pl
kzar 2015/03/28 14:11:56 Done.
+}());

Powered by Google App Engine
This is Rietveld