X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/7a98913d0cf74887180aca3520c628a52b0e7071..3ddc80325948aa1f5249c31dd39dcb3c8156d7d5:/vendor/assets/iD/iD.js diff --git a/vendor/assets/iD/iD.js b/vendor/assets/iD/iD.js index 11dd2f7b0..6adb5fef0 100644 --- a/vendor/assets/iD/iD.js +++ b/vendor/assets/iD/iD.js @@ -10729,7 +10729,7 @@ var JXON = new (function () { } }(this)); (function(e){if("function"==typeof bootstrap)bootstrap("osmauth",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeOsmAuth=e}else"undefined"!=typeof window?window.osmAuth=e():global.osmAuth=e()})(function(){var define,ses,bootstrap,module,exports; -return (function(e,t,n){function r(n,i){if(!t[n]){if(!e[n]){var s=typeof require=="function"&&require;if(!i&&s)return s(n,!0);throw new Error("Cannot find module '"+n+"'")}var o=t[n]={exports:{}};e[n][0](function(t){var i=e[n][1][t];return r(i?i:t)},o,o.exports)}return t[n].exports}for(var i=0;i * @license New BSD (see LICENSE file) - * @version 1.0.1 - 17/02/2013 + * @version 1.0.3 * * Algorithms specification: * * MD5 * RIPEMD-160 - * SHA1 - * SHA256 - * SHA512 + * SHA1 + * SHA256 + * SHA512 * HMAC * */ @@ -11222,11 +11212,11 @@ module.exports = ohauth; // private helper methods function utf8Encode(input) { - var output = '', i = -1, x, y; - while (++i < input.length) { + var x, y, output = '', i = -1, l = input.length; + while ((i+=1) < l) { /* Decode utf-16 surrogate pairs */ x = input.charCodeAt(i); - y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0; + y = i + 1 < l ? input.charCodeAt(i + 1) : 0; if (0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF) { x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF); i += 1; @@ -11252,11 +11242,11 @@ module.exports = ohauth; } function utf8Decode(str_data) { - var i, ac, c1, c2, c3, arr = []; + var i, ac, c1, c2, c3, arr = [], l = str_data.length; i = ac = c1 = c2 = c3 = 0; str_data += ''; - while (i < str_data.length) { + while (i < l) { c1 = str_data.charCodeAt(i); ac += 1; if (c1 < 128) { @@ -11298,8 +11288,8 @@ module.exports = ohauth; */ function rstr2hex(input, hexcase) { var hex_tab = hexcase ? '0123456789ABCDEF' : '0123456789abcdef', - output = '', x, i = 0; - for (; i < input.length; i+=1) { + output = '', x, i = 0, l = input.length; + for (; i < l; i+=1) { x = input.charCodeAt(i); output += hex_tab.charAt((x >>> 4) & 0x0F) + hex_tab.charAt(x & 0x0F); } @@ -11310,16 +11300,16 @@ module.exports = ohauth; * Encode a string as utf-16 */ function str2rstr_utf16le(input) { - var i = 0, output = ''; - for (; i < input.length; i+=1) { + var i, l = input.length, output = ''; + for (i = 0; i < l; i+=1) { output += String.fromCharCode( input.charCodeAt(i) & 0xFF, (input.charCodeAt(i) >>> 8) & 0xFF); } return output; } function str2rstr_utf16be(input) { - var i = 0, output = ''; - for (; i < input.length; i+=1) { + var i, l = input.length, output = ''; + for (i = 0; i < l; i+=1) { output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF, input.charCodeAt(i) & 0xFF); } return output; @@ -11329,8 +11319,8 @@ module.exports = ohauth; * Convert an array of big-endian words to a string */ function binb2rstr(input) { - var i = 0, output = ''; - for (;i < input.length * 32; i += 8) { + var i, l = input.length * 32, output = ''; + for (i = 0; i < l; i += 8) { output += String.fromCharCode((input[i>>5] >>> (24 - i % 32)) & 0xFF); } return output; @@ -11340,8 +11330,8 @@ module.exports = ohauth; * Convert an array of little-endian words to a string */ function binl2rstr(input) { - var i = 0, output = ''; - for (;i < input.length * 32; i += 8) { + var i, l = input.length * 32, output = ''; + for (i = 0;i < l; i += 8) { output += String.fromCharCode((input[i>>5] >>> (i % 32)) & 0xFF); } return output; @@ -11352,11 +11342,11 @@ module.exports = ohauth; * Characters >255 have their high-byte silently ignored. */ function rstr2binl(input) { - var i, output = Array(input.length >> 2); - for (i = 0; i < output.length; i+=1) { + var i, l = input.length * 8, output = Array(input.length >> 2), lo = output.length; + for (i = 0; i < lo; i+=1) { output[i] = 0; } - for (i = 0; i < input.length * 8; i += 8) { + for (i = 0; i < l; i += 8) { output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (i%32); } return output; @@ -11367,11 +11357,11 @@ module.exports = ohauth; * Characters >255 have their high-byte silently ignored. */ function rstr2binb(input) { - var i, output = Array(input.length >> 2); - for (i = 0; i < output.length; i+=1) { + var i, l = input.length * 8, output = Array(input.length >> 2), lo = output.length; + for (i = 0; i < lo; i+=1) { output[i] = 0; } - for (i = 0; i < input.length * 8; i += 8) { + for (i = 0; i < l; i += 8) { output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (24 - i % 32); } return output; @@ -11383,11 +11373,12 @@ module.exports = ohauth; function rstr2any(input, encoding) { var divisor = encoding.length, remainders = Array(), - i, q, x, quotient, dividend, output, full_length; + i, q, x, ld, quotient, dividend, output, full_length; /* Convert to an array of 16-bit big-endian values, forming the dividend */ dividend = Array(Math.ceil(input.length / 2)); - for (i = 0; i < dividend.length; i+=1) { + ld = dividend.length; + for (i = 0; i < ld; i+=1) { dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1); } @@ -11438,7 +11429,7 @@ module.exports = ohauth; triplet = (input.charCodeAt(i) << 16) | (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0) | (i + 2 < len ? input.charCodeAt(i+2) : 0); - for (j = 0; j < 4; j++) { + for (j = 0; j < 4; j+=1) { if (i * 8 + j * 6 > input.length * 8) { output += b64pad; } else { @@ -11450,6 +11441,11 @@ module.exports = ohauth; } Hashes = { + /** + * @property {String} version + * @readonly + */ + VERSION : '1.0.3', /** * @member Hashes * @class Base64 @@ -11475,8 +11471,8 @@ module.exports = ohauth; triplet = (input.charCodeAt(i) << 16) | (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0) | (i + 2 < len ? input.charCodeAt(i+2) : 0); - for (j = 0; j < 4; j++) { - if (i * 8 + j * 6 > input.length * 8) { + for (j = 0; j < 4; j+=1) { + if (i * 8 + j * 6 > len * 8) { output += pad; } else { output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F); @@ -11553,35 +11549,37 @@ module.exports = ohauth; * @return {String} */ CRC32 : function (str) { - var crc = 0, x = 0, y = 0, table, i; + var crc = 0, x = 0, y = 0, table, i, iTop; str = utf8Encode(str); - table = '00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 ' + - '79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 ' + - '84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F ' + - '63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD ' + - 'A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC ' + - '51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 ' + - 'B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 ' + - '06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 ' + - 'E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 ' + - '12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 ' + - 'D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 ' + - '33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 ' + - 'CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 ' + - '9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E ' + - '7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D ' + - '806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 ' + - '60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA ' + - 'AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 ' + - '5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 ' + - 'B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 ' + - '05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 ' + - 'F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA ' + - '11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 ' + - 'D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F ' + - '30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E ' + - 'C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D'; + table = [ + '00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 ', + '79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 ', + '84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F ', + '63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD ', + 'A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC ', + '51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 ', + 'B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 ', + '06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 ', + 'E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 ', + '12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 ', + 'D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 ', + '33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 ', + 'CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 ', + '9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E ', + '7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D ', + '806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 ', + '60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA ', + 'AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 ', + '5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 ', + 'B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 ', + '05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 ', + 'F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA ', + '11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 ', + 'D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F ', + '30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E ', + 'C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D' + ].join(''); crc = crc ^ (-1); for (i = 0, iTop = str.length; i < iTop; i+=1 ) { @@ -11589,7 +11587,8 @@ module.exports = ohauth; x = '0x' + table.substr( y * 9, 8 ); crc = ( crc >>> 8 ) ^ x; } - return crc ^ (-1); + // always return a positive number (that's what >>> 0 does) + return (crc ^ (-1)) >>> 0; }, /** * @member Hashes @@ -11685,7 +11684,7 @@ module.exports = ohauth; * Calculate the HMAC-MD5, of a key and some data (raw strings) */ function rstr_hmac(key, data) { - var bkey, ipad, hash, i; + var bkey, ipad, opad, hash, i; key = (utf8) ? utf8Encode(key) : key; data = (utf8) ? utf8Encode(data) : data; @@ -11915,7 +11914,7 @@ module.exports = ohauth; * Calculate the HMAC-SHA1 of a key and some data (raw strings) */ function rstr_hmac(key, data) { - var bkey, ipad, i, hash; + var bkey, ipad, opad, i, hash; key = (utf8) ? utf8Encode(key) : key; data = (utf8) ? utf8Encode(data) : data; bkey = rstr2binb(key); @@ -11955,7 +11954,7 @@ module.exports = ohauth; oldd = d; olde = e; - for (j = 0; j < 80; j++) { + for (j = 0; j < 80; j+=1) { if (j < 16) { w[j] = x[i + j]; } else { @@ -12130,8 +12129,7 @@ module.exports = ohauth; function sha256_Gamma0512(x) {return (sha256_S(x, 1) ^ sha256_S(x, 8) ^ sha256_R(x, 7));} function sha256_Gamma1512(x) {return (sha256_S(x, 19) ^ sha256_S(x, 61) ^ sha256_R(x, 6));} - sha256_K = new Array - ( + sha256_K = [ 1116352408, 1899447441, -1245643825, -373957723, 961987163, 1508970993, -1841331548, -1424204075, -670586216, 310598401, 607225278, 1426881987, 1925078388, -2132889090, -1680079193, -1046744716, -459576895, -272742522, @@ -12143,11 +12141,11 @@ module.exports = ohauth; 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, -2067236844, -1933114872, -1866530822, -1538233109, -1090935817, -965641998 - ); + ]; function binb(m, l) { - var HASH = new Array(1779033703, -1150833019, 1013904242, -1521486534, - 1359893119, -1694144372, 528734635, 1541459225); + var HASH = [1779033703, -1150833019, 1013904242, -1521486534, + 1359893119, -1694144372, 528734635, 1541459225]; var W = new Array(64); var a, b, c, d, e, f, g, h; var i, j, T1, T2; @@ -12167,7 +12165,7 @@ module.exports = ohauth; g = HASH[6]; h = HASH[7]; - for (j = 0; j < 64; j++) + for (j = 0; j < 64; j+=1) { if (j < 16) { W[j] = m[j + i]; @@ -12321,11 +12319,11 @@ module.exports = ohauth; * Calculate the SHA-512 of an array of big-endian dwords, and a bit length */ function binb(x, len) { - var j, i, - W = new Array(80); + var j, i, l, + W = new Array(80), hash = new Array(16), //Initial hash values - H = new Array( + H = [ new int64(0x6a09e667, -205731576), new int64(-1150833019, -2067093701), new int64(0x3c6ef372, -23791573), @@ -12334,7 +12332,7 @@ module.exports = ohauth; new int64(-1694144372, 0x2b3e6c1f), new int64(0x1f83d9ab, -79577749), new int64(0x5be0cd19, 0x137e2179) - ), + ], T1 = new int64(0, 0), T2 = new int64(0, 0), a = new int64(0,0), @@ -12356,7 +12354,7 @@ module.exports = ohauth; if (sha512_k === undefined) { //SHA512 constants - sha512_k = new Array( + sha512_k = [ new int64(0x428a2f98, -685199838), new int64(0x71374491, 0x23ef65cd), new int64(-1245643825, -330482897), new int64(-373957723, -2121671748), new int64(0x3956c25b, -213338824), new int64(0x59f111f1, -1241133031), @@ -12397,7 +12395,7 @@ module.exports = ohauth; new int64(0x3c9ebe0a, 0x15c9bebc), new int64(0x431d67c4, -1676669620), new int64(0x4cc5d4be, -885112138), new int64(0x597f299c, -60457430), new int64(0x5fcb6fab, 0x3ad6faec), new int64(0x6c44198c, 0x4a475817) - ); + ]; } for (i=0; i<80; i+=1) { @@ -12407,8 +12405,8 @@ module.exports = ohauth; // append padding to the source string. The format is described in the FIPS. x[len >> 5] |= 0x80 << (24 - (len & 0x1f)); x[((len + 128 >> 10)<< 5) + 31] = len; - - for (i = 0; i>5] >>> (i % 32)) & 0xFF); } return output; @@ -12714,21 +12712,23 @@ module.exports = ohauth; * Calculate the RIPE-MD160 of an array of little-endian words, and a bit length. */ function binl(x, len) { - var T, j, i, + var T, j, i, l, h0 = 0x67452301, h1 = 0xefcdab89, h2 = 0x98badcfe, h3 = 0x10325476, h4 = 0xc3d2e1f0, - A1 = h0, B1 = h1, C1 = h2, D1 = h3, E1 = h4, - A2 = h0, B2 = h1, C2 = h2, D2 = h3, E2 = h4; + A1, B1, C1, D1, E1, + A2, B2, C2, D2, E2; /* append padding */ x[len >> 5] |= 0x80 << (len % 32); x[(((len + 64) >>> 9) << 4) + 14] = len; - - for (i = 0; i < x.length; i += 16) { - for (j = 0; j <= 79; ++j) { + l = x.length; + + for (i = 0; i < l; i+=16) { + A1 = A2 = h0; B1 = B2 = h1; C1 = C2 = h2; D1 = D2 = h3; E1 = E2 = h4; + for (j = 0; j <= 79; j+=1) { T = safe_add(A1, rmd160_f(j, B1, C1, D1)); T = safe_add(T, x[i + rmd160_r1[j]]); T = safe_add(T, rmd160_K1(j)); @@ -12781,7 +12781,7 @@ module.exports = ohauth; } }; - // expose Hashes Object + // exposes Hashes (function( window, undefined ) { var freeExports = false; if (typeof exports === 'object' ) { @@ -14796,16 +14796,18 @@ window.iD = function () { mode, container, ui = iD.ui(context), - map = iD.Map(context); - - // the connection requires .storage() to be available on calling. - var connection = iD.Connection(context) - .keys(iD.data.keys); + map = iD.Map(context), + connection = iD.Connection(context, iD.data.keys[0]); connection.on('load.context', function loadContext(err, result) { history.merge(result); }); + context.preauth = function(options) { + connection.switch(options); + return context; + }; + /* Straight accessors. Avoid using these if you can. */ context.ui = function() { return ui; }; context.connection = function() { return connection; }; @@ -14974,21 +14976,19 @@ iD.detect = function() { return browser; }; -iD.Connection = function(context) { +iD.Connection = function(context, options) { var event = d3.dispatch('auth', 'loading', 'load', 'loaded'), - url = 'http://www.openstreetmap.org', + url = options.url || 'http://www.openstreetmap.org', connection = {}, user = {}, - keys, inflight = {}, loadedTiles = {}, loadingModal, - oauth = osmAuth({ - url: url, + oauth = osmAuth(_.extend({ loading: authLoading, done: authDone - }), + }, options)), ndStr = 'nd', tagStr = 'tag', memberStr = 'member', @@ -15001,6 +15001,14 @@ iD.Connection = function(context) { return url + '/browse/changeset/' + changesetId; }; + connection.entityURL = function(entity) { + return url + '/browse/' + entity.type + '/' + entity.osmId(); + }; + + connection.userUrl = function(username) { + return url + "/user/" + username; + }; + connection.loadFromURL = function(url, callback) { function done(dom) { return callback(null, parse(dom)); @@ -15219,12 +15227,13 @@ iD.Connection = function(context) { }; connection.status = function(callback) { - function done(err, capabilities) { - if (err) return callback(err); + function done(capabilities) { var apiStatus = capabilities.getElementsByTagName('status'); callback(undefined, apiStatus[0].getAttribute('api')); } - oauth.xhr({ method: 'GET', path: '/api/capabilities' }, done); + d3.xml(url + '/api/capabilities').get() + .on('load', done) + .on('error', callback); }; function abortRequest(i) { i.abort(); } @@ -15287,14 +15296,12 @@ iD.Connection = function(context) { }); }; - connection.userUrl = function(username) { - return url + "/user/" + username; - }; - - connection.url = function(_) { - if (!arguments.length) return url; - url = _; - oauth.url(_); + connection.switch = function(options) { + url = options.url; + oauth.options(_.extend({ + loading: authLoading, + done: authDone + }, options)); event.auth(); connection.flush(); return connection; @@ -15330,13 +15337,6 @@ iD.Connection = function(context) { return connection; }; - connection.keys = function(_) { - if (!arguments.length) return keys; - keys = _; - oauth.keys(keys); - return connection; - }; - connection.authenticate = function(callback) { function done(err, res) { event.auth(); @@ -17144,7 +17144,7 @@ iD.behavior.DrawWay = function(context, wayId, index, mode, baseGraph) { return function(graph) { if (isArea) { return graph - .replace(way.removeNode(end.id).addNode(newNode.id, index)) + .replace(way.addNode(newNode.id, index)) .remove(end); } else { @@ -22281,7 +22281,7 @@ iD.ui.Account = function(context) { // Link var userLink = selection.append('a') - .attr('href', connection.url() + '/user/' + details.display_name) + .attr('href', connection.userUrl(details.display_name)) .attr('target', '_blank'); // Add thumbnail or dont @@ -22522,15 +22522,22 @@ iD.ui.Background = function(context) { } function clickNudge(d) { - var interval = window.setInterval(nudge, 100); + + var timeout = window.setTimeout(function() { + interval = window.setInterval(nudge, 100); + }, 500), + interval; d3.select(this).on('mouseup', function() { window.clearInterval(interval); + window.clearTimeout(timeout); nudge(); }); function nudge() { context.background().nudge(d[1], context.map().zoom()); + var offset = context.background().offset(); + resetButton.classed('disabled', offset[0] === 0 && offset[1] === 0); context.redraw(); } } @@ -22684,9 +22691,10 @@ iD.ui.Background = function(context) { .on('mousedown', clickNudge); var resetButton = nudgeContainer.append('button') - .attr('class', 'reset') + .attr('class', 'reset disabled') .on('click', function () { context.background().offset([0, 0]); + resetButton.classed('disabled', true); context.redraw(); }); @@ -22809,7 +22817,8 @@ iD.ui.Commit = function(context) { userLink.append('a') .attr('class','user-info') .text(user.display_name) - .attr('href', connection.url() + '/user/' + user.display_name) + .attr('href', connection.userUrl(user.display_name)) + .attr('tabindex', -1) .attr('target', '_blank'); saveSection.append('p') @@ -24669,10 +24678,11 @@ iD.ui.SourceSwitch = function(context) { if (context.history().hasChanges() && !window.confirm(t('source_switch.lose_changes'))) return; - var live = d3.select(this).classed('live'); + var live = d3.select(this) + .classed('live'); context.connection() - .url(live ? 'http://api06.dev.openstreetmap.org' : 'http://www.openstreetmap.org'); + .switch(live ? iD.data.keys[1] : iD.data.keys[0]); context.map() .flush(); @@ -24837,7 +24847,8 @@ iD.ui.Success = function(connection) { .on('click.save', function() { event.cancel(); }) - .append('span').attr('class','label').text('Okay'); + .text('Okay') + .node().focus(); } return d3.rebind(success, event, 'on'); @@ -24920,7 +24931,7 @@ iD.ui.TagEditor = function(context, entity) { var osmLink = tageditorpreset.append('div') .attr('class', 'col12 inspector-inner') .append('a') - .attr('href', 'http://www.openstreetmap.org/browse/' + entity.type + '/' + entity.osmId()) + .attr('href', context.connection().entityURL(entity)) .attr('target', '_blank'); osmLink.append('span') @@ -26488,7 +26499,7 @@ iD.ui.intro.line = function(context, reveal) { timeout(function() { d3.select('#curtain').style('pointer-events', 'none'); var road = d3.select('.preset-grid .grid-entry').filter(function(d) { - return d.id === 'Road'; + return d.id === 'category-road'; }); reveal(road.node(), 'intro.lines.road'); road.one('click.intro', roadCategory); @@ -54198,18 +54209,20 @@ iD.data = { "yh:TYPE", "yh:WIDTH_RANK" ], - "keys": { - "http://api06.dev.openstreetmap.org": { - "oauth_consumer_key": "zwQZFivccHkLs3a8Rq5CoS412fE5aPCXDw9DZj7R", - "oauth_secret": "aMnOOCwExO2XYtRVWJ1bI9QOdqh1cay2UgpbhA6p", - "oauth_signature_method": "HMAC-SHA1" - }, - "http://www.openstreetmap.org": { + "keys": [ + { + "url": "http://www.openstreetmap.org", "oauth_consumer_key": "5A043yRSEugj4DJ5TljuapfnrflWDte8jTOcWLlT", "oauth_secret": "aB3jKq1TRsCOUrfOIZ6oQMEDmv2ptV76PA54NGLL", "oauth_signature_method": "HMAC-SHA1" + }, + { + "url": "http://api06.dev.openstreetmap.org", + "oauth_consumer_key": "zwQZFivccHkLs3a8Rq5CoS412fE5aPCXDw9DZj7R", + "oauth_secret": "aMnOOCwExO2XYtRVWJ1bI9QOdqh1cay2UgpbhA6p", + "oauth_signature_method": "HMAC-SHA1" } - }, + ], "imagery": [ { "name": "Bing aerial imagery",