This repository has been archived by the owner on Jul 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
/
post.php
162 lines (153 loc) · 5.53 KB
/
post.php
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
<?php
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
$this->need('header.php');
?>
<main>
<?php if ($this->options->toc) : ?>
<div class="card shadow border-0 bg-secondary toc-container">
<a class="carousel-control-prev" id="toc-nomiao">
<i class="fa fa-chevron-left" aria-hidden="true"></i>
</a>
<div class="card-img container container-lg py-5 toc">
<strong>文章目录</strong>
<div class="toc-list">
<?php getCatalog(); ?>
</div>
</div>
</div>
<script>
var onshow = false;
function tocshow() {
if (onshow) {
$(".toc-container").css("right", '-175px')
$(".toc-container i").removeClass("fa-chevron-right").addClass("fa-chevron-left")
} else {
$(".toc-container").css("right", '-5px')
$(".toc-container i").removeClass("fa-chevron-left").addClass("fa-chevron-right")
}
onshow = !onshow
}
function jumpto(num) {
$('html,body').animate({
scrollTop: $('[name="cl-' + num + '"]').offset().top - 120
}, 500)
}
$("#toc-nomiao").click(tocshow)
var nowtoc = "cl-1"
$(document).ready(function() {
<?php if ($this->options->toc_enable) : ?>
tocshow()
<?php endif; ?>
$(document).scroll(function() {
for (var ele of $("*[name*='cl-']").get().reverse()) {
if ($(document).scrollTop() + 121 > $(ele).offset().top) {
if (nowtoc != ele.name) {
var tocele = $("*[name*='dl-" + nowtoc.replace("cl-", "") + "']")
tocele.removeClass("located")
tocele = $("*[name*='dl-" + ele.name.replace("cl-", "") + "']")
tocele.addClass("located")
$(".toc-list").animate({
scrollTop: $(".toc-list").scrollTop() - 50 + tocele.position().top
}, 80)
nowtoc = ele.name
}
break
}
}
//
})
});
</script>
<?php endif; ?>
<section class="section section-lg section-hero section-shaped">
<?php printBackground(($this->fields->pic ? $this->fields->pic : getRandomImage($this->options->randomImage)), $this->options->bubbleShow); ?>
<div class="container shape-container d-flex align-items-center py-lg">
<div class="col px-0 text-center">
<div class="row align-items-center justify-content-center">
<h1 class="text-white"><?php $this->title() ?></h1>
</div>
<div class="row align-items-center justify-content-center">
<h5 class="text-white">于 <time datetime="<?php $this->date('c'); ?>"><?php $this->date(); ?></time> 由 <?php $this->author(); ?> 发布</h5>
</div>
</div>
</div>
</section>
<section class="section section-components bg-secondary content-card-container">
<div class="container container-lg py-5 align-items-center content-card-container">
<div class="card shadow content-card content-card-head">
<!-- Article content -->
<section class="section">
<div class="container">
<div class="content">
<?php if($this->hidden){ ?>
<div class="container text-center">
<form class="protected" id="protected" action="<?php $this->permalink() ?>" method="post">
<textarea name="text" style="display:none;"></textarea>
<p class="lead">写一下密码啦</p>
<div class="row justify-content-md-center">
<div class="col col-10">
<input class="form-control" type="password" name="protectPassword" id="protectPassword" placeholder="请输入密码">
</div>
<div class="col-md-auto">
<button type="submit" class="btn btn-info" id="protectButton">确认</button>
</div>
</div>
</form>
<script>
$("#protectPassword").on('focus', function() {
$(this).removeClass("is-invalid")
})
$("#protected").submit(function() {
var secr = <?php echo Typecho_Common::shuffleScriptVar($this->security->getToken(clear_urlcan($this->request->getRequestUrl()))); ?>
$("#protectButton").attr("disabled", true);
$.ajax({
url: $(this).attr("action") + "?_=" + secr,
type: $(this).attr("method"),
data: $(this).serializeArray(),
complete: function() {
$("#protectButton").attr("disabled", false);
},
error: function() {
},
success: function(data) {
if (data) {
var parser = new DOMParser()
var htmlDoc = parser.parseFromString(data, "text/html")
if (htmlDoc.title == "Error") {
$("#protectPassword").addClass("is-invalid")
} else {
$("#protectPassword").addClass("is-valid")
$("#protected").fadeOut();
setTimeout(function() {
$("title").html(htmlDoc.title)
$("#pjax-container").html(htmlDoc.getElementById("pjax-container").innerHTML)
}, 1000)
}
}
}
})
return false
})
</script>
</div>
<?php }else{ ?>
<?php
$this->content();
?>
<hr>
<ul>
<li>分类:<?php printCategory($this); ?></li>
<li>标签:<?php printTag($this); ?></li>
</ul>
<?php } ?>
</div>
</div>
</section>
</div>
<div class="card shadow content-card">
<!-- Comment -->
<?php if (!$this->hidden && $this->allow('comment')) $this->need('comments.php'); ?>
</div>
</div>
</section>
<?php $this->need('footer.php'); ?>