forked from kracekumar/bangalore.python.org.in
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathindex.html
More file actions
130 lines (114 loc) · 4.97 KB
/
index.html
File metadata and controls
130 lines (114 loc) · 4.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
---
layout: default
title: Home
---
{% if page.url == "/" %}
<!-- Featured
================================================== -->
<section class="featured-posts">
<div class="section-title">
<h2><span>Featured</span></h2>
</div>
<div class="row">
{% assign posts = site.posts | where:'featured', true %}
{% for post in posts %}
{% include featuredbox.html %}
{% endfor %}
</div>
</section>
{% endif %}
<!-- Posts Navigation Toggles
================================================== -->
<section class="recent-posts">
<div class="section-title">
<h2 class="exclusive-tabs-header">
<span id="btn-meetup" class="exclusive-tab-link is-active" onclick="bangalorePythonSwitch('meetup')">Monthly Meetup Posts</span>
<span id="btn-community" class="exclusive-tab-link" onclick="bangalorePythonSwitch('community')">Community Posts</span>
</h2>
</div>
<div class="exclusive-content-area">
<!-- Monthly Meetup Pane -->
<div id="area-meetup" class="exclusive-pane">
<div class="row listrecent">
{% for post in paginator.posts %}
{% if post.categories contains 'community' %}{% continue %}{% endif %}
{% include postbox.html %}
{% endfor %}
</div>
<!-- Pagination for Meetup -->
<div class="bottompagination">
<div class="pointerup"><i class="fa fa-caret-up"></i></div>
<span class="navigation" role="navigation">
{% include pagination.html %}
</span>
</div>
</div>
<!-- Community Blog Pane -->
<div id="area-community" class="exclusive-pane">
<div id="community-posts-container" class="row listrecent">
{% assign community_posts = site.posts | where: "categories", "community" %}
{% if community_posts.size > 0 %}
{% for post in community_posts %}
{% include postbox.html %}
{% endfor %}
{% else %}
<div class="col-md-12" id="no-community-msg"><p>No community posts found.</p></div>
{% endif %}
</div>
<!-- Pagination for Community -->
<div id="community-pagination" class="bottompagination" style="display: none; margin-top: 50px;">
<div class="pointerup"><i class="fa fa-caret-up"></i></div>
<span class="navigation" role="navigation">
<div class="pagination" id="community-pagination-links">
<!-- JS will populate this -->
</div>
</span>
</div>
</div>
</div>
</section>
<script>
var communityPage = parseInt(sessionStorage.getItem('communityPage')) || 1;
function renderCommunity(page) {
var items = document.querySelectorAll('#community-posts-container .card-group');
if (!items.length) return;
var total = Math.ceil(items.length / 6);
if (page > total) page = 1;
communityPage = page;
sessionStorage.setItem('communityPage', page);
var start = (page - 1) * 6, end = start + 6;
items.forEach(function(it, i) {
it.style.setProperty('display', (i >= start && i < end) ? 'block' : 'none', 'important');
});
var nav = document.getElementById('community-pagination');
if (total <= 1) {
if (nav) nav.style.display = 'none';
return;
}
if (nav) nav.style.display = 'block';
var html = (page > 1 ? '<a class="ml-1 mr-1" style="color: #00ab6b;" onclick="renderCommunity('+(page-1)+')">« Prev</a>' : '<span class="ml-1 mr-1">« Prev</span>');
for (var i = 1; i <= total; i++) {
html += (i === page ? '<span class="ml-1 mr-1" style="color: #292b2c; font-weight: bold;">'+i+'</span>' : '<a class="ml-1 mr-1" style="color: #00ab6b;" onclick="renderCommunity('+i+')">'+i+'</a>');
}
html += (page < total ? '<a class="ml-1 mr-1" style="color: #00ab6b;" onclick="renderCommunity('+(page+1)+')">Next »</a>' : '<span class="ml-1 mr-1">Next »</span>');
document.getElementById('community-pagination-links').innerHTML = html;
}
function bangalorePythonSwitch(type) {
var isComm = type === 'community';
sessionStorage.setItem('activeTab', type);
['meetup', 'community'].forEach(function(t) {
var pane = document.getElementById('area-' + t);
var btn = document.getElementById('btn-' + t);
if (pane) pane.classList.toggle('is-visible', (t === type));
if (btn) btn.classList.toggle('is-active', (t === type));
});
if (isComm) renderCommunity(communityPage);
}
document.addEventListener('DOMContentLoaded', function() {
var savedTab = sessionStorage.getItem('activeTab') || 'meetup';
if (savedTab === 'community') {
renderCommunity(communityPage);
}
bangalorePythonSwitch(savedTab);
});
</script>