forked from numist/this-might-be-offensive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
1 addition
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/*! original file: thismight.be/offensive/js/picui.js */ | ||
function qc_dialog_init(){function e(h){var k=$("#qc_comments"),i=$("#qc_commentrows"),j=$("#qc_form:visible");if(k.hasAttr("loading")){return}if(i.children().length==0){k.hide();if(j.length>0){h.dialog("option","title","first post!")}else{h.dialog("option","title","nothing to see here, move along")}}else{k.show();if(j.length>0){h.dialog("option","title","let's hear it");if(k.children("b").length==0){k.prepend("<b>the dorks who came before you said: </b>")}}else{h.dialog("option","title","the dorks who came before you said:")}}a(h)}function a(h){var i=h.find("#qc_commentrows");if($("#qc_form:visible").length>0){i.css("margin-top","")}else{i.css("margin-top","0px")}if(!h.dialog("isOpen")){return}if(h.hasAttr("modified")){b(h);return}if(i.filter(":visible").length>0&&i.children().length>0){if(h.children(":visible").first().is("#qc_comments")){h.height(i.get(0).scrollHeight)}else{h.height(i.position().top+i.get(0).scrollHeight)}if(h.height()>$(window).height()-150){h.height($(window).height()-150)}}else{h.height("")}h.dialog("option","position","center");b(h)}function b(i){var h=i.find("textarea#qc_comment");h.width(i.width()-(h.outerWidth(true)-h.width()));var j=i.find("#qc_commentrows:visible");if(j.children().length>0){if(i.children(":visible").first().is("#qc_comments")){j.height(i.height())}else{j.height(i.height()-j.position().top)}}}$("form#qc_form").on("submit",function(i){i.preventDefault();var h=$("#qc_dialog");vote=$("#qc_form input[name=vote]:checked").val();comment=$("#qc_comment").val();tmbo=$("#qc_tmbo").attr("checked")?"1":"0";repost=$("#qc_repost").attr("checked")?"1":"0";subscribe=$("#qc_subscribe").attr("checked")?"1":"0";h.dialog("close");handle_comment_post(comment,vote,tmbo,repost,subscribe);return false});$("#qc_commentrows").on("scroll",function(){self=$(this);if(self.scrollTop()>0){self.attr("scrollTop",self.scrollTop())}else{self.removeAttr("scrollTop")}return true});function d(i){var h=$(this);window.setTimeout(function(){if(h.getCaretPosition()!=undefined){h.attr("caret",h.getCaretPosition())}},0);return true}$("#qc_comment").on("keydown",d).on("click",d);function c(h){h.dialog("widget").fadeTo("fast",0.7);h.attr("modified","");$(window).off("clickoutside.qc")}function g(h){h.dialog("widget").fadeTo("fast",1);a(h);f(h)}function f(h){window.setTimeout(function(){h.dialog("widget").on("clickoutside.qc",function(){h.dialog("close");return true})},0)}return{autoOpen:false,title:"please stand by",width:"500px",minHeight:"50px",open:function(j,k){var h=$(this);var i=$("#qc_commentrows");if(i.hasAttr("scrollTop")){i.scrollTop(i.attr("scrollTop"))}var n=$("#qc_comment:visible");if(n.length>0){var m=n.hasAttr("caret")?n.attr("caret"):0;n.focus().setCaretPosition(m)}else{h.get(0).focus()}unbind_default_events();$(window).on("resize.qc",function(p,q){a(h);return true});f(h);$("body").on("keydown.qc",function(o){if(o.target!=this){return true}$(h.dialog("widget").data("events").keydown).each(function(p,q){q.handler(o)});return true});var l=$("#qc_comments");if(!l.hasAttr("loading")){$.ajax({type:"GET",url:"/offensive/ui/api.php/getcomments.html?fileid="+getURLParam("id"),dataType:"html",beforeSend:function(){if(l.filter(":visible").length==0){l.show()}l.attr("loading","");if(i.children().length==0){i.text("loading…");a(h)}},success:function(s){if($(s).filter("div#comments").length!=1){return}l.removeAttr("loading");var p=i.children().length;var q=h.height()>0&&i.scrollTop()>0&&i.scrollTop()==i.get(0).scrollHeight-i.height();if(p==0){i.text("")}var r=$(s).find("div.entry");if(r.length>0){if(p>0){i.children().remove()}i.append(r);if(p==0){$("#qc_form").css("padding-bottom","10px")}if(q){var o=Math.min(i.scrollTop()+i.height(),i.get(0).scrollHeight-i.height());i.animate({scrollTop:o},500)}}e(h)},complete:function(o,p){if(l.hasAttr("loading")){i.text("fuck. try again?");l.removeAttr("loading");a(h)}}})}},close:function(h,i){$("*").off(".qc");$(document).off(".qc");$(window).off(".qc");bind_default_events()},dragStart:function(h,i){c($(this))},dragStop:function(i,k){var h=$(this),j=h.dialog("widget");g(h);h.dialog("option","position",[j.offset().left,j.offset().top])},resizeStart:function(h,i){c($(this))},resize:function(h,i){b($(this))},resizeStop:function(h,i){g($(this))}}}function qc_form_reset(){$("#qc_form textarea").val("");$("#qc_comment").removeAttr("caret");$("#qc_tmbo").removeAttr("checked");$("#qc_repost").removeAttr("checked");$("#qc_subscribe").removeAttr("checked")}function bind_default_events(){$(document).on("keydown.default",handle_keypress);$("#comments").focus().blur()}function unbind_default_events(){$(document).off(".default")}function do_vote(a){if(!a.parent().hasClass("on")){return}$("#votelinks a").off();vote=a.attr("id");imageid=getURLParam("id");if(vote=="good"){handle_comment_post("","this is good","","0","0","0")}else{handle_comment_post("","this is bad","","0","0","0")}}function handle_comment_post(f,c,d,b,a){var e=getURLParam("id");if(f==undefined){f=""}if(c==undefined){c=""}if(d==undefined){d="0"}if(b==undefined){b="0"}if(a==undefined){a="0"}if(f==""&&(c=="novote"||c=="")&&d==0&&b==0&&a==0){return}if(c=="this is good"||c=="this is bad"){disable_voting()}$.post("/offensive/api.php/postcomment.php",{fileid:e,comment:f,vote:c,offensive:d,repost:b,subscribe:a},function(g){if(c=="this is good"){increase_count("#count_good")}else{if(c=="this is bad"){increase_count("#count_bad")}}if(f!=""){increase_count("#count_comment")}if(d!=0&&$("#count_tmbo").length>0){increase_count("#count_tmbo")}if(f!=""||c=="this is bad"||a!="0"){toggle_subscribe("subscribe",e,$("#subscribeLink"))}qc_form_reset();if(c=="this is good"||c=="this is bad"){greyout_voting()}})}function disable_voting(){$("#good").parent().find("a").removeAttr("href")}function greyout_voting(){$("#good").parent().removeClass("on").addClass("off");$("#qc_vote").remove()}function handle_vote(b,a){a.preventDefault();do_vote(b);return false}function increase_count(a){count=parseInt($(a).html())+1;$(a).html(count)} | ||
function qc_dialog_init(){function e(h){var k=$("#qc_comments"),i=$("#qc_commentrows"),j=$("#qc_form:visible");if(k.hasAttr("loading")){return}if(i.children().length==0){k.hide();if(j.length>0){h.dialog("option","title","first post!")}else{h.dialog("option","title","nothing to see here, move along")}}else{k.show();if(j.length>0){h.dialog("option","title","let's hear it");if(k.children("b").length==0){k.prepend("<b>the dorks who came before you said: </b>")}}else{h.dialog("option","title","the dorks who came before you said:")}}a(h)}function a(h){var i=h.find("#qc_commentrows");if($("#qc_form:visible").length>0){i.css("margin-top","")}else{i.css("margin-top","0px")}if(!h.dialog("isOpen")){return}if(h.hasAttr("modified")){b(h);return}if(i.filter(":visible").length>0&&i.children().length>0){if(h.children(":visible").first().is("#qc_comments")){h.height(i.get(0).scrollHeight)}else{h.height(i.position().top+i.get(0).scrollHeight)}if(h.height()>$(window).height()-150){h.height($(window).height()-150)}}else{h.height("")}h.dialog("option","position","center");b(h)}function b(i){var h=i.find("textarea#qc_comment");h.width(i.width()-(h.outerWidth(true)-h.width()));var j=i.find("#qc_commentrows:visible");if(j.children().length>0){if(i.children(":visible").first().is("#qc_comments")){j.height(i.height())}else{j.height(i.height()-j.position().top)}}}$("form#qc_form").on("submit",function(i){i.preventDefault();var h=$("#qc_dialog");vote=$("#qc_form input[name=vote]:checked").val();comment=$("#qc_comment").val();tmbo=$("#qc_tmbo").attr("checked")?"1":"0";repost=$("#qc_repost").attr("checked")?"1":"0";subscribe=$("#qc_subscribe").attr("checked")?"1":"0";h.dialog("close");handle_comment_post(comment,vote,tmbo,repost,subscribe);return false});$("#qc_commentrows").on("scroll",function(){self=$(this);if(self.scrollTop()>0){self.attr("scrollTop",self.scrollTop())}else{self.removeAttr("scrollTop")}return true});function d(i){var h=$(this);window.setTimeout(function(){if(h.getCaretPosition()!=undefined){h.attr("caret",h.getCaretPosition())}},0);return true}$("#qc_comment").on("keydown",d).on("click",d);function c(h){h.dialog("widget").fadeTo("fast",0.7);h.attr("modified","");$(window).off("clickoutside.qc")}function g(h){h.dialog("widget").fadeTo("fast",1);a(h);f(h)}function f(h){window.setTimeout(function(){h.dialog("widget").on("clickoutside.qc",function(){h.dialog("close");return true})},0)}return{autoOpen:false,title:"please stand by",width:"500px",minHeight:"50px",open:function(j,k){var h=$(this);var i=$("#qc_commentrows");if(i.hasAttr("scrollTop")){i.scrollTop(i.attr("scrollTop"))}var n=$("#qc_comment:visible");if(n.length>0){var m=n.hasAttr("caret")?n.attr("caret"):0;n.focus().setCaretPosition(m)}else{h.get(0).focus()}unbind_default_events();$(window).on("resize.qc",function(p,q){a(h);return true});f(h);$("body").on("keydown.qc",function(o){if(o.target!=this){return true}$(h.dialog("widget").data("events").keydown).each(function(p,q){q.handler(o)});return true});var l=$("#qc_comments");if(!l.hasAttr("loading")){$.ajax({type:"GET",url:"/offensive/ui/api.php/getcomments.html?fileid="+getURLParam("id"),dataType:"html",beforeSend:function(){if(l.filter(":visible").length==0){l.show()}l.attr("loading","");if(i.children().length==0){i.text("loading…");a(h)}},success:function(s){if($(s).filter("div#comments").length!=1){return}l.removeAttr("loading");var p=i.children().length;var q=h.height()>0&&i.scrollTop()>0&&i.scrollTop()==i.get(0).scrollHeight-i.height();if(p==0){i.text("")}var r=$(s).find("div.entry");if(r.length>0){if(p>0){i.children().remove()}i.append(r);if(p==0){$("#qc_form").css("padding-bottom","10px")}if(q){var o=Math.min(i.scrollTop()+i.height(),i.get(0).scrollHeight-i.height());i.animate({scrollTop:o},500)}}e(h)},complete:function(o,p){if(l.hasAttr("loading")){i.text("fuck. try again?");l.removeAttr("loading");a(h)}}})}},close:function(h,i){$("*").off(".qc");$(document).off(".qc");$(window).off(".qc");bind_default_events()},dragStart:function(h,i){c($(this))},dragStop:function(i,k){var h=$(this),j=h.dialog("widget");g(h);h.dialog("option","position",[j.offset().left,j.offset().top])},resizeStart:function(h,i){c($(this))},resize:function(h,i){b($(this))},resizeStop:function(h,i){g($(this))}}}function qc_form_reset(){$("#qc_form textarea").val("");$("#qc_comment").removeAttr("caret");$("#qc_tmbo").removeAttr("checked");$("#qc_repost").removeAttr("checked");$("#qc_subscribe").removeAttr("checked")}function bind_default_events(){$(document).on("keydown.default",handle_keypress);$("#quickcomment").focus();if(!$.browser.opera){$("#quickcomment").blur()}}function unbind_default_events(){$(document).off(".default")}function do_vote(a){if(!a.parent().hasClass("on")){return}$("#votelinks a").off();vote=a.attr("id");imageid=getURLParam("id");if(vote=="good"){handle_comment_post("","this is good","","0","0","0")}else{handle_comment_post("","this is bad","","0","0","0")}}function handle_comment_post(f,c,d,b,a){var e=getURLParam("id");if(f==undefined){f=""}if(c==undefined){c=""}if(d==undefined){d="0"}if(b==undefined){b="0"}if(a==undefined){a="0"}if(f==""&&(c=="novote"||c=="")&&d==0&&b==0&&a==0){return}if(c=="this is good"||c=="this is bad"){disable_voting()}$.post("/offensive/api.php/postcomment.php",{fileid:e,comment:f,vote:c,offensive:d,repost:b,subscribe:a},function(g){if(c=="this is good"){increase_count("#count_good")}else{if(c=="this is bad"){increase_count("#count_bad")}}if(f!=""){increase_count("#count_comment")}if(d!=0&&$("#count_tmbo").length>0){increase_count("#count_tmbo")}if(f!=""||c=="this is bad"||a!="0"){toggle_subscribe("subscribe",e,$("#subscribeLink"))}qc_form_reset();if(c=="this is good"||c=="this is bad"){greyout_voting()}})}function disable_voting(){$("#good").parent().find("a").removeAttr("href")}function greyout_voting(){$("#good").parent().removeClass("on").addClass("off");$("#qc_vote").remove()}function handle_vote(b,a){a.preventDefault();do_vote(b);return false}function increase_count(a){count=parseInt($(a).html())+1;$(a).html(count)} | ||
/*! from: https://github.com/numist/jslib/blob/master/irsz.js */ | ||
function image_dimensions(d,c){var f="max-width",e="max-height",g="px",h,b;d=$(d);if(d.length!=1||d.attr("src")==undefined){return}if(d.filter("["+f+"]["+e+"]").length==1){var i,a;h=d.attr(f);i=parseInt(h.endsWith(g)?h.substr(0,h.lastIndexOf(g)):h);b=d.attr(e);a=parseInt(b.endsWith(g)?b.substr(0,b.lastIndexOf(g)):b);c(i,a)}else{$("<img/>").attr("src",d.attr("src")).load(function(){h=this.width,b=this.height;d.attr(f,h+g).attr(e,b+g);c(h,b)})}}if(window!=top){top.location.href=window.location.href}function theimage(){return $(document).find("a#imageLink img").last()}$(document).ready(function(){$("#qc_dialog").show().dialog(qc_dialog_init());$("#votelinks a").on("click",function(c){return handle_vote($(this),c)});$("#subscribeLink").on("click",function(c){return handle_subscribe($(this),c,$("#good").attr("name"))});$("#unsubscribeLink").on("click",function(c){return handle_subscribe($(this),c,$("#good").attr("name"))});$("#quickcomment").on("click",function(c){$("#qc_dialog").dialog("open");c.preventDefault();return false});bind_default_events();$("#instruction_link a").on("click",function(){$("#instructions").toggle()});image_dimensions(theimage(),function(d,c){$("span#dimensions").append(", "+d+"x"+c+' <span id="scaled"></span>')});var b=$("body").height()-theimage().outerHeight(true);var a=$("div#content").outerWidth(true)-$("div#content").width();theimage().irsz({min_height:40,min_width:40,padding:[a,b],cursor_zoom_in:"url(/offensive/graphics/zoom_in.cur),default",cursor_zoom_out:"url(/offensive/graphics/zoom_out.cur),default"}).on("resize",function(){if($("span#scaled").length==0){return true}if(theimage().length==0){return true}var e=theimage();var c=e.width(),d=e.height();image_dimensions(e,function(f,g){if(f!=c||g!=d){$("span#scaled").text("(shown: "+c+"x"+d+")")}else{$("span#scaled").text("")}});return true}).resize()}); |