Skip to content

Commit d251cb2

Browse files
authored
Digital Clock Widget (#1599)
- Created a simple digital clock widget with black background and white text. - Displays current time in HH:MM:SS format, updating every second. - Added HTML structure for time display. - Applied CSS for styling with centered alignment, black background, and white font. - Implemented JavaScript to update time every second using $interval. - Included README.md for setup and customization instructions.
1 parent 4aa2832 commit d251cb2

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Digital Clock Widget for ServiceNow Portal
2+
This widget displays a simple digital clock with a black background and white text. It shows the current time in hours, minutes, and seconds and updates every second.
3+
4+
## Features
5+
Displays the current time in HH:MM:SS format.
6+
Black background with white text for easy readability.
7+
Automatic time update every second.
8+
9+
## Usage
10+
Add this widget to any ServiceNow Portal page where you want to display the digital clock.
11+
The clock automatically updates every second without requiring any additional configuration.
12+
13+
## Customization
14+
Background Color: You can change the background-color property in CSS to a different color if desired.
15+
Font Color: Modify the color property to set a custom text color.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="digital-clock">
2+
<span>{{ currentTime }}</span>
3+
</div>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
api.controller = function($scope, $interval) {
2+
function updateTime() {
3+
var now = new Date();
4+
$scope.currentTime = now.toLocaleTimeString();
5+
}
6+
7+
// Initialize the clock on load
8+
updateTime();
9+
10+
// Update the clock every second
11+
$interval(updateTime, 1000);
12+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.digital-clock {
2+
display: flex;
3+
justify-content: center;
4+
align-items: center;
5+
height: 100px;
6+
width: 200px;
7+
margin: auto;
8+
background-color: #000;
9+
color: #fff;
10+
font-family: 'Courier New', Courier, monospace;
11+
font-size: 2em;
12+
border-radius: 5px;
13+
}

0 commit comments

Comments
 (0)