User:Wikidudeman/tags.js

// <pre>
// [[User:LilDice/flexitags.js]]
// <nowiki>
//
//Flexitags script, based on Tags by Seed 2.0
 
//requires:
//importScript('Wikipedia:WikiProject User scripts/Scripts/Add LI menu');
//importStylesheet('Wikipedia:WikiProject User scripts/Scripts/Add LI menu/css');
 
var thedate = new Date();
 
var edFocus = false;
 
 
if( typeof( FlexiTagConfig ) == 'undefined' ) {
	FlexiTagConfig = {};
}
 
/*Autosubmit? true/false*/
if( typeof( FlexiTagConfig.autosubmit ) == 'undefined' ) {
	FlexiTagConfig.autosubmit = false;
}
if( typeof( FlexiTagConfig.addSigOnTalk ) == 'undefined' ) {
	FlexiTagConfig.addSigOnTalk  = true;
}
 
/*Mark all edits as minor true/false*/
if( typeof( FlexiTagConfig.minoredit ) == 'undefined' ) {
	FlexiTagConfig.minoredit = false;
}
 
/*Mark all edits as minor true/false*/
if( typeof( FlexiTagConfig.summarySuffix ) == 'undefined' ) {
	FlexiTagConfig.summarySuffix  = ' ';
}
 
 
 
 
var defaultTagset = {
name:'tags',
namespace:'Main,User_talk',
tagset:[['external-links|%date','See [[WP:EL]]'],
['trivia','Adding Trivia Section'],
['Autobio-warn|%prompt(Article Name)'],
['cleanup','Adding Cleanup Tag']]
};
 
if( typeof( FlexiTagConfig.tabs ) == 'undefined' ) {
	FlexiTagConfig.tabs = new Array();
FlexiTagConfig.tabs.push(defaultTagset);
}
 
 
 
 
Date.monthNames = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ];
Date.prototype.getMonthName = function() { return Date.monthNames[ this.getMonth() ]; }
Date.prototype.getUTCMonthName = function() { return Date.monthNames[ this.getUTCMonth() ]; }
 
function insertAtCursor(myField, myValue) {
 
if(!edFocus)
{
myField.value =  myValue + '\n' + myField.value;
return;
}
//IE support
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
}
//MOZILLA/NETSCAPE support
else if (myField.selectionStart || myField.selectionStart == '0') {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)
+ myValue
+ myField.value.substring(endPos, myField.value.length);
} else {
myField.value =  myValue + '\n' + myField.value;
}
} 
function oc(a)
{
var o = {};
for(var i=0;i<a.length;i++)
{
o[a[i]]='';
}
return o;
}
 
function addTab(flexitag,i)
{
var tabs = document.getElementById( 'p-cactions' ).getElementsByTagName( 'ul' )[0];
addlimenu(tabs,flexitag.name,flexitag.name);
for(j=0;j<flexitag.tagset.length;j++)
{
tmpName = flexitag.tagset[j][0];
pipematch = /^(.+?)\|/.exec(tmpName);
if(pipematch)
{
tmpName = pipematch[1];
}
if (flexitag.tagset[j][2] != null)
{
tmpName = flexitag.tagset[j][2]
}
mw.util.addPortletLink(flexitag.name, "javascript:doAddTag(" + i + "," + j + ")", tmpName,tmpName,tmpName, "");
}
}
 
function parseTag(tagtext)
{
matched = false;
if(tagtext.match(/%twinkarticle/))
{
if( QueryString.exists( 'vanarticle' ) ) {
article = decodeURI(QueryString.get( 'vanarticle' )).replace( /^(Image|Category):/i, ':$1:');
tagtext = tagtext.replace(/%twinkarticle/,article);
matched = true;
}
else
{
tagtext = tagtext.replace(/%twinkarticle/,prompt('Which Article?'));
matched = true;
}
}
 
var promptmatch = /%prompt\((.+?)\)/i.exec(tagtext);
 
if(promptmatch)
{
tagtext = tagtext.replace(/%prompt\(.+?\)/,prompt(promptmatch[1]));
matched = true;
}
if(tagtext.match(/%date/))
{
tagtext = tagtext.replace(/%date/,thedate.getUTCMonthName() + ' ' + thedate.getUTCFullYear());
matched = true;
}
 
if(matched)
{
return parseTag(tagtext);
}
else
{
return tagtext;
}
 
 
}
 
function doAddTag(tabindex,tagindex)
{
// copy wikEd (http://en.wikipedia.org/wiki/User:Cacycle/wikEd.js) frame to wpTextbox1 textarea
if (typeof(wikEdUseWikEd) != 'undefined') {
if (wikEdUseWikEd == true) {
WikEdUpdateTextarea();
}
}
 
text = document.editform.wpTextbox1.value;
tag = "{{" + parseTag(FlexiTagConfig.tabs[tabindex].tagset[tagindex][0]) + "}}";
 
if(FlexiTagConfig.addSigOnTalk && mw.config.get('wgCanonicalNamespace').match(/talk/i))
{
tag += "~~~~";
}
insertAtCursor(document.editform.wpTextbox1,tag);
 
 
// make the changes to the classic wpTextbox1 textarea //
 
// copy wpTextbox1 textarea back to wikEd frame
if (typeof(wikEdUseWikEd) != 'undefined') {
if (wikEdUseWikEd == true) {
WikEdUpdateFrame();
}
}
document.editform.wpSummary.value = FlexiTagConfig.tabs[tabindex].tagset[tagindex][1] + FlexiTagConfig.summarySuffix;
 
if (FlexiTagConfig.minoredit == true) {
document.editform.wpMinoredit.checked = true;
}
 
if (FlexiTagConfig.autosubmit == true) {
document.editform.submit();
}
}
 
 
addOnloadHook(function() {
if(document.getElementById('editform'))
{
 
document.getElementById('wpTextbox1').onfocus = function () {edFocus=true;};
}
if(document.editform)
{
theNs = mw.config.get('wgCanonicalNamespace');
if(theNs == '') {theNs = 'Main'};
for(i=0;i<FlexiTagConfig.tabs.length;i++)
{
tmpTab = FlexiTagConfig.tabs[i];
if('namespace' in tmpTab)
{
if ( theNs in oc(tmpTab.namespace) )
{
addTab(tmpTab,i);
}   
}
else
{
addTab(tmpTab);
}
}
}
});
 
// </nowiki>
// </pre>

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.