]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - js/util.js
Add style function to output style() tags
[quix0rs-gnu-social.git] / js / util.js
index 8d99ca0ff6e07891a6af2ca1444732800f431ba3..73fcf37bee5482aa90d0126d72e5899d1a86e9a4 100644 (file)
@@ -185,7 +185,7 @@ var SN = { // StatusNet
                     $('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).removeClass(SN.C.S.Disabled);
                     $('#'+form_id+' #'+SN.C.S.NoticeActionSubmit).removeAttr(SN.C.S.Disabled, SN.C.S.Disabled);
                     if (textStatus == 'timeout') {
-                        alert ('Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists');
+                        form.append('<p class="error>Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.</p>');
                     }
                     else {
                         if ($('.'+SN.C.S.Error, xhr.responseXML).length > 0) {
@@ -193,7 +193,7 @@ var SN = { // StatusNet
                         }
                         else {
                             if(jQuery.inArray(parseInt(xhr.status), SN.C.I.HTTP20x30x) < 0) {
-                                alert('Sorry! We had trouble sending your notice ('+xhr.status+' '+xhr.statusText+'). Please report the problem to the site administrator if this happens again.');
+                                form.append('<p class="error>(Sorry! We had trouble sending your notice ('+xhr.status+' '+xhr.statusText+'). Please report the problem to the site administrator if this happens again.</p>');
                             }
                             else {
                                 $('#'+form_id+' #'+SN.C.S.NoticeDataText).val('');
@@ -205,8 +205,9 @@ var SN = { // StatusNet
                 success: function(data, textStatus) {
                     var result;
                     if ($('#'+SN.C.S.Error, data).length > 0) {
-                        result = document._importNode($('p', data)[0], true);
-                        alert(result.textContent || result.innerHTML);
+                        result = document._importNode($('p', data)[0], true);  
+                        result = result.textContent || result.innerHTML;
+                        form.append('<p class="error">'+result+'</p>');
                     }
                     else {
                         if($('body')[0].id == 'bookmarklet') {
@@ -215,28 +216,37 @@ var SN = { // StatusNet
 
                         if ($('#'+SN.C.S.CommandResult, data).length > 0) {
                             result = document._importNode($('p', data)[0], true);
-                            alert(result.textContent || result.innerHTML);
+                            result = result.textContent || result.innerHTML;
+                            form.append('<p class="success">'+result+'</p>');
                         }
                         else {
-                             notice = document._importNode($('li', data)[0], true);
-                             if ($('#'+notice.id).length === 0) {
-                                var notice_irt_value = $('#'+SN.C.S.NoticeInReplyTo).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) {
-                                        $(notice_irt).append('<ul class="notices"></ul>');
+                            var notices = $('#notices_primary .notices');
+                            if (notices.length > 0) {
+                                var notice = document._importNode($('li', data)[0], true);
+                                if ($('#'+notice.id).length === 0) {
+                                    var notice_irt_value = $('#'+SN.C.S.NoticeInReplyTo).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) {
+                                            $(notice_irt).append('<ul class="notices"></ul>');
+                                        }
+                                        $($(notice_irt+' .notices')[0]).append(notice);
                                     }
-                                    $($(notice_irt+' .notices')[0]).append(notice);
-                                }
-                                else {
-                                    $("#notices_primary .notices").prepend(notice);
+                                    else {
+                                        notices.prepend(notice);
+                                    }
+                                    $('#'+notice.id).css({display:'none'});
+                                    $('#'+notice.id).fadeIn(2500);
+                                    SN.U.NoticeWithAttachment($('#'+notice.id));
+                                    SN.U.NoticeReplyTo($('#'+notice.id));
+                                    SN.U.FormXHR($('#'+notice.id+' .form_favor'));
                                 }
-                                $('#'+notice.id).css({display:'none'});
-                                $('#'+notice.id).fadeIn(2500);
-                                SN.U.NoticeWithAttachment($('#'+notice.id));
-                                SN.U.NoticeReplyTo($('#'+notice.id));
-                                SN.U.FormXHR($('#'+notice.id+' .form_favor'));
-                             }
+                            }
+                            else {
+                                result = document._importNode($('title', data)[0], true);
+                                result_title = result.textContent || result.innerHTML;
+                                form.append('<p class="success">'+result_title+'</p>');
+                            }
                         }
                         $('#'+form_id+' #'+SN.C.S.NoticeDataText).val('');
                         $('#'+form_id+' #'+SN.C.S.NoticeDataAttach).val('');