Spaces:
Sleeping
Sleeping
Update nutri_call.html
Browse files- nutri_call.html +33 -47
nutri_call.html
CHANGED
|
@@ -813,59 +813,45 @@ function showCalculationStatus(response) {
|
|
| 813 |
}
|
| 814 |
</style>
|
| 815 |
<script type="module">
|
| 816 |
-
import
|
| 817 |
-
import
|
| 818 |
-
import 'https://cdn.jsdelivr.net/npm/@pnotify/
|
| 819 |
-
import 'https://cdn.jsdelivr.net/npm/@pnotify/bootstrap4@5.2.0/dist/PNotifyBootstrap4.css';
|
| 820 |
|
| 821 |
-
defaultModules.set(PNotifyMobile
|
|
|
|
| 822 |
|
| 823 |
window.showCalculationStatus = function(response) {
|
| 824 |
-
const
|
| 825 |
-
<div class="pnotify-card">
|
| 826 |
-
<div class="card-header success">
|
| 827 |
-
<svg class="icon" viewBox="0 0 24 24"><path fill="currentColor" d="M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M10 17L5 12L6.41 10.59L10 14.17L17.59 6.58L19 8L10 17Z"/></svg>
|
| 828 |
-
<h3>Расчёт успешен</h3>
|
| 829 |
-
</div>
|
| 830 |
-
<div class="card-body">
|
| 831 |
-
<p>Все элементы идеально сбалансированы</p>
|
| 832 |
-
<small>Общая концентрация: ${response.total_ppm.toFixed(2)} ppm</small>
|
| 833 |
-
</div>
|
| 834 |
-
</div>
|
| 835 |
-
`;
|
| 836 |
-
|
| 837 |
-
const errorTemplate = `
|
| 838 |
-
<div class="pnotify-card">
|
| 839 |
-
<div class="card-header error">
|
| 840 |
-
<svg class="icon" viewBox="0 0 24 24"><path fill="currentColor" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"/></svg>
|
| 841 |
-
<h3>Обнаружены дефициты</h3>
|
| 842 |
-
</div>
|
| 843 |
-
<div class="card-body">
|
| 844 |
-
<ul>
|
| 845 |
-
${Object.entries(response.deficits).map(([el, val]) => `
|
| 846 |
-
<li><strong>${el}:</strong> ${val.toFixed(2)} ppm</li>
|
| 847 |
-
`).join('')}
|
| 848 |
-
</ul>
|
| 849 |
-
</div>
|
| 850 |
-
</div>
|
| 851 |
-
`;
|
| 852 |
-
|
| 853 |
-
alert({
|
| 854 |
-
type: Object.keys(response.deficits || {}).length === 0 ? 'success' : 'error',
|
| 855 |
-
text: Object.keys(response.deficits || {}).length === 0 ? successTemplate : errorTemplate,
|
| 856 |
-
delay: 4000,
|
| 857 |
-
width: '320px',
|
| 858 |
modules: {
|
| 859 |
-
|
| 860 |
-
|
| 861 |
-
},
|
| 862 |
-
Animate: {
|
| 863 |
-
animate: true,
|
| 864 |
-
inClass: 'zoomIn',
|
| 865 |
-
outClass: 'zoomOut'
|
| 866 |
}
|
| 867 |
}
|
| 868 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 869 |
};
|
| 870 |
</script>
|
| 871 |
|
|
|
|
| 813 |
}
|
| 814 |
</style>
|
| 815 |
<script type="module">
|
| 816 |
+
import PNotify from 'https://cdn.jsdelivr.net/npm/@pnotify/core@5/dist/PNotify.js';
|
| 817 |
+
import PNotifyMobile from 'https://cdn.jsdelivr.net/npm/@pnotify/mobile@5/dist/PNotifyMobile.js';
|
| 818 |
+
import PNotifyBootstrap4 from 'https://cdn.jsdelivr.net/npm/@pnotify/bootstrap4@5/dist/PNotifyBootstrap4.js';
|
|
|
|
| 819 |
|
| 820 |
+
PNotify.defaultModules.set(PNotifyMobile);
|
| 821 |
+
PNotify.defaultModules.set(PNotifyBootstrap4);
|
| 822 |
|
| 823 |
window.showCalculationStatus = function(response) {
|
| 824 |
+
const defaults = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 825 |
modules: {
|
| 826 |
+
Mobile: {
|
| 827 |
+
swipeDismiss: true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 828 |
}
|
| 829 |
}
|
| 830 |
+
};
|
| 831 |
+
|
| 832 |
+
if (Object.keys(response.deficits || {}).length === 0) {
|
| 833 |
+
new PNotify({
|
| 834 |
+
...defaults,
|
| 835 |
+
title: 'Успешный расчёт',
|
| 836 |
+
text: 'Все элементы сбалансированы!',
|
| 837 |
+
type: 'success',
|
| 838 |
+
icon: 'fas fa-check-circle',
|
| 839 |
+
delay: 3000,
|
| 840 |
+
width: '300px'
|
| 841 |
+
});
|
| 842 |
+
} else {
|
| 843 |
+
new PNotify({
|
| 844 |
+
...defaults,
|
| 845 |
+
title: 'Обнаружены отклонения',
|
| 846 |
+
text: Object.entries(response.deficits)
|
| 847 |
+
.map(([el, val]) => `${el}: ${val.toFixed(2)} ppm`)
|
| 848 |
+
.join('<br>'),
|
| 849 |
+
type: 'error',
|
| 850 |
+
icon: 'fas fa-exclamation-triangle',
|
| 851 |
+
delay: 5000,
|
| 852 |
+
width: '300px'
|
| 853 |
+
});
|
| 854 |
+
}
|
| 855 |
};
|
| 856 |
</script>
|
| 857 |
|