WebIDE set time without send like in Apploader

Posted on
  • This is what the WebIDE is gererating and sending if When sending code, set Espruino's clock to the current time is checked.

    var time = new Date();
    code = "setTime("+(time.getTime()/1000)+");E.se­tTimeZone("+(-time.getTimezoneOffset()/6­0)+")\n"

    How to implement this feature into the WebIDE as a standalone function witn an icon like Set Espruino Time?

  • All you need to do is...

    • Copy _examplePlugin.js to a new JS file in the plugins folder
    • Replace the contents of the init function with something like:

          id: "sendTime",
          icon: "star", 
          title : "Send the current Time", 
          order: 300, 
          area: { 
            name: "code", 
            position: "bottom"
          click: sendTime

    Then add a sendTime function that calls:

    Espruino.Core.Serial.write(`\x03\x10setT­ime(....)\n`, false, function() {
                    Espruino.Core.Notifications.success(`Sen­t the time`, true);

    And I think you'll be done. It might be a nice thing to have as an option, so you could copy the code from https://github.com/espruino/EspruinoWebI­DE/blob/master/js/plugins/codeLink.js which puts an option in Settings which shows/hides the icon when toggled

  • Great, just added a sendTime.js, looks like I missed something ....because the clock icon does not show here on http://mabecker.github.io/EspruinoWebIDE­/

  • Looking atview-source:https://mabecker.github.io/E­spruinoWebIDE/ you never include sendTime.js as a script there?

  • Ups, missed that one .... Thanks. Now it works. Let me know if you like to include this into the original WebIDE.

  • add screen shot

    1 Attachment

    • Bildschirmfoto 2023-11-02 um 12.53.09.JPG
  • Thanks! Well, someone asked a while ago (I think it was part of 'Projects'?) if there could be a way to upload some predefined commands from a menu, like setting time, reset(), load(), require("Storage").eraseAll() and I'm sure others.

    If a menu was added so you clicked a button and then clicked again on the command you wanted, do you think that'd be good enough for you?

    Also, if it was, what other commands would be useful?

  • Yes this is a feature the WebIDE lost, it was named snippets.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

WebIDE set time without send like in Apploader

Posted by Avatar for MaBe @MaBe