diff --git a/board-search.php b/board-search.php index 7df27f4f..9c553793 100644 --- a/board-search.php +++ b/board-search.php @@ -47,7 +47,13 @@ if (isset( $_GET['lang'] ) && $_GET['lang'] != "" && isset($config['languages'][ // Include what tag? if (isset( $_GET['tags'] ) && $_GET['tags'] != "") { - $search['tags'] = explode( " ", $_GET['tags'] ); + if (!is_array($_GET['tags'])) { + $search['tags'] = explode( " ", (string) $_GET['tags'] ); + } + else { + $search['tags'] = $_GET['tags']; + } + $search['tags'] = array_splice( $search['tags'], 0, 5 ); } diff --git a/js/board-directory.js b/js/board-directory.js index b278fbde..94ccf9fd 100644 --- a/js/board-directory.js +++ b/js/board-directory.js @@ -100,7 +100,10 @@ .on( 'submit', selectors['search'], searchForms, boardlist.events.searchSubmit ) // Submit click .on( 'click', selectors['search-submit'], searchForms, boardlist.events.searchSubmit ); - + + $(window) + .on( 'hashchange', searchForms, boardlist.events.hashChange ); + $searchSubmit.prop( 'disabled', false ); } } @@ -265,6 +268,26 @@ boardlist.submit( parameters ); }, + hashChange : function(event) { + if (window.location.hash != "") { + // Turns "#porn,tits" into "porn tits" for easier search results. + var tags = window.location.hash.substr(1, window.location.hash.length).split(","), + hash = tags.join(" "); + } + else { + var tags = [], + hash = "" + } + + $( boardlist.options.selector['search-tag'], boardlist.$boardlist ).val( hash ); + $( boardlist.options.selector['tag-list'], boardlist.$boardlist ).html(""); + $( boardlist.options.selector['board-body'], boardlist.$boardlist ).html(""); + + boardlist.submit( { 'tags' : tags } ); + + return true; + }, + searchSubmit : function(event) { event.preventDefault(); @@ -330,6 +353,10 @@ boardlist.$boardlist = $boardlist; boardlist.bind.form(); + + if (window.location.hash != "") { + $(window).trigger( 'hashchange' ); + } } } }; diff --git a/templates/8chan/boards-table.html b/templates/8chan/boards-table.html index 82e48436..daf45ba1 100644 --- a/templates/8chan/boards-table.html +++ b/templates/8chan/boards-table.html @@ -5,10 +5,10 @@ /{{board['uri']}}/ {% if board['sfw'] %}{% endif %} -
{{ board['title'] }}
+
{{board['title']|e}}
{{board['pph']}}
{{board['posts_total']}}
{{board['active']}} -
{% for tag in board.tags %}{{ tag }}{% endfor %}
+
{% for tag in board.tags %}{{tag|e}}{% endfor %}
{% endfor %} \ No newline at end of file