![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 240 Pomógł: 2 Dołączył: 5.12.2010 Skąd: Fulda Ostrzeżenie: (0%) ![]() ![]() |
Witam, właśnie robię pierwszą wtyczkę do Firefoxa, mam już interfejs, i kod, ale nie wiem jak zapisywać podany tekst w textarea i wyświetlanie go w textarea.
Potem chce aby zapisany tekst z textarea był wyświetlany w textarea na innej stronie. W Greasemonky zrobiłem taki skrypt który działa: Kod var hr = "____________________________________________" var signature = "Pozdrawiam Saki."; var textarea = document.getElementById('questionContents'); textarea.innerHTML = "\n" + hr + "\n" + signature; Podany kod wyświetla podpis w textarea na stronie. I teraz chce zrobić nową wtyczkę do Firefoxa z tą samą funkcją. Mam na razie tylko to: main.js Kod // This is an active module of the modInfo (2) Add-on // exports.main = function() {}; var data = require("self").data; // Create a panel whose content is defined in "text-entry.html". // Attach a content script called "get-text.js". var text_entry = require("panel").Panel({ width: 212, height: 200, contentURL: data.url("text-entry.html"), contentScriptFile: data.url("get-text.js") }); var ss = require("simple-storage"); // miejsce do zapisu // Send the content script a message called "show" when // the panel is shown. text_entry.on("show", function() { text_entry.port.emit("show"); }); // Listen for messages called "text-entered" coming from // the content script. The message payload is the text the user // entered. // In this implementation we'll just log the text to the console. text_entry.port.on("text-entered", function (text) { ss.storage.myString = "" + text + ""; // console.log(text); text_entry.hide(); }); // Create a widget, and attach the panel to it, so the panel is // shown when the user clicks the widget. require("widget").Widget({ label: "Twój Podpis!", id: "text-entry", contentURL: "http://XXXX/images/favicon.ico", panel: text_entry }); get-text.js Kod self.port.on("show", function (arg) { var textArea = document.getElementById('edit-box'); textArea.focus(); // var ss = require("simple-storage"); // miejsce do zapisu // textArea.value = "" + ss.storage.value + ""; // When the user hits return, send a message to main.js. // The message payload is the contents of the edit box. textArea.onkeyup = function(event) { if (event.keyCode == 13) { // Remove the newline. text = textArea.value.replace(/(\r\n|\n|\r)/gm,""); self.port.emit("text-entered", text); //textArea.value = ''; } }; }); text-entry.html Kod <html> <head> <meta charset="UTF-8" /> <style type="text/css" media="all"> textarea { margin: 10px; } </style> </head> <body> <span>Wpisz swój podpis i wciśnij enter.</span><br /> <textarea id="edit-box"></textarea> </body> </html> Bardzo proszę o pomoc. Ten post edytował Saki 1.08.2012, 17:29:41 |
|
|
![]() ![]() |
![]() |
Aktualny czas: 24.08.2025 - 10:50 |