File: index.html

Recommend this page to a friend!
  Classes of Karl Holz   PowerTechTools   index.html   Download  
File: index.html
Role: Auxiliary data
Content type: text/plain
Description: Start page
Class: PowerTechTools
Solve Ohm's Law with Angular.js and MathML
Author: By
Last change: Code fixing
Date: 2 years ago
Size: 11,819 bytes
 

Contents

Class file image Download
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head lang="en"> <meta charset="UTF-8"> <title>PowerTools</title> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimal-ui" /> <meta name="apple-mobile-web-app-status-bar-style" content="yes" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link rel="stylesheet" href="js/mobile-angular-ui/dist/css/mobile-angular-ui-hover.min.css" /> <link rel="stylesheet" href="js/mobile-angular-ui/dist/css/mobile-angular-ui-base.min.css" /> <link rel="stylesheet" href="js/mobile-angular-ui/dist/css/mobile-angular-ui-desktop.min.css" /> <link rel="stylesheet" href="css/app.css" /> <script type="text/javascript" src="js/angular/angular.min.js"></script> <script type="text/javascript" src="js/angular/angular-route.min.js"></script> <script type="text/javascript" src="js/angular/angular-touch.min.js"></script> <script type="text/javascript" src="js/mobile-angular-ui/dist/js/mobile-angular-ui.min.js"></script> <script type="text/javascript" src="js/dbh5.js" ></script> <script type="text/javascript" src="js/powertech.js" ></script> <script type="text/javascript" > var ptt = angular.module('PowerTech', [ "ngRoute", "ngTouch", "mobile-angular-ui" ]); ptt.config(function($routeProvider, $locationProvider) { $routeProvider.when('/', {redirectTo: "/ohm"}); $routeProvider.when('/ohm', { templateUrl: "tmpl/power/ohm.html", controller: "ohmslaw" }); // $routeProvider.when('/curcuits', {templateUrl: "tmpl/power/curcuits.html"}); $routeProvider.when('/gennie', {templateUrl: "tmpl/power/gennorator.html"}); }); var $scope = {}; $scope.title = ""; ptt.controller('powertools', ['$scope', function($scope) { // calc values }]); ptt.controller('curcuits', ['$scope', function($scope) { // values for form var items = 'devices'; var p = new powertool(); $scope.pitem = p.ohmslaw.forms.curcuit_items; $scope.powered_items = dbh5.getPage(items); $scope.addItem = function() { if ($scope.pitem.id.new !== "" && $scope.pitem.pgroup.new !== '' && $scope.pitem.volt.new > 0 && $scope.pitem.amp.new > 0 && $scope.pitem.watt.new >= 0) { var update = { id: $scope.pitem.id.new, pgroup: $scope.pitem.pgroup.new, volt: $scope.pitem.volt.new, amp: $scope.pitem.amp.new, watt: $scope.pitem.watt.new, delete: false }; $scope.powered_items.push(update); $scope.pitem.id.new = ""; $scope.pitem.pgroup.new = ""; $scope.pitem.volt.new = 0; $scope.pitem.amp.new = 0; $scope.pitem.watt.new = 0; dbh5.setPage(items, $scope.powered_items); } }; $scope.deleteItem = function() { var update = []; angular.forEach($scope.powered_items, function(i) { if (!i.delete) { update.push(i); } }); dbh5.setPage(items, update); $scope.powered_items = update; }; /// }]); ptt.controller('ohmslaw', ['$scope', function($scope) { // calc values var p = new powertool(); $scope.history = dbh5.getPage("ohmslaw"); $scope.update_form = function(data) { $scope.volt = data.volt; $scope.amp = data.amp; $scope.watt = data.watt; $scope.ohm = data.ohm; return true; }; $scope.zero_calc = function() { $scope.work = false; p.reset(); $scope.update_form(p.data()); p.math.view(); return true; }; $scope.zero_calc(); $scope.solve = false; $scope.unit = p.units; $scope.check_num = function() { $scope.volt = p.check($scope.volt); $scope.amp = p.check($scope.amp); $scope.watt = p.check($scope.watt); $scope.ohm = p.check($scope.ohm); }; $scope.deleteHist = function() { var update = []; angular.forEach($scope.history, function(c) { if (!c.delete) { update.push(c); } }); dbh5.setPage("ohmslaw", update); $scope.history = update; p.math.view(); return true; }; $scope.solve = function() { $scope.work = true; var data = p.ohmslaw.solve($scope.volt, $scope.amp, $scope.ohm, $scope.watt); var update = { volt: data.volt, amp: data.amp, watt: data.watt, ohm: data.ohm, delete: false }; $scope.history.push(update); dbh5.setPage("ohmslaw", $scope.history); $scope.zero_calc(); return true; }; }]); ptt.controller('gennie', ['$scope', function($scope) { // calc values var p = new powertool(); $scope.history = dbh5.getPage("gennie"); $scope.update_form = function(data) { $scope.volt = data.volt; $scope.amp = data.amp; $scope.kva = data.kva; $scope.note = data.note; return true; }; $scope.zero_calc = function() { $scope.work = false; p.reset(); $scope.note=""; $scope.update_form(p.data()); return true; }; $scope.zero_calc(); $scope.solve = false; $scope.unit = p.units; $scope.check_num = function() { $scope.volt = p.check($scope.volt); $scope.amp = p.check($scope.amp); }; $scope.deleteHist = function() { var update = []; angular.forEach($scope.history, function(c) { if (!c.delete) { update.push(c); } }); dbh5.setPage("gennie", update); $scope.history = update; return true; }; $scope.solve = function() { $scope.work = true; p.volt = $scope.volt; p.amp = $scope.amp; p.ppgen.solve(); var data = p.data(); var update = { volt: data.volt, amp: data.amp, kva: data.kva, note: $scope.note, delete: false }; $scope.history.push(update); dbh5.setPage("gennie", $scope.history); $scope.zero_calc(); return true; }; }]); /** * getScript example: http://jsfiddle.net/xgrommx/6hSts/ */ function getScript(url,success){ var head = document.getElementsByTagName("head")[0], done = false; var script = document.createElement("script"); script.src = url; // Attach handlers for all browsers script.onload = script.onreadystatechange = function(){ if ( !done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") ) { done = true; success(); } }; head.appendChild(script); } </script> <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script> </head> <body ng-app="PowerTech" ng-controller="powertools"> <div class="sidebar sidebar-right" toggleable parent-active-class="sidebar-right-in" id="rightSidebar"> <div class="scrollable"> <div class="scrollable-content"> <div class="list-group" toggle="off" bubble target="rightSidebar"> <a class="list-group-item media" href="#/ohm">Ohm's Law Solver</a> <a class="list-group-item media" href="#/gennie">Do i need a Power Generator?</a> <!-- Never got around to completing this <a class="list-group-item media" href="#/curcuits">How many Circuits do I need?</a> --> </div> </div> </div> </div> <div class="app"> <div class="navbar navbar-app navbar-absolute-top"> <div class="navbar-brand navbar-brand-center" yield-to="title"> <span id="title">PowerTools</span> </div> <div class="btn-group pull-right" yield-to="navbarAction"> <div ng-click="toggle('rightSidebar')" class="btn btn-navbar"> <i class="fa fa-comment"></i> Tools </div> </div> </div> <div class="navbar navbar-app navbar-absolute-bottom"> <div class="btn-group justified"> <a href="http://en.wikipedia.org/wiki/Ohm's_law" class="btn btn-navbar"><i class="fa fa-github fa-navbar"></i> Ohm's Law</a> </div> </div> <div class="app-body" ng-class="{loading: loading}"> <div ng-show="loading" class="app-content-loading"> <i class="fa fa-spinner fa-spin loading-spinner"></i> </div> <ng-view class="app-content" ng-hide="loading"></ng-view> </div> </div> </body> </html>