Sublime Text parse error default(windows).sublime-keymap.2:52 - javascript

Sublime Text 2 wouldn't open. I kept getting this error:
(Error trying to parse file: Unexpected character, expected a comma or closing
bracket in c:\Users\adeleon\AppData\Roaming\Sublime Text 2\Packages\
Default (Windows).sublime-keymap.2:52)
I found the file and put it into JSON Lint. I got this error.
Expecting 'EOF', got ','
The validator says that the problem is on line 2 of the code. I do not see any missing curly brackets. Would somebody please tell me what I am overlooking?
The link to the code is below.
https://github.com/alexwebcoder/jsonFile/blob/master/ff.txt

I think you are missing an open bracket ([) at the very beginning of the code.

Related

How do I create line breaks in JavaScript?

I am using some code I found on this site and need to know how to insert a line break instead of a comma.
I have tried using \n as follows:
if(flg>0){
app.alert('There are '+flg+' fields that require a value\n\n'**+ fArr,3**)
}
But keep getting a syntax error. What am I doing wrong?
Adding the following text:
"\n"
on where you want the line break, definitely causes a line break. E.g. onclick="alert('Hi \n How are you?')"
You may be getting a syntax error because how you've entered asterisks. Try wrapping them with quotation marks too?
\n is what you require to get a line break and is correct. Your syntax error occurs because alert('There are '+flg+' fields that require a value\n\n'**+ fArr,3**) is not a valid method - unless you have overwritten it, alert() is a method that only takes one argument - a string.
'There are '+flg+' fields that require a value\n\n'**+ fArr,3** is not a valid string. Try instead 'There are '+flg+' fields that require a value\n\n**'+ fArr+',3**'.

selenium IDE javascript replace: Throw an exception: missing ; before statement

I wrote a test using selenium IDE, I need to compare two text that MAY contain the
character, if the strings are equal, it skips to a label. the comparison command
<td>gotoIf</td>
<td>'${var1}'=='${var2}'</td>
<td>skip</td>
works if the character above is not there, but fails with
[error] Threw an exception: missing ; before statement` otherwise
I tried to write a replace statement supposed to replace ' with a blank space (since I don't care if is there or not):
<td>storeEval</td>
<td>javascript{storedVars.var1.replace("\'"," ");}</td>
<td>var1</td>
but it always fails with the same error as above.
what am I missing? can anyone help me?
I took user extension js from here. Can you try with double quote instead of single quote in gotoIf command? It works for me. Please refer my screenshot below.
<td>gotoIf</td>
<td>"${var1}"=="${var2}"</td>
<td>skip</td>

Javascript Newline Character Throwing Error

I am having trouble getting some data from a textbox using javascript. What I am trying to do is take the value from a textbox and put it in an alert and copy it. Here is the code that I currently have:
var copyString = "Date: <%= TXT_Details_DateReq.Text %>;
window.prompt('Press CTRL+C, then ENTER\n\nNOTE: SAVE ANY CHANGES BEFORE COPYING TEXT!', copyString); return false;
So this code works perfectly fine if the text in the textbox is just one line. But if the text in the textbox has multiple lines such as:
"This is one line
here is a second line"
The code will throw the error Uncaught Syntax Error: Unexpected Token ILLEGAL.
From what I have researched this throws when there is an illegal character, so I believe it is the CRLF character from the textbox.
Any idea how to fix this?
Thanks.
New line characters might be preceded by return characters ('\r').
Swap '\n' with '\r\n' and you should be good to go.
Or even better: just handle all cases of the new line character instead of checking which case then applying it. This replace the newline:
htmlstring = stringContainingNewLines.replace(/(\r\n|\n|\r)/gm, "<br>");
Resource
hope it helps.

add class to parent on click with jQuery

I currently have this, it was working in jsFiddle, though its giving me errors, and not working when I use it outside of fiddle.
$('.down-photo').click(function() {
$(this).parent('.img-mask').toggleClass('hide');
});​
Firebug says:
Uncaught SyntaxError: Unexpected Token ILLEGAL
I'm newer to javascript and jQuery so I'm not sure what's wrong or what that error means.
Thanks!
In the code in your question there is a non-printing character after the last semicolon. It seems to be character 8203, a Unicode zero-width space. That's the illegal token that Firebug is telling you about.
You'll notice, if you edit the text in your question, that if you put the cursor to the left of that last semicolon and then press the right arrow a few times it takes one more keypress than you'd expect to get to the next line - that's the character I mean.
Delete that character, or manually retype the line (rather than copy/pasting), and it should be fine.
I fixed your error. $.appendTo() takes a selector, not a jquery object.
Try this:
http://jsfiddle.net/dvCmR/133/ (line 4)

jQuery illegal character showing up when trying to add jQuery and bootstrap

The illegal characters seem to be in Japanese? How did this happen?
here is my blank html with jQuery/bootstrap included, firebug gives me:
illegal character line 1 jQuery..min.js
...潡琨昮捳猨愬挫扸孥崩⥼簰⤻牥瑵牮⁤⬢灸≽晵湣瑩潮⁢漨愩筶慲⁢㵣⹣牥慴故汥浥湴⠢摩瘢⤻扨⹡灰敮摃桩汤⡢⤬戮楮湥版呍䰽愮潵瑥版呍䰻牥瑵牮⁢⹦楲獴䍨楬摽晵湣瑩潮⁢渨愩...
Server response begins with 2 "strange" characters before the DOCTYPE declaration (U+02C7 and U+02DB)

Categories

Resources