Warmcat homepage andy@warmcat.com
libwebsockets
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"", "gen_ut":1745907976, "reponame":"cgit", "desc":"CGI gitweb", "owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://warmcat.com/repo/cgit", "f":3, "items": [ {"schema":"libjg2-1", "cid":"7c055863da79dad9088b7be61ab94c88", "commit": {"type":"commit", "time": 1530589970, "time_ofs": 480, "oid_tree": { "oid": "c6db4124613c8a0bc674738ccc5c8f0deb8b5bc2", "alias": []}, "oid":{ "oid": "b8cbf846aef9266a3c5c22c8446d614053802b36", "alias": []}, "msg": "cgit.js: line range highlight: improve vertical scroll logic", "sig_commit": { "git_time": { "time": 1530589970, "offset": 480 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" }, "sig_author": { "git_time": { "time": 1529707307, "offset": 480 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" }}, "body": "cgit.js: line range highlight: improve vertical scroll logic\n\nInstead of following the browser heuristic to put any matching\nid element to the top left of the browser window, compute the\nnumber of visible lines vertically in the window, and the\nmiddle of the highlit range, and try to centre the middle of\nthe highlit range in the window.\n\nIf the top of the range is no longer visible due to a range\nconsisting of more lines than the window can show, fall back to\nplacing the top of the range at the top of the window.\n\nSigned-off-by: Andy Green \u003candy@warmcat.com\u003e" , "diff": "diff --git a/cgit.js b/cgit.js\nindex 6cc27c1..d99c980 100644\n--- a/cgit.js\n+++ b/cgit.js\n@@ -57,7 +57,7 @@ function line_range_highlight()\n \tif (l2 \u003c l1)\n \t\tl2 \u003d l1;\n \n-\tvar lh, etable, etr, de, n;\n+\tvar lh, etable, etr, de, n, hl, v;\n \n \te \u003d document.getElementById('n' + l1);\n \tif (!e)\n@@ -94,7 +94,18 @@ function line_range_highlight()\n \twhile (n \u003c\u003d l2)\n \t\tdocument.getElementById('n' + n++).style.backgroundColor \u003d \u0022yellow\u0022;\n \n-\te.scrollIntoView(true);\n+\thl \u003d (window.innerHeight / (e.offsetHeight + 1));\n+\tv \u003d (l1 + ((l2 - l1) / 2)) - (hl / 2);\n+\tif (v \u003e l1)\n+\t\tv \u003d l1;\n+\tif (v \u003c 1)\n+\t\tv \u003d 1;\n+\n+\tt \u003d document.getElementById('n' + Math.round(v));\n+\tif (!t)\n+\t\tt \u003d e;\n+\n+\tt.scrollIntoView(true);\n }\n \n /* we have to use load, because header images can push the layout vertically */\n","s":{"c":1745907976,"u": 460}} ],"g": 1293,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}