Advertisement
Gerst20051

HnS Social Script aC Undefined Problem

Aug 6th, 2011
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // THIS PROBLEM HAS BEEN RESOLVED (This code is also very outdated)
  2. // jsFiddle: http://jsfiddle.net/gerst20051/cpdFV/
  3. // Correct Indentation...: http://pastebin.com/RRq97J4r
  4. // Main URL: http://socialhns.comeze.com/
  5. // Username: guest
  6. // Password: guest
  7.  
  8. Array.prototype.clear=function(){this.splice(0,this.length)};
  9.  
  10. function main() {
  11. var aC = {
  12. title: "Social HnS",
  13. logged: false,
  14. loginFocus: false,
  15. registerFocus: false,
  16. currentPage: "login",
  17. profileID: 0,
  18. loadedLeft: [],
  19. loadedContent: [],
  20. loadedProfile: [],
  21. loadedRight: [],
  22. user: {},
  23. profileUser: {},
  24. newestUpdate: 0,
  25. oldestUpdate: 0,
  26. newerUpdates: 0,
  27. noMoreUpdates: false,
  28. timestamp: Date.now || function(){
  29.     return +new Date;
  30. },
  31. timestamp_sec: parseInt(Date.now / 1000) || function(){
  32.     return parseInt(+new Date / 1000);
  33. },
  34. stringToBoolean: function(string){
  35.         switch(string.toLowerCase()) {
  36.                 case "true": case "yes": case "1": return true;
  37.                 case "false": case "no": case "0": case null: return false;
  38.                 default: return false;
  39.         }
  40. },
  41. empty: function(mixed){
  42.     var key;
  43.     if (mixed === "" || mixed === 0 || mixed === "0" || mixed === null || mixed === false || typeof mixed === 'undefined') return true;
  44.     if (typeof mixed == 'object') {
  45.         for (key in mixed) return false;
  46.         return true;
  47.     }
  48.     return false;
  49. },
  50. addSlashes: function(str){
  51.     return (str + '').replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');
  52. },
  53. stripSlashes: function(str){
  54.     return (str + '').replace(/\\(.?)/g, function (s, n1) {
  55.         switch (n1) {
  56.             case '\\': return '\\';
  57.             case '0': return '\u0000';
  58.             case '': return '';
  59.             default: return n1;
  60.         }
  61.     });
  62. },
  63. setPage: function(name){
  64.     aC.currentPage = name;
  65. },
  66. setTitle: function(title,type){
  67.     if (!type) {
  68.         if (!title) document.title = aC.title;
  69.         else document.title = aC.title + " | " + title;
  70.     } else {
  71.         document.title = title;
  72.     }
  73. },
  74. setHash: function(hash){
  75.     if (!hash) window.location.replace("#");
  76.     else window.location.replace("#" + encodeURI(hash));
  77. },
  78. getHash: function(){
  79.     return decodeURIComponent(window.location.hash.substring(1));
  80. },
  81. init: function(){
  82.     $.get('ajax.php', {p:"logged"}, function(response) {
  83.         if (aC.stringToBoolean(response)) aC.logged = true;
  84.         if (!aC.logged) aC.loadModule('login');
  85.         else aC.loggedIn();
  86.     });
  87. },
  88. loadModule: function(module){
  89.     if (!arguments[1] || $.isFunction(arguments[1])) var target = "content";
  90.     else var target = arguments[1];
  91.     if (module == "login" && aC.logged) {
  92.         aC.loadedLeft.clear();
  93.         aC.loadedContent.clear();
  94.         aC.loadedProfile.clear();
  95.         aC.loadedRight.clear();
  96.         $("#left,#content,#right,#header").empty();
  97.     }
  98.     switch (target) {
  99.         case "left":
  100.             if ($.inArray(module,aC.loadedLeft) > -1) {
  101.                 $("#left").show().children().hide();
  102.                 $("#"+module).show();
  103.                 return;
  104.             }
  105.         break;
  106.         case "content":
  107.             if ($.inArray(module,aC.loadedContent) > -1) {
  108.                 $("#content").children().hide();
  109.                 $("#"+module).show();
  110.                 var profilePages = ['profile','about','photos','friends','posts','likes'];
  111.                 if ($.inArray(aC.currentPage,profilePages) == -1) {
  112.                     if ($("#right").is(":hidden")) aC.toggleModule('right');
  113.                 }
  114.                 return;
  115.             }
  116.         break;
  117.         case "profile":
  118.             if ($.inArray(module,aC.loadedProfile) > -1) {
  119.                 return;
  120.             }
  121.         break;
  122.         case "right":
  123.             if ($.inArray(module,aC.loadedRight) > -1) {
  124.                 $("#right").show().children().hide();
  125.                 $("#"+module).show();
  126.                 return;
  127.             }
  128.         break;
  129.     }
  130.     $.get('ajax.php', {p:module}, function(response) {
  131.         switch (target) {
  132.             case "left": aC.loadedLeft.push(module); $("#left").show().children().hide(); break;
  133.             case "content": aC.loadedContent.push(module); $("#content").children().hide(); break;
  134.             case "right": aC.loadedRight.push(module); $("#right").show().children().hide(); break;
  135.         }
  136.         $("#"+target).append(response);
  137.         if (aC.currentPage == "newsfeed") {
  138.             $(".loadingMostRecent,.loadingMore").hide();
  139.             $(".loadMore").css('display','block');
  140.         }
  141.         /*
  142.         if (arguments.length > 1) {
  143.             if ($.isFunction(arguments[arguments.length - 1])) {
  144.                 arguments[arguments.length - 1];
  145.             }
  146.         }
  147.         */
  148.     });
  149. },
  150. toggleModule: function(module,callback) {
  151.     if (module == "left") {
  152.         if ($("#left").is(":hidden")) {
  153.             $("#left").animate({width:200}, 600);
  154.             $("#body").animate({left:200}, 600);
  155.         } else {
  156.             $("#left").animate({width:0}, 400);
  157.             $("#body").animate({left:0}, 400);
  158.         }
  159.     } else if (module == "right") {
  160.         if ($("#right").is(":hidden")) {
  161.             $("#right").show();
  162.             $("#content").css('width',568);
  163.         } else {
  164.             $("#right").hide();
  165.             $("#content").css('width',778);
  166.         }
  167.     }
  168. },
  169. loggedIn: function(){
  170.     if (aC.logged) {
  171.         $.getJSON('ajax.php', {p:"userdata"}, function(response) {
  172.             aC.user = response;
  173.             if (aC.user.middlename != "") aC.user.fullname = aC.user.firstname+' '+aC.user.middlename+' '+aC.user.lastname;
  174.             else aC.user.fullname = aC.user.firstname+' '+aC.user.lastname;
  175.         });
  176.         if (aC.empty(aC.getHash())) {
  177.             $("#content").empty();
  178.             aC.setPage('newsfeed');
  179.             aC.loadModule('home_newsfeed');
  180.             aC.loadModule('home_leftcol','left');
  181.             aC.loadModule('home_rightcol','right');
  182.             aC.loadModule('header','header');
  183.             $("#left").animate({width:200}, 600);
  184.             $("#right").animate({width:210}, 600);
  185.             $("#body").animate({left:200}, 600, function(){ $("#doc").addClass("in").removeClass("out"); $('.updateNewsFeed').click(); });
  186.         } else {
  187.             // handle module loading
  188.             $("#content").empty();
  189.             aC.setPage('newsfeed');
  190.             aC.loadModule('home_newsfeed');
  191.             aC.loadModule('home_leftcol','left');
  192.             aC.loadModule('home_rightcol','right');
  193.             aC.loadModule('header','header');
  194.             $("#left").animate({width:200}, 600);
  195.             $("#right").animate({width:210}, 600);
  196.             $("#body").animate({left:200}, 600, function(){ $("#doc").addClass("in").removeClass("out"); $('.updateNewsFeed').click(); });
  197.         }
  198.         setInterval("aC.checkStreamUpdates()",30000);
  199.     }
  200. },
  201. login: function(){
  202.     var e = false,
  203.     username = $("#lusername"),
  204.     password = $("#lpassword");
  205.     if ($.trim(username.val()) == "") { username.addClass('error'); e = true; } else username.removeClass('error');
  206.     if ($.trim(password.val()) == "") { password.addClass('error'); e = true; } else password.removeClass('error');
  207.     if (!e) {
  208.         $('#f_login input').attr('disabled',true);
  209.         $.post("ajax.php", {login:true,username:$.trim(username.val()),password:secure('hns'+$.trim(password.val()))}, function(response) {
  210.             if (aC.stringToBoolean(response)) aC.logged = true;
  211.             if (!aC.logged) $('#f_login input').attr('disabled',false);
  212.             else aC.loggedIn();
  213.         });
  214.     }
  215. },
  216. logout: function(){
  217.     $.post('ajax.php', {logout:true}, function() {
  218.         $("#left,#right").animate({width:0}, 400, function(){ $("#left,#right").empty(); });
  219.         aC.setPage('login'); aC.setTitle(); aC.setHash(); aC.loadModule('login'); aC.logged = false;
  220.         $("#body").animate({left:0}, 400, function(){ $("#doc").addClass("out").removeClass("in"); });
  221.         aC.profileID = 0;
  222.         aC.loadedLeft.clear();
  223.         aC.loadedContent.clear();
  224.         aC.loadedProfile.clear();
  225.         aC.loadedRight.clear();
  226.         aC.user = {};
  227.         aC.profileUser = {};
  228.         aC.newestUpdate = 0;
  229.         aC.oldestUpdate = 0;
  230.         aC.newerUpdates = 0;
  231.         aC.noMoreUpdates = false;
  232.     });
  233. },
  234. regValidate: function(){
  235.     var e = false,
  236.     username = $("#reg_username"),
  237.     password = $("#reg_password"),
  238.     name = $("#reg_name"),
  239.     email = $("#reg_email"),
  240.     hometown = $("#reg_hometown"),
  241.     city = $("#reg_city"),
  242.     bmonth = $("#reg_bmonth"),
  243.     bday = $("#reg_bday"),
  244.     byear = $("#reg_byear"),
  245.     usernameReg = /\W/,
  246.     nameReg = /[A-Za-z'-]/,
  247.     emailReg = /^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}?$/i;
  248.  
  249.     if ($.trim(username.val()) == "") { username.addClass('error'); e = true; }
  250.     else if (usernameReg.test($.trim(username.val()))) { username.addClass('error'); e = true; }
  251.     else { aC.checkUsername($.trim(username.val())); if ($("#username").hasClass('error')) e = true; }
  252.     if ($.trim(password.val()) == "") { password.addClass('error'); e = true; } else password.removeClass('error');
  253.  
  254.     if ($.trim(name.val()) == "") { name.addClass('error'); e = true; }
  255.     else if (!nameReg.test($.trim(name.val()))) { name.addClass('error'); e = true; }
  256.     else if ($.trim(name.val()).split(' ').length < 2) { name.addClass('error'); e = true; } else name.removeClass('error');
  257.  
  258.     if ($.trim(email.val()) == "") { email.addClass('error'); e = true; }
  259.     else if (!emailReg.test($.trim(email.val()))) { email.addClass('error'); e = true; } else email.removeClass('error');
  260.  
  261.     if ($.trim(hometown.val()) == "") { hometown.addClass('error'); e = true; } else hometown.removeClass('error');
  262.     if (bmonth.val() == 0) { bmonth.addClass('error'); e = true; } else bmonth.removeClass('error');
  263.     if (bday.val() == 0) { bday.addClass('error'); e = true; } else bday.removeClass('error');
  264.     if (byear.val() == 0) { byear.addClass('error'); e = true; } else byear.removeClass('error');
  265.    
  266.     if (e) return false;
  267.     else return true;
  268. },
  269. checkUsername: function(uname){
  270.     if (uname != "") {
  271.         $.get('ajax.php', {p:"username",username:uname}, function(response) {
  272.             if (aC.stringToBoolean(response)) $("#reg_username").addClass('error');
  273.             else $("#reg_username").removeClass('error');
  274.         });
  275.     } else $("#reg_username").addClass('error');
  276. },
  277. onKeyDown: function(e){
  278.     var keyCode = e.keyCode || e.which;
  279.     if (aC.logged) {
  280.  
  281.     } else {
  282.         if (keyCode == 13) {
  283.             if (aC.loginFocus) $("#b_login_splash").click();
  284.             else if (aC.registerFocus) $("#b_register").click();
  285.         }
  286.     }
  287. },
  288. handleError: function(error){
  289.     return error;
  290. },
  291. addNewStatusUpdate: function(sid,status){
  292.     var datetime = new Date(), hours = datetime.getHours(), prefix = "AM", minutes = datetime.getMinutes(), seconds = datetime.getSeconds();
  293.     if (hours > 12) { hours = hours - 12; prefix = "PM"; }
  294.     if (minutes < 10) { minutes = '0'+minutes; }
  295.     if (seconds < 10) { seconds = '0'+seconds; }
  296.     var monthArray = ['January','February','March','April','May','June','July','August','September','October','November','December'];
  297.     var dayArray = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
  298.     var timesecs = hours + ":" + minutes + ":" + seconds + " " + prefix;
  299.     var title = dayArray[datetime.getDay()] + ", " + monthArray[datetime.getMonth()] + " " + datetime.getDay() + ", " + datetime.getFullYear() + " " + timesecs;
  300.     var time = hours + ":" + minutes + " " + prefix;
  301.     var s = '<li id="update-'+sid+'" style="display:none">';
  302.     s += '<div class="updateWrapper"><div class="updateTitle">';
  303.     s += '<a href="#" class="updateImageLink"><img class="updateImg" src="/uploads/'+aC.user.username+'/images/thumb/'+aC.user.default_image+'"/></a>';
  304.     s += '<div class="updateNameDate"><a href="#" class="updateNameLink">'+aC.user.fullname+'</a>';
  305.     s += '<span class="updateDate">&nbsp;&nbsp;-&nbsp;&nbsp;<a href="#" class="updateDateLink" target="_blank" title="'+title+'">'+time+'</a></span>';
  306.     s += '<span class="updateEdit">&nbsp;&nbsp;<a href="#" class="updateEditLink">Edit</a></span>';
  307.     s += '</div></div>';
  308.     s += '<div class="updateBody">'+aC.stripSlashes(status)+'</div>';
  309.     s += '<div class="updateAttachments"></div>';
  310.     s += '<div class="updateActions">';
  311.     s += '<ul class="streamActions">';
  312.     s += '<li class="updateLinks"><a href="#" class="updateLikeLink">Like</a>&nbsp;&nbsp;-&nbsp;&nbsp;<a href="#" class="updateCommentLink">Comment</a>&nbsp;&nbsp;-&nbsp;&nbsp;<a href="#" class="updateShareLink">Share</a></li>';
  313.     s += '<li class="updateLikes"></li>';
  314.     s += '<li class="updateShares"></li>';
  315.     s += '<li class="updateOlderComments clickable"></li>';
  316.     s += '<li class="updateComments"></li>';
  317.     s += '<li class="updateNewComments clickable"></li>';
  318.     s += '<li class="updateComment">';
  319.     s += '<div class="updateCommentBox">';
  320.     s += '<form class="f_updateComment" action="#" method="post" onsubmit="return false">';
  321.     s += '<div id="updateComposer"><div class="commentBox"><div class="wrap"><div class="innerWrap">';
  322.     s += '<textarea class="textarea" placeholder="Add a comment..." cols="30" rows="4"></textarea>';
  323.     s += '</div></div></div></div>';
  324.     s += '<div class="buttonTools cf"><ul class="toolList rfloat">';
  325.     s += '<li class="listItem"><label class="commentButton" for="comment"><input value="Add comment" type="submit" id="comment"/></label></li>';
  326.     s += '</ul></div></form></div></li></ul></div></div></li>';
  327.     return s;
  328. },
  329. addStatusUpdates: function(data,type){
  330.     var s = "";
  331.     $.each(data,function(i,v){
  332.         if (type == "new") {
  333.             if (i == 0) aC.newestUpdate = v.timestamp;
  334.             if (aC.oldestUpdate == 0 && i == data.length-1) aC.oldestUpdate = v.timestamp;
  335.         } else if (type == "old") {
  336.             if (i == data.length-1) aC.oldestUpdate = v.timestamp;
  337.         }
  338.         var datetime = new Date(parseInt(v.timestamp + '000')), hours = datetime.getHours(), prefix = "AM", minutes = datetime.getMinutes(), seconds = datetime.getSeconds();
  339.         if (hours > 12) { hours = hours - 12; prefix = "PM"; }
  340.         if (minutes < 10) { minutes = '0'+minutes; }
  341.         if (seconds < 10) { seconds = '0'+seconds; }
  342.         var monthArray = ['January','February','March','April','May','June','July','August','September','October','November','December'];
  343.         var dayArray = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
  344.         var timesecs = hours + ":" + minutes + ":" + seconds + " " + prefix;
  345.         var title = dayArray[datetime.getDay()] + ", " + monthArray[datetime.getMonth()] + " " + datetime.getDay() + ", " + datetime.getFullYear() + " " + timesecs;
  346.         var time = hours + ":" + minutes + " " + prefix;
  347.         if (v.default_image != "") var image = "/uploads/"+v.username+"/images/thumb/"+v.default_image;
  348.         else var image = "i/mem/default.jpg";
  349.         if (v.middlename != "") var fullname = v.firstname + " " + v.middlename + " " + v.lastname;
  350.         else var fullname = v.firstname + " " + v.lastname;
  351.         var likes = v.likes;
  352.         var shares = "";
  353.         var oldcomments = "";
  354.         var comments = "";
  355.         var newcomments = "";
  356.         var likesA = ""; if (v.likes > 0) likesA = " active";
  357.         var sharesA = ""; if (shares != "") sharesA = " active";
  358.         var oldcA = ""; if (oldcomments != "") oldcA = " active";
  359.         var cA = ""; if (comments != "") cA = " active";
  360.         var newcA = ""; if (newcomments != "") newcA = " active";
  361.         var ucA = ""; if (v.likes > 0 || shares != "" || oldcomments != "" || comments != "" || newcomments != "") ucA = " active";
  362.         s += '<li id="update-'+v.sid+'">';
  363.         s += '<div class="updateWrapper"><div class="updateTitle">';
  364.         s += '<a href="#" class="updateImageLink"><img class="updateImg" src="'+image+'"/></a>';
  365.         s += '<div class="updateNameDate"><a href="#" class="updateNameLink">'+fullname+'</a>';
  366.         s += '<span class="updateDate">&nbsp;&nbsp;-&nbsp;&nbsp;<a href="#" class="updateDateLink" target="_blank" title="'+title+'">'+time+'</a></span>';
  367.         if (v.sid == aC.user.user_id) s += '<span class="updateEdit">&nbsp;&nbsp;<a href="#" class="updateEditLink">Edit</a></span>';
  368.         s += '</div></div>';
  369.         s += '<div class="updateBody">'+aC.stripSlashes(v.data)+'</div>';
  370.         s += '<div class="updateAttachments"></div>';
  371.         s += '<div class="updateActions">';
  372.         s += '<ul class="streamActions">';
  373.         s += '<li class="updateLinks"><a href="#" class="updateLikeLink">Like</a>&nbsp;&nbsp;-&nbsp;&nbsp;<a href="#" class="updateCommentLink">Comment</a>&nbsp;&nbsp;-&nbsp;&nbsp;<a href="#" class="updateShareLink">Share</a></li>';
  374.         s += '<li class="updateLikes'+likesA+'"><a href="#" class="updateLikesLink">'+v.likes+' likes</a> by '+likes+' others</li>';
  375.         s += '<li class="updateShares'+sharesA+'"><a href="#" class="updateSharesLink">'+shares+' shares</a> - '+shares+'</li>';
  376.         s += '<li class="updateOlderComments clickable'+oldcA+'"><a href="#" class="updateOlderCommentsLink">'+oldcomments+' older comments</a> from '+oldcomments+'</li>';
  377.         s += '<li class="updateComments'+cA+'"><ul class="streamComments"><li>'+comments+'</li></ul></li>';
  378.         s += '<li class="updateNewComments clickable'+newcA+'"><a href="#" class="updateNewCommentsLink">'+newcomments+' more comments</a> from '+newcomments+'</li>';
  379.         s += '<li class="updateComment'+ucA+'">';
  380.         s += '<div class="updateCommentBox">';
  381.         s += '<form class="f_updateComment" action="#" method="post" onsubmit="return false">';
  382.         s += '<div id="updateComposer"><div class="commentBox"><div class="wrap"><div class="innerWrap">';
  383.         s += '<textarea class="textarea" placeholder="Add a comment..." cols="30" rows="4"></textarea>';
  384.         s += '</div></div></div></div>';
  385.         s += '<div class="buttonTools cf"><ul class="toolList rfloat">';
  386.         s += '<li class="listItem"><label class="commentButton" for="comment"><input value="Add comment" type="submit" id="comment"/></label></li>';
  387.         s += '</ul></div></form></div></li></ul></div></div></li>';
  388.     });
  389.     return s;
  390. },
  391. addNewComment: function(cid,comment){
  392.     var datetime = new Date(), hours = datetime.getHours(), prefix = "AM", minutes = datetime.getMinutes(), seconds = datetime.getSeconds();
  393.     if (hours > 12) { hours = hours - 12; prefix = "PM"; }
  394.     if (minutes < 10) { minutes = '0'+minutes; }
  395.     if (seconds < 10) { seconds = '0'+seconds; }
  396.     var monthArray = ['January','February','March','April','May','June','July','August','September','October','November','December'];
  397.     var dayArray = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
  398.     var timesecs = hours + ":" + minutes + ":" + seconds + " " + prefix;
  399.     var title = dayArray[datetime.getDay()] + ", " + monthArray[datetime.getMonth()] + " " + datetime.getDay() + ", " + datetime.getFullYear() + " " + timesecs;
  400.     var time = hours + ":" + minutes + " " + prefix;
  401.     var c = '<li id="comment-'+cid+'">';
  402.     c += '<div class="commentWrapper">';
  403.     c += '<div class="commentContent">';
  404.     c += '<a href="#" class="commentImageLink"><img class="commentImg" src="/uploads/'+aC.user.username+'/images/thumb/'+aC.user.default_image+'"/></a>';
  405.     c += '<div class="commentNameBody">';
  406.     c += '<a href="#" class="commentNameLink">'+aC.user.fullname+'</a> - <span class="commentBody">'+comment+'</span>';
  407.     c += '</div>';
  408.     c += '<span class="expandComment"><a href="#" class="expandCommentLink">Expand this comment &#187;</a></span>';
  409.     c += '<span class="collapseComment"><a href="#" class="collapseCommentLink">Collapse this comment</a></span>';
  410.     c += '<div class="commentTimeTools">';
  411.     c += '<span class="commentTime" title="'+title+'">'+time+'</span></span>&nbsp;&nbsp;';
  412.     c += '<span class="commentTools"><a href="#" class="commentLikeLink">Like</a></span>';
  413.     c += '</div>';
  414.     c += '</div>';
  415.     c += '</div>';
  416.     c += '</li>';
  417. },
  418. addComments: function(cid,timestamp,comment,image,name){
  419.     var datetime = new Date(timestamp), hours = datetime.getHours(), prefix = "AM", minutes = datetime.getMinutes(), seconds = datetime.getSeconds();
  420.     if (hours > 12) { hours = hours - 12; prefix = "PM"; }
  421.     if (minutes < 10) { minutes = '0'+minutes; }
  422.     if (seconds < 10) { seconds = '0'+seconds; }
  423.     var monthArray = ['January','February','March','April','May','June','July','August','September','October','November','December'];
  424.     var dayArray = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
  425.     var timesecs = hours + ":" + minutes + ":" + seconds + " " + prefix;
  426.     var title = dayArray[datetime.getDay()] + ", " + monthArray[datetime.getMonth()] + " " + datetime.getDay() + ", " + datetime.getFullYear() + " " + timesecs;
  427.     var time = hours + ":" + minutes + " " + prefix;
  428.     var c = '<li id="comment-'+cid+'">';
  429.     c += '<div class="commentWrapper">';
  430.     c += '<div class="commentContent">';
  431.     c += '<a href="#" class="commentImageLink"><img class="commentImg" src="/uploads/Andrew/images/thumb/IMG_1271.JPG"/></a>';
  432.     c += '<div class="commentNameBody">';
  433.     c += '<a href="#" class="commentNameLink">Phillip Tunstall</a> - <span class="commentBody">Watch "Ghost in the Shell" to be better prepared...</span>';
  434.     c += '</div>';
  435.     c += '<span class="expandComment"><a href="#" class="expandCommentLink">Expand this comment &#187;</a></span>';
  436.     c += '<span class="collapseComment"><a href="#" class="collapseCommentLink">Collapse this comment</a></span>';
  437.     c += '<div class="commentTimeTools">';
  438.     c += '<span class="commentTime" title="Jul 28, 2011 9:13:25 AM">9:13 AM</span></span>&nbsp;&nbsp;';
  439.     c += '<span class="commentTools"><a href="#" class="commentLikeLink">Like</a></span>';
  440.     c += '</div>';
  441.     c += '</div>';
  442.     c += '</div>';
  443.     c += '</li>';
  444. },
  445. bbCode: function(text){
  446.     return true;
  447. },
  448. checkStreamUpdates: function(){ alert(aC.newestUpdate);
  449.     $.getJSON('ajax.php', {p:"stream",newest:aC.newestUpdate}, function(response) {
  450.         if (response != "0") {
  451.             var newerUpdates = response["data"].length;
  452.             aC.newerUpdates = newerUpdates;
  453.             $(".mostRecentCount").find(".mostRecentCountValue").html(newerUpdates).end().show();
  454.             $("ul.sideNav #newsFeedLink .sideNavCount").find(".countValue").html(newerUpdates).end().show();
  455.         }
  456.     });
  457. }
  458. };
  459.  
  460. $(document.documentElement).keydown(aC.onKeyDown);
  461. $(document).ready(function(){ aC.init();
  462. $(".homeLink").live('click',function(){
  463.     if (aC.logged) {
  464.         if (aC.currentPage != "newsfeed") {
  465.             aC.setPage('newsfeed'); aC.setHash(); aC.setTitle();
  466.             aC.loadModule('home_newsfeed');
  467.             aC.loadModule('home_leftcol','left');
  468.             aC.loadModule('home_rightcol','right');
  469.             $("#newsFeedLink").click();
  470.         }
  471.     } else {
  472.         aC.setPage('login'); aC.setTitle();
  473.         aC.loadModule('login');
  474.     }
  475. });
  476. $("#lusername, #lpassword").live('focus',function(){
  477.     aC.loginFocus = true;
  478. }).live('blur',function(){
  479.     aC.loginFocus = false;
  480. });
  481. $("#b_login_splash").live('click',function(){
  482.     aC.login();
  483. });
  484. $("#b_register_splash").live('click',function(){
  485.     aC.loadModule('register'); aC.setTitle('Register');
  486. });
  487. $("#reg_username, #reg_password, #reg_name, #reg_email, #reg_hometown, #reg_city").live('focus',function(){
  488.     aC.registerFocus = true;
  489. }).live('blur',function(){
  490.     aC.registerFocus = false;
  491. });
  492. $("#reg_username").live('blur',function(){
  493.     aC.checkUsername($.trim(this.value));
  494. });
  495. $("#b_register").live('click',function(){
  496.     if (!aC.regValidate()) return;
  497.     $('#f_register input,#f_register select').attr('disabled',true);
  498.     $.post("ajax.php", {register:true,username:$.trim($("#username").val()),password:$.trim($("#password").val()),name:$.trim($("#name").val()),email:$.trim($("#email").val()),hometown:$.trim($("#hometown").val()),city:$.trim($("#city").val()),gender:$.trim($("#gender").val()),bmonth:$("#bmonth").val(),bday:$("#bday").val(),byear:$("#byear").val()}, function() {
  499.         alert("registered");
  500.     });
  501. });
  502. $("#b_login").live('click',function(){
  503.     aC.setPage('login'); aC.setTitle();
  504.     aC.loadModule('login');
  505. });
  506. $("#headerLogoutLink").live('click',function(){
  507.     aC.logout();
  508. });
  509. $(".welcome_image,.welcome_name,.profileLink").live('click',function(){
  510.     if (aC.currentPage != "profile") {
  511.         aC.setPage('profile'); aC.setHash('profile'); aC.setTitle(aC.user.fullname,true);
  512.         aC.toggleModule('right');
  513.         aC.loadModule('profile');
  514.         aC.loadModule('profile_leftcol','left');
  515.         $("#wallLink").click();
  516.     }
  517. });
  518. $(".welcome_editlink").live('click',function(){
  519.     if (aC.currentPage != "edit") {
  520.         aC.setPage('edit');
  521.         aC.loadModule('edit');
  522.     }
  523. });
  524. $(".sideNavItem").live('click',function(){
  525.     if (!$(this).hasClass('selectedItem')) {
  526.         $(".sideNav").children().removeClass("selectedItem");
  527.         $(this).addClass("selectedItem");
  528.     }
  529. });
  530. $("#newsFeedLink").live('click',function(){
  531.     if (aC.currentPage != "newsfeed") {
  532.         aC.setPage('newsfeed');
  533.         aC.loadModule('home_newsfeed');
  534.     }
  535. });
  536. $("#messagesLink").live('click',function(){
  537.     if (aC.currentPage != "messages") {
  538.         aC.setPage('messages');
  539.         aC.loadModule('messages');
  540.     }
  541. });
  542. $("#friendsLink").live('click',function(){
  543.     if (aC.currentPage != "profile") {
  544.         aC.setPage('profile'); aC.setHash('profile'); aC.setTitle(aC.user.fullname,true);
  545.         aC.toggleModule('right');
  546.         aC.loadModule('profile');
  547.         aC.loadModule('profile_leftcol','left');
  548.         $("#friendsLink").click();
  549.     }
  550. });
  551. $("#wallLink").live('click',function(){
  552.     if (aC.currentPage != "profile") {
  553.         aC.setPage('profile');
  554.         aC.loadModule('profile');
  555.     }
  556. });
  557. $("#infoLink").live('click',function(){
  558.     if (aC.currentPage != "about") {
  559.         aC.setPage('about');
  560.         aC.loadModule('about');
  561.     }
  562. });
  563. $("#photosLink").live('click',function(){
  564.     if (aC.currentPage != "photos") {
  565.         aC.setPage('photos');
  566.         aC.loadModule('photos');
  567.     }
  568. });
  569. $(".updateStatus .textarea").live('focus',function(){
  570.     $(this).css('max-height',400);
  571.     $(".updateStatus .buttonTools").show();
  572. }).live('blur',function(){
  573.     if ($(this).val() == "") {
  574.         $(this).css('max-height',16);
  575.         $(".updateStatus .buttonTools").hide();
  576.     }
  577. });
  578. $("#share").live('click',function(){
  579.     if ($.trim($(".updateStatus .textarea").val()).length > 0) {
  580.         $.post("ajax.php", {p:"status",data:$.trim($(".updateStatus .textarea").val())}, function(response) {
  581.             if (response != "0") {
  582.                 response = $.parseJSON(response);
  583.                 if (aC.newerUpdates > 0) $(".updateNewsFeed").click();
  584.                 else aC.newestUpdate = aC.timestamp_sec;
  585.                 var s = aC.addNewStatusUpdate(response["data"].insertid,response["data"].status);
  586.                 $(".updateStatus .textarea").val('').blur();
  587.                 $("ul#stream").prepend(s).find("li.active").prev().addClass("borderActive").end().find("li:first").fadeIn();
  588.             }
  589.         });
  590.     }
  591. });
  592. $("ul#stream > li").live('click',function(){
  593.     $("ul#stream > li").removeClass('active borderActive');
  594.     $(this).addClass('active').prev().addClass('borderActive')
  595.     $(this).next().addClass('borderActive');
  596. });
  597. $(".updateComment .textarea").live('focus',function(){
  598.     $(this).css('max-height',300);
  599.     $(".updateComment .buttonTools").show();
  600. }).live('blur',function(){
  601.     if ($(this).val() == "") {
  602.         $(this).css('max-height',16);
  603.         $(".updateComment .buttonTools").hide();
  604.     }
  605. });
  606. $("#comment").live('click',function(){
  607.     if ($.trim($(".updateComment .textarea").val()).length > 0) {
  608.         $.post("ajax.php", {p:"comment",data:$.trim($(".updateComment .textarea").val())}, function(response) {
  609.             if (response != "0") {
  610.                 var c = aC.addNewComment(response,$.trim($(".updateComment .textarea").val()));
  611.                 $(".updateComment .textarea").val('').blur();
  612.                 alert($(this).closest("ul#streamActions").children("ul#streamComments").html());
  613.                 $(this).closest("ul#streamActions").children("ul#streamComments").append(c);
  614.                 $(this).parents().find("ul#streamActions").children().find("ul#streamComments li:last").fadeIn();
  615.             }
  616.         });
  617.     }
  618. });
  619. $(".updateNewsFeed").live('click',function(){
  620.     $(".mostRecentCount").hide().find(".mostRecentCountValue").empty();
  621.     $("ul.sideNav #newsFeedLink .sideNavCount").hide().find(".countValue").empty();
  622.     aC.newerUpdates = 0;
  623.     $(".loadingMostRecent").css('display','block');
  624.     $.getJSON('ajax.php', {p:"stream",newest:aC.newestUpdate}, function(response) {
  625.         if (response != "0") {
  626.             var s = aC.addStatusUpdates(response["data"],"new");
  627.             $("ul#stream").prepend(s).find("li.active").prev().addClass("borderActive");
  628.         }
  629.         $(".loadingMostRecent").hide();
  630.        
  631.     });
  632. });
  633. $(".loadMore").live('click',function(){
  634.     $(this).hide();
  635.     $(".loadingMore").css('display','block');
  636.     $.getJSON('ajax.php', {p:"stream",oldest:aC.oldestUpdate}, function(response) {
  637.         if (response != "0") {
  638.             var s = aC.addStatusUpdates(response["data"],"old");
  639.             $("ul#stream").append(s);
  640.         } else {
  641.             if (!aC.noMoreUpdates) {
  642.                 $("ul#stream").append('<div class="noMoreUpdates">No More Updates Available!</div>');
  643.                 aC.noMoreUpdates = true;
  644.                 $(".loadMoreLink").hide();
  645.             }
  646.         }
  647.         $(".loadingMore").hide();
  648.         $(".loadMore").show();
  649.     });
  650. });
  651. });
  652.  
  653. return true;
  654. }
  655.  
  656. window.$ && main() || (function() {
  657.     var jquery = document.createElement("script");
  658.     jquery.setAttribute("type","text/javascript");
  659.     jquery.setAttribute("src","jquery.js");
  660.     jquery.onload = main;
  661.     jquery.onreadystatechange = function() {
  662.         if (this.readyState == "complete" || this.readyState == "loaded") main();
  663.     };
  664.     (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(jquery);
  665. })();
  666.  
  667. window.log = function() {
  668.     log.history = log.history || [];
  669.     log.history.push(arguments);
  670.     if (this.console) console.log(Array.prototype.slice.call(arguments));
  671. };
  672.  
  673. function encode(a){if(a===null||typeof a==="undefined"){return""}var b=(a+'');var c="",start,end,stringl=0;start=end=0;stringl=b.length;for(var n=0;n<stringl;n++){var d=b.charCodeAt(n);var e=null;if(d<128){end++}else if(d>127&&d<2048){e=String.fromCharCode((d>>6)|192)+String.fromCharCode((d&63)|128)}else{e=String.fromCharCode((d>>12)|224)+String.fromCharCode(((d>>6)&63)|128)+String.fromCharCode((d&63)|128)}if(e!==null){if(end>start){c+=b.slice(start,end)}c+=e;start=end=n+1}}if(end>start){c+=b.slice(start,stringl)}return c}
  674. function secure(a){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var c,o2,o3,h1,h2,h3,h4,bits,i=0,ac=0,enc="",tmp_arr=[];if(!a){return a}a=this.encode(a+'');do{c=a.charCodeAt(i++);o2=a.charCodeAt(i++);o3=a.charCodeAt(i++);bits=c<<16|o2<<8|o3;h1=bits>>18&0x3f;h2=bits>>12&0x3f;h3=bits>>6&0x3f;h4=bits&0x3f;tmp_arr[ac++]=b.charAt(h1)+b.charAt(h2)+b.charAt(h3)+b.charAt(h4)}while(i<a.length);enc=tmp_arr.join('');switch(a.length%3){case 1:enc=enc.slice(0,-2)+'==';break;case 2:enc=enc.slice(0,-1)+'=';break}return enc}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement