зеркало из https://github.com/mozilla/gecko-dev.git
98 строки
2.8 KiB
JavaScript
98 строки
2.8 KiB
JavaScript
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
*
|
|
* The contents of this file are subject to the Mozilla Public
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
* except in compliance with the License. You may obtain a copy of
|
|
* the License at http://www.mozilla.org/MPL/
|
|
*
|
|
* Software distributed under the License is distributed on an "AS
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
* implied. See the License for the specific language governing
|
|
* rights and limitations under the License.
|
|
*
|
|
* The Original Code is Mozilla Leak-o-Matic.
|
|
*
|
|
* The Initial Developer of the Original Code is Netscape
|
|
* Communications Corp. Portions created by Netscape Communucations
|
|
* Corp. are Copyright (C) 1999 Netscape Communications Corp. All
|
|
* Rights Reserved.
|
|
*
|
|
* Contributor(s):
|
|
* Chris Waterson <waterson@netscape.com>
|
|
*
|
|
* $Id: balance.js,v 1.2 1999/11/17 19:15:02 waterson%netscape.com Exp $
|
|
*/
|
|
|
|
/*
|
|
|
|
Script for the HTML generated by ``balance.cgi''
|
|
|
|
*/
|
|
|
|
function toggle(target)
|
|
{
|
|
var tt = target.parentNode;
|
|
|
|
// ensure that we're actuallly looking at a method
|
|
if (tt.getAttribute('class') != 'method') return;
|
|
|
|
// toggle the selected state
|
|
var selected = tt.getAttribute('selected') == 'true';
|
|
selected = !selected;
|
|
tt.setAttribute('selected', selected ? 'true' : 'false');
|
|
|
|
// add/remove from the 'exclude' list
|
|
var exclude = document.getElementById('exclude');
|
|
var value = target.nodeValue;
|
|
|
|
if (selected) {
|
|
var found = false;
|
|
for (var i = 0; i < exclude.length; ++i) {
|
|
if (exclude.options[i].text == value) {
|
|
found = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (! found) {
|
|
dump('adding ' + value + '\n');
|
|
var option = document.createElement('option');
|
|
option.setAttribute('selected', 'true');
|
|
option.appendChild(document.createTextNode(value));
|
|
exclude.appendChild(option);
|
|
}
|
|
}
|
|
else {
|
|
for (var i = 0; i < exclude.length; ++i) {
|
|
if (exclude.options[i].text == value) {
|
|
exclude.removeChild(exclude.options[i]);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function remove() {
|
|
// remove all of the selected items from the 'exclude' list
|
|
var exclude = document.getElementById('exclude');
|
|
|
|
for (var i = 0; i < exclude.length; ++i) {
|
|
if (exclude.options[i].selected) {
|
|
exclude.removeChild(exclude.options[i]);
|
|
--i;
|
|
}
|
|
}
|
|
}
|
|
|
|
function onsubmit() {
|
|
// make sure that all of the elements in the select are actually
|
|
// -selected- so that the HTTP GET will contain them as excludes.
|
|
var exclude = document.getElementById('exclude');
|
|
|
|
for (var i = 0; i < exclude.length; ++i) {
|
|
// XXX doing this with 'options[i].selected = true' actually
|
|
// -changes- the selection. Oops.
|
|
exclude.options[i].setAttribute('selected', 'true');
|
|
}
|
|
}
|