Skip to content

Commit

Permalink
support pjax
Browse files Browse the repository at this point in the history
  • Loading branch information
DesertsP committed Mar 3, 2019
1 parent dece7dc commit 3032d59
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/Valine.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/Valine.min.js.map

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions src/Valine.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Valine {
let _root = this;
let av = option.av || AV;
// disable_av_init = option.disable_av_init || false;
defaultComment['url'] = option.pathname || location.pathname;
defaultComment['url'] = option.pathname || location.pathname.replace(/\/$/, '');
try {
let el = toString.call(option.el) === "[object HTMLDivElement]" ? option.el : document.querySelectorAll(option.el)[0];
if (toString.call(el) != '[object HTMLDivElement]') {
Expand Down Expand Up @@ -197,8 +197,11 @@ class Valine {
}

_root.loading.show();
var query = new _root.v.Query('Comment');
query.equalTo('url', defaultComment['url']);
let query1 = new _root.v.Query('Comment');
query1.equalTo('url', defaultComment['url']);
let query2 = new _root.v.Query('Comment');
query2.equalTo('url', defaultComment['url'] + '/');
let query = AV.Query.or(query1, query2);
query.count().then(function (count) {
_root.el.querySelector('.count').innerHTML = `${count}`;
_root.bind(option);
Expand Down Expand Up @@ -261,10 +264,13 @@ class Valine {
};

let commonQuery = () => {
let query = new _root.v.Query('Comment');
query.select(['nick', 'comment', 'link', 'rid', 'emailHash']);
let query1 = new _root.v.Query('Comment');
query1.equalTo('url', defaultComment['url']);
let query2 = new _root.v.Query('Comment');
query2.equalTo('url', defaultComment['url'] + '/');
let query = AV.Query.or(query1, query2);
query.notEqualTo('isSpam', true);
query.equalTo('url', defaultComment['url']);
query.select(['nick', 'comment', 'link', 'rid', 'emailHash']);
query.addDescending('createdAt');
return query;
};
Expand Down

0 comments on commit 3032d59

Please sign in to comment.