From 899fbb7092892fc111e30453d6d7abf307cf1a31 Mon Sep 17 00:00:00 2001 From: osmarks Date: Fri, 31 Jan 2025 14:10:15 +0000 Subject: [PATCH] fix embedding-from-URL feature --- clipfront2/src/App.svelte | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/clipfront2/src/App.svelte b/clipfront2/src/App.svelte index ed5b896..0277d60 100644 --- a/clipfront2/src/App.svelte +++ b/clipfront2/src/App.svelte @@ -300,6 +300,20 @@ } } + const decodeFloat16 = uint16 => { + const sign = (uint16 & 0x8000) ? -1 : 1 + const exponent = (uint16 & 0x7C00) >> 10 + const fraction = uint16 & 0x03FF + + if (exponent === 0) { + return sign * Math.pow(2, -14) * (fraction / Math.pow(2, 10)) + } else if (exponent === 0x1F) { + return fraction ? NaN : sign * Infinity + } else { + return sign * Math.pow(2, exponent - 15) * (1 + fraction / Math.pow(2, 10)) + } + } + const parseQueryString = queryStringParams => { if (queryStringParams.get("q") && queryTerms.length === 0) { newTextQuery(queryStringParams.get("q")) @@ -346,20 +360,6 @@ return `${snd}/${fst}` } - const decodeFloat16 = uint16 => { - const sign = (uint16 & 0x8000) ? -1 : 1 - const exponent = (uint16 & 0x7C00) >> 10 - const fraction = uint16 & 0x03FF - - if (exponent === 0) { - return sign * Math.pow(2, -14) * (fraction / Math.pow(2, 10)) - } else if (exponent === 0x1F) { - return fraction ? NaN : sign * Infinity - } else { - return sign * Math.pow(2, exponent - 15) * (1 + fraction / Math.pow(2, 10)) - } - } - const focusEl = el => el.focus() const removeTerm = term => { queryTerms = queryTerms.filter(x => x !== term)