WME Requests

Opens the Requests module with precompiled fields to submit an request

目前為 2016-09-14 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name WME Requests
  3. // @namespace https://greasyfork.org/ru/scripts/5085-wme-requests
  4. // @description Opens the Requests module with precompiled fields to submit an request
  5. // @include https://*.waze.com/editor/*
  6. // @include https://*.waze.com/*/editor/*
  7. // @include https://*.waze.com/map-editor/*
  8. // @include https://*.waze.com/beta_editor/*
  9. // @grant none
  10. // @author skirda
  11. // @version 2.6.0.1
  12. // ==/UserScript==
  13.  
  14. var wmer_Version = '2.6.0.1';
  15.  
  16. var CL=new Array(
  17. {
  18. c:'Russia',
  19. // Запрос на добавление населенного пункта
  20. f:'https://docs.google.com/forms/d/1ck0cCIV6vPy16YQZJvfmM0clOdAE2Z-kDsXn06ZwQ1s/viewform', // форма
  21. d:'https://docs.google.com/spreadsheets/d/1ddcW8EmNjojJp7EQ4AYPdfBqNWe28WqRaQ_RtkB8JAU', // таблица
  22. l:'https://script.google.com/macros/s/AKfycbzqA15-fy4g4StdRUmnuMj9z6rJ56gQPjCYpgCMni7h/exec', // Level5
  23. // WME Request (ответы)
  24. fr:'https://docs.google.com/forms/d/1QzvF3-lH8MuuEaSw0GA6LgLW62EiSHzQXBmG5-rQdIQ/viewform', // форма
  25. dr:'https://docs.google.com/spreadsheet/ccc?key=0AtcEFFDNcic4dEE2UFh5X0lDdlRZbno3YVFYUkg0Unc' // таблица
  26. },
  27. {
  28. c:'Belarus',
  29. // Запрос на добавление населенного пункта
  30. f:'https://docs.google.com/forms/d/1a7g7ONWOIHfxr8ZEXKxRXUkIxFF7xFb-2uX4LlydWXo/viewform',
  31. d:'https://docs.google.com/spreadsheets/d/1uuRY8ib5h_8xMfpzgXG2N78foMtftUNkPzJxP56mDXI',
  32. l:'https://script.google.com/macros/s/AKfycbz8_xLefn_06nLRsfwnupviEEStCXfttg777KryBMnD/exec',
  33. // WME Request (ответы)
  34. fr:'https://docs.google.com/forms/d/1a9wXzngDV_KGoYZC65X_-xAUfcyA7vgftaEBC9aHAMM/viewform',
  35. dr:'https://docs.google.com/spreadsheets/d/1gge9vlSuDrxkzH0ubiRGcx3VOawYA-Hub7EZzP94siI'
  36. },
  37. {
  38. c:'Uzbekistan',
  39. // Запрос на добавление населенного пункта
  40. f:'https://docs.google.com/forms/d/1wr3Bjkm1SKbThThdZ0ea80iriuoX9JJ4xRvutXcPGws/viewform', //
  41. d:'https://docs.google.com/spreadsheets/d/1sjniZzrQT5ygaZaMUzXKeoPFweASF7S7QPebNrHLo0Y', //
  42. l:'https://script.google.com/macros/s/AKfycbwKbjrauFor_XH4woPWrW9mkqvYCGzGXFoi6saWync/exec', //
  43. // WME Request (ответы)
  44. fr:'https://docs.google.com/forms/d/12oEAxVdrQZPUwHWK2AxKH0pIQwzG9UagRO0_ehRoaa4/viewform', //
  45. dr:'https://docs.google.com/spreadsheets/d/1wDYm7BKOpktL7MACucV-p94n-6M4HuyJy8HGntbumY4' //
  46. },
  47. {
  48. c:'Kazakhstan',
  49. // Запрос на добавление населенного пункта
  50. f:'https://docs.google.com/forms/d/1zdqseCwkJqxkmb7w9geTcKI-VKA5dNl-QKvuIw1rObg/viewform',//
  51. d:'https://docs.google.com/spreadsheets/d/1rmmxyNOh7zSYU0U9v0nN0yx8ZOW9Vr83YepmC3vt8ms', //
  52. l:'https://script.google.com/macros/s/AKfycbyvmneTt9c8HuwuDevm5tGB8vBvkL9lHu9Bl_JWrNo/exec', //
  53. // WME Request (ответы)
  54. fr:'https://docs.google.com/forms/d/1Ap4i0pSbBc7OKfggSao8XmirjdlxQWIBEVQ1Cq1WYyQ/viewform', //
  55. dr:'https://docs.google.com/spreadsheets/d/1Vl1sXOCRK4eTCihfHJPB5oI2nDu9g7cVIu0gpcxI0-g' //
  56. },
  57. {
  58. c:'Ukraine',
  59. // Запрос на добавление населенного пункта
  60. f:'https://docs.google.com/forms/d/13BWQv9Kvwzii8IDyCBfztLqBAoQnI-dDLL4exTv4DOw/viewform',//
  61. d:'https://docs.google.com/spreadsheets/d/1C6P-VmSTR2KTS9LMIFZFQyf7r57ki9Mzi7B-HNwjBbM', //
  62. l:'https://script.google.com/macros/s/AKfycby2OUnHmGkbTNeJDBcXu4zZ6eyNngh6XHpkcU_tsoVSmHn-NzY/exec', //
  63. // WME Request (ответы)
  64. fr:'https://docs.google.com/forms/d/1VLcIJAFKrLumCINck6bWKJAXvHiJPriZKam3k309--k/viewform', //
  65. dr:'https://docs.google.com/spreadsheets/d/1_R8f_0_j57gU7EYKYBCaiIWi-vKWsPgtM-xuEBNGfks' //
  66. }
  67. );
  68.  
  69. var wner_TTS_d="https://docs.google.com/spreadsheets/d/16rSWBWfRi5gXhywAlTGu6O3c3kH0B49ksp56hdh-xlI";
  70. var wner_TTS_f="https://docs.google.com/forms/d/e/1FAIpQLSfUdwm1Jlv5h_tauxcWZRDnFSOv2QR8vzi2XcjWPe-TKnxzMQ/viewform";
  71.  
  72. // через солько дней вернуть лок обратно
  73. var wmer_CountDays = 5;
  74. var wmer_UserCache = new Array();
  75. var wmer_LanguageRU = false;
  76. var wmer_Debug = false;
  77. var wmer_MousePos = '';
  78.  
  79. function wmer_bootstrap()
  80. {
  81. wmer_LanguageRU=I18n.locale === "ru"?true:false;
  82.  
  83. var WMELanguageRU=localStorage.getItem("WMELanguageRU");
  84. if (WMELanguageRU)
  85. wmer_LanguageRU=WMELanguageRU === "1"?true:false;
  86. // localStorage.setItem('WMELanguageRU', '1');
  87.  
  88. wmer_Debug=localStorage.getItem("wmer_Debug");
  89. if (wmer_Debug && (wmer_Debug === "true" || wmer_Debug === "1"))
  90. wmer_Debug=true;
  91. // localStorage.setItem('wmer_Debug', '1');
  92.  
  93. wmer_Init();
  94. }
  95.  
  96. /* helper function */
  97. function getElementsByClassName(classname, node) {
  98. if(!node)
  99. node = document.getElementsByTagName("body")[0];
  100. var a = [];
  101. var re = new RegExp('\\b' + classname + '\\b');
  102. var els = node.getElementsByTagName("*");
  103. for (var i=0,j=els.length; i<j; i++)
  104. if (re.test(els[i].className)) a.push(els[i]);
  105. return a;
  106. }
  107.  
  108.  
  109. function wmer_getUsername()
  110. {
  111. var thisUser = Waze.loginManager.user;
  112. if (thisUser === null)
  113. {
  114. alert(wmer_LanguageRU?'Невозможно получить имя текущего пользователя':'Nobody\'s logged in.');
  115. return "";
  116. }
  117. return Waze.loginManager.user.userName;
  118. }
  119.  
  120. function timeConverter(UNIX_timestamp)
  121. {
  122. var datetime = new Date();
  123. var mEpoch = parseInt(UNIX_timestamp);
  124. if (mEpoch<10000000000) mEpoch *= 1000;
  125. datetime.setTime(mEpoch)
  126. // !!! UTC !!!
  127. return datetime.getUTCFullYear()+"-"+('0' + (datetime.getUTCMonth() + 1)).slice(-2)+"-"+('0' + datetime.getUTCDate()).slice(-2)+"+"+('0' + datetime.getUTCHours()).slice(-2) + ':' + ('0' + datetime.getUTCMinutes()).slice(-2)
  128.  
  129. }
  130.  
  131. function wmer_getCCSD(segment){ // BUBBUB!!! need use "hasOwnProperty" or "in"
  132. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'start wmer_getCCSD');
  133.  
  134. var oID="";
  135. var streetName="";
  136. var cityName="";
  137. var countryName="";
  138. var countryID="";
  139. var description="";
  140. var typeName= "";
  141. var cityID="";
  142. var userID="";
  143. var forumUserID="";
  144. var userName="";
  145. var updatedOn="";
  146. var poiaddress="";
  147.  
  148. try {
  149. typeName=segment.type;
  150. /*
  151. "segment"
  152. "venue"
  153. "node"
  154. "camera" typeName: "Speed camera"
  155. "bigJunction"
  156. */
  157. oID=segment.attributes.id;
  158. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': oID=' + oID);
  159.  
  160. if(segment.attributes.hasOwnProperty('updatedOn'))
  161. updatedOn=segment.attributes.updatedOn;
  162. else
  163. updatedOn=segment.attributes.createdOn;
  164.  
  165. if (segment.attributes.hasOwnProperty('primaryStreetID'))
  166. {
  167. //Waze.model.streets.get(Waze.selectionManager.selectedItems[0].model.attributes.primaryStreetID).cityID
  168. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'found street');
  169. var sID=segment.attributes.primaryStreetID;
  170. if (sID)
  171. {
  172. var streetsObj = Waze.model.streets.get(sID);
  173. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'typeof streetsObj='+(typeof streetsObj));
  174. if (typeof streetsObj !== "undefined")
  175. {
  176. cityID=streetsObj.cityID;
  177. streetName=streetsObj.name;
  178. }
  179. }
  180. }
  181. else if (typeName === "camera")
  182. {
  183. //Waze.selectionManager.selectedItems[0].model.model.cities.additionalInfo[0].id
  184. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'found camera');
  185. streetName=segment.typeName;
  186. description= "\n "+(wmer_LanguageRU?'Скорость':'Speed')+": "+segment.attributes.speed
  187. +"\n "+(wmer_LanguageRU?'Подтверждено':'Approved')+": "+segment.attributes.validated
  188. +"\n "+(wmer_LanguageRU?'Тип':'Type')+": "+I18n.translations[wmer_LanguageRU?"ru":window.I18n.currentLocale()].edit.camera.fields.type[segment.attributes.type];
  189. // +"\n "+(wmer_LanguageRU?'Азимут':'Azymuth')+": "+segment.attributes.azymuth
  190. //if(segment.attributes.hasOwnProperty('updatedOn'))
  191. cityID=segment.model.cities.additionalInfo[0].id;
  192. if (cityID == null)
  193. cityID="";
  194. }
  195. else if (typeName === "node")
  196. {
  197. //Waze.selectionManager.selectedItems[0].model.segments.topCityID
  198. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'found node');
  199. cityID=''+segment.model.segments.topCityID;
  200.  
  201. if (cityID == null)
  202. cityID="";
  203. description="\n count segment(s)="+segment.attributes.segIDs.length;
  204. }
  205. else if(typeName === "bigJunction")
  206. {
  207. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'found bigJunction');
  208. cityID=''+segment.model.segments.topCityID;
  209. if (cityID == null)
  210. cityID="";
  211. description="\n count segment(s)="+segment.attributes.segIDs.length;
  212. }
  213. else // "venue"
  214. {
  215. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'found POI ('+typeName+')');
  216. //Waze.model.streets.get(Waze.selectionManager.selectedItems[0].attributes.streetID).cityID
  217. var sID=segment.attributes.streetID;
  218. if (sID == null)
  219. cityID="";
  220. else
  221. cityID=Waze.model.streets.get(sID).cityID;
  222.  
  223. if (sID == null)
  224. cityID="";
  225.  
  226. if (typeof Waze.selectionManager.selectedItems[0].model.attributes.categories === "undefined")
  227. {
  228. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'categories=undefined');
  229. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'segment.attributes.description='+segment.attributes.description);
  230.  
  231. }
  232. else
  233. {
  234. var vcats=segment.attributes.categories;
  235. var arrvcats=[]
  236. for(var i=0; i < vcats.length; ++i)
  237. {
  238. //if(wmer_Debug) console.log("segment.attributes.categories["+i+"]='"+segment.attributes.categories[i]+"'")
  239. arrvcats.push(window.I18n.translations[wmer_LanguageRU?"ru":window.I18n.currentLocale()].venues.categories[vcats[i]])
  240. //if(wmer_Debug) console.log("segment.attributes.categories["+i+"]='"+segment.attributes.categories[i]+"'")
  241. }
  242. description='\n '+(wmer_LanguageRU?'Категории':'Categories')+': '+(arrvcats.length > 0?arrvcats.join(';')+'.':'')+'\n ' + segment.attributes.description;
  243. //if(wmer_Debug) console.log(description)
  244. arrvcats=[];
  245.  
  246.  
  247. if (segment.attributes.categories.indexOf("GAS_STATION") != -1) // Gas Station
  248. {
  249. typeName="gas_station"
  250. description="\n "+(wmer_LanguageRU?'Брэнд':'Brand')+": "+segment.attributes.brand
  251. + "\n "+(wmer_LanguageRU?'Адрес':'Address')+": " + segment.attributes.address
  252. + "\n "+(wmer_LanguageRU?'Описание':'Description')+": " + segment.attributes.description;
  253. }
  254. }
  255.  
  256. if(segment.attributes.hasOwnProperty('streetID'))
  257. poiaddress+=Waze.model.streets.get(segment.attributes.streetID).name
  258. if(segment.attributes.hasOwnProperty('houseNumber'))
  259. {
  260. if(poiaddress.length > 0)
  261. poiaddress+= " "
  262. poiaddress+=segment.attributes.houseNumber
  263. }
  264. streetName=segment.attributes.name;
  265. }
  266.  
  267. if (!(/*typeName === "camera" || */typeName === "node" || cityID === "")) // BUGBUG!!!
  268. {
  269. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': cityID=' + cityID);
  270. var cityObj=Waze.model.cities.get(cityID);
  271. if (typeof cityObj !== "undefined")
  272. {
  273. countryID=cityObj.getAttributes().countryID;
  274. cityName=cityObj.getAttributes().name;
  275. var countriesObj=Waze.model.countries.get(countryID);
  276. if(wmer_Debug) console.log(countriesObj);
  277. if (typeof countriesObj !== "undefined")
  278. countryName = countriesObj.name;
  279. }
  280. }
  281.  
  282. if (!(typeName === "node"))
  283. {
  284. userID=segment.attributes.updatedBy;
  285. if (userID == null)
  286. userID=segment.attributes.createdBy;
  287.  
  288. if (userID==-1 || userID == null)
  289. {
  290. userID=segment.attributes.createdBy;
  291. if (userID==-1)
  292. {
  293. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'Do not PM Admin!');
  294. }
  295. }
  296.  
  297. userName=Waze.model.users.get(userID).userName;
  298. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'userName='+userName);
  299. }
  300. else
  301. userID="-1";
  302.  
  303. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'userID=' +userID);
  304.  
  305. }
  306. catch (err) {
  307. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': error['+err.columnNumber+','+err.lineNumber+']: ' +err.name);
  308. }
  309.  
  310. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'return from wmer_getCCSD');
  311. return {
  312. objid : oID,
  313. type : typeName,
  314. street : streetName,
  315. city : cityName,
  316. cityID : cityID,
  317. country : countryName,
  318. description : description,
  319. username : userName,
  320. userID : userID,
  321. forumuserID : forumUserID,
  322. updatedOn : updatedOn,
  323. poiaddress : poiaddress
  324. };
  325. }
  326.  
  327.  
  328. function wmer_userRank(segment)
  329. {
  330. var usrRank = 0;
  331. /*
  332. if (segment.attributes.lockRank)
  333. {
  334. var updatedBy = Waze.model.users.get(segment.attributes.updatedBy);
  335. return updatedBy != null ? updatedBy.rank : 0;
  336. }
  337. return 0;
  338. */
  339. if (Waze.selectionManager.selectedItems[0].model.attributes.hasOwnProperty('lockRank'))
  340. return segment.attributes.lockRank;
  341. else
  342. return 0;
  343. }
  344.  
  345. //It returns the maximum lock level
  346. function wmer_GetLevel() {
  347. //attributes.rank dovrebbe essere il road rank
  348. var sel = Waze.selectionManager.selectedItems;
  349. var maxR = wmer_userRank(sel[0].model);
  350.  
  351. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'wmer_GetLevel() maxR='+maxR);
  352. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'wmer_GetLevel() sel.length='+sel.length);
  353.  
  354. for (i = 1; i < sel.length; i++)
  355. {
  356. if (maxR == 5)
  357. {
  358. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'wmer_GetLevel() return 6');
  359. return 6;
  360. }
  361. var usrRank = wmer_userRank(sel[i].model);
  362. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'wmer_GetLevel() usrRank='+usrRank);
  363. if (usrRank > maxR) {
  364. maxR = usrRank;
  365. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'wmer_GetLevel() '+maxR);
  366. }
  367. }
  368. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'wmer_GetLevel() return [maxR + 1] = '+(maxR + 1));
  369. return maxR + 1;
  370. }
  371.  
  372. // получить данные имени НП у OSM
  373. function WmeR_GetCityFromOSM(ll,zoom)
  374. {
  375. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'WmeR_GetCityFromOSM([lat='+ll.lat+',lon='+ll.lon+'],'+zoom+')');
  376. var cityName='';
  377. var country_code='';
  378. var WMERequestAddCounty=localStorage.getItem("WMERequestAddCounty");
  379. WMERequestAddCounty= (WMERequestAddCounty && (WMERequestAddCounty === "1" || WMERequestAddCounty === "true"))?true:false;
  380. zoom += 7;
  381. var url = 'https://nominatim.openstreetmap.org/reverse';
  382. var data = {
  383. "lat": ll.lat,
  384. "lon": ll.lon,
  385. "zoom": zoom,
  386. "format": "json",
  387. "addressdetails": 1,
  388. "countrycodes": "ru",
  389. "accept-language": "Ru_ru"
  390. };
  391.  
  392. $.ajax({
  393. dataType: "json",
  394. cache: false,
  395. url: url,
  396. async: false,
  397. data: data,
  398. error: function() {
  399. },
  400. success: function(json) {
  401. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'WmeR_GetCityFromOSM(): json='+json);
  402. if (json.display_name !== undefined) {
  403. var li = '';
  404. if(wmer_Debug) console.dir(json);
  405. // json.address.country_code
  406. // json.address.state
  407. // json.address.region
  408. // json.address.city_district
  409. // json.address.suburb
  410. if (json.address.country_code !== undefined) {
  411. country_code=json.address.country_code;
  412. }
  413.  
  414. if (json.address.city !== undefined) {
  415. li = json.address.city;
  416. }
  417. else if (json.address.town !== undefined) {
  418. li = json.address.town;
  419. }
  420. else if (json.address.village !== undefined) {
  421. li = json.address.village;
  422. }
  423. else if (json.address.hamlet !== undefined) {
  424. li = json.address.hamlet;
  425. }
  426.  
  427. if (WMERequestAddCounty && li.length > 0 && json.address.county !== undefined) {
  428. li += " (" + json.address.county.replace("район","р-н").replace("область","обл.").replace("городской округ","р-н");
  429. //if (json.address.state !== undefined) {li += " / " + json.address.state; }
  430. li += ")";
  431. }
  432.  
  433. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'WmeR_GetCityFromOSM(): li='+li);
  434.  
  435. //$('#topbar-container .topbar .location-info-region .alt-location-info').html(alispan);
  436. cityName=li;
  437. }
  438. }
  439. });
  440.  
  441. return {cityName:cityName,country_code:country_code};
  442. }
  443.  
  444.  
  445. function PtInPoly(x, y, components)
  446. {
  447. npol = components.length;
  448. jj = npol - 1;
  449. var c = 0;
  450. for (var ii = 0; ii < npol;ii++)
  451. {
  452. if ((((components[ii].y<=y) && (y<components[jj].y)) || ((components[jj].y<=y) && (y<components[ii].y))) &&
  453. (x > (components[jj].x - components[ii].x) * (y - components[ii].y) / (components[jj].y - components[ii].y) + components[ii].x))
  454. {
  455. c = !c;
  456. }
  457. jj = ii;
  458. }
  459. return c;
  460. }
  461.  
  462. function checkPosKG(ll)
  463. {
  464. var p=[{x:33.545723,y:46.0000621},{x:33.5925865,y:46.0695387},{x:33.5961914,y:46.0775176},{x:33.5941315,y:46.0858525},{x:33.5924149,y:46.0875788},{x:33.5927582,y:46.1139437},{x:33.6037445,y:46.1303633},{x:33.610611,y:46.1339321},{x:33.6373901,y:46.1405933},{x:33.6178207,y:46.2135757},{x:33.6160183,y:46.2131599},{x:33.61413,y:46.2123878},{x:33.6128426,y:46.212863},{x:33.6133575,y:46.2138132},{x:33.6139584,y:46.2144666},{x:33.6172199,y:46.2153574},{x:33.6143875,y:46.2264623},{x:33.6461449,y:46.2293718},{x:33.6508656,y:46.2264623},{x:33.6551571,y:46.2247403},{x:33.6583328,y:46.2227807},{x:33.6642551,y:46.2217118},{x:33.674469,y:46.2151199},{x:33.6811638,y:46.2092993},{x:33.6857128,y:46.2060323},{x:33.6888027,y:46.2044879},{x:33.696785,y:46.2034186},{x:33.7084579,y:46.1999731},{x:33.7359238,y:46.1859512},{x:33.738842,y:46.1851788},{x:33.7409878,y:46.1850005},{x:33.7502575,y:46.188031},{x:33.7567806,y:46.191299},{x:33.7744617,y:46.1988444},{x:33.7851048,y:46.2014583},{x:33.7966919,y:46.2030028},{x:33.8113689,y:46.2035968},{x:33.8264751,y:46.2034186},{x:33.8388348,y:46.2018147},{x:33.8487053,y:46.1994979},{x:33.8618374,y:46.1941509},{x:33.9044952,y:46.1658034},{x:33.9177132,y:46.1585507},{x:33.9377975,y:46.150762},{x:33.961916,y:46.14321},{x:33.9851761,y:46.1343485},{x:34.0131569,y:46.1185845},{x:34.0213966,y:46.1143602},{x:34.0280914,y:46.1117422},{x:34.0356445,y:46.1101951},{x:34.0439701,y:46.109124},{x:34.0525532,y:46.1090645},{x:34.0565872,y:46.1099571},{x:34.0653419,y:46.1148362},{x:34.0695477,y:46.1162047},{x:34.0741825,y:46.1173946},{x:34.0812206,y:46.1172161},{x:34.091177,y:46.1156097},{x:34.1224194,y:46.1054941},{x:34.1291142,y:46.1015663},{x:34.1351223,y:46.0971621},{x:34.1409588,y:46.0913886},{x:34.1450787,y:46.0861502},{x:34.1502285,y:46.082102},{x:34.15658,y:46.078887},{x:34.1721153,y:46.0728734},{x:34.1776943,y:46.0693601},{x:34.1830158,y:46.0670377},{x:34.1866207,y:46.0660849},{x:34.1976929,y:46.0651916},{x:34.2121124,y:46.0627499},{x:34.2249012,y:46.0583426},{x:34.2339134,y:46.0557219},{x:34.247303,y:46.0530415},{x:34.2535686,y:46.0529224},{x:34.2642975,y:46.0543519},{x:34.2909908,y:46.0592956},{x:34.306097,y:46.0612014},{x:34.3175125,y:46.0614992},{x:34.3246365,y:46.061261},{x:34.3295288,y:46.0604272},{x:34.3405151,y:46.0576279},{x:34.3625736,y:46.0482165},{x:34.3809414,y:46.0369564},{x:34.39785,y:46.0214626},{x:34.4082355,y:46.0037586},{x:34.4124413,y:45.9900445},{x:34.4163036,y:45.9852736},{x:34.4254017,y:45.9760885},{x:34.4411945,y:45.9627255},{x:34.4570732,y:45.9520448},{x:34.4660854,y:45.9473303},{x:34.4773293,y:45.9433913},{x:34.4841957,y:45.942317},{x:34.4909763,y:45.9421976},{x:34.4974136,y:45.9429138},{x:34.5029068,y:45.94363},{x:34.5100307,y:45.9470319},{x:34.5228195,y:45.9550285},{x:34.5481396,y:45.9793691},{x:34.5511436,y:45.9867049},{x:34.5532036,y:45.9893289},{x:34.5601559,y:45.9929665},{x:34.5669365,y:45.9948747},{x:34.5747471,y:45.9955902},{x:34.5835018,y:45.9957691},{x:34.5995522,y:45.9945169},{x:34.6073627,y:45.9929069},{x:34.6297646,y:45.9859297},{x:34.6582603,y:45.97412},{x:34.6691608,y:45.968095},{x:34.7247791,y:45.9287071},{x:34.7531891,y:45.9100179},{x:34.8019409,y:45.902433},{x:34.7999668,y:45.8046917},{x:34.8609924,y:45.7945192},{x:34.8807335,y:45.7888935},{x:34.8975563,y:45.7824294},{x:34.9585819,y:45.7593198},{x:35.053854,y:45.787517},{x:36.7630005,y:45.8000844},{x:36.6778564,y:45.395316},{x:36.6081619,y:45.321013},{x:36.5068817,y:45.2903466},{x:36.529541,y:44.1664447},{x:31.9921875,y:44.1703849},{x:32.0361328,y:45.7253564},{x:33.545723,y:46.0000621}];
  465. if (PtInPoly(ll.lon, ll.lat, p))
  466. {
  467. return true;
  468. }
  469.  
  470. return false;
  471. }
  472.  
  473. function click_WMERequest() {
  474. var RenamePref="";
  475.  
  476. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'click_WMERequest()::Action: '+this.id);
  477. if (typeof Waze.selectionManager === "undefined")
  478. {
  479. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'Waze.selectionManager not found');
  480. return;
  481. }
  482. if (Waze.selectionManager.selectedItems.length == 0)
  483. {
  484. alert(wmer_LanguageRU?'Нет выделенных объектов':'No selected segments.');
  485. return;
  486. }
  487. if (Waze.selectionManager.selectedItems.length < 2 && this.id === 'wmerBtn_join')
  488. {
  489. alert(wmer_LanguageRU?'Вы должны выделить 2 сегмента':'You must select 2 segments.');
  490. return;
  491. }
  492.  
  493. var username = wmer_getUsername();
  494. var sccObj = wmer_getCCSD(Waze.selectionManager.selectedItems[0].model);
  495. if(wmer_Debug) console.log("sccObj="+JSON.stringify(sccObj))
  496. if(sccObj.city && sccObj.city.length > 0)
  497. RenamePref="Rename: '" + sccObj.city + "' => '";
  498.  
  499. var lockLevel = wmer_GetLevel();
  500. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'lockLevel= '+lockLevel);
  501. if (lockLevel == 1 && this.id == 'wmerBtn_lock')
  502. {
  503. alert(wmer_LanguageRU?'Выбранные сегменты уже разблокированы':'Selected segments are already unlocked');
  504. return;
  505. }
  506.  
  507. var normalizedLevel=Waze.loginManager.user.normalizedLevel;
  508. //normalizedLevel=2;
  509. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'My level: '+normalizedLevel);
  510. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'Lock level: '+lockLevel);
  511.  
  512. if (lockLevel <= normalizedLevel && this.id == 'wmerBtn_lock') {
  513. alert(wmer_LanguageRU?'Выбранные сегменты имеют доступный вам уровень блокировки':'Selected segments have a lock level that is less or equal to yours')
  514. return;
  515. }
  516.  
  517. lockLevel=normalizedLevel;
  518.  
  519. var description='type: ' + sccObj.type + '\r' +
  520. 'country: '+ sccObj.country + '\r' +
  521. 'city: ' + sccObj.city + '\r' +
  522. 'street/name: ' + sccObj.street + '\r' +
  523. 'description: ' + sccObj.description;
  524.  
  525. description = description.replace(/%/g, '%25');
  526. description = description.replace(/\+/g, '%2B'); // +
  527. description = description.replace(' ', '%20'); // ' '
  528. description = description.replace(/\r\n/g, '\r'); // '\r\n'
  529. description = description.replace(/\r/g, '%0A'); // '\n'
  530. description = description.replace(/&/g, '%26');
  531. description = description.replace(/</g, '%3C');
  532. description = description.replace(/\>/g, '%3E');
  533. description = description.replace(/\?/g, '%3F');
  534. description = description.replace(/=/g, '%3D');
  535.  
  536. var permalink = wmer_generate_permalink();
  537.  
  538. // попытка центрировать...
  539. var urPos=new OpenLayers.LonLat(
  540. Waze.selectionManager.selectedItems[0].geometry.bounds.left+(Waze.selectionManager.selectedItems[0].geometry.bounds.right-Waze.selectionManager.selectedItems[0].geometry.bounds.left)/2,
  541. Waze.selectionManager.selectedItems[0].geometry.bounds.top-(Waze.selectionManager.selectedItems[0].geometry.bounds.top-Waze.selectionManager.selectedItems[0].geometry.bounds.bottom)/2
  542. );
  543. urPos.transform(new OpenLayers.Projection("EPSG:900913"),new OpenLayers.Projection("EPSG:4326"));
  544. var venues0='';
  545. if(getQueryString(permalink, 'venues') != -1)
  546. venues0="&venues=" + getQueryString(permalink, 'venues');
  547. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'venues0: '+venues0);
  548.  
  549. // https://www.waze.com/editor/?env=row&lon=36.11483&lat=53.96670&zoom=4&marker=yes
  550. var segments0='';
  551. if(getQueryString(permalink, 'segments') != -1)
  552. segments0="&segments=" + getQueryString(permalink, 'segments');
  553. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'segments0: '+segments0);
  554.  
  555.  
  556. var permalink5=permalink.split("&")[0] +
  557. "&zoom=" + parseInt(getQueryString(permalink, 'zoom')) +
  558. "&lon=" + urPos.lon +
  559. "&lat=" + urPos.lat +
  560. segments0 +
  561. venues0;
  562. var permalink50=permalink5;
  563.  
  564. function preparePermalink(s)
  565. {
  566. s = s.replace(/%/g, '%25'); //???
  567. s = s.replace(/&/g, '%26');
  568. s = s.replace(/\?/g, '%3F');
  569. s = s.replace(/=/g, '%3D');
  570. s = s.replace(/</g, '%3C');
  571. s = s.replace(/\>/g, '%3E');
  572. return s;
  573. }
  574.  
  575. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'permalink=' + permalink);
  576. permalink = preparePermalink(permalink);
  577. permalink5 = preparePermalink(permalink5);
  578.  
  579. //You can get entry numbers in google stylesheet: "Answers->Get precompiled URL"
  580. var curDate=new Date();
  581. curDate.setDate(curDate.getDate() + wmer_CountDays);
  582.  
  583. var action="";
  584. switch(this.id)
  585. {
  586. case 'wmerBtn_lock':
  587. action='lock';
  588. break;
  589. case 'wmerBtn_join':
  590. action='join';
  591. break;
  592. case 'wmerBtn_dir':
  593. action='direction';
  594. break;
  595. case 'wmerBtn_turn':
  596. action='turn';
  597. break;
  598. case 'wmerBtn_closures':
  599. action='closures';
  600. break;
  601.  
  602. }
  603.  
  604. function zero2(d){
  605. if((""+d).length == 1)
  606. d="0" + "" + d;
  607. return d;
  608. }
  609.  
  610. // для автозаполнения имени НП в форме
  611. var osmName=WmeR_GetCityFromOSM(urPos,parseInt(getQueryString(permalink50, 'zoom')));
  612.  
  613. var suffix="";
  614.  
  615. if(sccObj.country === '')
  616. {
  617. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': sccObj.country=""; work with osmName!!!');
  618. switch(osmName.country_code)
  619. {
  620. case 'ru': sccObj.country='Russia'; break;
  621. case 'by': sccObj.country='Belarus'; break;
  622. case 'uz': sccObj.country='Uzbekistan'; break;
  623. case 'kz': sccObj.country='Kazakhstan'; break;
  624. case 'ua': sccObj.country='Ukraine'; break;
  625. }
  626. }
  627.  
  628. if (checkPosKG(urPos) && sccObj.country==='Ukraine')
  629. {
  630. sccObj.country='Russia';
  631. suffix=" / Крым";
  632. }
  633.  
  634.  
  635. var WMERequestEmail=localStorage.getItem("WMERequestEmail");
  636. if (!WMERequestEmail)
  637. WMERequestEmail=""
  638. // localStorage.setItem('WMERequestEmail', 'МЫЛО');
  639.  
  640. if(this.id === 'wmerBtn_tts')
  641. {
  642. /*
  643. var wner_TTS_d="https://docs.google.com/spreadsheets/d/16rSWBWfRi5gXhywAlTGu6O3c3kH0B49ksp56hdh-xlI";
  644. var wner_TTS_f="https://docs.google.com/forms/d/e/1FAIpQLSfUdwm1Jlv5h_tauxcWZRDnFSOv2QR8vzi2XcjWPe-TKnxzMQ/viewform";
  645.  
  646. entry.587168531=nik
  647. entry.846152130=email
  648. entry.1316827755=country
  649. entry.1780120881=Какое действие предпринять
  650. entry.722429754=Название сегмента как на карте
  651. entry.543004173=Сейчас произноситься так
  652. entry.495130616=...должно звучать так
  653. entry.1226154757=permalink
  654. entry.1360508522=remark
  655. */
  656. description='';
  657.  
  658. // TTS: always zoom = 4
  659. var urlTTS=wner_TTS_f +
  660. '?entry.587168531=' + username +
  661. '&entry.846152130=' + WMERequestEmail +
  662. '&entry.1226154757=' + permalink5.replace(/zoom\%3D([0-9]+)\%26/,"zoom%3D4%26") +
  663. '&entry.1316827755=' + sccObj.country +
  664. //'&entry.1780120881=' + // Какое действие предпринять
  665. '&entry.722429754=' + sccObj.street + // Название сегмента как на карте
  666. '&entry.543004173=' + sccObj.street + // Сейчас произноситься так
  667. '&entry.495130616=' + sccObj.street + // ...должно звучать так
  668. '';
  669.  
  670. window.open(urlTTS, '_blank');
  671.  
  672. return;
  673. }
  674.  
  675.  
  676. var idCL=(sccObj.country=='Russia'?0:(sccObj.country=='Belarus'?1:(sccObj.country=='Uzbekistan'?2:(sccObj.country==='Kazakhstan'?3:(sccObj.country==='Ukraine'?4:-1)))));
  677. if(idCL == -1)
  678. {
  679. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': idCL = ' +idCL + ', sccObj.countryName='+sccObj.country);
  680. return;
  681. }
  682.  
  683. /*
  684. entry.1230839078 username
  685. entry.1797072526 e-mail
  686. entry.390417455 permalink
  687. entry.1508498769 Country
  688. entry.1856604039 Action
  689. entry.1939939237 Start Closures
  690. entry.1229617197 End Closures
  691. entry.1746680078 Причина перекрытия
  692. entry.1224334113 locklevel
  693. entry.571885954 EndUnlock
  694. entry.2082027069 Узел
  695. entry.259824358 Description
  696. */
  697. // !!!
  698. var url = CL[idCL].fr +
  699. '?entry.1230839078=' + username +
  700. '&entry.390417455=' + permalink5 +
  701. '&entry.1224334113=' + lockLevel +
  702. '&entry.1508498769=' + sccObj.country +
  703. '&entry.1856604039=' + action +
  704. '&entry.259824358=' + description + suffix +
  705. '&entry.1797072526=' + WMERequestEmail +
  706. '&entry.571885954='+curDate.getUTCFullYear()+'-'+zero2(curDate.getUTCMonth()+1)+'-'+zero2(curDate.getUTCDate()) +
  707. '';
  708.  
  709. // CL: always zoom = 4
  710. var urlCL = CL[idCL].f +
  711. '?entry.1109766685=' + username +
  712. '&entry.1785513403=' + WMERequestEmail +
  713. '&entry.1300384005=' + permalink5.replace(/zoom\%3D([0-9]+)\%26/,"zoom%3D4%26") +
  714. '&entry.1967623256=' + RenamePref+ osmName.cityName + suffix + (RenamePref.length>0?"'":"") +
  715. '';
  716.  
  717. var urlL5 = CL[idCL].l +
  718. '?p1=' + sccObj.username +
  719. '&p2=' + sccObj.city + suffix +
  720. '&p3=' + permalink5 +
  721. '&p4=' + timeConverter(sccObj.updatedOn) +
  722. '&p5=' + sccObj.cityID +
  723. '';
  724.  
  725. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'urlL5=' + urlL5);
  726.  
  727. if(this.id == 'wmerA_cl')
  728. {
  729. if(sccObj.city == null || sccObj.city == '')
  730. {
  731. alert(wmer_LanguageRU?"Внимание! Имя НП пустое. Сохранение не возможно.":"Attention! The name of the city is empty. Saving is not possible.")
  732. return;
  733. }
  734. }
  735.  
  736. window.open(this.id == 'wmerBtn_cl'?urlCL:(this.id == 'wmerA_cl'?urlL5:url), '_blank');
  737. }
  738.  
  739. function getQueryString(link, name)
  740. {
  741. if (link.indexOf( name + '=' ) <= 0)
  742. return -1;
  743. var pos = link.indexOf( name + '=' ) + name.length + 1;
  744. var len = link.substr(pos).indexOf('&');
  745. return (len == -1)?link.substr(pos):link.substr(pos,len);
  746. }
  747.  
  748. function wmer_generate_permalink() {
  749. var wcp=document.getElementsByClassName('WazeControlPermalink');
  750. for(var i=0; i < wcp.length; ++i)
  751. for (var j=0; j < wcp[i].getElementsByTagName('a').length;++j)
  752. {
  753. var href=wcp[i].getElementsByTagName('a')[j].href;
  754. if (href.indexOf(".waze.com/") > 0 && href.indexOf("/editor") > 0)
  755. {
  756. // kill "/ru/", kill "layers"
  757. href=href.replace("/ru/","/").replace(/layers=([0-9]+)\&/,"") + "&marker=yes";
  758. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'href=' + href);
  759. return href;
  760. }
  761. }
  762. return "";
  763. }
  764.  
  765. function CreateID()
  766. {
  767. return 'WME-Request-' + wmer_Version.replace(/\./g,"-");
  768. }
  769.  
  770.  
  771. function wmer_insertButton(z)
  772. {
  773. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'wmer_insertButton()');
  774. /*{
  775. var permalink=wmer_generate_permalink();
  776. var p = document.getElementsByClassName('WazeControlMousePosition')[0].lastChild.innerHTML.split(' ');
  777. permalink=permalink.replace(/#/g, "").replace(/&lat=([0-9\.]+)/g, '&lat='+p[1]).replace(/&lon=([0-9\.]+)/g, '&lon='+p[0]);
  778. }*/
  779.  
  780. // if(document.getElementById(CreateID()) != null)
  781. // document.getElementById(CreateID()).setAttribute('style', 'display:'+(Waze.selectionManager && Waze.selectionManager.selectedItems.length == 0?'none':'')+';');
  782.  
  783. if(Waze.selectionManager.selectedItems.length <= 0)
  784. return;
  785.  
  786. //
  787. if (Waze.selectionManager.selectedItems[0].model.type === "venue")
  788. {
  789. var area_poi=document.getElementById('WME.PlaceNames-Square');
  790. if(!area_poi)
  791. {
  792. var wcp=document.getElementsByClassName('additional-attributes list-unstyled side-panel-section');
  793. if (wcp)
  794. {
  795. var li=document.createElement("LI");
  796. li.setAttribute('id', 'WME.PlaceNames-Square');
  797. wcp[0].appendChild(li);
  798. area_poi=document.getElementById('WME.PlaceNames-Square');
  799. }
  800. }
  801.  
  802. if(area_poi)
  803. {
  804. var v_id=Waze.selectionManager.selectedItems[0].model.attributes.id;
  805. if (typeof Waze.model.venues.get(v_id).geometry.getGeodesicArea === "undefined")
  806. area_poi.innerHTML="";
  807. else
  808. {
  809. var square=Waze.model.venues.get(v_id).geometry.getGeodesicArea(Waze.map.getProjectionObject());
  810. area_poi.style=(square < 650)?"color: red;":"color: black;";
  811. area_poi.innerHTML="Площадь: " + square.toFixed(2) + " м&#178;"
  812. }
  813. }
  814.  
  815. }
  816. /*
  817. else if (Waze.selectionManager.selectedItems[0].model.type === "camera") // camera-edit-general
  818. {
  819. var cam=document.getElementsByClassName('additional-attributes list-unstyled side-panel-section');
  820. if (cam && cam.length > 0)
  821. {
  822. var camDate = Waze.selectionManager.selectedItems[0].model.attributes.updatedOn;
  823. if (!camDate)
  824. camDate = Waze.selectionManager.selectedItems[0].model.attributes.createdOn;
  825. if (camDate)
  826. {
  827. var dateNow = new Date();
  828. var age=Math.floor((dateNow.getTime() - camDate) / 86400000);
  829. var li=document.createElement("LI");
  830. li.setAttribute('id', 'WME.Age');
  831. cam[0].appendChild(li);
  832. camage=document.getElementById('WME.Age');
  833. camage.innerHTML="Age: " + age + " day(s)";
  834. }
  835.  
  836. }
  837.  
  838. }
  839. */
  840. //
  841.  
  842. var editPanelID='';
  843. var disabled=false;
  844. var disabledjoin=false;
  845. var disabledLock=false;
  846. var disabledPM=false;
  847.  
  848. if (document.getElementById('segment-edit-general') != null)
  849. {
  850. editPanelID='segment-edit-general';
  851. disabled=false;
  852. disabledjoin=false;
  853. disabledLock=false;
  854. }
  855. else if (document.getElementById('landmark-edit-general') != null)
  856. {
  857. editPanelID='landmark-edit-general';
  858. disabledLock=false;
  859. disabledjoin=true;
  860. disabled=true;
  861. }
  862. else if (document.getElementById('node-edit-general') != null)
  863. {
  864. editPanelID='node-edit-general';
  865. disabled=true;
  866. disabledjoin=true;
  867. disabledPM=true;
  868. disabledLock=true;
  869. }
  870. else if (document.getElementById('edit-panel') != null)
  871. {
  872. editPanelID='edit-panel';
  873. disabled=true;
  874. disabledjoin=true;
  875. disabledLock=true;
  876. }
  877.  
  878.  
  879. var sccObj = wmer_getCCSD(Waze.selectionManager.selectedItems[0].model);
  880. if(wmer_Debug) console.dir(sccObj)
  881.  
  882. var urPos=new OpenLayers.LonLat(
  883. Waze.selectionManager.selectedItems[0].geometry.bounds.left+(Waze.selectionManager.selectedItems[0].geometry.bounds.right-Waze.selectionManager.selectedItems[0].geometry.bounds.left)/2,
  884. Waze.selectionManager.selectedItems[0].geometry.bounds.top-(Waze.selectionManager.selectedItems[0].geometry.bounds.top-Waze.selectionManager.selectedItems[0].geometry.bounds.bottom)/2
  885. );
  886. urPos.transform(new OpenLayers.Projection("EPSG:900913"),new OpenLayers.Projection("EPSG:4326"));
  887.  
  888. if(sccObj.country === '')
  889. {
  890. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': sccObj.country=""; work with osmName!!!');
  891. // попытка центрировать...
  892. switch(WmeR_GetCityFromOSM(urPos,parseInt(getQueryString(wmer_generate_permalink(), 'zoom'))).country_code)
  893. {
  894. case 'ru': sccObj.country='Russia'; break;
  895. case 'by': sccObj.country='Belarus'; break;
  896. case 'uz': sccObj.country='Uzbekistan'; break;
  897. case 'kz': sccObj.country='Kazakhstan'; break;
  898. case 'ua': sccObj.country='Ukraine'; break;
  899. }
  900. }
  901. if (checkPosKG(urPos) && sccObj.country==='Ukraine')
  902. {
  903. sccObj.country='Russia';
  904. }
  905.  
  906. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': sccObj.cityID=' + sccObj.cityID + ', sccObj.country='+sccObj.country);
  907. var idCL=(sccObj.country=='Russia'?0:(sccObj.country=='Belarus'?1:(sccObj.country=='Uzbekistan'?2:(sccObj.country=='Kazakhstan'?3:(sccObj.country==='Ukraine'?4:-1)))));
  908. if(idCL == -1)
  909. {
  910. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': idCL = ' +idCL + ', sccObj.country='+sccObj.country);
  911. idCL=0;
  912. }
  913.  
  914. if(!document.getElementById(CreateID()))
  915. {
  916. // add new edit tab to left of the map
  917. var srsCtrl = document.createElement('div');
  918. srsCtrl.id = CreateID();
  919.  
  920. // inject new tab
  921. var userTabs = document.getElementById('edit-panel');
  922. var navTabs = getElementsByClassName('nav-tabs', userTabs)[0];
  923. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': typeof navTabs=' + (typeof navTabs));
  924. if (typeof navTabs !== "undefined")
  925. {
  926. var tabContent = getElementsByClassName('tab-content', userTabs)[0];
  927.  
  928. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': typeof tabContent=' + (typeof tabContent));
  929. if (typeof tabContent !== "undefined")
  930. {
  931. newtab = document.createElement('li');
  932. newtab.innerHTML = '<a href="#' + CreateID() + '" id="pwmerequest" data-toggle="tab">'+(wmer_LanguageRU?'Запросы':'Requests')+'</a>';
  933. navTabs.appendChild(newtab);
  934.  
  935. var padding="padding:5px 9px"
  936. srsCtrl.innerHTML = /*'<hr>'+*/
  937. '<div class="form-group">'+
  938. '<label class="control-label">' + (wmer_LanguageRU?'Запросы':'Requests') +' ' + wmer_Version + '</label>' +
  939. '<div class="controls-container">' +
  940. '<label><a href="' + CL[idCL].dr + '" id="wmerA_dr" target="_gdocRequest" title="' + sccObj.country + '">' + (wmer_LanguageRU?'Таблица':'Table') +'</a></label> | '+
  941. '<label><a href="https://www.waze.com/forum/viewtopic.php?p=662218#p662218" title="City Lock ' + wmer_Version + '" target="_blank">' + (wmer_LanguageRU?'О проекте':'About') +'</a></label></br>'+
  942. '<button id="wmerBtn_lock" class="btn btn-default" style="font-size:9px;'+padding+'" title="'+
  943. (wmer_LanguageRU?'Отправить запрос на изменение уровня блокировки объектов':'Send a request to lock/unlock segment(s)')+
  944. '"><i class="fa fa-unlock"></i>&nbsp;Lock</button>&nbsp;' +
  945. '<button id="wmerBtn_join" class="btn btn-default" style="font-size:9px;'+padding+'" title="'+
  946. (wmer_LanguageRU?'Отправить запрос на присоединение сегментов':'Send a request to join several segments')+
  947. '"><i class="fa fa-cogs"></i>&nbsp;Join</button>&nbsp;' +
  948. '<button id="wmerBtn_dir" class="btn btn-default" style="font-size:9px;'+padding+'" title="'+
  949. (wmer_LanguageRU?'Отправить запрос на изменение направления движения сегментов':'Send a request to change the direction of segment(s)')+
  950. '"><i class="fa fa-random"></i>&nbsp;Dir</button>&nbsp;' +
  951. '<button id="wmerBtn_turn" class="btn btn-default" style="font-size:9px;'+padding+'" title="'+
  952. (wmer_LanguageRU?'Отправить запрос на изменение разрешения поворотов':'Send a request to change the turn restriction.')+
  953. '"><i class="fa fa-arrows-alt"></i>&nbsp;Turn</button>&nbsp;' +
  954. '<button id="wmerBtn_closures" class="btn btn-default" style="font-size:9px;'+padding+'" title="'+
  955. (wmer_LanguageRU?'Отправить запрос на изменение перекрытие сегментов':'Send a request to change the Real Time Closures.')+
  956. '"><i class="fa fa-calendar"></i>&nbsp;Closures</button>' +
  957. '</div></div>' +
  958.  
  959.  
  960. '<div class="form-group">'+
  961. '<label class="control-label">' + (wmer_LanguageRU?'CityLock':'CityLock') +'</label>' +
  962. '<div class="controls-container">' +
  963. '<label><a href="' + CL[idCL].d + '" id="wmerA_d" target="_gdocRequest" title="' + sccObj.country + '">' + (wmer_LanguageRU?'Таблица':'Table') +'</a></label> | '+
  964. '<label><a href="https://www.waze.com/forum/viewtopic.php?f=787&t=105793" title="City Lock ' + wmer_Version + '" target="_blank">' + (wmer_LanguageRU?'О проекте':'About') +'</a></label></br>'+
  965. '<button id="wmerBtn_cl" class="btn btn-default" style="font-size:9px;'+padding+'" title="'+
  966. (wmer_LanguageRU?'Отправить запрос на изменение наименования населенного пункта':'Send a request to CityLock')+
  967. '"><i class="fa fa-home"></i>&nbsp;City</button>&nbsp;<span id="wmerCitySave0"></span></br>' +
  968. '<label><span id="wmerCityID"></span></label>'+
  969. '<div class="controls-container">' +
  970. '<input name="wmerChk_county" value="" id="wmerChk_county" type="checkbox"><label for="wmerChk_county" title="'+(wmer_LanguageRU?'Добавлять РАЙОН в название НП':'Adding DISTRICT in the name of the locality')+'">&nbsp;'+(wmer_LanguageRU?'Добавлять район':'Add District')+'</label><br>' +
  971. '</div>' +
  972. //'</br><label><span id="wmerLatLon"></span></label>'+
  973. '</div></div>' +
  974.  
  975. '<div class="form-group">'+
  976. '<label class="control-label">' + (wmer_LanguageRU?'TTS Marussia':'TTS Marussia') +'</label>' +
  977. '<div class="controls-container">' +
  978. '<label><a href="' + wner_TTS_d + '" id="wmerTTS_d" target="_gdocRequest" title="TTS Marussia">' + (wmer_LanguageRU?'Таблица':'Table') +'</a></label> | '+
  979. '<label><a href="https://www.waze.com/forum/viewtopic.php?f=785&t=148400" title="Маруся - новый TTS-голос" target="_blank">' + (wmer_LanguageRU?'О проекте':'About') +'</a></label></br>'+
  980. '<button id="wmerBtn_tts" class="btn btn-default" style="font-size:9px;'+padding+'" title="'+
  981. (wmer_LanguageRU?'Отправить запрос по проблеме произношения или сокращения в Waze TTS Marussia':'Отправить запрос по проблеме произношения или сокращения в Waze TTS Marussia')+
  982. '"><i class="fa fa-volume-up"></i>&nbsp;TTS</button></br>' +
  983. '</div></div>' +
  984.  
  985.  
  986.  
  987. '<div class="form-group">'+
  988. '<label class="control-label">' + (wmer_LanguageRU?'Прочее':'Other') +'</label>' +
  989. '<div class="controls-container">' +
  990. '<button id="wmerBtn_pm" class="btn btn-default" style="font-size:9px;'+padding+'" title="'+
  991. (wmer_LanguageRU?'Отправить приватное сообщение в форум авторам выделенных объектов':'Send (in forum) a Private Message to the author of the segment')+
  992. '"><li class="fa fa-envelope"></li>&nbsp;PM</button>'+
  993. '</div></div>' +
  994.  
  995. '<div class="form-group">' +
  996. '<label class="control-label">' + (wmer_LanguageRU?'Настройки':'Config') +'</label>' +
  997. '<div class="controls-container">' +
  998. '<input name="wmerEdt_lang" value="" id="wmerEdt_lang" type="checkbox"><label for="wmerEdt_lang" title="Принудительно использовать русскоязычный интерфейс для WME Request">Рускоязычный интерфейс</label>' +
  999. '<label>E-mail:' +
  1000. '<input title="' + (wmer_LanguageRU?'Ваш e-mail адрес':'Your e-mail address') +'" type="text" class="form-control" autocomplete="off" id="wmerEdt_email" name="wmerEdt_email" value="" size="15"/></label><br>' +
  1001. '<input name="wmerChk_debug" value="" id="wmerChk_debug" type="checkbox"><label for="wmerChk_debug" title="Включить логирование">&nbsp;Debug script</label><br>' +
  1002. '</div></div>' +
  1003. '';
  1004.  
  1005. //srsCtrl.id = "sidepanel-wmerequest";
  1006. srsCtrl.className = "tab-pane";
  1007. tabContent.appendChild(srsCtrl);
  1008. }
  1009. else
  1010. srsCtrl.id='';
  1011. }
  1012. else
  1013. srsCtrl.id='';
  1014. //http://www.earthtools.org/sun/51.65500265464235/39.18297673378902/22/1/99/0
  1015. //document.getElementById(editPanelID).appendChild(srsCtrl);
  1016.  
  1017. if(srsCtrl.id != '')
  1018. {
  1019. document.getElementById('wmerBtn_lock').onclick = click_WMERequest;
  1020. document.getElementById('wmerBtn_dir').onclick = click_WMERequest;
  1021. document.getElementById('wmerBtn_turn').onclick = click_WMERequest;
  1022. document.getElementById('wmerBtn_closures').onclick = click_WMERequest;
  1023. document.getElementById('wmerBtn_join').onclick = click_WMERequest;
  1024. document.getElementById('wmerBtn_pm').onclick = click_submitPMForm;
  1025. document.getElementById('wmerBtn_cl').onclick = click_WMERequest;
  1026. document.getElementById('wmerBtn_tts').onclick = click_WMERequest;
  1027. }
  1028.  
  1029. //var permalink=wmer_generate_permalink();
  1030. //var p = document.getElementsByClassName('WazeControlMousePosition')[0].innerHTML.replace(' ', '').split(',');
  1031. //var p = document.getElementsByClassName('WazeControlMousePosition')[0].lastChild.innerHTML.split(' ');
  1032. //permalink=permalink.replace(/#/g, "").replace(/&lat=([0-9\.]+)/g, '&lat='+p[1]).replace(/&lon=([0-9\.]+)/g, '&lon='+p[0]);
  1033. /*
  1034. if (typeof Waze.selectionManager.selectedItems[0].geometry.x !== "undefined")
  1035. {
  1036. // корректировка пермалинка для камеры, жанкшина и Place (point)
  1037. var urPos=new OpenLayers.LonLat(Waze.selectionManager.selectedItems[0].geometry.x,Waze.selectionManager.selectedItems[0].geometry.y);
  1038. urPos.transform(new OpenLayers.Projection("EPSG:900913"),new OpenLayers.Projection("EPSG:4326")); // {lon, lat}
  1039. permalink=permalink.replace(/#/g, "").replace(/&lat=([0-9\.]+)/g, '&lat='+urPos.lat).replace(/&lon=([0-9\.]+)/g, '&lon='+urPos.lon);
  1040. }
  1041. */
  1042. //document.getElementById('wmerCityID').innerHTML='<small><a href="'+permalink+'">cityID: '+sccObj.cityID+'</a></small>';
  1043. //document.getElementById('wmerCityID').innerHTML='<small>cityID: '+sccObj.cityID+'</small>';
  1044. /*
  1045. if(Waze.loginManager.user.rank >= 4)
  1046. {
  1047. document.getElementById('wmerCityID').innerHTML+='&nbsp;(<small><a style="cursor: pointer" title="Save the name of the new city in the Google Table" id="wmerA_cl">save</a></small>)';
  1048. document.getElementById('wmerA_cl').onclick = click_WMERequest;
  1049. }
  1050. */
  1051.  
  1052. //document.getElementById('wmerLatLon').innerHTML='<small>'+p[0]+','+p[1]+'</a></small>';
  1053.  
  1054. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'initialised');
  1055. }
  1056.  
  1057. if(document.getElementById(CreateID()) != null)
  1058. {
  1059.  
  1060. // ********************
  1061. if(document.getElementById('wmerA_dr'))
  1062. {
  1063. document.getElementById('wmerA_dr').href=CL[idCL].dr;
  1064. document.getElementById('wmerA_dr').title=sccObj.country;
  1065. }
  1066. if(document.getElementById('wmerA_d'))
  1067. {
  1068. document.getElementById('wmerA_d').href=CL[idCL].d;
  1069. document.getElementById('wmerA_d').title=sccObj.country;
  1070. }
  1071.  
  1072. // ********************
  1073. if(document.getElementById('wmerCityID'))
  1074. document.getElementById('wmerCityID').innerHTML='<small>cityID: '+sccObj.cityID+'</small>';
  1075.  
  1076. // ********************
  1077. // config e-mail
  1078. if(document.getElementById('wmerEdt_email'))
  1079. {
  1080. var WMERequestEmail=localStorage.getItem("WMERequestEmail");
  1081. if (!WMERequestEmail)
  1082. WMERequestEmail=""
  1083. document.getElementById('wmerEdt_email').value=WMERequestEmail;
  1084. document.getElementById('wmerEdt_email').onchange=function(){localStorage.setItem('WMERequestEmail', this.value);}
  1085. }
  1086.  
  1087. // ********************
  1088. // config language
  1089. if (document.getElementById('wmerEdt_lang'))
  1090. {
  1091. var WMELanguageRU=localStorage.getItem("WMELanguageRU");
  1092. if (WMELanguageRU)
  1093. wmer_LanguageRU=WMELanguageRU === "1"?true:false;
  1094. document.getElementById('wmerEdt_lang').checked=wmer_LanguageRU;
  1095. document.getElementById('wmerEdt_lang').onchange=function(){localStorage.setItem('WMELanguageRU', this.checked?"1":"0");}
  1096. }
  1097.  
  1098. // ********************
  1099. // config debug
  1100. document.getElementById('wmerChk_debug').checked=wmer_Debug;
  1101. document.getElementById('wmerChk_debug').onchange=function(){localStorage.setItem('wmer_Debug', this.checked?"1":"0");}
  1102.  
  1103. // ********************
  1104. // config debug AddCounty
  1105. var wmer_AddCounty = localStorage.getItem('WMERequestAddCounty')
  1106. if (!wmer_AddCounty) // start value
  1107. {
  1108. if (idCL == 1) // BY ==> false, other ==> true
  1109. wmer_AddCounty=false;
  1110. else
  1111. wmer_AddCounty=true;
  1112. }
  1113. else
  1114. wmer_AddCounty=(wmer_AddCounty === "true" || wmer_AddCounty === "1")?true:false;
  1115. document.getElementById('wmerChk_county').checked=wmer_AddCounty;
  1116. document.getElementById('wmerChk_county').onchange=function(){localStorage.setItem('WMERequestAddCounty', this.checked?"1":"0");}
  1117.  
  1118.  
  1119. // ********************
  1120. if(Waze.loginManager.user.rank >= 4 || (sccObj.country=='Belarus' && Waze.loginManager.user.rank >= 3)) // ??? Uzbekistan ???
  1121. {
  1122. document.getElementById('wmerCitySave0').innerHTML=
  1123. '<button id="wmerA_cl" class="btn btn-default" style="font-size:9px;'+padding+'" title="'+
  1124. (wmer_LanguageRU?'Сохранить имя нового НП в Google-таблице':'Save the name of the new city in the Google Table')+
  1125. '"><i class="fa fa-floppy-o"></i>&nbsp;Save</button>';
  1126.  
  1127. //document.getElementById('wmerCityID').innerHTML+='&nbsp;(<small><a style="cursor: pointer" title="Save the name of the new city in the Google Table" id="wmerA_cl">save</a></small>)';
  1128. document.getElementById('wmerA_cl').onclick = click_WMERequest;
  1129. }
  1130. }
  1131.  
  1132. if(document.getElementById(CreateID()) != null)
  1133. {
  1134. document.getElementById('wmerBtn_lock').disabled=disabledLock;
  1135. document.getElementById('wmerBtn_dir').disabled=disabled;
  1136. document.getElementById('wmerBtn_turn').disabled=disabled;
  1137. document.getElementById('wmerBtn_closures').disabled=disabled;
  1138. document.getElementById('wmerBtn_join').disabled=disabled;
  1139. document.getElementById('wmerBtn_pm').disabled=disabledPM;
  1140. document.getElementById('wmerBtn_cl').disabled=disabled;
  1141. //document.getElementById('wmerBtn_tts').disabled=disabled;
  1142. if(document.getElementById('wmerA_cl'))
  1143. document.getElementById('wmerA_cl').disabled=disabled;
  1144. }
  1145. }
  1146.  
  1147.  
  1148. // <WME Fancy permalink> - http://userscripts.org/users/548866
  1149. function getId(node) {
  1150. return document.getElementById(node);
  1151. }
  1152.  
  1153. function getForumUserIdFromID(wmeUserID)
  1154. {
  1155. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'call getForumUserIdFromID(' + wmeUserID + ')');
  1156. var userName=Waze.model.users.get(wmeUserID);
  1157. if(wmer_Debug) console.dir(userName);
  1158. return (getForumUserIdFromName(userName.userName));
  1159. }
  1160.  
  1161. function getForumUserIdFromName(userName)
  1162. {
  1163. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'call getForumUserIdFromName(' + userName + ')');
  1164. var forumID=-1;
  1165. var forumIDs=new Array();
  1166.  
  1167. if (userName.indexOf('/')!=-1)
  1168. {
  1169. var userNames=userName.split('/');
  1170. for (var i=0; i<userNames.length; i++)
  1171. {
  1172. forumID=getForumUserIdFromName(userNames[i]);
  1173. forumIDs[i]=forumID[0];
  1174. }
  1175. return forumIDs;
  1176. }
  1177.  
  1178. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'looking for ' + userName + ' in the forum.');
  1179.  
  1180. var xhr3_object;
  1181.  
  1182. if(window.XMLHttpRequest) // Firefox & Chrome
  1183. xhr3_object = new XMLHttpRequest();
  1184. else if(window.ActiveXObject) // Internet Explorer
  1185. xhr3_object = new ActiveXObject("Microsoft.XMLHTTP");
  1186.  
  1187. xhr3_object.open("GET", "https://www.waze.com/forum/memberlist.php?username=" + userName, false);
  1188.  
  1189. xhr3_object.onreadystatechange = function() {
  1190. if(xhr3_object.readyState == 4)
  1191. {
  1192. var test = xhr3_object.responseText.match(/u=([0-9]+)"/g);
  1193. if (test==null)
  1194. {
  1195. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'Forum return null');
  1196. return(-1); // no match
  1197. }
  1198. if (test.length>1)
  1199. {
  1200. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'Forum return multiple match:');
  1201. if(wmer_Debug) console.dir(test);
  1202. return(-2); // multiple match
  1203. }
  1204. forumID=test[0].substring(2, test[0].length-1);
  1205. }
  1206. };
  1207.  
  1208. if(wmer_Debug) console.dir(xhr3_object);
  1209.  
  1210. try {
  1211. xhr3_object.send(null);
  1212. }
  1213. catch (err) {
  1214. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'XMLHttpRequest error: ' +err.name);
  1215. if(wmer_Debug) console.dir(err);
  1216. return(-3);
  1217. }
  1218. forumIDs[0]=forumID;
  1219. return (forumIDs);
  1220. }
  1221.  
  1222. function click_submitPMForm()
  1223. {
  1224. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'click_submitPMForm() start');
  1225. if (typeof Waze.selectionManager === "undefined")
  1226. {
  1227. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'Waze.selectionManager not found');
  1228. return;
  1229. }
  1230.  
  1231. if (Waze.selectionManager.selectedItems.length == 0)
  1232. {
  1233. alert(wmer_LanguageRU?'Сначала необходимо выделить сегмент':'Please, select one segment before');
  1234. return false;
  1235. }
  1236.  
  1237. //-------------
  1238. var sccObjs=new Array();
  1239. for (var i=0; i < Waze.selectionManager.selectedItems.length; ++i)
  1240. {
  1241. var sccObj = wmer_getCCSD(Waze.selectionManager.selectedItems[i].model);
  1242. if (sccObj.userID==-1)
  1243. {
  1244. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'PM request - Do not PM Admin!');
  1245. alert("Can't PM admin!");
  1246. return false;
  1247. }
  1248.  
  1249. var j;
  1250. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'sccObj.userID='+sccObj.userID);
  1251. for (j=0; j < wmer_UserCache.length; j+=2)
  1252. {
  1253. if (wmer_UserCache[j] === sccObj.userID)
  1254. {
  1255. sccObj.forumuserID=wmer_UserCache[j+1];
  1256. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'found ['+j+']'+wmer_UserCache[j+1]);
  1257. break;
  1258. }
  1259. }
  1260.  
  1261. if (sccObj.forumuserID == "")
  1262. {
  1263. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'not found '+sccObj.userID);
  1264. sccObj.forumuserID=getForumUserIdFromID(sccObj.userID);
  1265. wmer_UserCache.push(sccObj.userID,sccObj.forumuserID);
  1266. }
  1267.  
  1268. sccObjs.push(sccObj);
  1269. }
  1270.  
  1271. var forumIDs=new Array();
  1272. for (var i=0; i < sccObjs.length; ++i)
  1273. forumIDs[i]=sccObjs[i].forumuserID;
  1274. //-------------
  1275.  
  1276. if (forumIDs.length==1 && forumIDs[0]==-1)
  1277. {
  1278. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'PM request - User never logged to the forum...');
  1279. alert(wmer_LanguageRU?'Автор сегмента не найден на форуме':'Sorry: unable to find the user in the forum');
  1280. return false;
  1281. }
  1282. if (forumIDs.length==1 && forumIDs[0]==-2)
  1283. {
  1284. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'PM request - Several users match name. Should never happen :s');
  1285. alert(wmer_LanguageRU?'Найдено более одного пользователя\nОтправьте сообщение самостоятельно.':'Sorry: more than one user found in the forum.\nYou should look for him/her by yourself.');
  1286. return false;
  1287. }
  1288. if (forumIDs.length==1 && forumIDs[0]==-3)
  1289. {
  1290. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'A network error occurred.');
  1291. alert(wmer_LanguageRU?'Сетевые проблемы\nОтправьте сообщение самостоятельно.':'Sorry: a network error occurred.\nYou should look for him/her by yourself.');
  1292. return false;
  1293. }
  1294.  
  1295. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'PM request - all OK. go to PM!');
  1296.  
  1297. var formID="WMER-PM-FORM";
  1298.  
  1299. var nodePM;
  1300.  
  1301. if (getId("WMER-PM-Send") == null)
  1302. {
  1303. nodePM= document.createElement('div');
  1304. nodePM.id = 'WMER-PM-Send';
  1305. nodePM.style.display='hidden';
  1306. getId(CreateID()).appendChild(nodePM);
  1307. }
  1308. else
  1309. {
  1310. nodePM=getId("WMER-PM-Send");
  1311. }
  1312.  
  1313. var PMForm;
  1314. PMForm='<form id="' + formID + '" target="_blank" method="post" style="display: inline">';
  1315. PMForm+='<input id="' + formID + '-subject" type="hidden" name="subject" value="" />';
  1316. PMForm+='<input type="hidden" name="addbbcode20" value="100" />';
  1317. PMForm+='<input id="' + formID + '-message" type="hidden" name="message" value="" />';
  1318. PMForm+='<input type="hidden" name="preview" value="Preview" />';
  1319. PMForm+='<input type="hidden" name="attach_sig" value="on" />';
  1320. PMForm+='<input id="' + formID + '-ct" type="hidden" name="creation_time" value="0" />';
  1321. PMForm+='<input id="' + formID + '-lc" type="hidden" name="lastclick" value="0" />';
  1322. for (var i=0; i<forumIDs.length; i++)
  1323. {
  1324. PMForm+='<input type="hidden" name="address_list[u]['+forumIDs[i]+']" value="to" />';
  1325. }
  1326. PMForm+='</form>';
  1327. nodePM.innerHTML=PMForm;
  1328.  
  1329. var permalink=wmer_generate_permalink();
  1330. //if(wmer_Debug) console.log(permalink);
  1331. var name_object=""
  1332. linkParts=permalink.replace(/#/g, "").split('&');
  1333. for (var j=0; j<linkParts.length; j++)
  1334. {
  1335. if (linkParts[j].indexOf("segments=")==0 || linkParts[j].indexOf("venues=")==0 || linkParts[j].indexOf("cameras=")==0 || linkParts[j].indexOf("bigJunctions=")==0)
  1336. {
  1337. name_object=linkParts[j].split('=')[0]
  1338. linkParts.splice (j,1);
  1339. break;
  1340. }
  1341. }
  1342. permalink=linkParts.join('&');
  1343.  
  1344. if(wmer_Debug) console.dir(linkParts);
  1345.  
  1346. var message=wmer_LanguageRU?
  1347. 'Есть вопросы по правкам в [url=' + permalink + ']этой области редактирования[/url]:\n\n':
  1348. 'Some questions about [url=' + permalink + ']this area[/url]:\n\n';
  1349.  
  1350. function NullToEmpty(s)
  1351. {
  1352. return !s?"":s;
  1353. }
  1354. function GetTypeName(s)
  1355. {
  1356. if(wmer_LanguageRU)
  1357. {
  1358. switch(s)
  1359. {
  1360. case "segment": return "сегмент"
  1361. case "venue": return "ПОИ"
  1362. case "node": return "узел"
  1363. case "camera": return "камера"
  1364. case "bigJunction": return "развязка"
  1365. }
  1366. }
  1367. return s
  1368. //'+(wmer_LanguageRU?'Категории':'Categories')+'
  1369. }
  1370.  
  1371. for (var i=0; i < sccObjs.length; ++i)
  1372. {
  1373. var on=sccObjs[i].type === "segment"?(wmer_LanguageRU?'Улица':"Street"):(wmer_LanguageRU?'Название':"Name");
  1374. message += ''
  1375. + (wmer_LanguageRU?'Автор':'Author')+': [b]' + sccObjs[i].username + '[/b]\n'
  1376. + (wmer_LanguageRU?'Тип':'Type')+': [b]' + GetTypeName(sccObjs[i].type) + '[/b]\n'
  1377. + (sccObj.country=='Belarus'?'':(wmer_LanguageRU?'Страна':'Country')+': [b]' + sccObjs[i].country + '[/b]\n')
  1378. + (wmer_LanguageRU?'НП':'City')+': [b]' + NullToEmpty(sccObjs[i].city) + '[/b]\n'
  1379. + (sccObjs[i].poiaddress.length > 0?(wmer_LanguageRU?'Адрес':'Address')+': [b]'+sccObjs[i].poiaddress+'[/b]\n':'')
  1380. + on+ ': [b]' + NullToEmpty(sccObjs[i].street) + '[/b]\n'
  1381. + (wmer_LanguageRU?'Дата':'Date')+': [b]' + timeConverter(sccObjs[i].updatedOn).replace('+',' ') + '[/b]\n'
  1382. + (wmer_LanguageRU?'Ссылка':'Permalink')+': [url]' + permalink + '&' + name_object + '=' + sccObjs[i].objid + '[/url]\n'
  1383. + (wmer_LanguageRU?'Дополнительно':'Description')+': {' + NullToEmpty(sccObjs[i].description) + '\n}\n'
  1384. + '\n';
  1385. }
  1386. //if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + message);
  1387.  
  1388. getId(formID + '-message').value=message;
  1389. var now=new Date().getTime();
  1390. now /= 1000;
  1391. now = Math.floor(now);
  1392. getId(formID + '-ct').value=now;
  1393. getId(formID + '-lc').value=now;
  1394.  
  1395. getId(formID).action="https://www.waze.com/forum/ucp.php?i=pm&mode=compose&action=post";
  1396. getId(formID + '-subject').value=
  1397. wmer_LanguageRU?
  1398. '[WME Request] Уточнение по правкам':
  1399. '[WME Request] Question about map edits';
  1400.  
  1401. if(wmer_Debug) console.dir(getId(formID));
  1402.  
  1403. getId(formID).submit();
  1404. return true; // this forces to open in new tab!
  1405. }
  1406. // </WME Fancy permalink>
  1407.  
  1408.  
  1409. function wmer_WazeBits()
  1410. {
  1411. // if (typeof Waze === "undefined")
  1412. // Waze=unsafeWindow.Waze;
  1413.  
  1414. if (typeof Waze === "undefined")
  1415. Waze=window.Waze;
  1416. }
  1417.  
  1418.  
  1419. function wmer_HandCreateRequest()
  1420. {
  1421. if ((typeof arguments[0]) === "object")
  1422. {
  1423. switch(arguments[0].type)
  1424. {
  1425. case 'click': // click button
  1426. {
  1427. var e=document.getElementById(arguments[0].id);
  1428. if(e)
  1429. e.click();
  1430.  
  1431. break;
  1432. }
  1433. }
  1434. }
  1435. }
  1436.  
  1437. function wmer_initBindKey() {
  1438. var Config =[
  1439. {handler: 'WMERequest_Lock', title: "Запрос на изменение уровня блокировки объекта", func:wmer_HandCreateRequest , key:-1, arg:{type:'click',id:'wmerBtn_lock'}},
  1440. {handler: 'WMERequest_Join', title: "Запрос на присоединение сегментов", func:wmer_HandCreateRequest , key:-1, arg:{type:'click',id:'wmerBtn_join'}},
  1441. {handler: 'WMERequest_Dir', title: "Запрос на изменение направления сегментов", func:wmer_HandCreateRequest , key:-1, arg:{type:'click',id:'wmerBtn_dir'}},
  1442. {handler: 'WMERequest_Turn', title: "Запрос на изменение разрешения поворотов", func:wmer_HandCreateRequest , key:-1, arg:{type:'click',id:'wmerBtn_turn'}},
  1443. {handler: 'WMERequest_Closures', title: "Запрос на перекрытие сегментов", func:wmer_HandCreateRequest , key:-1, arg:{type:'click',id:'wmerBtn_closures'}},
  1444. {handler: 'WMERequest_City', title: "Запрос на создание/изменение НП", func:wmer_HandCreateRequest , key:-1, arg:{type:'click',id:'wmerBtn_cl'}},
  1445. ];
  1446. /*
  1447. Waze.loginManager.user.editableCountryIDs
  1448. 186 - Russia
  1449. 180 - Poland
  1450. 123 - Latvia
  1451. 37 - Belarus
  1452. 129 - Lithuania
  1453. */
  1454. if(Waze.loginManager.user.rank >= 4 || (Waze.loginManager.user.editableCountryIDs.indexOf(37) >= 0 && Waze.loginManager.user.rank >= 3)) // ??? Uzbekistan ???
  1455. {
  1456. Config.push({handler: 'WMERequest_CitySave', title: "Сохранить название НП", func:wmer_HandCreateRequest , key:-1, arg:{type:'click',id:'wmerA_cl'}});
  1457. }
  1458.  
  1459. for(var i=0; i < Config.length; ++i)
  1460. {
  1461. WMEKSRegisterKeyboardShortcut('WME-Requests', 'WME-Requests', Config[i].handler, Config[i].title, Config[i].func, Config[i].key, Config[i].arg);
  1462. }
  1463.  
  1464. WMEKSLoadKeyboardShortcuts('WME-Requests');
  1465.  
  1466. window.addEventListener("beforeunload", function() {
  1467. WMEKSSaveKeyboardShortcuts('WME-Requests');
  1468. }, false);
  1469.  
  1470. }
  1471.  
  1472. function wmer_FakeLoad()
  1473. {
  1474. wmer_WazeBits();
  1475.  
  1476. if (typeof Waze === "undefined")
  1477. {
  1478. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'Waze not found, retrying in 500ms...');
  1479. setTimeout(wmer_FakeLoad,500);
  1480. return;
  1481. }
  1482. if (typeof Waze.selectionManager === "undefined")
  1483. {
  1484. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'Waze.selectionManager not found, retrying in 500ms...');
  1485. setTimeout(wmer_FakeLoad,500);
  1486. return;
  1487. }
  1488. if (typeof Waze.model === "undefined")
  1489. {
  1490. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'Waze.model not found, retrying in 500ms...');
  1491. setTimeout(wmer_FakeLoad,500);
  1492. return;
  1493. }
  1494.  
  1495. try {
  1496. Waze.selectionManager.events.register("selectionchanged", null, wmer_insertButton);
  1497. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'added event handler for selectionchanged');
  1498. }
  1499. catch (err) {
  1500. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'added event handler error: ' +err.name);
  1501. }
  1502. setTimeout(wmer_initBindKey, 500);
  1503. }
  1504.  
  1505.  
  1506. function wmer_Init() {
  1507. if(wmer_Debug) console.log('WME Requests v.' + wmer_Version + ': ' + 'init');
  1508. setTimeout(wmer_FakeLoad, 500);
  1509. }
  1510.  
  1511. wmer_bootstrap();
  1512.  
  1513.  
  1514.  
  1515. // from: https://greasyfork.org/ru/scripts/16071-wme-keyboard-shortcuts (modify)
  1516. /*
  1517. when adding shortcuts each shortcut will need a uniuque name
  1518. the command to add links is WMERegisterKeyboardShortcut(ScriptName, ShortcutsHeader, NewShortcut, ShortcutDescription, FunctionToCall, ShortcutKeysObj) {
  1519. ScriptName: This is the name of your script used to track all of your shortcuts on load and save.
  1520. ScriptName: replace 'WMEAwesome' with your scripts name such as 'SomeOtherScript'
  1521. ShortcutsHeader: this is the header that will show up in the keyboard editor
  1522. NewShortcut: This is the name of the shortcut and needs to be uniuque from all of the other shortcuts, from other scripts, and WME
  1523. ShortcutDescription: This wil show up as the text next to your shortcut
  1524. FunctionToCall: this is the name of your function that will be called when the keyboard shortcut is presses
  1525. ShortcutKeysObj: the is the object representing the keys watched set this to '-1' to let the users specify their own shortcuts.
  1526. ShortcutKeysObj: The alt, shift, and ctrl keys are A=alt, S=shift, C=ctrl. for short cut to use "alt shift ctrl and l" the object would be 'ASC+l'
  1527. */
  1528. function WMEKSRegisterKeyboardShortcut(e,r,t,a,o,s,c){try{I18n.translations.en.keyboard_shortcuts.groups[e].members.length}catch(n){Waze.accelerators.Groups[e]=[],Waze.accelerators.Groups[e].members=[],I18n.translations.en.keyboard_shortcuts.groups[e]=[],I18n.translations.en.keyboard_shortcuts.groups[e].description=r,I18n.translations.en.keyboard_shortcuts.groups[e].members=[]}if(o&&"function"==typeof o){I18n.translations.en.keyboard_shortcuts.groups[e].members[t]=a,Waze.accelerators.addAction(t,{group:e});var l="-1",i={};i[l]=t,Waze.accelerators._registerShortcuts(i),null!==s&&(i={},i[s]=t,Waze.accelerators._registerShortcuts(i)),W.accelerators.events.register(t,null,function(){o(c)})}else alert("The function "+o+" has not been declared")}function WMEKSLoadKeyboardShortcuts(e){if(localStorage[e+"KBS"])for(var r=JSON.parse(localStorage[e+"KBS"]),t=0;t<r.length;t++)Waze.accelerators._registerShortcuts(r[t])}function WMEKSSaveKeyboardShortcuts(e){var r=[];for(var t in Waze.accelerators.Actions){var a="";if(Waze.accelerators.Actions[t].group==e){Waze.accelerators.Actions[t].shortcut?(Waze.accelerators.Actions[t].shortcut.altKey===!0&&(a+="A"),Waze.accelerators.Actions[t].shortcut.shiftKey===!0&&(a+="S"),Waze.accelerators.Actions[t].shortcut.ctrlKey===!0&&(a+="C"),""!==a&&(a+="+"),Waze.accelerators.Actions[t].shortcut.keyCode&&(a+=Waze.accelerators.Actions[t].shortcut.keyCode)):a="-1";var o={};o[a]=Waze.accelerators.Actions[t].id,r[r.length]=o}}localStorage[e+"KBS"]=JSON.stringify(r)}
  1529. /* ********************************************************** */