Skip to content

Commit dfd029f

Browse files
refactor: preserve original module names
Removed formatName() and capitalizeFirst() transformations from remote.js and node_helper.js. Module names now display as-is (e.g., "MMM-Remote-Control" not "Remote Control").
1 parent 8c7cea0 commit dfd029f

2 files changed

Lines changed: 8 additions & 15 deletions

File tree

node_helper.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,14 @@ module.exports = NodeHelper.create({
203203
this.modulesAvailable = JSON.parse(data.toString());
204204

205205
for (const module of this.modulesAvailable) {
206-
module.name = this.formatName(module.longname);
206+
module.name = module.longname;
207207
module.isDefaultModule = false;
208208
}
209209

210210
for (const [index, moduleName] of defaultModules.entries()) {
211211
this.modulesAvailable.push({
212212
longname: moduleName,
213-
name: this.capitalizeFirst(moduleName),
213+
name: moduleName,
214214
isDefaultModule: true,
215215
installed: true,
216216
author: "MagicMirrorOrg",
@@ -259,7 +259,7 @@ module.exports = NodeHelper.create({
259259
if (!currentModule) {
260260
const newModule = {
261261
longname: folderName,
262-
name: this.formatName(folderName),
262+
name: folderName,
263263
isDefaultModule: false,
264264
installed: true,
265265
author: "unknown",

remote.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -704,13 +704,6 @@ const Remote = {
704704
}
705705
},
706706

707-
formatName (string) {
708-
string = string.replaceAll(/MMM?-/ig, "").replaceAll("_", " ").replaceAll("-", " ");
709-
string = string.replaceAll(/([a-z])([A-Z])/g, (txt) => `${txt[0]} ${txt[1]}`);
710-
string = string.replaceAll(/\w\S*/g, (txt) => txt.at(0).toUpperCase() + txt.slice(1));
711-
return string.at(0).toUpperCase() + string.slice(1);
712-
},
713-
714707
formatLabel (string) {
715708

716709
/*
@@ -824,7 +817,7 @@ const Remote = {
824817

825818
const text = document.createElement("span");
826819
text.className = "text";
827-
text.innerHTML = ` ${this.formatName(module.name)}`;
820+
text.innerHTML = ` ${module.name}`;
828821
if ("header" in module) {
829822
text.innerHTML += ` (${module.header})`;
830823
}
@@ -883,7 +876,7 @@ const Remote = {
883876
const select = document.createElement("select");
884877
for (const typeOption of this.types) {
885878
const option = document.createElement("option");
886-
option.innerHTML = this.formatName(typeOption);
879+
option.innerHTML = typeOption;
887880
option.value = typeOption;
888881
if (typeOption === type) {
889882
option.selected = "selected";
@@ -918,7 +911,7 @@ const Remote = {
918911
label.append(desc);
919912

920913
if (!forcedType) {
921-
const typeLabel = Remote.createSymbolText("fa fa-fw fa-pencil", this.formatName(type), (event) => {
914+
const typeLabel = Remote.createSymbolText("fa fa-fw fa-pencil", type, (event) => {
922915
const thisElement = event.currentTarget;
923916
label.replaceChild(this.createTypeEditSelection(key, label, type, thisElement), thisElement);
924917
}, "span");
@@ -1270,7 +1263,7 @@ const Remote = {
12701263
const wrapper = this.getPopupContent();
12711264

12721265
const name = document.createElement("div");
1273-
name.innerHTML = this.formatName(data.module);
1266+
name.innerHTML = data.module;
12741267
name.className = "bright title medium";
12751268
wrapper.append(name);
12761269

@@ -1310,7 +1303,7 @@ const Remote = {
13101303
// Module name (left side)
13111304
const moduleName = document.createElement("div");
13121305
moduleName.className = "module-name";
1313-
moduleName.textContent = this.formatName(data.module);
1306+
moduleName.textContent = data.module;
13141307
innerWrapper.append(moduleName);
13151308

13161309
// Buttons container (right side)

0 commit comments

Comments
 (0)