Commit 08f92077 authored by Martin Bieder's avatar Martin Bieder

Hervorheben gesuchter Wörter; Cleanup

parent 17b9266a
......@@ -11,3 +11,5 @@
<!-- Custom Theme JavaScript -->
<script src="{{ site.baseurl }}/js/creative.js"></script>
<script src="{{ site.baseurl }}/js/ew.js"></script>
......@@ -20,7 +20,8 @@
{% include footer.html %}
{% include scripts.html %}
<script src="{{ site.baseurl }}/js/sources.js"></script>
<script src="{{ site.baseurl }}/bower_components/jQuery.highlightRegex/highlightRegex.min.js"></script>
<script src="{{ site.baseurl }}/js/post.js"></script>
</body>
</html>
......@@ -6,6 +6,10 @@ sup>a:target {
background: yellow;
}
.highlight {
background: yellow;
}
.breadcrumb {
margin-top: -30px;
margin-bottom: 30px;
......
......@@ -18,6 +18,7 @@
"animate.css": "~3.4.0",
"bootstrap": "~3.3.5",
"jquery": "~2.1.4",
"simple-jekyll-search": "~1.0.7"
"simple-jekyll-search": "~1.0.7",
"jQuery.highlightRegex": "jquery-highlightRegex#~0.1.2"
}
}
(function($) {
/**
* Gesuchten Begriff an URL anhängen
*/
var $container = $('#results-container');
if ($container.length > 0) {
$container.delegate('a', 'click', function(evt) {
evt.preventDefault();
window.location.href = $(this).attr('href') + '#highlight=' + $('#search-input').val();
});
}
})(jQuery);
/**
* Funktionalität für den Klick-Support der Quellenangaben.
*/
(function($) {
/**
* Funktionalität für den Klick-Support der Quellenangaben.
*/
var $sups = $('sup');
// <sup> durchlaufen und zu Links umwandeln
......@@ -38,4 +38,22 @@
);
$anchor.removeAttr('href');
});
/**
* Hervorheben von Suchbegriffen
*/
var hash = window.location.hash;
if (hash.indexOf('#highlight=') !== -1) {
var highlight = hash.replace('#highlight=', '');
$('p').highlightRegex(new RegExp(highlight, 'gi'));
/*$('p').each(function() {
$(this).html(
$(this).html().replace(
rgxp,
'<span class="highlighted">' + highlight + '</span>'
)
);
});*/
}
})(jQuery);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment