Miha Stajdohar avatar Miha Stajdohar committed 86f1d53

Added Disqus identifier.

Comments (0)

Files changed (1)

benchmarks/static/benchmarks/js/controllers.js

 function BenchmarksCtrl($scope, $filter, $routeParams, ngTableParams, Benchmark, Bookmark) {
     var bookmarkId = $routeParams.bookmarkId,
         field_names = {},
+        all_fields = {},
         orderedData,
         data;
 
         $scope.checkboxes = { 'checked': false, items: {}, 'num_checked': 0 };
     }
 
-    set_defaults();
+    function set_attributes() {
+        $scope.attributes_x = [
+            {label: 'Date', attribute: 'date'},
+            {label: 'Title', attribute: 'title'}
+        ];
+
+        $scope.attributes_y = [
+            {label: 'TPS', attribute: 'tps_excluding'},
+            {label: 'TPS (including connection establishing)', attribute: 'tps_including'},
+            {label: 'Transactions per client', attribute: 'transactions_per_client'},
+            {label: 'Transactions processed', attribute: 'transactions_processed'},
+            {label: 'Threads', attribute: 'threads'},
+            {label: 'Clients', attribute: 'clients'},
+            {label: 'Scaling factor', attribute: 'scaling_factor'}
+        ];
+
+        // add special fields to analysis combo boxes
+        for (var key in field_names) {
+            if (field_names[key] === 'STR') {
+                $scope.attributes_x.push({label: key, attribute: key});
+            } else if (field_names[key] === 'NUM') {
+                $scope.attributes_y.push({label: key, attribute: key});
+            }
+        }
+    }
 
-    $scope.attributes_x = [
-        {label: 'Date', attribute: 'date'},
-        {label: 'Title', attribute: 'title'}
-    ];
-
-    $scope.attributes_y = [
-        {label: 'TPS', attribute: 'tps_excluding'},
-        {label: 'TPS (including connection establishing)', attribute: 'tps_including'},
-        {label: 'Transactions per client', attribute: 'transactions_per_client'},
-        {label: 'Transactions processed', attribute: 'transactions_processed'},
-        {label: 'Threads', attribute: 'threads'},
-        {label: 'Clients', attribute: 'clients'},
-        {label: 'Scaling factor', attribute: 'scaling_factor'}
-    ];
+    set_defaults();
+    set_attributes();
 
     $scope.bookmark = {
         title: "",
                 data.objects[i].field_set = {};
 
                 for (var j = 0, l2 = data.objects[i].fields.length; j < l2; j++) {
-                    if (!(data.objects[i].fields[j].name in field_names)) {
-                        field_names[data.objects[i].fields[j].name] = data.objects[i].fields[j].type;
+                    if (!(data.objects[i].fields[j].name in all_fields)) {
+                        all_fields[data.objects[i].fields[j].name] = data.objects[i].fields[j].type;
                     }
                     data.objects[i].field_set[data.objects[i].fields[j].name] = data.objects[i].fields[j];
                 }
             }
-            // add special fields to analysis combo boxes
-            for (var key in field_names) {
-                if (field_names[key] === 'STR') {
-                    $scope.attributes_x.push({label: key, attribute: key});
-                } else if (field_names[key] === 'NUM') {
-                    $scope.attributes_y.push({label: key, attribute: key});
-                }
-            }
+
+            set_attributes();
+
             // watch for changes in table properties (sort, page...)
             $scope.$watch('tableBenchmarks', function (params) {
                 orderedData = params.sorting ?
             $scope.$watch('checkboxes.items', function (values) {
                 var checked = 0, unchecked = 0,
                     total = orderedData.length;
+
+                field_names = {};
+
                 for (var i = 0, l = orderedData.length; i < l; i++) {
                     checked += ($scope.checkboxes.items[orderedData[i].id]) || 0;
                     unchecked += (!$scope.checkboxes.items[orderedData[i].id]) || 0;
+                    /* DOES NOT WORK YET!
+                    if ($scope.checkboxes.items[orderedData[i].id]) {
+                        for (var j = 0, l2 = orderedData[i].fields.length; j < l2; j++) {
+                            if (!(orderedData[i].fields[j].name in field_names)) {
+                                field_names[orderedData[i].fields[j].name] = orderedData[i].fields[j].type;
+                            }
+                        }
+                    }
+                    */
                 }
                 if ((unchecked == 0) || (checked == 0)) {
                     $scope.checkboxes.checked = (checked == total);
                 }
+                if (true) {
+                    field_names = all_fields;
+                }
                 $scope.checkboxes.num_checked = checked;
+                set_attributes();
                 // grayed checkbox
                 $("#select_all").prop("indeterminate", (checked != 0 && unchecked != 0));
                 plot_benchmarks();
     if (bookmarkId !== undefined) {
         setTimeout(function () {
             var disqus_shortname = 'benguru';
+            var disqus_identifier = bookmarkId;
+
             (function () {
                 var dsq = document.createElement('script');
                 dsq.type = 'text/javascript';
                 dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
                 (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
             })();
-        }, 2000);
+        }, 1000);
     }
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.