mirror of
https://github.com/rystaf/mlmym.git
synced 2024-11-22 05:36:16 +00:00
save post xhr. fixes #33
This commit is contained in:
parent
ca47acec84
commit
7b423eebb7
|
@ -315,9 +315,9 @@ function setup() {
|
|||
var posts = document.getElementsByClassName("post")
|
||||
for (var i = 0; i < posts.length; i++) {
|
||||
posts[i].addEventListener("click", postClick)
|
||||
var voteForm = posts[i].getElementsByClassName("link-btn")
|
||||
if (voteForm.length) {
|
||||
voteForm[0].addEventListener("submit", formSubmit)
|
||||
var forms = posts[i].getElementsByClassName("link-btn")
|
||||
for (var f = 0; f < forms.length; f++) {
|
||||
forms[f].addEventListener("submit", formSubmit)
|
||||
}
|
||||
var url = posts[i].getElementsByClassName("url")[0].href
|
||||
if (id = parseYoutube(url)) {
|
||||
|
|
|
@ -924,6 +924,14 @@ func UserOp(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
if r.FormValue("xhr") != "" {
|
||||
state.GetPost(postid)
|
||||
state.PostID = 0
|
||||
state.Op = "save_post"
|
||||
state.XHR = true
|
||||
Render(w, "index.html", state)
|
||||
return
|
||||
}
|
||||
case "save_comment":
|
||||
commentid, _ := strconv.Atoi(r.FormValue("commentid"))
|
||||
_, err := state.Client.SaveComment(context.Background(), types.SaveComment{
|
||||
|
|
|
@ -56,6 +56,6 @@
|
|||
{{ template "sidebar.html" . }}
|
||||
</main>
|
||||
{{ end }}
|
||||
<script src="/_/static/utils.js?v=15"></script>
|
||||
<script src="/_/static/utils.js?v=17"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -133,7 +133,7 @@
|
|||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
<script src="/_/static/utils.js?v=16"></script>
|
||||
<script src="/_/static/utils.js?v=17"></script>
|
||||
{{ template "sidebar.html" . }}
|
||||
</main>
|
||||
{{ end }}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
{{ if ne .State.Op "vote_post" }}
|
||||
{{ if and (ne .State.Op "vote_post") (ne .State.Op "save_post") }}
|
||||
<div class="post{{if .Post.Deleted}} deleted{{end}}{{ if or .Post.FeaturedCommunity .Post.FeaturedLocal }} distinguished{{end}}">
|
||||
{{ if gt .Rank 0 }}
|
||||
<div class="rank"> {{ .Rank }} </div>
|
||||
{{ end }}
|
||||
<div class="score">
|
||||
{{ end }}
|
||||
{{ if or (ne .State.Op "save_post") (eq .State.Op "vote_post") }}
|
||||
{{ if .State.Session }}
|
||||
<form class="link-btn {{ if lt .Rank 1 }}squish{{end}}{{ if eq .MyVote.String "1" }} like{{else if eq .MyVote.String "-1"}} dislike{{end}}" method="POST">
|
||||
<input type="submit" name="vote" value="▲">
|
||||
|
@ -19,7 +20,8 @@
|
|||
{{ else }}
|
||||
<div style="margin-top: 19px;">{{ .Counts.Score }}</div>
|
||||
{{ end }}
|
||||
{{ if ne .State.Op "vote_post" }}
|
||||
{{ end }}
|
||||
{{ if and (ne .State.Op "vote_post") (ne .State.Op "save_post") }}
|
||||
</div>
|
||||
<div class="thumb">
|
||||
<a class="url" href="{{ if .Post.URL.IsValid }}{{ .Post.URL }}{{ else }}/{{ .State.Host }}/post/{{ .Post.ID }}{{ end }}">
|
||||
|
@ -59,6 +61,8 @@
|
|||
{{ end }}
|
||||
</form>
|
||||
{{ end}}
|
||||
{{ end }}
|
||||
{{ if or (ne .State.Op "vote_post") (eq .State.Op "save_post") }}
|
||||
{{ if .State.Session }}
|
||||
<form class="link-btn" method="POST">
|
||||
<input type="hidden" name="postid" value="{{.Post.ID }}">
|
||||
|
@ -70,6 +74,8 @@
|
|||
{{ end }}
|
||||
</form>
|
||||
{{end}}
|
||||
{{ end }}
|
||||
{{ if and (ne .State.Op "vote_post") (ne .State.Op "save_post") }}
|
||||
{{ if .State.PostID }}
|
||||
<a id="hidechildren" class="scripting" href="">hide all child comments</a>
|
||||
{{ end }}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
{{ template "activities.html" . }}
|
||||
{{ else }}
|
||||
{{ range $post := .Posts }}
|
||||
|
||||
{{ template "post.html" $post }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
|
Loading…
Reference in a new issue