Skip to content

Commit 243464b

Browse files
committed
Minor syntax changes to ChatSetAttr 1.0.1
1 parent 4443898 commit 243464b

File tree

2 files changed

+16
-28
lines changed

2 files changed

+16
-28
lines changed

ChatSetAttr/1.0.1/ChatSetAttr.js

+8-14
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,13 @@ var chatSetAttr = chatSetAttr || (function() {
2323
handleError = function(who, errorMsg) {
2424
let output = '/w "' + who
2525
+ '" <div style="border: 1px solid black; background-color: #FFBABA; padding: 3px 3px;">'
26-
+ '<h4>Error</h4>'
27-
+ '<p>'+errorMsg+'</p>'
28-
+ '</div>';
26+
+ '<h4>Error</h4>'+'<p>'+errorMsg+'</p>'+'</div>';
2927
sendChat('ChatSetAttr', output, null, {noarchive:true});
3028
},
3129

3230
getPlayerName = function(who) {
3331
let match = who.match(/(.*) \(GM\)/);
34-
if (match) {
35-
return match[1];
36-
} else {
37-
return who;
38-
}
32+
return (match) ? match[1] : who;
3933
},
4034

4135
processInlinerolls = function (msg) {
@@ -414,12 +408,14 @@ var chatSetAttr = chatSetAttr || (function() {
414408
handleInput = function(msg) {
415409
if (msg.type === 'api' && msg.content.search(/^!(set|del)attr\b/) !== -1) {
416410
// Parsing input
417-
let charIDList, deleteMode = false;
418-
let who = getPlayerName(msg.who);
411+
let charIDList;
419412
const hasValue = ['charid','name'],
420413
optsArray = ['all','allgm','charid','name','silent','sel','replace', 'nocreate','mod'],
414+
who = getPlayerName(msg.who),
421415
opts = parseOpts(processInlinerolls(msg),hasValue),
422-
setting = parseAttributes(_.chain(opts).omit(optsArray).keys().value(),opts.replace);
416+
setting = parseAttributes(_.chain(opts).omit(optsArray).keys().value(),opts.replace),
417+
deleteMode = (msg.content.search(/^!delattr\b/) !== -1);
418+
423419
if (_.isEmpty(setting)) {
424420
handleError(who, 'No attributes supplied.');
425421
return;
@@ -443,9 +439,7 @@ var chatSetAttr = chatSetAttr || (function() {
443439
handleError(who,'No target characters. You need to supply one of --all, --allgm, --sel, --charid, or --name.');
444440
return;
445441
}
446-
if (msg.content.search(/^!delattr\b/) !== -1) {
447-
deleteMode = true;
448-
}
442+
449443
// Get attributes
450444
let allAttrs = getAllAttributes(who, charIDList, setting, !opts.nocreate && !deleteMode, deleteMode);
451445

ChatSetAttr/ChatSetAttr.js

+8-14
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,13 @@ var chatSetAttr = chatSetAttr || (function() {
2323
handleError = function(who, errorMsg) {
2424
let output = '/w "' + who
2525
+ '" <div style="border: 1px solid black; background-color: #FFBABA; padding: 3px 3px;">'
26-
+ '<h4>Error</h4>'
27-
+ '<p>'+errorMsg+'</p>'
28-
+ '</div>';
26+
+ '<h4>Error</h4>'+'<p>'+errorMsg+'</p>'+'</div>';
2927
sendChat('ChatSetAttr', output, null, {noarchive:true});
3028
},
3129

3230
getPlayerName = function(who) {
3331
let match = who.match(/(.*) \(GM\)/);
34-
if (match) {
35-
return match[1];
36-
} else {
37-
return who;
38-
}
32+
return (match) ? match[1] : who;
3933
},
4034

4135
processInlinerolls = function (msg) {
@@ -414,12 +408,14 @@ var chatSetAttr = chatSetAttr || (function() {
414408
handleInput = function(msg) {
415409
if (msg.type === 'api' && msg.content.search(/^!(set|del)attr\b/) !== -1) {
416410
// Parsing input
417-
let charIDList, deleteMode = false;
418-
let who = getPlayerName(msg.who);
411+
let charIDList;
419412
const hasValue = ['charid','name'],
420413
optsArray = ['all','allgm','charid','name','silent','sel','replace', 'nocreate','mod'],
414+
who = getPlayerName(msg.who),
421415
opts = parseOpts(processInlinerolls(msg),hasValue),
422-
setting = parseAttributes(_.chain(opts).omit(optsArray).keys().value(),opts.replace);
416+
setting = parseAttributes(_.chain(opts).omit(optsArray).keys().value(),opts.replace),
417+
deleteMode = (msg.content.search(/^!delattr\b/) !== -1);
418+
423419
if (_.isEmpty(setting)) {
424420
handleError(who, 'No attributes supplied.');
425421
return;
@@ -443,9 +439,7 @@ var chatSetAttr = chatSetAttr || (function() {
443439
handleError(who,'No target characters. You need to supply one of --all, --allgm, --sel, --charid, or --name.');
444440
return;
445441
}
446-
if (msg.content.search(/^!delattr\b/) !== -1) {
447-
deleteMode = true;
448-
}
442+
449443
// Get attributes
450444
let allAttrs = getAllAttributes(who, charIDList, setting, !opts.nocreate && !deleteMode, deleteMode);
451445

0 commit comments

Comments
 (0)