Replace the user interface of this web app with one that matches a native iOS app…
- User
Replace the user interface of this web app with one that matches a native iOS app
code - Assistant
Replace the user interface of this web app with one that matches a native iOS app
gtag('config', 'UA-57211579-1');
</script>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="apple-touch-icon" href="Digital-Scale-Icon-2.png">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<title>Digital Scale+</title>
<style>
* {
font-family: sans-serif, Helvetica, Arial;
-webkit-user-select: none;
-webkit-text-size-adjust: 100%;
}
body, html {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
}
#view {
background: #FFF;
height: 100%;
width: 100%;
}
#navigationBar {
width: 100%;
height: 56px;
margin: 0 auto;
position: absolute;
background: #3876ED;
}
#title {
width: 100%;
height: 25px;
top: calc(50% - 25px/2);
text-align: center;
font-size: 20px;
color: white;
position: relative;
}
#setting{
position: absolute;
font-size: 15px;
top: 12px;
right: 8px;
text-align: center;
}
#weightLabel {
width: 100%;
height: 72px;
position: absolute;
text-align: center;
font-size: 40px;
line-height: 75px;
padding-bottom: 8px;
bottom: 0px;
color: white;
font-family: 'Menlo', sans-serif, Helvetica;
background: #3876ED;
}
#weightMeasurementArea {
position: absolute;
top: calc(16px + 56px);
left: 16px;
right: 16px;
bottom: calc(16px + 80px);
margin: auto;
background: #fdfdfd;
border-radius: 20px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.2);
}
#message, #orientationWarning {
width: 100%;
height: auto;
text-align: center;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
position: absolute;
font-size: 12px;
color: #777;
}
#orientationWarning {
transform: translate(-50%, -60%);
display: none;
}
#footer {
width: 100%;
text-align: center;
position:absolute;
bottom: calc(80px + 24px);
font-size: 12px;
color: #777;
}
#footer a {
color: #07F;
}
#controls {
width: 100%;
height: 80px;
position: absolute;
background: #4B8CF3;
bottom: 0px;
display: none;
}
select {
bottom: 10px;
width: 40%;
height: 28px;
margin-top: 8px;
margin-bottom: 8px;
margin-left: 5%;
margin-right: 5%;
position: absolute;
text-align: center;
border: none;
border-radius: 14px;
outline: none;
font-weight: bold;
font-size: 15px;
-webkit-appearance: none;
background-color: white;
}
.settingLabel {
position: absolute;
font-size: 12px;
font-weight: bold;
width: 37%;
text-align: center;
top: 8px;
color: white;
}
a, a:hover, a:active, a:visited {
color: white;
}
@media screen and (prefers-color-scheme: dark) {
html, body {
background: black;
}
#view {
background: #000;
}
#navigationBar {
background: #000;
}
#weightMeasurementArea {
background: #222;
}
#message, #orientationWarning {
color: #BBB;
}
#weightLabel {
background: #000;
}
#controls {
background: #000;
}
#footer a {
color: #09F;
}
}
@media screen and (orientation: landscape) and (max-height: 512px) {
html, body {
background: black; /* hack to hide display cutout on iPhone X, XS when in landscape mode */
}
#message {
display: none;
}
#orientationWarning {
display: block;
}
}
</style>
</head>
<body>
<div id="view">
<div id="navigationBar">
<div id="title"><b>Digital Scale+</b></div>
<div id="setting"><img src="white-gear-icon.png" height='32px' width='32px'></img>
</div>
</div>
<div id="weightMeasurementArea">
<div id="message">
This app uses 3D touch to function.
<br><br>
Place something conductive on the center<br>
of the screen to measure its weight.
<br><br>
If it is not conductive, place a spoon, set<br>
spoon as the tare weight, then place the<br>
object on the spoon to measure its weight.
<br><br>
Touch the weight below to set the <br> current weight as the tare weight.
<br><br>
If you have changed your device's 3D Touch<br>
Sensitivity, set it in this app's settings.
</div>
<div id="orientationWarning">
Place something conductive on the center<br>
of the screen to measure its weight.
<br><br>
Please rotate your phone to portrait<br>
to view detailed instructions.
</div>
</div>
<div id="footer"><a href="https://www.wernjie.com/digital-scale-3d-touch/">Need help or more info?</a></div>
<b><div id="weightLabel">Loading...</div></b>
<div id="controls">
<select id="WeightUnitSelector" style="left: 0;">
<option value="0" selected>Grams</option>
<option value="1">Ounces</option>
<option value="2">Pounds</option>
<option value="3">Newtons</option>
</select>
<select id="Sensitivity3dSelector" style="right: 0;">
<option value="0">Light</option>
<option value="1" selected>Medium</option>
<option value="2">Firm</option>
</select>
<div class="settingLabel" style="left: 7%;">
Weight Unit
</div>
<div class="settingLabel" style="right: 7%;">
3D Touch Sensitivity
</div>
</div>
</div></div>
<link rel="stylesheet" type="text/css" href="addtohomescreen.css">
<script src="addtohomescreen.js"></script>
<script>
var weightLabel = document.getElementById('weightLabel');
var tareForce = 0;
function tareWeight() {
tareForce = getCurrent3DTForce();
updateForce();
}
weightLabel.onclick = tareWeight;
var forceConversionRatios = [320, 400, 480];
var selected3DTSettingIndex = getStoredSensitivity();
var weightUnitIndex = getStoredWeightUnitIndex();
var weightUnitNames = ['g','oz','lb','N']
var weightConvertGramsRatios/*Unit*/ = [1.0, 0.03527396, 0.00220462, 0.00980665]
var touch;
var touches;
var touchCount = 0;
function onTouchStart(e) {
touch = e.touches[0];
touches = e.touches;
touchCount = e.touches.length;
settingPressed(true); //Force close settings if open
updateForce();
}
function onTouchMove(e) {
e.preventDefault();
touches = e.touches;
touch = e.touches[0];
touchCount = e.touches.length;
updateForce();
}
function onTouchForceChange(e) {
e.preventDefault();
touch = e.touches[0];
touches = e.touches;
touchCount = e.touches.length;
updateForce();
}
function onTouchEnded(e) {
e.preventDefault();
touch = undefined;
touches = e.touches;
touchCount = e.touches.length;
updateForce();
}
var confirmNoErrors = false;
function updateForce() {
var raw3dtForce = getCurrent3DTForce()
var current3dtForce = raw3dtForce - tareForce;
var isMaxForce = current3dtForce == touchCount - tareForce && touchCount != 0;
var currentGramsForce = getForceInGrams(current3dtForce);
var displayedWeight = getDisplayedWeight(currentGramsForce);
if ((raw3dtForce == 0 || isNaN(raw3dtForce)) && touchCount != 0 && !confirmNoErrors) {
weightLabel.innerText = "No 3D Touch?";
} else {
if (touchCount != 0) {
confirmNoErrors = true;
}
weightLabel.innerText = (isMaxForce ? "≥" : "") + displayedWeight;
}
var alpha = 0.2*(1-current3dtForce);
weightMeasurementArea.style.boxShadow = "0 4px 8px 0 rgba(0, 0, 0, " + alpha + "), 0 6px 20px 0 rgba(0, 0, 0, " + alpha + ");"
}
function getCurrent3DTForce() {
var totalforce = 0;
for (var i = 0; i < touchCount; i++) {
totalforce += touches[i].force;
}
return totalforce;//(typeof touch !== 'undefined') ? touch.force : 0;
}
function getForceInGrams(scale) {
return scale * forceConversionRatios[selected3DTSettingIndex];
//Returns scale from 0-1 multiplied by the force conversion
}
function getDisplayedWeight(grams) {
var conversionRatio = weightConvertGramsRatios[weightUnitIndex]
var finalWeight = grams * conversionRatio;
var inaccuracyRatio = Math.round(Math.min(Math.pow(2, Math.round(Math.floor(Math.abs(grams)/100))), 4));
var decimalPointPrecision = 2;
if (weightUnitNames[weightUnitIndex] == 'g') {
finalWeight = Math.round(finalWeight/5.0/inaccuracyRatio)*5.0*inaccuracyRatio;
decimalPointPrecision = 0;
} else if (weightUnitNames[weightUnitIndex] == 'oz') {
finalWeight = Math.round(finalWeight*5.0/inaccuracyRatio)/5.0*inaccuracyRatio;
decimalPointPrecision = Math.max(0, 2 - inaccuracyRatio);
} else if (weightUnitNames[weightUnitIndex] == 'N') {
finalWeight = Math.round(finalWeight*20.0/inaccuracyRatio)/20*inaccuracyRatio;
decimalPointPrecision = Math.max(1, 3 - inaccuracyRatio);
} else if (weightUnitNames[weightUnitIndex] == 'lb') {
finalWeight = Math.round(finalWeight*100.0/inaccuracyRatio)/100*inaccuracyRatio;
decimalPointPrecision = 2;
}
return finalWeight.toFixed(decimalPointPrecision) + weightUnitNames[weightUnitIndex];
}
function settingPressed(forceClose) {
if (document.getElementById('controls').style.display == "inline" || forceClose) {
document.getElementById('controls').style.display = "none";
} else {
document.getElementById('controls').style.display = "inline";
}
}
//Cookie management
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length,c.length);
}
}
return "";
}
//Storage and retrieval
function getStoredWeightUnitIndex() {
var data = getCookie("SelectedWeightUnitIndex");
if (data != "") {
return Number(data);
} else {
return 0;
}
}
function getStoredSensitivity() {
var data = getCookie("Selected3DTSensitivity");
if (data != "") {
return Number(data);
} else {
return 1;
}
}
var Sensitivity3dSelector = document.getElementById('Sensitivity3dSelector');
Sensitivity3dSelector.onchange = function(e) {
selected3DTSettingIndex = this.selectedIndex;
setCookie("Selected3DTSensitivity", selected3DTSettingIndex, 365);
updateForce();
}
var WeightUnitSelector = document.getElementById('WeightUnitSelector');
WeightUnitSelector.onchange = function(e) {
weightUnitIndex = this.selectedIndex;
setCookie("SelectedWeightUnitIndex", weightUnitIndex, 365);
updateForce();
}
function isPortrait() {
return window.innerHeight > window.innerWidth;
}
//Update selected setting on load
window.onload = function() {
Sensitivity3dSelector.selectedIndex = selected3DTSettingIndex;
WeightUnitSelector.selectedIndex = weightUnitIndex;
}
//Update touch recognizers on load
var weightMeasurementArea = document.getElementById('weightMeasurementArea')
window.onload = function() {
var iOS = ['iPad', 'iPhone', 'iPod', 'iPhone Simulator'].indexOf(navigator.platform) >= 0;
if (!iOS) {
window.alert("Sorry, but this application requires iOS.");
weightLabel.innerText = "iOS Only";
} else {
function iOSversion() {
if (/iP(hone|od|ad)/.test(navigator.platform)) {
var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
}
}
if (iOSversion()[0] >= 12.0) {
//document.getElementsByTagName("head").innerHTML += '<meta name="apple-mobile-web-app-capable" content="yes">'
addToHomescreen();
} else {
window.alert("Note: This web app works best on iOS 12 and later. You are using iOS " + iOSversion()[0] + ". Please update your device for the best performance and to avoid any issues.");
}
}
Sensitivity3dSelector.selectedIndex = selected3DTSettingIndex;
WeightUnitSelector.selectedIndex = weightUnitIndex;
weightMeasurementArea.addEventListener('touchstart', onTouchStart, false)
weightMeasurementArea.addEventListener('touchmove', onTouchMove, false)
weightMeasurementArea.addEventListener('touchforcechange', onTouchForceChange, false)
weightMeasurementArea.addEventListener('touchend', onTouchEnded, false)
weightLabel.addEventListener('touchstart', tareWeight, false)
document.getElementById('setting').onclick = function() {
settingPressed();
}
if (iOS) updateForce();
}
</script>
</body>
Remove Google Analytics and make settings a tab
Sure! Here's the updated code with the user interface modified to match a native iOS app, the Google Analytics code removed, and the settings moved to a tab at the bottom:
<!DOCTYPE html>
<!-- LICENSE: https://github.com/wernjie/digital-scale-plus/blob/master/LICENSE -->
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="apple-touch-icon" href="Digital-Scale-Icon-2.png">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<title>Digital Scale+</title>
<style>
/* Global Styles */
* {
font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Helvetica", "Arial", sans-serif;
-webkit-user-select: none;
-webkit-text-size-adjust: 100%;
margin: 0;
padding: 0;
}
body, html {
height: 100%;
overflow: hidden;
background-color: #FFFFFF;
}
#view {
display: flex;
flex-direction: column;
height: 100%;
}
/* iOS Style Navigation Bar */
#navigationBar {
width: 100%;
height: 44px;
background-color: #FFFFFF;
border-bottom: 1px solid #C7C7CC;
display: flex;
align-items: center;
justify-content: center;
}
#title {
font-size: 17px;
font-weight: 600;
color: #000000;
}
/* Content Area */
#content {
flex: 1;
overflow: auto;
background-color: #FFFFFF;
}
/* Message Styles */
#message, #orientationWarning {
width: 90%;
margin: 0 auto;
text-align: center;
top: 50%;
transform: translateY(-50%);
position: relative;
font-size: 15px;
color: #8E8E93;
line-height: 1.5;
}
#orientationWarning {
transform: translateY(-60%);
display: none;
}
/* Tab Bar */
#tabBar {
width: 100%;
height: 49px;
background-color: #FFFFFF;
border-top: 1px solid #C7C7CC;
display: flex;
}
.tabBarItem {
flex: 1;
text-align: center;
font-size: 10px;
color: #8E8E93;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.tabBarItem.active {
color: #007AFF;
}
.tabBarIcon {
width: 25px;
height: 25px;
margin-bottom: 3px;
}
/* Scale Page */
#scalePage {
display: none;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
}
#weightLabel {
font-size: 40px;
color: #000000;
font-family: 'Menlo', monospace;
margin-top: 20px;
}
/* Settings Page */
#settingsPage {
display: none;
padding: 16px;
}
.settingItem {
display: flex;
align-items: center;
padding: 12px 0;
border-bottom: 1px solid #C7C7CC;
}
.settingLabel {
flex: 1;
font-size: 17px;
color: #000000;
}
.settingControl {
font-size: 17px;
color: #007AFF;
}
select {
font-size: 17px;
color: #007AFF;
border: none;
background: none;
-webkit-appearance: none;
appearance: none;
}
a, a:hover, a:active, a:visited {
color: #007AFF;
text-decoration: none;
}
/* Dark Mode Styles */
@media screen and (prefers-color-scheme: dark) {
html, body {
background: #000000;
color: #FFFFFF;
}
#navigationBar {
background-color: #1C1C1E;
border-bottom: 1px solid #3A3A3C;
}
#title {
color: #FFFFFF;
}
#content {
background-color: #000000;
}
#message, #orientationWarning {
color: #8E8E93;
}
#tabBar {
background-color: #1C1C1E;
border-top: 1px solid #3A3A3C;
}
.tabBarItem {
color: #8E8E93;
}
.tabBarItem.active {
color: #0A84FF;
}
.tabBarIcon {
filter: invert(100%);
}
#settingsPage {
background-color: #000000;
}
.settingItem {
border-bottom: 1px solid #3A3A3C;
}
.settingLabel {
color: #FFFFFF;
}
.settingControl {
color: #0A84FF;
}
select {
color: #0A84FF;
}
a {
color: #0A84FF;
}
}
</style>
</head>
<body>
<div id="view">
<!-- Navigation Bar -->
<div id="navigationBar">
<div id="title">Digital Scale+</div>
</div>
<!-- Content Area -->
<div id="content">
<!-- Scale Page -->
<div id="scalePage">
<div id="weightLabel">Loading...</div>
<div id="message">
This app uses 3D Touch to function.
<br><br>
Place something conductive on the center<br>
of the screen to measure its weight.
<br><br>
If it is not conductive, place a spoon, set<br>
spoon as the tare weight, then place the<br>
object on the spoon to measure its weight.
<br><br>
Touch the weight above to set the <br> current weight as the tare weight.
<br><br>
If you have changed your device's 3D Touch<br>
sensitivity, set it in this app's settings.
<br><br>
<a href="https://www.wernjie.com/digital-scale-3d-touch/">Need help or more info?</a>
</div>
</div>
<!-- Settings Page -->
<div id="settingsPage">
<div class="settingItem">
<div class="settingLabel">Weight Unit</div>
<div class="settingControl">
<select id="WeightUnitSelector">
<option value="0">Grams</option>
<option value="1">Ounces</option>
<option value="2">Pounds</option>
<option value="3">Newtons</option>
</select>
</div>
</div>
<div class="settingItem">
<div class="settingLabel">3D Touch Sensitivity</div>
<div class="settingControl">
<select id="Sensitivity3dSelector">
<option value="0">Light</option>
<option value="1">Medium</option>
<option value="2">Firm</option>
</select>
</div>
</div>
</div>
</div>
<!-- Tab Bar -->
<div id="tabBar">
<div class="tabBarItem" id="tabScale">
<img src="scale_icon.png" class="tabBarIcon"></img>
Scale
</div>
<div class="tabBarItem" id="tabSettings">
<img src="settings_icon.png" class="tabBarIcon"></img>
Settings
</div>
</div>
</div>
<script>
var weightLabel = document.getElementById('weightLabel');
var tareForce = 0;
function tareWeight() {
tareForce = getCurrent3DTForce();
updateForce();
}
weightLabel.onclick = tareWeight;
var forceConversionRatios = [320, 400, 480];
var selected3DTSettingIndex = getStoredSensitivity();
var weightUnitIndex = getStoredWeightUnitIndex();
var weightUnitNames = ['g','oz','lb','N']
var weightConvertGramsRatios/*Unit*/ = [1.0, 0.03527396, 0.00220462, 0.00980665]
var touch;
var touches;
var touchCount = 0;
function onTouchStart(e) {
touch = e.touches[0];
touches = e.touches;
touchCount = e.touches.length;
updateForce();
}
function onTouchMove(e) {
e.preventDefault();
touches = e.touches;
touch = e.touches[0];
touchCount = e.touches.length;
updateForce();
}
function onTouchForceChange(e) {
e.preventDefault();
touch = e.touches[0];
touches = e.touches;
touchCount = e.touches.length;
updateForce();
}
function onTouchEnded(e) {
e.preventDefault();
touch = undefined;
touches = e.touches;
touchCount = e.touches.length;
updateForce();
}
var confirmNoErrors = false;
function updateForce() {
var raw3dtForce = getCurrent3DTForce()
var current3dtForce = raw3dtForce - tareForce;
var isMaxForce = current3dtForce == touchCount - tareForce && touchCount != 0;
var currentGramsForce = getForceInGrams(current3dtForce);
var displayedWeight = getDisplayedWeight(currentGramsForce);
if ((raw3dtForce == 0 || isNaN(raw3dtForce)) && touchCount != 0 && !confirmNoErrors) {
weightLabel.innerText = "No 3D Touch?";
} else {
if (touchCount != 0) {
confirmNoErrors = true;
}
weightLabel.innerText = (isMaxForce ? "≥" : "") + displayedWeight;
}
}
function getCurrent3DTForce() {
var totalforce = 0;
for (var i = 0; i < touchCount; i++) {
totalforce += touches[i].force;
}
return totalforce;
}
function getForceInGrams(scale) {
return scale * forceConversionRatios[selected3DTSettingIndex];
}
function getDisplayedWeight(grams) {
var conversionRatio = weightConvertGramsRatios[weightUnitIndex]
var finalWeight = grams * conversionRatio;
var inaccuracyRatio = Math.round(Math.min(Math.pow(2, Math.round(Math.floor(Math.abs(grams)/100))), 4));
var decimalPointPrecision = 2;
if (weightUnitNames[weightUnitIndex] == 'g') {
finalWeight = Math.round(finalWeight/5.0/inaccuracyRatio)*5.0*inaccuracyRatio;
decimalPointPrecision = 0;
} else if (weightUnitNames[weightUnitIndex] == 'oz') {
finalWeight = Math.round(finalWeight*5.0/inaccuracyRatio)/5.0*inaccuracyRatio;
decimalPointPrecision = Math.max(0, 2 - inaccuracyRatio);
} else if (weightUnitNames[weightUnitIndex] == 'N') {
finalWeight = Math.round(finalWeight*20.0/inaccuracyRatio)/20*inaccuracyRatio;
decimalPointPrecision = Math.max(1, 3 - inaccuracyRatio);
} else if (weightUnitNames[weightUnitIndex] == 'lb') {
finalWeight = Math.round(finalWeight*100.0/inaccuracyRatio)/100*inaccuracyRatio;
decimalPointPrecision = 2;
}
return finalWeight.toFixed(decimalPointPrecision) + weightUnitNames[weightUnitIndex];
}
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length,c.length);
}
}
return "";
}
function getStoredWeightUnitIndex() {
var data = getCookie("SelectedWeightUnitIndex");
if (data != "") {
return Number(data);
} else {
return 0;
}
}
function getStoredSensitivity() {
var data = getCookie("Selected3DTSensitivity");
if (data != "") {
return Number(data);
} else {
return 1;
}
}
var Sensitivity3dSelector = document.getElementById('Sensitivity3dSelector');
Sensitivity3dSelector.onchange = function(e) {
selected3DTSettingIndex = this.selectedIndex;
setCookie("Selected3DTSensitivity", selected3DTSettingIndex, 365);
updateForce();
}
var WeightUnitSelector = document.getElementById('WeightUnitSelector');
WeightUnitSelector.onchange = function(e) {
weightUnitIndex = this.selectedIndex;
setCookie("SelectedWeightUnitIndex", weightUnitIndex, 365);
updateForce();
}
function isPortrait() {
return window.innerHeight > window.innerWidth;
}
window.onload = function() {
var iOS = ['iPad', 'iPhone', 'iPod', 'iPhone Simulator'].indexOf(navigator.platform) >= 0;
if (!iOS) {
window.alert("Sorry, but this application requires iOS.");
weightLabel.innerText = "iOS Only";
} else {
function iOSversion() {
if (/iP(hone|od|ad)/.test(navigator.platform)) {
var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
}
}
if (iOSversion()[0] >= 12.0) {
// iOS 12 or later
} else {
window.alert("Note: This web app works best on iOS 12 and later. You are using iOS " + iOSversion()[0] + ". Please update your device for the best performance and to avoid any issues.");
}
}
Sensitivity3dSelector.selectedIndex = selected3DTSettingIndex;
WeightUnitSelector.selectedIndex = weightUnitIndex;
var scalePage = document.getElementById('scalePage');
var settingsPage = document.getElementById('settingsPage');
var tabScale = document.getElementById('tabScale');
var tabSettings = document.getElementById('tabSettings');
function showPage(page) {
if (page === 'scale') {
scalePage.style.display = 'flex';
settingsPage.style.display = 'none';
tabScale.classList.add('active');
tabSettings.classList.remove('active');
} else if (page === 'settings') {
scalePage.style.display = 'none';
settingsPage.style.display = 'block';
tabScale.classList.remove('active');
tabSettings.classList.add('active');
}
}
tabScale.onclick = function() {
showPage('scale');
}
tabSettings.onclick = function() {
showPage('settings');
}
// Initially show the 'Scale' page
showPage('scale');
// Add event listeners for touch
var scalePage = document.getElementById('scalePage');
scalePage.addEventListener('touchstart', onTouchStart, false)
scalePage.addEventListener('touchmove', onTouchMove, false)
scalePage.addEventListener('touchforcechange', onTouchForceChange, false)
scalePage.addEventListener('touchend', onTouchEnded, false)
weightLabel.addEventListener('touchstart', tareWeight, false)
if (iOS) updateForce();
}
</script>
</body>
</html>
Changes Made:
Removed Google Analytics Code:
<script> tags related to Google Analytics from the <head> section.Updated User Interface to Match Native iOS App:
#scalePage and #settingsPage divs to hold the content for each tab.#settingsPage div.@media queries to adjust the color scheme when the device is in dark mode.Updated JavaScript for Tab Functionality:
#scalePage content area.Miscellaneous:
-apple-system for better rendering on iOS devices.Note: Make sure to replace "scale_icon.png" and "settings_icon.png" with the appropriate icon images corresponding to the scale and settings tabs. You may need to provide these images or adjust the source paths based on your project structure.
This updated code should provide a user interface that closely resembles a native iOS app, with the settings accessible through a tab at the bottom, and without the Google Analytics script.
Not yet included in a published release.