This repository has been archived by the owner on Apr 8, 2021. It is now read-only.
forked from borkweb/BootstrapMediaWiki
-
Notifications
You must be signed in to change notification settings - Fork 128
/
custom.js
74 lines (63 loc) · 1.82 KB
/
custom.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
/**
* Vector-specific scripts
*/
jQuery( function ( $ ) {
// custom stuff
var $dirs = $('.mud-dir');
$dirs.find('.toggle').click( function( e ) {
$(this).closest('.mud-dir').toggleClass('show-long');
});
if ( false && ! $dirs.find('.reverse-short').length ) {
var opposites = {
n: 's',
s: 'n',
e: 'w',
w: 'e',
u: 'd',
d: 'u',
nw: 'se',
ne: 'sw',
se: 'nw',
sw: 'ne',
in: 'out',
out: 'in',
climb: 'd',
enter: 'leave',
xmen: 'eternal'
};
var dirs = $dirs.find('.short').html();
var short_dirs = [];
var long_dirs = [];
if ( /^From/.test( dirs ) ) {
console.log( 'here' );
dirs = $.trim( dirs.replace( /^From [^:]/, '' ) );
}//end if
dirs = dirs.split( ',' );
for ( var i in dirs ) {
dirs[ i ] = $.trim( dirs[ i ] );
matches = dirs[ i ].match(/([0-9]+)?(.+)/);
if ( typeof opposites[ matches[2] ] != 'undefined' ) {
short_dirs.push( ( matches[1] || '' ) + matches[2] );
} else {
short_dirs.push( ( matches[1] || '' ) + '?' );
}//end else
matches = dirs[ i ].match( /^([0-9]+)(n|s|e|w|u|d|nw|ne|sw|se|out|in|climb|jump|enter|leave)$/ );
if ( matches[1] ) {
for ( var index = 0; index < parseInt( matches[1], 10 ); index++ ) {
long_dirs.push( typeof opposites[ matches[2] ] != 'undefined' ? opposites[ matches[2] ] : '?' );
}//end for
} else {
long_dirs.push( ( typeof opposites[ dirs[ i ] ] != 'undefined' ? opposites[ dirs[ i ] ] : '?' ) );
}//end else
}//end for
$dirs.append( '<div class="reverse-short">' + short_dirs.join( ', ' ) + '</div>' );
$dirs.append( '<div class="reverse-long">' + long_dirs.join( ', ' ) + '</div>' );
}//end if
else {
$dirs.find('.reverse').hide();
}
$dirs.find('.reverse').click( function( e ) {
e.stopPropagation();
$(this).closest('.mud-dir').toggleClass('show-reverse');
});
} );