{"schema":"libjg2-1",
"vpath":"/git/",
"avatar":"/git/avatar/",
"alang":"",
"gen_ut":1745907902,
"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":"ddadece001473b3948674df7ff05f3e5",
"commit": {"type":"commit",
"time": 1530589970,
"time_ofs": 480,
"oid_tree": { "oid": "261332b8606ca40abf2c3eb332265ec7c9b04cb4", "alias": []},
"oid":{ "oid": "ea8a160bfb460c1ac424a7ae05cd5b5c2dcf42f9", "alias": [ "refs/heads/line-range-high"]},
"msg": "line-range-highlight: copy text",
"sig_commit": { "git_time": { "time": 1530589970, "offset": 480 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },
"sig_author": { "git_time": { "time": 1530234346, "offset": 480 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" }},
"body": "line-range-highlight: copy text\n\nImplement picking a line range or single line\nfrom the textContent version of the rendered\nsource to the clipboard.\n\nIt works in blame and tree the same.\n\nSigned-off-by: Andy Green \u003candy@warmcat.com\u003e"
,
"diff": "diff --git a/cgit.js b/cgit.js\nindex 7fae9aa..bc2ba65 100644\n--- a/cgit.js\n+++ b/cgit.js\n@@ -31,6 +31,25 @@ function find_parent_of_type(e, type)\n \treturn e;\n }\n \n+function parse_hashurl_start(h)\n+{\n+\treturn parseInt(h.substring(2));\n+}\n+\n+function parse_hashurl_end(h, start)\n+{\n+\tvar t \u003d h.indexOf(\u0022-\u0022), e \u003d start;\n+\n+\tif (t \u003e\u003d 1)\n+\t\te \u003d parseInt(h.substring(t + 1));\n+\n+\tif (e \u003c start)\n+\t\te \u003d start;\n+\n+\treturn e;\n+}\n+\n+\n /*\n * This creates an absolute div as a child of the content table.\n * It's horizontally and vertically aligned and sized according\n@@ -56,17 +75,11 @@ function line_range_highlight(do_burger)\n \t\te.remove();\n \t}\n \n-\tl1 \u003d parseInt(h.substring(2));\n+\tl1 \u003d parse_hashurl_start(h);\n \tif (!l1)\n \t\treturn;\n \n-\tt \u003d h.indexOf(\u0022-\u0022);\n-\tl2 \u003d l1;\n-\tif (t \u003e\u003d 1)\n-\t\tl2 \u003d parseInt(h.substring(t + 1));\n-\n-\tif (l2 \u003c l1)\n-\t\tl2 \u003d l1;\n+\tl2 \u003d parse_hashurl_end(h, l1);\n \n \tvar lh, etable, etr, de, n, hl, v;\n \n@@ -142,18 +155,36 @@ function copy_clipboard(value)\n \tinp.remove();\n }\n \n+/* we want to copy plain text for a line range */\n+\n+function copy_text(elem, l1, l2)\n+{\n+\tvar tc \u003d elem.textContent.split('\u005cn'), s \u003d \u0022\u0022;\n+\n+\tl1 --;\n+\n+\twhile (l1 \u003c l2)\n+\t\ts +\u003d tc[l1++] + '\u005cn';\n+\n+\tcopy_clipboard(s);\n+}\n+\n+\n /*\n * An element in the popup menu was clicked, perform the appropriate action\n */\n function mi_click(e) {\n-\tvar u, n;\n+\tvar u, n, l1, l2, el;\n \n \te.stopPropagation();\n \te.preventDefault();\n \n \tswitch (e.target.id) {\n \tcase \u0022mi-c-line\u0022:\n-\t\t/* implemented in next patch */\n+\t\tl1 \u003d parse_hashurl_start(window.location.hash);\n+\t\tl2 \u003d parse_hashurl_end(window.location.hash, l1);\n+\t\tel \u003d document.getElementsByClassName(\u0022highlight\u0022)[0].firstChild;\n+\t\tcopy_text(el, l1, l2);\n \t\tbreak;\n \tcase \u0022mi-c-link\u0022:\n \t\tcopy_clipboard(window.location.href);\n","s":{"c":1745907902,"u": 1004}}
],"g": 1804,"chitpc": 0,"ehitpc": 0,"indexed":0
,
"ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}