-
Notifications
You must be signed in to change notification settings - Fork 0
/
src.js
228 lines (200 loc) · 5.92 KB
/
src.js
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*
* File: event-loader.js
* CVS: $Id$
* Description: Load up Rule
* Author: Allan Jardine
* Created: 25-8-07
* Modified: $Date$ by $Author$
* Language: JavaScript
* Project: Event
*
* Copyright 2007-2010 Allan Jardine. All rights reserved.
*
*/
/*
* If visual event is already defined then we can toggle the display - giving the effect of
* starting it up and shutting it down when using the loader. Note it's preferable to do this in
* the bookmarklet code (and is now - but is it for backwards compatability)
*/
if ( typeof VisualEvent != 'undefined' )
{
if ( document.getElementById('Event_display') )
{
VisualEvent.fnClose();
}
else
{
VisualEvent.fnInit();
}
}
if ( typeof EventLoader == 'undefined' )
{
/*
* Object: EventLoader
* Purpose: EventLoader constructor
* Returns: -
*/
var EventLoader = {
/*
* Variable: bLoadingComplete
* Purpose: Inidicate if the loading is finished or not
*/
bLoadingComplete: false,
/*
* Variable: toInfo
* Purpose: Timeout var for the info
*/
toInfo: false,
/*
* Function: EventLoader.fnLoadFile
* Purpose: Load a new file into the DOM
* Returns: -
* Inputs:
* string:sFile - file to load
* string:sType - type of file 'css' or 'js'
* Notes: -
*/
fnLoadFile: function ( sFile, sType )
{
var nElement;
if ( sType == 'css' )
{
nElement = document.createElement('link');
nElement.type = 'text/css';
nElement.rel = 'stylesheet';
nElement.href = sFile;
nElement.media = 'screen';
document.getElementsByTagName('head')[0].appendChild( nElement );
}
else if ( sType == 'image' )
{
var imImage = new Image( 1, 1 );
imImage.src = sFile;
}
else
{
nElement = document.createElement( 'script' );
nElement.setAttribute( 'language', 'JavaScript' );
nElement.setAttribute( 'src', sFile );
document.body.appendChild( nElement );
}
},
/*
* Function: EventLoader.fnPollReady
* Purpose: Wait for everything to be available
* Returns: -
* Inputs: -
* Notes: -
*/
fnPollReady: function ( sFile, sType )
{
if ( typeof VisualEvent == 'object' &&
typeof VisEventSyntaxHighlighter == 'object' )
{
VisualEvent.fnInit();
this.fnComplete();
}
else
{
setTimeout( function() { EventLoader.fnPollReady(); }, 100 );
}
},
/*
* Function: EventLoader.fnComplete
* Purpose: Loading complete
* Returns: -
* Inputs: -
* Notes: -
*/
fnComplete: function ()
{
this.bLoadingComplete = true;
var nInfo = document.getElementById('EventLoading');
nInfo.innerHTML = '<span class="Event_header">Visual Event</span> (v.10) - by Allan Jardine<br>'+
'Information about events assigned on this page.<br>'+
'Press escape to quit. Note that jQuery, jQuery live, YUI 2,<br>'+
'MooTools, Prototype, JAK and Glow are currently supported<br>'+
'along with DOM level 0 events.<br>'+
'<div><a href="http://www.sprymedia.co.uk/article/Visual+Event" target="_blank">'+
'Click here for further information</a></div>'
EventLoader.toInfo = setTimeout( function() {
document.body.removeChild( nInfo );
}, 3000 );
jQuery(nInfo).mouseover( function() {
clearTimeout( EventLoader.toInfo );
} );
jQuery(nInfo).mouseout( function() {
EventLoader.toInfo = setTimeout( function() {
document.body.removeChild( nInfo );
}, 3000 );
} );
},
/*
* Function: EventLoader.fnLoad
* Purpose: Start the loading
* Returns: -
* Inputs: -
* Notes: -
*/
fnLoad: function ()
{
/* Check to see if already loaded */
if ( this.bLoadingComplete == true )
{
return 0;
}
var nLoading = document.createElement( 'div' );
nLoading.style.position = 'absolute';
nLoading.style.top = '0';
nLoading.style.left = '0';
nLoading.style.color = 'white';
nLoading.style.padding = '5px 10px';
nLoading.style.fontSize = '11px';
nLoading.style.fontFamily = '"Lucida Grande", Verdana, Arial, Helvetica, sans-serif';
nLoading.style.zIndex = '55999';
nLoading.style.backgroundColor = '#a2392d';
nLoading.setAttribute( 'id', 'EventLoading' );
nLoading.appendChild( document.createTextNode( 'Loading Visual Event...' ) );
document.getElementsByTagName('body')[0].insertBefore(
nLoading, document.body.childNodes[0] );
if ( typeof VisualEvent == 'object' )
{
EventLoader.fnPollReady();
}
else
{
setTimeout( function () { EventLoader.fnPollReady(); }, 1000 );
}
/* Deploy */
EventLoader.fnLoadFile( window.location.protocol+'//www.sprymedia.co.uk/design/event/media-0.10/css/event.css', 'css' );
if ( typeof jQuery == 'undefined' )
{
EventLoader.jQueryPreLoaded = false;
EventLoader.fnLoadFile( window.location.protocol+'//www.sprymedia.co.uk/design/event/media-0.10/js/event-complete-jquery.js', 'js' );
}
else
{
EventLoader.jQueryPreLoaded = true;
EventLoader.fnLoadFile( window.location.protocol+'//www.sprymedia.co.uk/design/event/media-0.10/js/event-complete.js', 'js' );
}
/* Localhost testing */
//var sAddress = "192.168.1.72";
//EventLoader.fnLoadFile( 'http://'+sAddress+'/design/event/media/css/event.css', 'css' );
//EventLoader.fnLoadFile( 'http://'+sAddress+'/design/event/media/css/shCore.css', 'css' );
//EventLoader.fnLoadFile( 'http://'+sAddress+'/design/event/media/css/shThemeEvent.css', 'css' );
//
//if ( typeof jQuery == 'undefined' )
//{
// EventLoader.fnLoadFile( 'http://'+sAddress+'/design/event/media/js/jquery.js', 'js' );
//}
//EventLoader.fnLoadFile( 'http://'+sAddress+'/design/event/media/js/shCore.js', 'js' );
//EventLoader.fnLoadFile( 'http://'+sAddress+'/design/event/media/js/shBrushJScript.js', 'js' );
//EventLoader.fnLoadFile( 'http://'+sAddress+'/design/event/media/js/event.js', 'js' );
}
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Initialisation - poll until all the required objects are available and
* then initalise Event Control.
*/
EventLoader.fnLoad();
};