Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
ehthumbs.db
Thumbs.db
.idea/

*.iml
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.8.3
1.8.4
13 changes: 8 additions & 5 deletions qa-content/qa-global.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,12 @@ function qa_vote_click(elem)
mess = document.createElement('div');
mess.id = 'errorbox';
mess.className = 'qa-error';
mess.innerHTML = lines[1];
mess.style.display = 'none';
mess.role = 'alert';
mess.innerHTML = lines[1];
}
mess.setAttribute('role', 'alert');
elem.setAttribute('aria-describedby', mess.id);

var postelem = document.getElementById(anchor);
var e = postelem.parentNode.insertBefore(mess, postelem);
Expand Down Expand Up @@ -194,19 +197,19 @@ function qa_display_rule_show(target, show, first)

var qa_element_revealed = null;

function qa_toggle_element(elem)
function qa_toggle_element(elem, dontClose)
{
var e = elem ? document.getElementById(elem) : null;

if (e && e.qa_disabled)
e = null;

if (e && (qa_element_revealed == e)) {
if (e && (qa_element_revealed === e) && !dontClose) {
qa_conceal(qa_element_revealed, 'form');
qa_element_revealed = null;

} else {
if (qa_element_revealed)
if (qa_element_revealed !== e)
qa_conceal(qa_element_revealed, 'form');

if (e) {
Expand Down Expand Up @@ -431,7 +434,7 @@ function qa_form_params(formname)
var e = es[i];
var t = (e.type || '').toLowerCase();

if (((t != 'checkbox') && (t != 'radio')) || e.checked)
if (((t != 'checkbox') && (t != 'radio')) || (e && e.checked))
params[e.name] = e.value;
}

Expand Down
30 changes: 18 additions & 12 deletions qa-include/app/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ function qa_post_html_fields($post, $userid, $cookieid, $usershtml, $dummy, $opt

// this is for backwards compatibility with any existing links using the old style of anchor
// that contained the post id only (changed to be valid under W3C specifications)
$fields['content'] = '<a name="' . qa_html($postid) . '"></a>' . $fields['content'];
$fields['content'] = '<a aria-hidden="true" name="' . qa_html($postid) . '"></a>' . $fields['content'];
}

// Voting stuff
Expand Down Expand Up @@ -495,7 +495,7 @@ function qa_post_html_fields($post, $userid, $cookieid, $usershtml, $dummy, $opt

// schema.org microdata - vote display might be formatted (e.g. '2k') so we use meta tag for true count
if ($microdata) {
$fields['netvotes_view']['suffix'] .= ' <meta itemprop="upvoteCount" content="' . qa_html($netvotes) . '"/>';
$fields['netvotes_view']['suffix'] .= ' <meta itemprop="upvoteCount" content="' . qa_html($upvotes - $downvotes) . '"/>';
$fields['upvotes_view']['suffix'] .= ' <meta itemprop="upvoteCount" content="' . qa_html($upvotes) . '"/>';
}

Expand Down Expand Up @@ -542,7 +542,8 @@ function qa_post_html_fields($post, $userid, $cookieid, $usershtml, $dummy, $opt
$fields['vote_down_tags'] = 'title="' . qa_lang_html('main/voted_down_popup') . '" name="' . qa_html('vote_' . $postid . '_0_' . $elementid) . '" ' . $onclick;

} else {
$fields['vote_up_tags'] = 'title="' . qa_lang_html('main/vote_up_popup') . '" name="' . qa_html('vote_' . $postid . '_1_' . $elementid) . '" ' . $onclick;
$title = $fields['raw']['type'] == "Q" ? qa_lang_html('main/vote_up_popup_question') : qa_lang_html('main/vote_up_popup_answer');
$fields['vote_up_tags'] = 'title="' . $title . '" name="' . qa_html('vote_' . $postid . '_1_' . $elementid) . '" ' . $onclick;

if (strpos($voteview, '-uponly-level')) {
$fields['vote_state'] = 'up_only';
Expand All @@ -553,8 +554,9 @@ function qa_post_html_fields($post, $userid, $cookieid, $usershtml, $dummy, $opt
$fields['vote_down_tags'] = 'title="' . qa_lang_html('main/vote_disabled_down_approve') . '"';

} else {
$fields['vote_state'] = 'enabled';
$fields['vote_down_tags'] = 'title="' . qa_lang_html('main/vote_down_popup') . '" name="' . qa_html('vote_' . $postid . '_-1_' . $elementid) . '" ' . $onclick;
$title = $fields['raw']['type'] == "Q" ? qa_lang_html('main/vote_down_popup_question') : qa_lang_html('main/vote_down_popup_answer');
$fields['vote_state'] = 'enabled';
$fields['vote_down_tags'] = 'title="' . $title . '" name="' . qa_html('vote_' . $postid . '_-1_' . $elementid) . '" ' . $onclick;
}
}
}
Expand Down Expand Up @@ -1867,8 +1869,9 @@ function qa_set_up_name_field(&$qa_content, &$fields, $inname, $fieldprefix = ''
{
$fields['name'] = array(
'label' => qa_lang_html('question/anon_name_label'),
'tags' => 'name="' . $fieldprefix . 'name"',
'tags' => 'name="' . $fieldprefix . 'name" id="' .$fieldprefix . 'inputNameAnon"',
'value' => qa_html($inname),
'id' => $fieldprefix . 'inputNameAnon'
);
}

Expand All @@ -1889,10 +1892,12 @@ function qa_set_up_name_field(&$qa_content, &$fields, $inname, $fieldprefix = ''
*/
function qa_set_up_notify_fields(&$qa_content, &$fields, $basetype, $login_email, $innotify, $inemail, $errors_email, $fieldprefix = '')
{
$fields['notify'] = array(
'tags' => 'name="' . $fieldprefix . 'notify"',

$fields['notify'] = array(
'tags' => 'name="' . $fieldprefix . 'notify" id="' . $fieldprefix .'notify"',
'type' => 'checkbox',
'value' => qa_html($innotify),
'id' => $fieldprefix.'notify'
);

switch ($basetype) {
Expand Down Expand Up @@ -1920,19 +1925,20 @@ function qa_set_up_notify_fields(&$qa_content, &$fields, $basetype, $login_email
'<span id="' . $fieldprefix . 'email_shown">' . $labelaskemail . '</span>' .
'<span id="' . $fieldprefix . 'email_hidden" style="display:none;">' . $labelonly . '</span>';

$fields['notify']['tags'] .= ' id="' . $fieldprefix . 'notify" onclick="if (document.getElementById(\'' . $fieldprefix . 'notify\').checked) document.getElementById(\'' . $fieldprefix . 'email\').focus();"';
$fields['notify']['tags'] .= ' id="' . $fieldprefix . 'notify" onclick="if (document.getElementById(\'' . $fieldprefix . 'notify\').checked) document.getElementById(\'' . $fieldprefix . 'email_display\').focus();"';
$fields['notify']['tight'] = true;

$fields['email'] = array(
'id' => $fieldprefix . 'email_display',
'tags' => 'name="' . $fieldprefix . 'email" id="' . $fieldprefix . 'email"',
'label' => qa_lang_html('main/email_optional'),
'id' => $fieldprefix . 'email_display',
'tags' => 'name="' . $fieldprefix . 'email" id="' . $fieldprefix . 'email_display"',
'value' => qa_html($inemail),
'note' => qa_lang_html('question/notify_email_note'),
'error' => qa_html($errors_email),
);

qa_set_display_rules($qa_content, array(
$fieldprefix . 'email_display' => $fieldprefix . 'notify',
$fieldprefix . 'email_display-tbody' => $fieldprefix . 'notify',
$fieldprefix . 'email_shown' => $fieldprefix . 'notify',
$fieldprefix . 'email_hidden' => '!' . $fieldprefix . 'notify',
));
Expand Down
1 change: 1 addition & 0 deletions qa-include/app/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ function qa_content_prepare($voting = false, $categoryids = array())
'feedback' => array(
'url' => qa_path_html('feedback'),
'label' => qa_lang_html('main/nav_feedback'),
'role' => 'link'
),
),

Expand Down
4 changes: 4 additions & 0 deletions qa-include/app/votes.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ function qa_vote_set($post, $userid, $handle, $cookieid, $vote)
$vote = (int)min(1, max(-1, $vote));
$oldvote = (int)qa_db_uservote_get($post['postid'], $userid);

if ($oldvote === $vote) {
return;
}

qa_db_uservote_set($post['postid'], $userid, $vote);
qa_db_post_recount_votes($post['postid']);

Expand Down
2 changes: 1 addition & 1 deletion qa-include/db/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function qa_db_cache_set($type, $cacheid, $content)
);

qa_db_query_sub(
'INSERT INTO ^cache (type, cacheid, content, created, lastread) VALUES ($, #, $, NOW(), NOW()) ' .
'INSERT INTO ^cache (type, cacheid, content, created, lastread) VALUES ($, $, $, NOW(), NOW()) ' .
'ON DUPLICATE KEY UPDATE content = VALUES(content), created = VALUES(created), lastread = VALUES(lastread)',
$type, $cacheid, $content
);
Expand Down
Loading