Show line numbers in code view
authorJan Lahoda <jlahoda@netbeans.org>
Sun, 30 Jun 2013 12:40:51 +0200
changeset 968dcfacd3588c9
parent 967 8532a2fa1751
child 969 d51acc0022c7
Show line numbers in code view
remoting/server/web/web.ui.frontend/public_html/index/ui/index.html
remoting/server/web/web.ui.frontend/public_html/index/ui/script.js
     1.1 --- a/remoting/server/web/web.ui.frontend/public_html/index/ui/index.html	Sat Jun 29 08:20:10 2013 +0200
     1.2 +++ b/remoting/server/web/web.ui.frontend/public_html/index/ui/index.html	Sun Jun 30 12:40:51 2013 +0200
     1.3 @@ -52,6 +52,28 @@
     1.4          .markup-attribute {color: #007c00;}
     1.5          .markup-attribute-value {color: #99009D;}
     1.6          .entity-reference {color: #b20000;}
     1.7 +
     1.8 +        #code table tr td:first-child {
     1.9 +            width:auto;
    1.10 +            white-space:nowrap;
    1.11 +            text-align:right;
    1.12 +            vertical-align:text-top;
    1.13 +            border-right: 1px solid #c3c3c3;
    1.14 +            padding-right:10px;
    1.15 +            color: #999999;
    1.16 +        }
    1.17 +        
    1.18 +        #code table tr td:last-child {
    1.19 +            padding-left:10px;
    1.20 +        }
    1.21 +
    1.22 +        .unselectable {
    1.23 +            user-select: none;
    1.24 +            -moz-user-select: none;
    1.25 +            -webkit-user-select: none;
    1.26 +            -ms-user-select: none;
    1.27 +            -khtml-user-select: none;
    1.28 +        }
    1.29      </style>
    1.30  </head>
    1.31      <body ng-controller="topLevel" style="padding: 40px">
     2.1 --- a/remoting/server/web/web.ui.frontend/public_html/index/ui/script.js	Sat Jun 29 08:20:10 2013 +0200
     2.2 +++ b/remoting/server/web/web.ui.frontend/public_html/index/ui/script.js	Sun Jun 30 12:40:51 2013 +0200
     2.3 @@ -341,12 +341,21 @@
     2.4  function tokenColoring(code, tokenColoring, tokenSpans) {
     2.5      var current = 0;
     2.6      var coloredCode = "";
     2.7 +    var line = 1;
     2.8 +    coloredCode += '<table><tr><td class="unselectable">' + (line++) + "</td><td>";
     2.9      
    2.10      for (var i = 0; i < tokenColoring.length; i++ ) {
    2.11 -        coloredCode += '<span id="p' + current + '" class="' + tokenColoring[i] + '" jpt30pos="' + current + '">' + code.slice(current, current+tokenSpans[i]).replace(/&/g, '&amp;').replace(/</g, '&lt;') + "</span>";
    2.12 +        var currentCode = code.slice(current, current+tokenSpans[i]);
    2.13 +        var byLines = currentCode.split("\n");
    2.14 +        for (var j = 0; j < byLines.length; j++) {
    2.15 +            if (j > 0) coloredCode += '</td></tr><tr><td class="unselectable">' + (line++) + "</td><td>";
    2.16 +            coloredCode += '<span id="p' + current + '" class="' + tokenColoring[i] + '" jpt30pos="' + current + '">' + byLines[j].replace(/&/g, '&amp;').replace(/</g, '&lt;') + "</span>";
    2.17 +        }
    2.18          current += tokenSpans[i];
    2.19      }
    2.20  
    2.21 +    coloredCode += "</td></tr></table>";
    2.22 +
    2.23      return coloredCode;
    2.24  }
    2.25