コンテンツにスキップ

利用者:っ/functions.js

お知らせ: 保存した後、ブラウザのキャッシュをクリアしてページを再読み込みする必要があります。

多くの WindowsLinux のブラウザ

  • Ctrl を押しながら F5 を押す。

Mac における Safari

  • Shift を押しながら、更新ボタン をクリックする。

Mac における ChromeFirefox

  • Cmd Shift を押しながら R を押す。

詳細についてはWikipedia:キャッシュを消すをご覧ください。

function insertTags3(tagOpen, tagMiddle, tagClose, sampleText) {
	if (document.editform)
		var txtarea = document.editform.wpTextbox1;
	else {
		// some alternate form? take the first one we can find
		var areas = document.getElementsByTagName('textarea');
		var txtarea = areas[0];
	}

	// IE
	if (document.selection  && !is_gecko) {
		var theSelection = document.selection.createRange().text;
		if (!theSelection)
			theSelection=sampleText;
		txtarea.focus();
		if (theSelection.charAt(theSelection.length - 1) == " ") { // exclude ending space char, if any
			theSelection = theSelection.substring(0, theSelection.length - 1);
			document.selection.createRange().text = tagOpen + theSelection + tagMiddle + theSelection + tagClose + " ";
		} else {
			document.selection.createRange().text = tagOpen + theSelection + tagMiddle + theSelection + tagClose;
		}

	// Mozilla
	} else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
		var replaced = false;
		var startPos = txtarea.selectionStart;
		var endPos = txtarea.selectionEnd;
		if (endPos-startPos)
			replaced = true;
		var scrollTop = txtarea.scrollTop;
		var myText = (txtarea.value).substring(startPos, endPos);
		if (!myText)
			myText=sampleText;
		if (myText.charAt(myText.length - 1) == " ") { // exclude ending space char, if any
			subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagMiddle + myText.substring(0, (myText.length - 1)) + tagClose + " ";
		} else {
			subst = tagOpen + myText + tagMiddle + myText + tagClose;
		}
		txtarea.value = txtarea.value.substring(0, startPos) + subst +
			txtarea.value.substring(endPos, txtarea.value.length);
		txtarea.focus();
		//set new selection
		if (replaced) {
			var cPos = startPos+(tagOpen.length + myText.length * 2 + tagClose.length + tagMiddle.length);
			txtarea.selectionStart = cPos;
			txtarea.selectionEnd = cPos;
		} else {
			txtarea.selectionStart = startPos + tagOpen.length;
			txtarea.selectionEnd = startPos + tagOpen.length + myText.length;
		}
		txtarea.scrollTop = scrollTop;

	// All other browsers get no toolbar.
	// There was previously support for a crippled "help"
	// bar, but that caused more problems than it solved.
	}
	// reposition cursor if possible
	if (txtarea.createTextRange)
		txtarea.caretPos = document.selection.createRange().duplicate();
}

function appendButton(e, imageFile, speedTip, tagOpen, tagClose, sampleText) {
	if (!document.selection && !is_gecko) {
		return false;
	}
	var atag, imagetag, t, p, b;
	imageFile = escapeQuotesHTML(imageFile);
	speedTip = escapeQuotesHTML(speedTip);
	tagOpen = escapeQuotes(tagOpen);
	tagClose = escapeQuotes(tagClose);
	sampleText = escapeQuotes(sampleText);
	var mouseOver = "";

	imagetag = document.createElement('img');
	imagetag.setAttribute('width', "23");
	imagetag.setAttribute('height', "22");
	imagetag.setAttribute('src', imageFile);
	imagetag.setAttribute('border', "0");
	imagetag.setAttribute('alt', speedTip);
	imagetag.setAttribute ('title', speedTip);

	atag = document.createElement('a');
	atag.setAttribute ('href', "javascript:insertTags('" + tagOpen + "', '" + tagClose + "','" + sampleText + "')");
	//mouseover
	atag.appendChild(imagetag);
	e.appendChild(atag);
	return;
}

function appendTag(e, itsText, speedTip, tagOpen, tagClose, sampleText) {
	var atag;
	atag = document.createElement('a');
	atag.setAttribute ('href', "javascript:insertTags('" + tagOpen + "', '" + tagClose + "','" + sampleText + "')");
	atag.setAttribute ('title', speedTip);
	atag.innerHTML = itsText;
	e.innerHTML += " ";//" ";
	e.appendChild(atag);
}

function appendTag3(e, itsText, speedTip, tagOpen, tagMiddle, tagClose, sampleText) {
	var atag;
	atag = document.createElement('a');
	atag.setAttribute ('href', "javascript:insertTags3('" + tagOpen + "', '" + tagMiddle + "','" + tagClose + "','" + sampleText + "')");
	atag.setAttribute ('title', speedTip);
	atag.innerHTML = itsText;
	e.innerHTML += " ";//" ";
	e.appendChild(atag);
}

function getPageName () {
	var pagename = document.getElementsByTagName('h1')[0].innerHTML;
	if (document.getElementById('toolbar')) {
		pagename = pagename.replace(/ を編集中$/,"");
	}
	return pagename;
}