Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

link opens in new tab

  • Loading branch information...
commit e8c9f39058a71d989e5f69296c9b4a1c773062ff 1 parent d6e8930
@sukhada authored
Showing with 106 additions and 5 deletions.
  1. +94 −0 jquery.cookie.js
  2. +5 −5 reddit.js
  3. +7 −0 scrollsaver.min.js
View
94 jquery.cookie.js
@@ -0,0 +1,94 @@
+/*!
+ * jQuery Cookie Plugin v1.3.1
+ * https://github.com/carhartl/jquery-cookie
+ *
+ * Copyright 2013 Klaus Hartl
+ * Released under the MIT license
+ */
+(function (factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD. Register as anonymous module.
+ define(['jquery'], factory);
+ } else {
+ // Browser globals.
+ factory(jQuery);
+ }
+}(function ($) {
+
+ var pluses = /\+/g;
+
+ function raw(s) {
+ return s;
+ }
+
+ function decoded(s) {
+ return decodeURIComponent(s.replace(pluses, ' '));
+ }
+
+ function converted(s) {
+ if (s.indexOf('"') === 0) {
+ // This is a quoted cookie as according to RFC2068, unescape
+ s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
+ }
+ try {
+ return config.json ? JSON.parse(s) : s;
+ } catch(er) {}
+ }
+
+ var config = $.cookie = function (key, value, options) {
+
+ // write
+ if (value !== undefined) {
+ options = $.extend({}, config.defaults, options);
+
+ if (typeof options.expires === 'number') {
+ var days = options.expires, t = options.expires = new Date();
+ t.setDate(t.getDate() + days);
+ }
+
+ value = config.json ? JSON.stringify(value) : String(value);
+
+ return (document.cookie = [
+ config.raw ? key : encodeURIComponent(key),
+ '=',
+ config.raw ? value : encodeURIComponent(value),
+ options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
+ options.path ? '; path=' + options.path : '',
+ options.domain ? '; domain=' + options.domain : '',
+ options.secure ? '; secure' : ''
+ ].join(''));
+ }
+
+ // read
+ var decode = config.raw ? raw : decoded;
+ var cookies = document.cookie.split('; ');
+ var result = key ? undefined : {};
+ for (var i = 0, l = cookies.length; i < l; i++) {
+ var parts = cookies[i].split('=');
+ var name = decode(parts.shift());
+ var cookie = decode(parts.join('='));
+
+ if (key && key === name) {
+ result = converted(cookie);
+ break;
+ }
+
+ if (!key) {
+ result[name] = converted(cookie);
+ }
+ }
+
+ return result;
+ };
+
+ config.defaults = {};
+
+ $.removeCookie = function (key, options) {
+ if ($.cookie(key) !== undefined) {
+ $.cookie(key, '', $.extend(options, { expires: -1 }));
+ return true;
+ }
+ return false;
+ };
+
+}));
View
10 reddit.js
@@ -152,7 +152,7 @@ function frontPage(result) {
var img = result.data.children[i].data.title;
if (!result.data.children[i].data.over_18) {
$("#posts").append("<li><span class='upvotes'>" +result.data.children[i].data.ups+ "<span class='labelupvotes'>upvotes</span></span><a class='mainlink' href='" +
- result.data.children[i].data.url +"'><span class='title'>" + img + "</span></a><span class='author'>Submitted by <span class='color'>"
+ result.data.children[i].data.url +"' target='_blank'><span class='title'>" + img + "</span></a><span class='author'>Submitted by <span class='color'>"
+ result.data.children[i].data.author+ "</span></span> to <span class='subreddit'>" + result.data.children[i].data.subreddit+
" </span><span class='comments'><a href='http://www.reddit.com"+ result.data.children[i].data.permalink +"'>"+
result.data.children[i].data.num_comments + " comments</a></span></li>");
@@ -269,7 +269,7 @@ window.onload = function() {
}
}
-if ($(window).width > 704) {
+if ($(window).width() > 704) {
$("#open").on('mouseenter', function() {
clearTimeout(r);
$(".modal").removeClass("hide");
@@ -293,8 +293,6 @@ else {
$("#open").on('click', function() {
$(".modal").toggleClass("hide");
});
-
-
}
$(".close").click(function() {
@@ -380,8 +378,10 @@ $("#refresh").click(function() {
window.location.reload();
});
-$("#loadmore").click(function () {
+$("#loadmore").click(function (e) {
loadPosts();
+ e.preventDefault();
+ return false;
});
View
7 scrollsaver.min.js
@@ -0,0 +1,7 @@
+// scrollsaver.js
+// Copyright (C) 2009 M. Mahdi Hasheminezhad (hasheminezhad at gmail dot com)
+// Maintain scroll position of every element on postbacks and partial updates
+// This source is licensed under Common Public License Version 1.0 (CPL)
+// History:
+// 2009-08-21 First Public Release M. Mahdi Hasheminezhad (http://hasheminezhad.com)
+(function(){function ls(){var c=document.cookie.split(';');for(var i=0;i<c.length;i++){var p=c[i].split('=');if(p[0]=='scrollPosition'){p=unescape(p[1]).split('/');for(var j=0;j<p.length;j++){var e=p[j].split(',');try{if(e[0]=='window'){window.scrollTo(e[1],e[2]);}else if(e[0]){var o=document.getElementById(e[0]);o.scrollLeft=e[1];o.scrollTop=e[2];}}catch(ex){}}return;}}}function ss(){var s='scrollPosition=';var l,t;if(window.pageXOffset!==undefined){l=window.pageXOffset;t=window.pageYOffset;}else if(document.documentElement&&document.documentElement.scrollLeft!==undefined){l=document.documentElement.scrollLeft;t=document.documentElement.scrollTop;}else{l=document.body.scrollLeft;t=document.body.scrollTop;}if(l||t){s+='window,'+l+','+t+'/';}var es=(document.all)?document.all:document.getElementsByTagName('*');for(var i=0;i<es.length;i++){var e=es[i];if(e.id&&(e.scrollLeft||e.scrollTop)){s+=e.id+','+e.scrollLeft+','+e.scrollTop+'/';}}document.cookie=s+';';}var a,p;if(window.attachEvent){a=window.attachEvent;p='on';}else{a=window.addEventListener;p='';}a(p+'load',function(){ls();if(typeof Sys!='undefined'&&typeof Sys.WebForms!='undefined'){Sys.WebForms.PageRequestManager.getInstance().add_endRequest(ls);Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(ss);}},false);a(p+'unload',ss,false);})();
Please sign in to comment.
Something went wrong with that request. Please try again.