~ubuntu-branches/ubuntu/karmic/xdaliclock/karmic

« back to all changes in this revision

Viewing changes to OSX/DaliClock.wdgt/DaliClock.js

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2007-12-02 11:28:00 UTC
  • mfrom: (1.1.4 upstream) (4.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20071202112800-347g6j06sgjp0s1f
Tags: 2.25-1
* New upstream release
* Do the menu transition: Apps/Tools -> Games/Toys
* Make use of Homepage control field

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// This file was generated by Dashcode from Apple Inc.
 
2
// You may edit this file to customize your Dashboard widget.
 
3
 
 
4
//
 
5
// Function: load()
 
6
// Called by HTML body element's onload event when the widget is ready to start
 
7
//
 
8
//window.DaliClock = undefined;
 
9
function load()
 
10
{
 
11
    setupParts();
 
12
        if (window.DaliClock) {
 
13
 
 
14
          // load preferences
 
15
          window.DaliClock.setDateStyle(widget.preferenceForKey(createInstancePreferenceKey("dateStyle")) || 0);
 
16
          window.DaliClock.setTimeStyle(widget.preferenceForKey(createInstancePreferenceKey("timeStyle")) || 0);
 
17
          window.DaliClock.setHourStyle(widget.preferenceForKey(createInstancePreferenceKey("hourStyle")) || 0);
 
18
 
 
19
        } else {
 
20
          showError ("Dali Clock widget plugin failed to load!");
 
21
        }
 
22
}
 
23
 
 
24
//
 
25
// Function: remove()
 
26
// Called when the widget has been removed from the Dashboard
 
27
//
 
28
function remove()
 
29
{
 
30
    // Stop any timers to prevent CPU usage
 
31
    // Remove any preferences as needed
 
32
    // widget.setPreferenceForKey(null, createInstancePreferenceKey("your-key"));
 
33
        if (window.DaliClock) {
 
34
          window.DaliClock.hide();
 
35
        }
 
36
}
 
37
 
 
38
//
 
39
// Function: hide()
 
40
// Called when the widget has been hidden
 
41
//
 
42
function hide()
 
43
{
 
44
    // Stop any timers to prevent CPU usage
 
45
  if (window.DaliClock) {
 
46
    window.DaliClock.hide();
 
47
  }
 
48
}
 
49
 
 
50
//
 
51
// Function: show()
 
52
// Called when the widget has been shown
 
53
//
 
54
function show()
 
55
{
 
56
    // Restart any timers that were stopped on hide
 
57
  if (window.DaliClock && front.style.display != "none") {
 
58
    var x = 12;
 
59
    var y = 28;
 
60
    var w = document.width  - (x*2);
 
61
    var h = document.height - (y*2);
 
62
    window.DaliClock.setFrame(new Array (x, y, w, h));
 
63
    window.DaliClock.show();
 
64
  }
 
65
}
 
66
 
 
67
//
 
68
// Function: sync()
 
69
// Called when the widget has been synchronized with .Mac
 
70
//
 
71
function sync()
 
72
{
 
73
    // Retrieve any preference values that you need to be synchronized here
 
74
    // Use this for an instance key's value:
 
75
    // instancePreferenceValue = widget.preferenceForKey(null, createInstancePreferenceKey("your-key"));
 
76
    //
 
77
    // Or this for global key's value:
 
78
    // globalPreferenceValue = widget.preferenceForKey(null, "your-key");
 
79
}
 
80
 
 
81
//
 
82
// Function: showBack(event)
 
83
// Called when the info button is clicked to show the back of the widget
 
84
//
 
85
// event: onClick event from the info button
 
86
//
 
87
function showBack(event)
 
88
{
 
89
    var front = document.getElementById("front");
 
90
    var back = document.getElementById("back");
 
91
 
 
92
    if (window.widget) {
 
93
        widget.prepareForTransition("ToBack");
 
94
    }
 
95
 
 
96
    front.style.display = "none";
 
97
    back.style.display = "block";
 
98
 
 
99
    if (window.widget) {
 
100
        setTimeout('widget.performTransition();', 0);
 
101
    }
 
102
        
 
103
    if (window.DaliClock) {
 
104
        window.DaliClock.hide();
 
105
        
 
106
        var d = window.DaliClock.dateStyle();
 
107
        var t = window.DaliClock.timeStyle();
 
108
        var h = window.DaliClock.hourStyle();
 
109
        document.getElementById("dateStyleMMDDYY").checked = (d == 0);
 
110
        document.getElementById("dateStyleDDMMYY").checked = (d == 1);
 
111
        document.getElementById("dateStyleYYMMDD").checked = (d == 2);
 
112
        document.getElementById("timeStyleHHMMSS").checked = (t == 0);
 
113
        document.getElementById("timeStyleHHMM").checked   = (t == 1);
 
114
        document.getElementById("timeStyleSS").checked     = (t == 2);
 
115
        document.getElementById("hourStyle12").checked     = (h == 0);
 
116
        document.getElementById("hourStyle24").checked     = (h == 1);
 
117
    }
 
118
}
 
119
 
 
120
//
 
121
// Function: showFront(event)
 
122
// Called when the done button is clicked from the back of the widget
 
123
//
 
124
// event: onClick event from the done button
 
125
//
 
126
function showFront(event)
 
127
{
 
128
    var front = document.getElementById("front");
 
129
    var back = document.getElementById("back");
 
130
 
 
131
    if (window.widget) {
 
132
        widget.prepareForTransition("ToFront");
 
133
    }
 
134
 
 
135
    front.style.display="block";
 
136
    back.style.display="none";
 
137
 
 
138
    if (window.widget) {
 
139
        setTimeout('widget.performTransition();', 0);
 
140
    }
 
141
        
 
142
    if (window.DaliClock) {
 
143
        window.DaliClock.setHourStyle(document.getElementById("hourStyle24").checked ? 1 : 0);
 
144
        window.DaliClock.setTimeStyle(document.getElementById("timeStyleSS").checked ? 2 :
 
145
                                                   document.getElementById("timeStyleHHMM").checked ? 1 : 0);
 
146
        window.DaliClock.setDateStyle(document.getElementById("dateStyleYYMMDD").checked ? 2 :
 
147
                                                   document.getElementById("dateStyleDDMMYY").checked ? 1 : 0);
 
148
 
 
149
        widget.setPreferenceForKey(window.DaliClock.dateStyle(), createInstancePreferenceKey("dateStyle"));
 
150
        widget.setPreferenceForKey(window.DaliClock.timeStyle(), createInstancePreferenceKey("timeStyle"));
 
151
        widget.setPreferenceForKey(window.DaliClock.hourStyle(), createInstancePreferenceKey("hourStyle"));
 
152
 
 
153
        window.DaliClock.show();
 
154
    }
 
155
}
 
156
 
 
157
function showError(error) {
 
158
        var errorDiv = document.getElementById("errorDiv");
 
159
        if (errorDiv.firstChild) {
 
160
                errorDiv.removeChild(errorDiv.firstChild);
 
161
        }
 
162
        errorDiv.appendChild(document.createTextNode(error));
 
163
        errorDiv.style.display = "block";
 
164
}
 
165
 
 
166
if (window.widget) {
 
167
    widget.onremove = remove;
 
168
    widget.onhide = hide;
 
169
    widget.onshow = show;
 
170
    widget.onsync = sync;
 
171
}