Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MapBBCode Loader #235

Merged
merged 3 commits into from Dec 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions files/mapbbcode-loader/1.2.0/MapBBCodeLoader.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions files/mapbbcode-loader/1.2.0/MapBBCodeLoader.plain.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions files/mapbbcode-loader/1.2.0/mapbbcode-window.html
@@ -0,0 +1,70 @@
<!DOCTYPE html>
<html>
<head>
<title>MapBBCode Editor</title>
<meta charset="utf-8">
<script type="text/javascript" src="//cdn.jsdelivr.net/mapbbcode-loader/1.2.0/MapBBCodeLoader.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>
5 changes: 5 additions & 0 deletions files/mapbbcode-loader/info.ini
@@ -0,0 +1,5 @@
author = "Ilya Zverev"
github = "https://github.com/MapBBCode/mapbbcode-loader"
homepage = "http://mapbbcode.org/"
description = "MapBBCode Loader checks a page for [map] bbcode and converts these to interactive maps with MapBBCode library."
mainfile = "MapBBCodeLoader.js"