This page, or parts of it, are still untranslated. Please translate it to the appropriate language (ไทย).
AjaxPoll ช่วยฝังโพลการสนทนาไว้ที่หน้าวิกิ ตั้งชื่อมาจากส่วนขยายมีเดียวิกิซึ่งไม่สามารถใช้งานใน UCP ได้
คุณสมบัติ
- ฝังโพลการสนทนาไว้ที่หน้าวิกิ
- สามารถโหวดได้โดยตรง แม้กระทั้งเปลี่ยนการโหวด ซึ่งโพลการสนทนาไม่สามารถทำได้
- สามารถปรับแต่งโพลได้อย่างง่ายดาย
Installation
Usage
- Create a poll thread in Discussions.
- Copy the thread ID, which is present in the address bar, e.g
https://dev.fandom.com/f/p/ID - Setup a div with class
d-polland supply the thread ID to thedata-idattribute.
- Example
<div class="d-poll" data-id="4400000000000005134"></div>
- Result
You can also copy and use Template:AjaxPoll which only requires you to supply the ID, and it also automatically adds a fallback link (See about fallback content below).
Fallback content
As custom JavaScript is disabled on mobile, the poll will not be loaded, therefore it is recommended to put some fallback content. The fallback content could be some text to display to the readers when the poll is not loaded, or a spinner/loader to indicate the poll is being loaded, or a link to the original poll.
- Example
<div class="d-poll" data-id="4400000000000005134"> [[File:Ajax-loader.gif]] </div>
- Result
Styling
Quickly import the available skins below, or easily design your own.
Modern
AjaxPoll Modern
Whale
AjaxPoll Whale
Bootstrap
AjaxPoll Bootstrap
Discussions
AjaxPoll Discussions
HTML Structure (for custom styling)
div.d-poll
└─ form
├─ div.d-poll__question
├─ div.d-poll__answer
| ├─ label.d-poll__answerName
| | └─ input[type="radio"]
| ├─ div.d-poll__answerVotes
| └─ div.d-poll__answerBar
| └─ div
├─ div.d-poll__info
└─ input[type="submit"]
Using with personal JS for changing a vote
Typically, this script only makes sense when imported by admins in sitewide JS, as the point is to show the polls to everyone. However, it can be used in personal JS for the purpose of changing a vote, which isn't possible via the built-in poll interface.
In order to do so, first import the script personally
importArticles({
type: 'script',
articles: [
'u:dev:MediaWiki:AjaxPoll.js'
]
});
then follow the same usage steps, but you don't need to save the page where you insert the embed code. You can simply use preview mode and change your vote from there.
Known issues
Voting does not work on wikis with a content language other than English. Solution: Adjust the form action URL (line 54) to support other wiki languages.- Fixed
Changelog
| Date | Description | Author |
|---|---|---|
| Dec 1, 2020 | First commit. | KhangND |