-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
54 lines (47 loc) · 1.87 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var isDefaultName = false;
Hooks.once("init", () => {
game.settings.register("default_name", "isDefaultName", {
name: 'is Default Name',
hint: 'If checked, there will be a be default name by placeholder in box, otherwise will focus only.',
scope: "world",
config: true,
default: false,
type: Boolean
});
isDefaultName = game.settings.get("default_name", "isDefaultName");
});
Hooks.on("renderDialog", (dialog, $element) => {
isDefaultName = game.settings.get("default_name", "isDefaultName");
if ($element.find(`input[type=text]`)[0] && !$element.find(`input[type=text]`)[0].value) {
if (isDefaultName) $element.find(`input[type=text]`)[0].value = $element.find(`input[type=text]`)[0].placeholder || 'New Item';
$element.find(`input[type=text]`)[0].focus();
}
});
Hooks.on("renderFolderConfig", (dialog, $element) => {
isDefaultName = game.settings.get("default_name", "isDefaultName");
if ($element.find(`input[type=text]`)[0] && !$element.find(`input[type=text]`)[0].value) {
if (isDefaultName) $element.find(`input[type=text]`)[0].value = $element.find(`input[type=text]`)[0].placeholder || 'New Item';
$element.find(`input[type=text]`)[0].focus();
}
});
Hooks.on("preCreateScene", (dialog) => {
if (!dialog.name) dialog.name = 'New';
});
Hooks.on("preCreateActor", (dialog) => {
if (!dialog.name) dialog.name = 'New';
});
Hooks.on("preCreateItem", (dialog) => {
if (!dialog.name) dialog.name = 'New';
});
Hooks.on("preCreateJournalEntry", (dialog) => {
if (!dialog.name) dialog.name = 'New';
});
Hooks.on("preCreateRollTable", (dialog) => {
if (!dialog.name) dialog.name = 'New';
});
Hooks.on("preCreateFolder", (dialog) => {
if (!dialog.name) dialog.name = 'New';
});
Hooks.on("preCreatePlaylist", (dialog) => {
if (!dialog.name) dialog.name = 'New';
});