mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
hgweb: make infinite scroll handling more generic and extensible
Namely, this allows the next page pointer to be not only revision hash given in page code, but also any value computed from the value for previous page.
This commit is contained in:
parent
ee2943c680
commit
f0c93d06c2
@ -74,9 +74,12 @@ files, or words in the commit message</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
ajaxScrollInit(
|
||||
'{url|urlescape}shortlog/%hash%',
|
||||
'{url|urlescape}shortlog/%next%',
|
||||
'{nextentry%"{node}"}', <!-- NEXTHASH
|
||||
/'(\w+)', <!-- NEXTHASH/,
|
||||
function (htmlText, previousVal) \{
|
||||
var m = htmlText.match(/'(\w+)', <!-- NEXTHASH/);
|
||||
return m ? m[1] : null;
|
||||
},
|
||||
'.bigtable > tbody:nth-of-type(2)',
|
||||
'<tr class="%class%">\
|
||||
<td colspan="3" style="text-align: center;">%text%</td>\
|
||||
|
@ -355,8 +355,8 @@ function appendFormatHTML(element, formatStr, replacements) {
|
||||
}
|
||||
|
||||
function ajaxScrollInit(urlFormat,
|
||||
nextHash,
|
||||
nextHashRegex,
|
||||
nextPageVar,
|
||||
nextPageVarGet,
|
||||
containerSelector,
|
||||
messageFormat) {
|
||||
updateInitiated = false;
|
||||
@ -377,7 +377,7 @@ function ajaxScrollInit(urlFormat,
|
||||
removeByClassName('scroll-loading-error');
|
||||
container.lastElementChild.classList.add('scroll-separator');
|
||||
|
||||
if (!nextHash) {
|
||||
if (!nextPageVar) {
|
||||
var message = {
|
||||
class: 'scroll-loading-info',
|
||||
text: 'No more entries'
|
||||
@ -387,7 +387,7 @@ function ajaxScrollInit(urlFormat,
|
||||
}
|
||||
|
||||
makeRequest(
|
||||
format(urlFormat, {hash: nextHash}),
|
||||
format(urlFormat, {next: nextPageVar}),
|
||||
'GET',
|
||||
function onstart() {
|
||||
var message = {
|
||||
@ -397,8 +397,7 @@ function ajaxScrollInit(urlFormat,
|
||||
appendFormatHTML(container, messageFormat, message);
|
||||
},
|
||||
function onsuccess(htmlText) {
|
||||
var m = htmlText.match(nextHashRegex);
|
||||
nextHash = m ? m[1] : null;
|
||||
nextPageVar = nextPageVarGet(htmlText, nextPageVar);
|
||||
|
||||
var doc = docFromHTML(htmlText);
|
||||
var nodes = doc.querySelector(containerSelector).children;
|
||||
|
@ -307,9 +307,12 @@ Logs and changes
|
||||
|
||||
<script type="text/javascript">
|
||||
ajaxScrollInit(
|
||||
'/shortlog/%hash%',
|
||||
'/shortlog/%next%',
|
||||
'', <!-- NEXTHASH
|
||||
/'(\w+)', <!-- NEXTHASH/,
|
||||
function (htmlText, previousVal) {
|
||||
var m = htmlText.match(/'(\w+)', <!-- NEXTHASH/);
|
||||
return m ? m[1] : null;
|
||||
},
|
||||
'.bigtable > tbody:nth-of-type(2)',
|
||||
'<tr class="%class%">\
|
||||
<td colspan="3" style="text-align: center;">%text%</td>\
|
||||
|
@ -92,9 +92,12 @@ Some tests for hgweb in an empty repository
|
||||
|
||||
<script type="text/javascript">
|
||||
ajaxScrollInit(
|
||||
'/shortlog/%hash%',
|
||||
'/shortlog/%next%',
|
||||
'', <!-- NEXTHASH
|
||||
/'(\w+)', <!-- NEXTHASH/,
|
||||
function (htmlText, previousVal) {
|
||||
var m = htmlText.match(/'(\w+)', <!-- NEXTHASH/);
|
||||
return m ? m[1] : null;
|
||||
},
|
||||
'.bigtable > tbody:nth-of-type(2)',
|
||||
'<tr class="%class%">\
|
||||
<td colspan="3" style="text-align: center;">%text%</td>\
|
||||
@ -199,9 +202,12 @@ Some tests for hgweb in an empty repository
|
||||
|
||||
<script type="text/javascript">
|
||||
ajaxScrollInit(
|
||||
'/shortlog/%hash%',
|
||||
'/shortlog/%next%',
|
||||
'', <!-- NEXTHASH
|
||||
/'(\w+)', <!-- NEXTHASH/,
|
||||
function (htmlText, previousVal) {
|
||||
var m = htmlText.match(/'(\w+)', <!-- NEXTHASH/);
|
||||
return m ? m[1] : null;
|
||||
},
|
||||
'.bigtable > tbody:nth-of-type(2)',
|
||||
'<tr class="%class%">\
|
||||
<td colspan="3" style="text-align: center;">%text%</td>\
|
||||
|
Loading…
Reference in New Issue
Block a user