Browse files

added line endings

ready for compression
  • Loading branch information...
1 parent 845b3b5 commit 1f792ad1832ac61784737b7608316c4caaa16c79 @mattclegg committed Feb 3, 2012
Showing with 96 additions and 96 deletions.
  1. +96 −96 magic.js
View
192 magic.js
@@ -12,34 +12,34 @@ function init () {
$(".post_thumb").click(function () {
var id = $(this).attr("id").replace("thumb_","")
window.location = "#"+id
- })
+ });
//
$("#search_field").keydown(function (e) {
if (e_.which == 13) {
$("#search_field").submit()
}
- })
- $("#loading").fadeTo(n_speed, 0)
+ });
+ $("#loading").fadeTo(n_speed, 0);
if ($.cookie("view") == null) {
- view = default_format
- $.cookie("view", view)
+ view = default_format;
+ $.cookie("view", view);
} else {
- view = $.cookie("view")
- default_format = view
+ view = $.cookie("view");
+ default_format = view;
}
if (is_index) {
if (view == "grid") {
- $(".grid").removeClass("hide")
- $("#view_options").html("<li><a href=\"#list\" id=\"show_list_link\" class=\"rounded\">Display as list.</a></li>")
- $("#show_list_link").click(show_list)
- getPhotosetImages()
+ $(".grid").removeClass("hide");
+ $("#view_options").html("<li><a href=\"#list\" id=\"show_list_link\" class=\"rounded\">Display as list.</a></li>");
+ $("#show_list_link").click(show_list);
+ getPhotosetImages();
getVideoThumbs();
} else {
- $("#entry").addClass("hide")
- $(".line").addClass("hide")
- $(".list").removeClass("hide")
- $("#view_options").html("<li><a href=\"#grid\" class=\"rounded\" id=\"show_grid_link\">Display as grid.</a></li>")
- $("#show_grid_link").click(show_grid)
+ $("#entry").addClass("hide");
+ $(".line").addClass("hide");
+ $(".list").removeClass("hide");
+ $("#view_options").html("<li><a href=\"#grid\" class=\"rounded\" id=\"show_grid_link\">Display as grid.</a></li>");
+ $("#show_grid_link").click(show_grid);
$(window).scroll(check_for_more);
}
SWFAddress.addEventListener(SWFAddressEvent.CHANGE, history);
@@ -50,10 +50,10 @@ function init () {
}
if (!$("body").hasClass("index") && !$("body").hasClass("perma")) {
- $("#pages").removeClass("hide")
+ $("#pages").removeClass("hide");
}
- add_credit()
+ add_credit();
}
//
function history(hash) {
@@ -62,29 +62,29 @@ function history(hash) {
//
}else if (id == "about") {
if (view == "list") {
- show_grid()
+ show_grid();
} else {
- $(".line").removeClass("hide")
- $("#entry").removeClass("hide")
- $("#entry").html(""+$("#about").html())
+ $(".line").removeClass("hide");
+ $("#entry").removeClass("hide");
+ $("#entry").html(""+$("#about").html());
}
}else if (id == "following") {
if (view == "list") {
- show_grid()
+ show_grid();
} else {
- $(".line").removeClass("hide")
- $("#entry").removeClass("hide")
- $("#entry").html(""+$("#following").html())
+ $(".line").removeClass("hide");
+ $("#entry").removeClass("hide");
+ $("#entry").html(""+$("#following").html());
}
}else if (id == "search") {
if (view == "list") {
- show_grid()
+ show_grid();
} else {
- $(".line").removeClass("hide")
- $("#entry").removeClass("hide")
- $("#entry").html(""+$("#search").html())
+ $(".line").removeClass("hide");
+ $("#entry").removeClass("hide");
+ $("#entry").html(""+$("#search").html());
}
- } else {
+ } else {
// in certain scenarios (IE/Windows?) we get the hash with a leading '/' - strip it off
// thanks to Brian Long — http://newobj.net/
@@ -93,63 +93,63 @@ function history(hash) {
id = id.substring(1, id.length);
}
- goto_post(id)
- }
+ goto_post(id);
+ }
}
//
function goto_post(id) {
if (view == "list") {
- show_grid()
+ show_grid();
}
- $("#thumb_"+id+" .loading").fadeTo(0, 0)
- $("#thumb_"+id+" .loading").removeClass("hide")
- $("#thumb_"+id+" .loading").fadeTo(n_speed, 1)
+ $("#thumb_"+id+" .loading").fadeTo(0, 0);
+ $("#thumb_"+id+" .loading").removeClass("hide");
+ $("#thumb_"+id+" .loading").fadeTo(n_speed, 1);
//$("#entry").fadeTo(n_speed, .1)
$("html body").animate({
scrollTop:0
- }, n_speed)
+ }, n_speed);
var src = "/post/"+id+"/"
if ($("#entry").hasClass("hide")) {
- $("#entry").removeClass("hide")
+ $("#entry").removeClass("hide");
}
if ($(".line").hasClass("hide")) {
- $(".line").removeClass("hide")
- }
- $("#entry").html($("#"+id).html())
- $("#entry").fadeTo(0, 0)
+ $(".line").removeClass("hide");
+ }
+ $("#entry").html($("#"+id).html());
+ $("#entry").fadeTo(0, 0);
if ($("#entry").hasClass("hide")) {
- $("#entry").removeClass("hide")
+ $("#entry").removeClass("hide");
}
- $("#entry").fadeTo(200, 1)
+ $("#entry").fadeTo(200, 1);
$(".post_thumb").each(function () {
if ($(this).attr("id") == "thumb_"+id) {
if (!$(this).hasClass("selected")) {
- $(this).addClass("selected")
+ $(this).addClass("selected");
}
} else {
if ($(this).hasClass("selected")) {
- $(this).removeClass("selected")
+ $(this).removeClass("selected");
}
}
- })
+ });
return false
}
//
function show_list() {
$.cookie("view", null);
- $.cookie("view", "list")
- SWFAddress.setValue("")
+ $.cookie("view", "list");
+ SWFAddress.setValue("");
setTimeout("window.location.reload()", 10);
- return false
-}
+ return false;
+}
//
function show_grid() {
$.cookie("view", null);
- $.cookie("view", "grid")
+ $.cookie("view", "grid");
setTimeout("window.location.reload()", 10);
- return false
+ return false;
}
-//
+//
function getVideoThumbs() {
$(".list .video").each(function () {
var embedCode;
@@ -169,7 +169,7 @@ function getVideoThumbs() {
$("#post_" + ID).addClass("tumblr-video");
var frameR = /poster=(http.+?_frame1.jpg)/g;
var frame = decodeURIComponent(String(frameR.exec(embedCode)[1]));
- $("#thumb_" + ID + " .video").prepend("<div class=\"bg rounded\" style=\"background-image:url('" + frame + "');\"></div>")
+ $("#thumb_" + ID + " .video").prepend("<div class=\"bg rounded\" style=\"background-image:url('" + frame + "');\"></div>");
} else {
if (embedCode.indexOf("iframe") >= 0) {
@@ -180,94 +180,94 @@ function getVideoThumbs() {
vimeo_ID = String(rID.exec(embedCode)).replace("/video/", "").replace("\"", "");
$.getJSON("http://vimeo.com/api/clip/" + vimeo_ID + ".json?callback=?", function (d) {
var thumb_url = d[0].thumbnail_large;
- $("#thumb_" + ID + " .video").prepend("<div class=\"bg rounded\" style=\"background-image:url('" + thumb_url + "');\"></div>");
- });
+ $("#thumb_" + ID + " .video").prepend("<div class=\"bg rounded\" style=\"background-image:url('" + thumb_url + "');\"></div>");
+ });
}
} else {
- var swf = ""
- var id = $(this).parent().parent().attr("id")
+ var swf = "";
+ var id = $(this).parent().parent().attr("id");
$(this).children("object").children("param").each(function () {
if ($(this).attr("name") == "movie") {
- swf = $(this).attr("value")
+ swf = $(this).attr("value");
}
- })
- if (swf.indexOf("youtube.com") >= 0) {
+ });
+ if (swf.indexOf("youtube.com") >= 0) {
// get youtube thumb
- swf = swf.replace("http://www.youtube.com")
- swf = swf.replace("http://youtube.com")
- var youtube_id = swf.substring(swf.indexOf("/v/")+3, swf.indexOf("&"))
- var thumb_url = "http://i.ytimg.com/vi/"+youtube_id+"/0.jpg"
- $("#thumb_"+id+" .video").prepend("<div class=\"bg rounded\" style=\"background-image:url('"+thumb_url+"');\"></div>")
+ swf = swf.replace("http://www.youtube.com");
+ swf = swf.replace("http://youtube.com");
+ var youtube_id = swf.substring(swf.indexOf("/v/")+3, swf.indexOf("&"));
+ var thumb_url = "http://i.ytimg.com/vi/"+youtube_id+"/0.jpg";
+ $("#thumb_"+id+" .video").prepend("<div class=\"bg rounded\" style=\"background-image:url('"+thumb_url+"');\"></div>");
}else if (swf.indexOf("vimeo.com") >= 0) {
// get vimeo json, then thumb (SO ANNOYING!)
- swf = swf.replace("http://vimeo.com/moogaloop.swf?")
- swf = swf.replace("http://www.vimeo.com/moogaloop.swf?")
+ swf = swf.replace("http://vimeo.com/moogaloop.swf?");
+ swf = swf.replace("http://www.vimeo.com/moogaloop.swf?");
var vimeo_id = swf.substring(swf.indexOf("clip_id=")+8, swf.indexOf("&"));
$.getJSON("http://vimeo.com/api/clip/"+vimeo_id+".json?callback=?", function (d) {
- var thumb_url = d[0].thumbnail_large
- $("#thumb_"+id+" .video").prepend("<div class=\"bg rounded\" style=\"background-image:url('"+thumb_url+"');\"></div>")
- })
+ var thumb_url = d[0].thumbnail_large;
+ $("#thumb_"+id+" .video").prepend("<div class=\"bg rounded\" style=\"background-image:url('"+thumb_url+"');\"></div>");
+ });
}
- }
+ }
}
})
-}
+}
//
function getPhotosetImages() {
$(".post_thumb .photoset").each(function () {
var ID = $(this).parent().attr("id").replace("thumb_", "")
$.getJSON("/api/read/json?id="+ID+"&callback=?", {}, function (D) {
var photos = D["posts"][0]["photos"]
for(var i = 0; i<photos.length; i++) {
- var thumb = photos[i]["photo-url-250"]
- $("#thumb_"+ID+" .photoset .thumbs").append("<div class=\"thumb rounded\" style=\"background-image:url('"+thumb+"')\"></div>")
+ var thumb = photos[i]["photo-url-250"];
+ $("#thumb_"+ID+" .photoset .thumbs").append("<div class=\"thumb rounded\" style=\"background-image:url('"+thumb+"')\"></div>");
}
})
- })
+ });
}
//
function check_for_more() {
if (view == "list") {
var yPos = window.pageYOffset;
- var h = $(document).height()
- var wH = $(window).height()
+ var h = $(document).height();
+ var wH = $(window).height();
//$("#debug").text(yPos+" / "+h)
if ((yPos/(h-wH)) >= .8 && !is_loading_next && next_page != "no") {
//alert("we're trying to load the next shit.")
- is_loading_next = true
- $("html body").append("<div id=\"temp\" class=\"hide\"></div>")
- $(".list").append("<div id=\"next_"+current_page+"\"><div class=\"post_preloader\">loading next page...</div></div>")
+ is_loading_next = true;
+ $("html body").append("<div id=\"temp\" class=\"hide\"></div>");
+ $(".list").append("<div id=\"next_"+current_page+"\"><div class=\"post_preloader\">loading next page...</div></div>");
$("#temp").load(next_page, {}, function (d) {
- $(".post_preloader").remove()
+ $(".post_preloader").remove();
var content = $(d).children("#main_column .list").html()
- $("#next_"+current_page).html(content)
+ $("#next_"+current_page).html(content);
var n_p = $(d).children("#info .next_page").text()
if (n_p != "") {
next_page = n_p;
} else {
- next_page = "no"
+ next_page = "no";
}
- setTimeout(can_check_for_more_now, 2000)
- })
+ setTimeout(can_check_for_more_now, 2000);
+ });
}
}
}
//
function can_check_for_more_now() {
- $(".post_preloader").remove()
- current_page++
- is_loading_next = false
+ $(".post_preloader").remove();
+ current_page++;
+ is_loading_next = false;
}
-//
+//
function format_notes() {
$(".avatar").each(function () {
- $(this).parent().remove()
- })
+ $(this).parent().remove();
+ });
}
//
function add_credit() {
$("html body").append("<div id=\"credit\"><a href=\"http://cargotheme.tumblr.com\">Cargo Theme</a> by <a href=\"http://jarredbishop.tumblr.com\">Jarred Bishop</a>. Inspired by <a href=\"http://cargocollective.com\">Cargo</a></div>")
-}
+}
-$(document).ready(init)
+$(document).ready(init);
//$(document).load(loaded)

0 comments on commit 1f792ad

Please sign in to comment.