]> git.mxchange.org Git - friendica.git/blob - include/main.js
show members of locked conversations
[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
20         var src = null;
21         var prev = null;
22         var livetime = null;
23         var msie = false;
24         var stopped = false;
25         var timer = null;
26         var pr = 0;
27
28         $(document).ready(function() {
29                 $.ajaxSetup({cache: false});
30                 msie = $.browser.msie ;
31                 NavUpdate(); 
32                 sparkler();
33                 // Allow folks to stop the ajax page updates with the pause/break key
34                 $(document).keypress(function(event) {
35                         if(event.keyCode == '19') {
36                                 event.preventDefault();
37                                 if(stopped == false) {
38                                         stopped = true;
39                                         $('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
40                                 }
41                                 else {
42                                         stopped = false;
43                                         $('#pause').html('');
44                                 }
45                         }
46                 });                                     
47         });
48
49         var spark = false;
50         function sparkler() {
51                 if(spark) { 
52                         $('.sparkle').css({cursor: 'pointer'});
53                         spark = false;
54                 }
55                 else {
56                         $('.sparkle').css({cursor: 'crosshair'});
57                         spark = true;
58                 }
59                 setTimeout(sparkler,500);
60         }
61         
62
63         function NavUpdate() {
64
65                 if($('#live-network').length) { src = 'network'; liveUpdate(); }
66                 if($('#live-profile').length) { src = 'profile'; liveUpdate(); }
67
68                 if(! stopped) {
69                         $.get("ping",function(data) {
70                                 $(data).find('result').each(function() {
71                                         var net = $(this).find('net').text();
72                                         if(net == 0) { net = ''; }
73                                         $('#net-update').html(net);
74                                         var home = $(this).find('home').text();
75                                         if(home == 0) { home = ''; }
76                                         $('#home-update').html(home);
77                                         var mail = $(this).find('mail').text();
78                                         if(mail == 0) { mail = ''; }
79                                         $('#mail-update').html(mail);
80                                         var intro = $(this).find('intro').text();
81                                         if(intro == 0) { intro = ''; }
82                                         $('#notify-update').html(intro);
83                                 });
84                         }) ;
85                 }
86                 timer = setTimeout(NavUpdate,30000);
87
88         }
89
90         function liveUpdate() {
91                 if((src == null) || (stopped) || (! profile_uid)) { $('.like-rotator').hide(); return; }
92                 if($('.comment-edit-text-full').length) {
93                         livetime = setTimeout(liveUpdate, 10000);
94                         return;
95                 }
96                 prev = 'live-' + src;
97
98                 $.get('update_' + src + '?p=' + profile_uid + '&msie=' + ((msie) ? 1 : 0),function(data) {
99                         $('.wall-item-outside-wrapper',data).each(function() {
100                                 var ident = $(this).attr('id');
101                                 if($('#' + ident).length == 0) { 
102                                         $('img',this).each(function() {
103                                                 $(this).attr('src',$(this).attr('dst'));
104                                         });
105                                         $('#' + prev).after($(this));
106                                 }
107                                 else { 
108
109                                         $('#' + ident + ' ' + '.wall-item-ago').replaceWith($(this).find('.wall-item-ago')); 
110                                         $('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper'));
111                                         $('#' + ident + ' ' + '.wall-item-like').replaceWith($(this).find('.wall-item-like'));
112                                         $('#' + ident + ' ' + '.wall-item-dislike').replaceWith($(this).find('.wall-item-dislike'));
113                                         $('#' + ident + ' ' + '.my-comment-photo').each(function() {
114                                                 $(this).attr('src',$(this).attr('dst'));
115                                         });
116
117
118                                 }
119                                 prev = ident; 
120                         });
121                         $('.like-rotator').hide();
122                 });
123
124         }
125
126         function imgbright(node) {
127                 $(node).attr("src",$(node).attr("src").replace('hide','show'));
128                 $(node).css('width',24);
129                 $(node).css('height',24);
130         }
131
132         function imgdull(node) {
133                 $(node).attr("src",$(node).attr("src").replace('show','hide'));
134                 $(node).css('width',16);
135                 $(node).css('height',16);
136         }
137
138         // Since our ajax calls are asynchronous, we will give a few 
139         // seconds for the first ajax call (setting like/dislike), then 
140         // run the updater to pick up any changes and display on the page.
141         // The updater will turn any rotators off when it's done. 
142         // This function will have returned long before any of these
143         // events have completed and therefore there won't be any
144         // visible feedback that anything changed without all this
145         // trickery. This still could cause confusion if the "like" ajax call
146         // is delayed and NavUpdate runs before it completes.
147
148         function dolike(ident,verb) {
149                 $('#like-rotator-' + ident.toString()).show();
150                 $.get('like/' + ident.toString() + '?verb=' + verb );
151                 if(timer) clearTimeout(timer);
152                 timer = setTimeout(NavUpdate,3000);
153         }
154
155         function getPosition(e) {
156                 e = e || window.event;
157                 var cursor = {x:0, y:0};
158                 if ( e.pageX > 0 || e.pageY > 0 ) {
159                         cursor.x = e.pageX;
160                         cursor.y = e.pageY;
161                 }
162                 else {
163                         if( e.clientX > 0 || e.clientY > 0 ) {
164                                 cursor.x = e.clientX;
165                                 cursor.y = e.clientY;
166                         }
167                         else {
168                                 if( e.x > 0 || e.y > 0 ) {
169                                         cursor.x = e.x;
170                                         cursor.y = e.y;
171                                 }
172                         }
173                 }
174                 return cursor;
175         }
176
177         var lockvisible = false;
178
179         function lockview(event,id) {
180                 if(lockvisible) {
181                         lockviewhide();
182                 }
183                 else {
184                         lockvisible = true;
185                         $.get('lockview/' + id, function(data) {
186                                 cursor = getPosition(event);
187                                 $('#panel').html(data);
188                                 $('#panel').css({ 'left': cursor.x + 5 , 'top': cursor.y + 5});
189                                 $('#panel').show();
190                         });
191                 }
192         }
193
194         function lockviewhide() {
195                 lockvisible = false;
196                 $('#panel').hide();
197         }
198