spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / script.js
38 lines · 1.4 KBRaw
1// Sample JavaScript functions for the web page
2
3function showMessage() {
4 const output = document.getElementById('output');
5 output.innerHTML = '<p><strong>Hello from JavaScript!</strong> This message was generated by the external script file.</p>';
6}
7
8function changeColor() {
9 const output = document.getElementById('output');
10 const colors = ['#e3f2fd', '#f3e5f5', '#e8f5e8', '#fff3e0', '#fce4ec'];
11 const randomColor = colors[Math.floor(Math.random() * colors.length)];
12
13 output.style.backgroundColor = randomColor;
14 output.innerHTML = '<p>Background color changed! The new color is: <strong>' + randomColor + '</strong></p>';
15}
16
17function showDateTime() {
18 const output = document.getElementById('output');
19 const now = new Date();
20 const dateTimeString = now.toLocaleString();
21
22 output.innerHTML = '<p>Current date and time: <strong>' + dateTimeString + '</strong></p>';
23}
24
25// Add event listener for when the page loads
26document.addEventListener('DOMContentLoaded', function() {
27 console.log('JavaScript file loaded successfully!');
28
29 // You can add any initialization code here
30 const container = document.querySelector('.container');
31 if (container) {
32 container.addEventListener('click', function(event) {
33 if (event.target.classList.contains('button')) {
34 console.log('Button clicked:', event.target.textContent);
35 }
36 });
37 }
38});