{if $input.mapId}
{/if} {if $input.shareCode or ! $input.mapId} {/if} {jq} var input = {{$input|json_encode}} , baseUrl = {{$base_url|json_encode}} ; $('#edit-share-code').submit(function () { var form = this; $.post($(this).attr('action'), $(this).serialize(), function () { document.location.href = 'Map?coordinates=' + encodeURIComponent(input.coordinates) + '&mapId=' + encodeURIComponent(input.mapId) + '&mapName=' + encodeURIComponent(input.mapName) + '&shareCode=' + encodeURIComponent($(':text', form).val()) ; }, 'json'); return false; }); $('#appframe .map-container').bind('initialized', function () { var container = this, updatePermalink; updatePermalink = function () { var url = baseUrl + 'Map?coordinates=' + encodeURIComponent($(container).getMapCenter()); if (input.shareCode) { url = url + '&shareCode=' + encodeURIComponent(input.shareCode) + '&mapName=' + encodeURIComponent(input.mapName) + '&sourceId=' + encodeURIComponent(input.mapId ? input.mapId : input.originalId) ; } $('#permalink') .val(url) .closest('form').attr('action', url); $('#embbed-map') .val($('').attr('src', url).attr('height', 400).attr('width', 600).wrap('').parent().html()); }; this.map.events.on({ move: updatePermalink }); updatePermalink(); }); $('#permalink').focus(function () { $(this).select(); }); {/jq}