]> git.mxchange.org Git - friendica.git/blob - include/main.js
mongo checkin, global directory, redir rework, location basics
[friendica.git] / include / main.js
1
2   function openClose(theID) {
3     if(document.getElementById(theID).style.display == "block") { 
4       document.getElementById(theID).style.display = "none" 
5     }
6     else { 
7       document.getElementById(theID).style.display = "block" 
8     } 
9   }
10
11   function openMenu(theID) {
12       document.getElementById(theID).style.display = "block" 
13   }
14
15   function closeMenu(theID) {
16       document.getElementById(theID).style.display = "none" 
17   }
18
19         function commentOpen(obj,id) {
20                 if(obj.value == 'Comment') {
21                         obj.value = '';
22                         obj.className = "comment-edit-text-full";
23                         openMenu("comment-edit-submit-wrapper-" + id);
24                 }
25         }
26         function commentClose(obj,id) {
27                 if(obj.value == '') {
28                         obj.value = 'Comment';
29                         obj.className="comment-edit-text-empty";
30                         closeMenu("comment-edit-submit-wrapper-" + id);
31                 }
32         }
33
34         var src = null;
35         var prev = null;
36         var livetime = null;
37         var msie = false;
38
39         $(document).ready(function() {
40                 $.ajaxSetup({cache: false});
41                 msie = $.browser.msie ;
42                 NavUpdate(); 
43
44
45
46         });
47
48         function NavUpdate() {
49
50                 if($('#live-network').length) { src = 'network'; liveUpdate(); }
51                 if($('#live-profile').length) { src = 'profile'; liveUpdate(); }
52
53                 $.get("ping",function(data) {
54                         $(data).find('result').each(function() {
55                                 var net = $(this).find('net').text();
56                                 if(net == 0) { net = ''; }
57                                 $('#net-update').html(net);
58                                 var home = $(this).find('home').text();
59                                 if(home == 0) { home = ''; }
60                                 $('#home-update').html(home);
61                                 var mail = $(this).find('mail').text();
62                                 if(mail == 0) { mail = ''; }
63                                 $('#mail-update').html(mail);
64                                 var intro = $(this).find('intro').text();
65                                 if(intro == 0) { intro = ''; }
66                                 $('#notify-update').html(intro);
67                         });
68                 }) ;
69                 setTimeout(NavUpdate,30000);
70
71         }
72
73         function liveUpdate() {
74                 if(src == null) { return; }
75                 if($('.comment-edit-text-full').length) {
76                         livetime = setTimeout(liveUpdate, 10000);
77                         return;
78                 }
79                 prev = 'live-' + src;
80
81                 $.get('update_' + src + '?msie=' + ((msie) ? 1 : 0),function(data) {
82                         $('.wall-item-outside-wrapper',data).each(function() {
83                                 var ident = $(this).attr('id');
84                                 if($('#' + ident).length == 0) { 
85                                         $('img',this).each(function() {
86                                                 $(this).attr('src',$(this).attr('dst'));
87                                         });
88                                         $('#' + prev).after($(this));
89                                 }
90                                 else { 
91
92                                         $('#' + ident + ' ' + '.wall-item-ago').replaceWith($(this).find('.wall-item-ago')); 
93                                         $('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper'));
94                                         $('#' + ident + ' ' + '.my-comment-photo').each(function() {
95                                                 $(this).attr('src',$(this).attr('dst'));
96                                         });
97
98
99                                 }
100                                 prev = ident; 
101                         });
102                 });
103
104         }
105
106         function confirmDelete() { 
107                 return confirm("Delete this item?");
108         }
109
110         function imgbright(node) {
111                 $(node).attr("src",$(node).attr("src").replace('hide','show'));
112                 $(node).css('width',24);
113                 $(node).css('height',24);
114         }
115
116         function imgdull(node) {
117                 $(node).attr("src",$(node).attr("src").replace('show','hide'));
118                 $(node).css('width',16);
119                 $(node).css('height',16);
120         }