Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADnD 2E Revised] Bugfix useroptions #10392

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 15 additions & 5 deletions ADnD 2E Revised/2ESheet.html
Expand Up @@ -45851,21 +45851,31 @@ <h3>Monster Sheet specific</h3>
});

// Fix for Roll20 not handling quotes correctly from sheet.json
on(BOOK_FIELDS.map(b => `change:${b}`).join(' '), function (eventInfo) {
console.log(eventInfo);
if (eventInfo.newValue && eventInfo.newValue.includes('’')) {
const fixQuotes = function (currentValue, attribute, event) {
if (currentValue.includes('’')) {
let newValue = {};
newValue[eventInfo.sourceAttribute] = eventInfo.newValue.replaceAll('’', '\'');
newValue[attribute] = currentValue.replaceAll('’', '\'');
console.log(`${attribute} was updated via ${event}`);
setAttrs(newValue,{silent:true});
}
}

on(BOOK_FIELDS.map(b => `change:${b}`).join(' '), function (eventInfo) {
if (eventInfo.newValue) {
fixQuotes(eventInfo.newValue, eventInfo.sourceAttribute, "eventInfo.newValue");
} else {
getAttrs([eventInfo.sourceAttribute], function (values) {
fixQuotes(values[eventInfo.sourceAttribute], eventInfo.sourceAttribute, "getAttrs");
});
}
});

// --- ALL SHEET WORKERS END --- //

// --- Version change start --- //

const SHEET_NAME = 'AD&D 2E Revised';
const SHEET_VERSION = '4.7.1';
const SHEET_VERSION = '4.7.2';

on('sheet:opened', function(){
getAttrs(['character_sheet'],function(attrs){
Expand Down
18 changes: 14 additions & 4 deletions ADnD 2E Revised/javascript/sheetWorkers.js
Expand Up @@ -1577,13 +1577,23 @@ on('sheet:opened', function () {
});

// Fix for Roll20 not handling quotes correctly from sheet.json
on(BOOK_FIELDS.map(b => `change:${b}`).join(' '), function (eventInfo) {
console.log(eventInfo);
if (eventInfo.newValue && eventInfo.newValue.includes('’')) {
const fixQuotes = function (currentValue, attribute, event) {
if (currentValue.includes('’')) {
let newValue = {};
newValue[eventInfo.sourceAttribute] = eventInfo.newValue.replaceAll('’', '\'');
newValue[attribute] = currentValue.replaceAll('’', '\'');
console.log(`${attribute} was updated via ${event}`);
setAttrs(newValue,{silent:true});
}
}

on(BOOK_FIELDS.map(b => `change:${b}`).join(' '), function (eventInfo) {
if (eventInfo.newValue) {
fixQuotes(eventInfo.newValue, eventInfo.sourceAttribute, "eventInfo.newValue");
} else {
getAttrs([eventInfo.sourceAttribute], function (values) {
fixQuotes(values[eventInfo.sourceAttribute], eventInfo.sourceAttribute, "getAttrs");
});
}
});

// --- ALL SHEET WORKERS END --- //
2 changes: 1 addition & 1 deletion ADnD 2E Revised/javascript/version.js
@@ -1,7 +1,7 @@
// --- Version change start --- //

const SHEET_NAME = 'AD&D 2E Revised';
const SHEET_VERSION = '4.7.1';
const SHEET_VERSION = '4.7.2';

on('sheet:opened', function(){
getAttrs(['character_sheet'],function(attrs){
Expand Down