Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
paveldrobny committed Sep 28, 2021
1 parent 3c9de51 commit cf14152
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 10 deletions.
35 changes: 30 additions & 5 deletions event.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { ipcRenderer } = require("electron");

const electron = window.require("electron");
const URL =
"https://firebasestorage.googleapis.com/v0/b/personal-24c21.appspot.com/o/Version.txt?alt=media&token=96fbd6bd-5045-4adf-8817-87504b84859c";
const SITE_VERSION = "0.1.5";

const webView = document.querySelector("webview"),
minBtn = document.getElementById("min-btn"),
Expand All @@ -13,13 +14,33 @@ const webView = document.querySelector("webview"),
viewDevTools = document.getElementById("view-devTools"),
//viewAppTools = document.getElementById("view-appTools"),
timerAction = document.getElementById("timer-action"),
remainingTime = document.getElementById("remaining-time");
remainingTime = document.getElementById("remaining-time"),
updateReady = document.getElementsByClassName("update-ready"),
updateApp = document.getElementById("update-ready-button");
// title = document.getElementById("page-title");

// webView.addEventListener("update-target-url", () => {
// title.innerHTML = webView.getURL();
// });

const checkVersion = () => {
setInterval(function () {
fetch(URL).then(function (response) {
response.text().then(function (version) {
if (SITE_VERSION == version) {
updateReady[0].classList.remove("is-show");
} else {
updateReady[0].classList.add("is-show");
}
});
});
}, 5000);
};

window.addEventListener("load", function () {
checkVersion();
});

minBtn.addEventListener("click", function () {
electron.ipcRenderer.send("app-minimize");
});
Expand All @@ -32,12 +53,16 @@ closeBtn.addEventListener("click", function () {
electron.ipcRenderer.send("app-close");
});

updateApp.addEventListener("click", function () {
electron.ipcRenderer.send("app-reload");
});

let isStart = false,
timer,
courseTimer;

const TIME_IN_MINUTES = 1;
const TARGET_TIME = TIME_IN_MINUTES * 30;
const TIME_IN_MINUTES = 4;
const TARGET_TIME = TIME_IN_MINUTES * 60;

const startAction = () => {
timerAction.innerHTML = "СТОП";
Expand Down
5 changes: 4 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@
</div>
</div>
<webview id="web-view" src="http://e.adidonntu.ru/"></webview>

<div class="update-ready">
Доступно обновлениe
<button id="update-ready-button">Перезагрузить</button>
</div>
<script src="./event.js" type="module"></script>
</body>
</html>
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ function createWindow() {
webSecurity: true,
},
});

//mainWindow.hide();
// mainWindow.loadFile("index.html");
mainWindow.hide();
mainWindow.loadURL("https://paveldrobny.github.io/EasyMoodle/");
mainWindow.webContents.session.clearCache(() => {
win.webContents.session.clearStorageData();
Expand All @@ -58,6 +56,10 @@ function createWindow() {
mainWindow.close();
});

ipcMain.on("app-reload", () => {
mainWindow.reload();
});

ipcMain.on("app-code", () => {
if (mainWindow.webContents.isDevToolsOpened()) {
mainWindow.webContents.closeDevTools();
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"dependencies": {
"electron-log": "^4.4.1",
"electron-updater": "^4.3.9",
"firebase": "^9.1.0",
"i": "^0.3.7"
},
"build": {
Expand Down
28 changes: 27 additions & 1 deletion styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ body, html {
.nav-btn.other {
cursor: default;
width: 5px;
background:none
background: none
}

.line {
Expand Down Expand Up @@ -156,6 +156,7 @@ body, html {
}

#web-view {
z-index: 99;
position: relative;
top: -3px;
left: 1px;
Expand Down Expand Up @@ -195,4 +196,29 @@ body, html {
overflow: hidden;
letter-spacing: 1px;
color: rgb(235, 235, 235);
}

.update-ready {
z-index: 999;
position: absolute;
width: 100%;
bottom: -35px;
text-align: center;
padding: 4px;
font-size: 13px;
color: white;
transition: .3s;
background: rgb(180, 42, 42);
}

#update-ready-button {
margin-left: 10px;
border-radius: 5px;
padding: 5px 7px;
color: rgb(251, 251, 251);
background: rgb(21, 129, 21);
}

.is-show {
bottom: 0px;
}

0 comments on commit cf14152

Please sign in to comment.