Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
hunter-ht.cn
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘莹莹
hunter-ht.cn
Commits
3167e0fd
Commit
3167e0fd
authored
May 06, 2020
by
liuyingying
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
前成员弹出显示
parent
06391d94
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
209 additions
and
29 deletions
+209
-29
style.css
Hunter_ht/hunter/static/hunter/style.css
+23
-7
editArticle.html
Hunter_ht/hunter/templates/hunter/editArticle.html
+164
-0
index.html
Hunter_ht/hunter/templates/hunter/index.html
+22
-22
No files found.
Hunter_ht/hunter/static/hunter/style.css
View file @
3167e0fd
...
...
@@ -7,6 +7,11 @@
margin
:
0
;
padding
:
0
;
}
html
,
body
{
width
:
100%
;
height
:
100%
;
max-width
:
1800px
;
}
body
{
background-color
:
rgba
(
253
,
253
,
253
,
.3
);
width
:
100%
;
...
...
@@ -234,9 +239,20 @@ nav>div{
box-shadow
:
2px
2px
3px
black
;
}
#former_member
{
margin-top
:
30px
;
background-color
:
#ffffff
;
border
:
solid
1px
#6e829e
;
position
:
fixed
;
width
:
100%
;
height
:
100%
;
top
:
0
;
right
:
-100%
;
background-color
:
rgba
(
252
,
252
,
252
,
0.48
);
z-index
:
999
;
}
.member_wrap
{
width
:
100%
;
height
:
400px
;
position
:
fixed
;
top
:
50%
;
margin-top
:
-200px
;
}
.left-bar
{
...
...
@@ -309,9 +325,10 @@ nav>div{
.member_type
{
display
:
block
;
float
:
left
;
margin
:
0
5
%
;
width
:
40
%
;
margin
:
0
2
%
;
width
:
21
%
;
}
.wrap
:after
{
content
:
"."
;
clear
:
both
;
...
...
@@ -323,7 +340,7 @@ nav>div{
.member_type
>
p
{
width
:
100%
;
font-size
:
20
px
;
font-size
:
18
px
;
height
:
40px
;
line-height
:
40px
;
font-weight
:
100
;
...
...
@@ -388,7 +405,6 @@ blockquote>p{
display
:
block
;
line-height
:
30px
;
float
:
left
;
margin-left
:
20px
;
}
ul
:after
{
content
:
"."
;
...
...
Hunter_ht/hunter/templates/hunter/editArticle.html
0 → 100644
View file @
3167e0fd
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
编辑文章
</title>
{% load static %}
<link
rel=
"icon"
href=
"{% static 'hunter/images/logo.ico' %}"
type=
"text/icon"
>
<script
src=
"{% static 'hunter/jquery-1.9.1.min.js' %}"
></script>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'hunter/md/markdown.css' %}"
>
<script
type=
"text/javascript"
src=
"{% static 'hunter/md/showdown.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'hunter/bootstrap.min.js' %}"
></script>
</head>
<body>
<nav>
<div>
<div
id=
"hunter"
>
<span><a
href=
"/"
>
HUNTER
</a></span>
</div>
<div
id=
"bar"
class=
""
>
<span
id=
"username"
></span>
<button
onclick=
"saveArt()"
>
保存
</button>
</div>
</div>
</nav>
<div
class=
"middle_div"
>
<div
class=
"title"
>
<label
for=
"title"
>
标题
</label>
<input
type=
"text"
id=
"title"
value=
"{{ article.title }}"
>
</div>
<input
name=
"myfile"
id=
"myfile"
type=
"file"
>
<div
class=
"grey_text"
>
你正在修改文章,上传则覆盖原文件,不上传则保留原文件。多个文件请打包
</div>
<div
id=
"error_log"
></div>
</div>
<div
id=
"markdownCnt"
>
<div>
<label
for=
"originCnt"
>
原文
</label>
<textarea
id =
"originCnt"
class=
""
oninput=
"compile()"
placeholder=
"Start your writing"
>
{{ article.content }}
</textarea>
<!-- <button onclick="compile()">转换</button> -->
</div>
<div
id=
"textCnt"
class=
"halfView"
>
</div>
</div>
</body>
<script>
$
(
document
).
ready
(
function
()
{
var
height
=
window
.
innerHeight
;
$
(
'#markdownCnt'
).
css
(
"height"
,
height
*
0.88
);
getUsername
();
compile
();
//拖离
document
.
addEventListener
(
'dragleave'
,
function
(
e
){
e
.
preventDefault
();});
//拖后放
document
.
addEventListener
(
'drop'
,
function
(
e
){
e
.
preventDefault
();});
//拖进
document
.
addEventListener
(
'dragenter'
,
function
(
e
){
e
.
preventDefault
();});
//拖来拖去
document
.
addEventListener
(
'dragover'
,
function
(
e
){
e
.
preventDefault
();});
var
boxImg
=
document
.
getElementById
(
"originCnt"
);
boxImg
.
addEventListener
(
"drop"
,
function
(
e
){
e
.
preventDefault
();
var
fileList
=
e
.
dataTransfer
.
files
;
if
(
fileList
.
length
===
0
){
return
false
;}
else
if
(
fileList
.
length
>
1
){
console
.
log
(
"暂不支持多图同时上传"
);
return
false
;
}
else
if
(
fileList
[
0
].
type
.
indexOf
(
'image'
)
===-
1
){
alert
(
"文章中只能插入图片哦"
);
return
false
;
}
else
{
console
.
log
(
fileList
[
0
].
name
);
var
formData
=
new
FormData
();
formData
.
append
(
'image'
,
fileList
[
0
]);
$
.
ajax
({
type
:
"post"
,
url
:
'/uploadImg/'
,
//ajaxurl
async
:
false
,
dataType
:
"text"
,
data
:
formData
,
processData
:
false
,
contentType
:
false
,
success
:
function
(
data
){
if
(
data
){
var
addMDHTML
=
'!['
+
fileList
[
0
].
name
+
']('
+
data
+
')'
;
console
.
log
(
addMDHTML
);
$
(
"#originCnt"
).
val
(
$
(
"#originCnt"
).
val
()
+
addMDHTML
);
compile
();
}
else
{
console
.
log
(
data
)
}
},
error
:
function
(
e
){
console
.
log
(
e
)
}
});
}
});
},
false
);
function
saveArt
(){
let
username
=
document
.
getElementById
(
"username"
).
innerHTML
;
let
storage
=
window
.
localStorage
;
let
userID
=
storage
[
'userID'
];
let
title
=
document
.
getElementById
(
"title"
).
value
;
let
content
=
document
.
getElementById
(
"originCnt"
).
value
;
let
articleID
=
document
.
location
.
href
.
split
(
'/'
)[
5
];
if
(
title
.
length
<=
0
){
$
(
'#error_log'
).
empty
();
$
(
'#error_log'
).
append
(
'标题不能为空'
);
return
;
}
let
formdata
=
new
FormData
();
let
files
=
$
(
'input[name="myfile"]'
)[
0
].
files
;
if
(
files
.
length
>
0
){
let
myfile
=
files
[
0
];
formdata
.
append
(
"myfile"
,
myfile
);
formdata
.
append
(
"isHaveFile"
,
"1"
);
}
else
{
formdata
.
append
(
"isHaveFile"
,
"0"
);
}
formdata
.
append
(
"userID"
,
userID
);
formdata
.
append
(
"title"
,
title
);
formdata
.
append
(
"content"
,
content
);
formdata
.
append
(
"articleID"
,
articleID
);
$
.
ajax
({
url
:
'/save/edit/article/'
,
type
:
'post'
,
data
:
formdata
,
processData
:
false
,
// 使数据不做处理
contentType
:
false
,
// 不要设置Content-Type请求头
success
:
function
(
response
)
{
if
(
response
[
"message"
]){
alert
(
'修改成功'
);
let
storage
=
window
.
localStorage
;
window
.
location
.
href
=
"/user/"
+
storage
.
userID
;
}
else
{
$
(
'#error_log'
).
empty
();
$
(
'#error_log'
).
append
(
response
[
'error'
]);
}
},
});
}
function
getUsername
(){
let
storage
=
window
.
localStorage
;
let
username
=
storage
[
'username'
];
console
.
log
(
username
);
if
(
username
){
$
(
"#username"
).
text
(
username
);
}
else
{
alert
(
"请先登录"
);
window
.
location
.
href
=
"/"
;
}
}
function
compile
(){
var
text
=
document
.
getElementById
(
"originCnt"
).
value
;
var
converter
=
new
showdown
.
Converter
();
let
md_html
=
converter
.
makeHtml
(
text
);
document
.
getElementById
(
"textCnt"
).
innerHTML
=
md_html
;
}
</script>
</html>
\ No newline at end of file
Hunter_ht/hunter/templates/hunter/index.html
View file @
3167e0fd
...
...
@@ -26,6 +26,25 @@
</div>
</div>
</div>
<div
class=
"wrap"
id=
"former_member"
>
<div
class=
"member_wrap"
onclick=
"close_former()"
title=
"点击空白处关闭"
>
{% for tp,users in user_type_list_former.items %}
<div
class=
"member_type"
>
{% if users %}
<p>
{{ tp }}(former)
</p>
{% for user in users %}
<ul>
<li>
<a
href=
"{% url 'hunter:detail' user.userID %}"
target=
"_blank"
>
{{ user.name_hanzi }}
</a>
</li>
<li
class=
"user_mail"
>
{{ user.mailAddress }}
</li>
</ul>
{% endfor %}
{% endif %}
</div>
{% endfor %}
</div>
</div>
<nav>
<div>
<div
id=
"hunter"
>
...
...
@@ -90,23 +109,6 @@
<button
style=
"display: none"
id=
"close_btn"
onclick=
"close_former()"
>
隐藏
</button>
</span>
</div>
<div
class=
"wrap"
id=
"former_member"
style=
"display: none;"
>
{% for tp,users in user_type_list_former.items %}
<div
class=
"member_type"
>
{% if users %}
<p>
{{ tp }}(former)
</p>
{% for user in users %}
<ul>
<li>
<a
href=
"{% url 'hunter:detail' user.userID %}"
target=
"_blank"
>
{{ user.name_hanzi }}
</a>
</li>
<li
class=
"user_mail"
>
{{ user.mailAddress }}
</li>
</ul>
{% endfor %}
{% endif %}
</div>
{% endfor %}
</div>
<div
class=
"wrap"
style=
"padding-top:30px;"
>
{% for tp,users in user_type_list.items %}
<div
class=
"member_type"
>
...
...
@@ -308,18 +310,16 @@
$
(
'#top_bar'
).
append
(
"<ul><li><button onclick='logout()'>退出</button></li><li title='点击进入个人中心'><a href='/user/"
+
storage
[
"userID"
]
+
"/' target='_blank'>"
+
storage
[
"username"
]
+
"</a></li></ul>"
);
hide_log
();
}
};
function
show_former
(){
$
(
'#show_btn'
).
css
(
'display'
,
'none'
);
$
(
'#close_btn'
).
css
(
'display'
,
'block'
);
$
(
'#former_member'
).
css
(
'display'
,
'block'
);
$
(
'#former_member'
).
css
(
'right'
,
'0'
);
}
function
close_former
(){
$
(
'#show_btn'
).
css
(
'display'
,
'block'
);
$
(
'#close_btn'
).
css
(
'display'
,
'none'
);
$
(
'#former_member'
).
css
(
'display'
,
'none'
);
$
(
'#former_member'
).
css
(
'right'
,
'-100%'
);
}
function
logout
(){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment