Skip to content
This repository has been archived by the owner on Oct 17, 2019. It is now read-only.

Commit

Permalink
feat: 自動で読み込み
Browse files Browse the repository at this point in the history
* 通知とアカウントページは引っ張り更新と競合してバグる
  • Loading branch information
nzws committed Sep 4, 2018
1 parent 5d07115 commit 948916e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 31 deletions.
8 changes: 4 additions & 4 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ <h4 id="splitter-profile-name" class="acct-small" style="height: 20px"></h4>
</ons-template>

<ons-template id="alert.html">
<ons-page>
<ons-page id="alert-page">
<ons-toolbar>
<div class="left" id="alert_button">
<ons-toolbar-button onclick="fn.open()">
Expand Down Expand Up @@ -1729,7 +1729,7 @@ <h4><span data-i18n="config.notification.keyword.title">キーワード検知</s
</ons-page>
</ons-template>
<ons-template id="showtag.html">
<ons-page>
<ons-page id="showtag-page">
<ons-toolbar>
<div class="left">
<ons-toolbar-button onclick="BackTab()">
Expand Down Expand Up @@ -1757,7 +1757,7 @@ <h4><span data-i18n="config.notification.keyword.title">キーワード検知</s
</ons-page>
</ons-template>
<ons-template id="olist.html">
<ons-page>
<ons-page id="olist">
<ons-toolbar>
<div class="left">
<ons-toolbar-button onclick="fn.open()">
Expand All @@ -1774,7 +1774,7 @@ <h4><span data-i18n="config.notification.keyword.title">キーワード検知</s
</ons-page>
</ons-template>
<ons-template id="olist_nav.html">
<ons-page>
<ons-page id="olist_nav">
<ons-toolbar>
<div class="left">
<ons-toolbar-button onclick="BackTab()">
Expand Down
12 changes: 12 additions & 0 deletions www/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,18 @@ function initevent() {
if (event.enterPage.id === 'lists-page') {
renderListsCollection();
}

if (event.enterPage.id === 'olist' || event.enterPage.id === 'olist_nav') {
event.enterPage.onInfiniteScroll = function(done) {
list_n(null, null, done, null, event.enterPage.id === 'olist_nav');
};
}

if (event.enterPage.id === 'showtag-page') {
event.enterPage.onInfiniteScroll = function(done) {
showTagTL(null, done);
};
}
});

document.addEventListener('postpop', function(event) {
Expand Down
45 changes: 22 additions & 23 deletions www/js/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ function list_n(mode, title, more_load, mode_toot, navmode) {
pin;
var id_title, id_main;
if (more_load) {
if (!list_old_id[0]) {
setTimeout(function() {
more_load();
}, 500);
return;
}
get = '?' + list_old_id[0];
more_load.value = 'Loading now...';
more_load.disabled = true;
}
if (mode === 'pin') {
pin = true;
Expand All @@ -40,17 +44,17 @@ function list_n(mode, title, more_load, mode_toot, navmode) {
id_title = 'olist_title';
id_main = 'olist_main';
}
if (!mode && more_load) {
mode = elemId(id_main).mode;
mode_toot = elemId(id_main).mode_toot;
}
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200 || xhr.status === 304) {
var json = JSON.parse(xhr.responseText);
if (more_load) {
more_load.className = 'button button--large--quiet invisible';
reshtml = elemId(id_main).innerHTML;
} else {
elemId(id_title).innerHTML = title.match(/\./i) ? i18next.t(title) : title;
}
if (more_load) reshtml = elemId(id_main).innerHTML;
else elemId(id_title).innerHTML = title.match(/\./i) ? i18next.t(title) : title;

while (json[i]) {
if (mode_toot === 'toot') {
Expand Down Expand Up @@ -83,26 +87,21 @@ function list_n(mode, title, more_load, mode_toot, navmode) {
list_old_id = xhr.getResponseHeader('link').match(/max_id=\d+/);
else list_old_id = '';

if (!more_load) {
elemId(id_main).mode = mode;
elemId(id_main).mode_toot = mode_toot;
elemId(id_main).navmode = navmode;
}

if (pin === true) mode = 'pin';
if (list_old_id !== '')
reshtml +=
"<button class='button button--large--quiet' onclick='list_n(\"" +
mode +
'", "' +
title +
'", this, "' +
mode_toot +
'", ' +
navmode +
")'>" +
i18next.t('navigation.load_more') +
'</button>';

elemId(id_main).innerHTML = reshtml;
return true;
} else {
showtoast('cannot-load');
return false;
}
setTimeout(function() {
if (more_load) more_load();
}, 500);
}
};
xhr.open('GET', 'https://' + inst + '/api/v1/' + mode + get, false);
Expand Down
5 changes: 1 addition & 4 deletions www/js/timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -638,11 +638,8 @@ function showTagTL(tag, more_load) {
}

if (i !== 0) tag_old_id = json[i - 1]['id'];
reshtml +=
"<button class='button button--large--quiet' onclick='showTagTL(null,this)'>" +
i18next.t('navigation.load_more') +
'</button>';
elemId('tag_main').innerHTML = reshtml;
if (more_load) more_load();
return true;
}
})
Expand Down

0 comments on commit 948916e

Please sign in to comment.