Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
reis committed Sep 20, 2022
1 parent 2e27317 commit 10213ae
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 37 deletions.
66 changes: 41 additions & 25 deletions public/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable no-unused-vars */

const WS_URI = `${window?.location?.protocol === 'https:' ? 'wss' : 'ws'}://${window?.location?.host ?? 'localhost:8080'
}`;
const WS_URI = `${window?.location?.protocol === 'https:' ? 'wss' : 'ws'}://${
window?.location?.host ?? 'localhost:8080'
}`;
const ws = new WebSocket(WS_URI);

let currentFile;
Expand Down Expand Up @@ -158,9 +159,10 @@ function getAppVersions(isRooted) {
document.getElementsByTagName('header')[0].innerHTML = `
<h1>Select the version you want to download</h1>
<span>Versions marked as beta might have bugs or can be unstable, unless marked as recommended<span>
${isRooted
? '<span><strong>You are building rooted ReVanced</strong>, ReVanced Builder will automatically download the correct version for you.<br>If you didn\'t intend on doing a rooted build, include all "Root required to exclude" patches<span>'
: ''
${
isRooted
? '<span><strong>You are building rooted ReVanced</strong>, ReVanced Builder will automatically download the correct version for you.<br>If you didn\'t intend on doing a rooted build, include all "Root required to exclude" patches<span>'
: ''
}
`;

Expand Down Expand Up @@ -261,13 +263,18 @@ ws.onmessage = (msg) => {
const patch = message.patchList[i];

patchListElement.innerHTML += `<li>
<input class="select" id="select-patch-${i}" data-patch-name="${patch.name
}" data-excluded="${patch.excluded ? '1' : '0'}" type="checkbox">
<input class="select" id="select-patch-${i}" data-patch-name="${
patch.name
}" data-excluded="${patch.excluded ? '1' : '0'}" type="checkbox">
<label for="select-patch-${i}">
<span style="float:right;"><strong>${patch.isRooted ? 'Needed for Non-Root Building' : ''
}</strong></span>
<span><strong class="patchName">${toTitleCase(patch.name)}</strong>&nbsp;&nbsp;(${patch.maxVersion !== ' ' ? patch.maxVersion : 'ALL'
})</span>
<span style="float:right;"><strong>${
patch.isRooted ? 'Needed for Non-Root Building' : ''
}</strong></span>
<span><strong class="patchName">${toTitleCase(
patch.name
)}</strong>&nbsp;&nbsp;(${
patch.maxVersion !== ' ' ? patch.maxVersion : 'ALL'
})</span>
<span class="patch-description">${patch.description}</span>
</label>
</li>`;
Expand All @@ -278,7 +285,7 @@ ws.onmessage = (msg) => {
if (searchText.lenght === 0) return;

for (const e of document.getElementsByTagName('li'))
e.style.display = 'none'
e.style.display = 'none';

for (const e of document.getElementsByClassName('patchName')) {
if (e.innerText.toLowerCase().startsWith(searchText)) {
Expand Down Expand Up @@ -341,12 +348,16 @@ ws.onmessage = (msg) => {

versionsElement.innerHTML += `
<li>
<input type="radio" name="version" id="app-${i}" value="${version.version
}" data-beta="${version.beta ? '1' : '0'}" ${!noRec ? ('data-recommended=' + version.recommended ? 1 : 0) : ''
}/>
<label for="app-${i}">${version.version} ${version.beta ? ' (beta)' : ''
} ${!noRec ? (version.recommended ? ' (recommended)' : '') : ''
}</label></li>`;
<input type="radio" name="version" id="app-${i}" value="${
version.version
}" data-beta="${version.beta ? '1' : '0'}" ${
!noRec ? ('data-recommended=' + version.recommended ? 1 : 0) : ''
}/>
<label for="app-${i}">${version.version} ${
version.beta ? ' (beta)' : ''
} ${
!noRec ? (version.recommended ? ' (recommended)' : '') : ''
}</label></li>`;
}

if (message.selectedApp === 'music' && !message.foundDevice)
Expand Down Expand Up @@ -384,8 +395,8 @@ ws.onmessage = (msg) => {
const logLevel = message.log.includes('WARNING')
? 'warn'
: message.log.includes('SEVERE')
? 'error'
: 'info';
? 'error'
: 'info';

document.getElementsByClassName(
'log'
Expand All @@ -400,11 +411,13 @@ ws.onmessage = (msg) => {
// TODO: on a root install, if the file already exists and the user selects yes it skips checking if a device is plugged in
document.getElementsByTagName('header')[0].innerHTML = `
<h1>Use already downloaded APK?</h1>
<span>The APK already exists in the revanced folder.${message.isRooted ? ' ' : '<br>'
}Do you want to use it?${message.isRooted
<span>The APK already exists in the revanced folder.${
message.isRooted ? ' ' : '<br>'
}Do you want to use it?${
message.isRooted
? '<br>(Saying no is recommended for rooted building)<br>If you didn\'t intend on doing a rooted build, include all "Root required to exclude" patches'
: ''
}</span>`;
}</span>`;

const continueButton = document.getElementById('continue');
const backButton = document.getElementById('back');
Expand Down Expand Up @@ -465,9 +478,12 @@ ws.onmessage = (msg) => {
break;
}
case 'askRootVersion': {
const confirmVer = confirm(`**Non Recommended Version**\nYour device has an non recommended version, do you want to patch it?`);
const confirmVer = confirm(
`**Non Recommended Version**\nYour device has an non recommended version, do you want to patch it?`
);

if (confirmVer) return sendCommand({ event: 'getAppVersion', useVer: true });
if (confirmVer)
return sendCommand({ event: 'getAppVersion', useVer: true });
else return sendCommand({ event: 'getAppVersion' });
}
}
Expand Down
6 changes: 5 additions & 1 deletion public/patches/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ <h1>Select patches to include</h1>
<button onclick="toggle(false)">Deselect all</button>
</div>
<div>
<input id="search" type="text" placeholder="Search for a patch...">
<input
id="search"
type="text"
placeholder="Search for a patch..."
/>
</div>
</header>
<div id="content--wrapper">
Expand Down
4 changes: 2 additions & 2 deletions utils/downloadApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ async function downloadApp(ws) {
event: 'finished'
})
);
};
}

module.exports = {
downloadApp
}
};
25 changes: 16 additions & 9 deletions wsEvents/getAppVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,22 @@ async function getPage(url) {
async function downloadApp(ws, message) {
if (message.useVer) return await downloadApp_(ws);
else if (message.checkVer) {
if (global.versions.includes(global.apkInfo.version)) return await downloadApp_(ws);

return ws.send(JSON.stringify({
event: 'askRootVersion'
}));
} else return ws.send(JSON.stringify({
event: 'error',
error: 'You did not choose to use the non recommended version. Please downgrade.'
}));
if (global.versions.includes(global.apkInfo.version))
return await downloadApp_(ws);

return ws.send(
JSON.stringify({
event: 'askRootVersion'
})
);
} else
return ws.send(
JSON.stringify({
event: 'error',
error:
'You did not choose to use the non recommended version. Please downgrade.'
})
);
}

/**
Expand Down

0 comments on commit 10213ae

Please sign in to comment.