Javascript for wikimized keyword
3 posters
Page 1 of 1
Javascript for wikimized keyword
Hi every body!
I want each time I put a keywork to a code tag like
Can it done with JS? And can I put it to the Editor as a button?
Thanks in advance!
I want each time I put a keywork to a code tag like
- Code:
[wiki]keyword[/wiki]
Can it done with JS? And can I put it to the Editor as a button?
Thanks in advance!
Re: Javascript for wikimized keyword
Try adding to a new Javascript:
- Code:
(function($) {
'use strict';
$(function() {
var lang = window._userdata && _userdata.user_lang ?
_userdata.user_lang : 'en'
;
var base = 'https://' + lang + '.wikipedia.org/wiki/';
$([
'.post-entry > div',
'.content > div',
'#preview .postbody > div',
].join(', ')).each(function() {
var $this = $(this);
$this.html($this.html().replace(
/\[wiki\]([^\]]+)\[\/wiki\]/gi, function(text, match) {
return $('<a>', {
'href': base + match,
'text': match,
'class': 'fa-wiki-link',
}).prop('outerHTML');
}
));
});
});
$(window).on('load', function() {
var $sceditor = $("#text_editor_textarea");
if (!$sceditor.length) {
return;
}
$([
'<a ',
' class="sceditor-button sceditor-button-fawiki"',
' data-sceditor-command="fawiki"',
' unselectable="on">',
' <div unselectable="on">',
' Wikipedia',
' </div>',
'</a>',
].join('\n'))
.on('click', function() {
$sceditor.sceditor('instance').insertText('[wiki]', '[/wiki]');
})
.prependTo('.sceditor-group:last')
;
$('<style>', { html: [
'#main .sceditor-button-fawiki > div {',
' background-image: url(\'https://vi.wikipedia.org/static/favicon/wikipedia.ico\');',
' background-position: center center;',
' background-size: contain;',
'}',
].join('\n') })
.appendTo('head')
;
});
}(jQuery));
Re: Javascript for wikimized keyword
Are you trying to link certain terms/words to the Wikipedia? I mean you want members to click the word and the Wikipedia page load.
You should do this then:
You should do this then:
- Code:
[url=PAGE TO A CERTAIN WIKIPEDIA PAGE]TERM OR WORD[/url]
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Re: Javascript for wikimized keyword
Thank you two.
The code of @Kyo Panda work well. However, it would be perfectly if it have a button in Editor allow user to click and wikimize keyword after highlighted it. Just like this button message button
The code of @Kyo Panda work well. However, it would be perfectly if it have a button in Editor allow user to click and wikimize keyword after highlighted it. Just like this button message button
Re: Javascript for wikimized keyword
The code I passed you adds a button to the last group in the editor. Isn't it working?
Re: Javascript for wikimized keyword
@Kyo Panda
Yes, I haven't found the button in the Editor
Here is the forum:
http://learn.forumvi.com/f33-ngan-du-phong
id: testaccount
pass: test1234
Yes, I haven't found the button in the Editor
Here is the forum:
http://learn.forumvi.com/f33-ngan-du-phong
id: testaccount
pass: test1234
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum