Skip to content

Commit

Permalink
New visited, refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
fortSQ committed Mar 17, 2017
1 parent afec16f commit f5961ff
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
35 changes: 3 additions & 32 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
<title>♥ Москва</title>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" rel="stylesheet">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css" rel="stylesheet">
<style>
.label { display: block; position: relative; }
.inactive { text-decoration: line-through; }
.visited:after { content: '\221A'; font-weight: bold; position: absolute; right: 0; }
</style>
<link href="style.css" rel="stylesheet">
</head>
<body>

Expand Down Expand Up @@ -48,34 +44,9 @@ <h4 class="panel-title">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js"></script>
<script src="//maps.api.2gis.ru/2.0/loader.js?pkg=full"></script>

<script src="data.js"></script>
<script>
var $list = $('.accordion')
var $patternCategory = $('#pattern-category')
var $patternPlace = $('#pattern-place')

for (var i = 0; i < data.length; i++) {
var category = data[i]

var placeList = ''
for (var place of category.list) {
placeList += $patternPlace.html()
.replace('%x', place.x)
.replace('%y', place.y)
.replace('%status', 'status' in place ? place.status : '')
.replace('%name', place.name)
}

var content = $patternCategory.html()
.replace(/%id/g, 'category_' + i)
.replace('%name', category.title)
.replace('%count', category.list.length)
.replace('%list', placeList)

$list.append(content)
}
</script>
<script src="places/moscow.js"></script>

<script src="templates.js"></script>
<script type="text/javascript">
$('#map').height($(window).height() * .75)
var map, selectedViolation
Expand Down
2 changes: 2 additions & 0 deletions data.js → places/moscow.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ var data = [
'list': [
{
'name': 'Патриарший пруд',
'status': 'visited',
'x': 55.76383,
'y': 37.592162,
},
Expand Down Expand Up @@ -226,6 +227,7 @@ var data = [
'list': [
{
'name': 'Пушкин',
'status': 'visited',
'x': 55.765348,
'y': 37.605531,
},
Expand Down
3 changes: 3 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.label { display: block; position: relative; }
.inactive { text-decoration: line-through; }
.visited:after { content: '\221A'; font-weight: bold; position: absolute; right: 0; }
24 changes: 24 additions & 0 deletions templates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var $list = $('.accordion')
var $patternCategory = $('#pattern-category')
var $patternPlace = $('#pattern-place')

for (var i = 0; i < data.length; i++) {
var category = data[i]

var placeList = ''
for (var place of category.list) {
placeList += $patternPlace.html()
.replace('%x', place.x)
.replace('%y', place.y)
.replace('%status', 'status' in place ? place.status : '')
.replace('%name', place.name)
}

var content = $patternCategory.html()
.replace(/%id/g, 'category_' + i)
.replace('%name', category.title)
.replace('%count', category.list.length)
.replace('%list', placeList)

$list.append(content)
}

0 comments on commit f5961ff

Please sign in to comment.