insert youtube embeds on loadmore

This commit is contained in:
Ryan Stafford 2023-07-08 22:30:22 -04:00
parent 34f349313f
commit 6685badaca
4 changed files with 23 additions and 20 deletions

View file

@ -86,10 +86,10 @@ summary {
visibility: hidden; visibility: hidden;
} }
.score form.link-btn input { .score form.link-btn input {
display: block; display: inline-block;
color: #b7b7b7; color: #b7b7b7;
font-size: 20px; font-size: 20px;
line-height: 16px; line-height: 15px;
} }
.dark .score form.link-btn input { .dark .score form.link-btn input {
color: #646464; color: #646464;
@ -104,10 +104,6 @@ summary {
color: #eb445a; color: #eb445a;
} }
.score form div {
position: relative;
top: 2px;
}
.title a { .title a {
font-size: medium; font-size: medium;
text-decoration: none; text-decoration: none;
@ -174,7 +170,7 @@ summary {
margin: 0px 0px 5px 15px; margin: 0px 0px 5px 15px;
border: 1px solid #e6e6e6; border: 1px solid #e6e6e6;
border-radius: 3px; border-radius: 3px;
padding: 5px 10px 5px 5px; padding: 5px 10px 5px 7px;
} }
.dark .comment { .dark .comment {
border-color: #333; border-color: #333;
@ -395,8 +391,8 @@ form.nsfw div {
#loadmore.show { #loadmore.show {
display: block; display: block;
} }
#loadmore[disabled] { #end {
visibility: visible; visibility: hidden;
} }
.buttons li { .buttons li {
display: inline; display: inline;
@ -505,6 +501,9 @@ form.nsfw div {
.expando.open{ .expando.open{
display: block; display: block;
} }
.expando .embed {
text-align: center;
}
.expando .image { .expando .image {
display: block; display: block;
overflow: hidden; overflow: hidden;

View file

@ -122,6 +122,7 @@ function loadMore(e) {
} }
var loadmore = document.getElementById("loadmore") var loadmore = document.getElementById("loadmore")
if (loadmore) loadmore.className = "show" if (loadmore) loadmore.className = "show"
insert_youtube()
} }
else { else {
e.target.outerHTML = '<input id="end" type="submit" value="" disabled>' e.target.outerHTML = '<input id="end" type="submit" value="" disabled>'
@ -263,18 +264,21 @@ function toggle_images(open) {
} }
} }
var posts = document.getElementsByClassName("post") function insert_youtube() {
for (var i = 0; i < posts.length; i++) { var posts = document.getElementsByClassName("post")
var url = posts[i].getElementsByClassName("url")[0].href for (var i = 0; i < posts.length; i++) {
if (id = parse_youtube(url)) { var url = posts[i].getElementsByClassName("url")[0].href
var btn = posts[i].getElementsByClassName("expando-button")[0] if (id = parse_youtube(url)) {
if (btn.className.indexOf("open") > -1) { var btn = posts[i].getElementsByClassName("expando-button")[0]
posts[i].getElementsByClassName("embed")[0].innerHTML = youtube_iframe(id) if (btn.className.indexOf("open") > -1) {
} else { posts[i].getElementsByClassName("embed")[0].innerHTML = youtube_iframe(id)
btn.className = "expando-button" } else {
btn.className = "expando-button"
}
} }
} }
} }
insert_youtube()
if (localStorage.getItem("endlessScrolling") == "true") { if (localStorage.getItem("endlessScrolling") == "true") {
var pager = document.getElementsByClassName("pager") var pager = document.getElementsByClassName("pager")

View file

@ -2,7 +2,7 @@
<head> <head>
<title>{{ if and .Community (ne .Community.CommunityView.Community.Title "")}}{{.Community.CommunityView.Community.Title}}{{else if ne .CommunityName ""}}/c/{{.CommunityName}}{{ else if .User}}overview for {{.User.PersonView.Person.Name}}{{else}}{{ host .Host }}{{end}}</title> <title>{{ if and .Community (ne .Community.CommunityView.Community.Title "")}}{{.Community.CommunityView.Community.Title}}{{else if ne .CommunityName ""}}/c/{{.CommunityName}}{{ else if .User}}overview for {{.User.PersonView.Person.Name}}{{else}}{{ host .Host }}{{end}}</title>
<link rel="shortcut icon" href="/{{.Host}}/icon.jpg"> <link rel="shortcut icon" href="/{{.Host}}/icon.jpg">
<link rel="stylesheet" href="/_/static/style.css?v=15"> <link rel="stylesheet" href="/_/static/style.css?v=16">
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
</head> </head>
<body {{ if .Dark }}class="dark"{{end}}> <body {{ if .Dark }}class="dark"{{end}}>

View file

@ -3,7 +3,7 @@
<title>{{if and .Posts .PostID }}{{ (index .Posts 0).Post.Name}} : {{.CommunityName}}{{else if and .Community (ne .Community.CommunityView.Community.Title "")}}{{.Community.CommunityView.Community.Title}}{{else if ne .CommunityName ""}}/c/{{.CommunityName}}{{ else if .User}}overview for {{.User.PersonView.Person.Name}}{{else}}{{ host .Host }}{{end}}</title> <title>{{if and .Posts .PostID }}{{ (index .Posts 0).Post.Name}} : {{.CommunityName}}{{else if and .Community (ne .Community.CommunityView.Community.Title "")}}{{.Community.CommunityView.Community.Title}}{{else if ne .CommunityName ""}}/c/{{.CommunityName}}{{ else if .User}}overview for {{.User.PersonView.Person.Name}}{{else}}{{ host .Host }}{{end}}</title>
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="shortcut icon" href="/{{.Host}}/icon.jpg"> <link rel="shortcut icon" href="/{{.Host}}/icon.jpg">
<link rel="stylesheet" href="/_/static/style.css?v=15"> <link rel="stylesheet" href="/_/static/style.css?v=16">
</head> </head>
<body{{ if .Dark }} class="dark"{{end}}> <body{{ if .Dark }} class="dark"{{end}}>
<noscript> <noscript>