/[drupal]/contributions/modules/watchdog_live/watchdog_live.js
ViewVC logotype

Contents of /contributions/modules/watchdog_live/watchdog_live.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Tue Apr 21 14:17:16 2009 UTC (7 months ago) by naxoc
Branch: MAIN
CVS Tags: DRUPAL-6--1-0, HEAD
Changes since 1.2: +10 -7 lines
File MIME type: text/javascript
#369180 by nquocbao: Port to D6
1 // $Id: watchdog_live.js,v 1.2 2008/01/28 22:43:26 stevemckenzie Exp $
2
3 Drupal.watchdog = {
4 // Attach functionality.
5 autoAttach: function() {
6 // Grab settings.
7 Drupal.watchdog.interval = $('#edit-watchdog-live-interval').val();
8 Drupal.watchdog.disabled = $('#edit-watchdog-live-disabled').attr('checked') || 0;
9
10 // Interval setting.
11 $('#edit-watchdog-live-interval').bind('change', function(event) {
12 Drupal.watchdog.saveSetting('interval', this.value);
13 });
14
15 // Disabled state.
16 $('#edit-watchdog-live-disabled').bind('click', function(event) {
17 Drupal.watchdog.saveSetting('disabled', this.checked);
18 if (!this.checked) {
19 Drupal.watchdog.start();
20 }
21 });
22
23 // Handle updating.
24 Drupal.watchdog.start();
25 },
26
27 // Check callback for update and display new content if any.
28 load: function() {
29 $.get(Drupal.settings.watchdogLive.callback_url, function(data) {
30 var result = Drupal.parseJson(data);
31
32 // Only if we get content back.
33 if (result.content) {
34
35 var animated = false;
36 $('#dblog-filter-form').parent().children().not('#dblog-filter-form').fadeOut('fast', function() {
37 // Since we have multiple children, the callback will be called multiple times.
38 // Force a stop.
39 if (animated) {
40 return false;
41 }
42 animated = true;
43
44 // Remove old table.
45 $('#dblog-filter-form').parent().children().not('#dblog-filter-form').remove();
46
47 // Bring in new content.
48 $('#dblog-filter-form').parent().append(result.content);
49 $('#dblog-filter-form').parent().children().not('#dblog-filter-form').fadeIn('fast');
50 });
51 }
52
53 // Continue the loop.
54 Drupal.watchdog.start();
55 });
56 },
57
58 // Save a setting for the configurable options.
59 saveSetting: function(name, value) {
60 var setting = {};
61 setting[name] = value;
62 $.post(Drupal.settings.watchdogLive.setting_url, setting);
63 Drupal.watchdog[name] = value;
64 },
65
66 // Start the process.
67 start: function() {
68 if (!Drupal.watchdog.disabled) {
69 Drupal.watchdog.timeoutId = setTimeout(Drupal.watchdog.load, Drupal.watchdog.interval);
70 }
71 }
72
73 };
74
75 // Global Killswitch.
76 if (Drupal.jsEnabled) {
77 $(document).ready(Drupal.watchdog.autoAttach);
78 }

  ViewVC Help
Powered by ViewVC 1.1.2