~qeef/damn-client.js

ad40be8ccc71aba1f03084295d40304447f3c762 — Jiri Vlasak 6 months ago 7f5aba2 + 5fdc0d9
Merge branch 'hotfix/0.19.2'
1 files changed, 38 insertions(+), 0 deletions(-)

M static/mappy-area.js
M static/mappy-area.js => static/mappy-area.js +38 -0
@@ 225,6 225,9 @@ function html_possible_actions(aid, sid)
    ih += "<li>";
    ih += html_mappy_new_lock_action(aid, sid, "lock", "josm");
    ih += "</li>";
    ih += "<ul><li>";
    ih += html_mappy_new_download(aid, sid, "gpx");
    ih += "</li></ul>";
    ih += "<li>";
    ih += html_mappy_new_lock_action(aid, sid, "lock", "id");
    ih += "</li>";


@@ 297,3 300,38 @@ function html_mappy_new_unlock_action(aid, sid, what)
    ih += "</a>";
    return ih;
}
function html_mappy_new_download(aid, sid, what)
{
    var ih = "";
    switch (what) {
    case "gpx":
        ih += "<a href='javascript:download_square_gpx(";
            ih += aid + ",";
            ih += sid + ",";
        ih += ")'";
        ih += " title='" + L("download") + " " + L(what) + "'";
        ih += ">";
        ih += L("download") + " " + L(what);
        ih += "</a>";
        break;
    }
    return ih;
}
function download_square_gpx(aid, sid)
{
    just_get(
        function (r)
        {
            var data = new Blob([r], {type: 'text/xml'});
            var url = window.URL.createObjectURL(data);
            var a = document.createElement("a");
            a.href = url;
            a.download = "square.gpx";
            a.click();
            window.URL.revokeObjectURL(url);
        },
        note,
        api.ep("/area/" + aid + "/square/" + sid + "/gpx"),
    );
    sh("square_menu", false);
}