mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-15 08:56:21 +00:00
1 line
7.3 KiB
Plaintext
1 line
7.3 KiB
Plaintext
{"version":3,"sources":["utils.js"],"names":["lsKeys","siBytes","ampmTime","page","prepareShareX","const","sharexElement","document","querySelector","headers","token","albumid","album","filelength","fileLength","age","uploadAge","striptags","stripTags","origin","window","location","host","pathname","replace","originClean","sharexConfObj","Name","DestinationType","RequestMethod","RequestURL","Headers","Body","FileFormName","URL","ThumbnailURL","sharexConfStr","JSON","stringify","sharexBlob","Blob","type","setAttribute","createObjectURL","getPrettyDate","date","getFullYear","getMonth","getDate","toLocaleString","hour","minute","second","hour12","localStorage","getPrettyBytes","num","isFinite","si","neg","scale","exponent","Math","min","floor","log","LOG10E","Number","pow","toPrecision","charAt","getPrettyUptime","seconds","days","let","hours","minutes","escape","string","str","String","match","exec","html","index","lastIndex","length","charCodeAt","substring"],"mappings":"AAGAA,OAAOC,QAAU,UACjBD,OAAOE,SAAW,WAElBC,KAAKC,cAAa,WAChBC,IAAMC,EAAgBC,SAASC,cAAc,WAC7C,GAAKF,EAAL,CAEAD,IAAMI,EAAU,GAEZN,KAAKO,QACPD,EAAQC,MAAQP,KAAKO,OAAS,GAC9BD,EAAQE,QAAUR,KAAKS,OAAS,IAGlCH,EAAQI,WAAaV,KAAKW,YAAc,GACxCL,EAAQM,IAAMZ,KAAKa,WAAa,GAChCP,EAAQQ,UAAYd,KAAKe,WAAa,GAEtCb,IAAMc,GAAUC,OAAOC,SAASC,KAAOF,OAAOC,SAASE,UAAUC,QAAQ,kBAAmB,IACtFC,EAAcN,EAAOK,QAAQ,MAAO,KAEpCE,EAAgB,CACpBC,KAAMF,EACNG,gBAAiB,8BACjBC,cAAe,OACfC,WAAeV,OAAOC,SAAS,SAAQ,KAAKF,EAAM,cAClDY,QAAStB,EACTuB,KAAM,oBACNC,aAAc,UACdC,IAAK,sBACLC,aAAc,uBAQVC,EAAgBC,KAAKC,UAAUZ,EAAe,KAA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A,GAE9BC,EAAO,EACFA,EAAO,KAAOE,EAAQ,IAAMC,EAAU,IAAMJ,EAE5CG,EAAQ,IAAMC,EAAU,IAAMJ,GAIzCrE,KAAK0E,OAAM,SAAGC,GAMZ,IAAKA,EAAQ,OAAOA,EAEpBzE,IAKIwE,EALEE,EAAMC,OAAOF,GACbG,EAAQ,UAAUC,KAAKH,GAE7B,IAAKE,EAAO,OAAOF,EAGnBL,IAAIS,EAAO,GACPC,EAAQ,EACRC,EAAY,EAEhB,IAAKD,EAAQH,EAAMG,MAAOA,EAAQL,EAAIO,OAAQF,IAAS,CACrD,OAAQL,EAAIQ,WAAWH,IACrB,KAAK,GACHP,EAAS,SACT,MACF,KAAK,GACHA,EAAS,QACT,MACF,KAAK,GACHA,EAAS,QACT,MACF,KAAK,GACHA,EAAS,OACT,MACF,KAAK,GACHA,EAAS,OACT,MACF,QACE,SAGAQ,IAAcD,IAChBD,GAAQJ,EAAIS,UAAUH,EAAWD,IAGnCC,EAAYD,EAAQ,EACpBD,GAAQN,EAGV,OAAOQ,IAAcD,EACjBD,EAAOJ,EAAIS,UAAUH,EAAWD,GAChCD","file":"utils.js","sourcesContent":["/* global lsKeys, page */\n\n// keys for localStorage\nlsKeys.siBytes = 'siBytes'\nlsKeys.ampmTime = 'ampmTime'\n\npage.prepareShareX = () => {\n const sharexElement = document.querySelector('#ShareX')\n if (!sharexElement) return\n\n const headers = {}\n\n if (page.token) {\n headers.token = page.token || ''\n headers.albumid = page.album || ''\n }\n\n headers.filelength = page.fileLength || ''\n headers.age = page.uploadAge || ''\n headers.striptags = page.stripTags || ''\n\n const origin = (window.location.host + window.location.pathname).replace(/\\/(dashboard)?$/, '')\n const originClean = origin.replace(/\\//g, '_')\n\n const sharexConfObj = {\n Name: originClean,\n DestinationType: 'ImageUploader, FileUploader',\n RequestMethod: 'POST',\n RequestURL: `${window.location.protocol}//${origin}/api/upload`,\n Headers: headers,\n Body: 'MultipartFromData',\n FileFormName: 'files[]',\n URL: '$json:files[0].url$',\n ThumbnailURL: '$json:files[0].url$'\n }\n\n /*\n if (page.token)\n sharexConfObj.DeletionURL = '$json:files[0].deleteUrl$'\n */\n\n const sharexConfStr = JSON.stringify(sharexConfObj, null, 2)\n const sharexBlob = new Blob([sharexConfStr], { type: 'application/octet-binary' })\n /* eslint-disable-next-line compat/compat */\n sharexElement.setAttribute('href', URL.createObjectURL(sharexBlob))\n sharexElement.setAttribute('download', `${originClean}.sxcu`)\n}\n\npage.getPrettyDate = date => {\n // Not using .toLocaleString() for date display to maintain a global standard,\n // but its AM/PM logic is perfect for our use case as long as it's fixed to \"en\" locale.\n return date.getFullYear() + '/' +\n (date.getMonth() < 9 ? '0' : '') + // month's index starts from zero\n (date.getMonth() + 1) + '/' +\n (date.getDate() < 10 ? '0' : '') +\n date.getDate() + ' ' +\n date.toLocaleString('en', {\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: localStorage[lsKeys.ampmTime] === '1'\n })\n}\n\npage.getPrettyBytes = num => {\n // MIT License\n // Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)\n if (typeof num !== 'number' && !isFinite(num)) return num\n\n const si = localStorage[lsKeys.siBytes] !== '0'\n const neg = num < 0 ? '-' : ''\n const scale = si ? 1000 : 1024\n if (neg) num = -num\n if (num < scale) return `${neg}${num} B`\n\n const exponent = Math.min(Math.floor((Math.log(num) * Math.LOG10E) / 3), 8) // 8 is count of KMGTPEZY\n const numStr = Number((num / Math.pow(scale, exponent)).toPrecision(3))\n const pre = (si ? 'kMGTPEZY' : 'KMGTPEZY').charAt(exponent - 1) + (si ? '' : 'i')\n return `${neg}${numStr} ${pre}B`\n}\n\npage.getPrettyUptime = seconds => {\n const days = Math.floor(seconds / 86400)\n seconds %= 86400\n let hours = Math.floor(seconds / 3600)\n seconds %= 3600\n let minutes = Math.floor(seconds / 60)\n seconds %= 60\n\n if (hours < 10) hours = '0' + hours\n if (minutes < 10) minutes = '0' + minutes\n if (seconds < 10) seconds = '0' + seconds\n\n if (days > 0) {\n return days + 'd ' + hours + ':' + minutes + ':' + seconds\n } else {\n return hours + ':' + minutes + ':' + seconds\n }\n}\n\npage.escape = string => {\n // MIT License\n // Copyright(c) 2012-2013 TJ Holowaychuk\n // Copyright(c) 2015 Andreas Lubbe\n // Copyright(c) 2015 Tiancheng \"Timothy\" Gu\n\n if (!string) return string\n\n const str = String(string)\n const match = /[\"'&<>]/.exec(str)\n\n if (!match) return str\n\n let escape\n let html = ''\n let index = 0\n let lastIndex = 0\n\n for (index = match.index; index < str.length; index++) {\n switch (str.charCodeAt(index)) {\n case 34: // \"\n escape = '"'\n break\n case 38: // &\n escape = '&'\n break\n case 39: // '\n escape = '''\n break\n case 60: // <\n escape = '<'\n break\n case 62: // >\n escape = '>'\n break\n default:\n continue\n }\n\n if (lastIndex !== index) {\n html += str.substring(lastIndex, index)\n }\n\n lastIndex = index + 1\n html += escape\n }\n\n return lastIndex !== index\n ? html + str.substring(lastIndex, index)\n : html\n}\n"]} |