WME UR Comments

This script is for replying to user requests the goal is to speed up and simplify the process. Thanks to Chat Jumper and URO+!

目前为 2014-11-17 提交的版本。查看 最新版本

// ==UserScript==
// @name           WME UR Comments
// @description    This script is for replying to user requests the goal is to speed up and simplify the process. Thanks to Chat Jumper and URO+!
// @namespace      [email protected]
// @grant          none
// @grant          GM_info
// @version        0.3.0
// @match          https://editor-beta.waze.com/*editor/*
// @match          https://www.waze.com/*editor/*
// @author         Rick Zabel '2014
// @license        MIT/BSD/X11
// ==/UserScript==
window.URCommentVersion = "0.3.0";

var URCommentVersionUpdateNotes = "UR Comments has been updated to " + URCommentVersion;
//URCommentVersionUpdateNotes = URCommentVersionUpdateNotes + "\r\n" + "Welcome new users!";
//URCommentVersionUpdateNotes = URCommentVersionUpdateNotes + "\r\n" + "Be sure to check out the options at the bottom of the UR Comment Tab. Each item has a tooltip describing the item";
//URCommentVersionUpdateNotes = URCommentVersionUpdateNotes + "\r\n" + "When a comment is clicked my script will find and add some scripting to the UR's send button, then after the send button is clicked it will trigger the option.";
//URCommentVersionUpdateNotes = URCommentVersionUpdateNotes + "\r\n" + "New feature is the ability to have your own custom comment list. The custom list is kind of a work around but if you edit the list carefully it should work great and not be over written when I release new versions of this script. Instructions and the link to the custom list are in the list drop down under the custom list";
URCommentVersionUpdateNotes = URCommentVersionUpdateNotes + "\r\n" + "When we request more information from users Waze has the UR layer off on the link they send, so I changed the 4 day reminder message to include a link to the UR with the UR layer turned on. NOTE the 4 day reminder link will be taken from your current map view and zoom. So center the pin and set a zoom that makes sense before clicking 4 day reminder comment and try to only show one pin. I changed the way the options interact, broke apart auto close and auto reload. I also added a check on the URO presets to see if URO is installed. I think I fixed the bug that was keeping URComments from showing up some of the time.";
URCommentVersionUpdateNotes = URCommentVersionUpdateNotes + "\r\n" + "";
URCommentVersionUpdateNotes = URCommentVersionUpdateNotes + "\r\n" + "Change log:";
URCommentVersionUpdateNotes = URCommentVersionUpdateNotes + "\r\n" + "";
URCommentVersionUpdateNotes = URCommentVersionUpdateNotes + "\r\n" + "There was a problem with the auto clicking of the solved option.";
URCommentVersionUpdateNotes = URCommentVersionUpdateNotes + "\r\n" + "";
URCommentVersionUpdateNotes = URCommentVersionUpdateNotes + "\r\n" + "As usual let me know if there are any issues -RickZabel";

/* Changelog
 * 0.3.0 - There was a problem with the auto clicking of the solved option.
 * 0.2.9 - Changed the text color of the comments depending on their UR status. I also removed a section of code that was preventing right clicking
 * 0.2.8 - reworded tooltips added new comments.
 * 0.2.7 - On slow connections this script would close the UR before the comment was able to post, I added in a check that repeats its self every 500 milliseconds until the comment text area goes back to being empty.
 * 0.2.6 - added an URO option to only show the editors URS, made all the settings be enabled on first time running the script, added a zoom out button, added some checks to the 4-day reminder map zoom level for the link, changed font sizes, added headings,
 * 0.2.5 - 4 day tooltip wording changes
 * 0.2.4 - When we request more information from users Waze has the UR layer off on the link they send, so I changed the 4 day reminder message to include a link to the UR with the UR layer turned on. NOTE the 4 day reminder link will be taken from your current map view and zoom. So center the pin and set a zoom that makes sense before clicking 4 day reminder comment and try to only show one pin. I changed the way the options interact, broke apart auto close and auto reload. I also added a check on the URO presets to see if URO is installed. I think I fixed the bug that was keeping URComments from showing up some of the time.
 * 0.2.2 - bug fixes for firefox
 * 0.2.1 - added ability to have custom lists and preset lists
 * 0.2.0 - added new options for auto clicking ur status and auto saving after clicking stauts
 * 0.1.16 - URO+ added a new tag and zoom out after send
 * 0.1.15 - URO+ changed one of the tags for min replies changed to match
 * 0.1.14 - attempting to fix a bug in firefox and chrome each handles pub vars differently
 * 0.1.13 - Added a user setting for adding reply Instructions to the 4 day follow up
 * 0.1.11 - Added  version number to notifications
 * 0.1.1 - Added new version notifications
 * 0.1.0 - Close and Reloads the map if the following events happen, request has to be open, cicked any ur comment on the UrCommnet tab, then clicked send. this will force URO+ to reapply it's filter
 * 0.0.92 - added comment for clearing TTS Cache
 * 0.0.91 - changed generic error wording from can to would
 * 0.0.9 - Now working in FireFox
 * 0.0.8 - changed the code to look for the user tab instead of the buggy chat window before loading the ur comment tab
 * 0.0.8 - changed the code to look for the user tab instead of the buggy chat window before loading the ur comment tab
 * 0.0.7 - added code to set preset filters in URO+ (new / ur replies, 4day followup, 7 day close, URO clear ur filters)
 * 0.0.6 - rewrote majority of the code to pull comments out of an array and reuseable functions to generate the list / mouse clicks. also changed all instances of "rickzabelcomments" to "URComments"
 * 0.0.5 - added tool tips with the text of that comment
 * 0.0.4 - added Valid Route
 * 0.0.3 - added HawkeyGoals slightly edited Ur-comments
 * 0.0.2 - initial version
 */


/* Wishlist 
 *
 * /my own
 * work on getting the text not to wrap with seekingserinitys maximizer script
 * add peachez list
 * review my comment list errors with no text and wrong driving directions are very close to each other in wording
 *
 * /users
 *
 *
 */


//alert the user in  URComment version updates
if (localStorage.getItem('URCommentVersion') === URCommentVersion) {
    console.log("URComments Version - " + URCommentVersion);
} else {
    alert(URCommentVersionUpdateNotes);
    localStorage.setItem('URCommentVersion', URCommentVersion);
}


window.BoilerPlateCreatorsArray = ["rickzabel",
    "DwarfLord",
    "Custom"
];
//get the SelectedBoilerPlateCreator
window.SelectedBoilerPlateCreator = localStorage.getItem('BoilerPlateCreators');

//alert(SelectedBoilerPlateCreator);

if (SelectedBoilerPlateCreator === "" || SelectedBoilerPlateCreator === null) {
    //alert(SelectedBoilerPlateCreator);
    //} else {
    //alert("UR-Commenst now has multiple User's commnet lists that you may choose from. To select from the lists look under the settings section");
    SelectedBoilerPlateCreator = "rickzabel";
    localStorage.setItem('BoilerPlateCreators', SelectedBoilerPlateCreator);
}
//set global comment var and array
//this is the array used to store the ur comments the format is name, comment, name, comment...

//comment arrays should follow the format
// "Title",     * is what will show up in the ur comment tab
// "comment",   * is the comment that will be sent to the user currently 
// "URStatus"   * this is action to take when the option "Auto Click Open, Solved, Not Identified" is on. after clicking send it will click one of those choices. usage is. "Open", or "Solved",or "NotIdentified",

/////////////////////////////////////

function URComments_bootstrap() {

    if (SelectedBoilerPlateCreator === "rickzabel") {

        //rickzabel's list
        window.myArray = ["Errors with no descriptive text",
            "Waze did not send us enough information to fix your request. Would you please let us know what went wrong with the route Waze gave you? Would you tell us your destination as you entered it into Waze? Thanks!",
            "Open",
            "4 day Follow-Up",
            "Just a reminder: We haven't received a response on your report. If we don't hear back from you we'll have to infer everything is okay and close the report. Thanks!",
            "Open",
            "7th day With No Response",
            "The problem was unclear and volunteers didn't receive a response. As you travel, please feel welcome to report any map issues you encounter. Thanks!",
            "NotIdentified",
            "Fixed",
            "Thanks to your report we've found and fixed a problem with the map. The fix should reach handheld devices within a week, but on rare occasions it can take closer to two weeks. ",
            "Solved",
            "Thanks for the reply",
            "Thank you for the reply this request will be closed. As you travel, please feel welcome to report any map issues you encounter.",
            "Solved",
            "No further communication received.",
            "No further communication was received, this request will now be closed. As you travel, please feel welcome to report any map issues you encounter. Thanks!",
            "Solved",
            "No further communication received.",
            "No further communication was received, this request will now be closed. As you travel, please feel welcome to report any map issues you encounter. Thanks!",
            "NotIdentified",
            "Address fishing",
            "Waze does not tell us your starting or ending destinations. Would you tell us the address you are having problems with as you entered it into Waze?",
            "Open",			
            "<br>",
            "",
            "",
            "Missing Exit",
            "Would you please let us know what exit you believe is missing? Thanks!",
            "Open",
            "Turn Not Allowed",
            "Would you please let us know what turn was not, or should not be, allowed and the street names at the intersection? Thanks!",
            "Open",
            "Wrong Driving Direction",
            "Would you please let us know what went wrong with the route Waze gave you? Would you tell us your destination as you entered it into Waze? Thanks!",
            "Open",
            "User Followed Waze's route",
            "It appears that you ended up going the route Waze suggested, what was the problem you were having? Would you tell us your destination as you entered it into Waze? Thanks!",
            "Open",              
            "Chicago Alleys",
            "Waze doesn't tell volunteer editors where you were going, although it was probably adjacent to the alley. If you would, please supply your destination as you entered it into Waze it may be helpful in correcting the route. Thanks!",
            "Open",
            "Road Closed",
            "Would you please let us know the following, what road is closed; between which intersections is this road closed; do you know how long this road is scheduled to be closed? Thanks!",
            "Open",
            "48 Hour Reply",
            "Please allow 48 hours for changes to be reflected in the live map.",
            "Open",
            "Clear Saved Locations",
            "You should remove the location from your favorites and recent searches and then re-search for the location to update the result.",
            "Open",
            "Clear TTS Cache",
            "If you continue to have this problem you will need to clear your Text to Speech cache. Go to navigation screen and type cc@tts in search field and hit search. You should get a pop up message that the TTS file has been cleared. It will take a few days for the file to build back up with all the spoken street names.",
            "Open",
            "Address - Incorrect Position",
            "Thank you for your report. Would you please let us know what address you're reporting the problem with? You can also use the Report -> Places feature in Waze to mark the location. It is helpful that after taking a picture, if you move near the location your marking to save the place. Also, please do not submit pictures containing faces, license plates, or similar personal details. Thanks!",
            "Open",
            "Address - Missing from Map",
            "Thank you for your report. Would you please let us know where the address you're reporting is? The live map doesn't have all the street numbers for that street and Waze is interpolating in error. You can also use the Report -> Places feature in Waze to mark the location. It is helpful that after taking a picture, if you move near the location you’re marking to save the place. Also, please do not submit pictures containing faces, license plates, or similar personal details. Thanks!",
            "Open",
            "Address - Search Results Bad",
            "Thank you for your report. The search feature retrieves results from a number of locations, including Google. Scrolling to the bottom the Navigate screen, you'll see more results for 'name.' Select that and Waze will list locations Around You. From there, you can also select results from other search engines.",
            "Open",
            "Detours / Odd-Routing",
            "We can't find anything in the map to explain route Waze gave you. Waze wants to save you time every way it can and sometimes it suggests complex detours just to shave a few seconds off your trip. Waze may recommend a detour even after the traffic has cleared up because: it doesn't know yet, other Wazers may have reported a temporary street closure, or daily traffic patterns. In any event, we are very sorry to say that the volunteer map editors can't be much help here. Thanks!",
            "NotIdentified",
            "House Number Adjustment",
            "I've forced Waze to re-register the house number for your destination. I believe this should correct your issue. Please allow 48 hours for changes to be reflected in the live map. If the location is in your saved searches or favorites, please remove them and search for them again to pick up the change in the live map. Please let me know if you continue to experience the problem. Thanks!",
            "Open",
            "Missing Bridges or Roads",
            "The roads here have been pretty thoroughly mapped and we volunteers can't see anything missing that should ordinarily be there. Waze probably simply chose not to show you the feature in question. When moving at highway speeds, Waze deliberately chooses not to display some nearby features to avoid cluttering the screen. If you are certain a feature is missing from the map, please reply and tell us as much as possible about it. Thanks!",
            "Open",
            "Road Closure Request - Temporary",
            "How long is the road going to be closed? For closures of only a few days, we volunteer map editors can't be much help. It takes at least that long for our edits to make it to devices! When you encounter short-term road closures in the future, please use the Report->Closure feature in the Waze app. If this is a long-term closure please respond and let us know as much as you can. Thanks!",
            "Open",
            "Traffic - Stale Information",
            "Volunteer map editors can't do anything about Waze's traffic reporting. Waze relies on data from people using Waze to assess traffic. In the case of a fresh accident or slowdown, Waze may not yet have any data on the situation. Once Waze has detected a traffic situation, it can remember it for awhile, sometimes long after the situation changes.",
            "NotIdentified",
            "Traffic - Jams ",
            "To report traffic jam conditions, please use the Report -> Traffic Jam options in the Waze app. This will tell Waze about the problem in real-time. Traffic Jam reports can help route you and other Wazers around traffic problems.",
            "NotIdentified",
            "Valid Route",
            "We reviewed the issue and did not find any map errors. It looks like Waze had a valid route. If you feel yours is correct keep driving that way. If it is indeed faster Waze will learn from your drives and route you and others the faster route. Thanks!",
            "Solved"
        ];
        window.ReplyInstructions = 'To reply to this request go to the following link and click the map pin, then click on the conversation button.';
        //end rickzabel's list

    } else if (SelectedBoilerPlateCreator === "hawkeygoal") {
        //Hawkeygoal's list
        window.myArray = ["Closed - Unclear",
            "The problem was unclear and volunteers didn't receive a response. Please feel welcome to report any map issues you encounter. Thanks!",
            "NotIdentified",
            "Closed - OK",
            "We haven't received a response and are inferring that all is well. Please feel welcome to report any map issues you encounter. Thanks!",
            "NotIdentified",
            "Reminder",
            "Just a reminder: We haven't received a response on your report. If we don't hear back from you we'll have to infer there is no continuing need for the report and close the report in a few days. Thanks!",
            "Open",
            "General Error",
            "We don't have enough information to act. Would you please provide more detail on the problem you're reporting? Thanks!",
            "Open",
            "Incorrect Junction",
            "Would you please let us know what was in error? At what intersection? Thanks!",
            "Open",
            "Missing Exit",
            "Would you please let us know what exit you believe is missing? Thanks!",
            "Open",
            "Missing Road",
            "Would you please let us know what road you believe is missing? Thanks!",
            "Open",
            "Turn Not Allowed / Missing Turn",
            "Would you please let us know what turn was not, or should not be, allowed? At what intersection? Thanks!",
            "Open",
            "Turn Not Allowed / Missing Turn - Closed Road (wording doesnt work..)",
            "",
            "Open",
            "Wrong Driving Directions",
            "Waze doesn't tell volunteer editors where you were going. Would you please let us know what went wrong with the route Waze gave you? it is helpful if you can include your destination as you entered it too. Thanks!",
            "Open",
            "Chicago - Alley Issue",
            "Waze doesn't tell volunteer editors where you were going, although it was probably adjacent to the alley. If you would, please supply your destination as you entered it into Waze it may be helpful in correcting the route. Thanks!",
            "Open",
            "Fixed",
            "We reviewed the issue and updated the map. Please allow 48 hours for changes to be reflected in the live map (rarely up to two weeks). Thanks!",
            "Solved"
        ];
        window.ReplyInstructions = 'To reply to this request go to the following link and click the map pin, then click on the conversation button.';

    } else if (SelectedBoilerPlateCreator === "DwarfLord") {
        //DwarfLord's list
        window.myArray = ["General Error",
            "Volunteer responding to your general error map-issue report. Waze gives us volunteers very little to go on and we're stumped. What was wrong with the map? Can you provide any detail? Please respond using the Waze app, emails don't work with the reporting system. (Open to any editor)",
            "Open",
            "Wrong Driving Direction",
            "Volunteer responding to your wrong driving direction map-issue report. Waze gives us volunteers very little to go on; we don't even know where you were going! What went wrong with the route Waze gave you? Can you tell us your destination as you entered it into Waze? Please respond using the Waze app, emails don't work with the reporting system. (Open to any editor)",
            "Open",
            "Incorrect Junction",
            "Volunteer responding to your incorrect junction map-issue report. Waze gives us volunteers very little to go on. What junction was incorrect? What was incorrect about it? Please respond using the Waze app, emails don't work with the reporting system. (Open to any editor)",
            "Open",
            "Turn Not Allowed",
            "Volunteer responding to your turn not allowed map-issue report. Waze gives us volunteers very little to go on. What turn was not allowed? At what intersection? Please respond using the Waze app, emails don't work with the reporting system. (Open to any editor)",
            "Open",
            "Fixed",
            "Volunteer responding to your report of a map issue. Thanks to your report we've found and fixed a problem with the map. The fix should reach handheld devices within a week, but on rare occasions it can take closer to two weeks. Cheers!",
            "Solved",
            "No response",
            "No response and problem unclear, the volunteers will close this one out, but please feel welcome to submit map issues in the future if you encounter errors in the map. Cheers!",
            "NotIdentified",
            "Pronunciation",
            "Volunteer responding to your report of poor pronunciation by Waze text-to-speech (TTS). Unfortunately even the seniormost volunteers have little influence on the TTS system, and none of us can alter how any one street name is pronounced. I understand the frustration and I sympathize. Sorry not to be more help. Cheers!",
            "Open",
            "The Waze 180",
            "Volunteer responding to your report of a map issue. When you ask for a route immediately after waking up Waze, it has to guess what direction you are pointed. If it guesses wrong, it may give you an awkward route to avoid any illegal U-turns (I call this the Waze 180). When Waze offers you a route that starts off the wrong way, please drive a little in the direction you are pointed and then ask for the route again. This gives Waze a chance to know which way you are pointed and offer you a more suitable route. If you are sure this was not the problem, please respond using the Waze app (emails don't work with the reporting system) otherwise we'll close out this report in a few days. Cheers! (Open to any editor)",
            "Open",
            "Google fu (easy)",
            "Volunteer responding to your report of a map issue. The problem was caused by inaccurate data provided by Google (Waze gets most of its address locations from Google). We asked Google to fix its database and they accepted the request. Please allow at least three days for the fix to go live. Then -- and this is important! -- please remove the destination from your Waze app's navigation history and/or favorites list and wait at least a few minutes before adding it back. This will update your device's position data for this address so you don't go to the old (wrong) position. Cheers!",
            "Open",
            "Google fu (difficult)",
            "Volunteer responding to your report of a map issue. The problem is caused by inaccurate data provided by Google (Waze gets most of its address locations from Google). We have asked Google to fix its database but we have no control over how fast Google will respond. It is usually days, but it can be weeks or even months. We'll leave this report open in the meantime. Cheers!",
            "Open",
            "Google FAIL, how to use Waze",
            "Volunteer responding to your report of a map issue. The problem is caused by inaccurate data provided by Google (Waze gets most of its destination locations from Google). In this case, unfortunately, we cannot persuade Google to change its database (this often happens with large areas such as parks and airports, or with high-profile locations). You can however use the Waze database to reach the destination. First, remove any instances of the destination from your recents and favorites lists. Then search again, but when you enter your search terms, DO NOT SELECT ANY OF THE IMMEDIATELY-OFFERED ITEMS, EVEN IF YOU SEE A PERFECT MATCH! Instead, scroll to the bottom of the menu and select More results for.... You will be given the opportunity to choose a search engine under Other search engines. Choose Waze and select your destination. This is cumbersome and we volunteers don't like it any more than you do, but it works, and once the correct information is in your recents and/or favorites lists you should not need to repeat the process. Cheers!",
            "Open",
            "Bogus GPS",
            "Volunteer responding to your report of a map issue. It looks like your GPS position information was awfully inaccurate. Bad GPS position data can cause all sorts of problems. Waze may think you are on some other road and give you bogus directions to get you back to the road you're already on. There's nothing we volunteer map editors can do about this, but in the future, please try ensuring that your handheld device has as clear a view of the sky as possible so it will get the most accuracy out of the GPS satellite signals. Cheers!",
            "Open",
            "Still tracking stale route",
            "Volunteer responding to your report of a map issue. It looks like you departed from Waze's recommended route and followed a new route. If the new route is physically close to the recommended route -- for example, if Waze recommends a frontage road but you decide to remain on the highway next to it, or vice versa -- Waze can't easily tell that you're on a different track. It will continue giving you routing instructions appropriate for the old route. These instructions won't make any sense because you aren't on that route any more. There's nothing we volunteer map editors can do about this; GPS isn't perfect and Waze has to make educated guesses about what road you're on. When there are multiple possibilities it assumes you are on its suggested route. If that's a bad assumption the driving instructions can go wrong. Sorry not to be more help. Cheers!",
            "Open",
            "Stale or bogus traffic indications/routing",
            "Volunteer responding to your report of a map issue involving wrong traffic indications. We volunteer map editors can't do anything about Waze's traffic reporting, but I can explain what may have happened. Waze relies on data from people using Waze to assess traffic. In the case of a fresh accident or slowdown, Waze may not yet have any data on the situation and route you into it because it doesn't know. Then, when Waze thinks it has detected a traffic situation, it can remember it for awhile, sometimes long after the situation changes. Also, slow-moving Wazers can confuse Waze into incorrectly detecting heavy traffic (this is why one should never run Waze while walking or biking along roads). Sorry we volunteers can't be more help with this. Cheers!",
            "Open",
            "Waited forever to make Waze's recommended left turn",
            "Volunteer responding. I would hate it too if Waze asked me to make a left turn through heavy traffic! Unfortunately there's nothing we volunteer map editors can do. If we disable the left turn, then others who want that route during off-peak hours will complain. The good news is that your long wait did not go unnoticed. Waze keeps track of how long it takes to make a turn. Thanks to your experience, other drivers are less likely to be routed this way during peak traffic hours. Cheers!",
            "Open",
            "Unexplained detour",
            "Volunteer responding. I can't find anything in the map to explain the apparent detour Waze gave you. Waze may have thought there was traffic, or a daily pattern of traffic at that time, on the simplest route. Or maybe Waze was not yet familiar enough with the alternate route to know that it might not be faster. Waze wants to save you time every way it can and sometimes it suggests complex detours to shave a few seconds off your trip. Waze may recommend a detour even after the traffic has cleared up, because it doesn't know yet. Or, other Wazers may have reported a temporary street closure in the area. In any event we volunteer map editors can't find anything wrong with the map itself. Cheers!",
            "Open",
            "Unexplained NON-detour",
            "Volunteer responding. Waze is indeed aware of the alternate route to bypass traffic. It routed you on a more typical path at that time because it thought, at that moment, that it would be faster to go that way. We volunteer map editors can't do anything about Waze's traffic detection and routing algorithms, but we have checked that the map itself does look OK. Cheers!",
            "Open",
            "missing road and missing bridge overpass reports",
            "Volunteer responding to your report of a missing road or bridge overpass. The drivable roads along this highway have been pretty thoroughly mapped and we can't see anything missing that should ordinarily be there. Probably Waze simply chose not to show you the road in question; when moving at highway speeds, Waze deliberately chooses not to display many nearby roads to avoid cluttering the screen. If you are certain a road is missing from the map, please respond using the Waze app (emails don't work with the reporting system) and provide details! Otherwise we'll close out this report in a few days. Cheers! (Open to any editor)",
            "Open",
            "Short-term closure reported as a map issue",
            "Volunteer responding to your report regarding a temporary closure. How long will the road be closed? If it is only for a few days or less, we volunteer map editors can't be much help. It takes at least that long for our edits to make it to handheld devices! When you encounter short-term road closures in the future, please use the Report->Closure feature in the Waze app (you used Report->Map issue to file this report). If this is a long-term closure please respond using the app (emails don't work with the reporting system) and let us know as much as you can. Otherwise we'll close out this report in a few days. Cheers! (Open to any editor)",
            "Open",
            "Map-Issue field to enter navigation destination",
            "Volunteer responding to your map-issue report in which you described the problem as an address. Did you mean to enter the address as a navigation destination? If there is a problem with the address please respond using the Waze app (emails don't work with the reporting system) and explain what went wrong. Otherwise we'll assume this was an accident and close out this report in a few days. Cheers! (Open to any editor)",
            "Open",
            "No hablo muy bien el Español", "Lo siento, estamos voluntarios solamente para mantener las mapas. No hablamos muy bien el Español y no podemos ayudar con el aplicación.(Regrets, we are volunteers only for maintaining the maps. We don't speak Spanish well and we can't help with the application.)",
            "NotIdentified",
            "NO THRU TRAFFIC",
            "Volunteer responding. Confusingly, the private road Waze type does not mean it is a private road. It is just a flag that Waze should prohibit thru traffic. You are completely right, this is a public road! But at both ends it is posted RESIDENTIAL ONLY - NO THRU TRAFFIC. For better or worse Waze, like most folks, can't fight city hall and must respect the signs. The good news is that the Waze route is only a suggestion. You are free to drive on this street as it is indeed a public road. Once you are there, Waze will automatically recalculate your route. Cheers!",
            "Open",
            "Possible routing bug",
            "Volunteer responding. The snippet of data Waze provided us along with your report does suggest inexplicable routing. I've checked everywhere I can think of and unfortunately I can't find anything wrong with the map. But, Waze is currently working on an issue with speed detection for different turns out of an intersection. In rare instances this issue can lead Waze to suggest non-ideal routes, usually involving one or more U-turns or loops. We volunteers have no way to know if your experience resulted from this issue, but as there's nothing I can find on the map I'll close this report as not identified. I sure wish I could be more help but that's what's going on.",
            "NotIdentified",
            "We can't do U-turns",
            "Volunteer responding to the map issue you reported involving U-turns. Waze does consider U-turns when preparing a route for you, but unfortunately the app cannot yet give voice instructions for U-turns. This omission could make it hard for drivers to follow Waze's suggested route when U-turns are involved. To avoid routing drivers in a way that will lack critical voice instructions, the Waze volunteer editing community has decided to disable nearly all U-turns, including this one, until such time as Waze fully supports U-turns. We know that Waze is very aware of this issue but we do not have a schedule for when they might address it. I sure wish I could be more help but that's what's going on. Cheers!",
            "Solved",
            "We can't do continue straight (usually a followup response)",
            "That behaviour has happened to me too and I agree it is disconcerting. Unfortunately at this time the Waze app has no ability to provide a continue straight instruction. We can often persuade it to say keep left or keep right, but we can't make it say keep going. In this situation, where all you needed to do was continue straight ahead with no turns, I'm afraid I don't see any way to improve the driving instructions. Waze continues to work on their app and their routing engine and it's very possible they will support a continue on instruction in the future, but for now we volunteer editors can't improve situations like this. Sorry not to be more help!",
            "Solved"
        ];
        window.ReplyInstructions = 'To reply to this request go to the following link and click the map pin, then click on the conversation button.';

        //custom list from external list
    } else if (SelectedBoilerPlateCreator === "Custom") {

        if (window.UrcommentsCustomArray) {
            //found custom list
            window.myArray = UrcommentsCustomArray;
            window.ReplyInstructions = UrcommentsCustomReplyInstructions;

        } else {
            window.myArray = ["Custom List not be found you can find the custom list and insctructions at <a href=https://greasyfork.org/en/scripts/6236-wme-ur-comments-custom-list>https://greasyfork.org/en/scripts/6236-wme-ur-comments-custom-list</a> ",
                " ",
                " "
            ];
            window.ReplyInstructions = 'To reply to this request go to the following link and click the map pin, then click on the conversation button.';
        }
    }



    console.log("URComments - Start of bootstrap");

    var bGreasemonkeyServiceDefined = false;

    try {
        var ver = window.navigator.appVersion.match(/Chrome\/(.*?) /)[1];
    } catch (err) {
        var ver = null;
    }
    if (null !== ver) {
        var itschrome = true;
        ///ver = "27.0.1438.7"; // last old working version
        // example: 32.0.1700.107
        // [0] - major versin
        // [2] - minor version
        ver = ver.split(".");
        ver[0] = parseInt(ver[0]);
        ver[2] = parseInt(ver[2]);
        if (ver[0] > 27) {
            var newmethod = true;
        } else if (ver[0] == 27) {
            if (ver[2] <= 1438) {
                var newmethod = false;
            } else {
                var newmethod = true;
            }
        } else {
            var newmethod = false;
        }
    } else {
        var itschrome = false;
        var newmethod = false;
    }

    try {
        // Firefox tells that "Components" is deprecated
        if ("object" === typeof Components.interfaces.gmIGreasemonkeyService) {
            bGreasemonkeyServiceDefined = true;
        }
    } catch (err) {};

    try {
        if ("object" === typeof GM_info) {
            bGreasemonkeyServiceDefined = true;
        }
    } catch (err) {};


    if ("undefined" === typeof unsafeWindow || !bGreasemonkeyServiceDefined) {
        try {
            unsafeWindow = (function() {
                var dummyElem = document.createElement('p');
                dummyElem.setAttribute('onclick', 'return window;');
                return dummyElem.onclick();
            })();
        } catch (err) {
            //Ignore.
        }
    }

    /* FIX IT !!!! */
    var itschrome = true;
    var newmethod = true;
    var bGreasemonkeyServiceDefined = false;

    //And check again for new chrome, and no tamper(grease)monkey
    if (itschrome && newmethod && !bGreasemonkeyServiceDefined) {
        //use "dirty" but effective method with injection to document
        var DLscript = document.createElement("script");
        DLscript.textContent = 'unsafeWindow=window; \n' + // need this for compatibility
            URComments_init.toString() + ' \n' +
            'URComments_init();';
        DLscript.setAttribute("type", "application/javascript");
        document.body.appendChild(DLscript);
        document.body.removeChild(DLscript);
    } else {
        /* begin running the code! */
        console.log("URComments end of boot strap");
        URComments_init();
        ///setTimeout(URComments_init,200);
    }
}

function URComments_init() {
    console.log("URComments - Start init 1");

    URComments = {
        last: new Array(),
        isLast: false,
        isLSsupported: false,
        zoom: false
    };

    URComments.init = function() {



/*
        //$(document).ready(function() {
        $('#WazeMap').mousedown(function(event) {
            switch (event.which) {
                case 1:
                    //alert('Left mouse button pressed');
                    break;
                case 2:
                    //;alert('Middle mouse button pressed');
                    break;
                case 3:
                    alert('Right mouse button pressed');
                    break;
                default:
                    break;

            }
            //alert("test");
        });
        //});
*/



        //console.log("URComments init 2");
        console.log("URComments - Start adding the URComments's tab");
        //add comments tab
        var b = $('<li> <a data-toggle="tab" href="#sidepanel-Comments">UrComments</a> </li> ');
        $(".nav-tabs").append(b);

        //add the content to the comments tab
        //Comment tab header
        var c = $('<div class="tab-pane" id="sidepanel-Comments" style="font-size: 14px;> <div class="result-list-container"><p class="URComments" style="font-size: 12px;"><b>UR Comments Version ' + URCommentVersion + ' </b></p></div></div><br><br>');
        $(".tab-content").append(c);

        //URO+ Preset filters
        console.log("URComments - Start adding URO preset filters to the comment tab");
        //uro preset header
        var d = $('<div style="margin:1px;"><b>URO+ Presets</b></div>');
        $("#sidepanel-Comments").append(d);

        //URO+ new ur
        var d = $('<div style="margin:1px;"><a id="URCommentURONEW" class="URComments" style="float:none;color:#000000;font-size: 12px;" Title="Use URO+ to only show new requests or UR replies">URO+ New Requests /  UR Replies</a></div>');
        //d.click (URComments.comment1);
        $("#sidepanel-Comments").append(d);
        //create the callback function
        document.getElementById("URCommentURONEW").addEventListener("click", URCommentUROClicked('UroShowNew'), false);

        //show no responses for 4 days
        d = $('<div style="margin:1px;"><a id="URCommentURO4DayFollowUp" class="URComments" style="float:none;color:#000000;font-size: 12px;" Title="Use URO+ to only show URs that need a 4 day follow up">URO+ 4 Day Follow Up</a></div>');
        //d.click (URComments.comment1);
        $("#sidepanel-Comments").append(d);
        //create the callback function
        document.getElementById("URCommentURO4DayFollowUp").addEventListener("click", URCommentUROClicked('URO4DayFollowUp'), false);

        //show no responses for 7 days needs closing
        d = $('<div style="margin:1px;"><a id="URCommentURO7DayClose" class="URComments" style="float:none;color:#000000;font-size: 12px;" Title="Use URO+ to only show URs that are older then 7days and need to be closed">URO+ 7 Day Close</a></div>');
        //d.click (URComments.comment1);
        $("#sidepanel-Comments").append(d);
        //create the callback function
        document.getElementById("URCommentURO7DayClose").addEventListener("click", URCommentUROClicked('URO7DayClose'), false);

        //URO+ clear
        d = $('<div style="margin:1px;"><a id="URCommentUROclearUROFiltrs" class="URComments" style="float:none;color:#000000;font-size: 12px;" Title="Clear URO+ UR Filters">URO+ Clear UR Filters</a></div>');
        //d.click (URComments.comment1);
        $("#sidepanel-Comments").append(d);
        //create the callback function
        document.getElementById("URCommentUROclearUROFiltrs").addEventListener("click", URCommentUROClicked('UROclearUROFiltrs'), false);

        //the predefined presets only show comments that the current user has commented on
        d = $('<input type="checkbox" id="URCommentUROOnlyMyUR" Title="Show URs with comments from me." style="margin:0px 0px 0px; vertical-align: middle;font-size: 12px;"></input><font style="font-size: 12px;"> Only My URs</font><br><br>');
        $("#sidepanel-Comments").append(d);
        //create the callback function
        document.getElementById("URCommentUROOnlyMyUR").addEventListener("change", OnlyMyUR, false);

        //$(document.getElementById("URCommentUROOnlyMyUR")).trigger('click');


        /*
        UroShowNew
        URO4DayFollowUp
        URO7DayClose
        UROclearUROFiltrs
  
        $('.myCheckbox').prop('checked', true);
        $('.myCheckbox').prop('checked', false);
        */




        //start generating the comment list and mouse click handlers
        console.log("URComments - Start adding comments to the comment tab");
        //comments setup

        //comments header
        var d = $('<div style="margin:1px;"><b>UR Comments</b></div>');
        $("#sidepanel-Comments").append(d);

        //CurrentIndex is used to keep count of total arrays pairs which is used on the div's id tags
        var CurrentIndex = 1;
        console.log("URComments - Create Div 1");

        
        //2E5C8A for Open? blue
        //996633 not ident brown
        //339933 solved green
        
        var colorrr= "CC0000";
        //go over the array and generate divs
        for (var i = 0; i < myArray.length; i = i + 3) {
            console.log("URComments - Create div for - " + myArray[i] + " " + myArray[i + 2]);
            
            if(myArray[i + 2] === "Open"){
               colorrr= "#000000";
            } else if(myArray[i + 2] === "Solved"){
               colorrr= "#008F00";
            } else if(myArray[i + 2] === "NotIdentified"){
               colorrr= "#E68A00";
            } else {
               colorrr= "#CC0000";
               //not defined and that is a problem
            }
            
            d = $('<div style="margin:1px;font-size: 12px;"><a id="URComments-comment' + CurrentIndex + '" class="URComments" style="float:none;color:'+ colorrr +'" Title="Action: ' + myArray[i + 2] + '; Comment: ' + myArray[i + 1] + ' ">' + myArray[i] + '</a></div>');
            $("#sidepanel-Comments").append(d);

            console.log("URComments - Create callback for - " + 'URComments-comment' + CurrentIndex);
            //create the callback function in order to pass text we need to pass it trough 2 even handlers
            document.getElementById('URComments-comment' + CurrentIndex).addEventListener("click", getClickFunction(myArray[i], myArray[i + 1], myArray[i + 2]), false);

            //inc the CurrentIndex
            CurrentIndex++;
        }

        //script comment options

        //URO+ Preset filters options
        //Options header
        var d = $('<br><div style="margin:1px;"><b>Options</b></div>');
        $("#sidepanel-Comments").append(d);

        //ZoomOutButton
        d = $('<div style="margin:1px;"><a id="URCommentZoomOutButton" class="URComments" style="float:none;color:#000000;font-size: 12px;" Title="Zoom all the way out.">Zoom Out</a></div>');
        $("#sidepanel-Comments").append(d);
        //create the callback function
        document.getElementById("URCommentZoomOutButton").addEventListener("click", ZoomOutButton, false)

        //add reply Instructions to the 4 day Follow-Up
        d = $('<input type="checkbox" id="UrCommentAddReplyInstructions" Title="Adds Reply Instructions to each 4 day reply including a link to the user request with the UR layer enabled. (The link Waze sends doesn’t have the layers enabled and people have a hard time figuring it out) NOTE the 4 day reminder link will be taken from your current map view and zoom. So center the pin and set a zoom that makes sense also try to only show one pin before clicking 4 day reminder comment!" style="margin:0px 0px 0px; vertical-align: middle;font-size: 12px;"></input><font style="font-size: 12px;"> Add Instructions to the 4 day Follow Up</font><br>');
        $("#sidepanel-Comments").append(d);
        //create the callback function
        document.getElementById("UrCommentAddReplyInstructions").addEventListener("change", AddReplyInstructions, false);

        //Auto Click open solved not Identified 
        d = $('<input type="checkbox" id="URCommentAutoClickURStatus" Title="Suppress the message about recent pending questions to the reporter and then depending on the choice set for that comment Clicks Open, Solved, Not Identified." style="margin:0px 0px 0px; vertical-align: middle;font-size: 12px;"></input><font style="font-size: 12px;"> Auto Click Open, Solved, Not Identified</font><br>');
        $("#sidepanel-Comments").append(d);
        //create the callback function
        document.getElementById("URCommentAutoClickURStatus").addEventListener("change", AutoClickURStatus, false);

        //UrCommentSaveAfterComment
        d = $('<input type="checkbox" id="UrCommentSaveAfterComment" Title="If Auto Click Open, Solved, Not Identified is also checked, this option will click the save button after clicking on a UR-Comment and then the send button." style="margin:0px 0px 0px; vertical-align: middle;font-size: 12px;"></input><font style="font-size: 12px;"> Auto Save UR After Comment</font><br>');
        $("#sidepanel-Comments").append(d);
        //create the callback function
        document.getElementById("UrCommentSaveAfterComment").addEventListener("change", SaveAfterComment, false);

        //auto close after sending comment replies
        d = $('<input type="checkbox" id="UrCommentAutoCloseComment" Title="For the user requests that do not require saving this will close the user request after clicking on a UR-Comment and then the send button." style="margin:0px 0px 0px; vertical-align: middle;font-size: 12px;"></input><font style="font-size: 12px;"> Auto Close Comment</font><br>');
        $("#sidepanel-Comments").append(d);
        //create the callback function
        document.getElementById("UrCommentAutoCloseComment").addEventListener("change", AutoCloseComment, false);

        //auto reload map after sending comment replies
        d = $('<input type="checkbox" id="UrCommentAutoReloadAfterComment" Title="Reloads the map after clicking on a UR-Comment and then send button. This forces URO+ to re-apply the chosen URO filters. Currently this does not apply to any messages that get saved. Since saving automatically reloads the map." style="margin:0px 0px 0px; vertical-align: middle;font-size: 12px;"></input><font style="font-size: 12px;"> Auto Reload map After Comment</font><br>');
        $("#sidepanel-Comments").append(d);
        //create the callback function
        document.getElementById("UrCommentAutoReloadAfterComment").addEventListener("change", AutoReloadAfterComment, false);

        //zoom out map after sending comment replies
        d = $('<input type="checkbox" id="UrCommentZoomOutAfterComment" Title="Zooms the map all the way out after clicking on a UR-Comment then clicking send." style="margin:0px 0px 0px; vertical-align: middle;font-size: 12px;"></input><font style="font-size: 12px;"> Auto Zoom Out After Comment</font><br>');
        $("#sidepanel-Comments").append(d);
        //create the callback function
        document.getElementById("UrCommentZoomOutAfterComment").addEventListener("change", ZoomOutAfterComment, false);



        //page loading set options to last state

        //OnlyMyUR have the predefined pre-sets only show comments that the current user has commented on
        if (localStorage.getItem('OnlyMyUR') == "yes" || !localStorage.getItem('OnlyMyUR')) {
            //alert("YES");
            $(document.getElementById("URCommentUROOnlyMyUR")).trigger('click');
        }

        //post reply Instructions to comments
        if (localStorage.getItem('AddReplyInstructions') == "yes" || !localStorage.getItem('AddReplyInstructions')) {
            //alert("YES");
            $(document.getElementById("UrCommentAddReplyInstructions")).trigger('click');
        }

        // UR-Comments load and set settings and checkboxes  

        if (localStorage.getItem('UrCommentAutoCloseComment') == "yes" || !localStorage.getItem('UrCommentAutoCloseComment')) {
            //alert("YES");
            $(document.getElementById("UrCommentAutoCloseComment")).trigger('click');
        }

        if (localStorage.getItem('AutoReloadAfterComment') == "yes" || !localStorage.getItem('AutoReloadAfterComment')) {
            //alert("YES");
            $(document.getElementById("UrCommentAutoReloadAfterComment")).trigger('click');
        }

        // UR-COmments load and set settings and checkboxes  
        if (localStorage.getItem('AutoClickURStatus') == "yes" || !localStorage.getItem('AutoClickURStatus')) {
            //alert("YES");
            $(document.getElementById("URCommentAutoClickURStatus")).trigger('click');
        }

        //  UrCommentSaveAfterComment
        if (localStorage.getItem('SaveAfterComment') == "yes" || !localStorage.getItem('SaveAfterComment')) {
            //alert("YES");
            $(document.getElementById("UrCommentSaveAfterComment")).trigger('click');
        }

        //AutoZoomOutAfterComment
        // UR-COmments load and set settings and checkboxes  
        if (localStorage.getItem('ZoomOutAfterComment') == "yes" || !localStorage.getItem('ZoomOutAfterComment')) {
            //alert("YES");
            $(document.getElementById("UrCommentZoomOutAfterComment")).trigger('click');
        }

        //go over  BoilerPlateCreatorsArray and generate the select   
        d = '<font style="font-size: 12px;">Comment List <select id="BoilerPlateCreators" style="font-size 12px; title"Comments lists that are built into the script with support for a custom list. If you would like your comment list built into the this script or have suggestions on mine please contact me at rickzabel @waze or @gmail">';
        for (var i = 0; i < BoilerPlateCreatorsArray.length; i = i + 1) {
            console.log("URComments - make div for - " + BoilerPlateCreatorsArray[i]);
            //var d = $('<div style="margin:1px;"><a id="URComments-comment' + i + '" class="URComments" style="float:none;color:#000000" Title="123">' + BoilerPlateCreatorsArray[ i ] + '</a></div>');  
            d = d + '<option style="font-size 12px;" value="' + BoilerPlateCreatorsArray[i] + '">' + BoilerPlateCreatorsArray[i] + '</option>';
            console.log("URComments - BoilerPlateCreatorsArray " + BoilerPlateCreatorsArray[i]);
        }
        d = d + "</select> </font><br><br>";
        $("#sidepanel-Comments").append(d);
        //create call back for the select
        //document.getElementById('URComments-comment' + CurrentIndex).addEventListener("click", getClickFunction( BoilerPlateCreatorsArray[ i ] ,BoilerPlateCreatorsArray[ i + 1 ]), false);
        document.getElementById("BoilerPlateCreators").addEventListener("change", BoilerPlateCreatorsFunction, false);

        //set the users BoilerPlateCreators choice in the select   
        var SelectedBoilerPlateCreator = localStorage.getItem('BoilerPlateCreators');
        //alert(storedlist);
        //  if (SelectedBoilerPlateCreator != "") {
        //   } else {
        $("#BoilerPlateCreators").val(SelectedBoilerPlateCreator);

        //end getting boilerplatecreators

        console.log("URComments - Tab Complete");

    };


    //use this to save what choice is made in the list and then reload the page to change lists
    BoilerPlateCreatorsFunction = function() {
        //alert(BoilerPlateCreatorsFunction);
        alert("Ur-Comments you have chossen " + BoilerPlateCreators.value + "'s list. The page now must be reloaded to repopulate the UR-Comment tab");

        //this is how you set the select after it is filled
        // $("#BoilerPlateCreators").val("vectorspace");

        localStorage.setItem('BoilerPlateCreators', BoilerPlateCreators.value);
        //localStorage.setItem('BoilerPlateCreators', "");
        //this will reload the page
        location.reload();
    };

    getsendcommentbutton = function() {
        //console.log("URComments - click function");
        return function() {
            // PostURComment(a, b);   
        };
    };


    OnlyMyUR = function() {
        //alert("check Box clicked");

        //try to save the state of the check box
        if (URCommentUROOnlyMyUR.checked) {
            localStorage.setItem('OnlyMyUR', 'yes');
            //alert("yes");
        } else {
            localStorage.setItem('OnlyMyUR', 'no');
            //alert("no");
        }
        //alert ( localStorage.getItem('OnlyMyUR') ); 

        if (URCommentUROOnlyMyUR.checked && !_cbHideAnyComments.checked) {

            $(document.getElementById("_cbHideAnyComments")).trigger('click');

        } else if (!URCommentUROOnlyMyUR.checked && _cbHideAnyComments.checked) {

            $(document.getElementById("_cbHideAnyComments")).trigger('click');

        }

    };

    ZoomOutButton = function() {
        URCommentZoomOut();
    };

    AutoClickURStatus = function() {
        //alert("check Box clicked");

        //try to save the state of the check box
        if (URCommentAutoClickURStatus.checked) {
            localStorage.setItem('AutoClickURStatus', 'yes');
            //alert("yes");
        } else {
            localStorage.setItem('AutoClickURStatus', 'no');
            //alert("no");

            //turn off save after send
            if (!URCommentAutoClickURStatus.checked && UrCommentSaveAfterComment.checked) {
                // $(document.getElementById("UrCommentSaveAfterComment")).trigger('click');
                document.getElementById("UrCommentSaveAfterComment").checked = false;
                localStorage.setItem('SaveAfterComment', 'no');
            }

        }
        //alert ( localStorage.getItem('AutoClickURStatus') ); 




    };


    SaveAfterComment = function() {
        //alert("check Box clicked");

        //try to save the state of the check box
        if (UrCommentSaveAfterComment.checked) {
            localStorage.setItem('SaveAfterComment', 'yes');
            //alert("yes");
        } else {
            localStorage.setItem('SaveAfterComment', 'no');
            //alert("no");
        }
        //alert ( localStorage.getItem('AutoClickURStatus') ); 

        //when save if on turn on auto click status
        if (UrCommentSaveAfterComment.checked && !URCommentAutoClickURStatus.checked) {

            //$(document.getElementById("URCommentAutoClickURStatus")).trigger('click');
            document.getElementById("URCommentAutoClickURStatus").checked = true;
            localStorage.setItem('AutoClickURStatus', 'yes');
        }



    };

    AutoCloseComment = function() {
        //alert("check Box clicked");

        //try to save the state of the check box
        if (UrCommentAutoCloseComment.checked) {
            localStorage.setItem('UrCommentAutoCloseComment', 'yes');
            //alert("yes");
        } else {
            localStorage.setItem('UrCommentAutoCloseComment', 'no');
            //alert("no");
        }
        //alert ( localStorage.getItem('UrCommentAutoCloseComment') ); 

    };



    // UrCommentAutoReloadAfterComment
    AutoReloadAfterComment = function() {
        //alert("check Box clicked");

        //try to save the state of the check box
        if (UrCommentAutoReloadAfterComment.checked) {
            localStorage.setItem('AutoReloadAfterComment', 'yes');
            //alert("yes");
        } else {
            localStorage.setItem('AutoReloadAfterComment', 'no');
            //alert("no");
        }
        //alert ( localStorage.getItem('AutoReloadAfterComment') ); 

    };


    // UrCommentAutoReloadAfterComment
    ZoomOutAfterComment = function() {
        //alert("check Box clicked");

        //try to save the state of the check box
        if (UrCommentZoomOutAfterComment.checked) {
            localStorage.setItem('ZoomOutAfterComment', 'yes');
            //alert("yes");
        } else {
            localStorage.setItem('ZoomOutAfterComment', 'no');
            //alert("no");
        }
        //alert ( localStorage.getItem('ZoomOutAfterComment') ); 

    };


    //UrCommentAddReplyInstructions
    //add reply inscrutions to replies
    AddReplyInstructions = function() {
        //alert("UrCommentAddReplyInstructions check Box clicked");

        //try to save the state of the check box
        if (UrCommentAddReplyInstructions.checked) {
            localStorage.setItem('AddReplyInstructions', 'yes');
            //alert(" AddReplyInstructions yes");
        } else {
            localStorage.setItem('AddReplyInstructions', 'no');
            //alert("AddReplyInstructions no");
        }
        //alert ( localStorage.getItem('AutoReloadAfterComment') ); 

    };


    //on click pass text to the PostURComment function
    getClickFunction = function(Title, Comment, URStatus) {
        //console.log("URComments - click function");
        return function() {
            PostURComment(Title, Comment, URStatus);
        };
    };


    function URCommentSendBtnClicked(Title, URStatus) {

        console.log("URComments - URCommentSendBtnClicked " + Title + " " + URStatus);
        return function() {

            //look for close btn
            var x = document.getElementsByClassName("close-button");
            //alert( x.length );
            //go trough all of the eletemnts that match the requested class
            for (var i = 0, j = x.length; i < j; i++) {
                // alert(i + " - " + x[i].innerHTML);
                var btnHtml = (i + " - " + x[i].innerHTML);
                //alert (btnHtml);
                if (btnHtml.indexOf("<span>Close</span>") > -1) {

                    //waze is weird and after clicking send the close button had to be refound, which takes a few seconds for the new close button to be found
                    // so we wait 1500 miliseconds before looking for the close button
                    //since we are passing vars to the next function we have to pass this to handler function so it doesnt happen on click
                    setTimeout(CloseDelayhack1(Title, URStatus), 1500);

                }
            }
        };


    }


    //on click pass text to the PostURComment function
    //we have to have an event handler so close delay hack doesn't launch right away
    CloseDelayhack1 = function(Title, URStatus) {
        console.log("URComments - CloseDelayhack1 " + Title + " " + URStatus);
        return function() {

            if ($(".new-comment-text").val() != "") {
                console.log('URComments - Waiting for the comment to send...');
                setTimeout(CloseDelayhack1(Title, URStatus), 500);
            } else {
                CloseDelayHack2(Title, URStatus);
            }

        };


    };

    function CloseDelayHack2(Title, URStatus) {
        console.log("URComments - CloseDelayhack2 " + Title + " " + URStatus);
        // alert(Title + " + " + URStatus);
        //now that we found the new close button and send was clicked

        //lets check if we should click close or save
        //option to save ur after clicking a choice
        //& Title != "Fixed" & Title != "7th day With No Response" & Title != "Thanks for the reply"

        //switch this to look for urstatus "solved", or "NotIdentified"
        //when clicking save you dont need to click close
        //when not saving you have to click close.


        //need to give the ur time to send the comment i am thinking a loop that keeps reading the text out of the comments box
        //and when it is not the comment then we can click close. we should wait for both save and no-save comments



        //alert($(".new-comment-text").innerHTML);



        if (URStatus === "Solved" || URStatus === "NotIdentified") {
            console.log("URComments - CloseDelayhack2 solved or NotIdentified");
            //this clicks the waze save btn
            if (URCommentAutoClickURStatus.checked === true && UrCommentSaveAfterComment.checked === true) {
                //alert("URComments - clicking save");

                //click save
                //class="toolbar-button WazeControlSave ItemInactive"
                // $(document.getElementsByClassName('toolbar-button WazeControlSave')).trigger('click');

                // alert(Title);
                var x = document.getElementsByClassName("WazeControlSave");
                //this clicks x0 in our case it is the reload button for the maps
                x[0].click();
            }

        } else {
            //alert("close");
            console.log("URComments - CloseDelayhack2 else");
            if (UrCommentAutoCloseComment.checked) {
                console.log("URComments - CloseDelayhack2 auto close option checked");
                //alert("ppp");
                var x = document.getElementsByClassName("close-button");
                //alert( x.length );
                //go trough all of the eletemnts that match the requested class
                for (var i = 0, j = x.length; i < j; i++) {
                    // alert(i + " - " + x[i].innerHTML);
                    var btnHtml = (i + " - " + x[i].innerHTML);
                    //alert (btnHtml);
                    if (btnHtml.indexOf("<span>Close</span>") > -1) {
                        //alert("clse btn found");

                        console.log("URComments found close button at #" + i + " - " + x[i].innerHTML);
                        //click the close button
                        x[i].click();
                    }

                    //auto reload map for non save urs
                    //setTimeout(URCommentAutoReloadMapOnComment, 500);


                    //close btn
                    // x[i].addEventListener("click", URCommentCloseBtnClicked, true);
                }



                //since saving above reloads the map we need this reload only to happen when we dont click save
                //so we are in the else after checking for saving or no saving

                //auto reload map for non save urs
                if (UrCommentAutoReloadAfterComment.checked) {
                    setTimeout(URCommentAutoReloadMapOnComment, 500);
                }
            }


            
        }
		console.log("URComments - end of saving or closing comment");
        /*
		// doing this made the whole process look like it froze. since we can zoom out while we are waiting for the comment to post before closing, 
		//I am putting this back to on clicking send
		//lets try auto zooming check and zoom here!
		                //zoomout option
                if (UrCommentZoomOutAfterComment.checked === true) {
				//alert("zooming out");
                    //click zoom out (-) button 10 times
					for (var i = 0; i < 9; i++) {
					
						//$(document.getElementById("OpenLayers.Control.PanZoomBar_116_zoomout")).trigger('click');
						
						 $(".zoom-minus-button").trigger('click');
					}
					//alert($(document.getElementById("OpenLayers.Control.PanZoomBar_116_zoomout")));
                }
		*/

    }


    function URCommentZoomOut() {
        //click the zoom out button 10 times

        //click zoom out (-) button 10 times
        for (var i = 0; i < 9; i++) {
            //waze change the name to 108 i am going to test using the class name instead in hopes they leave it alone
            //$(document.getElementById("OpenLayers.Control.PanZoomBar_116_zoomout")).trigger('click');
            $(".zoom-minus-button").trigger('click');
        }

    }

    function URCommentCloseBtnClicked() {
        //reload map event handler so reload doesnt launch right away
        setTimeout(URCommentAutoReloadMapOnComment, 500);
    }


    function URCommentAutoReloadMapOnComment() {
        //waze / uro /this script together is buggy i have to close the comment window before reloading the map or the pin ends up getting stuck on for all URO filters and it takes a page reload to fix it.
        // to get uro to rescan urs that have been commented on you have to reload the map

        //look for the map reload button
        var x = document.getElementsByClassName("icon-repeat reload-button");

        //click the reload button for the map
        x[0].click();
    }



    //over ride the default action of confirm by writing standard confirm to a new function nconfirm, makeing a 'fake' confirm and then restoring confirm by copying the nconfirm back over confirm!

    //Definition of global attached to window properties 
    URcommentConfirmToConsole = function(a) {
        (function() {
            nconfirm = window.confirm;
            Type = {
                native: 'native',
                custom: 'custom'
            };
        })();

        /**
         * Factory method for calling confirm().
         * It will be call a native confirm() or a custom redefined confirm() by a Type param.
         * This definition need for IE
         */
        (function(proxy) {

            proxy.confirm = function() {
                var message = (!arguments[0]) ? 'null' : arguments[0];
                var type = (!arguments[1]) ? '' : arguments[1];

                if (type && type == 'native') {
                    nconfirm(message);
                } else {
					return true;
                    console.log('URComment confirm redirected to console: ' + message);
                }
            };
        })(this);
    };

    URcommentRestoreConfirmToConfirm = function(a) {
        (function() {
            window.confirm = nconfirm;
            Type = {
                native: 'native',
                custom: 'custom'
            };
        })();
    };

    PostURComment = function(Title, Comment, URStatus) {

        //this is a good area to test code sice it can be launched by clicking any of the comments


        /*
	if ($(".new-comment-text").val() === "") {
		alert($(".new-comment-text").val());
	}
	*/
        /*
	var waitcount = 0;
	do {
		waitcount++;
		console.log('URComments - Waiting for the comment to send ' + waitcount);
	}
	while ($(".new-comment-text").val() != "");
	*/



        // the user clicked on a comment link
        //look for the send button
        var x = document.getElementsByClassName("btn-default");
        //go trough all of the elements that match the requested class
        for (var i = 0, j = x.length; i < j; i++) {
            var btnHtml = (i + " - " + x[i].innerHTML);
            //alert (btnHtml);
            if (btnHtml.indexOf("Send") > -1) {
                //alert("send button found");
                //console.log("URComments Send button fount at #" + i + " - " + x[i].innerHTML);
                //send btn found

                //if the user option is set to reload map after posting a comment reply

                //here we are getting ready to reload the maps after clicking a urcomment reply then send then close.

                //it does not work if i reload after clicking send (the ur gets stuck untill a page reload), or clicking send then close (wont reload),

                //autoReload option
                // if (UrCommentAutoReloadAfterComment.checked == true & Title != "Fixed" & Title != "7th day With No Response" & Title != "Thanks for the reply") {

                //we will need to add all options to send button clicked and then add ifs there :(
                //if (UrCommentAutoReloadAfterComment.checked === true) {

                //add event listener for most options
                x[i].addEventListener("click", URCommentSendBtnClicked(Title, URStatus), false);
                // }


                //zoomout option
                if (UrCommentZoomOutAfterComment.checked === true) {
                    x[i].addEventListener("click", URCommentZoomOut, true);
                }

            }
        }

        if ($(".new-comment-text")[0]) {
            //alert(UrCommentAddReplyInstructions.checked);

            //alert("reply insc");
            if (UrCommentAddReplyInstructions.checked === true && Title === "4 day Follow-Up") {
                //reply instructions


                var href = $('.WazeControlPermalink a').attr('href');
                var lon = getQueryString(href, 'lon');
                var lat = getQueryString(href, 'lat');
                var zoom = parseInt(getQueryString(href, 'zoom'));
                var layers = "&layers=1797"; //this should have on; sat maps, roads, user requests, edit area, live editors
                //zoom = zoom > 5 ? 17 : zoom + 12;
                // https://www.waze.com/livemap?lon=-40.94918&lat=-18.56958&zoom=7
                //alert(mapsUrl);	

                //wrap the zoom level in logic to confirm that we are not zoomed way out on accident
                // set the confirm to false so we can reuse the varible
                var r = false;
                //zoom 4 seems like the furthest out we would ever need to send a link to
                if (zoom > 3) {
                    r = true;
                } else {
                    //promt the user
                    var r = confirm("UR Comments!\nThe map's zoom level is at " + zoom + " are you sure you want to send the user a link to the map with this zoom level? Remember to center the pin in your map window before clicking 4-day reminder.");

                }
                //this is where we reuse the r var this makes the nested ifs much more simple
                if (r == true) {
                    var mapsUrl = 'https://www.waze.com/editor/?' + lon + '&lat=' + lat + layers + '&zoom=' + zoom;
                    console.log('URComments - ReplyInstructions - ' + ReplyInstructions + mapsUrl);
                    $(".new-comment-text").val(Comment + "\r\n\r\n" + ReplyInstructions + "\r\n" + mapsUrl);
                } else {
                    //user chose no lets clear the text area just in case there was 4 day from before
                    $(".new-comment-text").val("");
                }


            } else {
                //comment only
                console.log('URComments - comment only');
                console.log('URComment set comment box to "' + Title + ' - "' + Comment + '"');
                $(".new-comment-text").val(Comment);
            }

            if (URCommentAutoClickURStatus.checked === true) {
                //alert(URStatus);

                //redirect confirm function
                URcommentConfirmToConsole();

                //click the ur status options open,closed, Not identified
                //2 cases to check for; #1. fixed and thanks and #2. 7th day close

                //click Not identified
                // if (Title == "7th day With No Response") {
                if (URStatus == "NotIdentified") {
                    $(document.getElementById('state-1')).trigger('click');
                    //click a second time because of the way we are bypassing the confirm the site treats it as a cancel, but i noticed it only asks one time
                    //setTimeout($(document.getElementById('state-1')).trigger('click'), 500);
                    //$(document.getElementById('state-1')).trigger('click');
                    // } else if (Title == "Fixed" || Title == "Thanks for the reply") {
                } else if (URStatus == "Solved") {
                    //click solved
                    $(document.getElementById('state-0')).trigger('click');
                    //click a second time because of the way we are bypassing the confirm the site treats it as a cancel, but i noticed it only asks one time
                    //setTimeout($(document.getElementById('state-0')).trigger('click'), 500);
                } else {
                    //click back on open just encase the wrong reply was clicked
                    $(document.getElementById('state--1')).trigger('click');
                }

                //restore confirm function so other site messages come up!
                URcommentRestoreConfirmToConfirm();

            }


        } else {
            alert("Can not find the comment box! In order for this scrip to work you need to have a user request open");
        }
    };



    function getQueryString(link, name) {
        var pos = link.indexOf(name + '=') + name.length + 1;
        var len = link.substr(pos).indexOf('&');
        if (-1 == len) len = link.substr(pos).length;
        return link.substr(pos, len);
    }



    URComments.startcode = function() {
        // Check if WME is loaded, if not, waiting a moment and checks again. if yes init URComments
        try {
            //look for the me tab instead if the buggy chat room!           
            var element = document.getElementById('user-details');
            console.log("URComments - Found user-details window");
            if (typeof element !== "undefined" && element.value !== '') {

                //if ("undefined" != typeof unsafeWindow.W.model.chat.rooms._events.listeners.add[0].obj.userPresenters[unsafeWindow.Waze.model.loginManager.user.id] ) {

                //check for the comment area
                //  if ($(".new-comment-text")[0]){  
                //console.log("URComments To Add Comment Tab");
                URComments.init();
            } else {
                setTimeout(URComments.startcode, 2000);
            }
        } catch (err) {
            //alert("URComments - " + err);
            console.log("URComments - " + err);

            if (err === "TypeError: element is null" || err === "TypeError: element is null") {
                //alert("URComments - page loading slow");
                setTimeout(URComments.startcode, 2000);
            }
            setTimeout(URComments.startcode, 2000);
        }

    };

    //setTimeout(URComments.startcode, 2000);
    URComments.startcode();
}
setTimeout(URComments_bootstrap, 2000);
//URComments_bootstrap();  



/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
////
////    URO Preset Filters
////   
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


window.URCommentUROClicked = function(a) {
    return function() {
        URCommentUROClearClicked(a);
    };
};

URCommentUROClearClicked = function(a) {
    // alert(a);


    if ($("#sidepanel-uroverview").length) {
        //alert("test");

        console.log("URComments - URO clear");
        //this is the array used to store the URO id tags

        var URCommentUROCheckboxesArray = ["_cbFilterWazeAuto",
            "_cbFilterIncorrectTurn",
            "_cbFilterIncorrectAddress",
            "_cbFilterIncorrectRoute",
            "_cbFilterMissingRoundabout",
            "_cbFilterGeneralError",
            "_cbFilterTurnNotAllowed",
            "_cbFilterIncorrectJunction",
            "_cbFilterMissingBridgeOverpass",
            "_cbFilterWrongDrivingDirection",
            "_cbFilterMissingExit",
            "_cbFilterMissingRoad",
            "_cbFilterBlockedRoad",
            "_cbFilterMissingLandmark",
            "_cbFilterUndefined",
            "_cbFilterCryosphere",
            "_cbFilterRoadworks",
            "_cbFilterConstruction",
            "_cbFilterClosure",
            "_cbFilterEvent",
            "_cbFilterNote",
            "_cbInvertURFilter",
            "_cbFilterOpenUR",
            "_cbFilterClosedUR",
            "_cbFilterSolved",
            "_cbFilterUnidentified",
            "_cbEnableMinAgeFilter",
            "_cbEnableMaxAgeFilter",
            "_cbURDescriptionMustBePresent",
            "_cbURDescriptionMustBeAbsent",
            "_cbEnableKeywordMustBePresent",
            "_cbEnableKeywordMustBeAbsent",
            "_cbCaseInsensitive",
            "_cbHideMyComments",
            "_cbHideAnyComments",
            "_cbHideIfLastCommenter",
            "_cbHideIfNotLastCommenter",
            "_cbHideIfReporterLastCommenter",
            "_cbHideIfReporterNotLastCommenter",
            "_cbEnableMinCommentsFilter",
            "_cbEnableMaxCommentsFilter",
            "_cbHideMyFollowed",
            "_cbHideMyUnfollowed",
            "_cbEnableCommentAgeFilter2",
            "_cbEnableCommentAgeFilter",
            "_cbNoFilterForTaggedURs"

        ];

        //go over the array and clear all of the URO+ check boxes
        for (URCommentsIndex = 0; URCommentsIndex < URCommentUROCheckboxesArray.length; URCommentsIndex = URCommentsIndex + 1) {
            //document.getElementById(URCommentUROCheckboxesArray[ URCommentsIndex ]).trigger('click');
            if ($(document.getElementById(URCommentUROCheckboxesArray[URCommentsIndex])).is(":checked")) {
                //clicks the checkbox by if the checkbox is checked
                $(document.getElementById(URCommentUROCheckboxesArray[URCommentsIndex])).trigger('click');
            } else {
                //click check box if checkbox in unchecked
                //$(document.getElementById(URCommentUROCheckboxesArray[ URCommentsIndex ])).trigger('click');
            }
        }

        if (a === "UROclearUROFiltrs" && URCommentUROOnlyMyUR.checked) {
            URCommentUROOnlyMyUR.checked
            $(document.getElementById("URCommentUROOnlyMyUR")).trigger('click');
        }

        /*  
  UroShowNew

     URO4DayFollowUp
        URO7DayClose
        UROclearUROFiltrs
        */

        //set the different filters here      
        if (a == "UROclearUROFiltrs") {
            //alert("URO+ UR filters hav been cleared");
        } else {

            if (a == 'UroShowNew') {
                console.log("URComments - URO show new");
                //alert("new");
                //set URO+ max user comments to zero
                //document.getElementById('_inputFilterMaxComments').value = '0';
                //check the box for more than # comments
                //$(document.getElementById("_cbEnableMaxCommentsFilter")).trigger('click');
                //set URO+ max user comments to zero

                //check the box for last user  comments
                $(document.getElementById("_cbHideIfReporterNotLastCommenter")).trigger('click');
            }

            if (a == "URO4DayFollowUp") {
                console.log("URComments - URO 4 day");

                document.getElementById('_inputFilterMinComments').value = '1';
                $(document.getElementById("_cbEnableMinCommentsFilter")).trigger('click');

                document.getElementById('_inputFilterMaxComments').value = '1';
                $(document.getElementById("_cbEnableMaxCommentsFilter")).trigger('click');

                document.getElementById('_inputFilterCommentDays2').value = '4';
                $(document.getElementById("_cbEnableCommentAgeFilter2")).trigger('click');

                document.getElementById('_inputFilterCommentDays').value = '6';
                $(document.getElementById("_cbEnableCommentAgeFilter")).trigger('click');

            }

            if (a == "URO7DayClose") {
                console.log("URComments - URO 7 day");

                document.getElementById('_inputFilterMinComments').value = '1';
                $(document.getElementById("_cbEnableMinCommentsFilter")).trigger('click');

                document.getElementById('_cbEnableMaxCommentsFilter').value = '1';
                $(document.getElementById("_cbEnableCommentAgeFilter")).trigger('click');

                document.getElementById('_inputFilterCommentDays2').value = '7';
                $(document.getElementById("_cbEnableCommentAgeFilter2")).trigger('click');

                document.getElementById('_inputFilterCommentDays').value = '7';
                $(document.getElementById("_cbEnableCommentAgeFilter")).trigger('click');

            }


            if (URCommentUROOnlyMyUR.checked) {
                // _cbHideIfReporterNotLastCommenter
                $(document.getElementById("_cbHideAnyComments")).trigger('click');
            }


        }
    } else {
        alert("UR Overview Plus (URO+) needs to be installed to use these URO Presets.");
    }
};

URCommentURONewClicked = function() {
    console.log("URComments - URCommentURONewClicked");
    document.getElementById("_cbFilterWazeAuto").checked = true;
    element.attributeName = 'value';
};


//Notes

/*
//change the tag data of an element by class
var x = document.getElementsByClassName("slider");
//alert( x.length );
//go trough all of the eletemnts that match the requested class
for(var i = 0, j=x.length; i<j; i++){
    
    var btnHtml = (0 + " - " + x[i].innerHTML);
    alert (btnHtml);
    
    //this if doent matach the slider type but i am leaving it for future documentation
    if(btnHtml.indexOf("<span>Close</span>") > -1) {
        
        //change the tag data of an element by class
        //x[i].style.top = "125px";
        
    }
}
*/