diff options
author | Unknwon <u@gogs.io> | 2016-04-04 19:33:52 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-04-04 19:33:52 -0400 |
commit | d9900e4dbc2f2182ea06ad3ecdcf714da002dd24 (patch) | |
tree | a19204290b07ef4c079773b0e07730c68b3cdb0d | |
parent | 762ab056a2ee976037d9fe929c37ab5bdb940e7a (diff) | |
parent | b35157f4ffa6b94b49494f9de13fe7bc4307ed2b (diff) | |
download | gitea-d9900e4dbc2f2182ea06ad3ecdcf714da002dd24.tar.gz gitea-d9900e4dbc2f2182ea06ad3ecdcf714da002dd24.zip |
Merge pull request #2914 from psychomario/linenumoptimize
Reduce line number creation to one DOM manipulation
-rw-r--r-- | public/js/gogs.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/public/js/gogs.js b/public/js/gogs.js index 33da034551..0d7271c134 100644 --- a/public/js/gogs.js +++ b/public/js/gogs.js @@ -1043,10 +1043,14 @@ $(window).load(function () { var $num_list = $('.code-view .lines-num'); // Building blocks. + var $toappendblock = []; + var $toappendnum_list = []; for (var i = 0; i < lines.length; i++) { - $block.append('<li class="L' + (i + 1) + '" rel="L' + (i + 1) + '">' + lines[i] + '</li>'); - $num_list.append('<span id="L' + (i + 1) + '">' + (i + 1) + '</span>'); + $toappendblock.push('<li class="L' + (i + 1) + '" rel="L' + (i + 1) + '">' + lines[i] + '</li>'); + $toappendnum_list.push('<span id="L' + (i + 1) + '">' + (i + 1) + '</span>'); } + $block.append($toappendblock.join('')); + $num_list.append($toappendnum_list.join('')); $(document).on('click', '.lines-num span', function (e) { var $select = $(this); |