Skip to content

Commit c84c189

Browse files
committed
Added static media for floorplans.
- Legacy-Id: 11539
1 parent 874000f commit c84c189

2 files changed

Lines changed: 173 additions & 0 deletions

File tree

1.76 KB
Loading

ietf/static/ietf/js/room_params.js

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
var verbose = 0;
2+
3+
function suffixmap(nm)
4+
// Given a name like "foo-ab" or "foo-X-and-Y", change it to the "list-of-room-names" format, "foo-a/foo-b".
5+
{
6+
var andsuffix = /^(.*-)([^-]+)-and-(.*)$/;
7+
var andMatch = andsuffix.exec(nm);
8+
if (andMatch && andMatch[0] != '') {
9+
nm = andMatch[1] + andMatch[2] + "-" + andMatch[3];
10+
}
11+
// xyz-a/b/c => xyz-a/xyz-b/xyz-c
12+
var abcsuffix = /^(.*)-([a-h0-9]+)[-\/]([a-h0-9]+)([-\/][a-h0-9]+)?$/;
13+
var suffixMatch = abcsuffix.exec(nm);
14+
if (verbose) alert("nm=" + nm);
15+
if (suffixMatch && suffixMatch[0] != '') {
16+
if (verbose) alert("matched");
17+
nm = suffixMatch[1] + "-" + suffixMatch[2] + "/" +
18+
suffixMatch[1] + "-" + suffixMatch[3];
19+
if (verbose) alert("nm=>" + nm);
20+
if (suffixMatch[4] && suffixMatch[4] != '')
21+
nm += "/" + suffixMatch[1] + "-" + suffixMatch[4];
22+
if (verbose) alert("nm=>" + nm);
23+
}
24+
// xyz-abc => xyz-a/xyz-b/xyz-c
25+
abcsuffix = /^(.*)-([a-h])([a-h]+)([a-h])?$/;
26+
var suffixMatch = abcsuffix.exec(nm);
27+
if (suffixMatch && suffixMatch[0] != '') {
28+
nm = suffixMatch[1] + "-" + suffixMatch[2] + "/" +
29+
suffixMatch[1] + "-" + suffixMatch[3];
30+
if (suffixMatch[4] && suffixMatch[4] != '')
31+
nm += "/" + suffixMatch[1] + "-" + suffixMatch[4];
32+
}
33+
if (verbose) alert("suffixmap returning: " + nm);
34+
return nm;
35+
}
36+
37+
function roomcoords(nm)
38+
// Find the coordinates of a room or list of room names separated by "/".
39+
// Calls the function findroom() to get the coordinates for a specific room.
40+
{
41+
if (!nm) return null;
42+
43+
if (nm.match("/")) {
44+
var nms = nm.split("/");
45+
var nm0 = findroom(nms[0]);
46+
if (!nm0) return null;
47+
for (var i = 1; i < nms.length; i++) {
48+
var nmi = roomcoords(nms[i]);
49+
if (!nmi) return null;
50+
if (nmi[0] < nm0[0]) nm0[0] = nmi[0];
51+
if (nmi[1] < nm0[1]) nm0[1] = nmi[1];
52+
if (nmi[2] > nm0[2]) nm0[2] = nmi[2];
53+
if (nmi[3] > nm0[3]) nm0[3] = nmi[3];
54+
}
55+
return [nm0[0], nm0[1], nm0[2], nm0[3]];
56+
} else {
57+
return findroom(nm);
58+
}
59+
}
60+
61+
function setarrow(nm, fl)
62+
// Place an arrow at the center of a given room name (or list of room names separated by "/").
63+
{
64+
for (var i = 0; i < arrowsuffixlist.length; i++) {
65+
removearrow(arrowsuffixlist[i], fl);
66+
}
67+
for (var i = 0; i < arguments.length; i+=2) {
68+
nm = roommap(arguments[i]);
69+
if (verbose) alert("nm=" + nm);
70+
var rooms = nm.split(/[|]/);
71+
for (var j = 0; j < rooms.length; j++) {
72+
var room = rooms[j];
73+
var ret = roomcoords(room);
74+
if (verbose) alert("roomcoords returned: " + ret);
75+
if (!ret) continue;
76+
77+
var left = ret[0], top = ret[1], right = ret[2], bottom = ret[3], offsetleft = -25, offsettop = -25;
78+
if (verbose) alert("left=" + left + ", top=" + top + ", right=" + right + ", bottom=" + bottom);
79+
//alert("left=" + left + ", top=" + top + ", right=" + right + ", bottom=" + bottom);
80+
var arrowdiv = fl+'-arrowdiv' + (j > 0 ? j : "");
81+
//if (verbose) alert("arrowdiv: " + arrowdiv);
82+
var adiv = document.getElementById(arrowdiv);
83+
// if (verbose) alert("looking for 'arrowdiv'+" + j);
84+
if (adiv) {
85+
//if (verbose) alert("adiv found");
86+
adiv.style.left = left + (right - left) / 2 + offsetleft;
87+
adiv.style.top = top + (bottom - top) / 2 + offsettop;
88+
adiv.style.visibility = "visible";
89+
}
90+
}
91+
}
92+
}
93+
94+
function removearrow(which, fl)
95+
{
96+
for (var i = 0; i < arguments.length; i++) {
97+
var which = arguments[i];
98+
var arrowdiv = fl+'-arrowdiv' + (which ? which : "");
99+
var adiv = document.getElementById(arrowdiv);
100+
// if (verbose) alert("looking for '" + arrowdiv + "'");
101+
if (adiv) {
102+
// if (verbose) alert("adiv found");
103+
adiv.style.left = -500;
104+
adiv.style.top = -500;
105+
adiv.style.visibility = "hidden";
106+
}
107+
}
108+
}
109+
110+
function setarrowlist(which, names)
111+
{
112+
for (var i = 1; i < arguments.length; i++) {
113+
setarrow(arguments[i], which);
114+
}
115+
}
116+
117+
function QueryString()
118+
// Create a QueryString object
119+
{
120+
// get the query string, ignore the ? at the front.
121+
var querystring = location.search.substring(1);
122+
123+
// parse out name/value pairs separated via &
124+
var args = querystring.split('&');
125+
126+
// split out each name = value pair
127+
for (var i = 0; i < args.length; i++) {
128+
var pair = args[i].split('=');
129+
130+
// Fix broken unescaping
131+
var temp = unescape(pair[0]).split('+');
132+
var name_ = temp.join(' ');
133+
134+
var value_ = '';
135+
if (typeof pair[1] == 'string') {
136+
temp = unescape(pair[1]).split('+');
137+
value_ = temp.join(' ');
138+
}
139+
140+
this[name_] = value_;
141+
}
142+
143+
this.get = function(nm, def) {
144+
var value_ = this[nm];
145+
if (value_ == null) return def;
146+
else return value_;
147+
};
148+
}
149+
150+
function checkParams()
151+
// Check the parameters for one named "room". If found, call setarrow(room).
152+
{
153+
var querystring = new QueryString();
154+
var room = querystring.get("room");
155+
if (room && room != "") setarrow(room);
156+
}
157+
158+
// new functions
159+
function located(loc)
160+
{
161+
if (loc.civic && loc.civic.ROOM) {
162+
// map from "TerminalRoom" to "terminal-room" as necessary.
163+
setarrow(loc.civic.ROOM.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(), "-green");
164+
}
165+
}
166+
167+
// this needs to be called onload
168+
function automaticarrow()
169+
{
170+
// if (navigator.geolocation) {
171+
// navigator.geolocation.getCurrentPosition(located);
172+
// }
173+
}

0 commit comments

Comments
 (0)