mercurial/templates/static/followlines.js
author Pierre-Yves David <pierre-yves.david@octobus.net>
Sat, 25 Apr 2020 12:37:46 +0200
changeset 46151 c6bc77f7e593
parent 37491 685ad41feba0
child 49171 2c0570a6d5ae
permissions -rw-r--r--
copies-rust: tokenize all paths into integer Copy information for each changesets tend to affect a small new number of path. However, each of these path might be handled a large number of time. Handling HgPathBuf (aka `Vec<u8>`) is expensive. Handling integer is cheap. With this patch we: - turn any input path into an integer "token" early, - do all the internal logic using such "token", - turn "token" back into path right before returning a result. This gives use a quite significant performance boost in our slower cases. Repo Case Source-Rev Dest-Rev # of revisions old time new time Difference Factor time per rev --------------------------------------------------------------------------------------------------------------------------------------------------------------- pypy x000_revs_x000_added_x_copies 8a3b5bfd266e 2c68e87c3efe : 6780 revs, 0.092828 s, 0.081225 s, -0.011603 s, × 0.8750, 11 µs/rev pypy x0000_revs_x_added_0_copies d1defd0dc478 c9cb1334cc78 : 43645 revs, 0.711975 s, 0.586011 s, -0.125964 s, × 0.8231, 13 µs/rev pypy x0000_revs_xx000_added_x000_copies 08ea3258278e d9fa043f30c0 : 11316 revs, 0.124505 s, 0.114173 s, -0.010332 s, × 0.9170, 10 µs/rev netbeans x000_revs_x000_added_x000_copies ff453e9fee32 411350406ec2 : 5750 revs, 0.072072 s, 0.061004 s, -0.011068 s, × 0.8464, 10 µs/rev netbeans x0000_revs_xx000_added_x000_copies 588c2d1ced70 1aad62e59ddd : 66949 revs, 0.682732 s, 0.535874 s, -0.146858 s, × 0.7849, 8 µs/rev mozilla-central x00000_revs_x0000_added_x0000_copies 6832ae71433c 4c222a1d9a00 : 153721 revs, 1.935918 s, 1.781383 s, -0.154535 s, × 0.9202, 11 µs/rev mozilla-central x00000_revs_x00000_added_x000_copies 76caed42cf7c 1daa622bbe42 : 204976 revs, 2.827320 s, 2.603867 s, -0.223453 s, × 0.9210, 12 µs/rev mozilla-try x0000_revs_xx000_added_x000_copies 89294cd501d9 7ccb2fc7ccb5 : 97052 revs, 3.243010 s, 1.529120 s, -1.713890 s, × 0.4715, 15 µs/rev mozilla-try x00000_revs_x_added_0_copies 6a320851d377 1ebb79acd503 : 363753 revs, 5.693818 s, 4.842699 s, -0.851119 s, × 0.8505, 13 µs/rev mozilla-try x00000_revs_x_added_x_copies 5173c4b6f97c 95d83ee7242d : 362229 revs, 5.677655 s, 4.761732 s, -0.915923 s, × 0.8387, 13 µs/rev mozilla-try x00000_revs_x000_added_x_copies 9126823d0e9c ca82787bb23c : 359344 revs, 5.563370 s, 4.733912 s, -0.829458 s, × 0.8509, 13 µs/rev mozilla-try x00000_revs_x0000_added_x0000_copies 8d3fafa80d4b eb884023b810 : 192665 revs, 2.864099 s, 2.593410 s, -0.270689 s, × 0.9055, 13 µs/rev mozilla-try x00000_revs_x00000_added_x0000_copies 1b661134e2ca 1ae03d022d6d : 228985 revs, 113.297287 s, 41.041198 s, -72.256089 s, × 0.3622, 179 µs/rev mozilla-try x00000_revs_x00000_added_x000_copies 9b2a99adc05e 8e29777b48e6 : 382065 revs, 59.498652 s, 27.915689 s, -31.582963 s, × 0.4692, 73 µs/rev Full timing comparison between this revision and the previous one: Repo Case Source-Rev Dest-Rev # of revisions old time new time Difference Factor time per rev --------------------------------------------------------------------------------------------------------------------------------------------------------------- mercurial x_revs_x_added_0_copies ad6b123de1c7 39cfcef4f463 : 1 revs, 0.000042 s, 0.000042 s, +0.000000 s, × 1.0000, 42 µs/rev mercurial x_revs_x_added_x_copies 2b1c78674230 0c1d10351869 : 6 revs, 0.000104 s, 0.000110 s, +0.000006 s, × 1.0577, 18 µs/rev mercurial x000_revs_x000_added_x_copies 81f8ff2a9bf2 dd3267698d84 : 1032 revs, 0.004913 s, 0.004918 s, +0.000005 s, × 1.0010, 4 µs/rev pypy x_revs_x_added_0_copies aed021ee8ae8 099ed31b181b : 9 revs, 0.000191 s, 0.000195 s, +0.000004 s, × 1.0209, 21 µs/rev pypy x_revs_x000_added_0_copies 4aa4e1f8e19a 359343b9ac0e : 1 revs, 0.000050 s, 0.000049 s, -0.000001 s, × 0.9800, 49 µs/rev pypy x_revs_x_added_x_copies ac52eb7bbbb0 72e022663155 : 7 revs, 0.000112 s, 0.000112 s, +0.000000 s, × 1.0000, 16 µs/rev pypy x_revs_x00_added_x_copies c3b14617fbd7 ace7255d9a26 : 1 revs, 0.000288 s, 0.000324 s, +0.000036 s, × 1.1250, 324 µs/rev pypy x_revs_x000_added_x000_copies df6f7a526b60 a83dc6a2d56f : 6 revs, 0.010411 s, 0.010611 s, +0.000200 s, × 1.0192, 1768 µs/rev pypy x000_revs_xx00_added_0_copies 89a76aede314 2f22446ff07e : 4785 revs, 0.052852 s, 0.050835 s, -0.002017 s, × 0.9618, 10 µs/rev pypy x000_revs_x000_added_x_copies 8a3b5bfd266e 2c68e87c3efe : 6780 revs, 0.092828 s, 0.081225 s, -0.011603 s, × 0.8750, 11 µs/rev pypy x000_revs_x000_added_x000_copies 89a76aede314 7b3dda341c84 : 5441 revs, 0.063269 s, 0.061291 s, -0.001978 s, × 0.9687, 11 µs/rev pypy x0000_revs_x_added_0_copies d1defd0dc478 c9cb1334cc78 : 43645 revs, 0.711975 s, 0.586011 s, -0.125964 s, × 0.8231, 13 µs/rev pypy x0000_revs_xx000_added_0_copies bf2c629d0071 4ffed77c095c : 2 revs, 0.012771 s, 0.012824 s, +0.000053 s, × 1.0042, 6412 µs/rev pypy x0000_revs_xx000_added_x000_copies 08ea3258278e d9fa043f30c0 : 11316 revs, 0.124505 s, 0.114173 s, -0.010332 s, × 0.9170, 10 µs/rev netbeans x_revs_x_added_0_copies fb0955ffcbcd a01e9239f9e7 : 2 revs, 0.000082 s, 0.000085 s, +0.000003 s, × 1.0366, 42 µs/rev netbeans x_revs_x000_added_0_copies 6f360122949f 20eb231cc7d0 : 2 revs, 0.000111 s, 0.000108 s, -0.000003 s, × 0.9730, 54 µs/rev netbeans x_revs_x_added_x_copies 1ada3faf6fb6 5a39d12eecf4 : 3 revs, 0.000171 s, 0.000175 s, +0.000004 s, × 1.0234, 58 µs/rev netbeans x_revs_x00_added_x_copies 35be93ba1e2c 9eec5e90c05f : 9 revs, 0.000708 s, 0.000719 s, +0.000011 s, × 1.0155, 79 µs/rev netbeans x000_revs_xx00_added_0_copies eac3045b4fdd 51d4ae7f1290 : 1421 revs, 0.010608 s, 0.010175 s, -0.000433 s, × 0.9592, 7 µs/rev netbeans x000_revs_x000_added_x_copies e2063d266acd 6081d72689dc : 1533 revs, 0.015635 s, 0.015569 s, -0.000066 s, × 0.9958, 10 µs/rev netbeans x000_revs_x000_added_x000_copies ff453e9fee32 411350406ec2 : 5750 revs, 0.072072 s, 0.061004 s, -0.011068 s, × 0.8464, 10 µs/rev netbeans x0000_revs_xx000_added_x000_copies 588c2d1ced70 1aad62e59ddd : 66949 revs, 0.682732 s, 0.535874 s, -0.146858 s, × 0.7849, 8 µs/rev mozilla-central x_revs_x_added_0_copies 3697f962bb7b 7015fcdd43a2 : 2 revs, 0.000090 s, 0.000090 s, +0.000000 s, × 1.0000, 45 µs/rev mozilla-central x_revs_x000_added_0_copies dd390860c6c9 40d0c5bed75d : 8 revs, 0.000210 s, 0.000281 s, +0.000071 s, × 1.3381, 35 µs/rev mozilla-central x_revs_x_added_x_copies 8d198483ae3b 14207ffc2b2f : 9 revs, 0.000182 s, 0.000187 s, +0.000005 s, × 1.0275, 20 µs/rev mozilla-central x_revs_x00_added_x_copies 98cbc58cc6bc 446a150332c3 : 7 revs, 0.000594 s, 0.000660 s, +0.000066 s, × 1.1111, 94 µs/rev mozilla-central x_revs_x000_added_x000_copies 3c684b4b8f68 0a5e72d1b479 : 3 revs, 0.003102 s, 0.003385 s, +0.000283 s, × 1.0912, 1128 µs/rev mozilla-central x_revs_x0000_added_x0000_copies effb563bb7e5 c07a39dc4e80 : 6 revs, 0.060234 s, 0.069812 s, +0.009578 s, × 1.1590, 11635 µs/rev mozilla-central x000_revs_xx00_added_0_copies 6100d773079a 04a55431795e : 1593 revs, 0.006300 s, 0.006503 s, +0.000203 s, × 1.0322, 4 µs/rev mozilla-central x000_revs_x000_added_x_copies 9f17a6fc04f9 2d37b966abed : 41 revs, 0.004817 s, 0.004988 s, +0.000171 s, × 1.0355, 121 µs/rev mozilla-central x000_revs_x000_added_x000_copies 7c97034feb78 4407bd0c6330 : 7839 revs, 0.065451 s, 0.063963 s, -0.001488 s, × 0.9773, 8 µs/rev mozilla-central x0000_revs_xx000_added_0_copies 9eec5917337d 67118cc6dcad : 615 revs, 0.026282 s, 0.026225 s, -0.000057 s, × 0.9978, 42 µs/rev mozilla-central x0000_revs_xx000_added_x000_copies f78c615a656c 96a38b690156 : 30263 revs, 0.206873 s, 0.201377 s, -0.005496 s, × 0.9734, 6 µs/rev mozilla-central x00000_revs_x0000_added_x0000_copies 6832ae71433c 4c222a1d9a00 : 153721 revs, 1.935918 s, 1.781383 s, -0.154535 s, × 0.9202, 11 µs/rev mozilla-central x00000_revs_x00000_added_x000_copies 76caed42cf7c 1daa622bbe42 : 204976 revs, 2.827320 s, 2.603867 s, -0.223453 s, × 0.9210, 12 µs/rev mozilla-try x_revs_x_added_0_copies aaf6dde0deb8 9790f499805a : 2 revs, 0.000842 s, 0.000845 s, +0.000003 s, × 1.0036, 422 µs/rev mozilla-try x_revs_x000_added_0_copies d8d0222927b4 5bb8ce8c7450 : 2 revs, 0.000870 s, 0.000862 s, -0.000008 s, × 0.9908, 431 µs/rev mozilla-try x_revs_x_added_x_copies 092fcca11bdb 936255a0384a : 4 revs, 0.000165 s, 0.000161 s, -0.000004 s, × 0.9758, 40 µs/rev mozilla-try x_revs_x00_added_x_copies b53d2fadbdb5 017afae788ec : 2 revs, 0.001145 s, 0.001163 s, +0.000018 s, × 1.0157, 581 µs/rev mozilla-try x_revs_x000_added_x000_copies 20408ad61ce5 6f0ee96e21ad : 1 revs, 0.026500 s, 0.032414 s, +0.005914 s, × 1.2232, 32414 µs/rev mozilla-try x_revs_x0000_added_x0000_copies effb563bb7e5 c07a39dc4e80 : 6 revs, 0.059407 s, 0.070149 s, +0.010742 s, × 1.1808, 11691 µs/rev mozilla-try x000_revs_xx00_added_0_copies 6100d773079a 04a55431795e : 1593 revs, 0.006325 s, 0.006526 s, +0.000201 s, × 1.0318, 4 µs/rev mozilla-try x000_revs_x000_added_x_copies 9f17a6fc04f9 2d37b966abed : 41 revs, 0.005171 s, 0.005187 s, +0.000016 s, × 1.0031, 126 µs/rev mozilla-try x000_revs_x000_added_x000_copies 1346fd0130e4 4c65cbdabc1f : 6657 revs, 0.066837 s, 0.065047 s, -0.001790 s, × 0.9732, 9 µs/rev mozilla-try x0000_revs_x_added_0_copies 63519bfd42ee a36a2a865d92 : 40314 revs, 0.314252 s, 0.301129 s, -0.013123 s, × 0.9582, 7 µs/rev mozilla-try x0000_revs_x_added_x_copies 9fe69ff0762d bcabf2a78927 : 38690 revs, 0.304160 s, 0.280683 s, -0.023477 s, × 0.9228, 7 µs/rev mozilla-try x0000_revs_xx000_added_x_copies 156f6e2674f2 4d0f2c178e66 : 8598 revs, 0.089223 s, 0.084897 s, -0.004326 s, × 0.9515, 9 µs/rev mozilla-try x0000_revs_xx000_added_0_copies 9eec5917337d 67118cc6dcad : 615 revs, 0.026711 s, 0.026620 s, -0.000091 s, × 0.9966, 43 µs/rev mozilla-try x0000_revs_xx000_added_x000_copies 89294cd501d9 7ccb2fc7ccb5 : 97052 revs, 3.243010 s, 1.529120 s, -1.713890 s, × 0.4715, 15 µs/rev mozilla-try x0000_revs_x0000_added_x0000_copies e928c65095ed e951f4ad123a : 52031 revs, 0.756500 s, 0.738709 s, -0.017791 s, × 0.9765, 14 µs/rev mozilla-try x00000_revs_x_added_0_copies 6a320851d377 1ebb79acd503 : 363753 revs, 5.693818 s, 4.842699 s, -0.851119 s, × 0.8505, 13 µs/rev mozilla-try x00000_revs_x00000_added_0_copies dc8a3ca7010e d16fde900c9c : 34414 revs, 0.590904 s, 0.596946 s, +0.006042 s, × 1.0102, 17 µs/rev mozilla-try x00000_revs_x_added_x_copies 5173c4b6f97c 95d83ee7242d : 362229 revs, 5.677655 s, 4.761732 s, -0.915923 s, × 0.8387, 13 µs/rev mozilla-try x00000_revs_x000_added_x_copies 9126823d0e9c ca82787bb23c : 359344 revs, 5.563370 s, 4.733912 s, -0.829458 s, × 0.8509, 13 µs/rev mozilla-try x00000_revs_x0000_added_x0000_copies 8d3fafa80d4b eb884023b810 : 192665 revs, 2.864099 s, 2.593410 s, -0.270689 s, × 0.9055, 13 µs/rev mozilla-try x00000_revs_x00000_added_x0000_copies 1b661134e2ca 1ae03d022d6d : 228985 revs, 113.297287 s, 41.041198 s, -72.256089 s, × 0.3622, 179 µs/rev mozilla-try x00000_revs_x00000_added_x000_copies 9b2a99adc05e 8e29777b48e6 : 382065 revs, 59.498652 s, 27.915689 s, -31.582963 s, × 0.4692, 73 µs/rev Full timing comparison between this revision and the filelog copy tracing. Repo Case Source-Rev Dest-Rev # of revisions filelog sidedata Difference Factor time per rev --------------------------------------------------------------------------------------------------------------------------------------------------------------- mercurial x_revs_x_added_0_copies ad6b123de1c7 39cfcef4f463 : 1 revs, 0.000903 s, 0.000042 s, -0.000861 s, × 0.0465, 41 µs/rev mercurial x_revs_x_added_x_copies 2b1c78674230 0c1d10351869 : 6 revs, 0.001861 s, 0.000110 s, -0.001751 s, × 0.0591, 18 µs/rev mercurial x000_revs_x000_added_x_copies 81f8ff2a9bf2 dd3267698d84 : 1032 revs, 0.018577 s, 0.004918 s, -0.013659 s, × 0.2647, 4 µs/rev pypy x_revs_x_added_0_copies aed021ee8ae8 099ed31b181b : 9 revs, 0.001519 s, 0.000195 s, -0.001324 s, × 0.1283, 21 µs/rev pypy x_revs_x000_added_0_copies 4aa4e1f8e19a 359343b9ac0e : 1 revs, 0.213855 s, 0.000049 s, -0.350d73 s, × 0.0002, 48 µs/rev pypy x_revs_x_added_x_copies ac52eb7bbbb0 72e022663155 : 7 revs, 0.017022 s, 0.000112 s, -0.016910 s, × 0.0065, 15 µs/rev pypy x_revs_x00_added_x_copies c3b14617fbd7 ace7255d9a26 : 1 revs, 0.019398 s, 0.000324 s, -0.019074 s, × 0.0167, 323 µs/rev pypy x_revs_x000_added_x000_copies df6f7a526b60 a83dc6a2d56f : 6 revs, 0.769467 s, 0.010611 s, -0.758856 s, × 0.0137, 1768 µs/rev pypy x000_revs_xx00_added_0_copies 89a76aede314 2f22446ff07e : 4785 revs, 1.221952 s, 0.050835 s, -1.171117 s, × 0.0416, 10 µs/rev pypy x000_revs_x000_added_x_copies 8a3b5bfd266e 2c68e87c3efe : 6780 revs, 1.304007 s, 0.081225 s, -1.222782 s, × 0.0622, 11 µs/rev pypy x000_revs_x000_added_x000_copies 89a76aede314 7b3dda341c84 : 5441 revs, 1.686610 s, 0.061291 s, -1.625319 s, × 0.0363, 11 µs/rev pypy x0000_revs_x_added_0_copies d1defd0dc478 c9cb1334cc78 : 43645 revs, 0.001107 s, 0.586011 s, +0.584904 s, × 529.36, 13 µs/rev pypy x0000_revs_xx000_added_0_copies bf2c629d0071 4ffed77c095c : 2 revs, 1.100760 s, 0.012824 s, -1.087936 s, × 0.0116, 6408 µs/rev pypy x0000_revs_xx000_added_x000_copies 08ea3258278e d9fa043f30c0 : 11316 revs, 1.350547 s, 0.114173 s, -1.236374 s, × 0.0845, 10 µs/rev netbeans x_revs_x_added_0_copies fb0955ffcbcd a01e9239f9e7 : 2 revs, 0.027864 s, 0.000085 s, -0.027779 s, × 0.0030, 42 µs/rev netbeans x_revs_x000_added_0_copies 6f360122949f 20eb231cc7d0 : 2 revs, 0.132479 s, 0.000108 s, -0.132371 s, × 0.0008, 53 µs/rev netbeans x_revs_x_added_x_copies 1ada3faf6fb6 5a39d12eecf4 : 3 revs, 0.025405 s, 0.000175 s, -0.025230 s, × 0.0068, 58 µs/rev netbeans x_revs_x00_added_x_copies 35be93ba1e2c 9eec5e90c05f : 9 revs, 0.053244 s, 0.000719 s, -0.052525 s, × 0.0135, 79 µs/rev netbeans x000_revs_xx00_added_0_copies eac3045b4fdd 51d4ae7f1290 : 1421 revs, 0.038017 s, 0.010175 s, -0.027842 s, × 0.2676, 7 µs/rev netbeans x000_revs_x000_added_x_copies e2063d266acd 6081d72689dc : 1533 revs, 0.198308 s, 0.015569 s, -0.182739 s, × 0.0785, 10 µs/rev netbeans x000_revs_x000_added_x000_copies ff453e9fee32 411350406ec2 : 5750 revs, 0.949749 s, 0.061004 s, -0.888745 s, × 0.0642, 10 µs/rev netbeans x0000_revs_xx000_added_x000_copies 588c2d1ced70 1aad62e59ddd : 66949 revs, 3.932262 s, 0.535874 s, -3.396388 s, × 0.1362, 8 µs/rev mozilla-central x_revs_x_added_0_copies 3697f962bb7b 7015fcdd43a2 : 2 revs, 0.024490 s, 0.000090 s, -0.024400 s, × 0.0036, 44 µs/rev mozilla-central x_revs_x000_added_0_copies dd390860c6c9 40d0c5bed75d : 8 revs, 0.143885 s, 0.000281 s, -0.143604 s, × 0.0019, 35 µs/rev mozilla-central x_revs_x_added_x_copies 8d198483ae3b 14207ffc2b2f : 9 revs, 0.025471 s, 0.000187 s, -0.025284 s, × 0.0073, 20 µs/rev mozilla-central x_revs_x00_added_x_copies 98cbc58cc6bc 446a150332c3 : 7 revs, 0.086013 s, 0.000660 s, -0.085353 s, × 0.0076, 94 µs/rev mozilla-central x_revs_x000_added_x000_copies 3c684b4b8f68 0a5e72d1b479 : 3 revs, 0.200726 s, 0.003385 s, -0.197341 s, × 0.0168, 1127 µs/rev mozilla-central x_revs_x0000_added_x0000_copies effb563bb7e5 c07a39dc4e80 : 6 revs, 2.224171 s, 0.069812 s, -2.154359 s, × 0.0313, 11633 µs/rev mozilla-central x000_revs_xx00_added_0_copies 6100d773079a 04a55431795e : 1593 revs, 0.090780 s, 0.006503 s, -0.084277 s, × 0.0716, 4 µs/rev mozilla-central x000_revs_x000_added_x_copies 9f17a6fc04f9 2d37b966abed : 41 revs, 0.764805 s, 0.004988 s, -0.759817 s, × 0.0065, 121 µs/rev mozilla-central x000_revs_x000_added_x000_copies 7c97034feb78 4407bd0c6330 : 7839 revs, 1.161405 s, 0.063963 s, -1.097442 s, × 0.0550, 8 µs/rev mozilla-central x0000_revs_xx000_added_0_copies 9eec5917337d 67118cc6dcad : 615 revs, 6.816186 s, 0.026225 s, -6.789961 s, × 0.0038, 42 µs/rev mozilla-central x0000_revs_xx000_added_x000_copies f78c615a656c 96a38b690156 : 30263 revs, 3.374819 s, 0.201377 s, -3.173442 s, × 0.0596, 6 µs/rev mozilla-central x00000_revs_x0000_added_x0000_copies 6832ae71433c 4c222a1d9a00 : 153721 revs, 16.285469 s, 1.781383 s, -14.504086 s, × 0.1093, 11 µs/rev mozilla-central x00000_revs_x00000_added_x000_copies 76caed42cf7c 1daa622bbe42 : 204976 revs, 21.207733 s, 2.603867 s, -18.603866 s, × 0.1227, 12 µs/rev mozilla-try x_revs_x_added_0_copies aaf6dde0deb8 9790f499805a : 2 revs, 0.080843 s, 0.000845 s, -0.079998 s, × 0.0104, 422 µs/rev mozilla-try x_revs_x000_added_0_copies d8d0222927b4 5bb8ce8c7450 : 2 revs, 0.511068 s, 0.000862 s, -0.510206 s, × 0.0016, 430 µs/rev mozilla-try x_revs_x_added_x_copies 092fcca11bdb 936255a0384a : 4 revs, 0.021573 s, 0.000161 s, -0.021412 s, × 0.0074, 40 µs/rev mozilla-try x_revs_x00_added_x_copies b53d2fadbdb5 017afae788ec : 2 revs, 0.227726 s, 0.001163 s, -0.226563 s, × 0.0051, 581 µs/rev mozilla-try x_revs_x000_added_x000_copies 20408ad61ce5 6f0ee96e21ad : 1 revs, 1.120448 s, 0.032414 s, -1.088034 s, × 0.0289, 32381 µs/rev mozilla-try x_revs_x0000_added_x0000_copies effb563bb7e5 c07a39dc4e80 : 6 revs, 2.241713 s, 0.070149 s, -2.171564 s, × 0.0312, 11689 µs/rev mozilla-try x000_revs_xx00_added_0_copies 6100d773079a 04a55431795e : 1593 revs, 0.090633 s, 0.006526 s, -0.084107 s, × 0.0720, 4 µs/rev mozilla-try x000_revs_x000_added_x_copies 9f17a6fc04f9 2d37b966abed : 41 revs, 0.770403 s, 0.005187 s, -0.765216 s, × 0.0067, 126 µs/rev mozilla-try x000_revs_x000_added_x000_copies 1346fd0130e4 4c65cbdabc1f : 6657 revs, 1.184557 s, 0.065047 s, -1.119510 s, × 0.0549, 9 µs/rev mozilla-try x0000_revs_x_added_0_copies 63519bfd42ee a36a2a865d92 : 40314 revs, 0.085790 s, 0.301129 s, +0.215339 s, × 3.5100, 7 µs/rev mozilla-try x0000_revs_x_added_x_copies 9fe69ff0762d bcabf2a78927 : 38690 revs, 0.080616 s, 0.280683 s, +0.200067 s, × 3.4817, 7 µs/rev mozilla-try x0000_revs_xx000_added_x_copies 156f6e2674f2 4d0f2c178e66 : 8598 revs, 7.712554 s, 0.084897 s, -7.627657 s, × 0.0110, 9 µs/rev mozilla-try x0000_revs_xx000_added_0_copies 9eec5917337d 67118cc6dcad : 615 revs, 6.937294 s, 0.026620 s, -6.910674 s, × 0.0038, 43 µs/rev mozilla-try x0000_revs_xx000_added_x000_copies 89294cd501d9 7ccb2fc7ccb5 : 97052 revs, 7.712313 s, 1.529120 s, -6.183193 s, × 0.1982, 15 µs/rev mozilla-try x0000_revs_x0000_added_x0000_copies e928c65095ed e951f4ad123a : 52031 revs, 9.966910 s, 0.738709 s, -9.228201 s, × 0.0741, 14 µs/rev mozilla-try x00000_revs_x_added_0_copies 6a320851d377 1ebb79acd503 : 363753 revs, 0.090397 s, 4.842699 s, +4.752302 s, × 53.571, 13 µs/rev mozilla-try x00000_revs_x00000_added_0_copies dc8a3ca7010e d16fde900c9c : 34414 revs, 27.817167 s, 0.596946 s, -27.220221 s, × 0.0214, 17 µs/rev mozilla-try x00000_revs_x_added_x_copies 5173c4b6f97c 95d83ee7242d : 362229 revs, 0.091305 s, 4.761732 s, +4.670427 s, × 52.151, 13 µs/rev mozilla-try x00000_revs_x000_added_x_copies 9126823d0e9c ca82787bb23c : 359344 revs, 0.231183 s, 4.733912 s, +4.502729 s, × 20.476, 13 µs/rev mozilla-try x00000_revs_x0000_added_x0000_copies 8d3fafa80d4b eb884023b810 : 192665 revs, 19.830617 s, 2.593410 s, -17.237207 s, × 0.1307, 13 µs/rev mozilla-try x00000_revs_x00000_added_x0000_copies 1b661134e2ca 1ae03d022d6d : 228985 revs, 21.743873 s, 41.041198 s, +19.297325 s, × 1.8874, 179 µs/rev mozilla-try x00000_revs_x00000_added_x000_copies 9b2a99adc05e 8e29777b48e6 : 382065 revs, 25.935037 s, 27.915689 s, +1.980652 s, × 1.0763, 73 µs/rev Differential Revision: https://phab.mercurial-scm.org/D9493
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31785
d15c9feb4399 hgweb: rename linerangelog.js as followlines.js
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31784
diff changeset
     1
// followlines.js - JavaScript utilities for followlines UI
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
     2
//
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
     3
// Copyright 2017 Logilab SA <contact@logilab.fr>
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
     4
//
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
     5
// This software may be used and distributed according to the terms of the
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
     6
// GNU General Public License version 2 or any later version.
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
     7
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
     8
//** Install event listeners for line block selection and followlines action */
31783
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
     9
document.addEventListener('DOMContentLoaded', function() {
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    10
    var sourcelines = document.getElementsByClassName('sourcelines')[0];
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    11
    if (typeof sourcelines === 'undefined') {
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    12
        return;
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    13
    }
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    14
    // URL to complement with "linerange" query parameter
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    15
    var targetUri = sourcelines.dataset.logurl;
35156
9f44d44626a0 hgweb: use strict equals, remove non-breaking space in followlines.js
Anton Shestakov <av6@dwimlabs.net>
parents: 35020
diff changeset
    16
    if (typeof targetUri === 'undefined') {
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    17
        return;
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    18
    }
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    19
32995
7c82bfd55d47 hgweb: parameterize the tag name of elements holding followlines selection
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32071
diff changeset
    20
    // Tag of children of "sourcelines" element on which to add "line
7c82bfd55d47 hgweb: parameterize the tag name of elements holding followlines selection
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32071
diff changeset
    21
    // selection" style.
7c82bfd55d47 hgweb: parameterize the tag name of elements holding followlines selection
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32071
diff changeset
    22
    var selectableTag = sourcelines.dataset.selectabletag;
7c82bfd55d47 hgweb: parameterize the tag name of elements holding followlines selection
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32071
diff changeset
    23
    if (typeof selectableTag === 'undefined') {
7c82bfd55d47 hgweb: parameterize the tag name of elements holding followlines selection
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32071
diff changeset
    24
        return;
7c82bfd55d47 hgweb: parameterize the tag name of elements holding followlines selection
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32071
diff changeset
    25
    }
7c82bfd55d47 hgweb: parameterize the tag name of elements holding followlines selection
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32071
diff changeset
    26
32070
a298f5c61b34 hgweb: do not show "descending" link in followlines UI for filelog heads
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31940
diff changeset
    27
    var isHead = parseInt(sourcelines.dataset.ishead || "0");
a298f5c61b34 hgweb: do not show "descending" link in followlines UI for filelog heads
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31940
diff changeset
    28
31849
5c1abb4bd3ee hgweb: position the "followlines" box close to latest cursor position
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31848
diff changeset
    29
    //* position "element" on top-right of cursor */
5c1abb4bd3ee hgweb: position the "followlines" box close to latest cursor position
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31848
diff changeset
    30
    function positionTopRight(element, event) {
5c1abb4bd3ee hgweb: position the "followlines" box close to latest cursor position
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31848
diff changeset
    31
        var x = (event.clientX + 10) + 'px',
5c1abb4bd3ee hgweb: position the "followlines" box close to latest cursor position
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31848
diff changeset
    32
            y = (event.clientY - 20) + 'px';
5c1abb4bd3ee hgweb: position the "followlines" box close to latest cursor position
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31848
diff changeset
    33
        element.style.top = y;
5c1abb4bd3ee hgweb: position the "followlines" box close to latest cursor position
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31848
diff changeset
    34
        element.style.left = x;
5c1abb4bd3ee hgweb: position the "followlines" box close to latest cursor position
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31848
diff changeset
    35
    }
5c1abb4bd3ee hgweb: position the "followlines" box close to latest cursor position
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31848
diff changeset
    36
32995
7c82bfd55d47 hgweb: parameterize the tag name of elements holding followlines selection
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32071
diff changeset
    37
    // retrieve all direct *selectable* children of class="sourcelines"
7c82bfd55d47 hgweb: parameterize the tag name of elements holding followlines selection
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32071
diff changeset
    38
    // element
7c82bfd55d47 hgweb: parameterize the tag name of elements holding followlines selection
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32071
diff changeset
    39
    var selectableElements = Array.prototype.filter.call(
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    40
        sourcelines.children,
35020
75013952d8d9 hgweb: add missing semicolons to followlines.js
Anton Shestakov <av6@dwimlabs.net>
parents: 33390
diff changeset
    41
        function(x) { return x.tagName === selectableTag; });
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    42
33390
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    43
    var btnTitleStart = 'start following lines history from here';
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    44
    var btnTitleEnd = 'terminate line block selection here';
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    45
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    46
    //** return a <button> element with +/- spans */
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    47
    function createButton() {
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    48
        var btn = document.createElement('button');
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    49
        btn.title = btnTitleStart;
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    50
        btn.classList.add('btn-followlines');
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    51
        var plusSpan = document.createElement('span');
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    52
        plusSpan.classList.add('followlines-plus');
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    53
        plusSpan.textContent = '+';
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    54
        btn.appendChild(plusSpan);
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    55
        var br = document.createElement('br');
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    56
        btn.appendChild(br);
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    57
        var minusSpan = document.createElement('span');
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    58
        minusSpan.classList.add('followlines-minus');
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    59
        minusSpan.textContent = '−';
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    60
        btn.appendChild(minusSpan);
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    61
        return btn;
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    62
    }
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    63
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    64
    // extend DOM with CSS class for selection highlight and action buttons
35020
75013952d8d9 hgweb: add missing semicolons to followlines.js
Anton Shestakov <av6@dwimlabs.net>
parents: 33390
diff changeset
    65
    var followlinesButtons = [];
32995
7c82bfd55d47 hgweb: parameterize the tag name of elements holding followlines selection
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32071
diff changeset
    66
    for (var i = 0; i < selectableElements.length; i++) {
7c82bfd55d47 hgweb: parameterize the tag name of elements holding followlines selection
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32071
diff changeset
    67
        selectableElements[i].classList.add('followlines-select');
33390
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    68
        var btn = createButton();
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    69
        followlinesButtons.push(btn);
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    70
        // insert the <button> as child of `selectableElements[i]` unless the
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    71
        // latter has itself a child  with a "followlines-btn-parent" class
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    72
        // (annotate view)
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    73
        var btnSupportElm = selectableElements[i];
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    74
        var childSupportElms = btnSupportElm.getElementsByClassName(
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    75
            'followlines-btn-parent');
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    76
        if ( childSupportElms.length > 0 ) {
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    77
            btnSupportElm = childSupportElms[0];
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    78
        }
37491
685ad41feba0 hgweb: insert followlines buttons before any children, including text nodes
Anton Shestakov <av6@dwimlabs.net>
parents: 35156
diff changeset
    79
        var refNode = btnSupportElm.childNodes[0]; // node to insert <button> before
33390
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    80
        btnSupportElm.insertBefore(btn, refNode);
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    81
    }
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    82
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    83
    // ** re-initialize followlines buttons */
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    84
    function resetButtons() {
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    85
        for (var i = 0; i < followlinesButtons.length; i++) {
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    86
            var btn = followlinesButtons[i];
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    87
            btn.title = btnTitleStart;
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    88
            btn.classList.remove('btn-followlines-end');
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    89
            btn.classList.remove('btn-followlines-hidden');
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
    90
        }
31784
02eb52e9d413 hgweb: rely on a specific class to change cursor type in followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31783
diff changeset
    91
    }
02eb52e9d413 hgweb: rely on a specific class to change cursor type in followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31783
diff changeset
    92
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    93
    var lineSelectedCSSClass = 'followlines-selected';
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    94
32995
7c82bfd55d47 hgweb: parameterize the tag name of elements holding followlines selection
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32071
diff changeset
    95
    //** add CSS class on selectable elements in `from`-`to` line range */
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    96
    function addSelectedCSSClass(from, to) {
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    97
        for (var i = from; i <= to; i++) {
32995
7c82bfd55d47 hgweb: parameterize the tag name of elements holding followlines selection
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32071
diff changeset
    98
            selectableElements[i].classList.add(lineSelectedCSSClass);
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
    99
        }
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   100
    }
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   101
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   102
    //** remove CSS class from previously selected lines */
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   103
    function removeSelectedCSSClass() {
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   104
        var elements = sourcelines.getElementsByClassName(
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   105
            lineSelectedCSSClass);
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   106
        while (elements.length) {
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   107
            elements[0].classList.remove(lineSelectedCSSClass);
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   108
        }
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   109
    }
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   110
32995
7c82bfd55d47 hgweb: parameterize the tag name of elements holding followlines selection
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32071
diff changeset
   111
    // ** return the element of type "selectableTag" parent of `element` */
7c82bfd55d47 hgweb: parameterize the tag name of elements holding followlines selection
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32071
diff changeset
   112
    function selectableParent(element) {
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   113
        var parent = element.parentElement;
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   114
        if (parent === null) {
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   115
            return null;
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   116
        }
35156
9f44d44626a0 hgweb: use strict equals, remove non-breaking space in followlines.js
Anton Shestakov <av6@dwimlabs.net>
parents: 35020
diff changeset
   117
        if (element.tagName === selectableTag && parent.isSameNode(sourcelines)) {
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   118
            return element;
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   119
        }
32995
7c82bfd55d47 hgweb: parameterize the tag name of elements holding followlines selection
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32071
diff changeset
   120
        return selectableParent(parent);
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   121
    }
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   122
33390
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   123
    // ** update buttons title and style upon first click */
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   124
    function updateButtons(selectable) {
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   125
        for (var i = 0; i < followlinesButtons.length; i++) {
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   126
            var btn = followlinesButtons[i];
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   127
            btn.title = btnTitleEnd;
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   128
            btn.classList.add('btn-followlines-end');
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   129
        }
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   130
        // on clicked button, change title to "cancel"
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   131
        var clicked = selectable.getElementsByClassName('btn-followlines')[0];
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   132
        clicked.title = 'cancel';
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   133
        clicked.classList.remove('btn-followlines-end');
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   134
    }
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   135
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   136
    //** add `listener` on "click" event for all `followlinesButtons` */
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   137
    function buttonsAddEventListener(listener) {
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   138
        for (var i = 0; i < followlinesButtons.length; i++) {
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   139
            followlinesButtons[i].addEventListener('click', listener);
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   140
        }
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   141
    }
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   142
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   143
    //** remove `listener` on "click" event for all `followlinesButtons` */
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   144
    function buttonsRemoveEventListener(listener) {
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   145
        for (var i = 0; i < followlinesButtons.length; i++) {
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   146
            followlinesButtons[i].removeEventListener('click', listener);
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   147
        }
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   148
    }
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   149
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   150
    //** event handler for "click" on the first line of a block */
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   151
    function lineSelectStart(e) {
33390
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   152
        var startElement = selectableParent(e.target.parentElement);
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   153
        if (startElement === null) {
32995
7c82bfd55d47 hgweb: parameterize the tag name of elements holding followlines selection
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32071
diff changeset
   154
            // not a "selectable" element (maybe <a>): abort, keeping event
7c82bfd55d47 hgweb: parameterize the tag name of elements holding followlines selection
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32071
diff changeset
   155
            // listener registered for other click with a "selectable" target
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   156
            return;
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   157
        }
31848
7160bdd56b84 hgweb: add a floating tooltip to invite on followlines action
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31785
diff changeset
   158
33390
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   159
        // update button tooltip text and CSS
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   160
        updateButtons(startElement);
31848
7160bdd56b84 hgweb: add a floating tooltip to invite on followlines action
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31785
diff changeset
   161
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   162
        var startId = parseInt(startElement.id.slice(1));
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   163
        startElement.classList.add(lineSelectedCSSClass); // CSS
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   164
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   165
        // remove this event listener
33390
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   166
        buttonsRemoveEventListener(lineSelectStart);
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   167
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   168
        //** event handler for "click" on the last line of the block */
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   169
        function lineSelectEnd(e) {
33390
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   170
            var endElement = selectableParent(e.target.parentElement);
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   171
            if (endElement === null) {
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   172
                // not a <span> (maybe <a>): abort, keeping event listener
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   173
                // registered for other click with <span> target
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   174
                return;
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   175
            }
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   176
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   177
            // remove this event listener
33390
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   178
            buttonsRemoveEventListener(lineSelectEnd);
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   179
33390
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   180
            // reset button tooltip text
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   181
            resetButtons();
31848
7160bdd56b84 hgweb: add a floating tooltip to invite on followlines action
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31785
diff changeset
   182
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   183
            // compute line range (startId, endId)
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   184
            var endId = parseInt(endElement.id.slice(1));
35156
9f44d44626a0 hgweb: use strict equals, remove non-breaking space in followlines.js
Anton Shestakov <av6@dwimlabs.net>
parents: 35020
diff changeset
   185
            if (endId === startId) {
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   186
                // clicked twice the same line, cancel and reset initial state
33390
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   187
                // (CSS, event listener for selection start)
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   188
                removeSelectedCSSClass();
33390
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   189
                buttonsAddEventListener(lineSelectStart);
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   190
                return;
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   191
            }
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   192
            var inviteElement = endElement;
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   193
            if (endId < startId) {
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   194
                var tmp = endId;
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   195
                endId = startId;
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   196
                startId = tmp;
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   197
                inviteElement = startElement;
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   198
            }
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   199
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   200
            addSelectedCSSClass(startId - 1, endId -1);  // CSS
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   201
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   202
            // append the <div id="followlines"> element to last line of the
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   203
            // selection block
32070
a298f5c61b34 hgweb: do not show "descending" link in followlines UI for filelog heads
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31940
diff changeset
   204
            var divAndButton = followlinesBox(targetUri, startId, endId, isHead);
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   205
            var div = divAndButton[0],
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   206
                button = divAndButton[1];
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   207
            inviteElement.appendChild(div);
31849
5c1abb4bd3ee hgweb: position the "followlines" box close to latest cursor position
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31848
diff changeset
   208
            // set position close to cursor (top-right)
5c1abb4bd3ee hgweb: position the "followlines" box close to latest cursor position
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31848
diff changeset
   209
            positionTopRight(div, e);
33390
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   210
            // hide all buttons
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   211
            for (var i = 0; i < followlinesButtons.length; i++) {
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   212
                followlinesButtons[i].classList.add('btn-followlines-hidden');
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   213
            }
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   214
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   215
            //** event handler for cancelling selection */
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   216
            function cancel() {
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   217
                // remove invite box
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   218
                div.parentNode.removeChild(div);
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   219
                // restore initial event listeners
33390
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   220
                buttonsAddEventListener(lineSelectStart);
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   221
                buttonsRemoveEventListener(cancel);
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   222
                for (var i = 0; i < followlinesButtons.length; i++) {
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   223
                    followlinesButtons[i].classList.remove('btn-followlines-hidden');
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   224
                }
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   225
                // remove styles on selected lines
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   226
                removeSelectedCSSClass();
33390
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   227
                resetButtons();
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   228
            }
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   229
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   230
            // bind cancel event to click on <button>
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   231
            button.addEventListener('click', cancel);
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   232
            // as well as on an click on any source line
33390
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   233
            buttonsAddEventListener(cancel);
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   234
        }
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   235
33390
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   236
        buttonsAddEventListener(lineSelectEnd);
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   237
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   238
    }
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   239
33390
32331f54930c hgweb: re-implement followlines UI selection using buttons
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32995
diff changeset
   240
    buttonsAddEventListener(lineSelectStart);
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   241
31783
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   242
    //** return a <div id="followlines"> and inner cancel <button> elements */
32070
a298f5c61b34 hgweb: do not show "descending" link in followlines UI for filelog heads
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31940
diff changeset
   243
    function followlinesBox(targetUri, fromline, toline, isHead) {
31783
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   244
        // <div id="followlines">
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   245
        var div = document.createElement('div');
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   246
        div.id = 'followlines';
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   247
31783
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   248
        //   <div class="followlines-cancel">
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   249
        var buttonDiv = document.createElement('div');
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   250
        buttonDiv.classList.add('followlines-cancel');
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   251
31783
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   252
        //     <button>x</button>
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   253
        var button = document.createElement('button');
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   254
        button.textContent = 'x';
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   255
        buttonDiv.appendChild(button);
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   256
        div.appendChild(buttonDiv);
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   257
31783
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   258
        //   <div class="followlines-link">
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   259
        var aDiv = document.createElement('div');
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   260
        aDiv.classList.add('followlines-link');
31940
6ce09d2cc2db hgweb: add a link to followlines in descending direction
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31849
diff changeset
   261
        aDiv.textContent = 'follow history of lines ' + fromline + ':' + toline + ':';
6ce09d2cc2db hgweb: add a link to followlines in descending direction
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31849
diff changeset
   262
        var linesep = document.createElement('br');
6ce09d2cc2db hgweb: add a link to followlines in descending direction
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31849
diff changeset
   263
        aDiv.appendChild(linesep);
6ce09d2cc2db hgweb: add a link to followlines in descending direction
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31849
diff changeset
   264
        //     link to "ascending" followlines
6ce09d2cc2db hgweb: add a link to followlines in descending direction
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31849
diff changeset
   265
        var aAsc = document.createElement('a');
31783
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   266
        var url = targetUri + '?patch=&linerange=' + fromline + ':' + toline;
31940
6ce09d2cc2db hgweb: add a link to followlines in descending direction
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31849
diff changeset
   267
        aAsc.setAttribute('href', url);
32071
1cf0b651fa70 hgweb: change text of followlines links to "older / newer"
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32070
diff changeset
   268
        aAsc.textContent = 'older';
31940
6ce09d2cc2db hgweb: add a link to followlines in descending direction
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31849
diff changeset
   269
        aDiv.appendChild(aAsc);
32070
a298f5c61b34 hgweb: do not show "descending" link in followlines UI for filelog heads
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31940
diff changeset
   270
a298f5c61b34 hgweb: do not show "descending" link in followlines UI for filelog heads
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31940
diff changeset
   271
        if (!isHead) {
a298f5c61b34 hgweb: do not show "descending" link in followlines UI for filelog heads
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31940
diff changeset
   272
            var sep = document.createTextNode(' / ');
a298f5c61b34 hgweb: do not show "descending" link in followlines UI for filelog heads
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31940
diff changeset
   273
            aDiv.appendChild(sep);
a298f5c61b34 hgweb: do not show "descending" link in followlines UI for filelog heads
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31940
diff changeset
   274
            //     link to "descending" followlines
a298f5c61b34 hgweb: do not show "descending" link in followlines UI for filelog heads
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31940
diff changeset
   275
            var aDesc = document.createElement('a');
a298f5c61b34 hgweb: do not show "descending" link in followlines UI for filelog heads
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31940
diff changeset
   276
            aDesc.setAttribute('href', url + '&descend=');
32071
1cf0b651fa70 hgweb: change text of followlines links to "older / newer"
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 32070
diff changeset
   277
            aDesc.textContent = 'newer';
32070
a298f5c61b34 hgweb: do not show "descending" link in followlines UI for filelog heads
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31940
diff changeset
   278
            aDiv.appendChild(aDesc);
a298f5c61b34 hgweb: do not show "descending" link in followlines UI for filelog heads
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31940
diff changeset
   279
        }
31940
6ce09d2cc2db hgweb: add a link to followlines in descending direction
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31849
diff changeset
   280
31783
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   281
        div.appendChild(aDiv);
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   282
31783
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   283
        return [div, button];
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   284
    }
31758
04ec317b8128 hgweb: expose a followlines UI in filerevision view
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
diff changeset
   285
31783
70377de005a0 hgweb: use a function expression for the install listener of followlines UI
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 31758
diff changeset
   286
}, false);