1 line
6.9 KiB
JavaScript
1 line
6.9 KiB
JavaScript
|
(function(b,a){b.cookie=function(m,c,e){if(typeof c!="undefined"){e=e||{};if(c===null){c="";e.expires=-1}var d="";if(e.expires&&(typeof e.expires=="number"||e.expires.toUTCString)){var h;if(typeof e.expires=="number"){h=new Date();h.setTime(h.getTime()+(e.expires*24*60*60*1000))}else{h=e.expires}d="; expires="+h.toUTCString()}var j=e.path?"; path="+(e.path):"";var l=e.domain?"; domain="+(e.domain):"";var o=e.secure?"; secure":"";document.cookie=[m,"=",encodeURIComponent(c),d,j,l,o].join("")}else{var n=null;if(document.cookie&&document.cookie!=""){var k=document.cookie.split(";");for(var f=0;f<k.length;f++){var g=b.trim(k[f]);if(g.substring(0,m.length+1)==(m+"=")){n=decodeURIComponent(g.substring(m.length+1));break}}}return n}}}(jQuery,window));(function(a){a.fn.center=function(){var b=this.css("position")==="fixed";this.css("top",(a(window).height()-this.height())/2+(b?0:a(window).scrollTop())+"px");this.css("left",(a(window).width()-this.width())/2+(b?0:a(window).scrollLeft())+"px");return this}}(jQuery));(function(a){a.fn.applyModelErrors=function(b,c){var d=this;if(b!==null){d.find(".error-summary").first().text(b).show()}a.each(c,function(f,e){var g=d.find("input[name='"+f+"']");if(g.length>1){g=a("#"+f)}if(g.length===1){if(g[0].localName==="INPUT"){g.addClass("input-validation-error")}a("<span/>").addClass("field-validation-error").append(a("<span/>").addClass("error-icon")).append(a("<span/>").text(e)).insertAfter(g)}});return this};a.fn.clearModelErrors=function(){this.find(".field-validation-error").remove().end().find(".input-validation-error").removeClass("input-validation-error").end().find(".error-summary").empty().hide();return this}}(jQuery));(function(e,c){var a="jquery.refresh.fragment";var d=function(){var g=c.location.href;var f=g.lastIndexOf("#");if(f>=0){if(f!==g.length-1){e.cookie(a,g.substring(f+1))}g=g.substring(0,f)}c.location.href=g};var b=function(){var f=e.cookie(a);if(f!==null){c.location.href+="#"+f;e.cookie(a,null)}};e(document).ready(b);e.refresh=d}(jQuery,window));(function(e,c,a){e.vgquotes=function(){var h=function(j,i){return function(k){if(typeof(k)==="undefined"||typeof(k.Error)==="undefined"||k.Error!==null){i.call(null,null);return}i.call(null,k.Data.records[0])}};return{parseDate:function(i){return new Date(parseInt(i.substr(6)))},formatDate:function(i){return i.getFullYear()+"-"+(i.getMonth()+1)+"-"+i.getDate()},parseAndFormatDate:function(i){return e.vgquotes.formatDate(e.vgquotes.parseDate(i))},ajaxErrorHandler:function(i){alert("An error occurred ("+i.status+")")},preload:function(i){e.each(i,function(){e("<img/>")[0].src=this})},loadingGif:"/media/images/loading.gif",getResourceById:function(j,i,k){i=i.toString();e.ajax("/api/"+j+"/"+i,{type:"GET",success:h(j,k),error:h(j,k)})},createDialog:function(i){e("body").append(e("<div/>").attr("id","modal-background")).append(i);i.center()},closeDialog:function(i){e("#modal-background").remove();i.remove()}}}();var b=function(){var h=function(){var i=e.trim(e("#search-query").val());if(i.length>0){c.location="/search/"+i}return false};e(document).ready(function(){e("#search-query").keypress(function(i){if(i.which===13){h()}});e("#search-submit").click(h)})};var g=function(){var h=false;e(".vote-for, .vote-against").live("click",function(){if(h){alert("Please wait for the current vote to process before voting again");return false}h=true;var l=e(this);var n=l.parents(".quote-container");var k=l.hasClass("vote-for")?1:0;var i=n.find("input.quote-id").val();var m=n.find(".quote-score");var j=m.text();e.ajax("/vote",{type:"POST",data:{QuoteId:i,Direction:k},beforeSend:function(){m.empty().append(e("<img/>").attr({src:e.vgquotes.loadingGif,title:"submitting your vote"+String.fromCharCode(8230)}))},success:function(o,p,q){if(o.Error!==null){c.alert(o.Error);return}j=o.Data.score;m.attr("title","+"+o.Data.upVotes+", -"+o.Data.downVotes);l.remove();if(k===1){if(n.find(".vote-against").length===0){e("<span/>").addClass("vote-against").attr("title","I hate this quote").text(String.fromCharCode(9660)).appendTo(n.find(".vote-container:last"))}}el
|