summaryrefslogtreecommitdiff
path: root/js/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/util.js')
-rw-r--r--js/util.js49
1 files changed, 48 insertions, 1 deletions
diff --git a/js/util.js b/js/util.js
index 3623337b9..4b6c39a1d 100644
--- a/js/util.js
+++ b/js/util.js
@@ -54,7 +54,8 @@ var SN = { // StatusNet
NoticeGeoName: 'notice_data-geo_name',
NoticeDataGeo: 'notice_data-geo',
NoticeDataGeoCookie: 'notice_data-geo_cookie',
- NoticeDataGeoSelected: 'notice_data-geo_selected'
+ NoticeDataGeoSelected: 'notice_data-geo_selected',
+ StatusNetInstance:'StatusNetInstance'
}
},
@@ -670,6 +671,35 @@ var SN = { // StatusNet
date.setFullYear(year, month, day);
return date;
+ },
+
+ StatusNetInstance: {
+ Set: function(value) {
+ var SNI = SN.U.StatusNetInstance.Get();
+ if (SNI !== null) {
+ value = $.extend(SNI, value);
+ }
+
+ $.cookie(
+ SN.C.S.StatusNetInstance,
+ JSON.stringify(value),
+ {
+ path: '/',
+ expires: SN.U.GetFullYear(2029, 0, 1)
+ });
+ },
+
+ Get: function() {
+ var cookieValue = $.cookie(SN.C.S.StatusNetInstance);
+ if (cookieValue !== null) {
+ return JSON.parse(cookieValue);
+ }
+ return null;
+ },
+
+ Delete: function() {
+ $.cookie(SN.C.S.StatusNetInstance, null);
+ }
}
},
@@ -707,6 +737,20 @@ var SN = { // StatusNet
SN.U.NewDirectMessage();
}
+ },
+
+ Login: function() {
+ if (SN.U.StatusNetInstance.Get() !== null) {
+ var nickname = SN.U.StatusNetInstance.Get().Nickname;
+ if (nickname !== null) {
+ $('#form_login #nickname').val(nickname);
+ }
+ }
+
+ $('#form_login').bind('submit', function() {
+ SN.U.StatusNetInstance.Set({Nickname: $('#form_login #nickname').val()});
+ return true;
+ });
}
}
};
@@ -721,5 +765,8 @@ $(document).ready(function(){
if ($('#content .entity_actions').length > 0) {
SN.Init.EntityActions();
}
+ if ($('#form_login').length > 0) {
+ SN.Init.Login();
+ }
});