Merge pull request #52 from DorukSega/main

Latest Section Update
This commit is contained in:
Robin Universe 2022-05-13 07:23:58 -05:00 committed by GitHub
commit 5b58c0d9bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 280 additions and 82 deletions

View file

@ -1,7 +1,8 @@
var tweetCount = 1, var tweetCount = 1,
page = 0, page = 0,
loading = false, loading = false,
bigArray = []; bigArray = [],
isNSFWSHOW = false;
const iosHeight = () => { const iosHeight = () => {
document.documentElement.style.setProperty("--ios-height", window.innerHeight + "px"); document.documentElement.style.setProperty("--ios-height", window.innerHeight + "px");
}; };
@ -11,22 +12,46 @@ window.onload = () => {
//ios height //ios height
iosHeight(); iosHeight();
const contwarn = document.querySelector("#contwarn"); const contwarn = document.querySelector("#contwarn");
const notsafe = document.querySelector("#notsafe");
if (document.cookie.includes("NSFW=true")) {
notsafe.checked = true;
isNSFWSHOW = true;
}
if (document.cookie.includes("always=true")) { if (document.cookie.includes("always=true")) {
contwarn.checked = true; contwarn.checked = true;
forNow(); forNow();
} }
contwarn.addEventListener("change", () => { contwarn.addEventListener("change", () => {
if (contwarn.checked) { if (contwarn.checked)
document.cookie = `always = true; max-age=15780000; SameSite=None; Secure`; addCookie("always", true);
} else { else
document.cookie = "always=false"; addCookie("always", false);
})
notsafe.addEventListener("change", () => {
if (notsafe.checked) {
document.querySelectorAll(".nsfw").forEach(e => e.classList.add("noff"));
addCookie("NSFW", true);
isNSFWSHOW = true;
} }
else {
document.querySelectorAll(".noff").forEach(e => e.classList.remove("noff"));
isNSFWSHOW = false;
addCookie("NSFW", false);
}
}) })
} }
function addCookie(name, state) {
if (state)
document.cookie = `${name}=${state}; max-age=15780000; SameSite=None; Secure`;
else
document.cookie = `${name}=`;
}
function cookieTime() { function cookieTime() {
document.querySelector("#contwarn").checked = true; document.querySelector("#contwarn").checked = true;
document.cookie = `always = true; max-age=15780000; SameSite=None; Secure`; addCookie("always", true);
forNow(); forNow();
} }
function forNow() { function forNow() {
@ -149,31 +174,78 @@ function createTweet(json) {
tweet.appendChild(desc); tweet.appendChild(desc);
} }
if (json["nsfw"]) { //beware
var nsfw = createEl("div", "nsfw");
const ncont = createEl("div", "ncont");
const ninfo = createEl("div", "ninfo", { inner: "This is a NSFW Tweet <br> Press \"Show me\" if you want to see it" });
var nshow = createEl("div", "nshow", { inner: "Show me" });
ncont.appendChild(ninfo);
ncont.appendChild(nshow);
nsfw.appendChild(ncont);
if (isNSFWSHOW === true)
nsfw.classList.add("noff");
}
switch (json["type"]) { switch (json["type"]) {
case "Text": case "Text":
//so empty //so empty
break; break;
case "Image": case "Image":
const media = createEl("img", "media", { if (json["images"][4] > "1" && json["images"][4]) { //multiple images!!??
src: json["thumbnail"], const grid = createEl("div", "imgCont");
lazy: true for (let i = 0; i < json["images"][4]; i++)
}); grid.appendChild(createEl("img", "media", {
tweet.appendChild(media); src: json["images"][i],
lazy: true
}));
//console.log(json["images"][4])
if (nsfw)
nsfw.appendChild(grid);
else
tweet.appendChild(grid);
}
else {
const media = createEl("img", "media", {
src: json["thumbnail"],
lazy: true
});
if (nsfw)
nsfw.appendChild(media);
else
tweet.appendChild(media);
}
break; break;
case "Video": case "Video":
const video = createEl("video", "media", { const video = createEl("video", "media", {
video: json["url"] video: json["url"]
}); });
tweet.appendChild(video); if (nsfw)
nsfw.appendChild(video);
else
tweet.appendChild(video);
break; break;
default: default:
const video2 = createEl("video", "media", { const video2 = createEl("video", "media", {
video: json["url"] video: json["url"]
}); });
tweet.appendChild(video2); if (nsfw)
nsfw.appendChild(video2);
else
tweet.appendChild(video2);
//console.log("this should not happen!"); //console.log("this should not happen!");
break; break;
} }
if (nsfw) {
tweet.appendChild(nsfw);
nshow.addEventListener("click", () => {
nsfw.classList.add("noff");
});
}
const qrtob = json["qrt"]; const qrtob = json["qrt"];
if ((Object.keys(qrtob).length === 0 && Object.getPrototypeOf(qrtob) === Object.prototype) == false) { if ((Object.keys(qrtob).length === 0 && Object.getPrototypeOf(qrtob) === Object.prototype) == false) {
@ -207,6 +279,7 @@ function createTweet(json) {
share.addEventListener("click", () => share.addEventListener("click", () =>
navigator.clipboard.writeText(json["tweet"].replace("https://t", "https://fxt")) navigator.clipboard.writeText(json["tweet"].replace("https://t", "https://fxt"))
); );
tweetCount++; tweetCount++;
} else { } else {
if (bigArray.length > 100) //pro memory management 😎 if (bigArray.length > 100) //pro memory management 😎

View file

@ -2,23 +2,23 @@
font-family: NotoColorEmojiLimited; font-family: NotoColorEmojiLimited;
unicode-range: U+1F1E6-1F1FF; unicode-range: U+1F1E6-1F1FF;
src: url("https://fxtwitter.com/font.ttf"); src: url("https://fxtwitter.com/font.ttf");
} }
:root { :root {
--ios-height: 100vh; --ios-height: 100vh;
--top-height: calc(6vh + 2vw); --top-height: calc(4.5vh + 1.25vw);
} }
body{ body {
margin: 0; margin: 0;
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
height: var(--ios-height); height: var(--ios-height);
overflow: hidden; overflow: hidden;
} }
a{ a {
color: unset; color: unset;
text-decoration: unset; text-decoration: unset;
} }
@ -29,18 +29,18 @@ a:focus,
a:visited, a:visited,
a:active, a:active,
a:-webkit-any-link, a:-webkit-any-link,
:link{ :link {
color: unset; color: unset;
text-decoration: unset; text-decoration: unset;
} }
a:hover{ a:hover {
color: #8ebf42; color: #8ebf42;
} }
::-webkit-scrollbar { ::-webkit-scrollbar {
width: 1vmin; width: 1vmin;
} }
::-webkit-scrollbar-track { ::-webkit-scrollbar-track {
@ -63,94 +63,105 @@ a:hover{
background-color: #e8e8e8; background-color: #e8e8e8;
} }
.base{ .base {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: 100%; width: 100%;
height: 100%; height: 100%;
font-family: 'Paytone One','NotoColorEmojiLimited', sans-serif; font-family: 'Paytone One', 'NotoColorEmojiLimited', sans-serif;
background-color: #222222; background-color: #222222;
color: #e8e8e8; color: #e8e8e8;
} }
.top{ .top {
height: var(--top-height); height: var(--top-height);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
text-align: center; text-align: center;
box-sizing: border-box; box-sizing: border-box;
font-size: 9vmin; font-size: 7vmin;
padding: 1vmin 0 1vmin; padding: 1vmin 0 1vmin;
/*margin: 0 20vw 0; /*margin: 0 20vw 0;
border-bottom: #e8e8e8 .1vmin solid;*/ border-bottom: #e8e8e8 .1vmin solid;*/
box-shadow: rgba(0, 0, 0, 0.2) 0px 1px 2px 0px; box-shadow: rgba(0, 0, 0, 0.2) 0px 1px 2px 0px;
} }
.top:hover{
.top:hover {
color: #8ebf42; color: #8ebf42;
cursor: pointer; cursor: pointer;
} }
.bottom { .bottom {
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
} }
.tweetCont{ .tweetCont {
flex: 2; flex: 2;
padding: calc( 1vh + .25vw ) 10% 0; padding: calc(1vh + .25vw) 10% 0;
overflow-y: auto; overflow-y: auto;
max-height: calc( var(--ios-height) - var(--top-height) - calc( 1vh + .25vw ) ); max-height: calc(var(--ios-height) - var(--top-height) - calc(1vh + .25vw));
} }
.tweet{ .tweet {
display: flex; display: flex;
position: relative; position: relative;
flex-direction: column; flex-direction: column;
background-color: #171717; background-color: #171717;
margin: 0 0 calc( 2vh + .5vw ); margin: 0 0 calc(2vh + .5vw);
padding: 1vmin 0 1vmin; padding: 1vmin 0 1vmin;
box-shadow: rgba(0, 0, 0, 0.4) 0px 4px 7px; box-shadow: rgba(0, 0, 0, 0.4) 0px 4px 7px;
font-size: 18px; font-size: 18px;
} }
.side{ .side {
flex: 1; flex: 1;
overflow-y: auto; overflow-y: auto;
max-height: calc( var(--ios-height) - var(--top-height) - calc( 1vh + .25vw ) ); max-height: calc(var(--ios-height) - var(--top-height) - calc(1vh + .25vw));
}
.by{
color: #8ebf42;
}
.by:hover{
color: #F74843;
}
/* Tweet */
.desc{
padding: 0 calc( 1.5vh + .25vw ) 0;
} }
.auth,.meta{ .by {
color: #8ebf42;
}
.by:hover {
color: #F74843;
}
/* Tweet */
.desc {
padding: 0 calc(1.5vh + .25vw) 0;
}
.auth,
.meta {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
gap: 1%; gap: 1%;
font-size: 1.2em; font-size: 1.2em;
padding: 0 calc( .5vh + .125vw ) 0; padding: 0 calc(.5vh + .125vw) 0;
} }
.aname{
.aname {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-evenly; justify-content: space-evenly;
} }
.aname,.type{
.aname,
.type {
flex: 1; flex: 1;
} }
.type{
.type {
text-align: right; text-align: right;
margin: auto 2% auto; margin: auto 2% auto;
} }
.aimage{
.aimage {
border-radius: 50%; border-radius: 50%;
border: #8ebf42 .3vmin solid; border: #8ebf42 .3vmin solid;
height: 100%; height: 100%;
@ -163,63 +174,163 @@ a:hover{
-o-user-drag: none; -o-user-drag: none;
} }
.media{ .nsfw {
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
}
.ncont {
position: absolute;
z-index: 1;
bottom: 20%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 2vmin;
background-color: #17171788;
border-radius: .5vmin;
padding: 1vw;
}
.ninfo {
text-align: center;
}
.nshow {
padding: 1vh 1vw;
background-color: #171717;
border: solid .5vmin #8ebf42;
color: #e8e8e8;
border-radius: .5vmin;
transition-duration: .2s;
transition-timing-function: ease-in-out;
cursor: pointer;
user-select: none;
font-size: 1em;
}
.nshow:hover {
transform: scale(1.1);
border: solid .5vmin #bf4242;
}
.nshow:active {
transform: scale(.98);
}
.nsfw .media {
filter: blur(30px);
}
.noff div:not(.imgCont) {
display: none;
}
.noff .media {
display: unset;
filter: unset;
}
.imgCont {
display: flex;
flex-direction: row;
justify-content: center;
flex-wrap: wrap;
}
.imgCont .media {
max-width: 50%;
max-height: 35vh;
}
.media {
box-sizing: border-box; box-sizing: border-box;
width: 100%; width: 100%;
height: auto; height: auto;
max-height: 60vh; max-height: 60vh;
object-fit: scale-down; object-fit: scale-down;
background-color: black; background-color: black;
} }
.quote{
.quote {
margin: auto; margin: auto;
width: 90%; width: 90%;
border-radius: .5vmin; border-radius: .5vmin;
border: #222222 solid .5vmin; border: #222222 solid .5vmin;
padding: .5vmin; padding: .5vmin;
} }
.qname{
.qname {
color: #8ebf42; color: #8ebf42;
} }
.cont,.date{
.cont,
.date {
margin: auto 0 auto; margin: auto 0 auto;
} }
.date{
.date {
margin-left: 2%; margin-left: 2%;
} }
.share{
.share {
margin-left: auto; margin-left: auto;
height: 2em; height: 2em;
transition-duration: .2s; transition-duration: .2s;
transition-timing-function: ease-in-out; transition-timing-function: ease-in-out;
} }
.share:hover{
.share:hover {
transform: scale(.8); transform: scale(.8);
} }
.share:active{
.share:active {
transform: scale(2); transform: scale(2);
} }
.auth,.desc,.media,.quote{
.auth,
.desc,
.quote {
margin-bottom: 2vmin; margin-bottom: 2vmin;
} }
/* Settings */ /* Settings */
.settings,.info{ .settings,
.info {
font-size: 35px; font-size: 35px;
padding: 1vmin; padding: 1vmin;
} }
.opt{
.settings {
user-select: none;
display: flex;
flex-direction: column;
}
.opt {
font-size: .49em; font-size: .49em;
user-select: none; user-select: none;
white-space: nowrap; white-space: nowrap;
flex-wrap: nowrap;
} }
.Iinner{
.Iinner {
font-size: .5em; font-size: .5em;
} }
/* Preview */ /* Preview */
img:not(.previmg,.aimage){ img:not(.previmg, .aimage) {
cursor: pointer; cursor: pointer;
transition-duration: .2s; transition-duration: .2s;
transition-timing-function: ease-in-out; transition-timing-function: ease-in-out;
@ -263,16 +374,19 @@ img:not(.previmg,.aimage){
font-size: calc(1.75vh + .25vw); font-size: calc(1.75vh + .25vw);
text-align: center; text-align: center;
} }
#block .warn{
#block .warn {
font-size: 2em; font-size: 2em;
color: #F74843; color: #F74843;
text-align: center; text-align: center;
} }
.boptions{
.boptions {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
gap: 1.5vmin; gap: 1.5vmin;
} }
.boptions>div { .boptions>div {
padding: 2vh 2vw; padding: 2vh 2vw;
border: solid .5vmin #c5c5c5; border: solid .5vmin #c5c5c5;
@ -294,17 +408,22 @@ img:not(.previmg,.aimage){
transform: scale(.98); transform: scale(.98);
} }
@media (max-aspect-ratio: 4/4), (max-height: 500px), (max-width: 1100px){ @media (max-aspect-ratio: 4/4),
.side{ (max-height: 500px),
(max-width: 1100px) {
.side {
display: none; display: none;
} }
.tweet{
.tweet {
font-size: 12px; font-size: 12px;
} }
.tweetCont{
.tweetCont {
padding: 0 5% 0; padding: 0 5% 0;
} }
.boptions{
.boptions {
flex-direction: column; flex-direction: column;
} }
} }

View file

@ -6,12 +6,12 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Twitfix Latest</title> <title>Twitfix Latest</title>
<link rel="stylesheet" href={{ url_for('static', filename='style.css') }}> <link rel="stylesheet" href={{ url_for('static', filename='style.css' ) }}>
<link href="https://fonts.googleapis.com/css2?family=Paytone+One&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Paytone+One&display=swap" rel="stylesheet">
</head> </head>
<body> <body>
<script src={{ url_for('static', filename='main.js') }}></script> <script src={{ url_for('static', filename='main.js' ) }}></script>
<div class="previmgcont" onclick="document.querySelector('.previmgcont').style.display = 'none'; " <div class="previmgcont" onclick="document.querySelector('.previmgcont').style.display = 'none'; "
style="display: none;"> style="display: none;">
@ -21,8 +21,8 @@
<div class="base"> <div class="base">
<div id="block"> <div id="block">
<p class="warn">Warning!!</p> <p class="warn">Warning!!</p>
<p>Twitfix does not filter out any content.</p> <p>Twitfix only filters the content specified as NSFW.</p>
<p>Following content is most certainly NSFW.</p> <p>Following content might be NSFW.</p>
<p>Prepare yourself mentally and pick one of the options</p> <p>Prepare yourself mentally and pick one of the options</p>
<p>Do you want to see the latest twitfix requests?</p> <p>Do you want to see the latest twitfix requests?</p>
<br> <br>
@ -60,8 +60,14 @@
</div> </div>
<div class="settings side"> <div class="settings side">
<div>Settings</div> <div>Settings</div>
<input type="checkbox" id="contwarn" name="contwarn"> <div>
<label class="opt" for="contwarn">Skip Content Warning</label> <input type="checkbox" id="contwarn" name="contwarn">
<label class="opt" for="contwarn">Skip Content Warning</label>
</div>
<div>
<input type="checkbox" id="notsafe" name="notsafe">
<label class="opt" for="notsafe">Don't Hide NSFW Tweets</label>
</div>
</div> </div>
</div> </div>
</div> </div>