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
dca1cf1a
Commit
dca1cf1a
authored
Oct 20, 2015
by
Johannes Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed error handling, added filtering of invalid default fields
parent
41a62a15
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
6 deletions
+20
-6
index.js
index.js
+2
-2
dateArray.js
lib/dateArray.js
+1
-1
pretifyData.js
lib/pretifyData.js
+17
-3
No files found.
index.js
View file @
dca1cf1a
...
...
@@ -34,7 +34,7 @@ function getOHIndex(info, today, cb) {
function
getFull
(
info
,
now
,
cb
)
{
var
epocheSpan
=
dateView
.
getPropperEpochSpan
(
now
);
dateArray
(
epocheSpan
).
getData
(
info
,
function
(
err
,
dataObj
)
{
if
(
err
)
return
cb
(
null
,
err
);
if
(
err
)
return
cb
(
err
);
var
short
=
dateView
.
asString
(
dataObj
,
now
);
var
res
=
{
threeMonth
:
dateView
.
threeMonth
(
dataObj
,
now
),
...
...
@@ -50,7 +50,7 @@ function getFull(info, now, cb) {
function
getShort
(
info
,
now
,
cb
)
{
var
epocheSpan
=
dateView
.
getPropperEpochSpan
(
now
);
dateArray
(
epocheSpan
).
getData
(
info
,
function
(
err
,
dataObj
)
{
if
(
err
)
return
cb
(
null
,
err
);
if
(
err
)
return
cb
(
err
);
var
obj
=
dateView
.
asString
(
dataObj
,
now
);
cb
(
null
,
obj
);
})
...
...
lib/dateArray.js
View file @
dca1cf1a
...
...
@@ -154,7 +154,7 @@ function wrapper(_epochSpan) {
}
var
split
=
date
.
split
(
"."
);
if
(
split
.
length
<
2
)
{
if
(
!
split
||
split
.
length
<
2
)
{
return
null
;
}
...
...
lib/pretifyData.js
View file @
dca1cf1a
...
...
@@ -27,15 +27,29 @@ function pretify(data) {
return
ret
;
}
function
filterField
(
field
)
{
if
(
!
field
)
return
false
;
var
mandFields
=
[
'opening_from'
,
'opening_to'
];
if
(
field
.
option
==
'default'
)
{
var
hasMandFields
=
true
;
for
(
let
mandField
of
mandFields
)
{
if
(
!
field
[
mandField
])
hasMandFields
=
false
;
}
return
hasMandFields
;
}
else
{
return
true
;
}
}
var
ret
=
{};
for
(
let
key
of
Object
.
keys
(
data
))
{
let
fields
=
data
[
key
];
if
(
fields
)
{
var
newFields
=
fields
.
map
(
function
(
field
)
{
return
pretifyField
(
field
);
}).
filter
(
function
(
field
)
{
return
!!
field
;
});
}).
filter
(
filterField
);
ret
[
key
]
=
newFields
;
}
}
...
...
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