2 <div id="potlatch"><%= raw t 'site.edit.flash_player_required' %></div>
5 <%= javascript_include_tag 'swfobject.js' %>
7 <% if defined? POTLATCH2_KEY %>
8 <% token = @user.access_token(POTLATCH2_KEY) %>
10 <script type="text/javascript">alert("<%= t 'site.edit.potlatch2_not_configured' %>")</script>
13 <% locale = request.compatible_language_from(Potlatch2::LOCALES.keys) || "en" %>
15 <script type="text/javascript" defer="defer">
18 window.onbeforeunload=function() {
20 return '<%= escape_javascript(t('site.edit.potlatch2_unsaved_changes')) %>';
24 function markChanged(a) { changesaved=a; }
26 function doSWF(lat,lon,zoom) {
28 if (lat) { flashvars.lat = lat; }
29 if (lon) { flashvars.lon = lon; }
30 flashvars.zoom = zoom;
31 flashvars.assets = "<%= asset_path "potlatch2/assets.zip" %>";
32 flashvars.font_library = "<%= asset_path "potlatch2/FontLibrary.swf" %>";
33 flashvars.locale = "<%= Potlatch2::LOCALES[locale] %>";
34 flashvars.locale_paths = "<%= Potlatch2::LOCALES[locale] %>=<%= asset_path("potlatch2/locales/#{Potlatch2::LOCALES[locale]}.swf") %>";
35 <% if params['gpx'] %>
36 flashvars.gpx = '<%= h(params['gpx']) %>';
38 <% if params['tileurl'] %>
39 flashvars.tileurl = '<%= h(params['tileurl']) %>';
41 flashvars.api = "<%= request.protocol + request.host_with_port %>/api/<%= API_VERSION %>/";
42 flashvars.policy = "<%= request.protocol + request.host_with_port %>/api/crossdomain.xml";
43 flashvars.connection = "XML";
44 flashvars.show_help = "once";
46 flashvars.oauth_token = "<%= token.token %>";
47 flashvars.oauth_token_secret = "<%= token.secret %>";
48 flashvars.oauth_consumer_key = "<%= token.client_application.key %>";
49 flashvars.oauth_consumer_secret = "<%= token.client_application.secret %>";
51 flashvars.maximise_function = "maximiseMap";
52 flashvars.minimise_function = "minimiseMap";
53 flashvars.move_function = "mapMoved";
56 params.base = "/potlatch2";
59 attributes.id = "potlatch";
60 attributes.bgcolor = "#FFFFFF";
62 swfobject.embedSWF("<%= asset_path("potlatch2.swf") %>", "potlatch", "100%", "100%", "10.1.102","<%= asset_path("expressInstall.swf") %>", flashvars, params, attributes);
63 // 700,600 for fixed size, 100%,100% for resizable
66 <% if params[:node] -%>
67 <% bbox = Node.find(params[:node]).bbox.to_unscaled -%>
68 doSWF(<%= bbox.centre_lat %>,<%= bbox.centre_lon %>,16);
69 <% elsif params[:way] -%>
70 <% bbox = Way.find(params[:way]).bbox.to_unscaled -%>
71 doSWF(<%= bbox.centre_lat %>,<%= bbox.centre_lon %>,16);
73 doSWF(<%= @lat || 'null' %>,<%= @lon || 'null' %>,<%= @zoom %>);
76 $(document).ready(function () {
77 $("body").on("click", "a.set_position", function () {
78 var lat = parseFloat($(this).attr("data-lat"));
79 var lon = parseFloat($(this).attr("data-lon"));
80 var zoom = parseInt($(this).attr("data-zoom"));
82 $("#potlatch").each(function () {
83 this.setPosition(lat, lon, Math.max(zoom || 15, 13));
88 function mapMoved(lon, lat, zoom, minlon, minlat, maxlon, maxlat) {
89 updatelinks(lon, lat, zoom, null, minlon, minlat, maxlon, maxlat);