Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
whats-open-web
Commits
4ec4d92c
Commit
4ec4d92c
authored
May 02, 2017
by
mdsecurity
Browse files
fixing openFor method so it works with Food Trucks
parent
7e154b7c
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/app/place-window/area/area.component.ts
View file @
4ec4d92c
...
...
@@ -7,12 +7,15 @@ import { Place } from '../../Place';
styleUrls
:
[
'
./area.component.scss
'
]
})
export
class
AreaComponent
implements
OnInit
{
private
places
:
Place
[]
=
[]
private
places
:
Place
[]
=
[];
private
placee
:
Place
=
new
Place
();
constructor
(
private
dataProvider
:
DataProviderService
)
{
}
ngOnInit
()
{
this
.
dataProvider
.
getFacilities
().
subscribe
(
(
places
)
=>
{
this
.
places
=
places
;},
(
places
)
=>
{
this
.
places
=
places
;
this
.
placee
=
places
[
2
];
console
.
log
(
places
[
2
]);},
(
error
)
=>
{
console
.
log
(
error
);
}
)
}
...
...
src/app/place-window/area/place-card/place-card.component.html
View file @
4ec4d92c
...
...
@@ -24,12 +24,13 @@
</div>
</div>
<ng-template
#elseBlock
>
<div
class=
"closed-shader"
></div>
hello
<!--<div class="closed-shader"></div>
<div class="place-open-badge" style="width:102px;background-color:#C4B9B9;">
<div class="place-status">CLOSED</div>
<div class="place-divider"></div>
<div class="place-time-remaining">~{{place.openFor().hour}}Hrs</div>
</div>
</div>
-->
</ng-template>
<div
class=
"place-location"
>
{{place.location }}
</div>
...
...
src/app/place-window/area/place-card/place-card.component.ts
View file @
4ec4d92c
...
...
@@ -14,18 +14,18 @@ import {DomSanitizer} from '@angular/platform-browser';
export
class
PlaceCardComponent
implements
OnInit
{
@
Input
()
private
place
:
Place
;
private
status
:
string
;
private
show
;
private
week
:
string
[]
=
[
"
MON
"
,
"
TUE
"
,
"
WED
"
,
"
THU
"
,
"
FRI
"
,
"
SAT
"
,
"
SUN
"
];
private
url
;
constructor
(
private
dataProvider
:
DataProviderService
,
public
dialog
:
MdDialog
,
private
sanitizer
:
DomSanitizer
)
{
}
ngOnInit
()
{
this
.
url
=
this
.
sanitizer
.
bypassSecurityTrustUrl
(
'
https://unsplash.it/200/300?image=
'
+
Math
.
floor
((
Math
.
random
()
*
999
+
1
)));
}
openInContext
()
{
this
.
dataProvider
.
setContext
(
this
.
place
);
// console.log(this.place.openFor().hour+ " "+ this.place.openFor().minute+ " "+ this.place.openFor().second)
console
.
log
(
this
.
place
);
//
console.log(this.place);
}
openDialog
()
{
let
dialogRef
=
this
.
dialog
.
open
(
FeedbackDialogComponent
);
...
...
src/app/place.ts
View file @
4ec4d92c
...
...
@@ -25,7 +25,7 @@ export class Place {
isOpen
():
boolean
{
const
currTime
=
new
Date
();
const
inSeconds
=
currTime
.
getHours
()
*
60
*
60
+
currTime
.
getMinutes
()
*
60
+
currTime
.
getSeconds
();
const
dayOfWeekShift
=
[
6
,
5
,
4
,
3
,
2
,
1
,
0
];
const
dayOfWeekShift
=
[
6
,
0
,
1
,
2
,
3
,
4
,
5
];
const
dayOfWeek
=
dayOfWeekShift
[
currTime
.
getDay
()];
const
useSpecialSchedule
=
this
.
useSpecial
();
let
schedule
;
...
...
@@ -34,36 +34,61 @@ export class Place {
}
else
{
schedule
=
this
.
special_schedules
[
useSpecialSchedule
].
openTimes
;
}
// for (let i = 0; i < schedule.length; i++) {
// const day = schedule[i];
// // change the order of if statements at some point
// if (day.start_day !== day.end_day) {
// if (day.end_day === dayOfWeek) {
// if (day.end_time.inSeconds() > inSeconds) {
// return true;
// }
// } else if (day.start_day === dayOfWeek) {
// return true;
// }
// } else {
// if (day.start_day === dayOfWeek) {
// if (day.end_time.inSeconds() > inSeconds) {
// return true;
// }
// }
// }
// }
for
(
let
i
=
0
;
i
<
schedule
.
length
;
i
++
)
{
const
day
=
schedule
[
i
];
// change the order of if statements at some point
if
(
day
.
start_day
!==
day
.
end_day
)
{
if
(
day
.
end_day
===
dayOfWeek
)
{
if
(
day
.
end_time
.
inSeconds
()
>
inSeconds
)
{
if
((
dayOfWeek
===
day
.
start_day
||
dayOfWeek
===
day
.
end_day
)
&&
day
.
start_day
===
day
.
end_day
)
{
if
(
inSeconds
>=
day
.
start_time
.
inSeconds
())
{
if
(
inSeconds
<=
day
.
end_time
.
inSeconds
())
{
return
true
;
}
}
else
if
(
day
.
start_day
===
dayOfWeek
)
{
return
true
;
return
false
;
}
}
else
{
if
(
day
.
start_day
===
dayOfWeek
)
{
if
(
day
.
end_time
.
inSeconds
()
>
inSeconds
)
{
return
false
;
}
else
if
(
dayOfWeek
>=
day
.
start_day
&&
dayOfWeek
<=
day
.
end_day
)
{
if
(
dayOfWeek
===
day
.
start_day
)
{
if
(
inSeconds
>=
day
.
start_time
.
inSeconds
())
{
return
true
;
}
return
false
;
}
else
if
(
dayOfWeek
===
day
.
end_day
)
{
if
(
inSeconds
>=
day
.
end_time
.
inSeconds
())
{
return
false
;
}
return
true
;
}
else
{
return
true
;
}
}
}
console
.
log
(
'
false
'
);
return
false
;
}
openFor
():
Time
{
openFor
():
any
{
const
currTime
=
new
Date
();
const
today
=
currTime
.
getDay
()
-
1
;
const
inSeconds
=
currTime
.
getHours
()
*
60
*
60
+
currTime
.
getMinutes
()
*
60
+
currTime
.
getSeconds
();
const
dayOfWeekShift
=
[
6
,
5
,
4
,
3
,
2
,
1
,
0
];
const
dayOfWeekShift
=
[
6
,
0
,
1
,
2
,
3
,
4
,
5
];
const
dayOfWeek
=
dayOfWeekShift
[
currTime
.
getDay
()];
const
useSpecialSchedule
=
this
.
useSpecial
();
let
timeTilClose
=
new
Time
();
let
sumSeconds
=
0
;
...
...
@@ -73,25 +98,59 @@ export class Place {
}
else
{
schedule
=
this
.
special_schedules
[
useSpecialSchedule
].
openTimes
;
}
// clean up if statements later
// if (this.isOpen()) {
for
(
let
i
=
0
;
i
<
schedule
.
length
;
i
++
)
{
const
day
=
schedule
[
i
];
if
(
day
.
end_day
!==
day
.
start_day
)
{
if
(
dayOfWeek
===
day
.
end_day
)
{
sumSeconds
=
day
.
end_time
.
inSeconds
()
-
inSeconds
-
86400
;
}
else
if
(
dayOfWeek
===
day
.
start_day
)
{
sumSeconds
=
day
.
end_time
.
inSeconds
()
+
86400
-
inSeconds
;
// for (let i = 0; i < schedule.length; i++) {
// const day = schedule[i];
// if (day.end_day !== day.start_day) {
// if (dayOfWeek === day.end_day) {
// sumSeconds = day.end_time.inSeconds() - inSeconds - 86400;
// } else if (dayOfWeek === day.start_day) {
// sumSeconds = day.end_time.inSeconds() + 86400 - inSeconds;
// }
// } else {
// sumSeconds = day.end_time.inSeconds() - inSeconds;
// }
// return timeTilClose.fromSeconds(sumSeconds);
// }
for
(
let
i
=
0
;
i
<
schedule
.
length
;
i
++
)
{
const
day
=
schedule
[
i
];
if
((
dayOfWeek
===
day
.
start_day
||
dayOfWeek
===
day
.
end_day
)
&&
day
.
start_day
===
day
.
end_day
)
{
if
(
inSeconds
>=
day
.
start_time
.
inSeconds
())
{
if
(
inSeconds
<=
day
.
end_time
.
inSeconds
())
{
sumSeconds
=
day
.
end_time
.
inSeconds
()
-
inSeconds
;
}
else
{
//not done
sumSeconds
=
86400
-
inSeconds
;
}
}
else
{
sumSeconds
=
day
.
end
_time
.
inSeconds
()
-
inSeconds
;
sumSeconds
=
day
.
start
_time
.
inSeconds
()
-
inSeconds
;
}
// console.log(sumSeconds);
return
timeTilClose
.
fromSeconds
(
sumSeconds
);
}
else
if
(
dayOfWeek
>=
day
.
start_day
&&
dayOfWeek
<=
day
.
end_day
)
{
if
(
dayOfWeek
===
day
.
start_day
)
{
if
(
inSeconds
>=
day
.
start_time
.
inSeconds
())
{
sumSeconds
=
86400
-
inSeconds
+
(
86400
*
(
day
.
end_day
-
day
.
start_day
-
1
))
+
day
.
end_time
.
inSeconds
();
}
else
{
sumSeconds
=
day
.
start_time
.
inSeconds
()
-
inSeconds
;
}
}
else
if
(
dayOfWeek
===
day
.
end_day
)
{
if
(
inSeconds
>=
day
.
end_time
.
inSeconds
())
{
//not done
sumSeconds
=
86400
-
inSeconds
;
}
else
{
sumSeconds
=
day
.
end_time
.
inSeconds
()
-
inSeconds
;
}
}
else
{
sumSeconds
=
86400
-
inSeconds
+
(
86400
*
(
day
.
end_day
-
dayOfWeek
-
2
))
+
day
.
end_time
.
inSeconds
();
}
// console.log(sumSeconds);
return
timeTilClose
.
fromSeconds
(
sumSeconds
);
}
// } else {
return
timeTilClose
;
//
}
}
return
{
"
hour
"
:
"
closed
"
}
;
}
useSpecial
():
number
{
...
...
src/app/time.ts
View file @
4ec4d92c
...
...
@@ -4,7 +4,7 @@ export class Time {
second
:
number
;
constructor
(
hour
?:
number
,
minute
?:
number
,
second
?:
number
)
{
this
.
hour
=
hour
||
1
;
this
.
hour
=
hour
||
0
;
this
.
minute
=
minute
||
0
;
this
.
second
=
second
||
0
;
}
...
...
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