Attempt to fix undidio's unreadable indentation scheme

This commit is contained in:
8chan 2014-09-25 20:44:03 +00:00
parent a4c67065f1
commit f253d841f5

View File

@ -1,4 +1,4 @@
/* /*
Copyright (C) 2014 undido Copyright (C) 2014 undido
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
@ -13,104 +13,84 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
expands images and webm on hover expands images and webm on hover
*/
*/ $(document).ready(function(){
$(document).ready(function(){ var mouseisOnImage = false;
var mouseisOnImage = false; var mouseexitedImage = false;
var mouseexitedImage = false; var imageHover = (localStorage['imagehover']) ? true:false;
var imageHover = (localStorage['imagehover']) ? true:false; imageHover = !imageHover;
imageHover = !imageHover;
var imageEnter = function(){
var imageEnter = function(){
if (!imageHover) if (!imageHover)
return; return;
mouseexitedImage = false;
mouseisOnImage = false;
isVideo = (($(this).prop("tagName") == "VIDEO") ? true:($(this).parent().attr("href").indexOf("player.php?v=") > -1) ? true:false);
maxWidth = document.body.offsetWidth-(document.body.offsetWidth * 0.25);
maxHeight = document.documentElement.clientHeight;
stylez = "z-index:1000;z-index: 1000;position: fixed;top: 0;right: 0;";
if (!isVideo){
fileInfo = $(this).parent().parent().children(".fileinfo").children(".unimportant").text();
isSpoiler = (fileInfo.indexOf("Spoiler") > -1) ? true:false;
imageD = ((isSpoiler) ? fileInfo.split(",")[2]:fileInfo.split(",")[1]);
imageWidth = parseInt(imageD.split("x")[0]);
imageHeight = parseInt(imageD.split("x")[1]);
mouseexitedImage = false; widStyle = "max-width:" + maxWidth + "px;";
mouseisOnImage = false; heiStyle = ((maxHeight < imageHeight) ? "height:"+maxHeight+"px;":"");
$imgH = $("<img/>", {"src":$(this).parent().attr("href"), "style":stylez + ((imageWidth > maxWidth) ? widStyle:"")+heiStyle, "id":"hover-image"});
} else {
fileInfo = $(this).parent().parent().children(".fileinfo").children(".unimportant").text();
isSpoiler = (fileInfo.indexOf("Spoiler") > -1) ? true:false;
imageD = ((isSpoiler) ? fileInfo.split(",")[2]:fileInfo.split(",")[1]);
videoWidth = parseInt(imageD.split("x")[0]);
videoHeight = parseInt(imageD.split("x")[1]);
isVideo = (($(this).prop("tagName") == "VIDEO") ? true:($(this).parent().attr("href").indexOf("player.php?v=") > -1) ? true:false); widStyle = "width:" + ((maxWidth > videoWidth) ? videoWidth:maxWidth) + "px;" + "height:" + ((maxHeight < videoHeight) ? "100%": videoHeight+"px;");
maxWidth = document.body.offsetWidth-(document.body.offsetWidth * 0.25); $imgH = $("<iframe/>", {"src":$(this).parent().attr("href"), "style":stylez + widStyle, "id":"hover-image"});
maxHeight = document.documentElement.clientHeight; }
stylez = "z-index:1000;z-index: 1000;position: fixed;top: 0;right: 0;";
if (!isVideo){
fileInfo = $(this).parent().parent().children(".fileinfo").children(".unimportant").text();
isSpoiler = (fileInfo.indexOf("Spoiler") > -1) ? true:false;
imageD = ((isSpoiler) ? fileInfo.split(",")[2]:fileInfo.split(",")[1]);
imageWidth = parseInt(imageD.split("x")[0]);
imageHeight = parseInt(imageD.split("x")[1]);
widStyle = "max-width:" + maxWidth + "px;"; $(document.body).append($imgH);
heiStyle = ((maxHeight < imageHeight) ? "height:"+maxHeight+"px;":""); $("#hover-image").hover(function(){
$imgH = $("<img/>", {"src":$(this).parent().attr("href"), "style":stylez + ((imageWidth > maxWidth) ? widStyle:"")+heiStyle, "id":"hover-image"}); mouseisOnImage = true;
} else { }, function(){
fileInfo = $(this).parent().parent().children(".fileinfo").children(".unimportant").text(); mouseisOnImage = false;
isSpoiler = (fileInfo.indexOf("Spoiler") > -1) ? true:false; if (mouseexitedImage){
imageD = ((isSpoiler) ? fileInfo.split(",")[2]:fileInfo.split(",")[1]); $("#hover-image").remove();
videoWidth = parseInt(imageD.split("x")[0]); }
videoHeight = parseInt(imageD.split("x")[1]); });
};
imageLeave = function(){
setTimeout(function(){
mouseexitedImage = true;
widStyle = "width:" + ((maxWidth > videoWidth) ? videoWidth:maxWidth) + "px;" + "height:" + ((maxHeight < videoHeight) ? "100%": videoHeight+"px;"); if (!mouseisOnImage){
$imgH = $("<iframe/>", {"src":$(this).parent().attr("href"), "style":stylez + widStyle, "id":"hover-image"}); $("#hover-image").remove();
} }
},50);
};
$("a .post-image").hover(imageEnter,imageLeave);
$mrCheckie = $('<div><label id=\"toggle-image-hover\"><input id="toggle-hover" type=\"checkbox\"> show image on hover</label></div>');
$(".options_tab").append($mrCheckie);
$("#toggle-hover").prop("checked", imageHover);
$("#toggle-hover").on("click", function(){
if ($(this).prop("checked")){
imageHover = true;
delete localStorage['imagehover'];
} else {
imageHover = false;
localStorage['imagehover'] = true;
}
});
$(document.body).append($imgH); $(".options_tab").append();
$("#hover-image").hover(function(){
mouseisOnImage = true;
}, function(){
mouseisOnImage = false;
if (mouseexitedImage){
$("#hover-image").remove();
}
});
};
imageLeave = function(){
setTimeout(function(){
mouseexitedImage = true;
if (!mouseisOnImage){
$("#hover-image").remove();
}
},50);
};
$("a .post-image").hover(imageEnter,imageLeave);
$mrCheckie = $('<div><label id=\"toggle-image-hover\"><input id="toggle-hover" type=\"checkbox\"> show image on hover</label></div>');
$(".options_tab").append($mrCheckie);
$("#toggle-hover").prop("checked", imageHover);
$("#toggle-hover").on("click", function(){
if ($(this).prop("checked")){
imageHover = true;
delete localStorage['imagehover'];
} else {
imageHover = false;
localStorage['imagehover'] = true;
}
});
$(".options_tab").append();
$(document).on("new_post", function(e, post) { $(document).on("new_post", function(e, post) {
$(post).hover(imageEnter(),imageLeave()); $(post).hover(imageEnter(),imageLeave());