Jump to content

Myth of Echelon

Active Members
  • Content Count

    57
  • Joined

  • Last visited

  • Feedback

    0%

1 Follower

About Myth of Echelon

  • Rank
    Kilobyte Member
  • Birthday 08/09/1993

Profile Information

  • Gender
    Male
  • Location
    Merthyr Tydfil
  1. Never mind, it doesn't matter. I can do without it. :L Thanks for your help, though! Really, really appreciate it. (Feel free to mark this closed now)
  2. I store all of the values as a stringified JSON during transition and briefly before I extract them? And not particularly.. :L
  3. Wow. That worked seamlessly.. Thank you! One last inquiry: Even though I've just gotton rid of damn near 100 lines of code, I still have to manually define every value. Is there any way to get a FOR loop to cycle through a KV store?
  4. So, just something like: background.js var values = JSON.stringify({"lsName1": localStorage["lsName1"], lsName2: localStorage["lsName2"]}); //No idea if that's right function addMessageListeners(){ chrome.extension.onRequest.addListener( function(request, sender, sendResponse) { if (request.method == "getJSONData"){ sendResponse({data: values}); } } ); } content.js function passMessages(){ chrome.extension.sendRequest({method: "getJSONData"}, function(response) { var values = JSON.parse(response.data); localStorage["lsName1"] = values.lsName1; localStorage["lsName2"] = values.lsName2; continueOn(); //I'm guessing that things inside this function are asynchronous, and, therefore, "continueOn()" will only be fired once the above operations have been completed? }); } Sorry, this method and syntax is new to me. The above code was just a wild stab in the dark using what I could grasp. :|
  5. I understand the concept, I just don't understand how it could work. Then again, if it does work then I don't really need to know (although, I would find it interesting). I'll start testing and report back. Thanks.
  6. I really don't see how the mapped method name array thing could work, but funnelling the localStorage data into a JSON object, piping it through and then extracting it on the other end has intrigued me. Plus it would negate the need for the mapped array entirely, as I would only need one message to be passed. The only thing that concerns me, though, is how I would go abouts extracting the values once the JSON object has been passed to the content script. As previously mentioned, I don't think localStorage supports any other data than Strings (based entirely off of me trying to enter a Boolean value into it and only being able to confirm true/false by matching it as a string), so how would I separate the values and differentiate what preference they represent if it's just one long string?
  7. The localStorage data is set on the options page and then needs to be passed to the functions that use them (which are in the content script). Google disallows the content script to have any form of communication with the extension itself, except through message passing. So I have to pass all the preferences through as messages. Oh, I see. So you're suggesting that I send all of the data as one object it and then separate it on the other side? That could work, I suppose. I just can't use localStorage on the other side (I don't think it supports any data types other than String). If so, that still needs time to pass..
  8. I have no idea. It took me bloody ages to get my head around the message passing itself (it's hardly elegant or user-friendly). I've never come across a method like that before, but Google tells me that it's a shorthand way of creating objects. Wouldn't that method be similar to what I considered - statically checking if the data exists?
  9. Yes, it is just standard JavaScript wrapped in Chrome's framework. But my question is actually about Google's framework, so I don't know how far we'll get, as you said you have no personal experience. I'll post you the basic template of message passing from background to content. There's nothing wrong with the functionality, so there's no reason to include irrelevant bits. background.js function addMessageListeners(){ chrome.extension.onRequest.addListener( function(request, sender, sendResponse) { if (request.method == "methodName1"){ sendResponse({data: localStorage["lsName1"]}); //Send the localStorage data inside "response" if the method name is "methodName1" } if (request.method == "methodName2"){ sendResponse({data: localStorage["lsName2"]}); } //etc } ); } content.js function passMessages(){ chrome.extension.sendRequest({method: "methodName1"}, function(response) { localStorage["lsName1"] = response.data; //Send message request with method name "methodName1". When a response is received enter the "response" data back into localStorage }); chrome.extension.sendRequest({method: "methodName2"}, function(response) { localStorage["lsName2"] = response.data; }); } (localStorage data is not accessible from within the content script unless passed through in a message)
  10. Hey guys, long time no see. I have an issue with a Chrome extension I'm developing, that I've had for weeks and no one has been able to answer yet. The Question: When passing messages between a Google Chrome extension's background page and content script, respectively, is there any way to make it asynchronous - that is, to delay/pause the JavaScript until all of the messages are detected as being successfully being passed? The Explanation: I have a function immediately after the message-passing function that makes use of the localStorage data that is passed. On first runs the script always results in an error, due to the data not being passed (and therefore cached) fast enough. Currently, I'm circumventing this with setTimeout(nextFunction, 250); but that's hardly an elegant or practical solution, as the amount and size of the values passed is always going to change and I have no way of knowing how long it needs to pass the values. Plus, I would imagine, that passing times are relative to the browser version and the user's system. In short, I need it to be dynamic. I have considered something like this: function passMessages(){ chrome.extension.sendRequest({method: "methodName"}, function(response) { localStorage["lsName"] = response.data; }); checkPassedMessages(); } function checkPassedMessages(){ if (!localStorage["lsName"]){ setTimeout(checkPassedMessages, 100); //Recheck until data exists } else { continueOn(); } } but I need to pass quite a lot of data (at least 20 values) and, frankly, that "solution" just isn't practical, due to the amount of IF conditions that it would require. Plus I don't even know if that would work or not. Does anyone have any ideas? Thanks.
  11. Hey guys. Nice to have this website back! I've been on an apprenticeship for the last 6 months have have learnt a HUGE amount more than I did when this site was up (like, 30-fold), so I'll be contributing a lot more now. Nice to be back. ><
  12. I did a small amount of research first. The only 2 results, and my actions thereby, are as follows: Display > Properties > Desktop > Customise Desktop > Web > Lock Desktop Items [TICKED] My Computer > Properties > Advanced > Performance Settings > Use Drop Shadows For Icon Labels on the Desktop [TICKED] Both of these settings have been unticked, applied, closed, desktop-refreshed, opened, rechecked, applied, closed and desktop-refreshed and it has not worked. It may also help to know that old desktop wallpapers (the previous) are reappearing during animated transitions (windows maximised and so forth). In short - help?
  13. I have creative a Flash App that functions as multiple social networking search engines and my friend wishes to use it as his background for fast access to these websites. Are .swf's supported as backgrounds on Windows 7? If so, how do I go about making this a reality?
  14. For a college assignment I have to create a program in Visual Basic that can extract data from 3 textboxes and be able to print them and show them in print preview. I have added 3 labels and a button onto the form to test if the variables are functioniing, which they are. But when I input text into the text boxes and press Print Preview it displays the print preview but with a blank page.. Any ideas? Here's my code: Public Class Form1 Dim NameStore As String Dim EquipmentStore As String Dim TimeStore As Integer Dim X, Y As Integer Dim FontHeight1 As Integer Dim Myfont As New Font("Arial", 12, FontStyle.Regular) Dim assign As Boolean = False Private Sub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintToolStripMenuItem.Click assign = True If assign = True Then assign = False NameStore = NameBox.Text EquipmentStore = EquipmentBox.Text TimeStore = CInt(TimeBox.Text) X = 100 Y = 100 Y = Y + FontHeight1 e.Graphics.DrawString(NameStore, Myfont, Brushes.Black, X, Y) X = X + 150 e.Graphics.DrawString("", Myfont, Brushes.Black, X, Y) X = X + 150 e.Graphics.DrawString(TimeStore, Myfont, Brushes.Black, X, Y) FontHeight1 = Myfont.GetHeight(e.Graphics) Y = Y + FontHeight1 e.Graphics.DrawString("", Myfont, Brushes.Black, X, Y) X = 100 Y = Y + FontHeight1 e.Graphics.DrawString(EquipmentStore, Myfont, Brushes.Black, X, Y) End If End Sub Private Sub PrintPreviewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintPreviewToolStripMenuItem.Click PrintPreviewDialog1.Document = PrintDocument1 PrintPreviewDialog1.ShowDialog() End Sub Private Sub QuitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitToolStripMenuItem.Click End End Sub Private Sub traceBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles traceBtn.Click NameStore = NameBox.Text EquipmentStore = EquipmentBox.Text TimeStore = CInt(TimeBox.Text) nameLabel.Text = NameStore eqLabel.Text = EquipmentStore timeLabel.Text = TimeStore End Sub End Class
×
×
  • Create New...