~katiekitty/+junk/solidstate

« back to all changes in this revision

Viewing changes to solidstate/branches/v0.5 Alpha/solidworks/widgets/popupcalendar/calendar.html

  • Committer: root
  • Date: 2010-01-13 07:44:31 UTC
  • Revision ID: root@ds3-vamp.cs-monitor.cz.cc-20100113074431-kt8ceoeznpjg22x7
Reviving the project

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html>
 
2
  <head>
 
3
    <title>Date Selector</title>
 
4
    <script language="JavaScript">
 
5
// {{{ y2k()
 
6
 
 
7
function y2k(number)
 
8
{
 
9
    return (number < 1000) ? number + 1900 : number; 
 
10
}
 
11
 
 
12
// }}}
 
13
// {{{ _rgb2hex()
 
14
 
 
15
function _rgb2hex(red,green,blue) 
 
16
{
 
17
    var html_red = red.toString(16).toUpperCase();
 
18
    var html_green = green.toString(16).toUpperCase();
 
19
    var html_blue = blue.toString(16).toUpperCase();
 
20
    if (html_red.length == 1) {
 
21
        html_red = "0" + html_red
 
22
    }
 
23
 
 
24
    if (html_green.length == 1) {
 
25
        html_green = "0" + html_green
 
26
    }
 
27
 
 
28
    if (html_blue.length == 1) {
 
29
        html_blue = "0" + html_blue
 
30
    }
 
31
 
 
32
    return '#' + html_red + html_green + html_blue;
 
33
}
 
34
 
 
35
// }}}
 
36
// {{{ _hex2rgb()
 
37
 
 
38
function _hex2rgb(htmlcode) 
 
39
{
 
40
    var htmlcode = htmlcode.replace(/#/,'');
 
41
    var rgb = new Array();
 
42
    rgb["red"] = parseInt(htmlcode.substr(0,2),16);
 
43
    rgb["green"] = parseInt(htmlcode.substr(2,2),16);
 
44
    rgb["blue"] = parseInt(htmlcode.substr(4,2),16);
 
45
    return rgb;
 
46
}
 
47
 
 
48
// }}}
 
49
// {{{ getDarkColor()
 
50
 
 
51
function getDarkColor(htmlcode) 
 
52
{
 
53
    var decimalcolor = _hex2rgb(htmlcode);
 
54
    decimalcolor["red"] = Math.max(0,decimalcolor["red"]-40);
 
55
    decimalcolor["green"] = Math.max(0,decimalcolor["green"]-40);
 
56
    decimalcolor["blue"] = Math.max(0,decimalcolor["blue"]-40);
 
57
    return _rgb2hex(decimalcolor["red"],decimalcolor["green"],decimalcolor["blue"]);
 
58
}
 
59
 
 
60
// }}}
 
61
 
 
62
if (typeof(window.opener.calendarStartMonday) == 'undefined') {
 
63
    var calendarStartMonday = false;
 
64
}
 
65
else {
 
66
    var calendarStartMonday = window.opener.calendarStartMonday ? true : false;
 
67
}
 
68
 
 
69
// get the date format
 
70
if (typeof(window.opener.calendarFormat) == 'undefined') {
 
71
    var calendarFormat = 'y/m/d';
 
72
}
 
73
// we are doing on a leap of faith here that the user has 'm','d' and 'y' only in the format
 
74
else {
 
75
    var calendarFormat = window.opener.calendarFormat;
 
76
}
 
77
 
 
78
// get the calendarColors variable and setup the colors
 
79
if (typeof(window.opener.calendarColors) == 'undefined') {
 
80
    alert('Please configure the colors by setting the calendarColors array!');
 
81
    window.close();
 
82
}
 
83
 
 
84
// grab the color settings
 
85
var calendarColors = window.opener.calendarColors;
 
86
// set defaults for the selected date to be a darker color
 
87
if (typeof(calendarColors['dateSelectedBgColor']) == 'undefined') {
 
88
    calendarColors['dateSelectedBgColor'] = getDarkColor(calendarColors['dateBgColor']);
 
89
}
 
90
 
 
91
if (typeof(calendarColors['dateSelectedColor']) == 'undefined') {
 
92
    calendarColors['dateSelectedColor'] = calendarColors['dateColor'];
 
93
}
 
94
 
 
95
if (typeof(window.opener.calendarMonths) == 'undefined' || window.opener.calendarMonths.length != 12) {
 
96
    var calendarMonths = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
 
97
}
 
98
else {
 
99
    var calendarMonths = window.opener.calendarMonths;
 
100
}
 
101
 
 
102
if (typeof(window.opener.calendarWeekdays) == 'undefined' || window.opener.calendarWeekdays.length != 8) {
 
103
    // we have two sundays to accomodate for calendars starting on monday
 
104
    var calendarWeekdays = new Array('S', 'M', 'T', 'W', 'T', 'F', 'S', 'S');
 
105
}
 
106
else {
 
107
    var calendarWeekdays = window.opener.calendarWeekdays;
 
108
}
 
109
 
 
110
var calendarDays  = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
 
111
 
 
112
//images
 
113
var right_still = "arrows_r_still.gif"
 
114
var right_anim = "arrows_r_anim.gif"
 
115
var left_still = "arrows_l_still.gif"
 
116
var left_anim = "arrows_l_anim.gif"
 
117
 
 
118
// get the reference to the target element and setup the date
 
119
var targetDateField = window.opener.calendarTarget;
 
120
var dateString = targetDateField.value;
 
121
 
 
122
if (dateString != '' && 
 
123
   (typeof(window.opener.calendarUseToday) == 'undefined' || !window.opener.calendarUseToday)) {
 
124
    // convert the user format of the date into something we use to make a javascript Date object
 
125
    // we need to pad with placeholders to get the rigth offset
 
126
    tmp_format = calendarFormat.replace(/m/i, 'mm').replace(/d/i, 'dd').replace(/y/i, 'yyyy');
 
127
    tmp_yOffset = tmp_format.indexOf('y');
 
128
    tmp_mOffset = tmp_format.indexOf('m');
 
129
    tmp_dOffset = tmp_format.indexOf('d');
 
130
    var today = new Date(dateString.substring(tmp_yOffset, tmp_yOffset + 4), dateString.substring(tmp_mOffset, tmp_mOffset +
 
131
 2) - 1, dateString.substring(tmp_dOffset, tmp_dOffset + 2));
 
132
 
 
133
    if ((today == "Invalid Date") || (isNaN(today))) {
 
134
        var today = new Date();
 
135
    }
 
136
}
 
137
// use today's date
 
138
else {
 
139
    var today = new Date();
 
140
}
 
141
 
 
142
var day = today.getDate();
 
143
var year  = y2k(today.getYear());
 
144
var month = today.getMonth();
 
145
 
 
146
var currentDay = day;
 
147
var currentYear = year;
 
148
var currentMonth = month;
 
149
    </script>
 
150
  </head>
 
151
  <frameset frameborder="0" framespacing="0" ROWS="100%,*">
 
152
    <frame scrolling="no" frameborder="0" marginheight="0" marginwidth="0" name="cal" noresize src="calendar_body.html">
 
153
  </frameset>
 
154
</html>
 
155