-
Notifications
You must be signed in to change notification settings - Fork 1
/
mapbbcode-window.html
70 lines (67 loc) · 1.9 KB
/
mapbbcode-window.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
<!DOCTYPE html>
<html>
<head>
<title>MapBBCode Editor</title>
<meta charset="utf-8">
<script type="text/javascript" src="MapBBCodeLoader.min.js"></script>
<style>html, body, #edit, .leaflet-container { margin: 0; height: 100%; }</style>
</head>
<body>
<div id="edit"></div>
<script>
<!--
var lopt = mapBBCodeLoaderOptions;
lopt.set(opener.mapBBCodeLoaderOptions);
var path, lpath = lopt.path || '.', wpath = lopt.mapBBCodeOptions.windowPath;
if( wpath.indexOf('/') < 0 )
wpath = './' + wpath;
wpath = wpath.replace(/\/[^\/.]+\.[a-z]+$/, '/');
if( lpath.substring(lpath.length - 1) !== '/' )
lpath += '/';
if( wpath.substring(wpath.length - 1) !== '/' )
wpath += '/';
lpath = lpath.replace(/(^|\/)\.\//g, '$1');
wpath = wpath.replace(/(^|\/)\.\//g, '$1');
if( lopt.pathInWindow )
path = lopt.pathInWindow;
else if( lpath === wpath )
path = '';
else if( /^([a-z]:)?\//.test(lpath) )
path = lpath;
else if( /^([a-z]:)?\//.test(wpath) )
path = wpath;
else {
// derive path from relative lopt.path and windowPath (does not expand '..')
var pathFrag = lpath.split('/'), wpathFrag = wpath.split('/'), i = 0, j;
while( pathFrag.length > 0 && pathFrag[pathFrag.length - 1] === '' )
pathFrag.pop();
while( wpathFrag.length > 0 && wpathFrag[wpathFrag.length - 1] === '' )
wpathFrag.pop();
while( i < pathFrag.length && i < wpathFrag.length && pathFrag[i] === wpathFrag[i] )
i++;
path = '';
for( j = i; j < wpathFrag.length; j++ )
path += '../';
for( j = i; j < pathFrag.length; j++ )
path += pathFrag[j] + '/';
}
lopt.set({
path: path,
force: true,
draw: true,
onload: function(mapBB) {
var stored = opener.storedMapBB;
mapBB.options.editorHeight = 0;
mapBB.options.editorCloseButtons = true;
mapBB.editor('edit', stored.bbcode, function(res) {
window.close();
if( stored.callback )
stored.callback.call(stored.context, res);
opener.storedMapBB = null;
}, this);
}
});
// -->
</script>
</body>
</html>