-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
189 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
from app.main.checks.base_check import BaseCheck, answer | ||
|
||
class SearchKeyWord(BaseCheck): | ||
def __init__(self, presentation, key_slide): | ||
def __init__(self, presentation, key_slide, pdf_id): | ||
super().__init__(presentation) | ||
self.key_slide = key_slide | ||
self.pdf_id = pdf_id | ||
|
||
def check(self): | ||
for i, text in enumerate(self.presentation.get_text_from_slides(), 1): | ||
if self.key_slide.lower() in str(text).lower(): | ||
return answer(True, i, 'Найден под номером: {}'.format(i)) | ||
found = self.format_page_link([i]) | ||
return answer(True, i, 'Найден под номером: {}'.format(', '.join(map(str, found)))) | ||
return answer(False, None, 'Слайд не найден') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,87 @@ | ||
import '../styles/results.css'; | ||
import * as pdfjsLib from 'pdfjs-dist'; | ||
import pdfjsWorker from "pdfjs-dist/build/pdf.worker.entry"; | ||
|
||
let pdfDoc, | ||
pageNum, | ||
pageIsRendering, | ||
pageNumIsPending, | ||
scale, | ||
canvas, | ||
ctx, | ||
currentPage; | ||
|
||
pdfjsLib.GlobalWorkerOptions.workerSrc = pdfjsWorker; | ||
|
||
const renderPage = num => { | ||
pageIsRendering = true; | ||
|
||
pdfDoc.getPage(num).then(page => { | ||
const viewport = page.getViewport({ scale }); | ||
canvas.height = viewport.height; | ||
canvas.width = viewport.width; | ||
|
||
const renderCtx = { | ||
canvasContext: ctx, | ||
viewport | ||
}; | ||
|
||
page.render(renderCtx).promise.then(() => { | ||
pageIsRendering = false; | ||
|
||
if (pageNumIsPending !== null) { | ||
renderPage(pageNumIsPending); | ||
pageNumIsPending = null; | ||
} | ||
}); | ||
|
||
$('#page-num')[0].textContent = num; | ||
}); | ||
}; | ||
|
||
const queueRenderPage = num => { | ||
if (pageIsRendering) { | ||
pageNumIsPending = num; | ||
} else { | ||
renderPage(num); | ||
} | ||
}; | ||
|
||
const showPrevPage = () => { | ||
if (pageNum <= 1) { | ||
return; | ||
} | ||
pageNum--; | ||
queueRenderPage(pageNum); | ||
}; | ||
|
||
const showNextPage = () => { | ||
if (pageNum >= pdfDoc.numPages) { | ||
return; | ||
} | ||
pageNum++; | ||
queueRenderPage(pageNum); | ||
}; | ||
|
||
if ($("#pdf").length !== 0){ | ||
var href = $("#pdf").attr('href'); | ||
pdfDoc = null; | ||
pageNum = 1; | ||
pageIsRendering = false, | ||
pageNumIsPending = null; | ||
scale = 1.1; | ||
canvas = $("#the-canvas")[0]; | ||
ctx = canvas.getContext("2d"); | ||
|
||
pdfjsLib | ||
.getDocument(href) | ||
.promise.then(pdfDoc_ => { | ||
pdfDoc = pdfDoc_; | ||
|
||
$('#page-count')[0].textContent = pdfDoc.numPages; | ||
renderPage(pageNum); | ||
}); | ||
|
||
$('#prev-page').click(showPrevPage); | ||
$('#next-page').click(showNextPage); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.