Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Find text area with jQuery and tag an ID to it

  • Loading branch information...
commit 2aea6db3eb892830382aefb3809b4a2a576bc2ff 1 parent b0bfe38
@stsquad authored
Showing with 43 additions and 20 deletions.
  1. BIN  gumdrop.png
  2. +23 −0 ta_test.html
  3. +20 −20 textareas.js
View
BIN  gumdrop.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
23 ta_test.html
@@ -0,0 +1,23 @@
+<HTML><HEAD><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<TITLE>Text Area Test</TITLE>
+<SCRIPT language="JavaScript">
+function seeTextArea (form) {
+ alert (form.myarea.value);
+
+}
+</SCRIPT>
+<STYLE></STYLE></HEAD><BODY>
+<FORM name="myform">
+<INPUT type="button" name="button3" value="Test" onclick="seeTextArea(this.form)">
+<TEXTAREA name="body" cols="40" rows="5" id="foo">
+</TEXTAREA>
+</FORM>
+
+<FORM name="myform2">
+<INPUT type="button" name="button4" value="Test" onclick="seeTextArea(this.form)">
+<TEXTAREA name="body" cols="40" rows="5" id="foo">
+</TEXTAREA>
+</FORM>
+
+
+</BODY></HTML>
View
40 textareas.js
@@ -1,37 +1,37 @@
/*
* TextArea.js
*
- * This "content" script finds TextArea's in the DOM and wraps them in
- * a unique <div> block with and edit button. When the button is
+ * This "content" script finds TextArea's in the DOM and tags them
+ * with a unique ID and edit button. When the button is
* clicked it communicates with the master extension page to send an
* edit request.
*
* This uses jQuery for handy stuff
*/
+
+var editImgURL = chrome.extension.getURL("gumdrop.png");
+var editImgTag = "<img src=\""+editImgURL+"\">";
-
+function editTextArea(edit_id) {
+ console.log("editTextArea");
+
+ alert ("Editing "+edit_id);
+}
+
function findTextAreas() {
console.log("Finding text area");
- var result = null;
-
- // Find the body text area
- result = document.getElementsByTagName('textarea');
-
- if(result) {
- console.log("Found some areas:"+result);
- for (ta in result)
- {
- console.log("Processing one:"+ta);
- }
- }
-
+ text_id=0;
+
// Try the jQuery way
- result = $('textarea');
- if (result) {
- console.log("Found some via jQuery:"+result);
- }
+ $('textarea').each ( function() {
+ console.log("each="+$(this));
+ id_string="eta_"+text_id;
+ $(this).attr({ emacs_chrome_id: id_string });
+ $(this).after('<a href="javascript:editTextArea(\''+id_string+'\')">'+editImgTag+'</a>');
+ text_id++;
+ } )
}
Please sign in to comment.
Something went wrong with that request. Please try again.