Skip to content

Commit 9c618d3

Browse files
committed
applied some patches - v1.1.1
- auto-scroll to search results. - auto focus on contribute page. - remove duplicate JS code.
1 parent f6379a3 commit 9c618d3

5 files changed

Lines changed: 30 additions & 45 deletions

File tree

app/static/app/js/custom.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
setTimeout(function focusMe(){
3+
document.getElementById("focus-here").scrollIntoView();
4+
});
5+
6+
function share(title, link){
7+
if (navigator.share) {
8+
navigator.share({
9+
title: title,
10+
url: link,
11+
})
12+
.then(() => console.log('Successful Share'))
13+
.catch((error) => console.log('Error sharing', error));
14+
}
15+
}
16+
17+
async function registerSW(){
18+
if('serviceWorker' in navigator) {
19+
try{
20+
await navigator.serviceWorker.register("{% static 'app/js/sw.js' %}");
21+
} catch(e) {
22+
console.log('SW Registration Failed.');
23+
}
24+
}
25+
}

app/templates/base.html

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,31 +68,11 @@
6868
<script async src="https://c6.patreon.com/becomePatronButton.bundle.js"></script>
6969
<script src="https://cdnjs.cloudflare.com/ajax/libs/randomcolor/0.5.4/randomColor.min.js"></script>
7070
<script src="{% static 'app/js/colorpad.js' %}"></script>
71+
<script async src="{% static 'app/js/custom.js' %}"></script>
7172
<script type="text/javascript">
7273
window.onload = function() {
7374
registerSW();
7475
};
75-
async function registerSW(){
76-
if('serviceWorker' in navigator) {
77-
try{
78-
await navigator.serviceWorker.register("{% static 'app/js/sw.js' %}");
79-
} catch(e) {
80-
console.log('SW Registration Failed.');
81-
}
82-
}
83-
}
84-
</script>
85-
<script type="text/javascript">
86-
function share(title, link){
87-
if (navigator.share) {
88-
navigator.share({
89-
title: title,
90-
url: link,
91-
})
92-
.then(() => console.log('Successful Share'))
93-
.catch((error) => console.log('Error sharing', error));
94-
}
95-
}
9676
</script>
9777
</body>
9878
</html>

app/templates/contribute.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ <h2 class="title is-3"><i>{{ error }}</i></h2>
3737
<div class="field">
3838
<label class="label">Link</label>
3939
<div class="control">
40-
<input class="input is-rounded" type="url" name="tlink" placeholder="paste tutorial link here">
40+
<input class="input is-rounded" type="url" name="tlink" placeholder="paste tutorial link here" autofocus>
4141
</div>
4242
</div>
4343

app/templates/home.html

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ <h1 class="title" align="center">Search Tutorials</h1>
105105
</div>
106106
</div>
107107
<div class="control">
108-
<button class="button is-primary is-rounded" type="submit">Submit</button>
108+
<button class="button is-primary is-rounded" onclick='focusMe()' type="submit">Submit</button>
109109
</div>
110110
</form>
111111
</div>
@@ -126,31 +126,11 @@ <h1 class="title" align="center">Search Tutorials</h1>
126126
</div>
127127
</footer>
128128
<script async src="https://c6.patreon.com/becomePatronButton.bundle.js"></script>
129+
<script async src="{% static 'app/js/custom.js' %}"></script>
129130
<script type="text/javascript">
130131
window.onload = function() {
131132
registerSW();
132133
};
133-
async function registerSW(){
134-
if('serviceWorker' in navigator) {
135-
try{
136-
await navigator.serviceWorker.register("{% static 'app/js/sw.js' %}");
137-
} catch(e) {
138-
console.log('SW Registration Failed.');
139-
}
140-
}
141-
}
142-
</script>
143-
<script type="text/javascript">
144-
function share(title, link){
145-
if (navigator.share) {
146-
navigator.share({
147-
title: title,
148-
url: link,
149-
})
150-
.then(() => console.log('Successful Share'))
151-
.catch((error) => console.log('Error sharing', error));
152-
}
153-
}
154134
</script>
155135
</body>
156136
</html>

app/templates/search_results.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% block content %}
44

55
{% if object_list %}
6-
<div class="section">
6+
<div class="section" id="focus-here">
77
<h3 class="subtitle">Search Results for "{{ tquery }}"</h3>
88
<div class="container">
99

0 commit comments

Comments
 (0)