-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.html
249 lines (231 loc) · 9.96 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Hijri/Gregorian Datepicker Demo</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="ZulNs">
<meta name="keywords" content="">
<meta name="description" content="">
<meta name="robots" content="all">
<meta name="copyright" content="ZulNs">
<link rel="icon" href="../favicon.svg" type="image/svg+xml" />
<!--link rel="icon" href="favicon.png" type="image/png" /-->
<!--link rel="icon" href="favicon.ico" type="image/x-icon" /-->
</head>
<body>
<link rel="stylesheet" href="../w3css/w3.css"/>
<style type="text/css">
.w3-bar-item{border-left:6px solid transparent!important}
.w3-bar-item:not(:disabled):hover{border-color:#f44336!important}
.w3-bar-item:focus{border-color:#2196F3!important}
.w3-bar-item.expanded{color:#fff;background-color:#616161}
button.collapsed + div,button.collapsed>:nth-child(3),button.expanded>:nth-child(2){display:none!important}
.w3-bar-item input[type=radio],.w3-bar-item label{cursor:pointer}
.w3-bar-item:focus-within{border-color:#2196F3!important}
</style>
<div class="w3-sidebar w3-bar-block w3-collapse w3-card w3-animate-left" style="width:220px;z-index:2" id="mySidebar">
<button class="w3-bar-item w3-button w3-ripple w3-large w3-hide-large" onclick="closeSidebar()">Close<span class="w3-right">×</span></button>
<button class="w3-bar-item w3-button w3-ripple collapsed" onclick="dropdown(this)">
<span>Set Language</span>
<span class="w3-right"><svg width="10" height="10"><path d="M1 3L5 7L9 3Z"/></svg></span>
<span class="w3-right"><svg width="10" height="10"><path d="M1 7L5 3L9 7Z"/></svg></span>
</button>
<div class="w3-bar-block w3-light-grey">
<div class="w3-bar-item w3-button" onclick="selectLang(this)">
<input id="langEn" class="w3-radio" type="radio" name="lang" value="en" checked>
<label for="langEn">English</label>
</div>
<div class="w3-bar-item w3-button" onclick="selectLang(this)">
<input id="langAr" class="w3-radio" type="radio" name="lang" value="ar">
<label for="langAr">Arabic</label>
</div>
<div class="w3-bar-item w3-button" onclick="selectLang(this)">
<input id="langId" class="w3-radio" type="radio" name="lang" value="id">
<label for="langId">Indonesian</label>
</div>
</div>
<button class="w3-bar-item w3-button w3-ripple collapsed" onclick="dropdown(this)">
<span>Set Firstday</span>
<span class="w3-right"><svg width="10" height="10"><path d="M1 3L5 7L9 3Z"/></svg></span>
<span class="w3-right"><svg width="10" height="10"><path d="M1 7L5 3L9 7Z"/></svg></span>
</button>
<div class="w3-bar-block w3-light-grey">
<button class="w3-bar-item w3-button w3-ripple" onclick="setFirstDay(0)">Sunday</button>
<button class="w3-bar-item w3-button w3-ripple" onclick="setFirstDay(1)">Monday</button>
<button class="w3-bar-item w3-button w3-ripple" onclick="setFirstDay(2)">Tuesday</button>
<button class="w3-bar-item w3-button w3-ripple" onclick="setFirstDay(3)">Wednesday</button>
<button class="w3-bar-item w3-button w3-ripple" onclick="setFirstDay(4)">Thursday</button>
<button class="w3-bar-item w3-button w3-ripple" onclick="setFirstDay(5)">Friday</button>
<button class="w3-bar-item w3-button w3-ripple" onclick="setFirstDay(6)">Saturday</button>
</div>
<button class="w3-bar-item w3-button w3-ripple collapsed" onclick="dropdown(this)">
<span>Set Full Year</span>
<span class="w3-right"><svg width="10" height="10"><path d="M1 3L5 7L9 3Z"/></svg></span>
<span class="w3-right"><svg width="10" height="10"><path d="M1 7L5 3L9 7Z"/></svg></span>
</button>
<div class="w3-bar-block w3-light-grey">
<div class="w3-bar-item">
<input id="valYear" class="w3-input w3-border" type="text" placeholder="full year value...">
</div>
<button class="w3-bar-item w3-button w3-ripple" onclick="setYear()">Apply</button>
</div>
<button class="w3-bar-item w3-button w3-ripple collapsed" onclick="dropdown(this)">
<span>Set Month</span>
<span class="w3-right"><svg width="10" height="10"><path d="M1 3L5 7L9 3Z"/></svg></span>
<span class="w3-right"><svg width="10" height="10"><path d="M1 7L5 3L9 7Z"/></svg></span>
</button>
<div class="w3-bar-block w3-light-grey">
<div class="w3-bar-item">
<input id="valMonth" class="w3-input w3-border" type="text" placeholder="month value...">
</div>
<button class="w3-bar-item w3-button w3-ripple" onclick="setMonth()">Apply</button>
</div>
<button class="w3-bar-item w3-button w3-ripple collapsed" onclick="dropdown(this)">
<span>Set Width</span>
<span class="w3-right"><svg width="10" height="10"><path d="M1 3L5 7L9 3Z"/></svg></span>
<span class="w3-right"><svg width="10" height="10"><path d="M1 7L5 3L9 7Z"/></svg></span>
</button>
<div class="w3-bar-block w3-light-grey">
<div class="w3-bar-item">
<input id="valWidth" class="w3-input w3-show-inline-block" style="width:80px" type="text" value="300" readonly>
<label for="valWidth" class="w3-right-align" style="width:50px">pixels</label>
</div>
<div class="w3-bar-item">
<input id="sliderWidth" type="range" oninput="updateWidth(this)" onchange="updateWidth(this)" style="width:170px" min="280" max="600" value="300" step="1">
</div>
</div>
<button class="w3-bar-item w3-button w3-ripple" onclick="gotoToday()">Go to Today</button>
<button class="w3-bar-item w3-button w3-ripple collapsed" onclick="dropdown(this)">
<span>Set Theme</span>
<span class="w3-right"><svg width="10" height="10"><path d="M1 3L5 7L9 3Z"/></svg></span>
<span class="w3-right"><svg width="10" height="10"><path d="M1 7L5 3L9 7Z"/></svg></span>
</button>
<div class="w3-bar-block w3-light-grey">
<div class="w3-bar-item">
<input id="txtTheme" class="w3-input w3-border" type="text" placeholder="theme-color or index">
</div>
<button class="w3-bar-item w3-button w3-ripple" onclick="setTheme()">Apply</button>
<button class="w3-bar-item w3-button w3-ripple" onclick="newTheme()">New Theme</button>
</div>
<a class="w3-bar-item w3-button w3-ripple" href="../Calendar.js/index.html">See My Calendar</a>
<a class="w3-bar-item w3-button w3-ripple" href="../Timepicker.js/index.html">See My Timepicker</a>
<a class="w3-bar-item w3-button w3-ripple" href="https://github.com/ZulNs/Datepicker.js">Source code</a>
</div>
<div class="w3-main" style="margin-left:220px">
<div class="w3-container w3-padding w3-teal">
<button class="w3-button w3-ripple w3-xlarge w3-hide-large w3-left" style="margin:6px 8px 0px -16px" onclick="openSidebar()">
<svg width="18" height="23"><path d="M0 6L18 6L18 8L0 8Z M0 13L18 13L18 15L0 15Z M0 20L18 20L18 22L0 22Z"/></svg>
</button>
<h2>Hijri/Gregorian Datepicker Demo</h2>
</div>
<div class="w3-container w3-margin-top">
<div class="w3-container w3-margin-top">
<label for="gregDate">Gregorian Date</label>
<input id="gregDate" onclick="pickDate(event)" class="w3-input w3-border" type="text" placeholder="Click to pick a date...">
</div>
<div class="w3-container w3-margin-top">
<label for="hijrDate">Hijri Date</label>
<input id="hijrDate" onclick="pickDate(event)" class="w3-input w3-border" type="text" placeholder="Click to pick a date...">
</div>
</div>
</div>
<script type="text/javascript" src="../HijriDate.js/hijri-date.js"></script>
<script type="text/javascript" src="datepicker.js"></script>
<script type="text/javascript">
'use strict';
let picker=new Datepicker();
let pickElm=picker.getElement();
let pLeft=200;
let pWidth=300;
pickElm.style.position='absolute';
pickElm.style.left=pLeft+'px';
pickElm.style.top='172px';
picker.attachTo(document.body);
picker.onPicked=function(){
let elgd=document.getElementById('gregDate');
let elhd=document.getElementById('hijrDate');
if(picker.getPickedDate() instanceof Date){
elgd.value=picker.getPickedDate().getDateString();
elhd.value=picker.getOppositePickedDate().getDateString()
}else{
elhd.value=picker.getPickedDate().getDateString();
elgd.value=picker.getOppositePickedDate().getDateString()
}
};
function openSidebar(){
document.getElementById("mySidebar").style.display = "block"
}
function closeSidebar(){
document.getElementById("mySidebar").style.display = "none"
}
function dropdown(el){
if(el.className.indexOf('expanded')==-1){
el.className=el.className.replace('collapsed','expanded');
}else{
el.className=el.className.replace('expanded','collapsed');
}
}
function selectLang(el){
el.children[0].checked=true;
picker.setLanguage(el.children[0].value)
}
function setFirstDay(fd){
picker.setFirstDayOfWeek(fd)
}
function setYear(){
let el=document.getElementById('valYear');
picker.setFullYear(el.value)
}
function setMonth(){
let el=document.getElementById('valMonth');
picker.setMonth(el.value)
}
function updateWidth(el){
pWidth=parseInt(el.value);
if(!fixWidth()){
document.getElementById('valWidth').value=pWidth;
picker.setWidth(pWidth)
}
}
function pickDate(ev){
ev=ev||window.event;
let el=ev.target||ev.srcElement;
pLeft=ev.pageX;
fixWidth();
pickElm.style.top=ev.pageY+'px';
picker.setHijriMode(el.id=='hijrDate');
picker.show();
el.blur()
}
function gotoToday(){
picker.today()
}
function setTheme(){
let el=document.getElementById('txtTheme');
let n=parseInt(el.value);
if(!isNaN(n))picker.setTheme(n);
else picker.setTheme(el.value)
}
function newTheme(){
picker.setTheme()
}
function fixWidth(){
let docWidth=document.body.offsetWidth;
let isFixed=false;
if(pLeft+pWidth>docWidth)pLeft=docWidth-pWidth;
if(docWidth>=992&&pLeft<200)pLeft=200;
else if(docWidth<992&&pLeft<0)pLeft=0;
if(pLeft+pWidth>docWidth){
pWidth=docWidth-pLeft;
picker.setWidth(pWidth);
document.getElementById('valWidth').value=pWidth;
document.getElementById('sliderWidth').value=pWidth;
isFixed=true
}
pickElm.style.left=pLeft+'px';
return isFixed
}
</script>
</body>
</html>