Skip to content

Commit

Permalink
Version 2.0.0 bump
Browse files Browse the repository at this point in the history
Verified Foundry v12 compatibility and changed token tool visibility default to false.
  • Loading branch information
RichardRobertson committed Jun 14, 2024
1 parent 395e5b8 commit 5b486a0
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 128 deletions.
52 changes: 31 additions & 21 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.0] - 2023-06-24

### Added

- Menu option to change password in user list
- Settings to control visibility of token controls and user list menu items
- Both default to true
- Verified for Foundry VTT 11

## [1.0.0] - 2022-12-29

### Added

- First release
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.0] - 2024-06-13

### Added

- Verified for Foundry VTT 12

### Changed

- Changed token controls default visibility to false

## [1.1.0] - 2023-06-24

### Added

- Menu option to change password in user list
- Settings to control visibility of token controls and user list menu items
- Both default to true
- Verified for Foundry VTT 11

## [1.0.0] - 2022-12-29

### Added

- First release
66 changes: 33 additions & 33 deletions module.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"id": "update-your-password",
"title": "Update Your Password",
"description": "Allows users to update their own password",
"authors": [
{
"name": "Richard Robertson",
"url": "https://github.com/RichardRobertson"
}
],
"version": "",
"compatibility": {
"minimum": 10,
"verified": 11
},
"esmodules": [
"scripts/index.mjs"
],
"languages": [
{
"lang": "en",
"name": "English",
"path": "lang/en.json"
}
],
"url": "https://github.com/RichardRobertson/update-your-password",
"manifest": "https://github.com/RichardRobertson/update-your-password/releases/latest/download/module.json",
"download": "https://github.com/RichardRobertson/update-your-password/releases/download/v__VERSION__/update-your-password-v__VERSION__.zip",
"license": "LICENSE.md",
"readme": "README.md",
"bugs": "https://github.com/RichardRobertson/update-your-password/issues",
"changelog": "https://github.com/RichardRobertson/update-your-password/blob/main/CHANGELOG.md"
}
{
"id": "update-your-password",
"title": "Update Your Password",
"description": "Allows users to update their own password",
"authors": [
{
"name": "Richard Robertson",
"url": "https://github.com/RichardRobertson"
}
],
"version": "",
"compatibility": {
"minimum": 10,
"verified": 12
},
"esmodules": [
"scripts/index.mjs"
],
"languages": [
{
"lang": "en",
"name": "English",
"path": "lang/en.json"
}
],
"url": "https://github.com/RichardRobertson/update-your-password",
"manifest": "https://github.com/RichardRobertson/update-your-password/releases/latest/download/module.json",
"download": "https://github.com/RichardRobertson/update-your-password/releases/download/v__VERSION__/update-your-password-v__VERSION__.zip",
"license": "LICENSE.md",
"readme": "README.md",
"bugs": "https://github.com/RichardRobertson/update-your-password/issues",
"changelog": "https://github.com/RichardRobertson/update-your-password/blob/main/CHANGELOG.md"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "update-your-password",
"version": "1.1.0",
"version": "2.0.0",
"description": "Foundry VTT module that allows users to update their own password",
"repository": {
"type": "git",
Expand Down
146 changes: 73 additions & 73 deletions scripts/index.mjs
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
'use strict';

function updatePasswordDialog() {
new Dialog({
title: game.i18n.localize('update-your-password.dialog.title'),
content: `<label for="new-password">${game.i18n.localize('update-your-password.dialog.label.contents')}</label><input id="new-password" type="password"><label for="confirm-new-password">${game.i18n.localize('update-your-password.dialog.confirm-label.contents')}</label><input id="confirm-new-password" type="password">`,
buttons: {
apply: {
icon: '<i class="fas fa-check"></i>',
label: game.i18n.localize('update-your-password.dialog.buttons.apply.label'),
callback: async (html) => {
const newPassword = html.find('#new-password')[0].value;
const confirmPassword = html.find('#new-password')[0].value;
if (newPassword !== confirmPassword) {
ui.notifications.error('update-your-password.notifications.error.confirm-not-match', { localize: true});
return;
}
if (newPassword.length !== 0) {
await game.user.update({ password: newPassword });
}
}
},
cancel: {
icon: '<i class="fas fa-times"></i>',
label: game.i18n.localize('update-your-password.dialog.buttons.cancel.label')
}
},
default: 'apply'
}).render(true);
}

Hooks.on('init', function () {
game.settings.register('update-your-password', 'show-token-tool', {
name: 'update-your-password.settings.show-token-tool.name',
hint: 'update-your-password.settings.show-token-tool.hint',
scope: 'world',
config: true,
type: Boolean,
default: true,
requiresReload: true
});
game.settings.register('update-your-password', 'show-user-context-menu', {
name: 'update-your-password.settings.show-user-context-menu.name',
hint: 'update-your-password.settings.show-user-context-menu.hint',
scope: 'world',
config: true,
type: Boolean,
default: true,
requiresReload: true
});
});

Hooks.on('getSceneControlButtons', function (controls) {
if (game.settings.get('update-your-password', 'show-token-tool')) {
let tokenControls = controls.find(x => x.name === 'token');
tokenControls.tools.push({
icon: 'fas fa-key',
name: 'update-your-password',
title: game.i18n.localize('update-your-password.tool.title'),
button: true,
onClick: updatePasswordDialog
});
}
});

Hooks.on('getUserContextOptions', function (html, contextOptions) {
contextOptions.push({
name: game.i18n.localize('update-your-password.tool.title'),
icon: '<i class="fas fa-key"></i>',
callback: updatePasswordDialog,
condition: html => html.attr('data-user-id') === game.userId && game.settings.get('update-your-password', 'show-user-context-menu')
});
});
'use strict';

function updatePasswordDialog() {
new Dialog({
title: game.i18n.localize('update-your-password.dialog.title'),
content: `<label for="new-password">${game.i18n.localize('update-your-password.dialog.label.contents')}</label><input id="new-password" type="password"><label for="confirm-new-password">${game.i18n.localize('update-your-password.dialog.confirm-label.contents')}</label><input id="confirm-new-password" type="password">`,
buttons: {
apply: {
icon: '<i class="fas fa-check"></i>',
label: game.i18n.localize('update-your-password.dialog.buttons.apply.label'),
callback: async (html) => {
const newPassword = html.find('#new-password')[0].value;
const confirmPassword = html.find('#new-password')[0].value;
if (newPassword !== confirmPassword) {
ui.notifications.error('update-your-password.notifications.error.confirm-not-match', { localize: true });
return;
}
if (newPassword.length !== 0) {
await game.user.update({ password: newPassword });
}
}
},
cancel: {
icon: '<i class="fas fa-times"></i>',
label: game.i18n.localize('update-your-password.dialog.buttons.cancel.label')
}
},
default: 'apply'
}).render(true);
}

Hooks.on('init', function () {
game.settings.register('update-your-password', 'show-token-tool', {
name: 'update-your-password.settings.show-token-tool.name',
hint: 'update-your-password.settings.show-token-tool.hint',
scope: 'world',
config: true,
type: Boolean,
default: false,
requiresReload: true
});
game.settings.register('update-your-password', 'show-user-context-menu', {
name: 'update-your-password.settings.show-user-context-menu.name',
hint: 'update-your-password.settings.show-user-context-menu.hint',
scope: 'world',
config: true,
type: Boolean,
default: true,
requiresReload: true
});
});

Hooks.on('getSceneControlButtons', function (controls) {
if (game.settings.get('update-your-password', 'show-token-tool')) {
let tokenControls = controls.find(x => x.name === 'token');
tokenControls.tools.push({
icon: 'fas fa-key',
name: 'update-your-password',
title: game.i18n.localize('update-your-password.tool.title'),
button: true,
onClick: updatePasswordDialog
});
}
});

Hooks.on('getUserContextOptions', function (html, contextOptions) {
contextOptions.push({
name: game.i18n.localize('update-your-password.tool.title'),
icon: '<i class="fas fa-key"></i>',
callback: updatePasswordDialog,
condition: html => html.attr('data-user-id') === game.userId && game.settings.get('update-your-password', 'show-user-context-menu')
});
});

0 comments on commit 5b486a0

Please sign in to comment.