New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chore: Add Annotations test page to be hosted by github pages #294
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width"> | ||
<link rel="stylesheet" href='./styles.css' /> | ||
<link rel="stylesheet" href='https://cdn01.boxcdn.net/platform/preview/1.58.2/en-US/preview.css' /> | ||
<link rel="stylesheet" href='https://unpkg.com/box-annotations@3.3.0/lib/annotations.css' /> | ||
<script src='https://cdn01.boxcdn.net/platform/preview/1.58.2/en-US/preview.js'></script> | ||
<script src='https://unpkg.com/box-annotations@3.3.0/lib/annotations.js'></script> | ||
|
||
|
||
</head> | ||
|
||
<body> | ||
<div class='setters-container'> | ||
<div class='container' id='token'> | ||
<div> Token: <span id='token-display'></span> </div> | ||
<input id='token-set' placeholder='Enter token' /> | ||
<button onClick="setProperty('token')">Set new token</button> | ||
</div> | ||
|
||
<div class='container' id='file'> | ||
<div> File ID: <span id='fileid-display'></span></div> | ||
<input id='fileid-set' placeholder='Enter file ID' /> | ||
<button onClick="setProperty('fileid')">Set new file ID</button> | ||
</div> | ||
</div> | ||
|
||
<div class='preview-container'> </div> | ||
<script> | ||
function setProperty(selector) { | ||
// Get new value, fallback to local storage | ||
const inputValue = document.querySelector('#' + selector + '-set') | ||
value = inputValue && inputValue.value || localStorage.getItem(selector); | ||
|
||
|
||
if (!value) { | ||
return; | ||
} | ||
|
||
// Set it for display purposes | ||
displayElement = document.querySelector('#' + selector + '-display'); | ||
displayElement.textContent = value; | ||
|
||
// Cache it in local storage | ||
localStorage.setItem(selector, value) | ||
|
||
// Attempt to load Preview + Annotations | ||
loadPreview(); | ||
} | ||
|
||
function loadPreview() { | ||
const token = localStorage.getItem('token'); | ||
const fileid = localStorage.getItem('fileid'); | ||
|
||
if ( !token || !fileid) { | ||
return; | ||
} | ||
|
||
// Load Preview + Annotations with the passed in file ID | ||
const options = { | ||
Image: { | ||
enabledTypes: ["point"] | ||
}, | ||
Document: { | ||
enabledTypes: ["draw", "point", "highlight-comment", "highlight"] | ||
}, | ||
Presentation: { | ||
enabledTypes: ["draw", "point", "highlight-comment", "highlight"] | ||
} | ||
}; | ||
|
||
/* global BoxAnnotations */ | ||
const boxAnnotations = new BoxAnnotations(options); | ||
|
||
/* global Box */ | ||
var preview = new Box.Preview(); | ||
preview.show(fileid, token, { | ||
container: ".preview-container", | ||
boxAnnotations | ||
}); | ||
|
||
} | ||
|
||
// Try to load all properties from storage on page load | ||
setProperty('token'); | ||
setProperty('fileid'); | ||
</script> | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
* { | ||
font-family: sans-serif; | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
} | ||
.setters-container { | ||
height: 25vh; | ||
display: flex; | ||
font-size: 75%; | ||
justify-content: space-around; | ||
padding: 20px; | ||
} | ||
|
||
.setters-container button,input { | ||
padding: 5px; | ||
} | ||
|
||
.container { | ||
text-align: center; | ||
} | ||
|
||
.container > input { | ||
text-align: center; | ||
} | ||
|
||
#preview-container { | ||
width: 100vw; | ||
height: 75vh; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually we can pass in a version, but for now we can just make a commit here when doing a release