From 030585d26e310011178e2485e6bfab5d30aad623 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 10 Feb 2022 12:10:30 +0530 Subject: [PATCH] clean up some code smell --- www/admin/inner.js | 12 ++++++++---- www/common/common-language.js | 7 ------- www/profile/inner.js | 6 +++--- www/settings/inner.js | 33 +++++++++++++++++++-------------- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/www/admin/inner.js b/www/admin/inner.js index 63c516614..83143a546 100644 --- a/www/admin/inner.js +++ b/www/admin/inner.js @@ -1965,12 +1965,17 @@ define([ if (!categories[active]) { active = 'general'; } common.setHash(active); Object.keys(categories).forEach(function (key) { - var $category = $('
', {'class': 'cp-sidebarlayout-category'}).appendTo($categories); var iconClass = SIDEBAR_ICONS[key]; + var icon; if (iconClass) { - $category.append($('', {'class': iconClass})); + icon = h('span', { class: iconClass }); } - + var $category = $(h('div', { + 'class': 'cp-sidebarlayout-category' + }, [ + icon, + Messages['admin_cat_'+key] || key, + ])).appendTo($categories); if (key === active) { $category.addClass('cp-leftside-active'); } @@ -1987,7 +1992,6 @@ define([ showCategories(categories[key]); }); - $category.append(Messages['admin_cat_'+key] || key); }); showCategories(categories[active]); }; diff --git a/www/common/common-language.js b/www/common/common-language.js index 8b27a64bf..02e0e68c2 100644 --- a/www/common/common-language.js +++ b/www/common/common-language.js @@ -50,11 +50,6 @@ define([ var key = $el.data('localization'); $el.html(Messages[key]); }; - var translateAppend = function (i, e) { - var $el = $(e); - var key = $el.data('localization-append'); - $el.append(Messages[key]); - }; var translateTitle = function () { var $el = $(this); var key = $el.data('localization-title'); @@ -66,11 +61,9 @@ define([ $el.attr('placeholder', Messages[key]); }; $('[data-localization]').each(translateText); - $('[data-localization-append]').each(translateAppend); $('[data-localization-title]').each(translateTitle); $('[data-localization-placeholder]').each(translatePlaceholder); $('#pad-iframe').contents().find('[data-localization]').each(translateText); - $('#pad-iframe').contents().find('[data-localization-append]').each(translateAppend); $('#pad-iframe').contents().find('[data-localization-title]').each(translateTitle); $('#pad-iframe').contents().find('[data-localization-placeholder]').each(translatePlaceholder); }; diff --git a/www/profile/inner.js b/www/profile/inner.js index 2d63d2957..8f7b8cf08 100644 --- a/www/profile/inner.js +++ b/www/profile/inner.js @@ -271,7 +271,7 @@ define([ // Pending friend (we've sent a friend request) var pendingFriends = APP.common.getPendingFriends(); // Friend requests sent if (pendingFriends[data.curvePublic]) { - $button.attr('disabled', 'disabled').append(Messages.profile_friendRequestSent); + $button.attr('disabled', 'disabled').text(Messages.profile_friendRequestSent); addCancel(); return; } @@ -522,7 +522,7 @@ define([ var $category = $('
', {'class': 'cp-sidebarlayout-category'}).appendTo($categories); $category.append($('', {'class': 'fa fa-user'})); $category.addClass('cp-leftside-active'); - $category.append(Messages.profileButton); + $category.text(Messages.profileButton); }; var init = function () { @@ -603,7 +603,7 @@ define([ if (!privateData.readOnly && !common.isLoggedIn()) { UI.removeLoadingScreen(); - var $p = $('

', {id: CREATE_ID}).append(Messages.profile_register); + var $p = $('

', {id: CREATE_ID}).text(Messages.profile_register); var $a = $('', { href: APP.origin + '/register/' }); diff --git a/www/settings/inner.js b/www/settings/inner.js index 183f3acbb..ee48e19cd 100644 --- a/www/settings/inner.js +++ b/www/settings/inner.js @@ -340,9 +340,10 @@ define([ $('', { 'class': 'label' }).text(Messages.settings_userFeedbackTitle).appendTo($div); - $('', { 'class': 'cp-sidebarlayout-description' }) - .append(Messages.settings_userFeedbackHint1) - .append(Messages.settings_userFeedbackHint2).appendTo($div); + $div.append(h('span.cp-sidebarlayout-description', [ + Messages.settings_userFeedbackHint1, + Messages.settings_userFeedbackHint2, + ])); var $ok = $('', { 'class': 'fa fa-check', title: Messages.saved }); var $spinner = $('', { 'class': 'fa fa-spinner fa-pulse' }); @@ -851,9 +852,9 @@ define([ $('', { 'class': 'label' }).text(Messages.settings_driveRedirectTitle).appendTo($div); - $('', { 'class': 'cp-sidebarlayout-description' }) - .append(Messages.settings_driveRedirectHint) - .appendTo($div); + $div.append(h('span', { + class: 'cp-sidebarlayout-description', + }, Messages.settings_driveRedirectHint)); var $ok = $('', { 'class': 'fa fa-check', title: Messages.saved }); var $spinner = $('', { 'class': 'fa fa-spinner fa-pulse' }); @@ -1719,16 +1720,22 @@ define([ var active = privateData.category || 'account'; if (!categories[active]) { active = 'account'; } Object.keys(categories).forEach(function(key) { - var $category = $('