]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Fixed regression from util.js updates + syntax cleanup
authorMikael Nordfeldth <mmn@hethane.se>
Tue, 10 Sep 2013 13:14:42 +0000 (15:14 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Tue, 10 Sep 2013 13:14:42 +0000 (15:14 +0200)
We introduced a regression in 6fa9062d28713e81d508854fa232ce65a8a59319
based on syntax error, as a curly brace ({) was lost. This is now fixed.

js/util.js
js/util.min.js

index a7adb803d3e40e049284339f61828c3053834f4c..ae9a67dbb36dad6d8a10130c6b775374882565ed 100644 (file)
@@ -54,7 +54,7 @@ var SN = { // StatusNet
             NoticeDataGeo: 'notice_data-geo',
             NoticeDataGeoCookie: 'NoticeDataGeo',
             NoticeDataGeoSelected: 'notice_data-geo_selected',
-            StatusNetInstance:'StatusNetInstance'
+            StatusNetInstance: 'StatusNetInstance'
         }
     },
 
@@ -77,12 +77,11 @@ var SN = { // StatusNet
      * @param {String} key: string key name to pull from message index
      * @return matching localized message string
      */
-    msg: function(key) {
-        if (typeof SN.messages[key] == "undefined") {
+    msg: function (key) {
+        if (SN.messages[key] === undefined) {
             return '[' + key + ']';
-        } else {
-            return SN.messages[key];
         }
+        return SN.messages[key];
     },
 
     U: { // Utils
@@ -94,36 +93,35 @@ var SN = { // StatusNet
          * @param {jQuery} form: jQuery object whose first matching element is the form
          * @access private
          */
-        FormNoticeEnhancements: function(form) {
+        FormNoticeEnhancements: function (form) {
             if (jQuery.data(form[0], 'ElementData') === undefined) {
-                MaxLength = form.find('.count').text();
-                if (typeof(MaxLength) == 'undefined') {
-                     MaxLength = SN.C.I.MaxLength;
+                var MaxLength = form.find('.count').text();
+                if (MaxLength === undefined) {
+                    MaxLength = SN.C.I.MaxLength;
                 }
-                jQuery.data(form[0], 'ElementData', {MaxLength:MaxLength});
+                jQuery.data(form[0], 'ElementData', {MaxLength: MaxLength});
 
                 SN.U.Counter(form);
 
-                NDT = form.find('.notice_data-text:first');
+                var NDT = form.find('.notice_data-text:first');
 
-                NDT.on('keyup', function(e) {
+                NDT.on('keyup', function (e) {
                     SN.U.Counter(form);
                 });
 
-                var delayedUpdate= function(e) {
+                var delayedUpdate = function (e) {
                     // Cut and paste events fire *before* the operation,
                     // so we need to trigger an update in a little bit.
                     // This would be so much easier if the 'change' event
                     // actually fired every time the value changed. :P
-                    window.setTimeout(function() {
+                    window.setTimeout(function () {
                         SN.U.Counter(form);
                     }, 50);
                 };
                 // Note there's still no event for mouse-triggered 'delete'.
                 NDT.on('cut', delayedUpdate)
-                   .on('paste', delayedUpdate);
-            }
-            else {
+                    .on('paste', delayedUpdate);
+            } else {
                 form.find('.count').text(jQuery.data(form[0], 'ElementData').MaxLength);
             }
         },
@@ -142,7 +140,7 @@ var SN = { // StatusNet
          * @param {jQuery} form: jQuery object whose first element is the notice posting form
          * @access private
          */
-        Counter: function(form) {
+        Counter: function (form) {
             SN.C.I.FormNoticeCurrent = form;
 
             var MaxLength = jQuery.data(form[0], 'ElementData').MaxLength;
@@ -182,7 +180,7 @@ var SN = { // StatusNet
          * @param {jQuery} form: jQuery object whose first element is the notice posting form
          * @return number of chars
          */
-        CharacterCount: function(form) {
+        CharacterCount: function (form) {
             return form.find('.notice_data-text:first').val().length;
         },
 
@@ -193,7 +191,7 @@ var SN = { // StatusNet
          * @param {jQuery} form: jQuery object whose first element is the notice posting form
          * @access private
          */
-        ClearCounterBlackout: function(form) {
+        ClearCounterBlackout: function (form) {
             // Allow keyup events to poke the counter again
             SN.C.I.CounterBlackout = false;
             // Check if the string changed since we last looked
@@ -211,13 +209,12 @@ var SN = { // StatusNet
          * @param {String} url
          * @return string
          */
-        RewriteAjaxAction: function(url) {
+        RewriteAjaxAction: function (url) {
             // Quick hack: rewrite AJAX submits to HTTPS if they'd fail otherwise.
-            if (document.location.protocol == 'https:' && url.substr(0, 5) == 'http:') {
+            if (document.location.protocol === 'https:' && url.substr(0, 5) === 'http:') {
                 return url.replace(/^http:\/\/[^:\/]+/, 'https://' + document.location.host);
-            } else {
-                return url;
             }
+            return url;
         },
 
         /**
@@ -240,13 +237,13 @@ var SN = { // StatusNet
          *
          * @access public
          */
-        FormXHR: function(form, onSuccess) {
+        FormXHR: function (form, onSuccess) {
             $.ajax({
                 type: 'POST',
                 dataType: 'xml',
                 url: SN.U.RewriteAjaxAction(form.attr('action')),
                 data: form.serialize() + '&ajax=1',
-                beforeSend: function(xhr) {
+                beforeSend: function (xhr) {
                     form
                         .addClass(SN.C.S.Processing)
                         .find('.submit')
@@ -261,7 +258,7 @@ var SN = { // StatusNet
                     if (xhr.responseXML) {
                         errorReported = $('#error', xhr.responseXML).text();
                     }
-                    alert(errorReported || errorThrown || textStatus);
+                    window.alert(errorReported || errorThrown || textStatus);
 
                     // Restore the form to original state.
                     // Hopefully. :D
@@ -271,22 +268,20 @@ var SN = { // StatusNet
                             .removeClass(SN.C.S.Disabled)
                             .prop(SN.C.S.Disabled, false);
                 },
-                success: function(data, textStatus) {
-                    if (typeof($('form', data)[0]) != 'undefined') {
-                        form_new = document._importNode($('form', data)[0], true);
+                success: function (data, textStatus) {
+                    if ($('form', data)[0] !== undefined) {
+                        var form_new = document._importNode($('form', data)[0], true);
                         form.replaceWith(form_new);
                         if (onSuccess) {
                             onSuccess();
                         }
-                    }
-                    else if (typeof($('p', data)[0]) != 'undefined') {
+                    } else if ($('p', data)[0] !== undefined) {
                         form.replaceWith(document._importNode($('p', data)[0], true));
                         if (onSuccess) {
                             onSuccess();
                         }
-                    }
-                    else {
-                        alert('Unknown error.');
+                    } else {
+                        window.alert('Unknown error.');
                     }
                 }
             });
@@ -319,7 +314,7 @@ var SN = { // StatusNet
          *
          * @access public
          */
-        FormNoticeXHR: function(form) {
+        FormNoticeXHR: function (form) {
             SN.C.I.NoticeDataGeo = {};
             form.append('<input type="hidden" name="ajax" value="1"/>');
 
@@ -333,7 +328,7 @@ var SN = { // StatusNet
              * @param {String} text
              * @access private
              */
-            var showFeedback = function(cls, text) {
+            var showFeedback = function (cls, text) {
                 form.append(
                     $('<p class="form_response"></p>')
                         .addClass(cls)
@@ -344,14 +339,14 @@ var SN = { // StatusNet
             /**
              * Hide the previous response feedback, if any.
              */
-            var removeFeedback = function() {
+            var removeFeedback = function () {
                 form.find('.form_response').remove();
             };
 
             form.ajaxForm({
                 dataType: 'xml',
                 timeout: '60000',
-                beforeSend: function(formData) {
+                beforeSend: function (formData) {
                     if (form.find('.notice_data-text:first').val() == '') {
                         form.addClass(SN.C.S.Warning);
                         return false;
@@ -376,43 +371,38 @@ var SN = { // StatusNet
                     if (textStatus == 'timeout') {
                         // @fixme i18n
                         showFeedback('error', 'Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.');
-                    }
-                    else {
+                    } else {
                         var response = SN.U.GetResponseXML(xhr);
-                        if ($('.'+SN.C.S.Error, response).length > 0) {
-                            form.append(document._importNode($('.'+SN.C.S.Error, response)[0], true));
-                        }
-                        else {
+                        if ($('.' + SN.C.S.Error, response).length > 0) {
+                            form.append(document._importNode($('.' + SN.C.S.Error, response)[0], true));
+                        } else {
                             if (parseInt(xhr.status) === 0 || jQuery.inArray(parseInt(xhr.status), SN.C.I.HTTP20x30x) >= 0) {
                                 form
                                     .resetForm()
                                     .find('.attach-status').remove();
                                 SN.U.FormNoticeEnhancements(form);
-                            }
-                            else {
+                            } else {
                                 // @fixme i18n
-                                showFeedback('error', '(Sorry! We had trouble sending your notice ('+xhr.status+' '+xhr.statusText+'). Please report the problem to the site administrator if this happens again.');
+                                showFeedback('error', '(Sorry! We had trouble sending your notice (' + xhr.status + ' ' + xhr.statusText + '). Please report the problem to the site administrator if this happens again.');
                             }
                         }
                     }
                 },
-                success: function(data, textStatus) {
+                success: function (data, textStatus) {
                     removeFeedback();
-                    var errorResult = $('#'+SN.C.S.Error, data);
+                    var errorResult = $('#' + SN.C.S.Error, data);
                     if (errorResult.length > 0) {
                         showFeedback('error', errorResult.text());
-                    }
-                    else {
-                        if($('body')[0].id == 'bookmarklet') {
+                    } else {
+                        if ($('body')[0].id == 'bookmarklet') {
                             // @fixme self is not referenced anywhere?
                             self.close();
                         }
 
-                        var commandResult = $('#'+SN.C.S.CommandResult, data);
+                        var commandResult = $('#' + SN.C.S.CommandResult, data);
                         if (commandResult.length > 0) {
                             showFeedback('success', commandResult.text());
-                        }
-                        else {
+                        } else {
                             // New notice post was successful. If on our timeline, show it!
                             var notice = document._importNode($('li', data)[0], true);
                             var notices = $('#notices_primary .notices:first');
@@ -425,33 +415,30 @@ var SN = { // StatusNet
                                 replyItem.remove();
 
                                 var id = $(notice).attr('id');
-                                if ($("#"+id).length == 0) {
+                                if ($('#' + id).length == 0) {
                                     $(notice).insertBefore(placeholder);
-                                } else {
-                                    // Realtime came through before us...
-                                }
+                                } // else Realtime came through before us...
 
                                 // ...and show the placeholder form.
                                 placeholder.show();
                             } else if (notices.length > 0 && SN.U.belongsOnTimeline(notice)) {
                                 // Not a reply. If on our timeline, show it at the top!
 
-                                if ($('#'+notice.id).length === 0) {
+                                if ($('#' + notice.id).length === 0) {
                                     var notice_irt_value = form.find('[name=inreplyto]').val();
-                                    var notice_irt = '#notices_primary #notice-'+notice_irt_value;
-                                    if($('body')[0].id == 'conversation') {
-                                        if(notice_irt_value.length > 0 && $(notice_irt+' .notices').length < 1) {
+                                    var notice_irt = '#notices_primary #notice-' + notice_irt_value;
+                                    if ($('body')[0].id == 'conversation') {
+                                        if (notice_irt_value.length > 0 && $(notice_irt + ' .notices').length < 1) {
                                             $(notice_irt).append('<ul class="notices"></ul>');
                                         }
-                                        $($(notice_irt+' .notices')[0]).append(notice);
-                                    }
-                                    else {
+                                        $($(notice_irt + ' .notices')[0]).append(notice);
+                                    } else {
                                         notices.prepend(notice);
                                     }
-                                    $('#'+notice.id)
-                                        .css({display:'none'})
+                                    $('#' + notice.id)
+                                        .css({display: 'none'})
                                         .fadeIn(2500);
-                                    SN.U.NoticeWithAttachment($('#'+notice.id));
+                                    SN.U.NoticeWithAttachment($('#' + notice.id));
                                     SN.U.switchInputFormTab("placeholder");
                                 }
                             } else {
@@ -467,7 +454,7 @@ var SN = { // StatusNet
                         SN.U.FormNoticeEnhancements(form);
                     }
                 },
-                complete: function(xhr, textStatus) {
+                complete: function (xhr, textStatus) {
                     form
                         .removeClass(SN.C.S.Processing)
                         .find('.submit')
@@ -483,13 +470,13 @@ var SN = { // StatusNet
             });
         },
 
-        FormProfileSearchXHR: function(form) {
+        FormProfileSearchXHR: function (form) {
             $.ajax({
                 type: 'POST',
                 dataType: 'xml',
                 url: form.attr('action'),
                 data: form.serialize() + '&ajax=1',
-                beforeSend: function(xhr) {
+                beforeSend: function (xhr) {
                     form
                         .addClass(SN.C.S.Processing)
                         .find('.submit')
@@ -497,15 +484,14 @@ var SN = { // StatusNet
                             .prop(SN.C.S.Disabled, true);
                 },
                 error: function (xhr, textStatus, errorThrown) {
-                    alert(errorThrown || textStatus);
+                    window.alert(errorThrown || textStatus);
                 },
-                success: function(data, textStatus) {
+                success: function (data, textStatus) {
                     var results_placeholder = $('#profile_search_results');
-                    if (typeof($('ul', data)[0]) != 'undefined') {
+                    if ($('ul', data)[0] !== undefined) {
                         var list = document._importNode($('ul', data)[0], true);
                         results_placeholder.replaceWith(list);
-                    }
-                    else {
+                    } else {
                         var _error = $('<li/>').append(document._importNode($('p', data)[0], true));
                         results_placeholder.html(_error);
                     }
@@ -518,24 +504,24 @@ var SN = { // StatusNet
             });
         },
 
-        FormPeopletagsXHR: function(form) {
+        FormPeopletagsXHR: function (form) {
             $.ajax({
                 type: 'POST',
                 dataType: 'xml',
                 url: form.attr('action'),
                 data: form.serialize() + '&ajax=1',
-                beforeSend: function(xhr) {
+                beforeSend: function (xhr) {
                     form.find('.submit')
                             .addClass(SN.C.S.Processing)
                             .addClass(SN.C.S.Disabled)
                             .prop(SN.C.S.Disabled, true);
                 },
                 error: function (xhr, textStatus, errorThrown) {
-                    alert(errorThrown || textStatus);
+                    window.alert(errorThrown || textStatus);
                 },
-                success: function(data, textStatus) {
+                success: function (data, textStatus) {
                     var results_placeholder = form.parents('.entity_tags');
-                    if (typeof($('.entity_tags', data)[0]) != 'undefined') {
+                    if ($('.entity_tags', data)[0] !== undefined) {
                         var tags = document._importNode($('.entity_tags', data)[0], true);
                         $(tags).find('.editable').append($('<button class="peopletags_edit_button"/>'));
                         results_placeholder.replaceWith(tags);
@@ -551,7 +537,7 @@ var SN = { // StatusNet
             });
         },
 
-        normalizeGeoData: function(form) {
+        normalizeGeoData: function (form) {
             SN.C.I.NoticeDataGeo.NLat = form.find('[name=lat]').val();
             SN.C.I.NoticeDataGeo.NLon = form.find('[name=lon]').val();
             SN.C.I.NoticeDataGeo.NLNS = form.find('[name=location_ns]').val();
@@ -574,8 +560,7 @@ var SN = { // StatusNet
             }
             if (cookieValue == 'disabled') {
                 SN.C.I.NoticeDataGeo.NDG = form.find('[name=notice_data-geo]').prop('checked', false).prop('checked');
-            }
-            else {
+            } else {
                 SN.C.I.NoticeDataGeo.NDG = form.find('[name=notice_data-geo]').prop('checked', true).prop('checked');
             }
 
@@ -591,7 +576,7 @@ var SN = { // StatusNet
          * @param {XMLHTTPRequest} xhr
          * @return DOMDocument
          */
-        GetResponseXML: function(xhr) {
+        GetResponseXML: function (xhr) {
             try {
                 return xhr.responseXML;
             } catch (e) {
@@ -612,8 +597,8 @@ var SN = { // StatusNet
          *
          * @access private
          */
-        NoticeReply: function() {
-            $(document).on('click', '#content .notice_reply', function(e) {
+        NoticeReply: function () {
+            $(document).on('click', '#content .notice_reply', function (e) {
                 e.preventDefault();
                 var notice = $(this).closest('li.notice');
                 SN.U.NoticeInlineReplyTrigger(notice);
@@ -625,7 +610,7 @@ var SN = { // StatusNet
          * Stub -- kept for compat with plugins for now.
          * @access private
          */
-        NoticeReplyTo: function(notice) {
+        NoticeReplyTo: function (notice) {
         },
 
         /**
@@ -634,27 +619,28 @@ var SN = { // StatusNet
          * @param {jQuery} notice: jQuery object containing one notice
          * @param {String} initialText
          */
-        NoticeInlineReplyTrigger: function(notice, initialText) {
+        NoticeInlineReplyTrigger: function (notice, initialText) {
             // Find the notice we're replying to...
             var id = $($('.notice_id', notice)[0]).text();
+            var replyForm, placeholder;
             var parentNotice = notice;
             var stripForm = true; // strip a couple things out of reply forms that are inline
 
             // Find the threaded replies view we'll be adding to...
             var list = notice.closest('.notices');
             if (list.closest('.old-school').length) {
-               // We're replying to an old-school conversation thread;
-               // use the old-style ping into the top form.
-               SN.U.switchInputFormTab("status")
-               replyForm = $('#input_form_status').find('form');
-               stripForm = false;
+                // We're replying to an old-school conversation thread;
+                // use the old-style ping into the top form.
+                SN.U.switchInputFormTab("status");
+                replyForm = $('#input_form_status').find('form');
+                stripForm = false;
             } else if (list.hasClass('threaded-replies')) {
                 // We're replying to a reply; use reply form on the end of this list.
                 // We'll add our form at the end of this; grab the root notice.
                 parentNotice = list.closest('.notice');
 
-                       // See if the form's already open...
-                       var replyForm = $('.notice-reply-form', list);
+                // See if the form's already open...
+                replyForm = $('.notice-reply-form', list);
             } else {
                 // We're replying to a parent notice; pull its threaded list
                 // and we'll add on the end of it. Will add if needed.
@@ -663,26 +649,26 @@ var SN = { // StatusNet
                     SN.U.NoticeInlineReplyPlaceholder(notice);
                     list = $('ul.threaded-replies', notice);
                 } else {
-                    var placeholder = $('li.notice-reply-placeholder', notice);
+                    placeholder = $('li.notice-reply-placeholder', notice);
                     if (placeholder.length == 0) {
                         SN.U.NoticeInlineReplyPlaceholder(notice);
                     }
                 }
 
-                       // See if the form's already open...
-                       var replyForm = $('.notice-reply-form', list);
+                // See if the form's already open...
+                replyForm = $('.notice-reply-form', list);
             }
 
-            var nextStep = function() {
+            var nextStep = function () {
                 // Override...?
                 replyForm.find('input[name=inreplyto]').val(id);
                 if (stripForm) {
-                       // Don't do this for old-school reply form, as they don't come back!
-                       replyForm.find('#notice_to').prop('disabled', true).hide();
-                   replyForm.find('#notice_private').prop('disabled', true).hide();
-                   replyForm.find('label[for=notice_to]').hide();
-                   replyForm.find('label[for=notice_private]').hide();
-               }
+                    // Don't do this for old-school reply form, as they don't come back!
+                    replyForm.find('#notice_to').prop('disabled', true).hide();
+                    replyForm.find('#notice_private').prop('disabled', true).hide();
+                    replyForm.find('label[for=notice_to]').hide();
+                    replyForm.find('label[for=notice_private]').hide();
+                }
 
                 // Set focus...
                 var text = replyForm.find('textarea');
@@ -693,12 +679,12 @@ var SN = { // StatusNet
                 if (initialText) {
                     replyto = initialText + ' ';
                 }
-                text.val(replyto + text.val().replace(RegExp(replyto, 'i'), ''));
-                text.data('initialText', $.trim(initialText + ''));
+                text.val(replyto + text.val().replace(new RegExp(replyto, 'i'), ''));
+                text.data('initialText', $.trim(initialText));
                 text.focus();
                 if (text[0].setSelectionRange) {
                     var len = text.val().length;
-                    text[0].setSelectionRange(len,len);
+                    text[0].setSelectionRange(len, len);
                 }
             };
             if (replyForm.length > 0) {
@@ -706,19 +692,20 @@ var SN = { // StatusNet
                 nextStep();
             } else {
                 // Hide the placeholder...
-                var placeholder = list.find('li.notice-reply-placeholder').hide();
+                placeholder = list.find('li.notice-reply-placeholder').hide();
 
                 // Create the reply form entry at the end
                 var replyItem = $('li.notice-reply', list);
                 if (replyItem.length == 0) {
                     replyItem = $('<li class="notice-reply"></li>');
 
-                    var intermediateStep = function(formMaster) {
+                    var intermediateStep = function (formMaster) {
                         var formEl = document._importNode(formMaster, true);
                         replyItem.append(formEl);
                         list.append(replyItem); // *after* the placeholder
 
-                        var form = replyForm = $(formEl);
+                        var form = $(formEl);
+                        replyForm = form;
                         SN.Init.NoticeFormSetup(form);
 
                         nextStep();
@@ -732,7 +719,7 @@ var SN = { // StatusNet
                         // Warning: this can have a delay, which looks bad.
                         // @fixme this fallback may or may not work
                         var url = $('#form_notice').attr('action');
-                        $.get(url, {ajax: 1}, function(data, textStatus, xhr) {
+                        $.get(url, {ajax: 1}, function (data, textStatus, xhr) {
                             intermediateStep($('form', data)[0]);
                         });
                     }
@@ -740,7 +727,7 @@ var SN = { // StatusNet
             }
         },
 
-        NoticeInlineReplyPlaceholder: function(notice) {
+        NoticeInlineReplyPlaceholder: function (notice) {
             var list = notice.find('ul.threaded-replies');
             if (list.length == 0) {
                 list = $('<ul class="notices threaded-replies xoxo"></ul>');
@@ -761,18 +748,18 @@ var SN = { // StatusNet
          * Sets up event handlers for inline reply mini-form placeholders.
          * Uses 'on' rather than 'live' or 'bind', so applies to future as well as present items.
          */
-        NoticeInlineReplySetup: function() {
+        NoticeInlineReplySetup: function () {
             $('li.notice-reply-placeholder input')
-                .on('focus', function() {
+                .on('focus', function () {
                     var notice = $(this).closest('li.notice');
                     SN.U.NoticeInlineReplyTrigger(notice);
                     return false;
                 });
             $('li.notice-reply-comments a')
-                .on('click', function() {
+                .on('click', function () {
                     var url = $(this).attr('href');
                     var area = $(this).closest('.threaded-replies');
-                    $.get(url, {ajax: 1}, function(data, textStatus, xhr) {
+                    $.get(url, {ajax: 1}, function (data, textStatus, xhr) {
                         var replies = $('.threaded-replies', data);
                         if (replies.length) {
                             area.replaceWith(document._importNode(replies[0], true));
@@ -791,8 +778,8 @@ var SN = { // StatusNet
          * Uses 'on' rather than 'live' or 'bind', so applies to future as well as present items.
          *
          */
-        NoticeRepeat: function() {
-            $('.form_repeat').on('click', function(e) {
+        NoticeRepeat: function () {
+            $('.form_repeat').on('click', function (e) {
                 e.preventDefault();
 
                 SN.U.NoticeRepeatConfirmation($(this));
@@ -816,7 +803,7 @@ var SN = { // StatusNet
          *
          * @param {jQuery} form
          */
-        NoticeRepeatConfirmation: function(form) {
+        NoticeRepeatConfirmation: function (form) {
             var submit_i = form.find('.submit');
 
             var submit = submit_i.clone();
@@ -824,7 +811,7 @@ var SN = { // StatusNet
                 .addClass('submit_dialogbox')
                 .removeClass('submit');
             form.append(submit);
-            submit.on('click', function() { SN.U.FormXHR(form); return false; });
+            submit.on('click', function () { SN.U.FormXHR(form); return false; });
 
             submit_i.hide();
 
@@ -834,7 +821,7 @@ var SN = { // StatusNet
                 .closest('.notice-options')
                     .addClass('opaque');
 
-            form.find('button.close').click(function(){
+            form.find('button.close').click(function () {
                 $(this).remove();
 
                 form
@@ -855,8 +842,8 @@ var SN = { // StatusNet
          * Goes through all notices currently displayed and sets up attachment
          * handling if needed.
          */
-        NoticeAttachments: function() {
-            $('.notice a.attachment').each(function() {
+        NoticeAttachments: function () {
+            $('.notice a.attachment').each(function () {
                 SN.U.NoticeWithAttachment($(this).closest('.notice'));
             });
         },
@@ -871,17 +858,17 @@ var SN = { // StatusNet
          *
          * @param {jQuery} notice
          */
-        NoticeWithAttachment: function(notice) {
+        NoticeWithAttachment: function (notice) {
             if (notice.find('.attachment').length === 0) {
                 return;
             }
 
             var attachment_more = notice.find('.attachment.more');
             if (attachment_more.length > 0) {
-                $(attachment_more[0]).click(function() {
+                $(attachment_more[0]).click(function () {
                     var m = $(this);
                     m.addClass(SN.C.S.Processing);
-                    $.get(m.attr('href')+'/ajax', null, function(data) {
+                    $.get(m.attr('href') + '/ajax', null, function (data) {
                         m.parent('.entry-content').html($(data).find('#attachment_view .entry-content').html());
                     });
 
@@ -903,9 +890,10 @@ var SN = { // StatusNet
          *
          * @param {jQuery} form
          */
-        NoticeDataAttach: function(form) {
+        NoticeDataAttach: function (form) {
+            var i;
             var NDA = form.find('input[type=file]');
-            NDA.change(function(event) {
+            NDA.change(function (event) {
                 form.find('.attach-status').remove();
 
                 var filename = $(this).val();
@@ -914,9 +902,9 @@ var SN = { // StatusNet
                     return false;
                 }
 
-                var attachStatus = $('<div class="attach-status '+SN.C.S.Success+'"><code></code> <button class="close">&#215;</button></div>');
+                var attachStatus = $('<div class="attach-status ' + SN.C.S.Success + '"><code></code> <button class="close">&#215;</button></div>');
                 attachStatus.find('code').text(filename);
-                attachStatus.find('button').click(function(){
+                attachStatus.find('button').click(function () {
                     attachStatus.remove();
                     NDA.val('');
 
@@ -924,9 +912,9 @@ var SN = { // StatusNet
                 });
                 form.append(attachStatus);
 
-                if (typeof this.files == "object") {
+                if (typeof this.files === "object") {
                     // Some newer browsers will let us fetch the files for preview.
-                    for (var i = 0; i < this.files.length; i++) {
+                    for (i = 0; i < this.files.length; i++) {
                         SN.U.PreviewAttach(form, this.files[i]);
                     }
                 }
@@ -940,13 +928,12 @@ var SN = { // StatusNet
          * @param {jQuery} form
          * @return int max size in bytes; 0 or negative means no limit
          */
-        maxFileSize: function(form) {
+        maxFileSize: function (form) {
             var max = $(form).find('input[name=MAX_FILE_SIZE]').attr('value');
             if (max) {
                 return parseInt(max);
-            } else {
-                return 0;
             }
+            return 0;
         },
 
         /**
@@ -970,12 +957,12 @@ var SN = { // StatusNet
          * @todo detect pixel size?
          * @todo should we render a thumbnail to a canvas and then use the smaller image?
          */
-        PreviewAttach: function(form, file) {
+        PreviewAttach: function (form, file) {
             var tooltip = file.type + ' ' + Math.round(file.size / 1024) + 'KB';
             var preview = true;
 
             var blobAsDataURL;
-            if (typeof window.createObjectURL != "undefined") {
+            if (window.createObjectURL !== undefined) {
                 /**
                  * createObjectURL lets us reference the file directly from an <img>
                  * This produces a compact URL with an opaque reference to the file,
@@ -986,10 +973,10 @@ var SN = { // StatusNet
                  * - Safari 5.0.2: no
                  * - Chrome 8.0.552.210: works!
                  */
-                blobAsDataURL = function(blob, callback) {
+                blobAsDataURL = function (blob, callback) {
                     callback(window.createObjectURL(blob));
-                }
-            } else if (typeof window.FileReader != "undefined") {
+                };
+            } else if (window.FileReader !== undefined) {
                 /**
                  * FileAPI's FileReader can build a data URL from a blob's contents,
                  * but it must read the file and build it asynchronously. This means
@@ -1000,13 +987,13 @@ var SN = { // StatusNet
                  * - Safari 5.0.2: no
                  * - Chrome 8.0.552.210: works!
                  */
-                blobAsDataURL = function(blob, callback) {
+                blobAsDataURL = function (blob, callback) {
                     var reader = new FileReader();
-                    reader.onload = function(event) {
+                    reader.onload = function (event) {
                         callback(reader.result);
-                    }
+                    };
                     reader.readAsDataURL(blob);
-                }
+                };
             } else {
                 preview = false;
             }
@@ -1024,7 +1011,7 @@ var SN = { // StatusNet
             }
 
             if (preview) {
-                blobAsDataURL(file, function(url) {
+                blobAsDataURL(file, function (url) {
                     var img = $('<img>')
                         .attr('title', tooltip)
                         .attr('alt', tooltip)
@@ -1052,10 +1039,10 @@ var SN = { // StatusNet
          *        hard time figuring out if it's working or fixing if it's wrong.
          *
          */
-        NoticeLocationAttach: function(form) {
+        NoticeLocationAttach: function (form) {
             // @fixme this should not be tied to the main notice form, as there may be multiple notice forms...
-            var NLat = form.find('[name=lat]')
-            var NLon = form.find('[name=lon]')
+            var NLat = form.find('[name=lat]');
+            var NLon = form.find('[name=lon]');
             var NLNS = form.find('[name=location_ns]').val();
             var NLID = form.find('[name=location_id]').val();
             var NLN = ''; // @fixme
@@ -1086,23 +1073,22 @@ var SN = { // StatusNet
 
             function getJSONgeocodeURL(geocodeURL, data) {
                 SN.U.NoticeGeoStatus(form, 'Looking up place name...');
-                $.getJSON(geocodeURL, data, function(location) {
-                    var lns, lid;
+                $.getJSON(geocodeURL, data, function (location) {
+                    var lns, lid, NLN_text;
 
-                    if (typeof(location.location_ns) != 'undefined') {
+                    if (location.location_ns !== undefined) {
                         form.find('[name=location_ns]').val(location.location_ns);
                         lns = location.location_ns;
                     }
 
-                    if (typeof(location.location_id) != 'undefined') {
+                    if (location.location_id !== undefined) {
                         form.find('[name=location_id]').val(location.location_id);
                         lid = location.location_id;
                     }
 
-                    if (typeof(location.name) == 'undefined') {
+                    if (location.name === undefined) {
                         NLN_text = data.lat + ';' + data.lon;
-                    }
-                    else {
+                    } else {
                         NLN_text = location.name;
                     }
 
@@ -1133,19 +1119,17 @@ var SN = { // StatusNet
             if (check.length > 0) {
                 if ($.cookie(SN.C.S.NoticeDataGeoCookie) == 'disabled') {
                     check.prop('checked', false);
-                }
-                else {
+                } else {
                     check.prop('checked', true);
                 }
 
                 var NGW = form.find('.notice_data-geo_wrap');
                 var geocodeURL = NGW.attr('data-api');
 
-                label
-                    .attr('title', label.text());
+                label.attr('title', label.text());
 
-                check.change(function() {
-                    if (check.prop('checked') === true || $.cookie(SN.C.S.NoticeDataGeoCookie) === null)
+                check.change(function () {
+                    if (check.prop('checked') === true || $.cookie(SN.C.S.NoticeDataGeoCookie) === null) {
                         label
                             .attr('title', NoticeDataGeo_text.ShareDisable)
                             .addClass('checked');
@@ -1154,7 +1138,7 @@ var SN = { // StatusNet
                             if (navigator.geolocation) {
                                 SN.U.NoticeGeoStatus(form, 'Requesting location from browser...');
                                 navigator.geolocation.getCurrentPosition(
-                                    function(position) {
+                                    function (position) {
                                         form.find('[name=lat]').val(position.coords.latitude);
                                         form.find('[name=lon]').val(position.coords.longitude);
 
@@ -1167,13 +1151,13 @@ var SN = { // StatusNet
                                         getJSONgeocodeURL(geocodeURL, data);
                                     },
 
-                                    function(error) {
+                                    function (error) {
                                         switch(error.code) {
                                             case error.PERMISSION_DENIED:
                                                 removeNoticeDataGeo('Location permission denied.');
                                                 break;
                                             case error.TIMEOUT:
-                                                //$('#'+SN.C.S.NoticeDataGeo).prop('checked', false);
+                                                //$('#' + SN.C.S.NoticeDataGeo).prop('checked', false);
                                                 removeNoticeDataGeo('Location lookup timeout.');
                                                 break;
                                         }
@@ -1183,8 +1167,7 @@ var SN = { // StatusNet
                                         timeout: 10000
                                     }
                                 );
-                            }
-                            else {
+                            } else {
                                 if (NLat.length > 0 && NLon.length > 0) {
                                     var data = {
                                         lat: NLat,
@@ -1193,15 +1176,13 @@ var SN = { // StatusNet
                                     };
 
                                     getJSONgeocodeURL(geocodeURL, data);
-                                }
-                                else {
+                                } else {
                                     removeNoticeDataGeo();
                                     check.remove();
                                     label.remove();
                                 }
                             }
-                        }
-                        else {
+                        } else {
                             var cookieValue = JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));
 
                             form.find('[name=lat]').val(cookieValue.NLat);
@@ -1215,8 +1196,7 @@ var SN = { // StatusNet
                                 .attr('title', NoticeDataGeo_text.ShareDisable + ' (' + cookieValue.NLN + ')')
                                 .addClass('checked');
                         }
-                    }
-                    else {
+                    } else {
                         removeNoticeDataGeo();
                     }
                 }).change();
@@ -1232,12 +1212,12 @@ var SN = { // StatusNet
          * @param {String} lon (optional)
          * @param {String} url (optional)
          */
-        NoticeGeoStatus: function(form, status, lat, lon, url)
+        NoticeGeoStatus: function (form, status, lat, lon, url)
         {
             var wrapper = form.find('.geo_status_wrapper');
             if (wrapper.length == 0) {
-                wrapper = $('<div class="'+SN.C.S.Success+' geo_status_wrapper"><button class="close" style="float:right">&#215;</button><div class="geo_status"></div></div>');
-                wrapper.find('button.close').click(function() {
+                wrapper = $('<div class="' + SN.C.S.Success + ' geo_status_wrapper"><button class="close" style="float:right">&#215;</button><div class="geo_status"></div></div>');
+                wrapper.find('button.close').click(function () {
                     form.find('[name=notice_data-geo]').prop('checked', false).change();
                     return false;
                 });
@@ -1272,27 +1252,26 @@ var SN = { // StatusNet
          *
          * @fixme breaks ability to open link in new window?
          */
-        NewDirectMessage: function() {
+        NewDirectMessage: function () {
             NDM = $('.entity_send-a-message a');
-            NDM.attr({'href':NDM.attr('href')+'&ajax=1'});
-            NDM.on('click', function() {
+            NDM.attr({'href': NDM.attr('href') + '&ajax=1'});
+            NDM.on('click', function () {
                 var NDMF = $('.entity_send-a-message form');
                 if (NDMF.length === 0) {
                     $(this).addClass(SN.C.S.Processing);
-                    $.get(NDM.attr('href'), null, function(data) {
+                    $.get(NDM.attr('href'), null, function (data) {
                         $('.entity_send-a-message').append(document._importNode($('form', data)[0], true));
                         NDMF = $('.entity_send-a-message .form_notice');
                         SN.U.FormNoticeXHR(NDMF);
                         SN.U.FormNoticeEnhancements(NDMF);
                         NDMF.append('<button class="close">&#215;</button>');
-                        $('.entity_send-a-message button').click(function(){
+                        $('.entity_send-a-message button').click(function () {
                             NDMF.hide();
                             return false;
                         });
                         NDM.removeClass(SN.C.S.Processing);
                     });
-                }
-                else {
+                } else {
                     NDMF.show();
                     $('.entity_send-a-message textarea').focus();
                 }
@@ -1309,7 +1288,7 @@ var SN = { // StatusNet
          * @param {number} day: 1 == 1
          * @return {Date}
          */
-        GetFullYear: function(year, month, day) {
+        GetFullYear: function (year, month, day) {
             var date = new Date();
             date.setFullYear(year, month, day);
 
@@ -1332,7 +1311,7 @@ var SN = { // StatusNet
             /**
              * @fixme what is this?
              */
-            Set: function(value) {
+            Set: function (value) {
                 var SNI = SN.U.StatusNetInstance.Get();
                 if (SNI !== null) {
                     value = $.extend(SNI, value);
@@ -1350,7 +1329,7 @@ var SN = { // StatusNet
             /**
              * @fixme what is this?
              */
-            Get: function() {
+            Get: function () {
                 var cookieValue = $.cookie(SN.C.S.StatusNetInstance);
                 if (cookieValue !== null) {
                     return JSON.parse(cookieValue);
@@ -1361,7 +1340,7 @@ var SN = { // StatusNet
             /**
              * @fixme what is this?
              */
-            Delete: function() {
+            Delete: function () {
                 $.cookie(SN.C.S.StatusNetInstance, null);
             }
         },
@@ -1376,7 +1355,7 @@ var SN = { // StatusNet
          * @param {DOMElement} notice: HTML chunk with formatted notice
          * @return boolean
          */
-        belongsOnTimeline: function(notice) {
+        belongsOnTimeline: function (notice) {
             var action = $("body").attr('id');
             if (action == 'public') {
                 return true;
@@ -1408,15 +1387,15 @@ var SN = { // StatusNet
          *
          * @param {String} tag
          */
-       switchInputFormTab: function(tag) {
-           // The one that's current isn't current anymore
-           $('.input_form_nav_tab.current').removeClass('current');
+    switchInputFormTab: function (tag) {
+        // The one that's current isn't current anymore
+        $('.input_form_nav_tab.current').removeClass('current');
             if (tag == 'placeholder') {
                 // Hack: when showing the placeholder, mark the tab
                 // as current for 'Status'.
                 $('#input_form_nav_status').addClass('current');
             } else {
-                $('#input_form_nav_'+tag).addClass('current');
+                $('#input_form_nav_' + tag).addClass('current');
             }
 
             // Don't remove 'current' if we also have the "nonav" class.
@@ -1427,19 +1406,19 @@ var SN = { // StatusNet
                 return;
             }
 
-           $('.input_form.current').removeClass('current');
-           $('#input_form_'+tag)
+        $('.input_form.current').removeClass('current');
+        $('#input_form_' + tag)
                 .addClass('current')
-                .find('.ajax-notice').each(function() {
+                .find('.ajax-notice').each(function () {
                     var form = $(this);
                     SN.Init.NoticeFormSetup(form);
                 })
                 .find('.notice_data-text').focus();
-       },
+    },
 
-        showMoreMenuItems: function(menuid) {
-            $('#'+menuid+' .more_link').remove();
-            var selector = '#'+menuid+' .extended_menu';
+        showMoreMenuItems: function (menuid) {
+            $('#' + menuid + ' .more_link').remove();
+            var selector = '#' + menuid + ' .extended_menu';
             var extended = $(selector);
             extended.removeClass('extended_menu');
             return void(0);
@@ -1455,25 +1434,25 @@ var SN = { // StatusNet
          *  - location events
          *  - file upload events
          */
-        NoticeForm: function() {
+        NoticeForm: function () {
             if ($('body.user_in').length > 0) {
                 // SN.Init.NoticeFormSetup() will get run
                 // when forms get displayed for the first time...
 
                 // Hack to initialize the placeholder at top
-                $('#input_form_placeholder input.placeholder').focus(function() {
+                $('#input_form_placeholder input.placeholder').focus(function () {
                     SN.U.switchInputFormTab("status");
                 });
 
                 // Make inline reply forms self-close when clicking out.
-                $('body').on('click', function(e) {
+                $('body').on('click', function (e) {
                     var currentForm = $('#content .input_forms div.current');
                     if (currentForm.length > 0) {
                         if ($('#content .input_forms').has(e.target).length == 0) {
                             // If all fields are empty, switch back to the placeholder.
                             var fields = currentForm.find('textarea, input[type=text], input[type=""]');
                             var anything = false;
-                            fields.each(function() {
+                            fields.each(function () {
                                 anything = anything || $(this).val();
                             });
                             if (!anything) {
@@ -1485,7 +1464,7 @@ var SN = { // StatusNet
                     var openReplies = $('li.notice-reply');
                     if (openReplies.length > 0) {
                         var target = $(e.target);
-                        openReplies.each(function() {
+                        openReplies.each(function () {
                             // Did we click outside this one?
                             var replyItem = $(this);
                             if (replyItem.has(e.target).length == 0) {
@@ -1515,7 +1494,7 @@ var SN = { // StatusNet
          *
          * @param {jQuery} form
          */
-        NoticeFormSetup: function(form) {
+        NoticeFormSetup: function (form) {
             if (!form.data('NoticeFormSetup')) {
                 SN.U.NoticeLocationAttach(form);
                 SN.U.FormNoticeXHR(form);
@@ -1531,7 +1510,7 @@ var SN = { // StatusNet
          * - AJAX submission for fave/repeat/reply (if logged in)
          * - Attachment link extras ('more' links)
          */
-        Notices: function() {
+        Notices: function () {
             if ($('body.user_in').length > 0) {
                 var masterForm = $('.form_notice:first');
                 if (masterForm.length > 0) {
@@ -1551,25 +1530,25 @@ var SN = { // StatusNet
          * - AJAX submission for sub/unsub/join/leave/nudge
          * - AJAX form popup for direct-message
          */
-        EntityActions: function() {
+        EntityActions: function () {
             if ($('body.user_in').length > 0) {
-                $(document).on('click', '.form_user_subscribe', function() { SN.U.FormXHR($(this)); return false; });
-                $(document).on('click', '.form_user_unsubscribe', function() { SN.U.FormXHR($(this)); return false; });
-                $(document).on('click', '.form_group_join', function() { SN.U.FormXHR($(this)); return false; });
-                $(document).on('click', '.form_group_leave', function() { SN.U.FormXHR($(this)); return false; });
-                $(document).on('click', '.form_user_nudge', function() { SN.U.FormXHR($(this)); return false; });
-                $(document).on('click', '.form_peopletag_subscribe', function() { SN.U.FormXHR($(this)); return false; });
-                $(document).on('click', '.form_peopletag_unsubscribe', function() { SN.U.FormXHR($(this)); return false; });
-                $(document).on('click', '.form_user_add_peopletag', function() { SN.U.FormXHR($(this)); return false; });
-                $(document).on('click', '.form_user_remove_peopletag', function() { SN.U.FormXHR($(this)); return false; });
+                $(document).on('click', '.form_user_subscribe', function () { SN.U.FormXHR($(this)); return false; });
+                $(document).on('click', '.form_user_unsubscribe', function () { SN.U.FormXHR($(this)); return false; });
+                $(document).on('click', '.form_group_join', function () { SN.U.FormXHR($(this)); return false; });
+                $(document).on('click', '.form_group_leave', function () { SN.U.FormXHR($(this)); return false; });
+                $(document).on('click', '.form_user_nudge', function () { SN.U.FormXHR($(this)); return false; });
+                $(document).on('click', '.form_peopletag_subscribe', function () { SN.U.FormXHR($(this)); return false; });
+                $(document).on('click', '.form_peopletag_unsubscribe', function () { SN.U.FormXHR($(this)); return false; });
+                $(document).on('click', '.form_user_add_peopletag', function () { SN.U.FormXHR($(this)); return false; });
+                $(document).on('click', '.form_user_remove_peopletag', function () { SN.U.FormXHR($(this)); return false; });
 
                 SN.U.NewDirectMessage();
             }
         },
 
-        ProfileSearch: function() {
+        ProfileSearch: function () {
             if ($('body.user_in').length > 0) {
-                $(document).on('click', '.form_peopletag_edit_user_search input.submit', function() {
+                $(document).on('click', '.form_peopletag_edit_user_search input.submit', function () {
                     SN.U.FormProfileSearchXHR($(this).parents('form')); return false;
                 });
             }
@@ -1583,7 +1562,7 @@ var SN = { // StatusNet
          *
          * @fixme is this necessary? Browsers do their own form saving these days.
          */
-        Login: function() {
+        Login: function () {
             if (SN.U.StatusNetInstance.Get() !== null) {
                 var nickname = SN.U.StatusNetInstance.Get().Nickname;
                 if (nickname !== null) {
@@ -1591,7 +1570,7 @@ var SN = { // StatusNet
                 }
             }
 
-            $('#form_login').on('submit', function() {
+            $('#form_login').on('submit', function () {
                 SN.U.StatusNetInstance.Set({Nickname: $('#form_login #nickname').val()});
                 return true;
             });
@@ -1604,51 +1583,51 @@ var SN = { // StatusNet
          * - sets event handlers for tag completion
          *
          */
-        PeopletagAutocomplete: function(txtBox) {
-            var split = function(val) {
+        PeopletagAutocomplete: function (txtBox) {
+            var split = function (val) {
                 return val.split( /\s+/ );
             }
-            var extractLast = function(term) {
+            var extractLast = function (term) {
                 return split(term).pop();
             }
 
             // don't navigate away from the field on tab when selecting an item
-            txtBox.on( "keydown", function( event ) {
+            txtBox.on( "keydown", function ( event ) {
                 if ( event.keyCode === $.ui.keyCode.TAB &&
                         $(this).data( "autocomplete" ).menu.active ) {
                     event.preventDefault();
                 }
             }).autocomplete({
                 minLength: 0,
-                source: function(request, response) {
-                           // delegate back to autocomplete, but extract the last term
-                           response($.ui.autocomplete.filter(
-                                   SN.C.PtagACData, extractLast(request.term)));
-                   },
-                   focus: function() {
-                       return false;
+                source: function (request, response) {
+                    // delegate back to autocomplete, but extract the last term
+                    response($.ui.autocomplete.filter(
+                        SN.C.PtagACData, extractLast(request.term)));
                 },
-                   select: function(event, ui) {
-                           var terms = split(this.value);
-                           terms.pop();
-                           terms.push(ui.item.value);
-                           terms.push("");
-                           this.value = terms.join(" ");
-                           return false;
-                   }
-            }).data('autocomplete')._renderItem = function(ul, item) {
+                focus: function () {
+                    return false;
+                },
+                select: function (event, ui) {
+                    var terms = split(this.value);
+                    terms.pop();
+                    terms.push(ui.item.value);
+                    terms.push("");
+                    this.value = terms.join(" ");
+                    return false;
+                }
+            }).data('autocomplete')._renderItem = function (ul, item) {
                     // FIXME: with jQuery UI you cannot have it highlight the match
                     var _l = '<a class="ptag-ac-line-tag">' + item.tag
                           + ' <em class="privacy_mode">' + item.mode + '</em>'
                           + '<span class="freq">' + item.freq + '</span></a>'
 
-                           return $("<li/>")
-                               .addClass('mode-' + item.mode)
+                    return $("<li/>")
+                            .addClass('mode-' + item.mode)
                             .addClass('ptag-ac-line')
                             .data("item.autocomplete", item)
                             .append(_l)
                             .appendTo(ul);
-                   }
+                }
         },
 
         /**
@@ -1660,10 +1639,10 @@ var SN = { // StatusNet
          *     or if it is stale.
          *
          */
-        PeopleTags: function() {
+        PeopleTags: function () {
             $('.user_profile_tags .editable').append($('<button class="peopletags_edit_button"/>'));
 
-            $(document).on('click', '.peopletags_edit_button', function() {
+            $(document).on('click', '.peopletags_edit_button', function () {
                 var form = $(this).parents('dd').eq(0).find('form');
                 // We can buy time from the above animation
 
@@ -1672,7 +1651,7 @@ var SN = { // StatusNet
                     dataType: 'json',
                     data: {token: $('#token').val()},
                     ifModified: true,
-                    success: function(data) {
+                    success: function (data) {
                         // item.label is used to match
                         for (i=0; i < data.length; i++) {
                             data[i].label = data[i].tag;
@@ -1683,10 +1662,10 @@ var SN = { // StatusNet
                     }
                 });
 
-                $(this).parents('ul').eq(0).fadeOut(200, function() {form.fadeIn(200).find('input#tags')});
+                $(this).parents('ul').eq(0).fadeOut(200, function () {form.fadeIn(200).find('input#tags')});
             });
 
-            $(document).on('click', '.user_profile_tags form .submit', function() {
+            $(document).on('click', '.user_profile_tags form .submit', function () {
                 SN.U.FormPeopletagsXHR($(this).parents('form')); return false;
             });
         },
@@ -1694,12 +1673,12 @@ var SN = { // StatusNet
         /**
          * Set up any generic 'ajax' form so it submits via AJAX with auto-replacement.
          */
-        AjaxForms: function() {
-            $(document).on('submit', 'form.ajax', function() {
+        AjaxForms: function () {
+            $(document).on('submit', 'form.ajax', function () {
                 SN.U.FormXHR($(this));
                 return false;
             });
-            $(document).on('click', 'form.ajax input[type=submit]', function() {
+            $(document).on('click', 'form.ajax input[type=submit]', function () {
                 // Some forms rely on knowing which submit button was clicked.
                 // Save a hidden input field which'll be picked up during AJAX
                 // submit...
@@ -1718,8 +1697,8 @@ var SN = { // StatusNet
          * on browsers that support basic FileAPI.
          */
         UploadForms: function () {
-            $('input[type=file]').change(function(event) {
-                if (typeof this.files == "object" && this.files.length > 0) {
+            $('input[type=file]').change(function (event) {
+                if (typeof this.files === "object" && this.files.length > 0) {
                     var size = 0;
                     for (var i = 0; i < this.files.length; i++) {
                         size += this.files[i].size;
@@ -1739,24 +1718,24 @@ var SN = { // StatusNet
             });
         },
 
-       CheckBoxes: function() {
-           $("span[class='checkbox-wrapper']").addClass("unchecked");
-           $(".checkbox-wrapper").click(function(){
-               if($(this).children("input").prop("checked")){
-                   // uncheck
-                   $(this).children("input").prop("checked", false);
-                   $(this).removeClass("checked");
-                   $(this).addClass("unchecked");
-                   $(this).children("label").text("Private?");
-               }else{
-                   // check
-                   $(this).children("input").prop("checked", true);
-                   $(this).removeClass("unchecked");
-                   $(this).addClass("checked");
-                   $(this).children("label").text("Private");
-               }
-           });
-       }
+        CheckBoxes: function () {
+            $("span[class='checkbox-wrapper']").addClass("unchecked");
+            $(".checkbox-wrapper").click(function () {
+                if ($(this).children("input").prop("checked")) {
+                    // uncheck
+                    $(this).children("input").prop("checked", false);
+                    $(this).removeClass("checked");
+                    $(this).addClass("unchecked");
+                    $(this).children("label").text("Private?");
+                } else {
+                    // check
+                    $(this).children("input").prop("checked", true);
+                    $(this).removeClass("unchecked");
+                    $(this).addClass("checked");
+                    $(this).children("label").text("Private");
+                }
+            });
+        }
     }
 };
 
@@ -1767,11 +1746,11 @@ var SN = { // StatusNet
  * until that's done. To load scripts asynchronously without delaying setup,
  * don't start them loading until after DOM-ready time!
  */
-$(function() {
+$(function () {
     SN.Init.AjaxForms();
     SN.Init.UploadForms();
     SN.Init.CheckBoxes();
-    if ($('.'+SN.C.S.FormNotice).length > 0) {
+    if ($('.' + SN.C.S.FormNotice).length > 0) {
         SN.Init.NoticeForm();
     }
     if ($('#content .notices').length > 0) {
index 78e0c89841088e9663ba61c2617b6adf6d6b3ecb..8634b20e7803e7d5f343c38ea78825953dbceebc 100644 (file)
@@ -1 +1 @@
-var SN={C:{I:{CounterBlackout:false,MaxLength:140,PatternUsername:/^[0-9a-zA-Z\-_.]*$/,HTTP20x30x:[200,201,202,203,204,205,206,300,301,302,303,304,305,306,307],NoticeFormMaster:null},S:{Disabled:"disabled",Warning:"warning",Error:"error",Success:"success",Processing:"processing",CommandResult:"command_result",FormNotice:"form_notice",NoticeDataGeo:"notice_data-geo",NoticeDataGeoCookie:"NoticeDataGeo",NoticeDataGeoSelected:"notice_data-geo_selected",StatusNetInstance:"StatusNetInstance"}},messages:{},msg:function(a){if(typeof SN.messages[a]=="undefined"){return"["+a+"]"}else{return SN.messages[a]}},U:{FormNoticeEnhancements:function(b){if(jQuery.data(b[0],"ElementData")===undefined){MaxLength=b.find(".count").text();if(typeof(MaxLength)=="undefined"){MaxLength=SN.C.I.MaxLength}jQuery.data(b[0],"ElementData",{MaxLength:MaxLength});SN.U.Counter(b);NDT=b.find(".notice_data-text:first");NDT.bind("keyup",function(c){SN.U.Counter(b)});var a=function(c){window.setTimeout(function(){SN.U.Counter(b)},50)};NDT.bind("cut",a).bind("paste",a)}else{b.find(".count").text(jQuery.data(b[0],"ElementData").MaxLength)}},Counter:function(d){SN.C.I.FormNoticeCurrent=d;var b=jQuery.data(d[0],"ElementData").MaxLength;if(b<=0){return}var c=b-SN.U.CharacterCount(d);var a=d.find(".count");if(c.toString()!=a.text()){if(!SN.C.I.CounterBlackout||c===0){if(a.text()!=String(c)){a.text(c)}if(c<0){d.addClass(SN.C.S.Warning)}else{d.removeClass(SN.C.S.Warning)}if(!SN.C.I.CounterBlackout){SN.C.I.CounterBlackout=true;SN.C.I.FormNoticeCurrent=d;window.setTimeout("SN.U.ClearCounterBlackout(SN.C.I.FormNoticeCurrent);",500)}}}},CharacterCount:function(a){return a.find(".notice_data-text:first").val().length},ClearCounterBlackout:function(a){SN.C.I.CounterBlackout=false;SN.U.Counter(a)},RewriteAjaxAction:function(a){if(document.location.protocol=="https:"&&a.substr(0,5)=="http:"){return a.replace(/^http:\/\/[^:\/]+/,"https://"+document.location.host)}else{return a}},FormXHR:function(a,b){$.ajax({type:"POST",dataType:"xml",url:SN.U.RewriteAjaxAction(a.attr("action")),data:a.serialize()+"&ajax=1",beforeSend:function(c){a.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled)},error:function(e,f,d){var c=null;if(e.responseXML){c=$("#error",e.responseXML).text()}alert(c||d||f);a.removeClass(SN.C.S.Processing).find(".submit").removeClass(SN.C.S.Disabled).removeAttr(SN.C.S.Disabled)},success:function(c,d){if(typeof($("form",c)[0])!="undefined"){form_new=document._importNode($("form",c)[0],true);a.replaceWith(form_new);if(b){b()}}else{if(typeof($("p",c)[0])!="undefined"){a.replaceWith(document._importNode($("p",c)[0],true));if(b){b()}}else{alert("Unknown error.")}}}})},FormNoticeXHR:function(b){SN.C.I.NoticeDataGeo={};b.append('<input type="hidden" name="ajax" value="1"/>');b.attr("action",SN.U.RewriteAjaxAction(b.attr("action")));var c=function(d,e){b.append($('<p class="form_response"></p>').addClass(d).text(e))};var a=function(){b.find(".form_response").remove()};b.ajaxForm({dataType:"xml",timeout:"60000",beforeSend:function(d){if(b.find(".notice_data-text:first").val()==""){b.addClass(SN.C.S.Warning);return false}b.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled);SN.U.normalizeGeoData(b);return true},error:function(f,g,e){b.removeClass(SN.C.S.Processing).find(".submit").removeClass(SN.C.S.Disabled).removeAttr(SN.C.S.Disabled,SN.C.S.Disabled);a();if(g=="timeout"){c("error","Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.")}else{var d=SN.U.GetResponseXML(f);if($("."+SN.C.S.Error,d).length>0){b.append(document._importNode($("."+SN.C.S.Error,d)[0],true))}else{if(parseInt(f.status)===0||jQuery.inArray(parseInt(f.status),SN.C.I.HTTP20x30x)>=0){b.resetForm().find(".attach-status").remove();SN.U.FormNoticeEnhancements(b)}else{c("error","(Sorry! We had trouble sending your notice ("+f.status+" "+f.statusText+"). Please report the problem to the site administrator if this happens again.")}}}},success:function(j,f){a();var p=$("#"+SN.C.S.Error,j);if(p.length>0){c("error",p.text())}else{if($("body")[0].id=="bookmarklet"){self.close()}var d=$("#"+SN.C.S.CommandResult,j);if(d.length>0){c("success",d.text())}else{var o=document._importNode($("li",j)[0],true);var k=$("#notices_primary .notices:first");var m=b.closest("li.notice-reply");if(m.length>0){var l=b.closest(".threaded-replies");var n=l.find(".notice-reply-placeholder");m.remove();var e=$(o).attr("id");if($("#"+e).length==0){$(o).insertBefore(n)}else{}n.show()}else{if(k.length>0&&SN.U.belongsOnTimeline(o)){if($("#"+o.id).length===0){var h=b.find("[name=inreplyto]").val();var g="#notices_primary #notice-"+h;if($("body")[0].id=="conversation"){if(h.length>0&&$(g+" .notices").length<1){$(g).append('<ul class="notices"></ul>')}$($(g+" .notices")[0]).append(o)}else{k.prepend(o)}$("#"+o.id).css({display:"none"}).fadeIn(2500);SN.U.NoticeWithAttachment($("#"+o.id));SN.U.switchInputFormTab("placeholder")}}else{c("success",$("title",j).text())}}}b.resetForm();b.find("[name=inreplyto]").val("");b.find(".attach-status").remove();SN.U.FormNoticeEnhancements(b)}},complete:function(d,e){b.removeClass(SN.C.S.Processing).find(".submit").removeAttr(SN.C.S.Disabled).removeClass(SN.C.S.Disabled);b.find("[name=lat]").val(SN.C.I.NoticeDataGeo.NLat);b.find("[name=lon]").val(SN.C.I.NoticeDataGeo.NLon);b.find("[name=location_ns]").val(SN.C.I.NoticeDataGeo.NLNS);b.find("[name=location_id]").val(SN.C.I.NoticeDataGeo.NLID);b.find("[name=notice_data-geo]").attr("checked",SN.C.I.NoticeDataGeo.NDG)}})},FormProfileSearchXHR:function(a){$.ajax({type:"POST",dataType:"xml",url:a.attr("action"),data:a.serialize()+"&ajax=1",beforeSend:function(b){a.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled)},error:function(c,d,b){alert(b||d)},success:function(d,f){var b=$("#profile_search_results");if(typeof($("ul",d)[0])!="undefined"){var c=document._importNode($("ul",d)[0],true);b.replaceWith(c)}else{var e=$("<li/>").append(document._importNode($("p",d)[0],true));b.html(e)}a.removeClass(SN.C.S.Processing).find(".submit").removeClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,false)}})},FormPeopletagsXHR:function(a){$.ajax({type:"POST",dataType:"xml",url:a.attr("action"),data:a.serialize()+"&ajax=1",beforeSend:function(b){a.find(".submit").addClass(SN.C.S.Processing).addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled)},error:function(c,d,b){alert(b||d)},success:function(d,e){var c=a.parents(".entity_tags");if(typeof($(".entity_tags",d)[0])!="undefined"){var b=document._importNode($(".entity_tags",d)[0],true);$(b).find(".editable").append($('<button class="peopletags_edit_button"/>'));c.replaceWith(b)}else{c.find("p").remove();c.append(document._importNode($("p",d)[0],true));a.removeClass(SN.C.S.Processing).find(".submit").removeClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,false)}}})},normalizeGeoData:function(a){SN.C.I.NoticeDataGeo.NLat=a.find("[name=lat]").val();SN.C.I.NoticeDataGeo.NLon=a.find("[name=lon]").val();SN.C.I.NoticeDataGeo.NLNS=a.find("[name=location_ns]").val();SN.C.I.NoticeDataGeo.NLID=a.find("[name=location_id]").val();SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").attr("checked");var b=$.cookie(SN.C.S.NoticeDataGeoCookie);if(b!==null&&b!="disabled"){b=JSON.parse(b);SN.C.I.NoticeDataGeo.NLat=a.find("[name=lat]").val(b.NLat).val();SN.C.I.NoticeDataGeo.NLon=a.find("[name=lon]").val(b.NLon).val();if(b.NLNS){SN.C.I.NoticeDataGeo.NLNS=a.find("[name=location_ns]").val(b.NLNS).val();SN.C.I.NoticeDataGeo.NLID=a.find("[name=location_id]").val(b.NLID).val()}else{a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("")}}if(b=="disabled"){SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").attr("checked",false).attr("checked")}else{SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").attr("checked",true).attr("checked")}},GetResponseXML:function(b){try{return b.responseXML}catch(a){return(new DOMParser()).parseFromString(b.responseText,"text/xml")}},NoticeReply:function(){$("#content .notice_reply").live("click",function(b){b.preventDefault();var a=$(this).closest("li.notice");SN.U.NoticeInlineReplyTrigger(a);return false})},NoticeReplyTo:function(a){},NoticeInlineReplyTrigger:function(k,l){var b=$($(".notice_id",k)[0]).text();var e=k;var g=true;var f=k.closest(".notices");if(f.closest(".old-school").length){SN.U.switchInputFormTab("status");m=$("#input_form_status").find("form");g=false}else{if(f.hasClass("threaded-replies")){e=f.closest(".notice");var m=$(".notice-reply-form",f)}else{f=$("ul.threaded-replies",k);if(f.length==0){SN.U.NoticeInlineReplyPlaceholder(k);f=$("ul.threaded-replies",k)}else{var j=$("li.notice-reply-placeholder",k);if(j.length==0){SN.U.NoticeInlineReplyPlaceholder(k)}}var m=$(".notice-reply-form",f)}}var d=function(){m.find("input[name=inreplyto]").val(b);if(g){m.find("#notice_to").attr("disabled","disabled").hide();m.find("#notice_private").attr("disabled","disabled").hide();m.find("label[for=notice_to]").hide();m.find("label[for=notice_private]").hide()}var p=m.find("textarea");if(p.length==0){throw"No textarea"}var o="";if(l){o=l+" "}p.val(o+p.val().replace(RegExp(o,"i"),""));p.data("initialText",$.trim(l+""));p.focus();if(p[0].setSelectionRange){var n=p.val().length;p[0].setSelectionRange(n,n)}};if(m.length>0){d()}else{var j=f.find("li.notice-reply-placeholder").hide();var h=$("li.notice-reply",f);if(h.length==0){h=$('<li class="notice-reply"></li>');var c=function(n){var o=document._importNode(n,true);h.append(o);f.append(h);var p=m=$(o);SN.Init.NoticeFormSetup(p);d()};if(SN.C.I.NoticeFormMaster){c(SN.C.I.NoticeFormMaster)}else{var a=$("#form_notice").attr("action");$.get(a,{ajax:1},function(n,p,o){c($("form",n)[0])})}}}},NoticeInlineReplyPlaceholder:function(b){var a=b.find("ul.threaded-replies");if(a.length==0){a=$('<ul class="notices threaded-replies xoxo"></ul>');b.append(a);a=b.find("ul.threaded-replies")}var c=$('<li class="notice-reply-placeholder"><input class="placeholder" /></li>');c.find("input").val(SN.msg("reply_placeholder"));a.append(c)},NoticeInlineReplySetup:function(){$("li.notice-reply-placeholder input").live("focus",function(){var a=$(this).closest("li.notice");SN.U.NoticeInlineReplyTrigger(a);return false});$("li.notice-reply-comments a").live("click",function(){var a=$(this).attr("href");var b=$(this).closest(".threaded-replies");$.get(a,{ajax:1},function(d,f,e){var c=$(".threaded-replies",d);if(c.length){b.replaceWith(document._importNode(c[0],true))}});return false})},NoticeRepeat:function(){$(".form_repeat").live("click",function(a){a.preventDefault();SN.U.NoticeRepeatConfirmation($(this));return false})},NoticeRepeatConfirmation:function(a){var c=a.find(".submit");var b=c.clone();b.addClass("submit_dialogbox").removeClass("submit");a.append(b);b.bind("click",function(){SN.U.FormXHR(a);return false});c.hide();a.addClass("dialogbox").append('<button class="close">&#215;</button>').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('<div class="attach-status '+SN.C.S.Success+'"><code></code> <button class="close">&#215;</button></div>');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;e<this.files.length;e++){SN.U.PreviewAttach(b,this.files[e])}}})},maxFileSize:function(b){var a=$(b).find("input[name=MAX_FILE_SIZE]").attr("value");if(a){return parseInt(a)}else{return 0}},PreviewAttach:function(d,c){var e=c.type+" "+Math.round(c.size/1024)+"KB";var f=true;var h;if(typeof window.createObjectURL!="undefined"){h=function(j,k){k(window.createObjectURL(j))}}else{if(typeof window.FileReader!="undefined"){h=function(k,l){var j=new FileReader();j.onload=function(m){l(j.result)};j.readAsDataURL(k)}}else{f=false}}var a=["image/png","image/jpeg","image/gif","image/svg+xml"];if($.inArray(c.type,a)==-1){f=false}var g=8*1024*1024;if(c.size>g){f=false}if(f){h(c,function(k){var j=$("<img>").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("<div></div>").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('<div class="'+SN.C.S.Success+' geo_status_wrapper"><button class="close" style="float:right">&#215;</button><div class="geo_status"></div></div>');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("<a></a>").attr("href",c)}else{b=$("<span></span>")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('<button class="close">&#215;</button>');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()},showMoreMenuItems:function(c){$("#"+c+" .more_link").remove();var b="#"+c+" .extended_menu";var a=$(b);a.removeClass("extended_menu");return void (0)}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d='<a class="ptag-ac-line-tag">'+f.tag+' <em class="privacy_mode">'+f.mode+'</em><span class="freq">'+f.freq+"</span></a>";return $("<li/>").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('<button class="peopletags_edit_button"/>'));$(".peopletags_edit_button").live("click",function(){var a=$(this).parents("dd").eq(0).find("form");$.ajax({url:_peopletagAC,dataType:"json",data:{token:$("#token").val()},ifModified:true,success:function(b){for(i=0;i<b.length;i++){b[i].label=b[i].tag}SN.C.PtagACData=b;SN.Init.PeopletagAutocomplete(a.find("#tags"))}});$(this).parents("ul").eq(0).fadeOut(200,function(){a.fadeIn(200).find("input#tags")})});$(".user_profile_tags form .submit").live("click",function(){SN.U.FormPeopletagsXHR($(this).parents("form"));return false})},AjaxForms:function(){$("form.ajax").live("submit",function(){SN.U.FormXHR($(this));return false});$("form.ajax input[type=submit]").live("click",function(){var a=$(this);var b=a.closest("form");b.find(".hidden-submit-button").remove();$('<input class="hidden-submit-button" type="hidden" />').attr("name",a.attr("name")).val(a.val()).appendTo(b)})},UploadForms:function(){$("input[type=file]").change(function(d){if(typeof this.files=="object"&&this.files.length>0){var c=0;for(var b=0;b<this.files.length;b++){c+=this.files[b].size}var a=SN.U.maxFileSize($(this.form));if(a>0&&c>a){var e="File too large: maximum upload size is %d bytes.";alert(e.replace("%d",a));$(this).val("");d.preventDefault();return false}}})},CheckBoxes:function(){$("span[class='checkbox-wrapper']").addClass("unchecked");$(".checkbox-wrapper").click(function(){if($(this).children("input").attr("checked")){$(this).children("input").attr({checked:""});$(this).removeClass("checked");$(this).addClass("unchecked");$(this).children("label").text("Private?")}else{$(this).children("input").attr({checked:"checked"});$(this).removeClass("unchecked");$(this).addClass("checked");$(this).children("label").text("Private")}})}}};$(document).ready(function(){SN.Init.AjaxForms();SN.Init.UploadForms();SN.Init.CheckBoxes();if($("."+SN.C.S.FormNotice).length>0){SN.Init.NoticeForm()}if($("#content .notices").length>0){SN.Init.Notices()}if($("#content .entity_actions").length>0){SN.Init.EntityActions()}if($("#form_login").length>0){SN.Init.Login()}if($("#profile_search_results").length>0){SN.Init.ProfileSearch()}if($(".user_profile_tags .editable").length>0){SN.Init.PeopleTags()}});if(!document.ELEMENT_NODE){document.ELEMENT_NODE=1;document.ATTRIBUTE_NODE=2;document.TEXT_NODE=3;document.CDATA_SECTION_NODE=4;document.ENTITY_REFERENCE_NODE=5;document.ENTITY_NODE=6;document.PROCESSING_INSTRUCTION_NODE=7;document.COMMENT_NODE=8;document.DOCUMENT_NODE=9;document.DOCUMENT_TYPE_NODE=10;document.DOCUMENT_FRAGMENT_NODE=11;document.NOTATION_NODE=12}document._importNode=function(e,a){switch(e.nodeType){case document.ELEMENT_NODE:var d=document.createElement(e.nodeName);if(e.attributes&&e.attributes.length>0){for(var c=0,b=e.attributes.length;c<b;){if(e.attributes[c].nodeName=="class"){d.className=e.getAttribute(e.attributes[c++].nodeName)}else{d.setAttribute(e.attributes[c].nodeName,e.getAttribute(e.attributes[c++].nodeName))}}}if(a&&e.childNodes&&e.childNodes.length>0){for(var c=0,b=e.childNodes.length;c<b;){d.appendChild(document._importNode(e.childNodes[c++],a))}}return d;break;case document.TEXT_NODE:case document.CDATA_SECTION_NODE:case document.COMMENT_NODE:return document.createTextNode(e.nodeValue);break}};if(typeof navigator.geolocation=="undefined"||navigator.geolocation.shim){(function(){(function(){if(window.google&&google.gears){return}var c=null;if(typeof GearsFactory!="undefined"){c=new GearsFactory()}else{try{c=new ActiveXObject("Gears.Factory");if(c.getBuildInfo().indexOf("ie_mobile")!=-1){c.privateSetGlobalObject(this)}}catch(d){if((typeof navigator.mimeTypes!="undefined")&&navigator.mimeTypes["application/x-googlegears"]){c=document.createElement("object");c.style.display="none";c.width=0;c.height=0;c.type="application/x-googlegears";document.documentElement.appendChild(c)}}}if(!c){return}if(!window.google){google={}}if(!google.gears){google.gears={factory:c}}})();var a=(function(){var d=google.gears.factory.create("beta.geolocation");var c=function(f,e){return function(g){f(g);e.lastPosition=g}};return{shim:true,type:"Gears",lastPosition:null,getCurrentPosition:function(e,g,h){var f=this;var j=c(e,f);d.getCurrentPosition(j,g,h)},watchPosition:function(e,f,g){d.watchPosition(e,f,g)},clearWatch:function(e){d.clearWatch(e)},getPermission:function(g,e,f){d.getPermission(g,e,f)}}});var b=(function(){var j=false;var e=function(){if(!d()&&!j){j=true;var k=document.createElement("script");k.src=(document.location.protocol=="https:"?"https://":"http://")+"www.google.com/jsapi?callback=_google_loader_apiLoaded";k.type="text/javascript";document.getElementsByTagName("body")[0].appendChild(k)}};var c=[];var h=function(k){c.push(k)};var f=function(){if(d()){while(c.length>0){var k=c.pop();k()}}};window._google_loader_apiLoaded=function(){f()};var d=function(){return(window.google&&google.loader)};var g=function(k){if(d()){return true}h(k);e();return false};e();return{shim:true,type:"ClientLocation",lastPosition:null,getCurrentPosition:function(l,o,p){var n=this;if(!g(function(){n.getCurrentPosition(l,o,p)})){return}if(google.loader.ClientLocation){var m=google.loader.ClientLocation;var k={coords:{latitude:m.latitude,longitude:m.longitude,altitude:null,accuracy:43000,altitudeAccuracy:null,heading:null,speed:null},address:{city:m.address.city,country:m.address.country,country_code:m.address.country_code,region:m.address.region},timestamp:new Date()};l(k);this.lastPosition=k}else{if(o==="function"){o({code:3,message:"Using the Google ClientLocation API and it is not able to calculate a location."})}}},watchPosition:function(k,m,n){this.getCurrentPosition(k,m,n);var l=this;var o=setInterval(function(){l.getCurrentPosition(k,m,n)},10000);return o},clearWatch:function(k){clearInterval(k)},getPermission:function(m,k,l){return true}}});navigator.geolocation=(window.google&&google.gears)?a():b()})()};
\ No newline at end of file
+var SN={C:{I:{CounterBlackout:false,MaxLength:140,PatternUsername:/^[0-9a-zA-Z\-_.]*$/,HTTP20x30x:[200,201,202,203,204,205,206,300,301,302,303,304,305,306,307],NoticeFormMaster:null},S:{Disabled:"disabled",Warning:"warning",Error:"error",Success:"success",Processing:"processing",CommandResult:"command_result",FormNotice:"form_notice",NoticeDataGeo:"notice_data-geo",NoticeDataGeoCookie:"NoticeDataGeo",NoticeDataGeoSelected:"notice_data-geo_selected",StatusNetInstance:"StatusNetInstance"}},messages:{},msg:function(a){if(SN.messages[a]===undefined){return"["+a+"]"}return SN.messages[a]},U:{FormNoticeEnhancements:function(d){if(jQuery.data(d[0],"ElementData")===undefined){var a=d.find(".count").text();if(a===undefined){a=SN.C.I.MaxLength}jQuery.data(d[0],"ElementData",{MaxLength:a});SN.U.Counter(d);var c=d.find(".notice_data-text:first");c.on("keyup",function(f){SN.U.Counter(d)});var b=function(f){window.setTimeout(function(){SN.U.Counter(d)},50)};c.on("cut",b).on("paste",b)}else{d.find(".count").text(jQuery.data(d[0],"ElementData").MaxLength)}},Counter:function(d){SN.C.I.FormNoticeCurrent=d;var b=jQuery.data(d[0],"ElementData").MaxLength;if(b<=0){return}var c=b-SN.U.CharacterCount(d);var a=d.find(".count");if(c.toString()!=a.text()){if(!SN.C.I.CounterBlackout||c===0){if(a.text()!=String(c)){a.text(c)}if(c<0){d.addClass(SN.C.S.Warning)}else{d.removeClass(SN.C.S.Warning)}if(!SN.C.I.CounterBlackout){SN.C.I.CounterBlackout=true;SN.C.I.FormNoticeCurrent=d;window.setTimeout("SN.U.ClearCounterBlackout(SN.C.I.FormNoticeCurrent);",500)}}}},CharacterCount:function(a){return a.find(".notice_data-text:first").val().length},ClearCounterBlackout:function(a){SN.C.I.CounterBlackout=false;SN.U.Counter(a)},RewriteAjaxAction:function(a){if(document.location.protocol==="https:"&&a.substr(0,5)==="http:"){return a.replace(/^http:\/\/[^:\/]+/,"https://"+document.location.host)}return a},FormXHR:function(a,b){$.ajax({type:"POST",dataType:"xml",url:SN.U.RewriteAjaxAction(a.attr("action")),data:a.serialize()+"&ajax=1",beforeSend:function(c){a.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).prop(SN.C.S.Disabled,true)},error:function(e,f,d){var c=null;if(e.responseXML){c=$("#error",e.responseXML).text()}window.alert(c||d||f);a.removeClass(SN.C.S.Processing).find(".submit").removeClass(SN.C.S.Disabled).prop(SN.C.S.Disabled,false)},success:function(c,e){if($("form",c)[0]!==undefined){var d=document._importNode($("form",c)[0],true);a.replaceWith(d);if(b){b()}}else{if($("p",c)[0]!==undefined){a.replaceWith(document._importNode($("p",c)[0],true));if(b){b()}}else{window.alert("Unknown error.")}}}})},FormNoticeXHR:function(b){SN.C.I.NoticeDataGeo={};b.append('<input type="hidden" name="ajax" value="1"/>');b.attr("action",SN.U.RewriteAjaxAction(b.attr("action")));var c=function(d,e){b.append($('<p class="form_response"></p>').addClass(d).text(e))};var a=function(){b.find(".form_response").remove()};b.ajaxForm({dataType:"xml",timeout:"60000",beforeSend:function(d){if(b.find(".notice_data-text:first").val()==""){b.addClass(SN.C.S.Warning);return false}b.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).prop(SN.C.S.Disabled,true);SN.U.normalizeGeoData(b);return true},error:function(f,g,e){b.removeClass(SN.C.S.Processing).find(".submit").removeClass(SN.C.S.Disabled).prop(SN.C.S.Disabled,false);a();if(g=="timeout"){c("error","Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.")}else{var d=SN.U.GetResponseXML(f);if($("."+SN.C.S.Error,d).length>0){b.append(document._importNode($("."+SN.C.S.Error,d)[0],true))}else{if(parseInt(f.status)===0||jQuery.inArray(parseInt(f.status),SN.C.I.HTTP20x30x)>=0){b.resetForm().find(".attach-status").remove();SN.U.FormNoticeEnhancements(b)}else{c("error","(Sorry! We had trouble sending your notice ("+f.status+" "+f.statusText+"). Please report the problem to the site administrator if this happens again.")}}}},success:function(j,f){a();var p=$("#"+SN.C.S.Error,j);if(p.length>0){c("error",p.text())}else{if($("body")[0].id=="bookmarklet"){self.close()}var d=$("#"+SN.C.S.CommandResult,j);if(d.length>0){c("success",d.text())}else{var o=document._importNode($("li",j)[0],true);var k=$("#notices_primary .notices:first");var m=b.closest("li.notice-reply");if(m.length>0){var l=b.closest(".threaded-replies");var n=l.find(".notice-reply-placeholder");m.remove();var e=$(o).attr("id");if($("#"+e).length==0){$(o).insertBefore(n)}n.show()}else{if(k.length>0&&SN.U.belongsOnTimeline(o)){if($("#"+o.id).length===0){var h=b.find("[name=inreplyto]").val();var g="#notices_primary #notice-"+h;if($("body")[0].id=="conversation"){if(h.length>0&&$(g+" .notices").length<1){$(g).append('<ul class="notices"></ul>')}$($(g+" .notices")[0]).append(o)}else{k.prepend(o)}$("#"+o.id).css({display:"none"}).fadeIn(2500);SN.U.NoticeWithAttachment($("#"+o.id));SN.U.switchInputFormTab("placeholder")}}else{c("success",$("title",j).text())}}}b.resetForm();b.find("[name=inreplyto]").val("");b.find(".attach-status").remove();SN.U.FormNoticeEnhancements(b)}},complete:function(d,e){b.removeClass(SN.C.S.Processing).find(".submit").prop(SN.C.S.Disabled,false).removeClass(SN.C.S.Disabled);b.find("[name=lat]").val(SN.C.I.NoticeDataGeo.NLat);b.find("[name=lon]").val(SN.C.I.NoticeDataGeo.NLon);b.find("[name=location_ns]").val(SN.C.I.NoticeDataGeo.NLNS);b.find("[name=location_id]").val(SN.C.I.NoticeDataGeo.NLID);b.find("[name=notice_data-geo]").prop("checked",SN.C.I.NoticeDataGeo.NDG)}})},FormProfileSearchXHR:function(a){$.ajax({type:"POST",dataType:"xml",url:a.attr("action"),data:a.serialize()+"&ajax=1",beforeSend:function(b){a.addClass(SN.C.S.Processing).find(".submit").addClass(SN.C.S.Disabled).prop(SN.C.S.Disabled,true)},error:function(c,d,b){window.alert(b||d)},success:function(d,f){var b=$("#profile_search_results");if($("ul",d)[0]!==undefined){var c=document._importNode($("ul",d)[0],true);b.replaceWith(c)}else{var e=$("<li/>").append(document._importNode($("p",d)[0],true));b.html(e)}a.removeClass(SN.C.S.Processing).find(".submit").removeClass(SN.C.S.Disabled).prop(SN.C.S.Disabled,false)}})},FormPeopletagsXHR:function(a){$.ajax({type:"POST",dataType:"xml",url:a.attr("action"),data:a.serialize()+"&ajax=1",beforeSend:function(b){a.find(".submit").addClass(SN.C.S.Processing).addClass(SN.C.S.Disabled).prop(SN.C.S.Disabled,true)},error:function(c,d,b){window.alert(b||d)},success:function(d,e){var c=a.parents(".entity_tags");if($(".entity_tags",d)[0]!==undefined){var b=document._importNode($(".entity_tags",d)[0],true);$(b).find(".editable").append($('<button class="peopletags_edit_button"/>'));c.replaceWith(b)}else{c.find("p").remove();c.append(document._importNode($("p",d)[0],true));a.removeClass(SN.C.S.Processing).find(".submit").removeClass(SN.C.S.Disabled).prop(SN.C.S.Disabled,false)}}})},normalizeGeoData:function(a){SN.C.I.NoticeDataGeo.NLat=a.find("[name=lat]").val();SN.C.I.NoticeDataGeo.NLon=a.find("[name=lon]").val();SN.C.I.NoticeDataGeo.NLNS=a.find("[name=location_ns]").val();SN.C.I.NoticeDataGeo.NLID=a.find("[name=location_id]").val();SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").prop("checked");var b=$.cookie(SN.C.S.NoticeDataGeoCookie);if(b!==null&&b!="disabled"){b=JSON.parse(b);SN.C.I.NoticeDataGeo.NLat=a.find("[name=lat]").val(b.NLat).val();SN.C.I.NoticeDataGeo.NLon=a.find("[name=lon]").val(b.NLon).val();if(b.NLNS){SN.C.I.NoticeDataGeo.NLNS=a.find("[name=location_ns]").val(b.NLNS).val();SN.C.I.NoticeDataGeo.NLID=a.find("[name=location_id]").val(b.NLID).val()}else{a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("")}}if(b=="disabled"){SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").prop("checked",false).prop("checked")}else{SN.C.I.NoticeDataGeo.NDG=a.find("[name=notice_data-geo]").prop("checked",true).prop("checked")}},GetResponseXML:function(b){try{return b.responseXML}catch(a){return(new DOMParser()).parseFromString(b.responseText,"text/xml")}},NoticeReply:function(){$(document).on("click","#content .notice_reply",function(b){b.preventDefault();var a=$(this).closest("li.notice");SN.U.NoticeInlineReplyTrigger(a);return false})},NoticeReplyTo:function(a){},NoticeInlineReplyTrigger:function(k,l){var b=$($(".notice_id",k)[0]).text();var m,j;var e=k;var g=true;var f=k.closest(".notices");if(f.closest(".old-school").length){SN.U.switchInputFormTab("status");m=$("#input_form_status").find("form");g=false}else{if(f.hasClass("threaded-replies")){e=f.closest(".notice");m=$(".notice-reply-form",f)}else{f=$("ul.threaded-replies",k);if(f.length==0){SN.U.NoticeInlineReplyPlaceholder(k);f=$("ul.threaded-replies",k)}else{j=$("li.notice-reply-placeholder",k);if(j.length==0){SN.U.NoticeInlineReplyPlaceholder(k)}}m=$(".notice-reply-form",f)}}var d=function(){m.find("input[name=inreplyto]").val(b);if(g){m.find("#notice_to").prop("disabled",true).hide();m.find("#notice_private").prop("disabled",true).hide();m.find("label[for=notice_to]").hide();m.find("label[for=notice_private]").hide()}var p=m.find("textarea");if(p.length==0){throw"No textarea"}var o="";if(l){o=l+" "}p.val(o+p.val().replace(new RegExp(o,"i"),""));p.data("initialText",$.trim(l));p.focus();if(p[0].setSelectionRange){var n=p.val().length;p[0].setSelectionRange(n,n)}};if(m.length>0){d()}else{j=f.find("li.notice-reply-placeholder").hide();var h=$("li.notice-reply",f);if(h.length==0){h=$('<li class="notice-reply"></li>');var c=function(n){var o=document._importNode(n,true);h.append(o);f.append(h);var p=$(o);m=p;SN.Init.NoticeFormSetup(p);d()};if(SN.C.I.NoticeFormMaster){c(SN.C.I.NoticeFormMaster)}else{var a=$("#form_notice").attr("action");$.get(a,{ajax:1},function(n,p,o){c($("form",n)[0])})}}}},NoticeInlineReplyPlaceholder:function(b){var a=b.find("ul.threaded-replies");if(a.length==0){a=$('<ul class="notices threaded-replies xoxo"></ul>');b.append(a);a=b.find("ul.threaded-replies")}var c=$('<li class="notice-reply-placeholder"><input class="placeholder" /></li>');c.find("input").val(SN.msg("reply_placeholder"));a.append(c)},NoticeInlineReplySetup:function(){$("li.notice-reply-placeholder input").on("focus",function(){var a=$(this).closest("li.notice");SN.U.NoticeInlineReplyTrigger(a);return false});$("li.notice-reply-comments a").on("click",function(){var a=$(this).attr("href");var b=$(this).closest(".threaded-replies");$.get(a,{ajax:1},function(d,f,e){var c=$(".threaded-replies",d);if(c.length){b.replaceWith(document._importNode(c[0],true))}});return false})},NoticeRepeat:function(){$(".form_repeat").on("click",function(a){a.preventDefault();SN.U.NoticeRepeatConfirmation($(this));return false})},NoticeRepeatConfirmation:function(a){var c=a.find(".submit");var b=c.clone();b.addClass("submit_dialogbox").removeClass("submit");a.append(b);b.on("click",function(){SN.U.FormXHR(a);return false});c.hide();a.addClass("dialogbox").append('<button class="close">&#215;</button>').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(c){var b;var a=c.find("input[type=file]");a.change(function(f){c.find(".attach-status").remove();var e=$(this).val();if(!e){return false}var d=$('<div class="attach-status '+SN.C.S.Success+'"><code></code> <button class="close">&#215;</button></div>');d.find("code").text(e);d.find("button").click(function(){d.remove();a.val("");return false});c.append(d);if(typeof this.files==="object"){for(b=0;b<this.files.length;b++){SN.U.PreviewAttach(c,this.files[b])}}})},maxFileSize:function(b){var a=$(b).find("input[name=MAX_FILE_SIZE]").attr("value");if(a){return parseInt(a)}return 0},PreviewAttach:function(d,c){var e=c.type+" "+Math.round(c.size/1024)+"KB";var f=true;var h;if(window.createObjectURL!==undefined){h=function(j,k){k(window.createObjectURL(j))}}else{if(window.FileReader!==undefined){h=function(k,l){var j=new FileReader();j.onload=function(m){l(j.result)};j.readAsDataURL(k)}}else{f=false}}var a=["image/png","image/jpeg","image/gif","image/svg+xml"];if($.inArray(c.type,a)==-1){f=false}var g=8*1024*1024;if(c.size>g){f=false}if(f){h(c,function(k){var j=$("<img>").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("<div></div>").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").prop("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,t,s;if(q.location_ns!==undefined){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(q.location_id!==undefined){a.find("[name=location_id]").val(q.location_id);t=q.location_id}if(q.name===undefined){s=p.lat+";"+p.lon}else{s=q.name}SN.U.NoticeGeoStatus(a,s,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+s+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(t);a.find("[name=notice_data-geo]").prop("checked",true);var u={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:t,NLN:s,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(u),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.prop("checked",false)}else{c.prop("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.prop("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").prop("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('<div class="'+SN.C.S.Success+' geo_status_wrapper"><button class="close" style="float:right">&#215;</button><div class="geo_status"></div></div>');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").prop("checked",false).change();return false});e.append(h)}var b;if(c){b=$("<a></a>").attr("href",c)}else{b=$("<span></span>")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.on("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('<button class="close">&#215;</button>');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()},showMoreMenuItems:function(c){$("#"+c+" .more_link").remove();var b="#"+c+" .extended_menu";var a=$(b);a.removeClass("extended_menu");return void (0)}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").on("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(document).on("click",".form_user_subscribe",function(){SN.U.FormXHR($(this));return false});$(document).on("click",".form_user_unsubscribe",function(){SN.U.FormXHR($(this));return false});$(document).on("click",".form_group_join",function(){SN.U.FormXHR($(this));return false});$(document).on("click",".form_group_leave",function(){SN.U.FormXHR($(this));return false});$(document).on("click",".form_user_nudge",function(){SN.U.FormXHR($(this));return false});$(document).on("click",".form_peopletag_subscribe",function(){SN.U.FormXHR($(this));return false});$(document).on("click",".form_peopletag_unsubscribe",function(){SN.U.FormXHR($(this));return false});$(document).on("click",".form_user_add_peopletag",function(){SN.U.FormXHR($(this));return false});$(document).on("click",".form_user_remove_peopletag",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(document).on("click",".form_peopletag_edit_user_search input.submit",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").on("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.on("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d='<a class="ptag-ac-line-tag">'+f.tag+' <em class="privacy_mode">'+f.mode+'</em><span class="freq">'+f.freq+"</span></a>";return $("<li/>").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('<button class="peopletags_edit_button"/>'));$(document).on("click",".peopletags_edit_button",function(){var a=$(this).parents("dd").eq(0).find("form");$.ajax({url:_peopletagAC,dataType:"json",data:{token:$("#token").val()},ifModified:true,success:function(b){for(i=0;i<b.length;i++){b[i].label=b[i].tag}SN.C.PtagACData=b;SN.Init.PeopletagAutocomplete(a.find("#tags"))}});$(this).parents("ul").eq(0).fadeOut(200,function(){a.fadeIn(200).find("input#tags")})});$(document).on("click",".user_profile_tags form .submit",function(){SN.U.FormPeopletagsXHR($(this).parents("form"));return false})},AjaxForms:function(){$(document).on("submit","form.ajax",function(){SN.U.FormXHR($(this));return false});$(document).on("click","form.ajax input[type=submit]",function(){var a=$(this);var b=a.closest("form");b.find(".hidden-submit-button").remove();$('<input class="hidden-submit-button" type="hidden" />').attr("name",a.attr("name")).val(a.val()).appendTo(b)})},UploadForms:function(){$("input[type=file]").change(function(d){if(typeof this.files==="object"&&this.files.length>0){var c=0;for(var b=0;b<this.files.length;b++){c+=this.files[b].size}var a=SN.U.maxFileSize($(this.form));if(a>0&&c>a){var e="File too large: maximum upload size is %d bytes.";alert(e.replace("%d",a));$(this).val("");d.preventDefault();return false}}})},CheckBoxes:function(){$("span[class='checkbox-wrapper']").addClass("unchecked");$(".checkbox-wrapper").click(function(){if($(this).children("input").prop("checked")){$(this).children("input").prop("checked",false);$(this).removeClass("checked");$(this).addClass("unchecked");$(this).children("label").text("Private?")}else{$(this).children("input").prop("checked",true);$(this).removeClass("unchecked");$(this).addClass("checked");$(this).children("label").text("Private")}})}}};$(function(){SN.Init.AjaxForms();SN.Init.UploadForms();SN.Init.CheckBoxes();if($("."+SN.C.S.FormNotice).length>0){SN.Init.NoticeForm()}if($("#content .notices").length>0){SN.Init.Notices()}if($("#content .entity_actions").length>0){SN.Init.EntityActions()}if($("#form_login").length>0){SN.Init.Login()}if($("#profile_search_results").length>0){SN.Init.ProfileSearch()}if($(".user_profile_tags .editable").length>0){SN.Init.PeopleTags()}});if(!document.ELEMENT_NODE){document.ELEMENT_NODE=1;document.ATTRIBUTE_NODE=2;document.TEXT_NODE=3;document.CDATA_SECTION_NODE=4;document.ENTITY_REFERENCE_NODE=5;document.ENTITY_NODE=6;document.PROCESSING_INSTRUCTION_NODE=7;document.COMMENT_NODE=8;document.DOCUMENT_NODE=9;document.DOCUMENT_TYPE_NODE=10;document.DOCUMENT_FRAGMENT_NODE=11;document.NOTATION_NODE=12}document._importNode=function(e,a){switch(e.nodeType){case document.ELEMENT_NODE:var d=document.createElement(e.nodeName);if(e.attributes&&e.attributes.length>0){for(var c=0,b=e.attributes.length;c<b;){if(e.attributes[c].nodeName=="class"){d.className=e.getAttribute(e.attributes[c++].nodeName)}else{d.setAttribute(e.attributes[c].nodeName,e.getAttribute(e.attributes[c++].nodeName))}}}if(a&&e.childNodes&&e.childNodes.length>0){for(var c=0,b=e.childNodes.length;c<b;){d.appendChild(document._importNode(e.childNodes[c++],a))}}return d;break;case document.TEXT_NODE:case document.CDATA_SECTION_NODE:case document.COMMENT_NODE:return document.createTextNode(e.nodeValue);break}};if(typeof navigator.geolocation=="undefined"||navigator.geolocation.shim){(function(){(function(){if(window.google&&google.gears){return}var c=null;if(typeof GearsFactory!="undefined"){c=new GearsFactory()}else{try{c=new ActiveXObject("Gears.Factory");if(c.getBuildInfo().indexOf("ie_mobile")!=-1){c.privateSetGlobalObject(this)}}catch(d){if((typeof navigator.mimeTypes!="undefined")&&navigator.mimeTypes["application/x-googlegears"]){c=document.createElement("object");c.style.display="none";c.width=0;c.height=0;c.type="application/x-googlegears";document.documentElement.appendChild(c)}}}if(!c){return}if(!window.google){google={}}if(!google.gears){google.gears={factory:c}}})();var a=(function(){var d=google.gears.factory.create("beta.geolocation");var c=function(f,e){return function(g){f(g);e.lastPosition=g}};return{shim:true,type:"Gears",lastPosition:null,getCurrentPosition:function(e,g,h){var f=this;var j=c(e,f);d.getCurrentPosition(j,g,h)},watchPosition:function(e,f,g){d.watchPosition(e,f,g)},clearWatch:function(e){d.clearWatch(e)},getPermission:function(g,e,f){d.getPermission(g,e,f)}}});var b=(function(){var j=false;var e=function(){if(!d()&&!j){j=true;var k=document.createElement("script");k.src=(document.location.protocol=="https:"?"https://":"http://")+"www.google.com/jsapi?callback=_google_loader_apiLoaded";k.type="text/javascript";document.getElementsByTagName("body")[0].appendChild(k)}};var c=[];var h=function(k){c.push(k)};var f=function(){if(d()){while(c.length>0){var k=c.pop();k()}}};window._google_loader_apiLoaded=function(){f()};var d=function(){return(window.google&&google.loader)};var g=function(k){if(d()){return true}h(k);e();return false};e();return{shim:true,type:"ClientLocation",lastPosition:null,getCurrentPosition:function(l,o,p){var n=this;if(!g(function(){n.getCurrentPosition(l,o,p)})){return}if(google.loader.ClientLocation){var m=google.loader.ClientLocation;var k={coords:{latitude:m.latitude,longitude:m.longitude,altitude:null,accuracy:43000,altitudeAccuracy:null,heading:null,speed:null},address:{city:m.address.city,country:m.address.country,country_code:m.address.country_code,region:m.address.region},timestamp:new Date()};l(k);this.lastPosition=k}else{if(o==="function"){o({code:3,message:"Using the Google ClientLocation API and it is not able to calculate a location."})}}},watchPosition:function(k,m,n){this.getCurrentPosition(k,m,n);var l=this;var o=setInterval(function(){l.getCurrentPosition(k,m,n)},10000);return o},clearWatch:function(k){clearInterval(k)},getPermission:function(m,k,l){return true}}});navigator.geolocation=(window.google&&google.gears)?a():b()})()};
\ No newline at end of file