M CHANGELOG.md => CHANGELOG.md +5 -0
@@ 13,6 13,11 @@ The format is based on [Keep a Changelog][] and this project adheres to
Unreleased
==========
+Added
+-----
+
+- Panel (integration to iD editor without integration.)
+
Changed
-------
M static/fn.js => static/fn.js +25 -49
@@ 64,6 64,8 @@ function fo(w)
function sa(w)
{
switch (w) {
+ case "pa":
+ return pa;
case "la":
default:
return la;
@@ 222,6 224,20 @@ function go_to(where="list", aid=false, by)
note,
);
break;
+ case "panel":
+ if (!aid)
+ return go_to("list");
+ api.get_area(function(r) {
+ up("damn_main", pa.html_area(r));
+ sh("unlock_square", false);
+ window.scrollTo(0, 0);
+ window.history.pushState(
+ "damn " + aid,
+ "damn " + aid,
+ link_to("panel", aid),
+ );
+ }, aid);
+ break;
}
}
// create links
@@ 242,6 258,11 @@ function link_to(where="list", aid=false)
return link_to("list");
link += "?stats=" + aid;
break;
+ case "panel":
+ if (!aid)
+ return link_to("list");
+ link += "?panel=" + aid;
+ break;
}
return link;
}
@@ 271,7 292,7 @@ function link_to_edit(edit="id", aid=false, sid=false, msg="", mm=false)
break;
case "id":
default:
- link += "https://www.openstreetmap.org/edit?editor=id";
+ link += "https://www.openstreetmap.org/edit?editor=id#";
link += "&comment=" + encodeURI(msg);
link += "&gpx=" + encodeURIComponent(gpx);
}
@@ 306,54 327,9 @@ function new_lock_action(what, aid=false, msg, by)
sh("unlock_square", true);
document.getElementById("commit_msg").value = "";
var ih = "";
- switch (what.split(" ")[0]) {
- case "map":
- sa(by).open_edit(link_to_edit(EDIT, aid, sid, msg, mm));
- ih += L("unlock needs mapping")[0];
- ih += sa(by).html_new_unlock_action(
- "needs mapping",
- L("unlock needs mapping")[1],
- aid, sid,
- );
- ih += L("unlock needs mapping")[2];
- ih += sa(by).html_new_unlock_action(
- "needs review",
- L("unlock needs mapping")[3],
- aid, sid,
- );
- ih += L("unlock needs mapping")[4];
- ih += sa(by).html_new_unlock_action(
- "split",
- L("unlock needs mapping")[5],
- aid, sid,
- );
- ih += L("unlock needs mapping")[6];
- break;
- case "review":
- sa(by).open_edit(link_to_edit(EDIT, aid, sid, msg, mm));
- ih += L("unlock needs review")[0];
- ih += sa(by).html_new_unlock_action(
- "is done",
- L("unlock needs review")[1],
- aid, sid,
- );
- ih += L("unlock needs review")[2];
- ih += sa(by).html_new_unlock_action(
- "needs mapping",
- L("unlock needs review")[3],
- aid, sid,
- );
- ih += L("unlock needs review")[4];
- ih += sa(by).html_new_unlock_action(
- "needs review",
- L("unlock needs review")[5],
- aid, sid,
- );
- ih += L("unlock needs review")[6];
- break;
- default:
- return;
- }
+ sa(by).open_edit(link_to_edit(EDIT, aid, sid, msg, mm));
+ ih += sa(by)
+ .html_possible_unlock_actions(what.split(" ")[0], aid, sid);
document.getElementById("unlock_actions").innerHTML = ih;
},
aid,
M static/i18n.js => static/i18n.js +1 -1
@@ 157,7 157,7 @@ i18n = {
+ " | +-------+ |\n"
+ " +-| split |<-+\n"
+ " +-------+\n",
- "workflow what": ["Read <em>what are we mapping</em>. If you are new, ", /* link: */ "let reviewers know", " and <em>map some square</em>. If you are experienced, consider <em>reviewing</em> mapped squares."],
+ "workflow what": ["Read <em>what are we mapping</em>. If you are new, ", /* link: */ "let reviewers know", " and <em>map some square</em>. If you are experienced, consider <em>reviewing</em> mapped squares.", "For integration without integration to iD,", /* link: */ "open the panel."],
"workflow newbie": "Read <em>what are we mapping</em>. Reviewers can find your <em>mapped squares</em> untill" /* here is date */,
"unlock needs mapping": ["You have mapped the square. Now it's up to you to decide if the square ", /* link: */ "needs more mapping", " or the square ", /* link: */ "is ready for review", ". If the square is too large, you may ", /* link: */ "split the square", "."],
"unlock needs review": ["You have reviewed the square. Now it's up to you to decide if the square ", /* link: */ "is done", " or ", /* link: */ "needs more mapping", ". If you're not able to decide, ", /* link: */ "let another to do so", "."],
M static/index.html => static/index.html +4 -0
@@ 10,10 10,12 @@
<script src="fn.js"></script>
<script src="light-list.js"></script>
<script src="light-area.js"></script>
+<script src="panel-area.js"></script>
<script src="light-stats.js"></script>
<script>
var api = new DamnAPI("https://server.damn-project.org");
var la = new LightArea();
+ var pa = new PanelArea();
var LANG = "en";
try {
if (api.user() && api.user()["lang"] != "")
@@ 27,6 29,8 @@
return go_to("area", sp.get("area"));
} else if (sp.has("stats")) {
return go_to("stats", sp.get("stats"));
+ } else if (sp.has("panel")) {
+ return go_to("panel", sp.get("panel"));
}
return go_to("list");
}
M static/light-area.js => static/light-area.js +54 -0
@@ 18,6 18,7 @@ Provides
- LightArea:
- html_area
+ - html_possible_unlock_actions
- html_new_lock_action
- html_new_unlock_action
@@ 145,6 146,10 @@ LightArea.prototype = {
ih += L("workflow what")[1] + "</a>";
ih += L("workflow what")[2];
}
+ ih += " " + L("workflow what")[3] + " ";
+ ih += "<a href='javascript:pa.open(" + aid + ")'>";
+ ih += L("workflow what")[4];
+ ih += "</a>";
ih += "</p>";
// commit message (hidden by default, see go_to)
ih += "<div id='unlock_square'>";
@@ 214,6 219,55 @@ LightArea.prototype = {
ih += "</div>";
return ih;
},
+ html_possible_unlock_actions: function(what, aid, sid)
+ {
+ var ih = "";
+ switch (what) {
+ case "map":
+ ih += L("unlock needs mapping")[0];
+ ih += this.html_new_unlock_action(
+ "needs mapping",
+ L("unlock needs mapping")[1],
+ aid, sid,
+ );
+ ih += L("unlock needs mapping")[2];
+ ih += this.html_new_unlock_action(
+ "needs review",
+ L("unlock needs mapping")[3],
+ aid, sid,
+ );
+ ih += L("unlock needs mapping")[4];
+ ih += this.html_new_unlock_action(
+ "split",
+ L("unlock needs mapping")[5],
+ aid, sid,
+ );
+ ih += L("unlock needs mapping")[6];
+ break;
+ case "review":
+ ih += L("unlock needs review")[0];
+ ih += this.html_new_unlock_action(
+ "is done",
+ L("unlock needs review")[1],
+ aid, sid,
+ );
+ ih += L("unlock needs review")[2];
+ ih += this.html_new_unlock_action(
+ "needs mapping",
+ L("unlock needs review")[3],
+ aid, sid,
+ );
+ ih += L("unlock needs review")[4];
+ ih += this.html_new_unlock_action(
+ "needs review",
+ L("unlock needs review")[5],
+ aid, sid,
+ );
+ ih += L("unlock needs review")[6];
+ break;
+ }
+ return ih;
+ },
// depend on: new_lock_action, L
html_new_lock_action: function(what, aid, msg)
{
A static/panel-area.js => static/panel-area.js +217 -0
@@ 0,0 1,217 @@
+/*
+
+Panel area
+==========
+
+Wondering, how the integration without integration to iD editor looks like?
+
+Depends on
+----------
+
+- damn-api.js
+- i18n.js
+- fn.js
+
+Provides
+--------
+
+- PanelArea:
+
+ - html_area
+ - html_possible_unlock_actions
+ - html_new_lock_action
+ - html_new_unlock_action
+
+
+This code is published under MIT license
+========================================
+
+Copyright (c) 2020-2021 Jiri Vlasak
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+*/
+function PanelArea()
+{
+ this.w = false;
+}
+PanelArea.prototype = {
+ constructor: PanelArea,
+ open: function(aid) {
+ var specs = "";
+ specs += "left=" + (window.screen.availWidth - 150) + ",";
+ specs += "location=no,";
+ specs += "menubar=no,";
+ specs += "resizable=yes,";
+ specs += "status=no,";
+ specs += "titlebar=no,";
+ specs += "toolbar=no,";
+ specs += "width=150";
+ window.open("?panel=" + aid, "damn_win", specs);
+ },
+ open_edit: function(link) {
+ var specs = "";
+ specs += "location=no,";
+ specs += "menubar=no,";
+ specs += "resizable=yes,";
+ specs += "status=no,";
+ specs += "titlebar=no,";
+ specs += "toolbar=no,";
+ specs += "width=" + (screen.width - 150);
+ if (this.w)
+ this.w.close();
+ if (pa.w)
+ pa.w.close();
+ this.w = window.open(link, "", specs);
+ },
+ html_area: function(area) {
+ var aid = area["aid"];
+ var sm = area["squares_to_map"];
+ var sr = area["squares_to_review"];
+ var sd = area["squares_done"];
+ var ss = sm + sr + sd;
+ sm = Math.round(100 * sm / ss);
+ sr = Math.round(100 * sr / ss);
+ sd = Math.round(100 * sd / ss);
+ var t = area["aid"] + " " + area["tags"];
+ var d = "";
+ try {
+ for (k in area["description"]) {
+ d += k + ":\n" + area["description"][k] + "\n\n";
+ }
+ } catch(e) {}
+ try {
+ for (k in area["instructions"]) {
+ d += k + ": " + area["instructions"][k] + "\n";
+ }
+ } catch(e) {}
+ d += "\n";
+ d += sm + "% " + L("to map");
+ d += ", " + sr + "% " + L("to review");
+ d += ", " + sd + "% " + L("done");
+ var ih = "";
+ ih += "<div title='" + d + "'>" + t + "</div>";
+ // commit message (hidden by default, see go_to)
+ ih += "<div id='unlock_square'>";
+ ih += "<h3>" + L("unlock square") + "</h3>";
+ ih += "<textarea";
+ ih += " id='commit_msg'";
+ ih += " class='fill'";
+ ih += " placeholder='Something to share about the square?'";
+ ih += "></textarea>";
+ // . unlock actions
+ ih += "<p id='unlock_actions'></p>";
+ ih += "</div>";
+ // mapping actions
+ ih += "<div>";
+ ih += "<h3>" + sm + "% " + L("to map") + "</h3>";
+ ih += "<ul>";
+ var msg = area["tags"] + " " + "#damn-" + aid;
+ ih += "<li>" + this.html_new_lock_action("map random", aid, msg);
+ ih += "</li>";
+ ih += "<li>" + this.html_new_lock_action("map recent", aid, msg);
+ ih += "</li>";
+ ih += "<li>" + this.html_new_lock_action("map nearest", aid, msg);
+ ih += "</li>";
+ ih += "</ul>";
+ ih += "</div>";
+ // review actions
+ ih += "<div>";
+ ih += "<h3>" + sr + "% " + L("to review") + "</h3>";
+ ih += "<ul>";
+ ih += "<li>" + this.html_new_lock_action("review random", aid, msg);
+ ih += "</li>";
+ ih += "<li>" + this.html_new_lock_action("review recent", aid, msg);
+ ih += "</li>";
+ ih += "<li>" + this.html_new_lock_action("review nearest", aid, msg);
+ ih += "</li>";
+ ih += "<li>" + this.html_new_lock_action("review newbie", aid, msg);
+ ih += "</li>";
+ ih += "</ul>";
+ ih += "</div>";
+ ih += "<h3>" + sd + "% " + L("done") + "</h3>";
+ return ih;
+ },
+ html_possible_unlock_actions: function(what, aid, sid)
+ {
+ var ih = "";
+ ih += "<ul>";
+ ih += "<li>";
+ ih += this.html_new_unlock_action(
+ "needs mapping",
+ L("to map"),
+ aid, sid,
+ );
+ ih += "</li>";
+ ih += "<li>";
+ ih += this.html_new_unlock_action(
+ "needs review",
+ L("to review"),
+ aid, sid,
+ );
+ ih += "</li>";
+ ih += "<li>";
+ ih += this.html_new_unlock_action(
+ "is done",
+ L("done"),
+ aid, sid,
+ );
+ ih += "</li>";
+ ih += "<li>";
+ ih += this.html_new_unlock_action(
+ "split",
+ L("split"),
+ aid, sid,
+ );
+ ih += "</li>";
+ ih += "</ul>";
+ return ih;
+ },
+ // depend on: new_lock_action, L
+ html_new_lock_action: function(what, aid, msg) {
+ var r = what.split(" ");
+ var ih = "";
+ ih += "<a";
+ ih += " href='javascript:new_lock_action(";
+ ih += "\"" + what + "\",";
+ ih += aid + ",";
+ ih += "\"" + msg + "\",";
+ ih += "\"pa\",";
+ ih += ")'";
+ ih += " title='" + what + " square'";
+ ih += ">";
+ ih += L(r[1] + " square");
+ ih += "</a>";
+ return ih;
+ },
+ // depend on: new_unlock_action, L
+ html_new_unlock_action: function(what, title, aid, sid) {
+ var ih = "";
+ ih += "<a";
+ ih += " href='javascript:new_unlock_action(";
+ ih += "\"" + what + "\", ";
+ ih += aid + ", ";
+ ih += sid + ")'";
+ ih += " title='" + title + "'";
+ ih += ">";
+ ih += title;
+ ih += "</a>";
+ return ih;
+ },
+};