|
856 | 856 | log(err); |
857 | 857 | }); |
858 | 858 | } |
859 | | - function getTranslation(key, value = false) { |
860 | | - if (translation && translation.innerHTML && (key in translation.innerHTML)) { |
861 | | - // these are the proper translations |
862 | | - return translation.innerHTML[key]; |
863 | | - } else if (translation && translation.miscellaneous && translation.miscellaneous && (key in translation.miscellaneous)) { |
864 | | - return translation.miscellaneous[key]; |
865 | | - } else if (value !== false) { |
866 | | - return value; |
867 | | - } else { |
868 | | - return key.replaceAll("-", " "); // |
869 | | - } |
870 | | - } |
871 | | - function resolveSourceImageUrl(src) { |
872 | | - if (!src) { |
873 | | - return ""; |
874 | | - } |
875 | | - var str = (src + "").trim(); |
876 | | - if (!str) { |
877 | | - return ""; |
878 | | - } |
879 | | - if (/^[a-z][a-z0-9+.-]*:/i.test(str) || str.startsWith("//")) { |
880 | | - return str; |
881 | | - } |
882 | | - var cleaned = str.replace(/^\.\/+/, "").replace(/^\/+/, ""); |
883 | | - var lowerCleaned = cleaned.toLowerCase(); |
884 | | - var prefix = "sources/images/"; |
885 | | - if (!lowerCleaned.startsWith(prefix)) { |
886 | | - cleaned = prefix + cleaned; |
887 | | - } |
888 | | - return "./" + cleaned; |
889 | | - } |
890 | | - |
891 | | - var newFileHandle = false; |
892 | | - |
893 | | - async function overwriteFile(data = false) { |
894 | | - if (data == "setup") { |
| 859 | + function getTranslation(key, value = false) { |
| 860 | + if (translation && translation.innerHTML && (key in translation.innerHTML)) { |
| 861 | + // these are the proper translations |
| 862 | + return translation.innerHTML[key]; |
| 863 | + } else if (translation && translation.miscellaneous && translation.miscellaneous && (key in translation.miscellaneous)) { |
| 864 | + return translation.miscellaneous[key]; |
| 865 | + } else if (value !== false) { |
| 866 | + return value; |
| 867 | + } else { |
| 868 | + return key.replaceAll("-", " "); // |
| 869 | + } |
| 870 | + } |
| 871 | + function resolveSourceImageUrl(src) { |
| 872 | + if (!src) { |
| 873 | + return ""; |
| 874 | + } |
| 875 | + var str = (src + "").trim(); |
| 876 | + if (!str) { |
| 877 | + return ""; |
| 878 | + } |
| 879 | + if (/^[a-z][a-z0-9+.-]*:/i.test(str) || str.startsWith("//")) { |
| 880 | + return str; |
| 881 | + } |
| 882 | + var cleaned = str.replace(/^\.\/+/, "").replace(/^\/+/, ""); |
| 883 | + var lowerCleaned = cleaned.toLowerCase(); |
| 884 | + var prefix = "sources/images/"; |
| 885 | + if (!lowerCleaned.startsWith(prefix)) { |
| 886 | + cleaned = prefix + cleaned; |
| 887 | + } |
| 888 | + return "./" + cleaned; |
| 889 | + } |
| 890 | + |
| 891 | + var newFileHandle = false; |
| 892 | + |
| 893 | + async function overwriteFile(data = false) { |
| 894 | + if (data == "setup") { |
895 | 895 | const opts = { |
896 | 896 | types: [ |
897 | 897 | { |
|
1407 | 1407 | } |
1408 | 1408 |
|
1409 | 1409 | if (urlParams.get('font')) { |
1410 | | - const raw = urlParams.get('font').trim(); |
1411 | | - const clean = raw.replace(/^['"]|['"]$/g, ''); |
1412 | | - const escaped = clean.replace(/\\/g, '\\\\').replace(/"/g, '\\"'); |
1413 | | - document.documentElement.style.setProperty('--font-family', `"${escaped}", Sora, Roboto, Helvetica, Geneva, Verdana, Arial, sans-serif`); |
| 1410 | + const fontParam = urlParams.get('font').trim(); |
| 1411 | + const fonts = fontParam.split(',').map(f => { |
| 1412 | + const clean = f.trim().replace(/^['"]|['"]$/g, ''); |
| 1413 | + const escaped = clean.replace(/\\/g, '\\\\').replace(/"/g, '\\"'); |
| 1414 | + return escaped ? `"${escaped}"` : ''; |
| 1415 | + }).filter(Boolean); |
| 1416 | + if (fonts.length) { |
| 1417 | + document.documentElement.style.setProperty('--font-family', `${fonts.join(', ')}, Sora, Roboto, Helvetica, Geneva, Verdana, Arial, sans-serif`); |
| 1418 | + } |
1414 | 1419 | } |
1415 | 1420 |
|
1416 | 1421 | if (urlParams.get("googlefont")) { |
|
2114 | 2119 | showType = data.type; |
2115 | 2120 | } |
2116 | 2121 |
|
2117 | | - var customSourceClass = "sourceOffset"; |
2118 | | - if (showType && showsource && avatar) { |
2119 | | - showType = '<img src="./sources/images/' + showType + '.png" class="icon sourcetype" data-icon-name="' + showType + '" onerror="this.style.display=\'none\'" />'; |
2120 | | - } else if (showType && showsource && !avatar) { |
2121 | | - showType = '<img src="./sources/images/' + showType + '.png" class="icon sourcetype noavatar-source" data-icon-name="' + showType + '" onerror="this.style.display=\'none\'" />'; |
2122 | | - } else { |
2123 | | - customSourceClass = ""; |
2124 | | - showType = ""; |
2125 | | - } |
2126 | | - |
2127 | | - var resolvedSourceImg = data.sourceImg ? resolveSourceImageUrl(data.sourceImg) : ""; |
2128 | | - if (resolvedSourceImg && customSource && avatar) { |
2129 | | - showType += '<img src="' + resolvedSourceImg + '" class="icon sourcetype ' + customSourceClass + '" onerror="this.style.display=\'none\'" />'; |
2130 | | - } else if (resolvedSourceImg && customSource && !avatar) { |
2131 | | - showType += '<img src="' + resolvedSourceImg + '" class="icon sourcetype ' + customSourceClass + ' noavatar-source" onerror="this.style.display=\'none\'" />'; |
2132 | | - } |
| 2122 | + var customSourceClass = "sourceOffset"; |
| 2123 | + if (showType && showsource && avatar) { |
| 2124 | + showType = '<img src="./sources/images/' + showType + '.png" class="icon sourcetype" data-icon-name="' + showType + '" onerror="this.style.display=\'none\'" />'; |
| 2125 | + } else if (showType && showsource && !avatar) { |
| 2126 | + showType = '<img src="./sources/images/' + showType + '.png" class="icon sourcetype noavatar-source" data-icon-name="' + showType + '" onerror="this.style.display=\'none\'" />'; |
| 2127 | + } else { |
| 2128 | + customSourceClass = ""; |
| 2129 | + showType = ""; |
| 2130 | + } |
| 2131 | + |
| 2132 | + var resolvedSourceImg = data.sourceImg ? resolveSourceImageUrl(data.sourceImg) : ""; |
| 2133 | + if (resolvedSourceImg && customSource && avatar) { |
| 2134 | + showType += '<img src="' + resolvedSourceImg + '" class="icon sourcetype ' + customSourceClass + '" onerror="this.style.display=\'none\'" />'; |
| 2135 | + } else if (resolvedSourceImg && customSource && !avatar) { |
| 2136 | + showType += '<img src="' + resolvedSourceImg + '" class="icon sourcetype ' + customSourceClass + ' noavatar-source" onerror="this.style.display=\'none\'" />'; |
| 2137 | + } |
2133 | 2138 |
|
2134 | 2139 | if (hideNames) { |
2135 | 2140 | data.chatname = ""; |
|
0 commit comments