Jump to content

rain13

Members
  • Posts

    346
  • Joined

  • Last visited

Everything posted by rain13

  1. Thanks for tip. I finally got it working (almost) but it seems to be a little too greedy item.innerHTML = item.innerHTML .replace(new RegExp('"([^"]|("))*"', 'g'), "<span class="string">$&</span>"); It highlights it like that: a = "I am string for test if escaping "can 'break' it.."; b = 'I am string for test if escaping 'can "break" it..';So I found this:{x}Repeat the previous character, set or group exactly x times. but "([^"]|("))*"{1} doesn't tell it to stop at first match
  2. I tried "([^"]|("))*?" but still no effect. Could you tell me what else is wrong with it. Just wondering how much slower/faster it would work If I'd build highlighter manually by using indexOf() to find first quote and and then while loop to find next quote that is not escaped.
  3. Thanks for your reply. Just wanted be sure that my logic is right.
  4. Thanks.I still don't get what I am doing wrong. item.innerHTML = item.innerHTML .replace(new RegExp('"([^"]|(")*)?"', 'g'), "<span class="string">$&</span>");the code above is based on this example// Mimic leading, negative lookbehind like replace(/(?<!es)t/g, 'x')var output = 'testt'.replace(/(es)?t/g, function($0, $1){ return $1 ? $0 : 'x';});Edit: Could you tell me if this part of regex is correct: ([^"]|(")*)?
  5. Do you do that by sending separate request to server or do you use that same iframe to get the response?
  6. I am not quite used to regex. I am sorry to say that but I didn't really get much help from what you said.I tried to match anything that is not quote or that is escaped quote: "(([^"]|")*)(?<!)" but that didn't help. Meanwhile I also tries these: http://blog.stevenlevithan.com/archives/match-quoted-string but they didnt seem to work either.
  7. could anyone say why this regex doesn't do what I am tying to do? item.innerHTML = item.innerHTML .replace(new RegExp('"([^"]*)(?<!)"', 'g'), "<span class="string">$&</span>");source: http://www.regular-expressions.info/lookaround.htmlAlso tried this with out any resultRegExp('"([^"]*)?"', 'g')
  8. Thanks for explanation. I was just looking for different ideas/methods. Just out of curiosity how does your javascript determine if upload was success or not?
  9. Thanks for that clarification. That italic text also highlighted the idea console.log() which I missed before for some reason. Actually I didn't know about that possibility.
  10. Thanks a lot. I got it work that way. I have one extra question: whats the best way for removing iframe with deleted file from files list? I have structure like: iframe1 iframe2 ... iframenSeparate iframe for every file. And what I am currently doing is that once upload is complete I echo delete link back to user: echo "File: ". basename( $_FILES['uploaded']['name']). ' <a href="./upload.php?a=delete&file='.$id.'">delete</a>'; And when user clicks on that link I inform him about it: die("File have been successfully deleted."); But in my opinion it would look nicer if that iframe were removed instead of displaying "File have been successfully deleted." there. What's the best way of doing that? Can I make that delete link inside iframe so that it would also delete iframe itself or should I write javascript code that would check iframe contents once in every second and delete it if it contains "File have been successfully deleted."?Just looking forward to hear some thoughts/ideas on that.
  11. Hello.Could anyone give me info about file uploading? Here's my html form <form enctype="multipart/form-data" action="upload.php" method="POST">Please choose a file: <input name="uploaded" type="file" /><br /><input type="submit" value="Upload" /></form> And when I hit submit button I get the following post parameter -----------------------------31112091625756rnContent-Disposition: form-data; name="uploaded"; filename="acp.css"rnContent-Type: text/cssrnrn body {rn font: 13px arial, helvetica, sans-serif;rn }rnrntd.this {rn font: 13px arial, helvetica, sans-serif;rn }rnrn #header ul {rn list-style: none;rn padding: 0;rn margin: 0;rn }rnrn #header li {rn float: left;rn border: 1px solid #307C99;rn border-bottom-width: 0;rn margin: 0 1 0 0;rn }rnrn li.Selected {rn position: relative;rn top: 1px;rn background-color: #dbedff;rn }rnrn li.NotSelected {rn position: relative;rn top: 1px;rn background-color: #99ccff;rn }rnrn #content {rn border: 1px solid #307C99;rn clear: both;rn background-color: #dbedff;rn }rnrnTABLE,TR,TD,BODY,SELECT,INPUT,BUTTON,TEXTAREA{font-size :12px }rnrna{rn text-decoration: none;rn color: #0011ff;rn}rnrnrn-----------------------------31112091625756--rn I would like to know what's this called? 31112091625756. I guess I need to know what it is in order to generate valid post parameter. Here is javascript submitter I've made so far. Could anyone tell if there is better/easier way that does not include jQuery ? Like formObject.submit() without reloading whole page and with out having to manually write post parameter or something? function getXMLObject() //XML OBJECT{ var xmlHttp = false; try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP") // For Old Microsoft Browsers } catch (e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP") // For Microsoft IE 6.0+ } catch (e2) { xmlHttp = false // No Browser accepts the XMLHTTP Object then false } } if (!xmlHttp && typeof XMLHttpRequest != 'undefined') { xmlHttp = new XMLHttpRequest(); //For Mozilla, Opera Browsers } return xmlHttp; // Mandatory Statement returning the ajax object created}var xmlhttp = new getXMLObject(); //xmlhttp holds the ajax objectfunction Upload(action) { var getdate = new Date(); //Used to prevent caching during ajax call if(xmlhttp) { xmlhttp.open("POST","./index.php?p="+p+"&a=upload&id="+id,true); //ToServer xmlhttp.onreadystatechange = handleServerResponse; xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); var post_data = "Editor=" + txtname.value+"&title="+escape(txttitle.value); xmlhttp.send(post_data); //Posting txtname to PHP File }}
  12. Thanks for info. I'll see what can dig out. At the moment I hear both terms lookahead and lookbehind for a first time.
  13. Hello. I am trying to write very basic syntax highlighter. It has to be able to highlight strings quoted in different ways and keywords. Here is my javascript code: var codes = document.getElementsByClassName('code'); for (var i = 0; i < codes.length; ++i) { var item = codes[i]; alert(decodeHTMLEntities(item.innerHTML)); item.innerHTML = item.innerHTML .replace(new RegExp('"([^"]*)"', 'g'), "<span class="string">$&</span>"); //item.innerHTML = item.innerHTML .replace(new RegExp(keywords, 'g'), "<span class="keyword">$&</span>"); } Here is how it currently highlights: a = "I am string for test if escaping "can break it..";And this is how it should be highlighted a = "I am string for test if escaping "can break it..";I would also like to know how I could avoid highlighting keywords in string.I know there are enough ready to use highlighters available, but my intention is to get better at javascript/regex by writing at least basic one myself/with help of this forum.Would anyone be so nice and tell me how I could write regex that would do what I want it to?
  14. Thanks for info, I didn't know that. I'll take this into account.
  15. Thanks for pointing out that. Forgot to add BuildTable() here. Previous post edited in order to have example for those who have same problem. BuildTable() It just returns html. Wrong. Yes it is singlethreaded but wonce you click ok the code execution continues. http://msdn.microsoft.com/en-us/library/ms533897%28VS.85%29.aspx
  16. Ok so here is minimal code that demonstrates the problem. Run it with IE first and then with any other browser. What you can see is that in IE you will see empty page, in other browsers you would see "hello" <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <meta content="text/html; charset=UTF-8" http-equiv="content-type"> <title>Title</title></head><body><table id="BOARDSETTINGS"></table><script language="javascript" type="text/javascript">hGeneral= document.getElementById("BOARDSETTINGS");hGeneral.innerHTML = "<tr><td>hello</td></tr>";</script></body></html> And here is quick fix for IE <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <meta content="text/html; charset=UTF-8" http-equiv="content-type"> <title>Title</title></head><body><table id="BOARDSETTINGS"></table><script language="javascript" type="text/javascript">function setTBodyInnerHTML(tbody, html) { var temp = tbody.ownerDocument.createElement('div'); temp.innerHTML = '<table>' + html + '</table>'; tbody.parentNode.replaceChild(temp.firstChild.firstChild, tbody);}hGeneral= document.getElementById("BOARDSETTINGS");setTBodyInnerHTML(hGeneral,"<tr><td>hello</td></tr>")</script></body></html> Which shows that IE really is the worst nightmare of web developer.
  17. I did not have any unclosed <b> tag there but what I found was that as soon as I changed. body { font: 13px arial; } to body { font: 13px; } The bold text problem was gone.Edit: found solution: TABLE,TR,TD,BODY,SELECT,INPUT,BUTTON,TEXTAREA{font:11px Tahoma;color:#000} A little googling revealed that arial is known to be overweight with IE.Edit2:I figured the cause of my form problem too: hGeneral= document.getElementById("BOARDSETTINGS");alert("1");hGeneral.innerHTML = "<tr><td>hello</td></tr>";alert("2"); Code execution actually never reaches to alert("2"); however it does in FF.IE says: SCRIPT600: Invalid target element for this operation.acp.php?id=12&a=MANAGE_SETTINGS, line 176 character 1 however I have <table id="BOARDSETTINGS"></table> above javacript. Any ideas what might cause that?
  18. Just wondering that if there is unclosed tag, then shouldn't FF also display it all bold? See first screenshot on my previous post.
  19. Dont you see it like this:Or this difference between IE and FF (which can be only see when you look it directly from server and which somehow gets fixed as you save page to disk). I am trying to get it up somewhere more accessible place than my home computer as soon as possible, but until that all I can show you is these 2 pictures.
  20. That didn't change anything. IE still shows it bold + form still doesn't get built in IE.
  21. Thanks again Ingolme. I also figured that <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> didnt work for IE but <!DOCTYPE html> worked. Could <!DOCTYPE html> cause any problems for older browsers that doesnt support html 5? I am currently hosting it in localhost because it's easier to edit files thatway. I guess the saved page should do the same. Actually the code I posted here is already minimal code. I will upload it somewhere when I get chance to. However if you are lucky you might be able to get in http://62.65.214.232/a/lib/acp.php?id=12&a=MANAGE_SETTINGS with user: test and password: test .Here's acp.zip zip file demonstrates that with IE "Allow BBCode" and "If set to yes, bbcode will be parsed" are both bold but with firefox only "Allow BBCode" is bold (as it should be)Other problem with page attached and linked page is that with IE you will only see submit button. with firefox you will also see form itself. However when you save page and then open that saved file (from zip) then IE also shows form, but it doesn't show it when you view it directly from server.
  22. Thanks for quick response. I couldn't come up with anything better than <!DOCTYPE html>.That solved title bar problem, but font is still bold in IE. And it also removed 1px white space between tabs and now I have one 2px line between 2 tabs (its actually 2 different lines of course but it visually looks as one now).
  23. Hello.I am facing some problems with html. At the top I have firefox (and it also looks so in other browsers) and the bottom one is IE.Problem is that with IE font is bold and title bar is too tall. (almost no white space between tabs and this blue title bar.) Could anyone tell me how I could fix this please? Here is my test.css body { font: 13px arial, helvetica, sans-serif; }td.this { font: 13px arial, helvetica, sans-serif; } #header ul { list-style: none; padding: 0; margin: 0; } #header li { float: left; border: 1px solid #307C99; border-bottom-width: 0; margin: 0 1 0 0; } li.Selected { position: relative; top: 1px; background-color: #dbedff; } li.NotSelected { position: relative; top: 1px; background-color: #99ccff; } #content { border: 1px solid #307C99; clear: both; background-color: #dbedff; }TABLE,TR,TD,BODY,SELECT,INPUT,BUTTON,TEXTAREA{font-size :12px }a{ text-decoration: none; color: #0011ff;} And here is my html <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" type="text/css" href="./test.css"></head><body><div style="text-align: left; width: 100%; background-color: #99ccff"><div style="float:right; text-align: left;"><span>Some text</span></div><h1>Title</h1></div><div id="header"><ul id="TabTop"><li class="Selected"><a href="?id=1">TAB1</a></li><li class="NotSelected"><a href="?id=3">TAB2</a></li><li class="NotSelected"><a href="?id=10">TAB3</a></li><li class="NotSelected"><a href="?id=12">TAB4</a></li></ul></div><div id="content"> <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2"> <tbody> <tr> <td style="vertical-align: top; width: 200px;"> <a href="#">Link1<br></a> <a href="#">Link2<br></a> <a href="#">Link3<br></a> </td> <td style="vertical-align: top;">Sample text<br> </td> </tr> </tbody> </table></div><br></body></html> Thanks in advance.
  24. rain13

    Need help with eval

    I finally got it work. I had to use return(...); instead. My goal was to eveluat string containing only true, false and logic operators.
  25. rain13

    Need help with eval

    I am trying to eval if condition but for somereason ""itworks" never gets printed. When you call my_if(true||false); directly, it'll return true but not when you eval code.Does anyone know how to eval expression of trues and falses to get only 1 true or false? <?phpfunction my_if($cond){ return $cond;}if(eval("my_if(true||false);")){ print("itworks\n");}?> Examples (let T be true and F be false):T||T shall give TT||F shall give TT&&(T||F) shall give T since (T||F) is T therefore T &&T is T
×
×
  • Create New...