לדלג לתוכן

מדיה ויקי:Gadget-toggleRCOptions.js: הבדלים בין גרסאות בדף

מתוך צפונות ויקי
מ דף חדש: // // // Created by user:Yonidebest function findText() { var findThisRx = new RegExp(document.getElementById('fromReplace').value, 'g'); var foundIndex = document.editform.wpTex...
 
מאין תקציר עריכה
שורה 2: שורה 2:
//
//
// Created by [[user:Yonidebest]]
// Created by [[user:Yonidebest]]
function showFound(index) {
}


function findText() {
function findText() {
  var findThisRx = new RegExp(document.getElementById('fromReplace').value, 'g');
// clear Select object
  var foundIndex = document.editform.wpTextbox1.value.search(findThisRx);
  var results = document.getElementById('foundResults');
var statusFind = document.getElementById('statusFind');
while (results.length > 0)
if (foundIndex != -1) {
  results.remove(0);
  document.editform.wpTextbox1.value = tempText;
 
  statusFind.innerHTML = 'בוצע!';
// find text and add to select object
} else statusFind.innerHTML = 'לא נמצאו מופעים.';
var fromIndex = 0;
var counter = 0;
var findThis = document.getElementById('fromReplace').value;
  while (fromIndex != -1) {
  var foundIndex = document.editform.wpTextbox1.value.indexOf(findThis, fromIndex);
  if (foundIndex != -1) {
      counter++;
      var option = document.createElement('OPTION');
      option.text = 'תוצאה ' + counter;
      option.title = foundIndex;
      results.add(option);
      fromIndex = foundIndex;
  } else {
    var option = document.createElement('OPTION');
    option.title = foundIndex;
    option.disabled = true;
    if (results.length != 0) {
      option.text = 'נמצאו ' + counter + ' תוצאות.';
      results.add(option, 1);
    } else {
      option.text = 'לא נמצאות תוצאות.';
      results.add(option);
    }
    fromIndex = foundIndex;
  }
}
}
}


שורה 35: שורה 64:
  submitFind.href = 'javascript:findText();';
  submitFind.href = 'javascript:findText();';
  submitFind.appendChild(document.createTextNode('חפש'));
  submitFind.appendChild(document.createTextNode('חפש'));
  var statusFind = document.createElement('<SPAN ID="statusFind"></SPAN>');
  var foundResults = document.createElement('<SELECT ID="foundResults"></SELECT>');
  statusFind.appendChild(document.createTextNode('מחכה.'));
  var option = document.createElement('OPTION');
option.text = 'מחכה...';
option.disabled = true;
foundResults.add(option);


  var divBoxFind = document.createElement('<DIV ID="divFind"></DIV>');
  var divBoxFind = document.createElement('<DIV ID="divFind"></DIV>');
שורה 43: שורה 75:
  divBoxFind.appendChild(document.createTextNode(' '));
  divBoxFind.appendChild(document.createTextNode(' '));
  divBoxFind.appendChild(submitFind);
  divBoxFind.appendChild(submitFind);
  divBoxFind.appendChild(document.createTextNode(' | סטטוס: '));
  divBoxFind.appendChild(document.createTextNode(' | תוצאות: '));
  divBoxFind.appendChild(statusFind);
  divBoxFind.appendChild(foundResults);
  divBoxFind.appendChild(document.createElement('BR'));
  divBoxFind.appendChild(document.createElement('BR'));
   
   

גרסה מ־22:30, 30 בספטמבר 2007

//
//
// Created by [[user:Yonidebest]]

function showFound(index) {

}

function findText() {
 // clear Select object
 var results = document.getElementById('foundResults');
 while (results.length > 0)
   results.remove(0);

 // find text and add to select object
 var fromIndex = 0;
 var counter = 0;
 var findThis = document.getElementById('fromReplace').value;
 while (fromIndex != -1) {
   var foundIndex = document.editform.wpTextbox1.value.indexOf(findThis, fromIndex);
   if (foundIndex != -1) {
      counter++;
      var option = document.createElement('OPTION');
      option.text = 'תוצאה ' + counter; 
      option.title = foundIndex;
      results.add(option);
      fromIndex = foundIndex;
   } else {
     var option = document.createElement('OPTION'); 
     option.title = foundIndex;
     option.disabled = true;
     if (results.length != 0) {
       option.text = 'נמצאו ' + counter + ' תוצאות.';
       results.add(option, 1);
     } else {
       option.text = 'לא נמצאות תוצאות.';
       results.add(option);
     }
     fromIndex = foundIndex;
   }
 }
}

function toggleFindText() {
 var divBoxFind = document.getElementById('divFind');
 var aFind = document.getElementById('aFind');
 if (divBoxFind.style.display == 'none') {
   divBoxFind.style.display = 'block';
   aFind.innerHTML = '[הסתר]';
 } else {
   divBoxFind.style.display = 'none';
   aFind.innerHTML = 'בצע החלפה';
 }
}

function addFindText() {
 var toolbar = document.getElementById('toolbar');
 if (!toolbar) return;

 var iFind = document.createElement('<INPUT ID="findInput"></INPUT>');
 iFind.type = 'text';
 iFind.onchange = function() {javascript:document.getElementById("statusReplace").innerHTML = "מחכה.";};
 var submitFind = document.createElement('A');
 submitFind.href = 'javascript:findText();';
 submitFind.appendChild(document.createTextNode('חפש'));
 var foundResults = document.createElement('<SELECT ID="foundResults"></SELECT>');
 var option = document.createElement('OPTION');
 option.text = 'מחכה...';
 option.disabled = true;
 foundResults.add(option);

 var divBoxFind = document.createElement('<DIV ID="divFind"></DIV>');
 divBoxFind.appendChild(document.createTextNode('חפש את '));
 divBoxFind.appendChild(iFind);
 divBoxFind.appendChild(document.createTextNode(' '));
 divBoxFind.appendChild(submitFind);
 divBoxFind.appendChild(document.createTextNode(' | תוצאות: '));
 divBoxFind.appendChild(foundResults);
 divBoxFind.appendChild(document.createElement('BR'));
 
 var aFind = document.createElement('<A ID="aFind"></A>');
 aFind.href = 'javascript:toggleFindText();';
 aFind.appendChild(document.createTextNode('חפש'));

 toolbar.appendChild(aFind);
 toolbar.appendChild(document.createTextNode(' '));
 toolbar.appendChild(divBoxFind);
 toggleFindText();
}

addOnloadHook(addReplaceText);