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