Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
QuarkPixel committed Aug 19, 2022
1 parent d8a6b5a commit 11d8e06
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 4 deletions.
116 changes: 116 additions & 0 deletions Check-Download.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
let userOrOrgName = "QuarkPixel";
let repoName = "ScreenAmbientLight";
let currentVersion = "0.1.0";
let checker = UpdateChecker.createNew(userOrOrgName, repoName, currentVersion);
checker.hasNewVersion(function (result) {
if(result) {
checker.openBrowserToReleases();
}
});

function loadapp(url, btnId, num) {
mui("body").on("tap", btnId, function () {
var loadId = this.getAttribute("id")
sendloadId = loadId.slice(num)
var getvalue = document.getElementById(loadId).innerHTML
var loaddata = {
config: {
id: sendloadId,
},
fun_Success: function (data) {
console.log(JSON.stringify(data))
var geturl = data.data.down_a
if (geturl == "") {
alert("暂无数据可供下载")
} else {
createDownload(geturl, loadId)
}
},
}
if (getvalue == "下载") {
Fun_App.ExAjax(url, loaddata)
}
if (getvalue != "下载") {
document
.getElementById(loadId)
.addEventListener("tap", function () {
document.getElementById(loadId).innerHTML = "暂停"
pauseDownload()
})
}
if (getvalue == "暂停") {
document
.getElementById(loadId)
.addEventListener("tap", function () {
resumeDownload()
})
}
})
}

/*
* 创建下载任务
*/
function createDownload(url, loadId) {
dTask = plus.downloader.createDownload(url)
dTask.addEventListener(
"statechanged",
function (download, status) {
var fimeName = download.getFileName().slice(11).replace(".apk", "")
if (download.state == 4 && status == 200) {
document.getElementById(loadId).innerHTML = "下载"
plus.nativeUI.confirm(
"下载已完成,是否安装?",
function (e) {
if (e.index == 0) {
openFile(download.getFileName())
} else {
del()
}
},
fimeName,
["确定", "取消"]
)
} else {
var progress =
(download.downloadedSize / download.totalSize) * 100
progress = parseInt(progress.toFixed(2))
if (isNaN(progress)) {
document.getElementById(loadId).innerHTML = "下载"
} else if (progress == 100) {
del()
document.getElementById(loadId).innerHTML = "下载"
} else {
document.getElementById(loadId).innerHTML = progress + "%"
}
}
},
false
)
dTask.start()
}

/*
* 暂停下载任务
*/
// function pauseDownload() {
// dtask.pause()
// }
/*
* 恢复下载任务
*/
// function resumeDownload() {
// dtask.resume()
// }
/*
* 取消下载
*/
// function del() {
// plus.downloader.clear()
// }
/*
* 打开文件操作
*/
function openFile(fileName) {
plus.runtime.openFile(fileName)
}
File renamed without changes.
2 changes: 1 addition & 1 deletion index.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#ScreenLamp {
background-color: #e500e5;
/* background-color: #e500e5; */
}
7 changes: 4 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<html lang="zh_ch">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="NoSleep.min.js"></script>
<script src="NoSleep.js"></script>
<!-- <script src="Check-Download.js"></script> -->
<!-- <link
rel="shortcut icon"
href="https://imgtu.ly2018.top/img/2022/07/220714_zzHPVzPZ_ICON.png" /> -->
Expand All @@ -23,6 +24,6 @@
<div id="ScreenLamp"></div>
<input type="button" id="toggle" value="Wake Lock is disabled" />
</body>
<script src="index.js"></script>
<script src="index.js" type="module"></script>

</html>
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// console.log(aaa);
// import * as name from './NoSleep.min.js'
// checker()
var noSleep = new NoSleep()

var wakeLockEnabled = false
Expand Down

0 comments on commit 11d8e06

Please sign in to comment.