- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
是否有可能使这些 javascript 和 css 样式在 MyBB 论坛中工作?使用此脚本,人们可以提高帖子的声誉。有两个按钮:竖起大拇指和不竖起大拇指。当用户点击竖起大拇指按钮时,线程/帖子作者会自动获得 +1 声誉和拇指向下,然后让作者获得 -1 声誉。此外,它还算作所有选票的百分比,并显示将光标悬停在“赞成”或“反对”按钮上时获得的票数。
CSS:
.fa_vote, .fa_voted, .fa_count {
font-size:12px;
font-family:Verdana, Arial, Helvetica, Sans-serif;
display:inline-block !important;
width:auto !important;
transition:300ms;
}
.fa_voted, .fa_vote:hover { opacity:0.4 }
.fa_voted { cursor:default }
.fa_count {
font-weight:bold;
margin:0 3px;
cursor:default;
}
.fa_positive { color:#4A0 }
.fa_negative { color:#A44 }
.fa_votebar, .fa_votebar_inner {
background:#C44;
height:3px;
}
.fa_votebar_inner {
background:#4A0;
transition:300ms;
} .fa_vote, .fa_voted, .fa_count {
font-size:12px;
font-family:Verdana, Arial, Helvetica, Sans-serif;
display:inline-block !important;
width:auto !important;
transition:300ms;
}
.fa_voted, .fa_vote:hover { opacity:0.4 }
.fa_voted { cursor:default }
.fa_count {
font-weight:bold;
margin:0 3px;
cursor:default;
}
.fa_positive { color:#4A0 }
.fa_negative { color:#A44 }
.fa_votebar, .fa_votebar_inner {
background:#C44;
height:3px;
}
.fa_votebar_inner {
background:#4A0;
transition:300ms;
}
Java脚本:
$(function() {
// General Configuration of the plugin
var config = {
position_left : true, // true for left || false for right
negative_vote : true, // true for negative votes || false for positive only
vote_bar : true, // display a small bar under the vote buttons
// button config
icon_plus : '<img src="http://i18.servimg.com/u/f18/18/21/41/30/plus10.png" alt="+"/>',
icon_minus : '<img src="http://i18.servimg.com/u/f18/18/21/41/30/minus10.png" alt="-"/>',
// language config
title_plus : 'Like %{USERNAME}\'s post',
title_minus : 'Dislike %{USERNAME}\'s post',
title_like_singular : '%{VOTES} person likes %{USERNAME}\'s post',
title_like_plural : '%{VOTES} people like %{USERNAME}\'s post',
title_dislike_singular : '%{VOTES} person dislikes %{USERNAME}\'s post',
title_dislike_plural : '%{VOTES} people dislike %{USERNAME}\'s post',
title_vote_bar : '%{VOTES} people liked %{USERNAME}\'s post %{PERCENT}'
},
// function bound to the onclick handler of the vote buttons
submit_vote = function() {
var next = this.nextSibling, // the counter next to the vote button that was clicked
box = this.parentNode,
bar = box.getElementsByTagName('DIV'),
vote = box.getElementsByTagName('A'),
mode = /eval=plus/.test(this.href) ? 1 : 0,
i = 0, j = vote.length, pos, neg, percent;
// submit the vote asynchronously
$.get(this.href, function() {
next.innerHTML = +next.innerHTML + 1; // add to the vote count
next.title = next.title.replace(/(\d+)/, function(M, $1) { return +$1 + 1 });
pos = +vote[0].nextSibling.innerHTML;
neg = vote[1] ? +vote[1].nextSibling.innerHTML : 0;
percent = pos == 0 ? '0%' : pos == neg ? '50%' : Math.round(pos / (pos + neg) * 100) + '%';
if (bar[0]) {
bar[0].style.display = '';
bar[0].firstChild.style.width = percent;
box.title = box.title.replace(/\d+\/\d+/, pos + '/' + ( pos + neg )).replace(/\(\d+%\)/, '(' + percent + ')');
}
});
// revoke voting capabilities on the post once the vote is cast
for (; i < j; i++) {
vote[i].href = '#';
vote[i].className = vote[i].className.replace(/fa_vote/, 'fa_voted');
vote[i].onclick = function() { return false };
}
return false;
},
vote = $('.vote'), i = 0, j = vote.length,
version = $('.bodylinewidth')[0] ? 0 : document.getElementById('wrap') ? 1 : $('.pun')[0] ? 2 : document.getElementById('ipbwrapper') ? 3 : 'badapple', // version check
// version data so we don't have to redefine these arrays during the loop
vdata = {
tag : ['SPAN', 'LI', 'SPAN', 'LI'][version],
name : ['.name', '.postprofile dt > strong', '.username', '.popmenubutton'][version],
actions : ['.post-options', '.profile-icons', '.post-options', '.posting-icons'][version],
},
post, plus, minus, n_pos, n_neg, title_pos, title_neg, li, ul, bar, button, total, percent, span, pseudo, vote_bar; // startup variables for later use in the loop
// prevent execution if the version cannot be determined
if (version == 'badapple') {
if (window.console) console.warn('This plugin is not optimized for your forum version. Please contact the support for further assistance.');
return;
}
for (; i < j; i++) {
post = $(vote[i]).parentsUntil('.post').parent()[0];
bar = $('.vote-bar', vote[i])[0]; // vote bar
button = $('.vote-button', vote[i]); // plus and minus buttons
pseudo = $(vdata.name, post).text() || 'MISSING_STRING'; // username of the poster
ul = $(vdata.actions, post)[0]; // post actions
li = document.createElement(vdata.tag); // vote system container
li.className = 'fa_reputation';
if (li.tagName == 'SPAN') li.style.display = 'inline-block';
// calculate votes
if (bar) {
total = +bar.title.replace(/.*?\((\d+).*/, '$1');
percent = +bar.title.replace(/.*?(\d+)%.*/, '$1');
n_pos = Math.round(total * (percent / 100));
n_neg = total - n_pos;
} else {
n_pos = 0;
n_neg = 0;
}
// set up negative and positive titles with the correct grammar, votes, and usernames
title_pos = (n_pos == 1 ? config.title_like_singular : config.title_like_plural).replace(/%\{USERNAME\}/g, pseudo).replace(/%\{VOTES\}/g, n_pos);
title_neg = (n_neg == 1 ? config.title_dislike_singular : config.title_dislike_plural).replace(/%\{USERNAME\}/g, pseudo).replace(/%\{VOTES\}/g, n_neg);
// define the vote counts
li.innerHTML = '<span class="fa_count fa_positive" title="' + title_pos + '">' + n_pos + '</span>' + (config.negative_vote ? ' <span class="fa_count fa_negative" title="' + title_neg + '">' + n_neg + '</span>' : '');
span = li.getElementsByTagName('SPAN'); // get the vote count containers for use as insertion points
// create positive vote button
plus = document.createElement('A');
plus.href = button[0] ? button[0].firstChild.href : '#';
plus.onclick = button[0] ? submit_vote : function() { return false };
plus.className = 'fa_vote' + (button[0] ? '' : 'd') + ' fa_plus';
plus.innerHTML = config.icon_plus;
plus.title = (button[0] ? config.title_plus : title_pos).replace(/%\{USERNAME\}/g, pseudo);
span[0] && li.insertBefore(plus, span[0]);
// create negative vote button
if (config.negative_vote) {
minus = document.createElement('A');
minus.href = button[1] ? button[1].firstChild.href : '#';
minus.onclick = button[1] ? submit_vote : function() { return false };
minus.className = 'fa_vote' + (button[1] ? '' : 'd') + ' fa_minus';
minus.innerHTML = config.icon_minus;
minus.title = (button[1] ? config.title_minus : title_neg).replace(/%\{USERNAME\}/g, pseudo);
span[1] && li.insertBefore(minus, span[1]);
}
// create vote bar
if (config.vote_bar) {
vote_bar = document.createElement('DIV');
vote_bar.className = 'fa_votebar';
vote_bar.innerHTML = '<div class="fa_votebar_inner" style="width:' + percent + '%;"></div>';
vote_bar.style.display = bar ? '' : 'none';
li.title = config.title_vote_bar.replace(/%\{USERNAME\}/, pseudo).replace(/%\{VOTES\}/, n_pos + '/' + (n_pos + n_neg)).replace(/%\{PERCENT\}/, '(' + percent + '%)');
li.appendChild(vote_bar);
}
// finally insert the vote system and remove the default one
config.position_left ? ul.insertBefore(li, ul.firstChild) : ul.appendChild(li);
vote[i].parentNode.removeChild(vote[i]);
}
});
我尝试了不同的方法,但没有弄明白。欢迎任何帮助。
干杯!
最佳答案
最好的方法是为 MyBB 创建一个扩展/插件。 MyBB 1.8 Documentation on plugin creation .
但是如果您更喜欢一个 hacky 解决方案,那么可以通过将 CSS 和 Javascript 直接放入 MyBB 的 CSS 和模板中来实现。这可以通过管理控制面板 -> 模板和样式 -> 模板来实现。最终模板将取决于您希望代码出现的页面/页面集。我建议你阅读 documentation on templates为此。
希望对您有所帮助。
关于javascript - Mybb信誉系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39483547/
我正在将 MyBB 论坛与另一个需要 MyBB 数据库中的用户数据的应用程序集成。但是,问题是,没有这样的函数可以通过用户名检索用户数据,但是,我们可以通过ID获取用户数据..现在,有没有简单有效的方
我使用的是最新版本的mybb(mybb1.8),它有附件功能,但它上传文件到当前主机,我想将文件上传到不同的服务器或主机。 我怎样才能做到这一点? 如果需要,请下载 Mybb18: http://re
我的 mybb 论坛中有一个功能。它是一个插件的一部分,用于跟踪对某些论坛的依赖并在成员(member)页面上显示日期(除其他外)。 这部分是针对用户删除帖子的情况。然后,它应该在设置的论坛中找到已删
我一直在尝试使用自定义主题更改 myBB 论坛的 Logo 位置。 它有时在我更改后几小时或几天一直在改变位置,这让我很困惑。 这是我的代码: {$welcomeblock}
我正在使用这个插件 http://mods.mybb.com/download/online-today-1.2.2 以下部分是查询 $queries[] = $db->simple_
我有兴趣将 Materializecss 与我想为 MyBB 创建的主题相集成。 (免责声明:以前没有做过,对 php、css 和 html 是新手) 我取得了合理的进展,并且能够以我想要的样式将一些
我很好奇插件是如何工作的,我只知道我们使用插件而不是更改代码,但是他们如何在不更改代码的情况下完成工作?编码人员在编写新项目时应该考虑什么才能拥有插件?非常感谢你 :D 最佳答案 关于如何实现插件系统
我有MyBB安装在我的服务器上,显然模板集是通过 MySQL 数据库存储的,而不是下载到远程服务器。我想在 Dreamweaver 中设置一个路径,这样我就可以直接编辑模板集,而不必进入 MyBB 中
我正在尝试替换一些文本。如果您继续阅读,这将是有意义的。 [quote]Here is a message[/quote] Message one [quote]Another message[/qu
多用户创建mysql 我和一些 friend 很久以前创建了一个论坛。我们有一些用户并列出了他们的用户名列表,但不幸的是我们的网站被劫持并失去了对数据库的访问权限。我想知道的问题是 phpmyadmi
我需要的是为一个论坛中的所有新线程添加默认前缀。 我尝试在 php admin 中创建触发器 这是代码: CREATE TRIGGER set_thread_prefix BEFORE INSERT
我正在尝试为我的网站构建一个 Chrome 应用程序/扩展程序,该网站主要是一个 mybb 论坛。我想知道是否有人知道我如何检查用户的线程上是否有新的 Pm 或新帖子?也许通过 JS、AJAX 或 P
哪些论坛软件在 google 上的排名往往更高?例如,如果我有 2 个具有相同标题和名称的相同论坛,哪个在 google 中排名更高?这不是一个意见问题,而是一个真实的事实问题。 那么 vBullet
我目前正在使用 MyBB 设置,我正在尝试执行 SQL 查询,该查询可以检查用户是否属于某个附加组。但是,我遇到了困难。 MyBB 将其他组 ID 存储在一个用逗号分隔的 VARCHAR 字段中,例如
我设置了一个 Mybb 论坛,并注意到数据库中存储的 IP 是打包格式。 示例 4f42c2c3 我尝试使用以下查询解压其中一个 SELECT INET_NTOA(lastip) From db_1.
我正在使用 MyBB ,我想在我的网站主页上显示当前拥有最多读者的话题。 我假设我必须查询 session 表,但我不确定我应该怎么做 我需要的 mysql 结果应该类似于: ------------
您好,我有一个类登录,用于从外部脚本检查 MYBB 的用户名和密码,它似乎可以工作,但有一个小问题。对于不同的用户,结果为所有用户返回相同的 uid 和电子邮件(mybb_users 表中的第一个 u
我有一个 MyBB 论坛,其中默认包含 SCEditor 作为所见即所得编辑器。 SCEditor 不是为拖放而设计的,因此对于 IE、Safari 和 Chrome,如果您尝试将图像拖到字段中,整个
我的问题是为什么我的公告板配置文件必须具有权限 666 并且不需要执行权限,但 joomla 配置文件需要它并且必须具有权限 777在这里您可以看到推荐的权限 Required – ./inc/set
我正在尝试使用 Zoho 的 SMTP 服务器从 MyBB 安装发送注册电子邮件。但是,电子邮件永远不会发送,当我检查日志时,我注意到错误是。 Month Day Year:Hour:Minute h
我是一名优秀的程序员,十分优秀!