Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
opening-hours
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
regionalkauf
opening-hours
Commits
78cadac7
Commit
78cadac7
authored
Aug 04, 2014
by
Johannes Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added two week view, one week view now starts on monday
parent
964b2601
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
25 deletions
+51
-25
dateView.js
lib/dateView.js
+35
-18
dataBaseQuery.js
serverTest/dataBaseQuery.js
+8
-5
index.js
serverTest/routes/index.js
+8
-2
No files found.
lib/dateView.js
View file @
78cadac7
...
...
@@ -8,7 +8,9 @@ function createWeekView(dataObj, now) {
var
data
=
dataObj
.
intervals
;
var
holidays
=
dataObj
.
holidays
;
var
noOfDays
=
7
;
var
offset
=
3
;
// var offset = 3;
var
offset
=
now
.
getDay
()
-
1
;
if
(
offset
<
0
)
offset
+=
7
;
var
startDate
=
new
Date
(
now
.
getFullYear
(),
now
.
getMonth
(),
now
.
getDate
()
-
offset
);
var
endDate
=
new
Date
(
now
.
getFullYear
(),
now
.
getMonth
(),
now
.
getDate
()
+
noOfDays
-
offset
);
var
oHours
=
transformData
(
data
,
startDate
,
endDate
);
...
...
@@ -54,18 +56,27 @@ function createWeekView(dataObj, now) {
return
content
;
}
function
createWeekViewVertical
(
dataObj
,
now
)
{
function
createWeekViewVertical
(
dataObj
,
now
,
noOfDays
,
flexibleLayout
,
className
)
{
var
data
=
dataObj
.
intervals
;
var
holidays
=
dataObj
.
holidays
;
var
noOfDays
=
7
;
var
offset
=
3
;
noOfDays
=
noOfDays
||
7
;
var
offset
;
if
(
flexibleLayout
)
{
offset
=
3
;
}
else
{
offset
=
now
.
getDay
()
-
1
;
if
(
offset
<
0
)
offset
+=
7
;
}
var
startDate
=
new
Date
(
now
.
getFullYear
(),
now
.
getMonth
(),
now
.
getDate
()
-
offset
);
var
endDate
=
new
Date
(
now
.
getFullYear
(),
now
.
getMonth
(),
now
.
getDate
()
+
noOfDays
-
offset
);
var
oHours
=
transformData
(
data
,
startDate
,
endDate
);
var
maxNumber
=
getMaxNoOfItemsPerDay
(
oHours
);
var
tableWidth
=
maxNumber
;
var
content
=
'<div class="
weekview-v-container"><table class="weekview-v
-table">'
;
var
content
=
'<div class="
'
+
className
+
'-container"><table class="'
+
className
+
'
-table">'
;
content
+=
'<tbody>'
;
var
columns
=
[];
...
...
@@ -77,33 +88,33 @@ function createWeekViewVertical(dataObj, now) {
var
cls
=
''
;
if
(
dayInHolidays
(
day
.
date
,
holidays
))
{
cls
+=
"
weekview-v
-holiday"
;
cls
+=
"
"
+
className
+
"
-holiday"
;
}
if
(
compareDate
(
day
.
date
,
now
)
==
0
)
{
cls
+=
"
weekview-v
-today"
;
cls
+=
"
"
+
className
+
"
-today"
;
}
if
(
day
.
date
.
getDay
()
==
0
)
{
cls
+=
"
weekview-v
-sunday"
;
cls
+=
"
"
+
className
+
"
-sunday"
;
}
else
if
(
day
.
date
.
getDay
()
==
6
)
{
cls
+=
"
weekview-v
-saturday"
;
cls
+=
"
"
+
className
+
"
-saturday"
;
}
var
datString
=
formatDate
(
day
.
date
);
column
.
push
(
'<td class="
weekview-v
-td-first'
+
cls
+
'">'
+
datString
[
0
]
+
'</td>'
);
column
.
push
(
'<td class="
weekview-v
-td-date'
+
cls
+
'">'
+
datString
[
1
]
+
'</td>'
);
column
.
push
(
'<td class="
'
+
className
+
'
-td-first'
+
cls
+
'">'
+
datString
[
0
]
+
'</td>'
);
column
.
push
(
'<td class="
'
+
className
+
'
-td-date'
+
cls
+
'">'
+
datString
[
1
]
+
'</td>'
);
for
(
var
j
=
0
;
j
<
day
.
oHours
.
length
;
j
++
)
{
var
oHour
=
day
.
oHours
[
j
];
column
.
push
(
'<td class="
weekview-v-td weekview-v
-filled'
+
cls
+
'">'
+
formatTime
(
oHour
[
0
])
+
" – "
+
formatTime
(
oHour
[
1
])
+
'</td>'
);
column
.
push
(
'<td class="
'
+
className
+
'-td '
+
className
+
'
-filled'
+
cls
+
'">'
+
formatTime
(
oHour
[
0
])
+
" – "
+
formatTime
(
oHour
[
1
])
+
'</td>'
);
}
for
(
var
j
=
day
.
oHours
.
length
;
j
<
tableWidth
;
j
++
)
{
column
.
push
(
'<td class="
weekview-v-td weekview-v
-empty'
+
cls
+
'"></td>'
);
column
.
push
(
'<td class="
'
+
className
+
'-td '
+
className
+
'
-empty'
+
cls
+
'"></td>'
);
}
}
for
(
var
j
=
0
;
j
<
tableWidth
+
2
;
j
++
)
{
content
+=
'<tr class="
weekview-v
-tr">'
;
content
+=
'<tr class="
'
+
className
+
'
-tr">'
;
for
(
var
i
=
0
;
i
<
noOfDays
;
i
++
)
{
content
+=
columns
[
i
][
j
];
}
...
...
@@ -206,9 +217,10 @@ function create3MonthView(dataObj, now) {
function
getView
(
dataObj
,
now
)
{
var
content
=
'<div class="view-container">'
;
content
+=
createWeekView
(
dataObj
,
now
);
content
+=
createWeekViewVertical
(
dataObj
,
now
);
content
+=
create3MonthView
(
dataObj
,
now
);
content
+=
module
.
exports
.
weekView
(
dataObj
,
now
);
content
+=
module
.
exports
.
weekViewV
(
dataObj
,
now
);
content
+=
module
.
exports
.
twoWeekViewV
(
dataObj
,
now
);
content
+=
module
.
exports
.
monthView
(
dataObj
,
now
);
content
+=
'</div>'
;
return
content
;
}
...
...
@@ -330,7 +342,12 @@ function asString(data, now) {
module
.
exports
.
asString
=
asString
;
module
.
exports
.
weekView
=
createWeekView
;
module
.
exports
.
weekViewV
=
createWeekViewVertical
;
module
.
exports
.
weekViewV
=
function
(
dataObj
,
now
)
{
return
createWeekViewVertical
(
dataObj
,
now
,
7
,
false
,
'weekview-v'
);
};
module
.
exports
.
twoWeekViewV
=
function
(
dataObj
,
now
)
{
return
createWeekViewVertical
(
dataObj
,
now
,
14
,
true
,
'two-weekview-v'
);
};
module
.
exports
.
monthView
=
create3MonthView
;
module
.
exports
.
getView
=
getView
;
module
.
exports
.
getPropperEpochSpan
=
getPropperEpochSpan
;
\ No newline at end of file
serverTest/dataBaseQuery.js
View file @
78cadac7
...
...
@@ -18,7 +18,7 @@ module.exports.getData = function (now, cb) {
// console.log(epocheSpan);
// dateArray.setEpocheSpan(epocheSpan);
connection
.
query
(
'SELECT name, elements FROM cms_zoo_item WHERE type in ("pos", "company") LIMIT 100'
,
function
(
err
,
rows
)
{
connection
.
query
(
'SELECT name, elements FROM cms_zoo_item WHERE type in ("pos", "company")
ORDER BY id
LIMIT 100'
,
function
(
err
,
rows
)
{
console
.
log
(
rows
.
length
);
var
result
=
[];
var
cnt
=
0
;
...
...
@@ -27,22 +27,25 @@ module.exports.getData = function (now, cb) {
var
obj
=
JSON
.
parse
(
rows
[
i
].
elements
);
(
function
()
{
var
name
=
rows
[
i
].
name
;
var
idx
=
i
;
dateArray
(
epocheSpan
).
getData
(
obj
,
plz
,
function
(
err
,
dataObj
)
{
if
(
err
)
{
console
.
log
(
name
,
err
);
}
else
if
(
dataObj
&&
dataObj
.
intervals
.
length
>
0
)
{
else
if
(
dataObj
)
{
var
data
=
dataObj
.
intervals
;
cnt
++
;
var
view
=
dateView
.
getView
(
dataObj
,
now
);
var
asString
=
dateView
.
asString
(
dataObj
,
now
);
asString
=
asString
.
asString
.
join
(
", "
);
result
.
push
(
'<div class="name">'
+
name
+
"</div> "
+
asString
+
view
);
// result.push('<div class="name">' + name + "</div> " + asString + view);
result
[
idx
]
=
(
'<div class="name">'
+
name
+
"</div> "
+
asString
+
view
);
}
if
(
--
iters
==
0
)
{
console
.
log
(
"Count: %d"
,
cnt
);
result
=
result
.
filter
(
function
(
elem
)
{
return
!!
elem
;
});
cb
(
result
.
join
(
'<br>'
));
}
});
...
...
serverTest/routes/index.js
View file @
78cadac7
...
...
@@ -5,11 +5,17 @@ var db = require('../dataBaseQuery');
router
.
get
(
'/'
,
function
(
req
,
res
)
{
var
dateString
=
req
.
query
.
date
;
var
now
;
if
(
dateString
&&
dateString
.
length
=
=
8
)
{
if
(
dateString
&&
dateString
.
length
>
=
8
)
{
var
year
=
parseInt
(
dateString
.
slice
(
0
,
4
));
var
month
=
parseInt
(
dateString
.
slice
(
4
,
6
));
var
date
=
parseInt
(
dateString
.
slice
(
6
,
8
));
now
=
new
Date
(
year
,
month
-
1
,
date
);
var
hours
=
0
;
var
minutes
=
0
;
if
(
dateString
.
length
==
12
)
{
hours
=
dateString
.
slice
(
8
,
10
);
minutes
=
dateString
.
slice
(
10
,
12
);
}
now
=
new
Date
(
year
,
month
-
1
,
date
,
hours
,
minutes
);
}
else
{
now
=
new
Date
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment