forked from SSShooter/MyDiary
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiary.html
More file actions
193 lines (191 loc) · 6.32 KB
/
diary.html
File metadata and controls
193 lines (191 loc) · 6.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Diary</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<!-- 新 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="bootstrap/bootstrap.min.css">
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="lib/jquery.min.js"></script>
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="bootstrap/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="icon/iconfont.css">
<!-- 自定义bs -->
<link rel="stylesheet" type="text/css" href="css/custombs.css">
<style type="text/css">
header{
/*padding for导航栏*/
padding-top: 28px;
position: fixed;
width: 100vw;
background-color: #fff;
}
#logo{
color: #5A95BA;
margin: 5px auto;
}
/*以上公用 以下本文件专用*/
#main{
min-height: 100vh;
padding-top:88px;
padding-bottom: 44px;
}
/*padding = 140 - 60 - 20 * 2*/
#main .show-date{
height: 140px;
width: 100vw;
background-color: #5A95BA;
color: #FFF;
text-align: center;
padding: 20px 0;
}
#main .show-date .date{
font-size: 60px;
line-height: 60px;
font-weight: bold;
}
#main .show-date .month,#main .show-date .time{
font-size: 15px;
line-height: 20px;
}
#main .input-div .diary-content,#main .input-div .diary-title{
margin-top: 15px;
border: none;
outline: none;
box-shadow: none;
border-radius: 0;
}
#main .input-div .diary-title{
border-bottom: 1px #5A95BA solid;
}
/*height = 100vh - 89px - 140px - 44px */
/*全屏高-头部-日期div-footer-title输入框*/
#diary-content{
max-height:calc(100vh - 89px - 140px - 44px - 75px);
min-height:200px;
overflow-y: scroll;
}
footer{
position: fixed;
width: 100vw;
height: 44px;
background-color: #5A95BA;
bottom: 0;
text-align: center;
}
footer nav .iconfont{
color: #FFF;
line-height: 44px;
padding: 0 15px;
font-size: 25px;
}
.app{
display: none;
}
</style>
</head>
<body>
<div class="app">
<header>
<div class="text-center">
<div class="btn-group btn-group-sm">
<button type="button" class="btn btn-default" onClick="location.replace('entries.html')">Entries</button>
<button type="button" class="btn btn-default" onClick="location.replace('calendar.html')">Calendar</button>
<button type="button" class="btn btn-default active">Diary</button>
</div>
</div>
<p id="logo" class="center-block">Diary</p>
</header>
<div id="main">
<div class="show-date">
<div class="month"></div>
<div class="date"></div>
<div class="time"></div>
</div>
<div class="input-div container">
<input type="text" class="form-control diary-title" placeholder="Title">
<div contenteditable="true" class="form-control diary-content" id="diary-content" placeholder="Content"></div>
</div>
</div>
<footer>
<nav>
<i class="iconfont icon-camera"></i>
<i class="iconfont icon-save" onclick="save()"></i>
<i class="iconfont icon-cancel"></i>
</nav>
</footer>
</div>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/indexeddb.js"></script>
<script type="text/javascript">
$(".app").fadeIn('slow');
if(localStorage.theme === 'mitsuha'){
$('head').append('<link rel="stylesheet" type="text/css" href="css/mitsuha.diary.css"><link rel="stylesheet" type="text/css" href="css/mitsuha.bs.css">');
}
var d = new Date();
var monthEnglish = ["January","February","March","April","May","June","July","August","September","October","November","December"];
var monthEng = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var dayEnglish = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
var dayEng = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
var year = d.getFullYear();
var month = d.getMonth();
var date = d.getDate();
var day = d.getDay();
var time = d.getHours() + ':' + d.getMinutes();
var folder = localStorage.getItem("folder")||'';
$('.month').html(monthEng[month]);
$('.date').html(date);
$('.time').html(dayEnglish[day]+' '+time);
function save(){
var title = $(".diary-title").val()||'No Title';
//var content = document.getElementById("diary-content").value.replace(/\r/ig, "<br/>").replace(/\n/ig, "<br/>");//用jquery的.val()不能识别回车
var content = $("#diary-content").html();
if(content){
var getFirstSentence = content.split("<");
var hm = $('.show-date .time .hm').html();//for hour Minute
var timestamp = new Date().getTime();
var create_date = getNowFormatDate();
var data = {diary_id:"did"+timestamp,create_date:create_date,content:content,title:title,folder:folder,date:date,day:dayEng[day],time:time,month:monthEnglish[month],monthNum:month+1,type:"diary",description: getFirstSentence[0]};
console.log(data);
addData("diary",data);
plus(folder);
setTimeout("location.replace('entries.html')",500);
}else{
alert("~content empty~");
}
}
$("#diary-content").on('focus',function(){
$('.show-date').css('display', 'none');
});
$("#diary-content").on('blur',function(){
$('.show-date').css('display', 'block');
});
function getNowFormatDate() {
var date = new Date();
var seperator1 = "-";
var seperator2 = ":";
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
+ " " + date.getHours() + seperator2 + date.getMinutes()
+ seperator2 + date.getSeconds();
return currentdate;
}
function appendPic(){
$("#diary-content").append('<img src="avatar.png" alt="avatar" class="img-circle" style="width:100%">');
}
// window.onbeforeunload = function(e) {
// var dialogText = 'leaveing page without save';
// e.returnValue = dialogText;
// return dialogText;
// };
</script>
</body>
</html>