fixed sommatoria();

This commit is contained in:
kiki 2016-08-26 17:54:18 +02:00
parent 5580fd9f9f
commit 9ec79217ec
4 changed files with 172 additions and 12 deletions

View file

@ -29,15 +29,30 @@
* Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
* Enable inline JS: add 'unsafe-inline' to default-src
-->
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="stylesheet" href="themes/bluerelax.css" />
<link rel="stylesheet" href="themes/jquery.mobile.icons.min.css" />
<link rel="stylesheet" href="themes/jquery.mobile.structure-1.4.5.min.css" />
<script src="vendor/jquery-2.2.3.min.js"></script>
<script src="vendor/jquery.min.js"></script>
<script src="vendor/jquery.mobile-1.4.5.min.js"></script>
<script src="js/spesefurga.js"></script>
<script>
//$(function(){
$( document ).on( "mobileinit", function(){
$("#popup").popup();
});
/*$.mobile.document.on("click", "#open-popup", function (evt) {
$("#popup").popup("open", {
x: evt.pageX
, y: evt.pageY
});
evt.preventDefault();
});*/
</script>
<link rel="stylesheet" type="text/css" href="css/index.css">
<title>share fine</title>
</head>
@ -123,7 +138,7 @@
<h3 class="ui-bar ui-bar-a">Impostazioni</h3>
<div class="ui-body ui-body-a">
<div class="ui-body ui-body-a">
<p>Progetto</p>
<ul data-role="listview" data-theme="a">
<li id="prog-name">furga</li>
@ -133,9 +148,20 @@
<div data-role="collapsible" data-content-theme="false">
<h4>Modifica Progetto</h4>
<div data-role="controlgroup" data-type="horizontal">
<a href="#" class="ui-btn ui-corner-all ui-icon-plus">Cambia nome</a>
<a href="#popup1" id="open-popup1" data-rel="popup" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-icon-check ui-btn-icon-left ui-btn-a" data-position-to="window" data-transition="pop">Cambia nome</a>
<a href="#" class="ui-btn ui-corner-all ui-icon-delete">Cancella il progetto</a>
</div>
<div data-role="popup" id="popup1" data-theme="a" class="ui-corner-all">
<form>
<div style="padding:10px 20px;">
<h3>Cambia nome</h3>
<label for="p-name" class="ui-hidden-accessible">Nome:</label>
<input name="pass" id="p-name" value="" placeholder="camper Ada" data-theme="a" type="text">
<a href="#" id="setname" class="ui-btn ui-corner-all ui-shadow ui-btn-b ui-btn-icon-left ui-icon-check">Fatto</a >
</div>
</form>
</div>
</div>
<div class="ui-body ui-body-a">
<table data-role="table" id="table-spese" data-mode="columntoggle" class="ui-body-d ui-shadow table-stripe ui-responsive" data-column-btn-theme="a" data-column-btn-text="Colonne visibili..." data-column-popup-theme="a">
@ -178,13 +204,25 @@
</div>
<div data-role="collapsible" data-content-theme="false">
<h4>Modifica Spese</h4>
<a href="#popup" id="open-popup" data-rel="popup" data-position-to="window" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-icon-check ui-btn-icon-left ui-btn-a" data-transition="pop">Sign in</a>
<div data-role="controlgroup" data-type="horizontal">
<a href="#" class="ui-btn ui-corner-all ui-icon-plus">Aggiungi</a>
<a href="#" onclick="$('h4').css('color','red')" class="ui-btn ui-corner-all ui-icon-plus">Aggiungi</a>
<a href="#" class="ui-btn ui-corner-all ui-icon-delete">Cancella l'ultima</a>
</div>
</div>
<div data-role="popup" id="popup" data-theme="a" class="ui-corner-all">
<form>
<div style="padding:10px 20px;">
<h3>Please sign in</h3>
<label for="un" class="ui-hidden-accessible">Username:</label>
<input name="user" id="un" value="" placeholder="username" data-theme="a" type="text">
<label for="pw" class="ui-hidden-accessible">Password:</label>
<input name="pass" id="pw" value="" placeholder="password" data-theme="a" type="password">
<button type="submit" class="ui-btn ui-corner-all ui-shadow ui-btn-b ui-btn-icon-left ui-icon-check">Sign in</button>
</div>
</form>
</div>
<div class="ui-body ui-body-a">
<p>Soci aderenti al progetto</p>
<ul data-role="listview" data-theme="a">
@ -203,10 +241,10 @@
</div>
<div class="ui-body ui-body-a">
<div class="ui-body ui-body-a">
<p>Durata del progetto</p>
<p><span id="prog-time">365</span> giorni</p>
<p><span id="prog-time">365</span> giorni</p>
</div>
<div data-role="collapsible" data-content-theme="false">
@ -234,4 +272,4 @@
<script type="text/javascript" src="js/index.js"></script>
</body>
</html>
</html>

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
var app = {
/*var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
@ -48,4 +48,4 @@ var app = {
}
};
app.initialize();
app.initialize();*/

View file

@ -0,0 +1,117 @@
var prog_name=[];
var prog_data=[];
var prog_indice=0;
var sbollo=100;
var sassicurazione=600;
var deposito=600;
var totale=sbollo+sassicurazione+deposito;
console.log(totale+ "totale");
var user=["gabri", "ge", "brogie", "col_G"];
var giorni_uso=[23, 14, 200, 12];
//se lo si usa come collettivo vale 1 o vale 4?!
var s_giorni_uso=0;
var days=[23,23,23,23];
var n_user=user.length;
console.log(user.length+" utenti");
var p_annuale=(totale/n_user);
var p_giornaliero=p_annuale/365;
var full_giornaliero = totale/365;
var giorni_comuni=365;
var q_giorni_comuni=p_giornaliero*giorni_comuni;
var quote=[];
console.log(p_giornaliero+" piano giornaliera a capa");
console.log(p_annuale+" piano annuale a capa, "+(365/n_user)+" giorni");
function sommatoria(array_x){
var variabile=0;
for(var i=0;i<array_x.length;i=i+1){
variabile += array_x[i];
}
return variabile;
//attenzione non è universale! ma non so come assegnare quella variabile a s_giorni_uso come argomento. rimane sempre zero.why?
// console.log(variabile+"variabile sommatoria")
}
function conguaglio(){
var quota=0;
s_giorni_uso = sommatoria(giorni_uso);
console.log(s_giorni_uso +" giorni in cui il furgone è stato usato");
giorni_comuni= 365-s_giorni_uso;
console.log(giorni_comuni+ " giorni di inutilizzo")
q_giorni_comuni=p_giornaliero*giorni_comuni;
console.log(q_giorni_comuni+ "quota per i giorni di inutilizzo")
for(var i=0;i<user.length;i=i+1){
quota=(giorni_uso[i]*full_giornaliero)+q_giorni_comuni;
console.log("quota "+ user[i]+" (giorni "+giorni_uso[i]+"): "+quota)
quote.push(quota);
}
}
conguaglio();
function message(div,msg){
$(div).html(msg);
};
//console.log(quote)
// sommatoria(quote)
$(function(){
$( "#setname" ).on( "click", function( event ) {
// Prevent the usual navigation behavior
event.preventDefault();
setpropname();
$(`#popup1`).popup(`close`);
});
});
function setpropname(){
prog_name.push($(`#p-name`).prop(`value`));
console.log(prog_name[0]);
message(`#prog-name`,prog_name[0]);
};
$( "#setname" ).on( "click", function( event ) {
// Prevent the usual navigation behavior
event.preventDefault();
setpropname();
});

5
furgaclient/www/vendor/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long