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
a1e2dfd9
Commit
a1e2dfd9
authored
Sep 19, 2016
by
Johannes Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modifications for hallo-nachbarn
parent
fbfec87c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
8 deletions
+15
-8
index.js
index.js
+14
-8
package.json
package.json
+1
-0
No files found.
index.js
View file @
a1e2dfd9
"use strict"
;
"use strict"
;
var
Promise
=
require
(
'bluebird'
);
var
dateArray
=
require
(
'./lib/dateArray'
);
var
dateArray
=
require
(
'./lib/dateArray'
);
var
dateView
=
require
(
'./lib/dateView'
);
var
dateView
=
require
(
'./lib/dateView'
);
var
splitMidnight
=
require
(
'./lib/timeUtils'
).
splitMidnight
;
var
splitMidnight
=
require
(
'./lib/timeUtils'
).
splitMidnight
;
function
mapEvents
(
intervals
)
{
function
mapEvents
(
intervals
)
{
if
(
intervals
)
{
if
(
intervals
)
{
return
splitMidnight
(
intervals
).
map
(
function
(
evt
)
{
// var splitIntervals = splitMidnight(intervals);
var
splitIntervals
=
intervals
;
return
splitIntervals
.
map
(
function
(
evt
)
{
return
{
return
{
startDate
:
evt
[
0
],
startDate
:
evt
[
0
],
endDate
:
evt
[
1
]
endDate
:
evt
[
1
]
...
@@ -26,6 +28,7 @@ function transform(x) {
...
@@ -26,6 +28,7 @@ function transform(x) {
return
res
;
return
res
;
}
}
// intervals for elasticsearch index (to allow opening hours filters)
function
getOHIndex
(
info
,
today
,
cb
)
{
function
getOHIndex
(
info
,
today
,
cb
)
{
today
=
new
Date
(
today
.
getFullYear
(),
today
.
getMonth
(),
today
.
getDate
());
today
=
new
Date
(
today
.
getFullYear
(),
today
.
getMonth
(),
today
.
getDate
());
...
@@ -59,7 +62,7 @@ function mapCustomIntervals(customIvals) {
...
@@ -59,7 +62,7 @@ function mapCustomIntervals(customIvals) {
return
res
;
return
res
;
}
}
// for detail view, events* contain intervals {from, to}
function
getFull
(
info
,
now
,
cb
)
{
function
getFull
(
info
,
now
,
cb
)
{
var
epocheSpan
=
dateView
.
getPropperEpochSpan
(
now
);
var
epocheSpan
=
dateView
.
getPropperEpochSpan
(
now
);
dateArray
(
epocheSpan
).
getData
(
info
,
function
(
err
,
dataObj
)
{
dateArray
(
epocheSpan
).
getData
(
info
,
function
(
err
,
dataObj
)
{
...
@@ -70,7 +73,7 @@ function getFull(info, now, cb) {
...
@@ -70,7 +73,7 @@ function getFull(info, now, cb) {
isOpen
:
short
.
isOpen
,
isOpen
:
short
.
isOpen
,
text
:
short
.
text
,
text
:
short
.
text
,
status
:
short
.
status
,
status
:
short
.
status
,
weekView
:
dateView
.
weekViewData
(
dataObj
,
now
),
//
weekView: dateView.weekViewData(dataObj, now),
events
:
mapEvents
(
dataObj
.
intervals
),
events
:
mapEvents
(
dataObj
.
intervals
),
eventsMaybe
:
mapEvents
(
dataObj
.
maybeIntervals
),
eventsMaybe
:
mapEvents
(
dataObj
.
maybeIntervals
),
customEvents
:
mapCustomIntervals
(
dataObj
.
customIntervals
)
customEvents
:
mapCustomIntervals
(
dataObj
.
customIntervals
)
...
@@ -80,6 +83,7 @@ function getFull(info, now, cb) {
...
@@ -80,6 +83,7 @@ function getFull(info, now, cb) {
})
})
}
}
// for list view
function
getShort
(
info
,
now
,
cb
)
{
function
getShort
(
info
,
now
,
cb
)
{
var
epocheSpan
=
dateView
.
getPropperEpochSpan
(
now
);
var
epocheSpan
=
dateView
.
getPropperEpochSpan
(
now
);
dateArray
(
epocheSpan
).
getData
(
info
,
function
(
err
,
dataObj
)
{
dateArray
(
epocheSpan
).
getData
(
info
,
function
(
err
,
dataObj
)
{
...
@@ -89,10 +93,12 @@ function getShort(info, now, cb) {
...
@@ -89,10 +93,12 @@ function getShort(info, now, cb) {
})
})
}
}
// info is {state: "Bayern", zip: 1234, religiousHoliday: true, data: {include, exclude, maybe}}
module
.
exports
=
{
module
.
exports
=
{
getOHIndex
:
getOHIndex
,
getOHIndex
:
Promise
.
promisify
(
getOHIndex
),
getFull
:
getFull
,
getFull
:
Promise
.
promisify
(
getFull
),
getShort
:
getShort
,
getShort
:
Promise
.
promisify
(
getShort
)
pretify
:
require
(
'./lib/pretifyData'
).
pretify
};
};
package.json
View file @
a1e2dfd9
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
"main"
:
"index.js"
,
"main"
:
"index.js"
,
"dependencies"
:
{
"dependencies"
:
{
"
async
"
:
"^2.0.1"
,
"
async
"
:
"^2.0.1"
,
"
bluebird
"
:
"^3.4.6"
,
"
moment
"
:
"^2.15.0"
"
moment
"
:
"^2.15.0"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
...
...
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