Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: TOTAL newbie, trying to get my head around several issues

  1. #1
    Junior Member
    Join Date
    Jan 2021
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default TOTAL newbie, trying to get my head around several issues

    Hello

    Hope htis is the correct place to post?

    Been playing about with CodePly, and tying to get my head around HTML and Java programming. My usual way to learn this stuff is to just throw random 'chunks' of code in that I have found with Google, and then work out how to make it work.
    Not sure that is really the way forward, but it's worked up until now.

    I am playing around with 2 way comms between my ESP8266 and a webpage.

    I have several issues that I have been some time trying to fix.

    My HTML draws some gauges using the CanvasGauge library. They then update from Java. The animate the needle movement and all works fine on a PC webpage, but the animation is missing when viewed on a mobile device (the needle instantly jumps between values). Cannot work out what I am missing to make animations active on a mobile device.
    Any idea what I should be adding to my code to make it work on a mobile device?

    Not sure what code you would want me to post here ... it's fairly extensive. If you look at the examples on a mobile device, the animations work.

    It won't let me post the link to the gauges page.


    Then I have a form set up in HTML that lets you browse and select a local .txt file. This then displays in a text box underneath the button.

    The HTML...
    <div class="container-fluid">        
        <div class="jumbotron text-center container p-3 my-3 bg-secondary text-white">      
            <div class="row justify-content-center">
                <div class="col-auto">            
                    <h4 class="text-center">Send text file to the processor</h4>
                        <form>
                            <div class="form-group">
                                <p class="mb-3"></p>
                                <input type="file" class="form-control-file" id="myFile" accept=".txt">     <! --Opens a file browse box-->
                                <p class="mb-3"></p>
                                <label>Retrieved text from local file</label>
                                <textarea class="form-control" id="output" readonly cols="100" rows="5"></textarea>   <! --Draws a box to display the text-->
                            </div>
                        </form>
                        <p class="mb-2"></p>
                        <button class="btn btn-danger" onclick="ClearText();" >Clear text box</button>
                    <p class="mb-3"></p>
     
                    <button class="btn btn-info" onclick="TextData();">Send the text data to the ESP8266</button>
                </div>
            </div>  
        </div>    
    </div>

    The Java...

    var input = document.getElementById("myFile");        // Display the opened file in the HTML text box   Selected file = myFile
    var output = document.getElementById("output");       // The file after it has been opened, and sent back to the page as 'output'
     
    input.addEventListener("change", function () {
      if (this.files && this.files[0]) {
        var myFile = this.files[0];
        var reader = new FileReader();
     
        reader.addEventListener('load', function (e) {
          output.textContent = e.target.result;
        });
     
        reader.readAsBinaryString(myFile);                // Read the contents of 'myFile'
      }
    });

    This works, but I would now like to send that retrieved text file onto my ESP8266 using Websockets .I use ... connection.send('myData');
    How would I achieve that?

    Finally, there is a clear the text box button...

    function ClearText () {                                 // Clear the text box and flag
        document.getElementById('output').value = "";
    }

    This clears the text, but then when you open a new text file, it doesn't display it.

    Hmm...

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: TOTAL newbie, trying to get my head around several issues

    This looks like javascript, not java. Try asking on a javascript forum
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Total Newbie!
    By Luly_Marty in forum Member Introductions
    Replies: 2
    Last Post: November 26th, 2012, 07:40 PM
  2. Issues with my ordering program - if statement issues?
    By Shenaniganizer in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 31st, 2012, 10:17 PM
  3. Cannot get my head around this :S
    By hillzyy in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: July 17th, 2012, 02:21 PM
  4. Multiple newbie issues
    By DaggeTeo in forum What's Wrong With My Code?
    Replies: 7
    Last Post: May 3rd, 2012, 08:29 AM