Simplified jumpbox 📜 (#815)

* Simplified jumpbox 📜

* Updated

* Update README.md

* Updated

* Update page_header.tpl

* Update functions.php
This commit is contained in:
Roman Kelesidis 2023-11-12 01:05:14 +07:00 committed by GitHub
commit f098041713
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 27 additions and 25 deletions

1
.gitignore vendored
View file

@ -8,7 +8,6 @@ composer.phar
configs/local.php
data/avatars
data/torrent_files
internal_data/ajax_html
internal_data/atom
internal_data/cache
internal_data/log

View file

@ -60,7 +60,6 @@ You must provide write permissions to the specified folders:
* `data/avatars`
* `data/torrent_files`
* `data/torrent_files/thumbs`
* `internal_data/ajax_html`
* `internal_data/atom`
* `internal_data/cache`
* `internal_data/log`

View file

@ -36,7 +36,6 @@ define('CHECK_REQIREMENTS', [
define('ADMIN_DIR', BB_PATH . '/admin');
define('DATA_DIR', BB_PATH . '/data');
define('INT_DATA_DIR', BB_PATH . '/internal_data');
define('AJAX_HTML_DIR', BB_PATH . '/internal_data/ajax_html');
define('CACHE_DIR', BB_PATH . '/internal_data/cache');
define('LOG_DIR', BB_PATH . '/internal_data/log');
define('TRIGGERS_DIR', BB_PATH . '/internal_data/triggers');

View file

@ -106,15 +106,14 @@ $this->store('cat_forums', $data);
//
// jumpbox
//
$data = [
'guest' => get_forum_select('guest', 'f', null, null, null, 'id="jumpbox" onchange="window.location.href=\'' . FORUM_URL . '\'+this.value;"'),
'user' => get_forum_select('user', 'f', null, null, null, 'id="jumpbox" onchange="window.location.href=\'' . FORUM_URL . '\'+this.value;"'),
];
if ($bb_cfg['show_jumpbox']) {
$data = [
'guest' => get_forum_select('guest', 'f', null, null, null, 'id="jumpbox" onchange="window.location.href=\'' . FORUM_URL . '\'+this.value;"'),
'user' => get_forum_select('user', 'f', null, null, null, 'id="jumpbox" onchange="window.location.href=\'' . FORUM_URL . '\'+this.value;"'),
];
$this->store('jumpbox', $data);
file_write($data['guest'], AJAX_HTML_DIR . '/jumpbox_guest.html', false, true, true);
file_write($data['user'], AJAX_HTML_DIR . '/jumpbox_user.html', false, true, true);
$this->store('jumpbox', $data);
}
//
// viewtopic_forum_select

View file

@ -1012,16 +1012,20 @@ function get_userdata($u, bool $is_name = false, bool $allow_guest = false)
return $u_data;
}
function make_jumpbox($selected = 0)
function make_jumpbox()
{
global $datastore, $template;
global $datastore, $template, $bb_cfg;
if (!$bb_cfg['show_jumpbox']) {
return;
}
if (!$jumpbox = $datastore->get('jumpbox')) {
$datastore->update('jumpbox');
$jumpbox = $datastore->get('jumpbox');
}
$template->assign_vars(['JUMPBOX' => (IS_GUEST) ? $jumpbox['guest'] : $jumpbox['user']]);
$template->assign_vars(['JUMPBOX' => (IS_GUEST) ? DB()->escape($jumpbox['guest']) : DB()->escape($jumpbox['user'])]);
}
// $mode: array(not_auth_forum1,not_auth_forum2,..) or (string) 'mode'

View file

@ -56,6 +56,9 @@ if (defined('SHOW_ONLINE') && SHOW_ONLINE) {
]);
}
// Make jumpbox
make_jumpbox();
// Info about new private messages
$icon_pm = $images['pm_no_new_msg'];
$pm_info = $lang['NO_NEW_PM'];
@ -192,8 +195,6 @@ $template->assign_vars([
'BONUS_URL' => BB_ROOT . BONUS_URL,
'TOPIC_URL' => BB_ROOT . TOPIC_URL,
'AJAX_HTML_DIR' => AJAX_HTML_DIR,
// Misc
'BOT_UID' => BOT_UID,
'SID' => $userdata['session_id'],

View file

@ -68,9 +68,9 @@ var user = {
}
};
<!-- IF $bb_cfg['show_jumpbox'] -->
$(document).ready(function(){
$("div.jumpbox").html('\
<!-- IF JUMPBOX -->
$(document).ready(function () {
$("div.jumpbox").html('\
<span id="jumpbox-container"> \
<select id="jumpbox"> \
<option id="jumpbox-title" value="-1">&nbsp;&raquo;&raquo; {L_JUMPBOX_TITLE} &nbsp;</option> \
@ -78,12 +78,13 @@ $(document).ready(function(){
</span> \
<input id="jumpbox-submit" type="button" class="lite" value="{L_GO}" /> \
');
$('#jumpbox-container').one('click', function(){
$('#jumpbox-title').html('&nbsp;&nbsp; {L_LOADING} ... &nbsp;');
var jumpbox_src = '/internal_data/ajax_html' + ({LOGGED_IN} ? '/jumpbox_user.html' : '/jumpbox_guest.html');
$(this).load(jumpbox_src);
$('#jumpbox-submit').click(function(){ window.location.href='{FORUM_URL}'+$('#jumpbox').val(); });
});
$('#jumpbox-container').one('click', function () {
$('#jumpbox-title').html('&nbsp;&nbsp; {L_LOADING} ... &nbsp;');
$(this).html('{JUMPBOX}');
$('#jumpbox-submit').click(function () {
window.location.href = '{FORUM_URL}' + $('#jumpbox').val();
});
});
});
<!-- ENDIF -->