From d3bc25cd9c2d7f78f3cde30934c640abc8004b63 Mon Sep 17 00:00:00 2001 From: sssiiiiiii Date: Mon, 15 Sep 2025 13:49:42 +0000 Subject: [PATCH 1/2] Updated showError in register.js to username suffix --- public/src/client/register.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/src/client/register.js b/public/src/client/register.js index 62dbc41..ba66da2 100644 --- a/public/src/client/register.js +++ b/public/src/client/register.js @@ -131,7 +131,7 @@ define('forum/register', [ if (results.every(obj => obj.status === 'rejected')) { showSuccess(username_notify, successIcon); } else { - showError(username_notify, '[[error:username-taken]]'); + showError(username_notify, '[[error:username-taken, "${username}suffix"]]'); } callback(); From 119d78e4e36d5246f38671f69a95f126de02e393 Mon Sep 17 00:00:00 2001 From: sssiiiiiii Date: Fri, 26 Sep 2025 20:13:10 +0000 Subject: [PATCH 2/2] Refactored (public/src/modules/share.js): reduce parameters --- public/src/modules/share.js | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/public/src/modules/share.js b/public/src/modules/share.js index ea2f131..0f5ce4d 100644 --- a/public/src/modules/share.js +++ b/public/src/modules/share.js @@ -3,12 +3,11 @@ define('share', ['hooks'], function (hooks) { const module = {}; + const baseUrl = window.location.protocol + '//' + window.location.host; module.addShareHandlers = function (name) { - const baseUrl = window.location.protocol + '//' + window.location.host; - function openShare(url, urlToPost, width, height) { - window.open(url + encodeURIComponent(baseUrl + config.relative_path + urlToPost), '_blank', 'width=' + width + ',height=' + height + ',scrollbars=no,status=no'); + window.open(url, '_blank', 'width=' + width + ',height=' + height + ',scrollbars=no,status=no'); hooks.fire('action:share.open', { url: url, urlToPost: urlToPost, @@ -32,11 +31,36 @@ define('share', ['hooks'], function (hooks) { }); addHandler('[component="share/twitter"]', function () { - return openShare('https://twitter.com/intent/tweet?text=' + encodeURIComponent(name) + '&url=', getPostUrl($(this)), 550, 420); + const postUrl = getPostUrl($(this)); + const twitter_url = `https://twitter.com/intent/tweet?text=${encodeURIComponent(name)}&url=${encodeURIComponent(postUrl)}`; + return openShare(twitter_url, postUrl, 550, 420); }); addHandler('[component="share/facebook"]', function () { - return openShare('https://www.facebook.com/sharer/sharer.php?u=', getPostUrl($(this)), 626, 436); + const postUrl = getPostUrl($(this)); + const facebook_url = `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(postUrl)}`; + return openShare(facebook_url, postUrl, 626, 436); + }); + + addHandler('[component="share/whatsapp"]', function () { + const postUrl = getPostUrl($(this)); + const message = encodeURIComponent(name) + ' - ' + encodeURIComponent(postUrl); + const whatsapp_url = config.useragent.isMobile ? + `whatsapp://send?text=${message}` : + `https://wa.me/?text=${message}`; + return openShare(whatsapp_url, postUrl, 626, 436); + }); + + addHandler('[component="share/telegram"]', function () { + const postUrl = getPostUrl($(this)); + const telegram_url = `https://t.me/share/url?text=${encodeURIComponent(name)}&url=${encodeURIComponent(postUrl)}`; + return openShare(telegram_url, postUrl, 626, 436); + }); + + addHandler('[component="share/linkedin"]', function () { + const postUrl = getPostUrl($(this)); + const linkedin_url = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(postUrl)}`; + return openShare(linkedin_url, postUrl, 626, 436); }); hooks.fire('action:share.addHandlers', { openShare: openShare }); @@ -48,7 +72,8 @@ define('share', ['hooks'], function (hooks) { function getPostUrl(clickedElement) { const pid = parseInt(clickedElement.parents('[data-pid]').attr('data-pid'), 10); - return '/post' + (pid ? '/' + (pid) : ''); + const path = '/post' + (pid ? '/' + (pid) : ''); + return baseUrl + config.relative_path + path; } return module;