diff --git a/actions/all.php b/actions/all.php
index 12397b4b18..2936df4599 100644
--- a/actions/all.php
+++ b/actions/all.php
@@ -58,9 +58,9 @@ class AllAction extends ProfileAction
$cur = common_current_user();
if (!empty($cur) && $cur->id == $this->user->id) {
- $this->notice = $this->user->noticeInbox(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
+ $this->notice = $this->user->noticeInboxThreaded(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
} else {
- $this->notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
+ $this->notice = $this->user->noticesWithFriendsThreaded(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
}
if ($this->page > 1 && $this->notice->N == 0) {
diff --git a/classes/Inbox.php b/classes/Inbox.php
index a1ab6215fd..f0f626a24e 100644
--- a/classes/Inbox.php
+++ b/classes/Inbox.php
@@ -197,6 +197,70 @@ class Inbox extends Memcached_DataObject
return $ids;
}
+ /**
+ * Wrapper for Inbox::stream() and Notice::getStreamByIds() returning
+ * additional items up to the limit if we were short due to deleted
+ * notices still being listed in the inbox.
+ *
+ * This is meant to assist threaded views, and optimizes paging for
+ * threadness. Not ideal for very late pages, as we have to bump about
+ * through all previous items.
+ *
+ * Should avoid duplicates in paging, though.
+ *
+ * @param int $user_id
+ * @param int $offset skip past the most recent N notices (after since_id checks)
+ * @param int $limit
+ * @param mixed $since_id return only notices after but not including this id
+ * @param mixed $max_id return only notices up to and including this id
+ * @param mixed $own ignored?
+ * @return array of Notice objects
+ *
+ * @todo consider repacking the inbox when this happens?
+ * @fixme reimplement $own if we need it?
+ */
+ function streamNoticesThreaded($user_id, $offset, $limit, $since_id, $max_id, $own=false)
+ {
+ // So what we want is:
+ // * slurp in the beginning of the notice list
+ // * filter out deleted notices
+ // * replace any reply notices with their conversation roots
+ // * filter out any duplicate conversations
+ // * return $limit notices after skipping $offset from the most recent
+
+ $ids = self::stream($user_id, 0, self::MAX_NOTICES, $since_id, $max_id, $own);
+
+ // Do a bulk lookup for the first $limit items
+ // Fast path when nothing's deleted.
+ $firstChunk = array_slice($ids, 0, $offset + $limit);
+ $notices = Notice::getStreamByIds($firstChunk);
+
+ assert($notices instanceof ArrayWrapper);
+ $items = $notices->_items;
+
+ // Extract the latest non-deleted item in each convo
+ $noticeByConvo = array();
+ foreach ($items as $notice) {
+ if (empty($noticeByConvo[$notice->conversation])) {
+ $noticeByConvo[$notice->conversation] = $notice;
+ }
+ }
+
+ $wanted = count($firstChunk); // raw entry count in the inbox up to our $limit
+ // There were deleted notices, we'll need to look for more.
+ $remainder = array_slice($ids, $limit);
+
+ for ($i = $offset + $limit; count($noticeByConvo) < $wanted && $i < count($ids); $i++) {
+ $notice = Notice::staticGet($ids[$i]);
+ if ($notice && empty($noticeByConvo[$notice->conversation])) {
+ $noticeByConvo[$notice->conversation] = $notice;
+ }
+ }
+
+ $slice = array_slice($noticeByConvo, $offset, $limit, false);
+ return new ArrayWrapper($slice);
+ }
+
/**
* Wrapper for Inbox::stream() and Notice::getStreamByIds() returning
* additional items up to the limit if we were short due to deleted
diff --git a/classes/User.php b/classes/User.php
index 962714aa4d..970e167a3b 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -471,11 +471,21 @@ class User extends Memcached_DataObject
return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, false);
}
+ function noticesWithFriendsThreaded($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
+ {
+ return Inbox::streamNoticesThreaded($this->id, $offset, $limit, $since_id, $before_id, false);
+ }
+
function noticeInbox($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
{
return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, true);
}
+ function noticeInboxThreaded($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
+ {
+ return Inbox::streamNoticesThreaded($this->id, $offset, $limit, $since_id, $before_id, true);
+ }
+
function friendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0)
{
return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, false);
diff --git a/js/util.js b/js/util.js
index b78d5deca7..4868519228 100644
--- a/js/util.js
+++ b/js/util.js
@@ -450,7 +450,7 @@ var SN = { // StatusNet
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');
+ var notices = $('#notices_primary .notices:first');
if (notices.length > 0 && SN.U.belongsOnTimeline(notice)) {
if ($('#'+notice.id).length === 0) {
var notice_irt_value = $('#'+SN.C.S.NoticeInReplyTo).val();
diff --git a/js/util.min.js b/js/util.min.js
index 0ba253e6db..88736d1e8a 100644
--- a/js/util.min.js
+++ b/js/util.min.js
@@ -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]},S:{Disabled:"disabled",Warning:"warning",Error:"error",Success:"success",Processing:"processing",CommandResult:"command_result",FormNotice:"form_notice",NoticeDataText:"notice_data-text",NoticeTextCount:"notice_text-count",NoticeInReplyTo:"notice_in-reply-to",NoticeDataAttach:"notice_data-attach",NoticeDataAttachSelected:"notice_data-attach_selected",NoticeActionSubmit:"notice_action-submit",NoticeLat:"notice_data-lat",NoticeLon:"notice_data-lon",NoticeLocationId:"notice_data-location_id",NoticeLocationNs:"notice_data-location_ns",NoticeGeoName:"notice_data-geo_name",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("#"+SN.C.S.NoticeTextCount).text();if(typeof(MaxLength)=="undefined"){MaxLength=SN.C.I.MaxLength}jQuery.data(b[0],"ElementData",{MaxLength:MaxLength});SN.U.Counter(b);NDT=b.find("#"+SN.C.S.NoticeDataText);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);NDT.bind("keydown",function(c){SN.U.SubmitOnReturn(c,b)})}else{b.find("#"+SN.C.S.NoticeTextCount).text(jQuery.data(b[0],"ElementData").MaxLength)}if($("body")[0].id!="conversation"&&window.location.hash.length===0&&$(window).scrollTop()==0){b.find("textarea").focus()}},SubmitOnReturn:function(b,a){if(b.keyCode==13||b.keyCode==10){a.submit();b.preventDefault();b.stopPropagation();$("#"+a[0].id+" #"+SN.C.S.NoticeDataText).blur();$("body").focus();return false}return true},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("#"+SN.C.S.NoticeTextCount);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("#"+SN.C.S.NoticeDataText).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){$.ajax({type:"POST",dataType:"xml",url:SN.U.RewriteAjaxAction(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(b,c){if(typeof($("form",b)[0])!="undefined"){form_new=document._importNode($("form",b)[0],true);a.replaceWith(form_new)}else{a.replaceWith(document._importNode($("p",b)[0],true))}}})},FormNoticeXHR:function(b){SN.C.I.NoticeDataGeo={};b.append('');b.attr("action",SN.U.RewriteAjaxAction(b.attr("action")));var c=function(d,e){b.append($('
').addClass(d).text(e))};var a=function(){b.find(".form_response").remove()};b.ajaxForm({dataType:"xml",timeout:"60000",beforeSend:function(d){if(b.find("#"+SN.C.S.NoticeDataText)[0].value.length===0){b.addClass(SN.C.S.Warning);return false}b.addClass(SN.C.S.Processing).find("#"+SN.C.S.NoticeActionSubmit).addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled);SN.C.I.NoticeDataGeo.NLat=$("#"+SN.C.S.NoticeLat).val();SN.C.I.NoticeDataGeo.NLon=$("#"+SN.C.S.NoticeLon).val();SN.C.I.NoticeDataGeo.NLNS=$("#"+SN.C.S.NoticeLocationNs).val();SN.C.I.NoticeDataGeo.NLID=$("#"+SN.C.S.NoticeLocationId).val();SN.C.I.NoticeDataGeo.NDG=$("#"+SN.C.S.NoticeDataGeo).attr("checked");cookieValue=$.cookie(SN.C.S.NoticeDataGeoCookie);if(cookieValue!==null&&cookieValue!="disabled"){cookieValue=JSON.parse(cookieValue);SN.C.I.NoticeDataGeo.NLat=$("#"+SN.C.S.NoticeLat).val(cookieValue.NLat).val();SN.C.I.NoticeDataGeo.NLon=$("#"+SN.C.S.NoticeLon).val(cookieValue.NLon).val();if($("#"+SN.C.S.NoticeLocationNs).val(cookieValue.NLNS)){SN.C.I.NoticeDataGeo.NLNS=$("#"+SN.C.S.NoticeLocationNs).val(cookieValue.NLNS).val();SN.C.I.NoticeDataGeo.NLID=$("#"+SN.C.S.NoticeLocationId).val(cookieValue.NLID).val()}}if(cookieValue=="disabled"){SN.C.I.NoticeDataGeo.NDG=$("#"+SN.C.S.NoticeDataGeo).attr("checked",false).attr("checked")}else{SN.C.I.NoticeDataGeo.NDG=$("#"+SN.C.S.NoticeDataGeo).attr("checked",true).attr("checked")}return true},error:function(f,g,e){b.removeClass(SN.C.S.Processing).find("#"+SN.C.S.NoticeActionSubmit).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("#"+SN.C.S.NoticeDataAttachSelected).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(i,k){a();var e=$("#"+SN.C.S.Error,i);if(e.length>0){c("error",e.text())}else{if($("body")[0].id=="bookmarklet"){self.close()}var d=$("#"+SN.C.S.CommandResult,i);if(d.length>0){c("success",d.text())}else{var h=document._importNode($("li",i)[0],true);var j=$("#notices_primary .notices");if(j.length>0&&SN.U.belongsOnTimeline(h)){if($("#"+h.id).length===0){var f=$("#"+SN.C.S.NoticeInReplyTo).val();var g="#notices_primary #notice-"+f;if($("body")[0].id=="conversation"){if(f.length>0&&$(g+" .notices").length<1){$(g).append('
';NDAS=$("#"+SN.C.S.NoticeDataAttachSelected);if(NDAS.length>0){NDAS.replaceWith(S)}else{$("#"+SN.C.S.FormNotice).append(S)}$("#"+SN.C.S.NoticeDataAttachSelected+" button").click(function(){$("#"+SN.C.S.NoticeDataAttachSelected).remove();NDA.val("");return false});if(typeof this.files=="object"){for(var b=0;bf){e=false}if(e){g(c,function(i){var h=$("").attr("title",d).attr("alt",d).attr("src",i).attr("style","height: 120px");$("#"+SN.C.S.NoticeDataAttachSelected).append(h)})}else{var b=$("").text(d);$("#"+SN.C.S.NoticeDataAttachSelected).append(b)}},NoticeLocationAttach:function(){var c=$("#"+SN.C.S.NoticeLat).val();var h=$("#"+SN.C.S.NoticeLon).val();var d=$("#"+SN.C.S.NoticeLocationNs).val();var i=$("#"+SN.C.S.NoticeLocationId).val();var a=$("#"+SN.C.S.NoticeGeoName).text();var b=$("#"+SN.C.S.NoticeDataGeo);function e(){$("label[for="+SN.C.S.NoticeDataGeo+"]").attr("title",jQuery.trim($("label[for="+SN.C.S.NoticeDataGeo+"]").text())).removeClass("checked");$("#"+SN.C.S.NoticeLat).val("");$("#"+SN.C.S.NoticeLon).val("");$("#"+SN.C.S.NoticeLocationNs).val("");$("#"+SN.C.S.NoticeLocationId).val("");$("#"+SN.C.S.NoticeDataGeo).attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"})}function j(k,l){$.getJSON(k,l,function(m){var n,o;if(typeof(m.location_ns)!="undefined"){$("#"+SN.C.S.NoticeLocationNs).val(m.location_ns);n=m.location_ns}if(typeof(m.location_id)!="undefined"){$("#"+SN.C.S.NoticeLocationId).val(m.location_id);o=m.location_id}if(typeof(m.name)=="undefined"){NLN_text=l.lat+";"+l.lon}else{NLN_text=m.name}$("label[for="+SN.C.S.NoticeDataGeo+"]").attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");$("#"+SN.C.S.NoticeLat).val(l.lat);$("#"+SN.C.S.NoticeLon).val(l.lon);$("#"+SN.C.S.NoticeLocationNs).val(n);$("#"+SN.C.S.NoticeLocationId).val(o);$("#"+SN.C.S.NoticeDataGeo).attr("checked",true);var p={NLat:l.lat,NLon:l.lon,NLNS:n,NLID:o,NLN:NLN_text,NLNU:m.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(p),{path:"/"})})}if(b.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){b.attr("checked",false)}else{b.attr("checked",true)}var f=$("#notice_data-geo_wrap");var g=f.attr("title");f.removeAttr("title");$("label[for="+SN.C.S.NoticeDataGeo+"]").attr("title",jQuery.trim($("label[for="+SN.C.S.NoticeDataGeo+"]").text()));b.change(function(){if($("#"+SN.C.S.NoticeDataGeo).attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){$("label[for="+SN.C.S.NoticeDataGeo+"]").attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(m){$("#"+SN.C.S.NoticeLat).val(m.coords.latitude);$("#"+SN.C.S.NoticeLon).val(m.coords.longitude);var n={lat:m.coords.latitude,lon:m.coords.longitude,token:$("#token").val()};j(g,n)},function(m){switch(m.code){case m.PERMISSION_DENIED:e();break;case m.TIMEOUT:$("#"+SN.C.S.NoticeDataGeo).attr("checked",false);break}},{timeout:10000})}else{if(c.length>0&&h.length>0){var k={lat:c,lon:h,token:$("#token").val()};j(g,k)}else{e();$("#"+SN.C.S.NoticeDataGeo).remove();$("label[for="+SN.C.S.NoticeDataGeo+"]").remove()}}}else{var l=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));$("#"+SN.C.S.NoticeLat).val(l.NLat);$("#"+SN.C.S.NoticeLon).val(l.NLon);$("#"+SN.C.S.NoticeLocationNs).val(l.NLNS);$("#"+SN.C.S.NoticeLocationId).val(l.NLID);$("#"+SN.C.S.NoticeDataGeo).attr("checked",l.NDG);$("label[for="+SN.C.S.NoticeDataGeo+"]").attr("title",NoticeDataGeo_text.ShareDisable+" ("+l.NLN+")").addClass("checked")}}else{e()}}).change()}},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('');$(".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(".entry-title .author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false}},Init:{NoticeForm:function(){if($("body.user_in").length>0){SN.U.NoticeLocationAttach();$("."+SN.C.S.FormNotice).each(function(){SN.U.FormNoticeXHR($(this));SN.U.FormNoticeEnhancements($(this))});SN.U.NoticeDataAttach()}},Notices:function(){if($("body.user_in").length>0){SN.U.NoticeFavor();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});SN.U.NewDirectMessage()}},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})},UploadForms:function(){$("input[type=file]").change(function(d){if(typeof this.files=="object"&&this.files.length>0){var c=0;for(var b=0;b0&&c>a){var e="File too large: maximum upload size is %d bytes.";alert(e.replace("%d",a));$(this).val("");d.preventDefault();return false}}})}}};$(document).ready(function(){SN.Init.UploadForms();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(!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;c0){for(var c=0,b=e.childNodes.length;c0){var j=c.pop();j()}}};window._google_loader_apiLoaded=function(){f()};var d=function(){return(window.google&&google.loader)};var g=function(j){if(d()){return true}h(j);e();return false};e();return{shim:true,type:"ClientLocation",lastPosition:null,getCurrentPosition:function(k,n,o){var m=this;if(!g(function(){m.getCurrentPosition(k,n,o)})){return}if(google.loader.ClientLocation){var l=google.loader.ClientLocation;var j={coords:{latitude:l.latitude,longitude:l.longitude,altitude:null,accuracy:43000,altitudeAccuracy:null,heading:null,speed:null},address:{city:l.address.city,country:l.address.country,country_code:l.address.country_code,region:l.address.region},timestamp:new Date()};k(j);this.lastPosition=j}else{if(n==="function"){n({code:3,message:"Using the Google ClientLocation API and it is not able to calculate a location."})}}},watchPosition:function(j,l,m){this.getCurrentPosition(j,l,m);var k=this;var n=setInterval(function(){k.getCurrentPosition(j,l,m)},10000);return n},clearWatch:function(j){clearInterval(j)},getPermission:function(l,j,k){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]},S:{Disabled:"disabled",Warning:"warning",Error:"error",Success:"success",Processing:"processing",CommandResult:"command_result",FormNotice:"form_notice",NoticeDataText:"notice_data-text",NoticeTextCount:"notice_text-count",NoticeInReplyTo:"notice_in-reply-to",NoticeDataAttach:"notice_data-attach",NoticeDataAttachSelected:"notice_data-attach_selected",NoticeActionSubmit:"notice_action-submit",NoticeLat:"notice_data-lat",NoticeLon:"notice_data-lon",NoticeLocationId:"notice_data-location_id",NoticeLocationNs:"notice_data-location_ns",NoticeGeoName:"notice_data-geo_name",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("#"+SN.C.S.NoticeTextCount).text();if(typeof(MaxLength)=="undefined"){MaxLength=SN.C.I.MaxLength}jQuery.data(b[0],"ElementData",{MaxLength:MaxLength});SN.U.Counter(b);NDT=b.find("#"+SN.C.S.NoticeDataText);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);NDT.bind("keydown",function(c){SN.U.SubmitOnReturn(c,b)})}else{b.find("#"+SN.C.S.NoticeTextCount).text(jQuery.data(b[0],"ElementData").MaxLength)}if($("body")[0].id!="conversation"&&window.location.hash.length===0&&$(window).scrollTop()==0){b.find("textarea").focus()}},SubmitOnReturn:function(b,a){if(b.keyCode==13||b.keyCode==10){a.submit();b.preventDefault();b.stopPropagation();$("#"+a[0].id+" #"+SN.C.S.NoticeDataText).blur();$("body").focus();return false}return true},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("#"+SN.C.S.NoticeTextCount);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("#"+SN.C.S.NoticeDataText).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){$.ajax({type:"POST",dataType:"xml",url:SN.U.RewriteAjaxAction(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(b,c){if(typeof($("form",b)[0])!="undefined"){form_new=document._importNode($("form",b)[0],true);a.replaceWith(form_new)}else{a.replaceWith(document._importNode($("p",b)[0],true))}}})},FormNoticeXHR:function(b){SN.C.I.NoticeDataGeo={};b.append('');b.attr("action",SN.U.RewriteAjaxAction(b.attr("action")));var c=function(d,e){b.append($('').addClass(d).text(e))};var a=function(){b.find(".form_response").remove()};b.ajaxForm({dataType:"xml",timeout:"60000",beforeSend:function(d){if(b.find("#"+SN.C.S.NoticeDataText)[0].value.length===0){b.addClass(SN.C.S.Warning);return false}b.addClass(SN.C.S.Processing).find("#"+SN.C.S.NoticeActionSubmit).addClass(SN.C.S.Disabled).attr(SN.C.S.Disabled,SN.C.S.Disabled);SN.C.I.NoticeDataGeo.NLat=$("#"+SN.C.S.NoticeLat).val();SN.C.I.NoticeDataGeo.NLon=$("#"+SN.C.S.NoticeLon).val();SN.C.I.NoticeDataGeo.NLNS=$("#"+SN.C.S.NoticeLocationNs).val();SN.C.I.NoticeDataGeo.NLID=$("#"+SN.C.S.NoticeLocationId).val();SN.C.I.NoticeDataGeo.NDG=$("#"+SN.C.S.NoticeDataGeo).attr("checked");cookieValue=$.cookie(SN.C.S.NoticeDataGeoCookie);if(cookieValue!==null&&cookieValue!="disabled"){cookieValue=JSON.parse(cookieValue);SN.C.I.NoticeDataGeo.NLat=$("#"+SN.C.S.NoticeLat).val(cookieValue.NLat).val();SN.C.I.NoticeDataGeo.NLon=$("#"+SN.C.S.NoticeLon).val(cookieValue.NLon).val();if($("#"+SN.C.S.NoticeLocationNs).val(cookieValue.NLNS)){SN.C.I.NoticeDataGeo.NLNS=$("#"+SN.C.S.NoticeLocationNs).val(cookieValue.NLNS).val();SN.C.I.NoticeDataGeo.NLID=$("#"+SN.C.S.NoticeLocationId).val(cookieValue.NLID).val()}}if(cookieValue=="disabled"){SN.C.I.NoticeDataGeo.NDG=$("#"+SN.C.S.NoticeDataGeo).attr("checked",false).attr("checked")}else{SN.C.I.NoticeDataGeo.NDG=$("#"+SN.C.S.NoticeDataGeo).attr("checked",true).attr("checked")}return true},error:function(f,g,e){b.removeClass(SN.C.S.Processing).find("#"+SN.C.S.NoticeActionSubmit).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("#"+SN.C.S.NoticeDataAttachSelected).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(i,k){a();var e=$("#"+SN.C.S.Error,i);if(e.length>0){c("error",e.text())}else{if($("body")[0].id=="bookmarklet"){self.close()}var d=$("#"+SN.C.S.CommandResult,i);if(d.length>0){c("success",d.text())}else{var h=document._importNode($("li",i)[0],true);var j=$("#notices_primary .notices:first");if(j.length>0&&SN.U.belongsOnTimeline(h)){if($("#"+h.id).length===0){var f=$("#"+SN.C.S.NoticeInReplyTo).val();var g="#notices_primary #notice-"+f;if($("body")[0].id=="conversation"){if(f.length>0&&$(g+" .notices").length<1){$(g).append('