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
b142d7fe
Commit
b142d7fe
authored
Jul 06, 2014
by
Johannes Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
created lib folder
parent
e68c951e
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
61 additions
and
21 deletions
+61
-21
index.html
index.html
+38
-0
dateArray.js
lib/dateArray.js
+1
-1
dateView.js
lib/dateView.js
+7
-7
timeUtils.js
lib/timeUtils.js
+1
-1
app.js
serverTest/app.js
+0
-1
dataBaseQuery.js
serverTest/dataBaseQuery.js
+11
-8
index.js
serverTest/routes/index.js
+1
-1
index.ejs
serverTest/views/index.ejs
+1
-1
dateViewTest.js
test/dateViewTest.js
+1
-1
No files found.
index.html
0 → 100644
View file @
b142d7fe
<!DOCTYPE html>
<html>
<head
lang=
"en"
>
<meta
charset=
"UTF-8"
>
<title></title>
<style>
*
{
box-sizing
:
border-box
;
}
.main
{
border-collapse
:
collapse
;
width
:
400px
;
table-layout
:
fixed
;
}
.td
{
background-color
:
#e8e8e8
;
border
:
1px
solid
#d9d9d9
;
display
:
inline-block
;
}
</style>
</head>
<body>
<table
class=
"main"
>
<tr
class=
"tr"
>
<td
class=
"td"
style=
"width: 25%"
>
qe
</td>
<td
class=
"td"
style=
"width: 25%"
>
qe
</td>
<td
class=
"td"
style=
"width: 25%"
>
qe
</td>
<td
class=
"td"
style=
"width: 25%"
>
qe
</td>
</tr>
<tr
class=
"tr"
>
<td
class=
"td"
style=
"width: 15%"
>
qe
</td>
<td
class=
"td"
style=
"width: 35%"
>
qe
</td>
<td
class=
"td"
style=
"width: 10%"
>
qe
</td>
<td
class=
"td"
style=
"width: 40%"
>
qe
</td>
</tr>
</table>
</body>
</html>
\ No newline at end of file
lib/dateArray.js
View file @
b142d7fe
lib/dateView.js
View file @
b142d7fe
...
@@ -46,6 +46,7 @@ function createMonthView(data, now, monthOffset) {
...
@@ -46,6 +46,7 @@ function createMonthView(data, now, monthOffset) {
if
(
endDate
.
getDay
()
!=
1
)
if
(
endDate
.
getDay
()
!=
1
)
endDate
.
setDate
(
9
-
endDate
.
getDay
());
endDate
.
setDate
(
9
-
endDate
.
getDay
());
//TODO: only transform once for 3 month view
var
oHours
=
transformData
(
data
,
startDate
,
endDate
);
var
oHours
=
transformData
(
data
,
startDate
,
endDate
);
var
content
=
'<div class="monthview-maindiv">'
;
var
content
=
'<div class="monthview-maindiv">'
;
...
@@ -137,6 +138,7 @@ function transformData(data, startDate, endDate) {
...
@@ -137,6 +138,7 @@ function transformData(data, startDate, endDate) {
var
oHours
=
[];
var
oHours
=
[];
while
(
dataIdx
<
data
.
length
)
{
while
(
dataIdx
<
data
.
length
)
{
var
comp
=
compareDate
(
data
[
dataIdx
][
0
],
curDate
);
var
comp
=
compareDate
(
data
[
dataIdx
][
0
],
curDate
);
//TODO: split midnight
if
(
comp
<
0
)
if
(
comp
<
0
)
dataIdx
++
;
dataIdx
++
;
else
if
(
comp
==
0
)
{
else
if
(
comp
==
0
)
{
...
@@ -163,13 +165,11 @@ function compareDate(date1, date2) {
...
@@ -163,13 +165,11 @@ function compareDate(date1, date2) {
return
diff
;
return
diff
;
}
}
function
getPropperEpocheSpan
(
now
)
{
function
getPropperEpochSpan
(
now
)
{
var
epocheStart
=
new
Date
(
now
.
getFullYear
(),
now
.
getMonth
(),
-
10
);
var
epochStart
=
new
Date
(
now
.
getFullYear
(),
now
.
getMonth
(),
-
10
);
var
epocheEnd
=
new
Date
(
now
.
getFullYear
(),
now
.
getMonth
()
+
3
,
1
);
var
epochEnd
=
new
Date
(
now
.
getFullYear
(),
now
.
getMonth
()
+
3
,
1
);
console
.
log
(
epocheStart
);
return
[
epochStart
,
epochEnd
];
console
.
log
(
epocheEnd
);
return
[
epocheStart
,
epocheEnd
];
}
}
module
.
exports
.
getView
=
getView
;
module
.
exports
.
getView
=
getView
;
module
.
exports
.
getPropperEpocheSpan
=
getPropperEpocheSpan
;
module
.
exports
.
getPropperEpochSpan
=
getPropperEpochSpan
;
\ No newline at end of file
\ No newline at end of file
lib/timeUtils.js
View file @
b142d7fe
...
@@ -44,7 +44,7 @@ function standardFromTillDay(daySpan, timeSpan, dateSpan, epochSpan, daysDistanc
...
@@ -44,7 +44,7 @@ function standardFromTillDay(daySpan, timeSpan, dateSpan, epochSpan, daysDistanc
var
dayTo
=
daySpan
[
1
];
var
dayTo
=
daySpan
[
1
];
var
timeFrom
=
timeSpan
[
0
];
var
timeFrom
=
timeSpan
[
0
];
var
timeUntil
=
timeSpan
[
1
];
var
timeUntil
=
timeSpan
[
1
];
var
epochStart
=
dateSpan
[
0
]
;
var
epochStart
=
new
Date
(
dateSpan
[
0
])
;
var
epochEnd
=
dateSpan
[
1
];
var
epochEnd
=
dateSpan
[
1
];
var
firstDays
=
_standard
(
dayFrom
,
timeFrom
,
timeUntil
,
epochStart
,
epochEnd
,
daysDistance
);
var
firstDays
=
_standard
(
dayFrom
,
timeFrom
,
timeUntil
,
epochStart
,
epochEnd
,
daysDistance
);
...
...
serverTest/app.js
View file @
b142d7fe
...
@@ -18,7 +18,6 @@ app.use(function (req, res, next) {
...
@@ -18,7 +18,6 @@ app.use(function (req, res, next) {
next
(
err
);
next
(
err
);
});
});
if
(
app
.
get
(
'env'
)
===
'development'
)
{
if
(
app
.
get
(
'env'
)
===
'development'
)
{
app
.
use
(
function
(
err
,
req
,
res
,
next
)
{
app
.
use
(
function
(
err
,
req
,
res
,
next
)
{
res
.
status
(
err
.
status
||
500
);
res
.
status
(
err
.
status
||
500
);
...
...
serverTest/dataBaseQuery
→
serverTest/dataBaseQuery
.js
View file @
b142d7fe
...
@@ -11,28 +11,31 @@ var connection = mysql.createConnection({
...
@@ -11,28 +11,31 @@ var connection = mysql.createConnection({
connection
.
connect
();
connection
.
connect
();
module.exports.getData = function (now, cb) {
module
.
exports
.
getData
=
function
(
now
,
cb
)
{
var
epocheSpan
=
dateView
.
getPropperEpochSpan
(
now
);
var epocheSpan = dateView.getPropperEpocheSpan(now);
// console.log(now);
console.log(now);
// console.log(epocheSpan);
console.log(epocheSpan);
dateArray
.
setEpocheSpan
(
epocheSpan
);
dateArray
.
setEpocheSpan
(
epocheSpan
);
connection.query('SELECT name, elements FROM cms_zoo_item WHERE type = "company"', function
(err, rows) {
connection
.
query
(
'SELECT name, elements FROM cms_zoo_item WHERE type = "company"'
,
function
(
err
,
rows
)
{
var
result
=
[];
var
result
=
[];
var
cnt
=
0
;
for
(
var
i
=
0
;
i
<
rows
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
rows
.
length
;
i
++
)
{
var
obj
=
JSON
.
parse
(
rows
[
i
].
elements
);
var
obj
=
JSON
.
parse
(
rows
[
i
].
elements
);
var
name
=
rows
[
i
].
name
;
var
name
=
rows
[
i
].
name
;
try
{
try
{
var
data
=
dateArray
.
getData
(
obj
);
var
data
=
dateArray
.
getData
(
obj
);
if(data.length > 0) {
if
(
data
.
length
>
0
)
{
cnt
++
;
var
view
=
dateView
.
getView
(
data
,
now
);
var
view
=
dateView
.
getView
(
data
,
now
);
result.push('<div class="name">'
+ name + "</div> " +
view);
result
.
push
(
'<div class="name">'
+
name
+
"</div> "
+
view
);
}
}
}
}
catch
(
err
)
{
catch
(
err
)
{
}
}
}
}
console
.
log
(
"Count: %d"
,
cnt
);
cb
(
result
.
join
(
'<br>'
));
cb
(
result
.
join
(
'<br>'
));
});
});
};
};
...
...
serverTest/routes/index.js
View file @
b142d7fe
...
@@ -19,7 +19,7 @@ router.get('/', function(req, res) {
...
@@ -19,7 +19,7 @@ router.get('/', function(req, res) {
db
.
getData
(
now
,
function
(
result
)
{
db
.
getData
(
now
,
function
(
result
)
{
res
.
render
(
'index'
,
{
body
:
result
});
res
.
render
(
'index'
,
{
body
:
result
});
var
time1
=
process
.
hrtime
(
time0
);
var
time1
=
process
.
hrtime
(
time0
);
console
.
log
(
'Time
: '
+
(
time1
[
0
]
+
time1
[
1
]
/
1
e9
));
console
.
log
(
'Time
in ms: '
+
(
1000
*
time1
[
0
]
+
time1
[
1
]
*
1
e
-
6
));
});
});
...
...
serverTest/views/index.ejs
View file @
b142d7fe
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<head>
<title>
qwe
</title>
<title>
Views
</title>
<link
rel=
"stylesheet"
href=
"uikit.min.css"
/>
<link
rel=
"stylesheet"
href=
"uikit.min.css"
/>
<script
src=
"jquery.min.js"
></script>
<script
src=
"jquery.min.js"
></script>
<script
src=
"uikit.min.js"
></script>
<script
src=
"uikit.min.js"
></script>
...
...
test/dateViewTest.js
View file @
b142d7fe
...
@@ -5,7 +5,7 @@ var fs = require('fs');
...
@@ -5,7 +5,7 @@ var fs = require('fs');
var
now
=
new
Date
(
2014
,
4
,
1
);
var
now
=
new
Date
(
2014
,
4
,
1
);
dateArray
.
setEpocheSpan
(
dateView
.
getPropperEpoch
e
Span
(
now
));
dateArray
.
setEpocheSpan
(
dateView
.
getPropperEpochSpan
(
now
));
var
data
=
dateArray
.
getData
(
require
(
'./testData/testHof.json'
));
var
data
=
dateArray
.
getData
(
require
(
'./testData/testHof.json'
));
console
.
log
(
data
);
console
.
log
(
data
);
...
...
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