chore: fix some of the luacheck errors

This commit is contained in:
Qingping Hou
2015-04-26 20:49:27 -04:00
parent e695a3c30d
commit 186673587e
22 changed files with 84 additions and 47 deletions

View File

@@ -263,11 +263,8 @@ function ReaderBookmark:getDogearBookmarkIndex(pn_or_xp)
end
function ReaderBookmark:isBookmarkSame(item1, item2)
if item1.notes ~= item2.notes then return end
if item1.notes ~= item2.notes then return false end
if self.ui.document.info.has_pages then
if not item2.pos0 or not item2.pos1 then return end
local zoom1 = item1.pos0.zoom
local zoom1 = item2.pos0.zoom
return item2.pos0 and item2.pos1 and item1.pos0.page == item2.pos0.page
and item1.pos0.x == item2.pos0.x and item1.pos0.y == item2.pos0.y
and item1.pos1.x == item2.pos1.x and item1.pos1.y == item2.pos1.y
@@ -281,7 +278,6 @@ end
function ReaderBookmark:addBookmark(item)
local _start, _middle, _end, direction = 1, 1, #self.bookmarks, 0
while _start <= _end do
local v = self.bookmarks[_middle]
_middle = math.floor((_start + _end)/2)
-- won't add duplicated bookmarks
if self:isBookmarkSame(item, self.bookmarks[_middle]) then
@@ -301,7 +297,6 @@ end
function ReaderBookmark:isBookmarkAdded(item)
local _start, _middle, _end, direction = 1, 1, #self.bookmarks, 0
while _start <= _end do
local v = self.bookmarks[_middle]
_middle = math.floor((_start + _end)/2)
if self:isBookmarkSame(item, self.bookmarks[_middle]) then
return true
@@ -312,6 +307,7 @@ function ReaderBookmark:isBookmarkAdded(item)
_start, direction = _middle + 1, 1
end
end
return false
end
-- binary search to remove bookmark