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
306d8f25
Commit
306d8f25
authored
Jul 11, 2014
by
Johannes Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
holiday model refactored
parent
29b7c2ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
59 deletions
+49
-59
holidays.js
lib/holidays.js
+48
-58
dataBaseQuery.js
serverTest/dataBaseQuery.js
+1
-1
No files found.
lib/holidays.js
View file @
306d8f25
...
...
@@ -27,7 +27,7 @@ var variableOffsets = {
602
:
50
};
var
holidayToSpecific
Map
=
(
function
()
{
var
inverseHd
Map
=
(
function
()
{
var
regionH
=
holidayMapping
[
"region"
];
var
hMap
=
{};
for
(
var
rKey
in
regionH
)
{
...
...
@@ -47,7 +47,6 @@ var holidayToSpecificMap = (function () {
}
return
hMap
;
}());
console
.
log
(
holidayToSpecificMap
);
function
Holidays
(
year
)
{
...
...
@@ -86,29 +85,6 @@ function Holidays(year) {
return
!!
(
86150
<=
plz
&&
plz
<=
86199
);
}
function
getRegionOptions
(
plz
,
keys
,
cb
)
{
var
blnd
;
var
options
=
{
isKath
:
false
,
isAugsburg
:
false
};
restRequest
.
getBundesland
(
plz
,
function
(
err
,
result
)
{
if
(
err
)
return
cb
(
err
);
blnd
=
result
;
options
.
blnd
=
blnd
;
if
(
blnd
==
"BY"
)
{
options
.
isAugsburg
=
getIsAugsburg
(
plz
);
restRequest
.
getKatholisch
(
plz
,
function
(
err1
,
isKath
)
{
if
(
err1
)
return
cb
(
err1
);
options
.
isKath
=
isKath
;
cb
(
null
,
options
);
})
}
else
{
cb
(
null
,
options
);
}
});
}
function
isInEpochSpan
(
date
,
epochSpan
)
{
var
dateTime
=
date
.
getTime
();
...
...
@@ -126,47 +102,61 @@ function Holidays(year) {
if
(
plz
==
0
)
{
return
cb
(
null
,
initKeys
);
}
var
specialKeys
=
holidayMapping
[
"specificHolidays"
].
filter
(
function
(
key
)
{
return
initKeys
.
indexOf
(
key
)
>=
0
;
});
getRegionOptions
(
plz
,
initKeys
,
function
(
err
,
options
)
{
console
.
log
(
options
);
if
(
specialKeys
.
length
==
0
)
{
return
cb
(
null
,
initKeys
);
}
restRequest
.
getBundesland
(
plz
,
function
(
err
,
blnd
)
{
if
(
err
)
return
cb
(
err
);
var
blnd
=
options
.
blnd
;
var
isAugsburg
=
options
.
isAugsburg
;
var
isKath
=
options
.
isKath
;
var
keys
=
holidayMapping
[
'sureHolidays'
];
var
blndMap
=
holidayMapping
[
'region'
][
blnd
];
if
(
blndMap
)
{
keys
.
concat
(
blndMap
[
'default'
]);
if
(
isKath
&&
blndMap
[
'kath'
])
keys
=
keys
.
concat
(
blndMap
[
'kath'
]);
if
(
isAugsburg
&&
blndMap
[
'augsburg'
])
keys
=
keys
.
concat
(
blndMap
[
'augsburg'
]);
var
keys
=
holidayMapping
[
"sureHolidays"
].
filter
(
function
(
key
)
{
return
initKeys
.
indexOf
(
key
)
>=
0
;
});
var
regionMap
=
holidayMapping
[
"region"
][
blnd
];
var
regHD
=
regionMap
[
'default'
];
for
(
var
i
=
0
;
i
<
regHD
.
length
;
i
++
)
{
var
key
=
regHD
[
i
];
if
(
initKeys
.
indexOf
(
key
)
>=
0
)
{
keys
.
push
(
key
);
}
}
cb
(
null
,
keys
);
})
}
function
blndGetter
(
plz
)
{
var
blnd
;
var
errRec
;
function
getBlnd
(
cb
)
{
if
(
errRec
)
return
cb
(
errRec
);
if
(
blnd
)
return
cb
(
null
,
blnd
);
restRequest
.
getBundesland
(
plz
,
function
(
err
,
result
)
{
if
(
err
)
{
errRec
=
err
;
return
cb
(
err
);
if
(
blnd
!=
"BY"
)
{
cb
(
null
,
keys
);
}
else
{
if
(
regionMap
[
"augsburg"
]
&&
getIsAugsburg
(
plz
))
{
var
augsHDs
=
regionMap
[
"augsburg"
];
for
(
var
i
=
0
;
i
<
augsHDs
.
length
;
i
++
)
{
var
key
=
augsHDs
[
i
];
if
(
initKeys
.
indexOf
(
key
)
>=
0
)
keys
.
push
(
key
);
}
}
cb
(
null
,
result
);
})
}
return
getBlnd
;
if
(
regionMap
[
"kath"
]
&&
regionMap
[
"kath"
].
length
>
0
)
{
restRequest
.
getKatholisch
(
plz
,
function
(
err
,
kath
)
{
if
(
err
)
return
cb
(
err
);
if
(
kath
)
{
var
kathHDs
=
regionMap
[
"kath"
];
for
(
var
i
=
0
;
i
<
kathHDs
.
length
;
i
++
)
{
var
key
=
kathHDs
[
i
];
if
(
initKeys
.
indexOf
(
key
)
>=
0
)
keys
.
push
(
key
);
}
}
cb
(
null
,
keys
);
})
}
else
{
cb
(
null
,
keys
);
}
}
});
}
this
.
getAllHolidays
=
function
(
plz
,
epochSpan
,
cb
)
{
getHolidayKeys
(
plz
,
epochSpan
,
function
(
err
,
keys
)
{
if
(
err
)
return
cb
(
err
);
var
result
=
[];
...
...
serverTest/dataBaseQuery.js
View file @
306d8f25
var
mysql
=
require
(
'mysql'
);
var
dateArray
=
require
(
'../lib/dateArray'
);
var
dateView
=
require
(
'../lib/dateView'
);
var
plz
=
90473
;
var
plz
=
86150
;
var
connection
=
mysql
.
createConnection
({
host
:
'localhost'
,
...
...
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