User:PC-XT/Advisor.js: Difference between revisions

Content deleted Content added
m +yyOffset() testing hook for scrolling
m make scrolling optional
Line 13:
 
// == Helpers ==
 
function yyOffset(x){return x;}//testing hook for scrolling
 
// === DOM manipulation ===
 
Line 24 ⟶ 21:
// Initialise static variables used within this function
var _static = arguments.callee; // this is the Function we are in. It will be used as a poor man's function-local static scope.
ta.focus();
ta.setSelectionRange(start, end);
if(ct.noscroll)return;
if (ta.setSelectionRange) {
// Guess the vertical scroll offset by creating a
Line 43:
hta.style.width = ta.clientWidth + 'px';
hta.style.height = ta.clientHeight + 'px';
hta.value = _static.NEWLINES.substring(0, ta.rows) + ta.value.substring(0, start/*+(end-start)/2*/);
var yOffset = yyOffset(hta.scrollHeight);
hta.style.display = 'none';
//if(yOffset>ta.scrollTop||yOffset<=ta.scrollTop-ta.clientHeight) {
ta.focus();
if (yOffset -=> Math.floor(ta.clientHeight) / 2);{
ta.setSelectionRange(start, end);
if ta.scrollTop = (yOffset >- Math.floor(ta.clientHeight) {/ 2);
// Opera does not support setting the scrollTop property
yOffset -= Math.floor(ta.clientHeight / 2);
if (ta.scrollTop != yOffset;) {
// todo: Warn the user or apply a workaround
// Opera does not support setting the scrollTop property
}
if (ta.scrollTop != yOffset) {
} else {
// todo: Warn the user or apply a workaround
if ( ta.scrollTop != yOffset) {0;
}
//} else {
ta.scrollTop = 0;
}
} else {
// IE incorrectly counts '\r\n' as a signle character
Line 516 ⟶ 515:
return;
}
var editform = document.getElementById('editform');,
var suggestion = ct.suggestions[k];
s=editform.wpTextbox1.scrollTop,
var suggestion = ct.suggestions[k];
if (suggestion.replacement == null) { // the issue is not automatically fixable
return;
Line 529 ⟶ 530:
suggestion.start + suggestion.replacement.length
);
if(ct.noscroll)editform.wpTextbox1.scrollTop=s;
// Propose an edit summary unless it's a new section
var editform = document.getElementById('editform');
if (!editform['wpSection'] || (editform['wpSection'].value != 'new')) {
if (ct.appliedSuggestions[suggestion.name] == null) {