Online - Offline Simulator
How do I make an online - offline simulator?
What is a online - offline simulator? How do you make a online - offline simulator? This script and codes were developed by Robert on 09 January 2023, Monday.
Online - Offline Simulator - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Online - Offline Simulator</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <html ng-app="myApp">
<head> <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="https://code.angularjs.org/1.0.5/angular.min.js"></script>
</head>
<body ng-controller="Ctrl"> <div class="offline" ng-class="{'online' : online}"> </div>
</body>
</html> <script src="js/index.js"></script>
</body>
</html>
Online - Offline Simulator - Script Codes CSS Codes
.offline { background-color: lightgray; width: 16px; height: 16px; border-radius: 50%;
}
.online { background-color: green;
}
Online - Offline Simulator - Script Codes JS Codes
// Outside of Angular window.myVar = {online: true, cachedItems: []}; var myVarWatch = (function() { var watches = {}; return { watch: function(callback) { var id = Math.random().toString(); watches[id] = callback; // Return a function that removes the listener return function() { watches[id] = null; delete watches[id]; } }, trigger: function() { for (var k in watches) { watches[k](window.myVar); } } } })(); function callTimer(){ setTimeout(function() { window.myVar.online = Math.floor(Math.random()*2) === 0 ? false : true; myVarWatch.trigger(); callTimer(); }, 2000); } callTimer(); // Inside of Angular angular.module('myApp', []).controller('Ctrl', function($scope) { $scope.online = true; var unbind = myVarWatch.watch(function(newVal) { $scope.online = newVal.online; $scope.$apply(); //console.log("ONLINE:", $scope.online); }); // Unbind the listener when the scope is destroyed $scope.$on('$destroy', unbind); });
Developer | Robert |
Username | AgentRR007 |
Uploaded | January 09, 2023 |
Rating | 3 |
Size | 2,407 Kb |
Views | 6,072 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
CSS Background Color Split | 1,741 Kb |
AngularJS 1.5 Demo | 3,373 Kb |
CountDown | 4,688 Kb |
Debug Console | 12,047 Kb |
Angular Alarm | 5,760 Kb |
YouTube behind firewall | 10,266 Kb |
Headphones | 3,660 Kb |
Spanish X-mas Word Game | 6,137 Kb |
Custom Directive | 3,425 Kb |
AgentRR007 Logo Rotate | 1,874 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
The Monty Hall Problem | Melatonind | 4,360 Kb |
Word Wrap Algorithm for Multiline Canvas Text | Peterhry | 2,349 Kb |
Michelle, submit your photography to Unsplash. | Zaneriley | 3,368 Kb |
Parallax with only CSS | Thulioph | 2,297 Kb |
Elephants Full screen site | Orrinward | 3,981 Kb |
DNA Double Helix | Hugo | 5,112 Kb |
Sample Profile Screen | OurDailyBread | 5,375 Kb |
Wikipedia Viewer | Thomasvaeth | 2,549 Kb |
Hovers with popups | Zacharyolson | 2,380 Kb |
Vertically rotating text with CSS | Nopr | 2,141 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!