Skip to content
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

bump niimath version and enable some safari on tablet and desktop #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,40 @@ const pipelinesBaseUrl = new URL(`${viteBaseUrl}pipelines`, document.location.or
setCuberillePipelinesUrl(pipelinesBaseUrl)
setMeshFiltersPipelinesUrl(pipelinesBaseUrl)

function isDesktopModeiPad() {
const ua = navigator.userAgent;
return (
ua.includes("Macintosh") &&
navigator.maxTouchPoints &&
navigator.maxTouchPoints > 1
);
}

function getAppleDeviceType() {
const ua = navigator.userAgent;
console.log(ua)

// test for desktop based safari
if (ua.includes("Macintosh")) {
return true
}

if (/iPad/.test(ua)) {
return true
}

if (isDesktopModeiPad()) {
return true
}

if (/iPhone/.test(ua)) {
alert("brain2print is not supported on some mobile devices yet. Please use a desktop browser or tablet.")
return false
}

return false
}

async function main() {
const niimath = new Niimath()
await niimath.init()
Expand Down Expand Up @@ -304,7 +338,19 @@ async function main() {
}
nv1.onImageLoaded = doLoadImage
modelSelect.selectedIndex = -1
workerCheck.checked = await isChrome(); //TODO: Safari does not yet support WebGL TFJS webworkers, test FireFox
// workerCheck.checked = await isChrome(); TODO: test firefox
// modern iPadOS Safari requests the site as if it were a desktop browser by default,
// and these devices are more capable than iPhones so we should allow them.
// Desktop Safari is also supported.
workerCheck.checked = getAppleDeviceType()
// now check for isChrome
workerCheck.checked = !workerCheck.checked ? await isChrome() : workerCheck.checked
// if the worker is not checked, then no segmentation will be performed.
// Previously this was a silent failure, but it is probably better to alert the user.
if (!workerCheck.checked) {
alert("brain2print may not be able to reliably run segmentation in your browser. Segmentation will not be performed.")
}

console.log('brain2print 20241218')
// uncomment next two lines to automatically run segmentation when web page is loaded
// modelSelect.selectedIndex = 11
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
"@niivue/niimath": "^0.3.0",
"@niivue/niimath": "^1.0.0",
"@itk-wasm/cuberille": "^0.2.0",
"@itk-wasm/mesh-filters": "^0.2.0",
"@niivue/cbor-loader": "^1.1.0",
Expand Down