3 $(document).ready(function () {
4 window.changesaved = true;
6 window.markChanged = function (saved) {
7 window.changesaved = saved;
10 $(window).on("beforeunload", function() {
11 if (!window.changesaved) {
12 return I18n.t("site.edit.potlatch2_unsaved_changes");
16 window.mapMoved = $.throttle(250, function(lon, lat, zoom) {
17 var hash = OSM.formatHash({ lon: lon, lat: lat, zoom: zoom });
19 if (hash !== location.hash) {
20 location.replace(hash);
23 updateLinks({ lon: lon, lat: lat }, zoom);
26 var potlatch = $("#potlatch"),
27 urlparams = OSM.params(),
28 potlatch_swf = <%= asset_path("potlatch2.swf").to_json %>,
29 install_swf = <%= asset_path("expressInstall.swf").to_json %>,
34 if (potlatch.data("lat") && potlatch.data("lon")) {
35 flashvars.lat = potlatch.data("lat");
36 flashvars.lon = potlatch.data("lon");
37 flashvars.zoom = potlatch.data("zoom");
39 var mapParams = OSM.mapParams();
41 flashvars.lat = mapParams.lat;
42 flashvars.lon = mapParams.lon;
43 flashvars.zoom = mapParams.zoom || 17;
46 if (potlatch.data("token")) {
47 flashvars.oauth_token = potlatch.data("token");
48 flashvars.oauth_token_secret = potlatch.data("token-secret");
49 flashvars.oauth_consumer_key = potlatch.data("consumer-key");
50 flashvars.oauth_consumer_secret = potlatch.data("consumer-secret");
52 alert(I18n.t("site.edit.potlatch2_not_configured"));
55 flashvars.assets = <%= asset_path("potlatch2/assets.zip").to_json %>;
56 flashvars.font_library = <%= asset_path("potlatch2/FontLibrary.swf").to_json %>;
57 flashvars.locale = potlatch.data("locale");
58 flashvars.locale_paths = potlatch.data("locale") + "=" + potlatch.data("locale-path");
59 flashvars.intro_image = <%= asset_path("help/introduction.jpg").to_json %>;
60 flashvars.intro_video = <%= asset_path("help/introduction.mp4").to_json %>;
61 if (urlparams.gpx) flashvars.gpx = urlparams.gpx;
62 if (urlparams.tileurl) flashvars.tileurl = urlparams.tileurl;
63 flashvars.api = location.protocol + "//" + location.host + "/api/" + OSM.API_VERSION + "/";
64 flashvars.policy = location.protocol + "//" + location.host + "/api/crossdomain.xml";
65 flashvars.connection = "XML";
66 flashvars.show_help = "once";
67 flashvars.user_check = "warn";
68 flashvars.maximise_function = "maximiseMap";
69 flashvars.minimise_function = "minimiseMap";
70 flashvars.move_function = "mapMoved";
72 params.base = "/potlatch2";
74 attributes.id = "potlatch";
75 attributes.bgcolor = "#FFFFFF";
77 swfobject.embedSWF(potlatch_swf, "potlatch", "100%", "100%", "10.1.102",
78 install_swf, flashvars, params, attributes);
80 if (flashvars.lat && flashvars.lon) {
81 updateLinks({ lon: flashvars.lon, lat: flashvars.lat }, flashvars.scale);