Skip to content

Commit

Permalink
Merge pull request tdiary#166 from tdiary/fix_161_3rd
Browse files Browse the repository at this point in the history
fix tdiary#161: refresh the preview element except plugin error
  • Loading branch information
tdtds committed May 24, 2016
2 parents 17241bd + 51926e5 commit 4b18092
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions js/preview.js
Expand Up @@ -15,19 +15,24 @@ $tDiary.plugin.preview.reload = function() {
'update.rb',
$('form.update').serialize() + "&appendpreview=1",
function(data) {
$('div.autopagerize_page_element').replaceWith(
$(data).find('div.autopagerize_page_element')
);
var previewContent = $(data).find('div.autopagerize_page_element');
if (previewContent.size() != 0) {
$('div.autopagerize_page_element').replaceWith(previewContent);
intervalRate = 1;
} else {
intervalRate *= 2;
console.info('[preview.js] update failed, the next update will be after '
+ $tDiary.plugin.preview.interval * intervalRate + 'sec.');
}
$('div.day')
.css('flex', "1 1 " + $tDiary.plugin.preview.minWidth / 2 + "px");
},
'html'
)
.done(function() {
intervalRate = 1;
})
.fail(function() {
intervalRate *= 2;
console.info('[preview.js] update failed, the next update will be after '
+ $tDiary.plugin.preview.interval * intervalRate + 'sec.');
})
.always(function() {
previewButton.prop("disabled", false);
Expand Down

0 comments on commit 4b18092

Please sign in to comment.