├── css
├── postbirdAlertBox.css
└── style.css
├── fonts
└── DIGITAL.ttf
├── img
└── favicon.ico
├── index.html
└── js
├── be-full.js
├── postbirdAlertBox.min.js
└── script.js
/css/postbirdAlertBox.css:
--------------------------------------------------------------------------------
1 | /**
2 | * PostbirdAlertBox.js
3 | * 原生javascript弹框插件
4 | * Author: Postbird - http://www.ptbird.cn
5 | * License: MIT
6 | * Date: 2017-09-23
7 | */
8 |
9 | * {
10 | margin: 0;
11 | padding: 0;
12 | box-sizing: border-box
13 | }
14 |
15 | .postbird-box-container {
16 | width: 100%;
17 | height: 100%;
18 | overflow: hidden;
19 | position: fixed;
20 | top: 0;
21 | left: 0;
22 | z-index: 9999;
23 | background-color: rgba(0, 0, 0, 0.2);
24 | display: block;
25 | -webkit-user-select: none;
26 | -moz-user-select: none;
27 | -ms-user-select: none;
28 | user-select: none
29 | }
30 |
31 | .postbird-box-container.active {
32 | display: block
33 | }
34 |
35 | .postbird-box-content {
36 | border-radius: 10px;
37 | overflow: hidden;
38 | width: 400px;
39 | max-width: 90%;
40 | background-color: #fff;
41 | border: solid 1px #dfdfdf;
42 | position: absolute;
43 | top: 50%;
44 | left: 50%;
45 | transform: translate(-50%, -50%);
46 | }
47 |
48 | .postbird-box-header {
49 | width: 100%;
50 | padding: 10px 15px;
51 | position: relative;
52 | font-size: 1.1em;
53 | letter-spacing: 2px
54 | }
55 |
56 | .postbird-box-close-btn {
57 | cursor: pointer;
58 | font-weight: 700;
59 | color: #000;
60 | float: right;
61 | opacity: .5;
62 | font-size: 1.3em;
63 | margin-top: -3px;
64 | display: none
65 | }
66 |
67 | .postbird-box-close-btn:hover {
68 | opacity: 1
69 | }
70 |
71 | .postbird-box-text {
72 | width: 100%;
73 | margin-bottom: 1rem;
74 | padding: 0 10%;
75 | text-align: center;
76 | line-height: 40px;
77 | font-size: 20px;
78 | letter-spacing: 1px
79 | }
80 |
81 | .postbird-box-footer {
82 | width: 100%;
83 | padding: 0;
84 | margin: 0;
85 | display: flex;
86 | display: -webkit-flex;
87 | justify-content: space-around;
88 | border-top: solid 1px #dfdfdf;
89 | align-items: flex-end
90 | }
91 |
92 | .postbird-box-footer .btn-footer {
93 | line-height: 44px;
94 | border: 0;
95 | cursor: pointer;
96 | background-color: #fff;
97 | color: #0e90d2;
98 | font-size: 1.1em;
99 | letter-spacing: 2px;
100 | transition: background-color .5s;
101 | -webkit-transition: background-color .5s;
102 | -o-transition: background-color .5s;
103 | -moz-transition: background-color .5s;
104 | outline: 0
105 | }
106 |
107 | .postbird-box-footer .btn-footer:hover {
108 | background-color: #e5e5e5
109 | }
110 |
111 | .postbird-box-footer .btn-block-footer {
112 | width: 100%
113 | }
114 |
115 | .postbird-box-footer .btn-left-footer,
116 | .postbird-box-footer .btn-right-footer {
117 | position: relative;
118 | width: 100%
119 | }
120 |
121 | .postbird-box-footer .btn-left-footer::after {
122 | content: "";
123 | position: absolute;
124 | right: 0;
125 | top: 0;
126 | background-color: #e5e5e5;
127 | height: 100%;
128 | width: 1px
129 | }
130 |
131 | .postbird-box-footer .btn-footer-cancel {
132 | color: #333
133 | }
134 |
135 | .postbird-prompt-input {
136 | width: 100%;
137 | padding: 5px;
138 | font-size: 16px;
139 | border: 1px solid #ccc;
140 | outline: 0
141 | }
--------------------------------------------------------------------------------
/css/style.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | box-sizing: border-box;
5 | }
6 |
7 | @font-face {
8 | font-family: 'DIGITAL';
9 | src: url(/fonts/DIGITAL.ttf);
10 | }
11 |
12 | html {
13 | font-family: 'DIGITAL';
14 | width: 100%;
15 | height: 100%;
16 | }
17 |
18 | body.w {
19 | left: 50%;
20 | top: 50%;
21 | height: 100vw;
22 | width: 100vh;
23 | transform: translate(-50%, -50%) rotate(90deg);
24 | -webkit-transform: translate(-50%, -50%) rotate(90deg)
25 | }
26 |
27 | body {
28 | position: absolute;
29 | overflow: hidden;
30 | background: url(https://cdn.leonus.cn/img/studybg.webp);
31 | background-size: cover;
32 | background-position: center;
33 | background-repeat: no-repeat;
34 | width: 100%;
35 | height: 100%;
36 | color: #333;
37 | }
38 |
39 | li {
40 | list-style: none;
41 | }
42 |
43 | a {
44 | text-decoration: none;
45 | color: #333;
46 | }
47 |
48 | img {
49 | vertical-align: middle;
50 | }
51 |
52 | input {
53 | outline: none;
54 | color: #333;
55 | }
56 |
57 | .main {
58 | font-size: 18px;
59 | display: flex;
60 | flex-direction: column;
61 | align-items: center;
62 | justify-content: center;
63 | height: 100%;
64 | color: white;
65 | }
66 |
67 | .content {
68 | margin: 20px 0;
69 | min-width: 764px;
70 | font-size: 150px;
71 | display: flex;
72 | width: 60%;
73 | justify-content: space-between;
74 | }
75 |
76 | .content div {
77 | background: rgba(0, 0, 0, 0.2);
78 | position: relative;
79 | height: 180px;
80 | margin: 20px;
81 | border-radius: 15px;
82 | width: 180px;
83 | display: flex;
84 | align-items: center;
85 | justify-content: center;
86 | }
87 |
88 | .content span {
89 | align-items: center;
90 | display: flex;
91 | padding-bottom: 30px;
92 | }
93 |
94 | menu {
95 | position: fixed;
96 | left: 0;
97 | width: 100%;
98 | justify-content: space-around;
99 | display: flex;
100 | }
101 |
102 | menu a {
103 | background: rgba(0, 0, 0, 0.2);
104 | margin: 0 3px;
105 | color: white;
106 | display: flex;
107 | font-size: 18px;
108 | width: 40px;
109 | border-radius: 0 0 10px 10px;
110 | height: 35px;
111 | justify-content: center;
112 | align-items: center;
113 | }
114 |
115 | .hidebtns,
116 | .btns {
117 | display: flex;
118 | transition: .5s;
119 | border-radius: 0 0 10px 10px;
120 | }
121 |
122 | .hidebtns {
123 | transform: translateY(-100%);
124 | }
125 |
126 | .open {
127 | transform: translateY(0);
128 | }
129 |
130 | .pause {
131 | display: none;
132 | }
133 |
134 | .bottom {
135 | cursor: pointer;
136 | text-align: center;
137 | letter-spacing: 5px;
138 | margin: 0 10px;
139 | }
140 |
141 | .today {
142 | letter-spacing: 3px;
143 | }
144 |
145 | footer {
146 | position: absolute;
147 | width: 100%;
148 | bottom: 10px;
149 | text-align: center;
150 | }
151 |
152 | #cleerData,
153 | #hideFooterBtn {
154 | cursor: pointer;
155 | border: 1px solid #42a5f5;
156 | border-radius: 5px;
157 | color: #42a5f5;
158 | background: none;
159 | padding: 3px 8px;
160 | transition: .3s;
161 | }
162 |
163 | #cleerData:hover,
164 | #hideFooterBtn:hover {
165 | background-color: #42a5f5;
166 | color: white;
167 | }
168 |
169 | .footerHide {
170 | display: none;
171 | }
172 |
173 | footer * {
174 | letter-spacing: 2px;
175 | color: white;
176 | }
177 |
178 | @media screen and (max-width: 800px) {
179 | .content {
180 | font-size: 120px;
181 | min-width: 573px;
182 | }
183 | .content div {
184 | height: 150px;
185 | margin: 15px;
186 | width: 150px;
187 | }
188 | }
189 |
190 | @media screen and (max-width: 615px) {
191 | .main {
192 | font-size: 16px;
193 | }
194 | .content {
195 | font-size: 90px;
196 | min-width: 415px;
197 | }
198 | .content div {
199 | height: 110px;
200 | margin: 10px;
201 | width: 110px;
202 | }
203 | .content span {
204 | padding-bottom: 15px;
205 | }
206 | menu a {
207 | font-size: 16px;
208 | width: 38px;
209 | height: 32px;
210 | border-radius: 0 0 6px 6px;
211 | }
212 | }
213 |
214 | @media screen and (max-width: 432px) {
215 | .w .postbird-box-content {
216 | top: 0;
217 | transform: translate(-50%, 10%);
218 | margin-top: 0;
219 | }
220 | menu {
221 | justify-content: center;
222 | }
223 | .content {
224 | width: 100%;
225 | font-size: 70px;
226 | max-width: 432px;
227 | min-width: unset;
228 | }
229 | .content div {
230 | border-radius: 8px;
231 | height: 85px;
232 | margin: 10px;
233 | width: 85px;
234 | }
235 | }
--------------------------------------------------------------------------------
/fonts/DIGITAL.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lea321/studyTime/ab220edc441bbbaa284137a915e7e9bc016cc274/fonts/DIGITAL.ttf
--------------------------------------------------------------------------------
/img/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Lea321/studyTime/ab220edc441bbbaa284137a915e7e9bc016cc274/img/favicon.ico
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | 学习计时 - 今天你学习了吗?
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
39 |
40 |
43 |
44 |
00
:
45 |
00
:
46 |
00
47 |
48 |
你要悄悄拔尖,然后惊艳所有人!!
49 |
50 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/js/be-full.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | exports.toggleFull = exports.isFull = exports.exitFull = exports.beFull = void 0;
4 | var DOC_EL = document.documentElement;
5 | var headEl = DOC_EL.querySelector('head');
6 | var styleEl = document.createElement('style');
7 | var TYPE_REQUEST_FULL_SCREEN = 'requestFullscreen';
8 | var TYPE_EXIT_FULL_SCREEN = 'exitFullscreen';
9 | var TYPE_FULL_SCREEN_ELEMENT = 'fullscreenElement';
10 | var TYPE_ON_FULL_SCREEN_CHANGE = 'onfullscreenchange';
11 | if ("webkitRequestFullScreen" in DOC_EL) {
12 | TYPE_REQUEST_FULL_SCREEN = 'webkitRequestFullScreen';
13 | TYPE_EXIT_FULL_SCREEN = 'webkitExitFullscreen';
14 | TYPE_FULL_SCREEN_ELEMENT = 'webkitFullscreenElement';
15 | TYPE_ON_FULL_SCREEN_CHANGE = 'onwebkitfullscreenchange';
16 | }
17 | else if ("msRequestFullscreen" in DOC_EL) {
18 | TYPE_REQUEST_FULL_SCREEN = 'msRequestFullscreen';
19 | TYPE_EXIT_FULL_SCREEN = 'msExitFullscreen';
20 | TYPE_FULL_SCREEN_ELEMENT = 'msFullscreenElement';
21 | TYPE_ON_FULL_SCREEN_CHANGE = 'MSFullscreenChange';
22 | }
23 | else if ("mozRequestFullScreen" in DOC_EL) {
24 | TYPE_REQUEST_FULL_SCREEN = 'mozRequestFullScreen';
25 | TYPE_EXIT_FULL_SCREEN = 'mozCancelFullScreen';
26 | TYPE_FULL_SCREEN_ELEMENT = 'mozFullScreenElement';
27 | TYPE_ON_FULL_SCREEN_CHANGE = 'onmozfullscreenchange';
28 | }
29 | else if (!("requestFullscreen" in DOC_EL)) {
30 | throw "\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301Fullscreen API !";
31 | }
32 | function getCurrentElement(el) {
33 | return el instanceof HTMLElement ? el : DOC_EL;
34 | }
35 | function beFull(el, backgroundColor) {
36 | if (backgroundColor) {
37 | if (null === headEl) {
38 | headEl = document.createElement('head');
39 | }
40 | styleEl.innerHTML = ":fullscreen{background-color:" + backgroundColor + ";}";
41 | headEl.appendChild(styleEl);
42 | }
43 | return getCurrentElement(el)[TYPE_REQUEST_FULL_SCREEN]();
44 | }
45 | exports.beFull = beFull;
46 | function exitFull() {
47 | if (DOC_EL.contains(styleEl)) {
48 | headEl === null || headEl === void 0 ? void 0 : headEl.removeChild(styleEl);
49 | }
50 | return document[TYPE_EXIT_FULL_SCREEN]();
51 | }
52 | exports.exitFull = exitFull;
53 | function isFull(el) {
54 | return getCurrentElement(el) === document[TYPE_FULL_SCREEN_ELEMENT];
55 | }
56 | exports.isFull = isFull;
57 | function toggleFull(el, backgroundColor) {
58 | if (isFull(el)) {
59 | exitFull();
60 | return false;
61 | }
62 | else {
63 | beFull(el, backgroundColor);
64 | return true;
65 | }
66 | }
67 | exports.toggleFull = toggleFull;
68 | //# sourceMappingURL=main.js.map
--------------------------------------------------------------------------------
/js/postbirdAlertBox.min.js:
--------------------------------------------------------------------------------
1 | /**
2 | * PostbirdAlertBox.js
3 | * - 原生javascript弹框插件
4 | * Author: Postbird - http://www.ptbird.cn
5 | * License: MIT
6 | * Date: 2017-09-23
7 | */
8 | var PostbirdAlertBox={containerClass:"postbird-box-container active",box:null,textTemplate:{title:"提示信息",content:"提示内容",okBtn:"好的",cancelBtn:"取消",contentColor:"#000000",okBtnColor:"#0e90d2",promptTitle:"请输入内容",promptOkBtn:"确认",},getAlertTemplate:function(){var temp=''+'
'+'"+'
'+''+this.textTemplate.content+""+"
"+'"+"
"+"
";return temp},getConfirmTemplate:function(){return''+'
'+'
'+'"+'
'+''+this.textTemplate.content+"?"+"
"+'"+"
"+"
"+"
"},getPromptTemplate:function(){return'"},alert:function(opt){this.textTemplate.title=opt.title||this.textTemplate.title;this.textTemplate.content=opt.content||this.textTemplate.content;this.textTemplate.okBtn=opt.okBtn||this.textTemplate.okBtn;this.textTemplate.okBtnColor=opt.okBtnColor||this.textTemplate.okBtnColor;this.textTemplate.contentColor=opt.contentColor||this.textTemplate.contentColor;var box=document.createElement("div"),_this=this;box.className=this.containerClass;box.innerHTML=this.getAlertTemplate();this.box=box;document.body.appendChild(this.box);var btn=document.getElementsByClassName("btn-footer-ok");btn[btn.length-1].focus();btn[btn.length-1].onclick=function(){if(opt.onConfirm){opt.onConfirm()}_this.removeBox()}},confirm:function(opt){this.textTemplate.title=opt.title||this.textTemplate.promptTitle;this.textTemplate.promptPlaceholder=opt.promptPlaceholder||this.textTemplate.promptPlaceholder;this.textTemplate.okBtn=opt.okBtn||this.textTemplate.promptOkBtn;this.textTemplate.okBtnColor=opt.okBtnColor||this.textTemplate.okBtnColor;this.textTemplate.cancelBtn=opt.cancelBtn||this.textTemplate.cancelBtn;this.textTemplate.cancelBtnColor=opt.cancelBtnColor||this.textTemplate.cancelBtnColor;this.textTemplate.content=opt.content||this.textTemplate.content;var box=document.createElement("div"),_this=this;this.box=box;box.className=this.containerClass;box.innerHTML=this.getConfirmTemplate();document.body.appendChild(box);var okBtn=document.getElementsByClassName("btn-footer-ok");okBtn[okBtn.length-1].focus();okBtn[okBtn.length-1].onclick=function(){if(opt.onConfirm){opt.onConfirm()}_this.removeBox()};var cancelBtn=document.getElementsByClassName("btn-footer-cancel");cancelBtn[cancelBtn.length-1].onclick=function(){if(opt.onCancel){opt.onCancel()}_this.removeBox()}},prompt:function(opt){this.textTemplate.title=opt.title||this.textTemplate.title;this.textTemplate.content=opt.content||this.textTemplate.content;this.textTemplate.contentColor=opt.contentColor||this.textTemplate.contentColor;this.textTemplate.okBtn=opt.okBtn||this.textTemplate.okBtn;this.textTemplate.okBtnColor=opt.okBtnColor||this.textTemplate.okBtnColor;this.textTemplate.cancelBtn=opt.cancelBtn||this.textTemplate.cancelBtn;this.textTemplate.cancelBtnColor=opt.cancelBtnColor||this.textTemplate.cancelBtnColor;var box=document.createElement("div"),_this=this;box.className=this.containerClass;box.innerHTML=this.getPromptTemplate();this.box=box;document.body.appendChild(box);var promptInput=document.getElementsByClassName("postbird-prompt-input");
9 | promptInput=promptInput[promptInput.length-1];promptInput.focus();var okBtn=document.getElementsByClassName("btn-footer-ok");var inputData=promptInput.value;okBtn[okBtn.length-1].focus();okBtn[okBtn.length-1].onclick=function(){if(opt.onConfirm){opt.onConfirm(promptInput.value)}_this.removeBox()};var cancelBtn=document.getElementsByClassName("btn-footer-cancel");cancelBtn[cancelBtn.length-1].onclick=function(){if(opt.onCancel){opt.onCancel(promptInput.value)}_this.removeBox()}},colse:function(){this.removeBox()},removeBox:function(){var box=document.getElementsByClassName(this.containerClass);document.body.removeChild(box[box.length-1])}};
--------------------------------------------------------------------------------
/js/script.js:
--------------------------------------------------------------------------------
1 | window.addEventListener('DOMContentLoaded', function() {
2 | init();
3 | setDate();
4 | })
5 |
6 | window.onresize = () => {
7 | let fullBtn = document.querySelector('#fullBtn')
8 | if (isFull()) {
9 | fullBtn.children[0].classList.remove('fa-expand')
10 | fullBtn.children[0].classList.add('fa-compress')
11 | } else {
12 | fullBtn.children[0].classList.add('fa-expand')
13 | fullBtn.children[0].classList.remove('fa-compress')
14 | }
15 | }
16 |
17 | window.addEventListener('keyup', (e) => {
18 | if (e.code == 'F11' || e.key == 'F11') {
19 | fullBtn.children[0].classList.remove('fa-expand')
20 | fullBtn.children[0].classList.add('fa-compress')
21 | }
22 | })
23 |
24 |
25 | var exports = {},
26 | week = { 0: '星期日', 1: '星期一', 2: '星期二', 3: '星期三', 4: '星期四', 5: '星期五', 6: '星期六' },
27 | textls = ['时间不在于你拥有多少,而在于你怎么使用。',
28 | '书山有路勤为径,学海无涯苦作舟。',
29 | '天才就是百分之九十九的汗水加百分之一的灵感。',
30 | '凡事勤则易,凡事惰则难。',
31 | '只要春天还在,我就不会悲哀,纵使黑夜吞噬了一切,太阳还可以重新回来。',
32 | '前行,不要停下。', '为你指明路的,不是停止,而是前进。',
33 | '我不去想是否能够成功,既然选择了远方,便只顾风雨兼程。',
34 | '果能日日留心,则一日有一日之长进;事事留心,则一事有一事之长进。'
35 | ],
36 | startTime = passTime = 0,
37 | t;
38 |
39 | function init() {
40 | let data = loadData('studyTime')
41 | if (loadData('studyStyle')) document.querySelector('footer').classList.add('footerHide');
42 | let text = localStorage.getItem('studyText')
43 | if (text) document.querySelector('.bottom').innerHTML = text
44 | else randomText();
45 | if (data) {
46 | // 判断是否是今天
47 | if (new Date(data.start).toDateString() != new Date().toDateString()) {
48 | localStorage.removeItem('studyTime');
49 | PostbirdAlertBox.alert({
50 | 'title': '你好,自律的人',
51 | 'content': '又是新的一天,快开始学习吧!',
52 | 'okBtn': '关闭'
53 | });
54 | }
55 | // 判断是否继续计时
56 | else if (data.status) begin();
57 | // 不继续计时则渲染时间
58 | else timer(new Date().getTime() - data.pass);
59 | }
60 | }
61 |
62 | // 设置日期
63 | function setDate() {
64 | var d = new Date();
65 | let y = d.getFullYear(),
66 | m = d.getMonth() + 1,
67 | day = d.getDate(),
68 | w = week[d.getDay()];
69 | document.querySelector('.today').innerHTML = `${y}年${m}月${day}日 ${w}`;
70 | }
71 |
72 | // 存储时间数据
73 | function saveTime(status) {
74 | localStorage.setItem('studyTime', JSON.stringify({ 'start': startTime, 'pass': passTime, 'status': status }));
75 | }
76 |
77 | // 获取数据
78 | function loadData(name) {
79 | return JSON.parse(localStorage.getItem(name));
80 | }
81 |
82 | // 时间渲染
83 | function timer(s) {
84 | var nol = function(h) { return h > 9 ? h : '0' + h; };
85 | second = Math.floor((new Date().getTime() - s) / 1000);
86 | if (second >= 3600) {
87 | document.querySelector('.hour').innerHTML = nol(parseInt(second / 3600));
88 | second %= 3600;
89 | }
90 | if (second >= 60) {
91 | document.querySelector('.minute').innerHTML = nol(parseInt(second / 60));
92 | second %= 60;
93 | } else { document.querySelector('.minute').innerHTML = '00'; }
94 | if (second >= 0) document.querySelector('.second').innerHTML = nol(second);
95 | }
96 |
97 | // 菜单显隐
98 | function toggleMenu() {
99 | document.querySelector('menu .btns .hidebtns').classList.toggle('open');
100 | }
101 |
102 | function hideFooter() {
103 | document.querySelector('footer').classList.toggle('footerHide');
104 | if (loadData('studyStyle')) {
105 | localStorage.removeItem('studyStyle')
106 | } else {
107 | localStorage.setItem('studyStyle', 1)
108 | }
109 | }
110 |
111 | // 开始计时
112 | function begin() {
113 | let data = loadData('studyTime')
114 | if (data) {
115 | // 如果passTime不为空则重新计算startTime
116 | if (data.pass) {
117 | startTime = new Date().getTime() - data.pass;
118 | passTime = 0
119 | saveTime(1);
120 | } else startTime = data.start;
121 | } else {
122 | startTime = new Date().getTime();
123 | saveTime(1);
124 | }
125 |
126 | // 开始计时
127 | timer(startTime);
128 | t = setInterval(() => { timer(startTime) }, 1000);
129 | document.querySelector('.start').style.display = 'none';
130 | document.querySelector('.pause').style.display = 'flex';
131 | }
132 |
133 | // 暂停计时
134 | function pause() {
135 | clearInterval(t)
136 | passTime = new Date().getTime() - startTime;
137 | saveTime(0);
138 | document.querySelector('.start').style.display = 'flex';
139 | document.querySelector('.pause').style.display = 'none';
140 | }
141 |
142 | // 解答
143 | function question() {
144 | PostbirdAlertBox.alert({
145 | 'title': '问题解答',
146 | 'content': `
147 | 1. 开始之后可以不暂停关闭网站,将会继续为您计时。
148 | 2. 时间回溯:如果你中途有一段时间没有学习但是忘了暂停,可使用此功能减去那一段时间。
149 | 3. 全屏和旋转:顾名思义。开始计时后可以全屏 + 旋转,方便随时查看。
(有的手机可能开启了自动旋转,如已开启且生效就无需再点击旋转按钮)
150 | 4. 时间下面的文字点击可编辑,回车进行确认。不编辑则默认显示随机励志文本。
151 | 5. 时间问题先更新这么多,目前来看已经够用,以后有空了慢慢更新。
152 | 6. 本站由 Vercel 提供托管服务
153 | 7. 问题反馈(Q/V同号):990320751
154 |
155 | `,
156 | 'okBtn': '关闭',
157 | });
158 | }
159 |
160 | // 时间回溯
161 | function subTime() {
162 | PostbirdAlertBox.prompt({
163 | 'title': '时间回溯
若您在计时中做了其他的事情,可以使用此功能进行时间回溯。
如:中途玩了20分钟,输入20并提交计时将会减去20分钟。
请输入您想回溯的时间(单位:分钟)',
164 | 'okBtn': '确认',
165 | onConfirm: function(data) {
166 | if (!data) {
167 | alert('回溯时间不能为空!')
168 | return
169 | }
170 | let st = loadData('studyTime')
171 | if (!st) {
172 | alert('还未开始计时,无法回溯!')
173 | return
174 | }
175 | if (((st.start + (Number(data) * 60000)) > new Date().getTime()) || st.pass && st.pass < (Number(data) * 60000)) {
176 | alert('回溯失败,回溯时间超出已计时时间')
177 | return
178 | }
179 | if (confirm("确认回溯吗?") == true) {
180 | if (st.status) {
181 | startTime = st.start + (Number(data) * 60000)
182 | pause()
183 | begin()
184 | } else {
185 | passTime = st.pass - (Number(data) * 60000)
186 | startTime = new Date().getTime() - passTime
187 | pause()
188 | timer(startTime);
189 | }
190 | }
191 | }
192 | });
193 | }
194 |
195 | // 随机文本
196 | function randomText() {
197 | document.querySelector('.bottom').innerHTML = textls[Math.floor(Math.random() * textls.length)]
198 | }
199 |
200 | // 改文本
201 | function changeText() {
202 | PostbirdAlertBox.prompt({
203 | 'title': '更改文本
请输入一段文字替换此区域内容,清除文本则恢复随机显示。',
204 | 'okBtn': '确认',
205 | onConfirm: function(data) {
206 | if (data) {
207 | localStorage.setItem('studyText', data)
208 | document.querySelector('.bottom').innerHTML = data
209 | } else {
210 | localStorage.removeItem('studyText')
211 | randomText()
212 | }
213 | }
214 | });
215 | let text = localStorage.getItem('studyText')
216 | if (text) document.querySelector('.postbird-box-text input').value = text
217 | }
218 |
219 | // 清除数据
220 | function clearData() {
221 | if (confirm("确认清除本地数据吗?\n包括计时时间、设置的文本等。") == true) {
222 | localStorage.removeItem('studyStyle')
223 | localStorage.removeItem('studyText')
224 | localStorage.removeItem('studyTime')
225 | alert("清除成功!");
226 | window.location.reload()
227 | }
228 | }
--------------------------------------------------------------------------------