-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathignores.html
168 lines (147 loc) · 4.5 KB
/
ignores.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<!DOCTYPE html>
<html>
<head>
<title>Diomedes - Ignores</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/view.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/forms.css" />
</head>
<body class="ignoreWindow popUpWindow" onLoad="load( )">
<h1>Ignores</h1>
<div id="ignoresList" onclick="handleListClick( event );"></div>
<a href="#" onclick="showAddForm( event );">Add an Ignore</a>
<form class="hidden" id="form" onsubmit="saveIgnores( event );">
<p>
Create Ignores. Ignores are regular expresions. To ignore only by nick use ^joe! to ignore 'joe' for example.
</p>
<p>
Otherwise if you only put a nick such as 'joe', without the ^ and ! you'll ignore people who might have parts of this
nick in their host or nick:<br/>
[email protected] would get ignored<br/>
</p>
<input type="hidden" id="id" value="0"/>
<div class="formItem">
<label for="regex">Regex: </label> <input type="text" id="regex" />
</div>
<div class="formItem">
<label for="active">Active: </label> <input type="checkbox" id="active" checked="true"/>
</div>
<input type="submit" value="Save" />
<button onclick="closeForm( event );">Cancel</button>
</form>
<button onclick="closeWindow( event );">Close Window</button>
<script type="text/javascript">
var bridge = window.opener.ignoresBridge;
var util = bridge.util;
var dojo = bridge.dojo;
var topics = bridge.topics;
var ignores = bridge.ignores;
function load ( ) {
displayIgnores ( ignores );
}
function displayIgnores ( ignores ) {
var n = get( "ignoresList" );
n.innerHTML = "";
var r = [];
for ( var i = 0; i < ignores.length; i++ ) {
r.push( getIgnoreHTML( ignores[ i ] ) );
}
n.innerHTML = r.join( "" );
}
function getIgnoreHTML( ignore ) {
return [
'<span class="regex">', ignore.regex, '</span> ',
'<a href="#" id="delete.', ignore.id, '">Delete</a> ',
'</div>'].join( "" );
}
function clearForm ( ) {
get( "regex" ).value = "";
get( "id" ).value = "0";
}
function saveIgnores ( event ) {
dojo.stopEvent( event );
util.log( "Saving Ignores." );
var ignoreData = {};
var id = parseInt( get( "id" ).value, 10 );
if ( !this.getItem( "regex", "Command", ignoreData ) ) return;
if ( !this.getItem( "active", "Active", ignoreData, true ) ) return;
if ( id === 0 ) {
dojo.publish( topics.IGNORE_ADD, [ ignoreData ] );
closeWindow( event );
return;
}
closeForm( event );
}
function updateIgnores ( ignore ) {
for ( var i = 0; i < ignores.length; i++ ) {
var temp = ignores[ i ];
if ( temp.id == ignore.id ) {
ignores[ i ] = ignore;
displayIgnores( ignores );
return;
}
}
}
function closeForm ( event ) {
dojo.stopEvent( event );
dojo.removeClass( get( "form" ), "hidden" );
}
function showForm ( ) {
dojo.removeClass( get( "form" ), "hidden" );
}
function getItem( id, name, o, isCheckbox ) {
if ( isCheckbox ) {
var value = get( id ).checked;
if ( value === true || value === false ) {
o[ id ] = value;
return true;
}
}
var value = get( id ).value;
value = dojo.trim( value );
if ( !value ) {
alert( name + " required." );
return false;
}
o[ id ] = value;
return true;
}
function get ( name ) {
return util.get( name, document );
}
function handleListClick ( event ) {
var id = event.target.id;
if ( id ) {
var parts = id.split( "." );
if ( parts.length ) {
var cmd = parts[ 0 ];
var id = parts [ 1 ];
if ( cmd == "delete" ) {
deleteIgnore( id );
}
}
}
}
function deleteIgnore ( id ) {
dojo.publish( topics.IGNORE_DELETE, [ id ] );
var newIgnores = [];
for ( var i = 0; i < ignores.length; i++ ) {
var ignore = ignores[ i ];
if ( ignore.id != id ) {
newIgnores.push( ignore );
}
}
ignores = newIgnores;
displayIgnores( ignores );
}
function showAddForm ( event ) {
dojo.stopEvent( event );
clearForm( );
showForm( );
}
function closeWindow ( event ) {
dojo.stopEvent( event );
window.close( );
}
</script>
</body>
</html>