diff options
author | FChannel <> | 2021-06-28 20:09:42 -0700 |
---|---|---|
committer | FChannel <> | 2021-06-28 20:09:42 -0700 |
commit | 057c5639222dc773ff8d588ab122cc267b27c187 (patch) | |
tree | cfb3b98feb22844eea707e149657275aae377bab /static | |
parent | 429ab6de683653c0ae509ba169eab768f2e3bd91 (diff) |
added tor image in place of broken links. if user is using tor they just click the image to view it
Diffstat (limited to 'static')
-rw-r--r-- | static/clover.png | bin | 0 -> 92559 bytes | |||
-rw-r--r-- | static/js/posts.js | 7 | ||||
-rw-r--r-- | static/posts.html | 31 |
3 files changed, 33 insertions, 5 deletions
diff --git a/static/clover.png b/static/clover.png Binary files differnew file mode 100644 index 0000000..305748e --- /dev/null +++ b/static/clover.png diff --git a/static/js/posts.js b/static/js/posts.js index 06aab77..79fb7c4 100644 --- a/static/js/posts.js +++ b/static/js/posts.js @@ -296,7 +296,12 @@ function dragElement(elmnt) { function stripTransferProtocol(value){ var re = /(https:\/\/|http:\/\/)?(www.)?/ - return value.replace(re, "") } +function isOnion(value){ + var re = /\.onion/ + if(value.match(re) != null) + return true + return false +} diff --git a/static/posts.html b/static/posts.html index 1b1d78b..194c273 100644 --- a/static/posts.html +++ b/static/posts.html @@ -18,19 +18,30 @@ {{ end }} <span style="display: block;">File: <a id="{{ .Id }}-img" href="{{ (index .Attachment 0).Href}}">{{ (index .Attachment 0).Name }}</a><span id="{{ .Id }}-size">({{ (index .Attachment 0).Size }})</span></span> <div id="hide-{{ .Id }}" style="display: none;">[Hide]</div> - <div id="sensitive-{{ .Id }}" style="display: none;"><div style="position: relative; text-align: center;"><img style="float: left; margin-right: 10px; margin-bottom: 10px; max-width: 250px; max-height: 250px;" src="/static/sensitive.png"><div style="width: 240px; position: absolute; margin-top: 110px; padding: 5px; background-color: black; color: white; cursor: default; ">NSFW Content</div></div></div> + <div id="sensitive-{{ .Id }}" style="display: none;"><div style="position: relative; text-align: center;"><img id="sensitive-img-{{ .Id }}" style="float: left; margin-right: 10px; margin-bottom: 10px; max-width: 250px; max-height: 250px;" src="/static/sensitive.png"><div id="sensitive-text-{{ .Id }}" style="width: 240px; position: absolute; margin-top: 110px; padding: 5px; background-color: black; color: white; cursor: default; ">NSFW Content</div></div></div> <div id="media-{{ .Id }}"></div> <script> media = document.getElementById("media-{{ .Id }}") - if({{ .Sensitive }} && {{ $board.Actor.Restricted }}){ + if(({{ .Sensitive }} && {{ $board.Actor.Restricted }}) || isOnion("{{ .Id }}")){ sensitive = document.getElementById("sensitive-{{ .Id }}") hide = document.getElementById("hide-{{ .Id }}") sensitive.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: block;"; document.getElementById("sensitive-{{ .Id }}").style="display: none;"; document.getElementById("hide-{{ .Id }}").style="display: block; cursor: pointer;"} hide.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: none;"; document.getElementById("sensitive-{{ .Id }}").style="display: block;"; document.getElementById("hide-{{ .Id }}").style="display: none;"} sensitive.style = "display: block" media.style = "display: none;" - } + } + + if(isOnion("{{ .Id }}")) { + sensitive = document.getElementById("sensitive-{{ .Id }}") + document.getElementById("sensitive-img-{{ .Id }}").src = "/static/clover.png" + document.getElementById("sensitive-text-{{ .Id }}").innerText = "Tor Node" + hide = document.getElementById("hide-{{ .Id }}") + sensitive.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: block;"; document.getElementById("sensitive-{{ .Id }}").style="display: none;"; document.getElementById("hide-{{ .Id }}").style="display: block; cursor: pointer;"} + hide.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: none;"; document.getElementById("sensitive-{{ .Id }}").style="display: block;"; document.getElementById("hide-{{ .Id }}").style="display: none;"} + sensitive.style = "display: block" + media.style = "display: none;" + } if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "image"){ var img = document.createElement("img"); @@ -100,11 +111,12 @@ <div id="hide-{{ .Id }}" style="display: none;">[Hide]</div> <div id="sensitive-{{ .Id }}" style="display: none;"><div style="position: relative; text-align: center;"><img style="float: left; margin-right: 10px; margin-bottom: 10px; max-width: 250px; max-height: 250px;" src="/static/sensitive.png"><div style="width: 240px; position: absolute; margin-top: 110px; padding: 5px; background-color: black; color: white; cursor: default; ">NSFW Content</div></div></div> {{ end }} + <div> </div> <div id="media-{{ .Id }}" sensitive="0"></div> <script> media = document.getElementById("media-{{ .Id }}") - if({{ .Sensitive }} && {{ $board.Actor.Restricted }}){ + if(({{ .Sensitive }} && {{ $board.Actor.Restricted }}) || isOnion("{{ .Id }}")){ sensitive = document.getElementById("sensitive-{{ .Id }}") hide = document.getElementById("hide-{{ .Id }}") sensitive.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: block;"; document.getElementById("sensitive-{{ .Id }}").style="display: none;"; document.getElementById("hide-{{ .Id }}").style="display: block; cursor: pointer;"} @@ -112,6 +124,17 @@ sensitive.style = "display: block" media.style = "display: none;" } + + if(isOnion("{{ .Id }}")) { + sensitive = document.getElementById("sensitive-{{ .Id }}") + document.getElementById("sensitive-img-{{ .Id }}").src = "/static/clover.png" + document.getElementById("sensitive-text-{{ .Id }}").innerText = "Tor Node" + hide = document.getElementById("hide-{{ .Id }}") + sensitive.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: block;"; document.getElementById("sensitive-{{ .Id }}").style="display: none;"; document.getElementById("hide-{{ .Id }}").style="display: block; cursor: pointer;"} + hide.onclick = function(){document.getElementById("media-{{ .Id }}").style="display: none;"; document.getElementById("sensitive-{{ .Id }}").style="display: block;"; document.getElementById("hide-{{ .Id }}").style="display: none;"} + sensitive.style = "display: block" + media.style = "display: none;" + } if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "image"){ var img = document.createElement("img"); |