Note that there are some explanatory texts on larger screens.

plurals
  1. POdecode hex js in Drupal
    primarykey
    data
    text
    <p>I know I am missing something simple but cannot figure it out so I will ask the experts.</p> <p>In Drupal through Jquery and hook_menu and ajax I end up with this string:</p> <pre><code>\x3cform action=\"/comment/reply/1360\" accept-charset=\"UTF-8\" method=\"post\" id=\"comment-form\" class=\"ajax-form\"\x3e\n\x3cdiv\x3e\x3cdiv class=\"form-item\"\x3e\n \x3clabel\x3eYour name: \x3c/label\x3e\n \x3ca href=\"/users/testuser1\" title=\"View user profile.\"\x3etestuser1\x3c/a\x3e\n\x3c/div\x3e\n\x3cdiv class=\"form-item\" id=\"edit-comment-wrapper\"\x3e\n \x3clabel for=\"edit-comment\"\x3eComment: \x3cspan class=\"form-required\" title=\"This field is required.\"\x3e*\x3c/span\x3e\x3c/label\x3e\n \x3ctextarea cols=\"60\" rows=\"15\" name=\"comment\" id=\"edit-comment\" class=\"form-textarea required\"\x3e\x3c/textarea\x3e\n \x3cdiv class=\"description\"\x3eComments are limited to a maximum of \x3cem\x3e200\x3c/em\x3e characters.\x3c/div\x3e\n\x3c/div\x3e\n\x3cul class=\"tips\"\x3e\x3cli\x3eWeb page addresses and e-mail addresses turn into links automatically.\x3c/li\x3e\x3cli\x3eAllowed HTML tags: \x26lt;a\x26gt; \x26lt;em\x26gt; \x26lt;strong\x26gt; \x26lt;cite\x26gt; \x26lt;code\x26gt; \x26lt;ul\x26gt; \x26lt;ol\x26gt; \x26lt;li\x26gt; \x26lt;dl\x26gt; \x26lt;dt\x26gt; \x26lt;dd\x26gt;\x3c/li\x3e\x3cli\x3eLines and paragraphs break automatically.\x3c/li\x3e\x3c/ul\x3e\x3cp\x3e\x3ca href=\"/filter/tips\"\x3eMore information about formatting options\x3c/a\x3e\x3c/p\x3e\x3cinput type=\"hidden\" name=\"form_build_id\" id=\"form-0c4051b953791d21147f76e11c2ab7c4\" value=\"form-0c4051b953791d21147f76e11c2ab7c4\" /\x3e\n\x3cinput type=\"hidden\" name=\"form_token\" id=\"edit-form-token\" value=\"8dd5324de6e086d9412e9407eb7aba1e\" /\x3e\n\x3cinput type=\"hidden\" name=\"form_id\" id=\"edit-comment-form\" value=\"comment_form\" /\x3e\n\x3cinput type=\"submit\" name=\"op\" id=\"edit-submit\" value=\"COMMENT\" class=\"form-submit ajax-trigger\" /\x3e\n\x3cinput type=\"submit\" name=\"op\" id=\"edit-preview\" value=\"Preview\" class=\"form-submit ajax-trigger\" /\x3e\n\n\x3c/div\x3e\x3c/form\x3e\n&lt;/div&gt; </code></pre> <p>and I need it to end up as this when it is written to the div:</p> <pre><code>&lt;form action="/comment/reply/1360" accept-charset="UTF-8" method="post" id="comment-form" class="ajax-form"&gt; &lt;div&gt;&lt;div class="form-item"&gt; &lt;label&gt;Your name: &lt;/label&gt; &lt;a href="/users/testuser1" title="View user profile."&gt;testuser1&lt;/a&gt; &lt;/div&gt; &lt;div class="form-item" id="edit-comment-wrapper"&gt; &lt;label for="edit-comment"&gt;Comment: &lt;span class="form-required" title="This field is required."&gt;*&lt;/span&gt;&lt;/label&gt; &lt;textarea cols="60" rows="15" name="comment" id="edit-comment" class="form-textarea required"&gt;&lt;/textarea&gt; &lt;div class="description"&gt;Comments are limited to a maximum of &lt;em&gt;200&lt;/em&gt; characters.&lt;/div&gt; &lt;/div&gt; &lt;ul class="tips"&gt;&lt;li&gt;Web page addresses and e-mail addresses turn into links automatically.&lt;/li&gt;&lt;li&gt;Allowed HTML tags: &amp;lt;a&amp;gt; &amp;lt;em&amp;gt; &amp;lt;strong&amp;gt; &amp;lt;cite&amp;gt; &amp;lt;code&amp;gt; &amp;lt;ul&amp;gt; &amp;lt;ol&amp;gt; &amp;lt;li&amp;gt; &amp;lt;dl&amp;gt; &amp;lt;dt&amp;gt; &amp;lt;dd&amp;gt;&lt;/li&gt;&lt;li&gt;Lines and paragraphs break automatically.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;a href="/filter/tips"&gt;More information about formatting options&lt;/a&gt;&lt;/p&gt;&lt;input type="hidden" name="form_build_id" id="form-0c4051b953791d21147f76e11c2ab7c4" value="form-0c4051b953791d21147f76e11c2ab7c4" /&gt; &lt;input type="hidden" name="form_token" id="edit-form-token" value="8dd5324de6e086d9412e9407eb7aba1e" /&gt; &lt;input type="hidden" name="form_id" id="edit-comment-form" value="comment_form" /&gt; &lt;input type="submit" name="op" id="edit-submit" value="COMMENT" class="form-submit ajax-trigger" /&gt; &lt;input type="submit" name="op" id="edit-preview" value="Preview" class="form-submit ajax-trigger" /&gt; &lt;/div&gt;&lt;/form&gt; </code></pre> <p>so I wrote this:</p> <pre><code>function unjsEncode(string){ var leftCaret = /\x3c/ig; var rightCaret = /\x3e/ig; var lineBreak = /\n/ig; var escQuote = /\"/ig; var newstring = string.replace(leftCaret, "&lt;" ); newstring = newstring.replace(rightCaret, "&gt;"); newstring = newstring.replace(lineBreak, " "); newstring = newstring.replace(escQuote, '"'); return newstring; </code></pre> <p>}</p> <p>But it don't work. This is at the end of long haul figuring out how to write dynamic forms in Drupal and I feel like an idiot that I can't figure out a simple regex routine in js but after 8 hrs that is where I am. Any help in teaching me how to fish would be greatly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload