Skip to content

Commit

Permalink
Feat: two iframes in one page
Browse files Browse the repository at this point in the history
  • Loading branch information
coddingyun committed Oct 11, 2023
1 parent 711e951 commit e927729
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
8 changes: 2 additions & 6 deletions src/common/annotation-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { postApi } from '../custom/utils/apiFetch'

let api = '';
if (process.env.NODE_ENV === 'development'){
api = 'https://be.yeondoo.net'
//api = 'https://be.yeondoo.net'
api = 'https://virtserver.swaggerhub.com/SYLEELSW_1/Yeondoo/2.0'
}
else if (process.env.NODE_ENV === 'production'){
api = `${process.env.VITE_REACT_APP_AWS_SERVER}`
Expand Down Expand Up @@ -60,11 +61,6 @@ class AnnotationManager {
this._onChangeFilter(this._filter);
}

updateSettings(newAnnotations) {
this._annotations = newAnnotations;
this.render();
}

setReadOnly(readOnly) {
this._readOnly = readOnly;
}
Expand Down
5 changes: 5 additions & 0 deletions src/common/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ class Reader {
}
}

changePaper(annotation) {
this._annotationManager._annotations = annotation
this._annotationManager.render()
}

_ensureType() {
if (!Array.from(arguments).includes(this._type)) {
throw new Error(`The operation is not supported for '${this._type}'`);
Expand Down
20 changes: 16 additions & 4 deletions src/index.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ window.dev = true;

let api = '';
if (process.env.NODE_ENV === 'development'){
api = 'https://be.yeondoo.net'
//api = 'https://be.yeondoo.net'
api = 'https://virtserver.swaggerhub.com/SYLEELSW_1/Yeondoo/2.0'
}
else if (process.env.NODE_ENV === 'production'){
api = `${process.env.VITE_REACT_APP_AWS_SERVER}`
Expand All @@ -20,7 +21,7 @@ let reader

let chatNoteList = []

const receiveBasicInfo = (e) => {
const receiveBasicInfo = async(e) => {
if (e.data.workspaceId) {
sessionStorage.setItem('workspaceId', e.data.workspaceId)
}
Expand Down Expand Up @@ -48,7 +49,18 @@ const receiveBasicInfo = (e) => {
delete changeItem.itemType
return changeItem})
sessionStorage.setItem('paperItemsWithTag', JSON.stringify(paperItemsWithTag))
createReader(e.data.paperId, paperItemsWithTag);
if (window._reader) {
console.log(e.data.paperId)
const res = await fetch(`https://browse.arxiv.org/pdf/${e.data.paperId}.pdf`);
const newData = {
buf: new Uint8Array(await res.arrayBuffer()),
url: new URL('/', window.location).toString()
}
reader.changePaper(paperItemsWithTag)
reader.reload(newData)
} else {
createReader(e.data.paperId, paperItemsWithTag);
}
}
if (e.data.chatNote) {
const paperItemsWithTag = JSON.parse(sessionStorage.getItem('paperItemsWithTag'))
Expand Down Expand Up @@ -83,7 +95,7 @@ async function createReader(paperId, paperItems) {
demo = snapshot;
}
let res = await fetch(`https://browse.arxiv.org/pdf/${paperId}.pdf`);
console.log("hihi",Number(sessionStorage.getItem('workspaceId')))
// console.log("hihi",Number(sessionStorage.getItem('workspaceId')))
// console.log("location!!",window.location)
// console.log(window.location)
reader = new Reader({
Expand Down

0 comments on commit e927729

Please sign in to comment.