<commit_before><!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="UTF-8">
      <title>Custom context menu example</title>
      <link rel="shortcut icon" href="img/RootIcon.ico"/>
      <!-- To make use of RequireJS, replace following line with commented one -->
      <!--script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="scripts/JSRoot.core.js"></script-->
      <script type="text/javascript" src="../scripts/JSRoot.core.js"></script>
   </head>
   <body>
      <div id="guiDiv" path="../../files/" files="ct.root;exclusion.root;fillrandom.root;glbox.root;graph.root;hsimple.root;legends.root;rf107.root;stacks.root;zdemo.root">
         loading scripts ...
      </div>
      <script type="text/javascript">
         // build standard GUI, open ROOT file and display histogram

         let hh = null;

         JSROOT.buildGUI("guiDiv")
               .then(hpainter => { hh = hpainter; return hh.openRootFile("../../files/hsimple.root"); })
               .then(() => hh.display("hpxpy;1", "colz"));

         // assign new context menu handler for TH2 drawing
         JSROOT.require('hist').then(() => {
            JSROOT.TH2Painter.prototype.oldFillHistContextMenu = JSROOT.TH2Painter.prototype.fillHistContextMenu;

            JSROOT.TH2Painter.prototype.fillHistContextMenu = function(menu) {
               let itemname = this.getItemName();
               if ((typeof itemname == "string") && itemname.indexOf("hpxpy") >= 0) {
                  let tip = menu.painter.getToolTip(menu.getEventPosition());

                  console.log('Hist context menu for', this.getItemName(), tip);

                  menu.add("sub:Custom", () => menu.painter.provideSpecialDrawArea());
                  menu.add("Show hpx", () => menu.painter.provideSpecialDrawArea("bottom").then(() => hh.getObject("hpx")).then(res => menu.painter.drawInSpecialArea(res.obj, "*H")));
                  menu.add("Show hprof", () => menu.painter.provideSpecialDrawArea("left").then(() => hh.getObject("hprof")).then(res => menu.painter.drawInSpecialArea(res.obj, "E")));
                  menu.add("Close extra area", () => menu.painter.provideSpecialDrawArea());
                  menu.add("endsub:");
               }
               return this.oldFillHistContextMenu(menu);
            }
         });
      </script>
   </body>
</html>
<commit_msg>Adjust context menu example<commit_after><!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="UTF-8">
      <title>Custom context menu example</title>
      <link rel="shortcut icon" href="img/RootIcon.ico"/>
      <!-- To make use of RequireJS, replace following line with commented one -->
      <!--script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="scripts/JSRoot.core.js"></script-->
      <script type="text/javascript" src="../scripts/JSRoot.core.js"></script>
   </head>
   <body>
      <div id="guiDiv" path="../../files/" files="ct.root;exclusion.root;fillrandom.root;glbox.root;graph.root;hsimple.root;legends.root;rf107.root;stacks.root;zdemo.root">
         loading scripts ...
      </div>
      <script type="text/javascript">
         // build standard GUI, open ROOT file and display histogram

         let hh = null;

         JSROOT.buildGUI("guiDiv")
               .then(hpainter => { hh = hpainter; return hh.openRootFile("../../files/hsimple.root"); })
               .then(() => hh.display("hpxpy;1", "colz"));

         // assign new context menu handler for TH2 drawing
         JSROOT.require('hist').then(() => {
            JSROOT.TH2Painter.prototype.oldFillHistContextMenu = JSROOT.TH2Painter.prototype.fillHistContextMenu;

            JSROOT.TH2Painter.prototype.fillHistContextMenu = function(menu) {
               let itemname = this.getItemName();
               if ((typeof itemname == "string") && (itemname.indexOf("hpxpy") >= 0)) {
                  let tip = menu.painter.getToolTip(menu.getEventPosition());

                  // example how to get label from bin index
                  // if (tip.binx !== undefined) console.log('binx as text', menu.painter.getFramePainter().axisAsText("x", tip.binx));
                  // if (tip.biny !== undefined) console.log('biny as text', menu.painter.getFramePainter().axisAsText("y", tip.biny));

                  console.log('Hist context menu for', itemname, tip.binx, tip.biny, tip.cont);

                  menu.add(`sub:Histogram bin [${tip.binx}, ${tip.biny}]`, () => menu.painter.provideSpecialDrawArea());
                  menu.add("Show hpx", () => menu.painter.provideSpecialDrawArea("bottom").then(() => hh.getObject("hpx")).then(res => menu.painter.drawInSpecialArea(res.obj, "*H")));
                  menu.add("Show hprof", () => menu.painter.provideSpecialDrawArea("left").then(() => hh.getObject("hprof")).then(res => menu.painter.drawInSpecialArea(res.obj, "E")));
                  menu.add("Close extra area", () => menu.painter.provideSpecialDrawArea());
                  menu.add("endsub:");
               }
               return this.oldFillHistContextMenu(menu);
            }
         });
      </script>
   </body>
</html>

{'fraction_non_alphanumeric': 0.17230828074201568, 'fraction_numerical': 0.0049722700325109965, 'mean_word_length': 2.555404486743712, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '771083', 'n_tokens_mistral': 1619, 'n_tokens_neox': 1561, 'n_words': 272}