Skip to content

Commit

Permalink
refactor: npm run fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
shrihankp committed Apr 18, 2023
1 parent c2707da commit 35d1986
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 48 deletions.
103 changes: 57 additions & 46 deletions public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,16 @@ ws.onmessage = (msg) => {

versionsElement.innerHTML += `
<li>
${message.page != 1 ? `<button id="prevPage" onclick="getAppVersions(${message.isRooted}, ${message.page - 1})">Previous Page</button>` : ""}
<button id="nextPage" onclick="getAppVersions(${message.isRooted}, ${message.page + 1})">Next Page</button>
${
message.page != 1
? `<button id="prevPage" onclick="getAppVersions(${
message.isRooted
}, ${message.page - 1})">Previous Page</button>`
: ''
}
<button id="nextPage" onclick="getAppVersions(${message.isRooted}, ${
message.page + 1
})">Next Page</button>
</li>`;

for (let i = 0; i < len; i++) {
Expand Down Expand Up @@ -431,36 +439,38 @@ ws.onmessage = (msg) => {
};
}
break;
case 'installingStockApp': {
if (message.status === 'DOWNLOAD_STARTED') {
document.getElementsByTagName('header')[0].innerHTML =
'<h1><i class="fa-solid fa-download"></i>Downloading APK</h1>';
document.getElementById('content').innerHTML =
'<span class="log"></span>';
document.getElementsByTagName('main')[0].innerHTML +=
'<progress value="0"></progress>';
isDownloading = true;
document.getElementById('continue').classList.add('disabled');
} else if (message.status === 'DOWNLOAD_COMPLETE') {
document.getElementById('continue').classList.add('disabled');
isDownloading = false;
document.getElementsByClassName(
'log'
)[0].innerHTML += `<span class="log-line info"><strong>[builder]</strong> Uninstalling the stock app...</span><br>`;
} else if (message.status === 'UNINSTALL_COMPLETE') {
document.getElementsByClassName(
'log'
)[0].innerHTML += `<span class="log-line info"><strong>[builder]</strong> Installing the downloaded (stock) APK...</span><br>`;
} else if (message.status === 'ALL_DONE') {
document.getElementsByClassName(
'log'
)[0].innerHTML += `<span class="log-line info"><strong>[builder]</strong> Complete.</span><br>`;
document.getElementById('continue').classList.remove('disabled');
document.getElementById('continue').onclick = () => {
location.href = '/patch';
};
case 'installingStockApp':
{
if (message.status === 'DOWNLOAD_STARTED') {
document.getElementsByTagName('header')[0].innerHTML =
'<h1><i class="fa-solid fa-download"></i>Downloading APK</h1>';
document.getElementById('content').innerHTML =
'<span class="log"></span>';
document.getElementsByTagName('main')[0].innerHTML +=
'<progress value="0"></progress>';
isDownloading = true;
document.getElementById('continue').classList.add('disabled');
} else if (message.status === 'DOWNLOAD_COMPLETE') {
document.getElementById('continue').classList.add('disabled');
isDownloading = false;
document.getElementsByClassName(
'log'
)[0].innerHTML += `<span class="log-line info"><strong>[builder]</strong> Uninstalling the stock app...</span><br>`;
} else if (message.status === 'UNINSTALL_COMPLETE') {
document.getElementsByClassName(
'log'
)[0].innerHTML += `<span class="log-line info"><strong>[builder]</strong> Installing the downloaded (stock) APK...</span><br>`;
} else if (message.status === 'ALL_DONE') {
document.getElementsByClassName(
'log'
)[0].innerHTML += `<span class="log-line info"><strong>[builder]</strong> Complete.</span><br>`;
document.getElementById('continue').classList.remove('disabled');
document.getElementById('continue').onclick = () => {
location.href = '/patch';
};
}
}
}
break;
case 'patchLog':
{
const logLevel = message.log.includes('WARNING')
Expand Down Expand Up @@ -562,25 +572,26 @@ ws.onmessage = (msg) => {
}
break;
}
case 'askRootVersion': {
const confirmVer = confirm(
`**Non Recommended Version**\nYour device has a non recommended version. This means you have to let the builder replace the stock YouTube with a recommended version.\nContinue?`
);

if (confirmVer)
return sendCommand({
event: 'getAppVersion',
installLatestRecommended: true
});
else {
if (confirm('Alright, proceed with the non-recommended version?'))
case 'askRootVersion':
{
const confirmVer = confirm(
`**Non Recommended Version**\nYour device has a non recommended version. This means you have to let the builder replace the stock YouTube with a recommended version.\nContinue?`
);

if (confirmVer)
return sendCommand({
event: 'getAppVersion',
useVer: true
installLatestRecommended: true
});
else {
if (confirm('Alright, proceed with the non-recommended version?'))
return sendCommand({
event: 'getAppVersion',
useVer: true
});
}
}
}

break;
case 'appList': {
let id = 0;
for (const app of message.list) {
Expand Down
7 changes: 5 additions & 2 deletions wsEvents/getAppVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const { getAppVersion: getAppVersion_ } = require('../utils/getAppVersion.js');
const { downloadApp: downloadApp_ } = require('../utils/downloadApp.js');
const getDeviceArch = require('../utils/getDeviceArch.js');

const APKMIRROR_UPLOAD_BASE = (page) => `https://www.apkmirror.com/uploads/page/${page}/?appcategory=`;
const APKMIRROR_UPLOAD_BASE = (page) =>
`https://www.apkmirror.com/uploads/page/${page}/?appcategory=`;

/**
* @param {string} ver
Expand Down Expand Up @@ -124,7 +125,9 @@ async function downloadApp(ws, message) {
*/
module.exports = async function getAppVersion(ws, message) {
let versionsList = await getPage(
`${APKMIRROR_UPLOAD_BASE(message.page || 1)}${global.jarNames.selectedApp.link.split('/')[3]}`
`${APKMIRROR_UPLOAD_BASE(message.page || 1)}${
global.jarNames.selectedApp.link.split('/')[3]
}`
);

if (global.jarNames.isRooted) {
Expand Down

0 comments on commit 35d1986

Please sign in to comment.