VulpesOS/assets/webapps/bluetooth.gaiamobile.org/js/utils.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

1 line
No EOL
816 B
JavaScript

;function getTruncated(t,e){function i(t,e){return t!==e}var n=e.maxLine||2,l=e.node,o=e.ellipsisIndex||3,r=e.ellipsisCharacter||"...";if(null===l)return t;var s,a,c,u,d,y,h="",v=!0,p=[],f=t.slice(-o),g=l.style.visibility,x=l.style.wordBreak;l.style.visibility="hidden",l.style.wordBreak="break-all",l.textContent=".",c=l.clientHeight,l.textContent="";var C=t.split("").some(function(t,e){if(p.push(t),y=p.join(""),s=l.clientHeight,l.textContent=y+r+f,a=l.clientHeight,0===e&&(u=Math.floor(a/c)),i(s,a)&&0!==e){var o;l.textContent=y,o=l.clientHeight,i(s,o)?(v=!0,u+=1):v&&(d=e,v=!1)}return u>n?(0===e&&console.log("Your string is in a overflowed situation, please check your options"),p.pop(),l.textContent="",!0):void 0});return l.style.visibility=g,l.style.wordBreak=x,C?(h+=p.join("").slice(0,d),h+=r,h+=f):h=t,h}