-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnotepad_script.user.js
117 lines (95 loc) · 4.29 KB
/
notepad_script.user.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Notepad Module
function loadNote() {
var cookieNotepadJson = localStorage.getItem('vilagges_notepad');
var notepadArray = cookieNotepadJson ? JSON.parse(cookieNotepadJson) : [];
var notepadText = notepadArray[currentVillageIndex];
if (notepadText !== '') {
toggleElement('village_note_script');
var textPlacer = document.getElementById('village-note-body_script');
textPlacer.textContent = notepadText;
}
}
function saveNote() {
var textToSave = document.getElementById('message_note_script').value;
var currentCookieValue = localStorage.getItem('vilagges_notepad');
var notepadArray = currentCookieValue ? JSON.parse(currentCookieValue) : [];
notepadArray[currentVillageIndex] = textToSave;
var jsonToSave = JSON.stringify(notepadArray);
localStorage.setItem('vilagges_notepad', jsonToSave);
toggleElement('note_body_edit');
loadNote();
toggleElement('edit_notepad_link_script');
}
function openEditModeNote() {
listenTextAreas();
var currentCookieValue = localStorage.getItem('vilagges_notepad');
var notepadArray = currentCookieValue ? JSON.parse(currentCookieValue) : [];
document.getElementById('message_note_script').value = notepadArray[currentVillageIndex];
toggleElement('note_body_edit');
document.getElementById('village_note_script').style.display = 'none';
document.getElementById('edit_notepad_link_script').style.display = 'none';
}
function injectNotepadOveriew(columnToUse) {
if (settings_cookies.general['show__notepad']) {
var editLink = document.createElement('a');
editLink.id = 'edit_notepad_link_script';
editLink.textContent = '» Editar';
editLink.addEventListener('click', openEditModeNote);
var noteTextarea = document.createElement('textarea');
noteTextarea.id = 'message_note_script';
noteTextarea.name = 'note';
noteTextarea.style.width = '97%';
noteTextarea.rows = '10';
noteTextarea.cols = '40';
var saveButton = document.createElement('a');
saveButton.id = 'note_submit_button_script';
saveButton.className = 'btn btn-default';
saveButton.textContent = 'Guardar';
saveButton.addEventListener('click', saveNote);
var table = document.createElement('table');
table.width = '100%';
var tbody = document.createElement('tbody');
var noteRow = document.createElement('tr');
noteRow.id = 'village_note_script';
noteRow.style.display = 'none';
var noteCell = document.createElement('td');
var noteDiv = document.createElement('div');
noteDiv.className = 'village-note';
var noteBodyDiv = document.createElement('div');
noteBodyDiv.id = 'village-note-body_script';
noteBodyDiv.className = 'village-note-body';
noteBodyDiv.style.whiteSpace = 'pre-wrap';
noteDiv.appendChild(noteBodyDiv);
noteCell.appendChild(noteDiv);
noteRow.appendChild(noteCell);
var editRow = document.createElement('tr');
editRow.id = 'note_body_edit';
editRow.style.display = 'none';
var editCell = document.createElement('td');
var editDiv = document.createElement('div');
editDiv.className = 'village-note';
editDiv.style.width = '100%';
editDiv.style.overflow = 'hidden';
var textareaDiv = document.createElement('div');
textareaDiv.appendChild(noteTextarea);
var buttonDiv = document.createElement('div');
buttonDiv.appendChild(saveButton);
editDiv.appendChild(textareaDiv);
editDiv.appendChild(buttonDiv);
var editNoteBodyDiv = document.createElement('div');
editNoteBodyDiv.className = 'village-note-body';
editDiv.appendChild(editNoteBodyDiv);
editCell.appendChild(editDiv);
editRow.appendChild(editCell);
var editButtonRow = document.createElement('tr');
var editButtonCell = document.createElement('td');
editButtonCell.appendChild(editLink);
editButtonRow.appendChild(editButtonCell);
tbody.appendChild(noteRow);
tbody.appendChild(editRow);
tbody.appendChild(editButtonRow);
table.appendChild(tbody);
createWidgetElement('Notepad', table, columnToUse);
loadNote();
}
}