User:MusikAnimal/responseHelper.js: Difference between revisions

Content deleted Content added
use single indent for all PERM pages; requested at Special:Permalink/1176086559#Incorrect indentation
use jQuery.textSelection on #wpTextbox1
 
Line 947:
 
var $textarea = $("#wpTextbox1");
var currentText = $textarea.valtextSelection( 'getContents' );
var responseStr = indentation + "{{" + (templateName ? templateName + "|" : "") + code.replace(/\|$/, '') + "}}" + comment + " ~~~~";
 
if (inline) {
var caretPos = $textarea.textSelection('getCaretPosition');
$textarea.valtextSelection( 'setContents', currentText.substring(0, caretPos) + responseStr + currentText.substring(caretPos) );
} else if (spi) {
$textarea.valtextSelection(
'setContents',
currentText.replace(/(\n----<\!---|$)/, responseStr + "\n$&")
);
} else {
$textarea.valtextSelection( 'setContents', currentText + responseStr );
}
 
if (anew && !unresolved) {
var textArray = $textarea.valtextSelection( 'getContents' ).split("\n");
$textarea.valtextSelection(
'setContents',
textArray[0].replace('(Result: )','(Result: ' + (response.summary[0].toUpperCase() + response.summary.slice(1) + value).trim() + ')') +
'\n' + $textarea.valtextSelection( 'getContents' ).split("\n").splice(1).join("\n")
);
}