[PATCH] D13134: [analyzer] Add keyboard shortcuts to report.html

2015-09-24 Thread Karl Skomski via cfe-commits
skomski created this revision.
skomski added reviewers: dcoughlin, krememek, jordan_rose.
skomski added a subscriber: cfe-commits.
skomski set the repository for this revision to rL LLVM.

Adds three keyboard shortcuts to report.html
to make navigation faster:

Jump to next path: j
Jump to previous path: k
Show Help: ?

Repository:
  rL LLVM

http://reviews.llvm.org/D13134

Files:
  lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  tools/scan-build/keyboard-shortcuts.js
  tools/scan-build/scan-build

Index: tools/scan-build/scan-build
===
--- tools/scan-build/scan-build
+++ tools/scan-build/scan-build
@@ -459,28 +459,20 @@
 ####
 
 sub CopyFiles {
-
   my $Dir = shift;
+  my @Files = ("sorttable.js", "keyboard-shortcuts.js", "scanview.css");
 
-  my $JS = Cwd::realpath("$RealBin/sorttable.js");
-
-  DieDiag("Cannot find 'sorttable.js'.\n")
-if (! -r $JS);
-
-  copy($JS, "$Dir");
+  foreach my $FileName (@Files) {
+my $File = Cwd::realpath("$RealBin/$FileName");
 
-  DieDiag("Could not copy 'sorttable.js' to '$Dir'.\n")
-if (! -r "$Dir/sorttable.js");
+DieDiag("Cannot find '$FileName'.\n")
+  if (! -r $File);
 
-  my $CSS = Cwd::realpath("$RealBin/scanview.css");
+copy($File, "$Dir");
 
-  DieDiag("Cannot find 'scanview.css'.\n")
-if (! -r $CSS);
-
-  copy($CSS, "$Dir");
-
-  DieDiag("Could not copy 'scanview.css' to '$Dir'.\n")
-if (! -r $CSS);
+DieDiag("Could not copy '$FileName' to '$Dir'.\n")
+  if (! -r "$Dir/$FileName");
+  }
 }
 
 ####
Index: tools/scan-build/keyboard-shortcuts.js
===
--- /dev/null
+++ tools/scan-build/keyboard-shortcuts.js
@@ -0,0 +1,41 @@
+(function () {
+
+function Jump(matchTarget, lastBlock) {
+  var match = document.location.hash.match(/Path\d+|EndPath/)[0];
+  var matches = document.querySelectorAll('#' + match + ' .PathNav')
+  if (matches.length == 2) {
+document.location = matches[matchTarget].children[0].href;
+  } else {
+if (!document.location.hash.includes(lastBlock)) {
+  document.location = matches[0].children[0].href;
+}
+  }
+};
+
+function ShowHelp() {
+  alert("Keyboard shortcuts:\n\n" +
+"Jump to next path: j\n"  +
+"Jump to previous path: k\n");
+}
+
+const KEYS = {
+  J: 74,
+  K: 75,
+  SLASH: 191
+}
+
+document.onkeydown = function (e) {
+  switch(e.keyCode) {
+case KEYS.J:
+  Jump(1, '#EndPath');
+  break;
+case KEYS.K:
+  Jump(0, '#Path1');
+  break;
+case KEYS.SLASH:
+  ShowHelp();
+  break;
+  }
+};
+
+}());
Index: lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -263,6 +263,13 @@
 R.InsertTextBefore(SMgr.getLocForStartOfFile(FID), os.str());
   }
 
+  {
+std::string s;
+llvm::raw_string_ostream os(s);
+os << "";
+R.InsertTextBefore(SMgr.getLocForStartOfFile(FID), os.str());
+  }
+
   // Add CSS, header, and footer.
 
   html::AddHeaderFooterInternalBuiltinCSS(R, FID, Entry->getName());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13134: [analyzer] Add keyboard shortcuts to report.html

2015-10-05 Thread Karl Skomski via cfe-commits
skomski removed rL LLVM as the repository for this revision.
skomski updated this revision to Diff 36490.
skomski added a comment.

Included mousetrap to get keyboard shortcuts working on all international 
keyboards.
Fixed behaviour without hash path present: Jump to #Path1 on j or k


http://reviews.llvm.org/D13134

Files:
  tools/scan-build/keyboard-shortcuts.js

Index: tools/scan-build/keyboard-shortcuts.js
===
--- tools/scan-build/keyboard-shortcuts.js
+++ tools/scan-build/keyboard-shortcuts.js
@@ -1,8 +1,26 @@
+/* mousetrap v1.5.3 craig.is/killing/mice */
+(function(C,r,g){function 
t(a,b,h){a.addEventListener?a.addEventListener(b,h,!1):a.attachEvent("on"+b,h)}function
 x(a){if("keypress"==a.type){var 
b=String.fromCharCode(a.which);a.shiftKey||(b=b.toLowerCase());return b}return 
l[a.which]?l[a.which]:p[a.which]?p[a.which]:String.fromCharCode(a.which).toLowerCase()}function
 D(a){var 
b=[];a.shiftKey&&b.push("shift");a.altKey&&b.push("alt");a.ctrlKey&&b.push("ctrl");a.metaKey&&b.push("meta");return
 b}function u(a){return"shift"==a||"ctrl"==a||"alt"==a||
+"meta"==a}function y(a,b){var 
h,c,e,g=[];h=a;"+"===h?h=["+"]:(h=h.replace(/\+{2}/g,"+plus"),h=h.split("+"));for(e=0;em||l.hasOwnProperty(m)&&(k[l[m]]=m)}e=k[h]?"keydown":"keypress"}"keypress"==e&&g.length&&(e="keydown");return{key:c,modifiers:g,action:e}}function
 B(a,b){return null===a||a===r?!1:a===b?!0:B(a.parentNode,b)}function 
c(a){function b(a){a=
+a||{};var b=!1,n;for(n in q)a[n]?b=!0:q[n]=0;b||(v=!1)}function 
h(a,b,n,f,c,h){var 
g,e,l=[],m=n.type;if(!d._callbacks[a])return[];"keyup"==m&&u(a)&&(b=[a]);for(g=0;g":".","?":"/","|":"\\"},z={option:"alt",command:"meta","return":"enter",
+escape:"esc",plus:"+",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},k;for(g=1;20>g;++g)l[111+g]="f"+g;for(g=0;9>=g;++g)l[g+96]=g;c.prototype.bind=function(a,b,c){a=a
 instanceof Array?a:[a];this._bindMultiple.call(this,a,b,c);return 
this};c.prototype.unbind=function(a,b){return 
this.bind.call(this,a,function(){},b)};c.prototype.trigger=function(a,b){if(this._directMap[a+":"+b])this._directMap[a+":"+b]({},a);return
 this};c.prototype.reset=function(){this._callbacks={};this._directMap=
+{};return this};c.prototype.stopCallback=function(a,b){return-1<(" 
"+b.className+" ").indexOf(" mousetrap 
")||B(b,this.target)?!1:"INPUT"==b.tagName||"SELECT"==b.tagName||"TEXTAREA"==b.tagName||b.isContentEditable};c.prototype.handleKey=function(){return
 this._handleKey.apply(this,arguments)};c.init=function(){var a=c(r),b;for(b in 
a)"_"!==b.charAt(0)&&(c[b]=function(b){return function(){return 
a[b].apply(a,arguments)}}(b))};c.init();C.Mousetrap=c;"undefined"!==typeof 
module&&module.exports&&(module.exports=
+c);"function"===typeof define&&define.amd&&define(function(){return 
c})})(window,document);
+
+
 (function () {
+'use strict';
 
 function Jump(matchTarget, lastBlock) {
-  var match = document.location.hash.match(/Path\d+|EndPath/)[0];
-  var matches = document.querySelectorAll('#' + match + ' .PathNav')
+  var match = document.location.hash.match(/Path\d+|EndPath/);
+  if (!match) {
+document.location.hash = '#Path1';
+return;
+  }
+  var matches = document.querySelectorAll('#' + match[0] + ' .PathNav');
   if (matches.length == 2) {
 document.location = matches[matchTarget].children[0].href;
   } else {
@@ -10,32 +28,24 @@
   document.location = matches[0].children[0].href;
 }
   }
-};
+}
 
 function ShowHelp() {
-  alert("Keyboard shortcuts:\n\n" +
-"Jump to next path: j\n"  +
-"Jump to previous path: k\n");
+  alert('Keyboard shortcuts:\n\n' +
+'Jump to next path: j\n'  +
+'Jump to previous path: k\n');
 }
 
-const KEYS = {
-  J: 74,
-  K: 75,
-  SLASH: 191
-}
+Mousetrap.bind('j', function() {
+  Jump(1, '#EndPath');
+});
 
-document.onkeydown = function (e) {
-  switch(e.keyCode) {
-case KEYS.J:
-  Jump(1, '#EndPath');
-  break;
-case KEYS.K:
-  Jump(0, '#Path1');
-  break;
-case KEYS.SLASH:
-  ShowHelp();
-  break;
-  }
-};
+Mousetrap.bind('k', function() {
+  Jump(0, '#Path1');
+});
+
+Mousetrap.bind('?', function() {
+  ShowHelp();
+});
 
 }());


Index: tools/scan-build/keyboard-shortcuts.js
===
--- tools/scan-build/keyboard-shortcuts.js
+++ tools/scan-build/keyboard-shortcuts.js
@@ -1,8 +1,26 @@
+/* mousetrap v1.5.3 craig.is/killing/mice */
+(function(C,r,g){function t(a,b,h){a.addEventListener?a.addEventListener(b,h,!1):a.attachEvent("on"+b,h)}function x(a){if("keypress"==a.type){var b=String.fromCharCode(a.which);a.shiftKey||(b=b.toLowerCase());return b}return l[a.which]?l[a.which]:p[a.which]?p[a.which]:String.fromCharCode(a.which).toLowerCase()}function D(a){var b=[];a.shiftKey&&b.push("shift");a.altKey&&b.push("alt");a.ctrlKey&&b.push("ctrl");a.metaKey&&b.push("meta");return b}function u(a){return"shift"==a||"ctrl"==a