Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
O
OSMyBiz
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
35
Issues
35
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
2
Merge Requests
2
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
geometalab
OSMyBiz
Commits
d7016e77
Commit
d7016e77
authored
Aug 15, 2019
by
Seemann Benjamin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up spelling
parent
233ff33e
Pipeline
#76516144
passed with stages
in 3 minutes and 29 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
26 deletions
+26
-26
frontend/osmybiz/src/store/converter.js
frontend/osmybiz/src/store/converter.js
+26
-26
No files found.
frontend/osmybiz/src/store/converter.js
View file @
d7016e77
...
...
@@ -276,7 +276,7 @@ function switchDayAndMonthPosition(input) {
return
output
;
}
function
removeWrongDouble
p
oints
(
input
)
{
function
removeWrongDouble
P
oints
(
input
)
{
let
output
=
`
${
input
}
`
;
const
doublePointsInMonths
=
/
(
Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec
)
:
\s([
0
][
1-9
]
|
[
1-2
][
0-9
]
|
[
3
][
0-1
]
|
[
1-9
])(
:00
)?
/g
;
output
=
output
.
replace
(
doublePointsInMonths
,
(
_1
,
_2
,
_3
)
=>
`
${
_2
}
${
_3
}
`
);
...
...
@@ -290,7 +290,7 @@ function addMissingZeroesDays(input) {
return
output
;
}
function
monthRa
gn
eEndCorrection
(
input
)
{
function
monthRa
ng
eEndCorrection
(
input
)
{
let
output
=
`
${
input
}
`
;
const
detectWrongEnd
=
/
(
Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec
)\s([
0-2
][
0-9
]
|
[
3
][
0-1
])
;/g
;
output
=
output
.
replace
(
detectWrongEnd
,
(
_1
,
_2
,
_3
)
=>
`
${
_2
}
${
_3
}
:`
);
...
...
@@ -405,21 +405,21 @@ function combineDaysWithSameTimes(input) {
}
const
intermediate
=
`
${
output
}
`
;
const
matchingDays
=
intermediate
.
match
(
daysAndTime
);
const
split
t
DaysAndTime
=
[];
const
splitDaysAndTime
=
[];
if
(
matchingDays
)
{
for
(
let
a
=
0
;
a
<
matchingDays
.
length
;
a
+=
1
)
{
split
t
DaysAndTime
.
push
(
daysAndTime
.
exec
(
intermediate
));
splitDaysAndTime
.
push
(
daysAndTime
.
exec
(
intermediate
));
}
let
combinedTimes
=
[];
let
checkTime
=
''
;
let
result
=
''
;
for
(
let
a
=
0
;
a
<
split
t
DaysAndTime
.
length
;
a
+=
1
)
{
for
(
let
a
=
0
;
a
<
splitDaysAndTime
.
length
;
a
+=
1
)
{
if
(
combinedTimes
.
length
===
0
)
{
const
[,
combinedTime
,
_checkTime
]
=
split
t
DaysAndTime
[
a
];
const
[,
combinedTime
,
_checkTime
]
=
splitDaysAndTime
[
a
];
combinedTimes
.
push
(
combinedTime
);
checkTime
=
_checkTime
;
}
else
if
(
checkTime
===
split
t
DaysAndTime
[
a
][
2
])
{
combinedTimes
.
push
(
split
t
DaysAndTime
[
a
][
1
]);
}
else
if
(
checkTime
===
splitDaysAndTime
[
a
][
2
])
{
combinedTimes
.
push
(
splitDaysAndTime
[
a
][
1
]);
}
else
{
result
=
`
${
result
}${
combinedTimes
}
${
checkTime
}
; `
;
combinedTimes
=
[];
...
...
@@ -466,19 +466,19 @@ function sortDays(input) {
'
([-,])?
\\
s?
\\
b(Mo|T[hu]|We|Fr|S[au])?
\\
b
\\
s?([-,])?
\\
s?
\\
b(Mo|T[hu]|We|Fr|S[au]|PH)?
'
+
'
\\
b
\\
s?(off;)?((([0-1]?[0-9]|[2][0-4]):[0-5][0-9])
\\
s?([-+])
\\
s?(([0-1]?[0-9]|[2][0-4]):[0-5][0-9])?;?
'
+
'
(
\\
s?,
\\
s*(([0-1]?[0-9]|[2][0-4]):[0-5][0-9])(
\\
+|
\\
s?-
\\
s?(([0-1]?[0-9]|[2][0-4]):[0-5][0-9])))*;?)?(off)?
'
,
'
gm
'
);
const
openingHoursSep
e
ratedByDays
=
output
.
toString
().
match
(
stringForm
);
const
openingHoursSep
a
ratedByDays
=
output
.
toString
().
match
(
stringForm
);
const
weekDays
=
[
'
Mo
'
,
'
Tu
'
,
'
We
'
,
'
Th
'
,
'
Fr
'
,
'
Sa
'
,
'
Su
'
,
'
PH
'
];
const
days
=
[
false
,
false
,
false
,
false
,
false
,
false
,
false
,
false
];
let
orderedByWeekdays
=
[];
if
(
openingHoursSep
e
ratedByDays
)
{
for
(
let
a
=
0
;
a
<
openingHoursSep
e
ratedByDays
.
length
;
a
+=
1
)
{
if
(
openingHoursSep
a
ratedByDays
)
{
for
(
let
a
=
0
;
a
<
openingHoursSep
a
ratedByDays
.
length
;
a
+=
1
)
{
for
(
let
b
=
0
;
b
<
weekDays
.
length
;
b
+=
1
)
{
if
(
openingHoursSep
e
ratedByDays
[
a
].
toString
().
startsWith
(
weekDays
[
b
]))
{
if
(
openingHoursSep
a
ratedByDays
[
a
].
toString
().
startsWith
(
weekDays
[
b
]))
{
if
(
days
[
b
]
===
false
)
{
orderedByWeekdays
[
b
]
=
openingHoursSep
e
ratedByDays
[
a
];
orderedByWeekdays
[
b
]
=
openingHoursSep
a
ratedByDays
[
a
];
days
[
b
]
=
true
;
}
else
{
orderedByWeekdays
[
b
]
=
`
${
orderedByWeekdays
[
b
]}
,
${
openingHoursSep
e
ratedByDays
[
a
].
replace
(
stringForm
,
(
_1
,
_2
,
_3
,
_4
,
_5
,
_6
,
_7
,
_8
)
=>
_8
)}
`
;
orderedByWeekdays
[
b
]
=
`
${
orderedByWeekdays
[
b
]}
,
${
openingHoursSep
a
ratedByDays
[
a
].
replace
(
stringForm
,
(
_1
,
_2
,
_3
,
_4
,
_5
,
_6
,
_7
,
_8
)
=>
_8
)}
`
;
orderedByWeekdays
[
b
]
=
orderedByWeekdays
[
b
].
replace
(
/;/g
,
''
);
}
}
...
...
@@ -782,9 +782,9 @@ function convert(input) {
hoursToConvert
=
sortMonths
(
hoursToConvert
);
hoursToConvert
=
correctMonthDays
(
hoursToConvert
);
hoursToConvert
=
switchDayAndMonthPosition
(
hoursToConvert
);
hoursToConvert
=
removeWrongDouble
p
oints
(
hoursToConvert
);
hoursToConvert
=
removeWrongDouble
P
oints
(
hoursToConvert
);
hoursToConvert
=
addMissingZeroesDays
(
hoursToConvert
);
hoursToConvert
=
monthRa
gn
eEndCorrection
(
hoursToConvert
);
hoursToConvert
=
monthRa
ng
eEndCorrection
(
hoursToConvert
);
hoursToConvert
=
monthsAddSpace
(
hoursToConvert
);
hoursToConvert
=
combineSameMonths
(
hoursToConvert
);
hoursToConvert
=
hoursToConvert
.
replace
(
multipleSpecificDates
,
(
_1
)
=>
{
...
...
@@ -809,7 +809,7 @@ function convert(input) {
}
// this reads the needed data out of the dom
function
scriptHand
e
ling
(
input
)
{
function
scriptHandling
(
input
)
{
let
result
;
let
outputString
=
'
'
;
outputString
+=
input
.
toString
().
replace
(
/"/g
,
'
\'
'
);
...
...
@@ -823,8 +823,8 @@ function scriptHandeling(input) {
outputString
=
outputString
.
replace
(
cutRemainingNotRelevantPart
,
(
_1
,
_2
)
=>
_2
);
const
cutJSONParts
=
/
(
http:
\/\/
schema.org
\/
|{"@type":"OpeningHoursSpecification",|},|"dayOfWeek":|"openingHoursSpecification":
\[
|]|}
)
/g
;
outputString
=
outputString
.
replace
(
cutJSONParts
,
''
);
const
removeSep
e
rators
=
/
(
','|':'
)
/g
;
outputString
=
outputString
.
replace
(
removeSep
e
rators
,
'
'
);
const
removeSep
a
rators
=
/
(
','|':'
)
/g
;
outputString
=
outputString
.
replace
(
removeSep
a
rators
,
'
'
);
outputString
=
outputString
.
replace
(
/""/g
,
'
'
);
outputString
=
outputString
.
replace
(
/closes/g
,
'
-
'
);
outputString
=
outputString
.
replace
(
/"|opens/g
,
''
);
...
...
@@ -836,8 +836,8 @@ function scriptHandeling(input) {
return
result
;
}
function
handelShemaOrg
(
string
)
{
// this handels opning hours when written in markdown
function
handelS
c
hemaOrg
(
string
)
{
// this handels op
e
ning hours when written in markdown
const
el
=
document
.
createElement
(
'
html
'
);
el
.
innerHTML
=
string
.
toString
();
const
microOH
=
$
(
el
).
find
(
'
[itemprop="openingHours"]
'
);
...
...
@@ -864,9 +864,9 @@ function handelShemaOrg(string) {
rdfa
=
''
;
}
const
rdfaResponse
=
(
`
${
rdfaOH
}
${
rdfa
}
`
).
trim
();
// this handels opening hours specified in the script application/ld+json
// this handel
'
s opening hours specified in the script application/ld+json
const
scripts
=
`
${
$
(
el
).
find
(
"
[type='application/ld+json']
"
).
html
()}
`
;
let
scriptResponse
=
scriptHand
e
ling
(
scripts
);
let
scriptResponse
=
scriptHandling
(
scripts
);
if
(
scriptResponse
===
'
No valid input
'
)
{
scriptResponse
=
''
;
}
...
...
@@ -920,10 +920,10 @@ export default async function isURL(url) {
if
(
input
.
match
(
UrlRegex
))
{
const
fetched
=
await
getSourceAsDom
(
input
);
if
(
fetched
!=
null
)
{
output
=
handelShemaOrg
(
fetched
);
output
=
handelS
c
hemaOrg
(
fetched
);
}
else
{
// TODO prop
p
er error handling
console
.
log
(
'
failed to fetch
'
);
// TODO proper error handling
console
.
log
(
'
failed to fetch
website
'
);
}
}
else
if
(
input
.
match
(
/
[
0-9
]
/g
))
{
output
=
convert
(
input
);
...
...
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