From c04d46933efa20fda9bb4697f2b11c92af78bad8 Mon Sep 17 00:00:00 2001 From: 8chan Date: Tue, 10 Mar 2015 16:18:28 -0700 Subject: [PATCH] New post form part one --- inc/functions.php | 33 +++++++++--------------- inc/instance-config.php | 2 +- js/ajax.js | 2 +- js/quick-reply.js | 7 ++--- js/settings.js | 2 +- stylesheets/style.css | 20 +++++++++++---- templates/post_form.html | 55 ++++++++++++++++++++++++---------------- 7 files changed, 65 insertions(+), 56 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 3c53043c..382725e2 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -2410,33 +2410,19 @@ function shell_exec_error($command, $suppress_stdout = false) { */ function diceRoller($post) { global $config; - if(strpos(strtolower($post->email), 'dice%20') === 0) { - $dicestr = str_split(substr($post->email, strlen('dice%20'))); - + if (isset($_POST['dx'], $_POST['dy'], $_POST['dz']) && !empty($_POST['dy'])) { // Get params - $diceX = ''; - $diceY = ''; - $diceZ = ''; - - $curd = 'diceX'; - for($i = 0; $i < count($dicestr); $i ++) { - if(is_numeric($dicestr[$i])) { - $$curd .= $dicestr[$i]; - } else if($dicestr[$i] == 'd') { - $curd = 'diceY'; - } else if($dicestr[$i] == '-' || $dicestr[$i] == '+') { - $curd = 'diceZ'; - $$curd = $dicestr[$i]; - } - } + $diceX = $_POST['dx']; + $diceY = $_POST['dy']; + $diceZ = $_POST['dz']; // Default values for X and Z if($diceX == '') { - $diceX = '1'; + $diceX = 1; } if($diceZ == '') { - $diceZ = '+0'; + $diceZ = 0; } // Intify them @@ -2453,6 +2439,10 @@ function diceRoller($post) { $diceX = 200; } + if (abs($diceZ) > 1000000) { + $diceZ = 0; + } + // Continue only if we have valid values if($diceX > 0 && $diceY > 0) { $dicerolls = array(); @@ -2466,7 +2456,8 @@ function diceRoller($post) { // Prepend the result to the post body $modifier = ($diceZ != 0) ? ((($diceZ < 0) ? ' - ' : ' + ') . abs($diceZ)) : ''; $dicesum = ($diceX > 1) ? ' = ' . $dicesum : ''; - $post->body = '
Dice rollRolled ' . implode(', ', $dicerolls) . $modifier . $dicesum . '

' . $post->body; + $rollstring = "{$diceX}d{$diceY}"; + $post->body = '
Dice rollRolled ' . implode(', ', $dicerolls) . $modifier . $dicesum . " ($rollstring)

" . $post->body; } } } diff --git a/inc/instance-config.php b/inc/instance-config.php index ad78b452..ad46a030 100644 --- a/inc/instance-config.php +++ b/inc/instance-config.php @@ -137,13 +137,13 @@ $config['additional_javascript'][] = 'js/catalog-search.js'; $config['additional_javascript'][] = 'js/thread-stats.js'; $config['additional_javascript'][] = 'js/quote-selection.js'; - $config['additional_javascript'][] = 'js/twemoji/twemoji.js'; $config['additional_javascript'][] = 'js/flag-previews.js'; $config['additional_javascript'][] = 'js/post-menu.js'; $config['additional_javascript'][] = 'js/post-filter.js'; $config['additional_javascript'][] = 'js/fix-report-delete-submit.js'; $config['additional_javascript'][] = 'js/image-hover.js'; $config['additional_javascript'][] = 'js/auto-scroll.js'; + $config['additional_javascript'][] = 'js/twemoji/twemoji.js'; //$config['font_awesome_css'] = '/netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css'; diff --git a/js/ajax.js b/js/ajax.js index 11fac152..794e6a48 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -103,7 +103,7 @@ $(window).ready(function() { $(form).find('input[type="submit"]').val(submit_txt); $(form).find('input[type="submit"]').removeAttr('disabled'); $(form).find('input[name="subject"],input[name="file_url"],\ - textarea[name="body"],input[type="file"]').val('').change(); + textarea[name="body"],input[type="file"],input[name="embed"]').val('').change(); }, cache: false, contentType: false, diff --git a/js/quick-reply.js b/js/quick-reply.js index c5738eec..399e759b 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -98,9 +98,6 @@ #quick-reply .nonsense {\ display: none;\ }\ - #quick-reply td.submit {\ - width: 1%;\ - }\ #quick-reply td.recaptcha {\ text-align: center;\ padding: 0 0 1px 0;\ @@ -257,7 +254,7 @@ } // Remove mod controls, because it looks shit. - if ($td.find('input[type="checkbox"]').length) { + /*if ($td.find('input[type="checkbox"]').length) { var tr = this; $td.find('input[type="checkbox"]').each(function() { if ($(this).attr('name') == 'spoiler') { @@ -272,7 +269,7 @@ $(tr).remove(); } }); - } + }*/ $td.find('small').hide(); } diff --git a/js/settings.js b/js/settings.js index 81e88f7a..267a85aa 100644 --- a/js/settings.js +++ b/js/settings.js @@ -35,7 +35,7 @@ tb_settings['quick-reply'] = { // Show remote in quick reply show_remote: false, // Show embedding in quick reply - show_embed: false + show_embed: true }; // ajax.js diff --git a/stylesheets/style.css b/stylesheets/style.css index ef26f40c..45d57e19 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -79,10 +79,6 @@ header div.subtitle { font-size: 8pt; } -form { - margin-bottom: 4em; -} - form table { margin: auto; } @@ -131,7 +127,10 @@ form table tr th { form table tr td div.center { text-align: center; float: left; - padding-left: 3px; + padding: 3px; + padding-top: 0px; + border: 1px dashed black; + margin: 2px } form table tr td div input { @@ -261,6 +260,11 @@ p.intro a { margin-left: 5px; } +.sage { + color: red; + font-weight: bold; +} + div.delete { float: right; } @@ -1035,3 +1039,9 @@ div.mix { display: block!important; font-size: 12pt; } + +.dx,.dy,.dz { + width: 30px; + text-align: right; + display: inline-block; +} diff --git a/templates/post_form.html b/templates/post_form.html index 5f0d43ef..403af40c 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -11,7 +11,7 @@ {% if not config.field_disable_name or (mod and post.mod|hasPermission(config.mod.bypass_field_disable, board.uri)) %}{% endif %} {% if not config.field_disable_email or (mod and post.mod|hasPermission(config.mod.bypass_field_disable, board.uri)) %}{% endif %} {% if not (config.field_disable_subject or (id and config.field_disable_reply_subject)) or (mod and post.mod|hasPermission(config.mod.bypass_field_disable, board.uri)) %} {% endif %} @@ -98,7 +98,7 @@ {% if config.user_flag %} - + {% endif %} - {% if (mod and ((not id and post.mod|hasPermission(config.mod.sticky, board.uri)) or (not id and post.mod|hasPermission(config.mod.lock, board.uri)) or post.mod|hasPermission(config.mod.rawhtml, board.uri))) or (config.allow_no_country and config.country_flags) %} - + - {% endif %} {% if not config.field_disable_password or (mod and post.mod|hasPermission(config.mod.bypass_field_disable, board.uri)) %}
- {% trans %}Name{% endtrans %} + {% trans %}Name{% endtrans %} {% trans %}(optional){% endtrans %} {{ antibot.html() }} @@ -21,7 +21,7 @@
- {% trans %}Email{% endtrans %} + {% trans %}Email{% endtrans %} {% trans %}(optional){% endtrans %} {{ antibot.html() }} @@ -36,19 +36,19 @@ {% endif %} {{ antibot.html() }} {% if not (not (config.field_disable_subject or (id and config.field_disable_reply_subject)) or (mod and post.mod|hasPermission(config.mod.bypass_field_disable, board.uri))) %} - {% if config.spoiler_images %} {% endif %} + {% endif %} {{ antibot.html() }}
- {% trans %}Subject{% endtrans %} + {% trans %}Subject{% endtrans %} {% if not config.force_subject_op or id %}{% trans %}(optional){% endtrans %}{% endif %} {{ antibot.html() }} - {% if config.spoiler_images %} {% endif %} +
{% trans %}Flag{% endtrans %}{% trans %}Flag{% endtrans %} {% trans %}(optional){% endtrans %}
- {% trans %}File{% endtrans %} + {% trans %}File{% endtrans %} {% if not config.force_image_op or id %}{% trans %}(optional){% endtrans %}{% endif %} @@ -130,7 +130,7 @@ {% if config.enable_embedding %}
- {% trans %}Embed{% endtrans %} + {% trans %}Embed{% endtrans %} {% if not config.force_image_op or id %}{% trans %}(optional){% endtrans %}{% else %}{% trans %}(or file){% endtrans %}{% endif %} {{ antibot.html() }} @@ -138,34 +138,47 @@
- {% trans %}Flags{% endtrans %} + {% trans %}Options{% endtrans %} - {% if config.allow_no_country and config.country_flags %}
+
+ + +
+ + {% if config.spoiler_images %}
+ + +
{% endif %} + + {% if config.allow_no_country and config.country_flags %}
{% endif %} - {% if mod %} - {% if not id and post.mod|hasPermission(config.mod.sticky, board.uri) %}
- -
+ {% if config.allow_roll %}
+ +
d±
{% endif %} - {% if not id and post.mod|hasPermission(config.mod.lock, board.uri) %}
+ + {% if mod %} + {% if not id and post.mod|hasPermission(config.mod.sticky, board.uri) %}
+ + +
{% endif %} + {% if not id and post.mod|hasPermission(config.mod.lock, board.uri) %}

{% endif %} - {% if post.mod|hasPermission(config.mod.rawhtml, board.uri) %}
+ {% if post.mod|hasPermission(config.mod.rawhtml, board.uri) %}

{% endif %} {% endif %}
{% trans %}Password{% endtrans %} @@ -198,7 +211,5 @@ Max filesize is {{ config.max_filesize|filesize }}.
Max image dimensions are {{ config.max_height }} x {{ config.max_width }}.
You may upload {{ config.max_images }} per post.
{% endif %} -{% if config.allow_roll %} -You may roll dice on this board, type "dice XdY+Z" in the email field where X is number of dice, Y is max roll and Z is modifier.
-{% endif %} +
Confused? See the FAQ.