Just Used OpenAI ChatGPT to Write a Web Page!

For discussions about programming, and for programming questions and advice


Moderator: Forum moderators

Post Reply
User avatar
rockedge
Site Admin
Posts: 5815
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2073 times
Been thanked: 2165 times
Contact:

Just Used OpenAI ChatGPT to Write a Web Page!

Post by rockedge »

I just created a web page countdown timer using OpenAI's ChatGPT in a about 3 minutes. All I had to do was login to the interface and using the playground typed this at the top of the page and clicked submit.:

Code: Select all

<!-- Create web page count down timer -->
<!DOCTYPE html>

Which resulted in the Artificial Intelligence ChatGPT writing the complete code in about 3 minutes. This is the code it made:

Code: Select all

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Countdown Timer</title>
<style>
#countdown {
	font-size: 60px;
	font-weight: bold;
	color: #f00;
}
</style>
<script>
// Set the date we're counting down to
var countDownDate = new Date("Feb 27, 2023 22:37:25").getTime();

// Update the count down every 1 second
var x = setInterval(function() {

  // Get today's date and time
  var now = new Date().getTime();

  // Find the distance between now and the count down date
  var distance = countDownDate - now;

  // Time calculations for days, hours, minutes and seconds
  var days = Math.floor(distance / (1000 * 60 * 60 * 24));
  var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  var seconds = Math.floor((distance % (1000 * 60)) / 1000);

  // Display the result in the element with id="demo"
  document.getElementById("countdown").innerHTML = days + "d " + hours + "h "
  + minutes + "m " + seconds + "s ";

  // If the count down is finished, write some text
  if (distance < 0) {
    clearInterval(x);
    document.getElementById("countdown").innerHTML = "EXPIRED";
  }
}, 1000);
</script>
</head>
<body>

<p>Countdown timer until Feb 27, 2023 22:37:25</p>

<div id="countdown"></div>

</body>
</html>

Test it in a browser........mind blowing......

Screenshot(13).jpg
Screenshot(13).jpg (42.9 KiB) Viewed 490 times

I translated a driver for an X10 transceiver written for Python 2.7 into Python 3.7 using the commented text:

Code: Select all

##### Translate this function  from Python2.7 into Python3.7
### Python2.7

code goes here

###Python3.7

Wow is all I can say. What if I ask it to design a Puppy Linux Distro? :ugeek:

Clarity
Posts: 3351
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1382 times
Been thanked: 444 times

Re: Just Used OpenAI ChatGPT to Write a Web Page!

Post by Clarity »

Yeah, this service has all the marking of being very useful. :thumbup: Hopefully, it will remain free.

Use it to advantage while we can. The experience in knowing how to take advantage is of extreme benefit as time marches forward.; :geek:

With a little time, it CAN be taught to use WoofCE/GIT to build a PUP consistently. It appears that a stepwise approach may be the order necessary to achieve such. :idea:

Have you thought about a manner of including in a forum distro or a PET or ???

Clarity
Posts: 3351
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1382 times
Been thanked: 444 times

Re: Just Used OpenAI ChatGPT to Write a Web Page!

Post by Clarity »

Found this on saving a "Chat"

Hope the info is helpful

some1
Posts: 71
Joined: Wed Aug 19, 2020 4:32 am
Has thanked: 17 times
Been thanked: 11 times

Re: Just Used OpenAI ChatGPT to Write a Web Page!

Post by some1 »

User avatar
rockedge
Site Admin
Posts: 5815
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2073 times
Been thanked: 2165 times
Contact:

Re: Just Used OpenAI ChatGPT to Write a Web Page!

Post by rockedge »

Funny thing is while I was experimenting after the head dev at Zoneminder told me about using it to convert Python code into PERL code, I accidently had the ChatGPT instance write the count down timer in JavaScript.

So directly after that I specified to add the HTML to display it as well and it presented the above code.

JavaScript countdown timer

Code: Select all

<script type="text/javascript">
	var countDownDate = new Date("Jan 5, 2021 15:37:25").getTime();
	var x = setInterval(function() {
		var now = new Date().getTime();
		var distance = countDownDate - now;
		var days = Math.floor(distance / (1000 * 60 * 60 * 24));
		var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
		var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
		var seconds = Math.floor((distance % (1000 * 60)) / 1000);
		document.getElementById("demo").innerHTML = days + "d " + hours + "h " + minutes + "m " + seconds + "s ";
		if (distance < 0) {
			clearInterval(x);
			document.getElementById("demo").innerHTML = "EXPIRED";
		}
	}, 1000);
</script>
User avatar
Grey
Posts: 2003
Joined: Wed Jul 22, 2020 12:33 am
Location: Russia
Has thanked: 75 times
Been thanked: 365 times

Re: Just Used OpenAI ChatGPT to Write a Web Page!

Post by Grey »

rockedge wrote: Sat Feb 25, 2023 4:07 am

web page countdown timer
Which resulted in the Artificial Intelligence ChatGPT writing the complete code in about 3 minutes.

Indeed, it works (UngChromium).
I only changed the size and color manually, otherwise by default it resembled a annual demonstration with flags on May 1 in my town :)

3? Maybe "It" did not write the code, but was looking for a ready-made acceptable option :) ?

I see in your picture my favorite variation of the controls for closing and minimizing (windows) in the upper right corner of the window :thumbup:
This theme will one day win and displace all other options, especially round, small and faceless :)

Fossapup OS, Ryzen 5 3600 CPU, 64 GB RAM, GeForce GTX 1050 Ti 4 GB, Sound Blaster Audigy Rx with amplifier + Yamaha speakers for loud sound, USB Sound Blaster X-Fi Surround 5.1 Pro V3 + headphones for quiet sound.

Post Reply

Return to “Programming”