-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
174 lines (137 loc) · 6.23 KB
/
index.js
File metadata and controls
174 lines (137 loc) · 6.23 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import { Modlist } from "./modlist.js"
import { ModReport } from "./modreport.js"
import { animate } from "./libs/anime-4.3.6-modules/animation/index.js"
const inputTextWrapper = document.getElementById('inputTextWrapper')
const inputText = document.getElementById('inputText')
let firstModList = ''
let secondModList = ''
fadeInElement(inputTextWrapper)
inputText.focus()
inputText.addEventListener('input', _on_inputText_input)
function _on_inputText_input() {
const pastedText = inputText.value
if (pastedText.length == 1) {
scoldUserForTypingAndRetry()
} else {
if (firstModList === '') {
firstModList = inputText.value
inputText.value = ''
inputText.placeholder = 'Paste the current modlist here...'
}
else if (secondModList === '') {
inputText.disabled = true
secondModList = inputText.value
inputText.placeholder = 'Splendid.'
inputText.value = ''
inputText.removeEventListener('input', _on_inputText_input)
fadeOutInputTextWrapper()
}
}
}
function scoldUserForTypingAndRetry() {
inputText.disabled = true
inputText.value = "Paste, don't type."
animate(inputTextWrapper, {
color : ['#ff0000', '#000000'],
duration : 1000,
ease : 'inExpo',
onComplete : () => {
inputText.value = ''
fadeInElement(inputTextWrapper)
inputText.disabled = false
inputTextWrapper.style.color = 'white'
inputText.focus()
}
})
}
function fadeInElement(el) {
animate(el, {
opacity : [0, 1],
duration : 1000,
})
}
function fadeOutInputTextWrapper() {
animate(inputTextWrapper, {
opacity : [1,0],
duration : 1000,
easy : 'inExpo',
onComplete : () => {
inputTextWrapper.remove()
compareModLists()
}
})
}
function compareModLists() {
const parsedFirstModList = new Modlist(firstModList)
const parsedSecondModList = new Modlist(secondModList)
const modReports = parsedFirstModList.compare(parsedSecondModList)
showResults(modReports)
}
function showResults(modReports) {
const appWrapper = document.getElementById('appWrapper')
const resultWrapper = document.createElement('div')
resultWrapper.id = 'resultWrapper'
if (modReports.length == 0) {
const divIdenticalModLists = document.createElement('div')
divIdenticalModLists.id = 'divIdenticalModLists'
divIdenticalModLists.textContent = 'The modlists are identical.'
resultWrapper.appendChild(divIdenticalModLists)
appWrapper.appendChild(resultWrapper)
fadeInElement(divIdenticalModLists)
} else {
let ulMissingModsList = document.createElement('ul')
let divMissingModsText = document.createElement('div')
divMissingModsText.classList.add('resultContainerTextDiv')
divMissingModsText.textContent = 'Missing mods'
let divMissingModsContainer = document.createElement('div')
divMissingModsContainer.id = 'divMissingModsContainer'
divMissingModsContainer.classList.add('resultContainer')
divMissingModsContainer.appendChild(divMissingModsText)
divMissingModsContainer.appendChild(ulMissingModsList)
let ulMismatchedModsList = document.createElement('ul')
let divMismatchedModsText = document.createElement('div')
divMismatchedModsText.classList.add('resultContainerTextDiv')
divMismatchedModsText.textContent = 'Mismatched mods'
let divMismatchedModsContainer = document.createElement('div')
divMismatchedModsContainer.id = 'divMismatchedModsContainer'
divMismatchedModsContainer.classList.add('resultContainer')
divMismatchedModsContainer.appendChild(divMismatchedModsText)
divMismatchedModsContainer.appendChild(ulMismatchedModsList)
let ulExtraModsList = document.createElement('ul')
let divExtraModsText = document.createElement('div')
divExtraModsText.classList.add('resultContainerTextDiv')
divExtraModsText.textContent = 'Extra mods'
let divExtraModsContainer = document.createElement('div')
divExtraModsContainer.id = 'divExtraModsContainer'
divExtraModsContainer.classList.add('resultContainer')
divExtraModsContainer.appendChild(divExtraModsText)
divExtraModsContainer.appendChild(ulExtraModsList)
resultWrapper.appendChild(divMissingModsContainer)
resultWrapper.appendChild(divMismatchedModsContainer)
resultWrapper.appendChild(divExtraModsContainer)
for (let modReport of modReports) {
let modReportText = document.createElement('li')
modReportText.classList.add('listItemModReportEntry')
switch (modReport.getReportType()) {
case ModReport.MOD_MISSING:
let missingMod = modReport.getMod()
modReportText.textContent = missingMod.getModName() + ' [' + missingMod.getModVersion() + ']'
ulMissingModsList.appendChild(modReportText)
break
case ModReport.MOD_UNEXPECTED:
let unexpectedMod = modReport.getMod()
modReportText.textContent = unexpectedMod.getModName() + ' [' + unexpectedMod.getModVersion() + ']'
ulExtraModsList.appendChild(modReportText)
break
case ModReport.MOD_VERSION_MISMATCH:
let versionMismatchedMod = modReport.getMod()
modReportText.textContent = versionMismatchedMod.getModName() + ' [' + modReport.getMismatchedValue() + '] -> [' + versionMismatchedMod.getModVersion() + ']'
ulMismatchedModsList.appendChild(modReportText)
break
case ModReport.MOD_FILENAME_MISMATCH:
// Surprisingly, no thing here. I find it unlikely that a mod has same version BUT a different filename. I guess print something onscreen?
}
}
appWrapper.appendChild(resultWrapper)
}
}