diff --git a/dist/webdelta.js b/dist/webdelta.js index 3f9959b..d8c0bcf 100644 --- a/dist/webdelta.js +++ b/dist/webdelta.js @@ -1,6 +1,7 @@ window.webDeltaConfig = { tooltipBorderRadius: "5px", tooltipFont: "Menlo, monospaced", + tooltipFontSize: "15px", tooltipXOffset: 15, tooltipYOffset: 15, timeZone: "UTC", @@ -99,6 +100,7 @@ document.addEventListener("DOMContentLoaded", function() { tooltip.style.color = window.webDeltaConfig.tooltipForegroundColor || "white"; tooltip.style.borderRadius = window.webDeltaConfig.tooltipBorderRadius || "5px"; tooltip.style.fontFamily = window.webDeltaConfig.tooltipFont || "Arial, sans-serif"; + tooltip.style.fontSize = window.webDeltaConfig.tooltipFontSize || "15px"; tooltip.style.whiteSpace = "nowrap"; tooltip.style.visibility = "hidden"; tooltip.style.opacity = "0"; diff --git a/dist/webdelta.min.js b/dist/webdelta.min.js index f5e9bf5..d5d12b3 100644 --- a/dist/webdelta.min.js +++ b/dist/webdelta.min.js @@ -1 +1 @@ -window.webDeltaConfig={tooltipBorderRadius:"5px",tooltipFont:"Menlo, monospaced",tooltipXOffset:15,tooltipYOffset:15,timeZone:"UTC",lang:"en",tooltipBackgroundColor:"black",tooltipForegroundColor:"white"},document.addEventListener("DOMContentLoaded",function(){document.querySelectorAll("span.webDelta").forEach(t=>{const y=parseInt(t.textContent.trim()),l=new Date(y*1e3),w=t.classList.contains("utc")?"UTC":window.webDeltaConfig.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone,c=window.webDeltaConfig.lang||void 0;let e={timeZone:w},i="";if(t.classList.contains("raw"))i=y;else{if(isNaN(y)){console.error(`Invalid timestamp: ${t.textContent.trim()}`),t.textContent="Invalid timestamp";return}if(t.classList.contains("timeOnly"))if(e={hour:"numeric",minute:"numeric",second:"numeric",...e},t.classList.contains("weekday")){const d={weekday:"long",timeZone:w},s=l.toLocaleDateString(c,d),a=l.toLocaleTimeString(c,e);i=`${s}, ${a}`}else i=l.toLocaleTimeString(c,e);else t.classList.contains("dateOnly")?(e={year:"numeric",month:"long",day:"numeric",...e},t.classList.contains("weekday")&&(e.weekday="long"),i=l.toLocaleDateString(c,e)):t.classList.contains("iso8601")?i=l.toISOString():(t.classList.contains("short")?e={...e,dateStyle:"short",timeStyle:"short"}:t.classList.contains("medium")?e={...e,dateStyle:"medium",timeStyle:"medium"}:t.classList.contains("long")?e={...e,dateStyle:"long",timeStyle:"long"}:t.classList.contains("full")?e={...e,dateStyle:"full",timeStyle:"long"}:e={year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",...e},t.classList.contains("weekday")&&!t.classList.contains("short")&&(e.weekday="long"),i=l.toLocaleString(c,e));!t.classList.contains("noTZ")&&!t.classList.contains("iso8601")&&!i.includes(w)&&(i+=` ${w}`)}if(t.textContent=i,t.classList.contains("noTooltip"))return;t.nextElementSibling&&t.nextElementSibling.classList.contains("webDelta-tooltip")&&t.nextElementSibling.remove();const o=document.createElement("span");o.className="webDelta-tooltip",o.style.position="absolute",o.style.padding="8px",o.style.backgroundColor=window.webDeltaConfig.tooltipBackgroundColor||"black",o.style.color=window.webDeltaConfig.tooltipForegroundColor||"white",o.style.borderRadius=window.webDeltaConfig.tooltipBorderRadius||"5px",o.style.fontFamily=window.webDeltaConfig.tooltipFont||"Arial, sans-serif",o.style.whiteSpace="nowrap",o.style.visibility="hidden",o.style.opacity="0",o.style.transition="opacity 0.3s ease, transform 0.3s ease",o.style.pointerEvents="none",o.style.transform="scale(0.8)",o.style.zIndex="1000",document.body.appendChild(o);const m=()=>{const s=l-new Date,a=Math.abs(s),f=new Intl.RelativeTimeFormat(c,{numeric:"auto"});let r="";if(a>=31536e6){const n=Math.floor(s/31536e6);r=f.format(n,"year")}else if(a>=864e5){const n=Math.floor(s/864e5);r=f.format(n,"day")}else if(a>=36e5){const n=Math.floor(s/36e5);r=f.format(n,"hour")}else if(a>=6e4){const n=Math.floor(s/6e4);r=f.format(n,"minute")}else{const n=Math.floor(s/1e3);r=f.format(n,"second")}o.textContent=r},u=()=>{m(),setInterval(m,1e3)},p=1e3-new Date().getMilliseconds();setTimeout(u,p),t.addEventListener("mouseover",()=>{o.style.visibility="visible",o.style.opacity="1",o.style.transform="scale(1)"}),t.addEventListener("mousemove",d=>{const s=window.scrollY||window.pageYOffset,a=window.scrollX||window.pageXOffset;o.style.top=`${d.clientY+s+(window.webDeltaConfig.tooltipYOffset||15)}px`,o.style.left=`${d.clientX+a+(window.webDeltaConfig.tooltipXOffset||15)}px`}),t.addEventListener("mouseout",()=>{o.style.opacity="0",o.style.visibility="hidden",o.style.transform="scale(0.8)"})})}); +window.webDeltaConfig={tooltipBorderRadius:"5px",tooltipFont:"Menlo, monospaced",tooltipFontSize:"15px",tooltipXOffset:15,tooltipYOffset:15,timeZone:"UTC",lang:"en",tooltipBackgroundColor:"black",tooltipForegroundColor:"white"},document.addEventListener("DOMContentLoaded",function(){document.querySelectorAll("span.webDelta").forEach(t=>{const y=parseInt(t.textContent.trim()),l=new Date(y*1e3),w=t.classList.contains("utc")?"UTC":window.webDeltaConfig.timeZone||Intl.DateTimeFormat().resolvedOptions().timeZone,c=window.webDeltaConfig.lang||void 0;let e={timeZone:w},i="";if(t.classList.contains("raw"))i=y;else{if(isNaN(y)){console.error(`Invalid timestamp: ${t.textContent.trim()}`),t.textContent="Invalid timestamp";return}if(t.classList.contains("timeOnly"))if(e={hour:"numeric",minute:"numeric",second:"numeric",...e},t.classList.contains("weekday")){const d={weekday:"long",timeZone:w},s=l.toLocaleDateString(c,d),a=l.toLocaleTimeString(c,e);i=`${s}, ${a}`}else i=l.toLocaleTimeString(c,e);else t.classList.contains("dateOnly")?(e={year:"numeric",month:"long",day:"numeric",...e},t.classList.contains("weekday")&&(e.weekday="long"),i=l.toLocaleDateString(c,e)):t.classList.contains("iso8601")?i=l.toISOString():(t.classList.contains("short")?e={...e,dateStyle:"short",timeStyle:"short"}:t.classList.contains("medium")?e={...e,dateStyle:"medium",timeStyle:"medium"}:t.classList.contains("long")?e={...e,dateStyle:"long",timeStyle:"long"}:t.classList.contains("full")?e={...e,dateStyle:"full",timeStyle:"long"}:e={year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",...e},t.classList.contains("weekday")&&!t.classList.contains("short")&&(e.weekday="long"),i=l.toLocaleString(c,e));!t.classList.contains("noTZ")&&!t.classList.contains("iso8601")&&!i.includes(w)&&(i+=` ${w}`)}if(t.textContent=i,t.classList.contains("noTooltip"))return;t.nextElementSibling&&t.nextElementSibling.classList.contains("webDelta-tooltip")&&t.nextElementSibling.remove();const o=document.createElement("span");o.className="webDelta-tooltip",o.style.position="absolute",o.style.padding="8px",o.style.backgroundColor=window.webDeltaConfig.tooltipBackgroundColor||"black",o.style.color=window.webDeltaConfig.tooltipForegroundColor||"white",o.style.borderRadius=window.webDeltaConfig.tooltipBorderRadius||"5px",o.style.fontFamily=window.webDeltaConfig.tooltipFont||"Arial, sans-serif",o.style.fontSize=window.webDeltaConfig.tooltipFontSize||"15px",o.style.whiteSpace="nowrap",o.style.visibility="hidden",o.style.opacity="0",o.style.transition="opacity 0.3s ease, transform 0.3s ease",o.style.pointerEvents="none",o.style.transform="scale(0.8)",o.style.zIndex="1000",document.body.appendChild(o);const m=()=>{const s=l-new Date,a=Math.abs(s),f=new Intl.RelativeTimeFormat(c,{numeric:"auto"});let r="";if(a>=31536e6){const n=Math.floor(s/31536e6);r=f.format(n,"year")}else if(a>=864e5){const n=Math.floor(s/864e5);r=f.format(n,"day")}else if(a>=36e5){const n=Math.floor(s/36e5);r=f.format(n,"hour")}else if(a>=6e4){const n=Math.floor(s/6e4);r=f.format(n,"minute")}else{const n=Math.floor(s/1e3);r=f.format(n,"second")}o.textContent=r},u=()=>{m(),setInterval(m,1e3)},p=1e3-new Date().getMilliseconds();setTimeout(u,p),t.addEventListener("mouseover",()=>{o.style.visibility="visible",o.style.opacity="1",o.style.transform="scale(1)"}),t.addEventListener("mousemove",d=>{const s=window.scrollY||window.pageYOffset,a=window.scrollX||window.pageXOffset;o.style.top=`${d.clientY+s+(window.webDeltaConfig.tooltipYOffset||15)}px`,o.style.left=`${d.clientX+a+(window.webDeltaConfig.tooltipXOffset||15)}px`}),t.addEventListener("mouseout",()=>{o.style.opacity="0",o.style.visibility="hidden",o.style.transform="scale(0.8)"})})}); diff --git a/src/webdelta.js b/src/webdelta.js index da6e793..21d1483 100644 --- a/src/webdelta.js +++ b/src/webdelta.js @@ -22,6 +22,7 @@ window.webDeltaConfig = { tooltipBorderRadius: '5px', tooltipFont: 'Menlo, monospaced', + tooltipFontSize: '15px', tooltipXOffset: 15, tooltipYOffset: 15, timeZone: 'UTC', @@ -132,6 +133,7 @@ document.addEventListener("DOMContentLoaded", function () { tooltip.style.color = window.webDeltaConfig.tooltipForegroundColor || 'white'; tooltip.style.borderRadius = window.webDeltaConfig.tooltipBorderRadius || '5px'; tooltip.style.fontFamily = window.webDeltaConfig.tooltipFont || 'Arial, sans-serif'; + tooltip.style.fontSize = window.webDeltaConfig.tooltipFontSize || '15px'; tooltip.style.whiteSpace = 'nowrap'; tooltip.style.visibility = 'hidden'; tooltip.style.opacity = '0';