Skip to content

Commit

Permalink
remove color on web
Browse files Browse the repository at this point in the history
  • Loading branch information
boyphongsakorn committed Jan 27, 2021
1 parent fc63449 commit 2629260
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 12 deletions.
36 changes: 28 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {app, BrowserWindow, session} = require('electron');
const {app, BrowserWindow, session, ipcMain} = require('electron');
const path = require('path');
const url = require('url');
const {autoUpdater} = require("electron-updater");
Expand Down Expand Up @@ -34,6 +34,10 @@ function createWindow () {

win.maximize();

win.once('ready-to-show', () => {
autoUpdater.checkForUpdatesAndNotify();
});

// Open the DevTools.
// win.webContents.openDevTools()

Expand All @@ -50,17 +54,17 @@ app.commandLine.appendSwitch('disable-site-isolation-trials')
// Some APIs can only be used after this event occurs.
//app.on('ready', createWindow);

autoUpdater.on('update-downloaded', (ev, info) => {
//autoUpdater.on('update-downloaded', (ev, info) => {
// Wait 5 seconds, then quit and install
// In your application, you don't need to wait 5 seconds.
// You could call autoUpdater.quitAndInstall(); immediately
setTimeout(function() {
autoUpdater.quitAndInstall();
}, 5000)
})
//setTimeout(function() {
//autoUpdater.quitAndInstall();
//}, 5000)
//})

app.on('ready', function() {
autoUpdater.checkForUpdatesAndNotify();
//autoUpdater.checkForUpdatesAndNotify();
createWindow();
});

Expand Down Expand Up @@ -89,4 +93,20 @@ app.on('activate', () => {
})

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
// code. You can also put them in separate files and require them here.

ipcMain.on('app_version', (event) => {
event.sender.send('app_version', { version: app.getVersion() });
});

autoUpdater.on('update-available', () => {
win.webContents.send('update_available');
});

autoUpdater.on('update-downloaded', () => {
win.webContents.send('update_downloaded');
});

ipcMain.on('restart_app', () => {
autoUpdater.quitAndInstall();
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/boyphongsakorn/saox.git"
"url": "https://github.com/boyphongsakorn/saox.git"
},
"keywords": [
"Music Player App"
Expand Down
53 changes: 50 additions & 3 deletions test.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#notification {
position: fixed;
bottom: 20px;
left: 20px;
width: 200px;
padding: 20px;
border-radius: 5px;
background-color: white;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}
.hidden {
display: none;
}
.container-after-titlebar {
overflow: hidden !important; /* Hide scrollbars */
}
Expand All @@ -21,6 +34,16 @@
<iframe src="https://www.joox.com/th" id="iframe" frameborder="0" onLoad="updatedl()" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;height:100%;width:100%;position:absolute;top:0px;left:0px;right:0px;bottom:0px" height="100%" width="100%">
</iframe>

<div id="notification" class="hidden">
<p id="message"></p>
<button id="close-button" onClick="closeNotification()">
Close
</button>
<button id="restart-button" onClick="restartApp()" class="hidden">
Restart
</button>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js" onload="window.$ = window.jQuery = module.exports;"></script>

<script src="https://ajax.googleapis.com/ajax/libs/d3js/5.15.1/d3.min.js"></script>
Expand All @@ -29,10 +52,34 @@

<script>

const { app, remote } = require('electron')
const { app, remote, ipcRenderer } = require('electron')
const { Menu, MenuItem } = remote
const customTitlebar = require('custom-electron-titlebar');
//const {autoUpdater} = require('electron-updater');
const notification = document.getElementById('notification');
const message = document.getElementById('message');
const restartButton = document.getElementById('restart-button');

ipcRenderer.on('update_available', () => {
ipcRenderer.removeAllListeners('update_available');
message.innerText = 'A new update is available. Downloading now...';
notification.classList.remove('hidden');
});

ipcRenderer.on('update_downloaded', () => {
ipcRenderer.removeAllListeners('update_downloaded');
message.innerText = 'Update Downloaded. It will be installed on restart. Restart now?';
restartButton.classList.remove('hidden');
notification.classList.remove('hidden');
});

function closeNotification() {
notification.classList.add('hidden');
}

function restartApp() {
ipcRenderer.send('restart_app');
}

let MyTitleBar = new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex('#444'),
Expand Down Expand Up @@ -186,8 +233,8 @@
function (data, textStatus, jqXHR) { // success callback
MyTitleBar.updateTitle('SAOX : ' + elmnt);
MyTitleBar.updateBackground(customTitlebar.Color.fromHex(data));
console.log(iframe.contentWindow.document.getElementsByClassName('MainHeader jsx-1834506763')[0].style.backgroundColor = data)
console.log(iframe.contentWindow.document.getElementsByClassName('sidebar jsx-2761629659')[0].style.backgroundColor = data)
// console.log(iframe.contentWindow.document.getElementsByClassName('MainHeader jsx-1834506763')[0].style.backgroundColor = data)
// console.log(iframe.contentWindow.document.getElementsByClassName('sidebar jsx-2761629659')[0].style.backgroundColor = data)
// console.log(iframe.contentWindow.document.getElementsByClassName('ScrollbarsCustom-Thumb ScrollbarsCustom-ThumbY')[0].style.background = data)
// console.log(iframe.contentWindow.document.getElementsByClassName('ScrollbarsCustom-Thumb ScrollbarsCustom-ThumbY')[1].style.background = data)
});
Expand Down

0 comments on commit 2629260

Please sign in to comment.