MemEOL: Difference between revisions

From Desal Wiki
imported>WikiAdmin
No edit summary
imported>WikiAdmin
No edit summary
(11 intermediate revisions by the same user not shown)
Line 255: Line 255:
return result;
return result;
}
}
    function initialise(){
        var preferences = getPreferences(); //get preferences
        var scores = computePreferenceScores(preferences); //calculate matrix and produce scores for each criterion
        console.log(scores);
        var scoreObject = scoresArrayToObject(scores); //convert from array to object
        //now that we can access the scores by name we can make the additonal calculations for reuse as RO and conversion to UF
        for (var property in scoreObject) {
            if (scoreObject.hasOwnProperty(property)) {
                console.log(scoreObject[property]);
            }
        }
        //adjust UF score
        if(scoreObject.hasOwnProperty(CONST_CONV_TO_UF)){
            scoreObject[CONST_CONV_TO_UF] = conversionToUFCalc(scoreObject[CONST_CONV_TO_UF], getPhysicalDamage());
        }
        for (var property in scoreObject) {
            if (scoreObject.hasOwnProperty(property)) {
                console.log(scoreObject[property]);
            }
        }
        //adjust RO score & determine RO reuse quality
        var roReuseResult=0;
        if(scoreObject.hasOwnProperty(CONST_REUSE_RO)){
            console.log('physical damage: ' + String(getPhysicalDamage()));
            console.log('permeability: ' + String(getPermeability()));
            console.log('salt rejection: ' + String(getNaClRejection()));
            roReuseResult = calculateROReuseQuality(getPhysicalDamage(), getPermeability(), getNaClRejection());
            console.log('roReuseResult: ' + String(roReuseResult));
            if(roReuseResult===-1){
                scoreObject[CONST_REUSE_RO]=0;
            }
        }
        //determine highest score & second highest scores
        var max=-1;
        var maxName="";
        var second=-1;
        var secondName="";
        for (var property in scoreObject) {
            if (scoreObject.hasOwnProperty(property)) {
                if(scoreObject[property]>max){
                    max = scoreObject[property];
                    maxName=property;
                } else if (scoreObject[property]===max) {
                    second = scoreObject[property];
                    secondName=property;
                    //ignore case that max===second===third
                } else if (scoreObject[property]>=second) {
                    second = scoreObject[property];
                    secondName=property;
                }
            }
            console.log(property + ': ' + String(scoreObject[property]));
            console.log(maxName + ': ' + String(max));
            console.log(secondName + ': ' + String(second));
        }
        console.log('final ' + maxName + ': ' + String(max));
        console.log('final ' + secondName + ': ' + String(second));
        displayResults(maxName, secondName);
        $('.nav-pills > .active').next('li').find('a').trigger('click');
    }


$( document ).ready(function() {
$( document ).ready(function() {
        mw.loader.using( ['jquery.ui.core', 'ext.bootstrap','ext.bootstrap.scripts', 'ext.bootstrap.styles'], function () {
            $('.form-memEOL').bootstrapValidator()
            .on('success.form.bv', function(e) {
            // Prevent form submission
                e.preventDefault();
                initialise();
                //$('.nav-pills > .active').next('li').find('a').trigger('click');
            });
        });
mw.loader.using( 'jquery.ui.core', function () {
mw.loader.using( 'jquery.ui.core', function () {
     $( ".memEOL-submit" )
     $( ".memEOL-submit" )
Line 263: Line 334:
       .click(function( event ) {
       .click(function( event ) {
       event.preventDefault(); //lock the button for now.
       event.preventDefault(); //lock the button for now.
 
                 initialise();
                 var preferences = getPreferences(); //get preferences
                var scores = computePreferenceScores(preferences); //calculate matrix and produce scores for each criterion
                console.log(scores);
                var scoreObject = scoresArrayToObject(scores); //convert from array to object
                //now that we can access the scores by name we can make the additonal calculations for reuse as RO and conversion to UF
                for (var property in scoreObject) {
                    if (scoreObject.hasOwnProperty(property)) {
                        console.log(scoreObject[property]);
                    }
                }
                //adjust UF score
                if(scoreObject.hasOwnProperty(CONST_CONV_TO_UF)){
                    scoreObject[CONST_CONV_TO_UF] = conversionToUFCalc(scoreObject[CONST_CONV_TO_UF], getPhysicalDamage());
                }
                for (var property in scoreObject) {
                    if (scoreObject.hasOwnProperty(property)) {
                        console.log(scoreObject[property]);
                    }
                }
                //adjust RO score & determine RO reuse quality
                var roReuseResult=0;
                if(scoreObject.hasOwnProperty(CONST_REUSE_RO)){
                    console.log('physical damage: ' + String(getPhysicalDamage()));
                    console.log('permeability: ' + String(getPermeability()));
                    console.log('salt rejection: ' + String(getNaClRejection()));
                    roReuseResult = calculateROReuseQuality(getPhysicalDamage(), getPermeability(), getNaClRejection());
                    console.log('roReuseResult: ' + String(roReuseResult));
                    if(roReuseResult===-1){
                        scoreObject[CONST_REUSE_RO]=0;
                    }
                }
                //determine highest score & second highest scores
                var max=-1;
                var maxName="";
                var second=-1;
                var secondName="";
                for (var property in scoreObject) {
                    if (scoreObject.hasOwnProperty(property)) {
                        if(scoreObject[property]>max){
                            max = scoreObject[property];
                            maxName=property;
                        } else if (scoreObject[property]===max) {
                            second = scoreObject[property];
                            secondName=property;
                            //ignore case that max===second===third
                        } else if (scoreObject[property]>=second) {
                            second = scoreObject[property];
                            secondName=property;
                        }
                    }
                    console.log(property + ': ' + String(scoreObject[property]));
                    console.log(maxName + ': ' + String(max));
                    console.log(secondName + ': ' + String(second));
                }
                console.log('final ' + maxName + ': ' + String(max));
                console.log('final ' + secondName + ': ' + String(second));
 
                displayResults(maxName, secondName);
                $('.nav-pills > .active').next('li').find('a').trigger('click');
       });
       });


Line 341: Line 353:
   });
   });
   });
   });
</script>
</script>
</head>
</head>
Line 370: Line 380:
<div class="col-sm-6">
<div class="col-sm-6">
<!--<div class="">-->
<!--<div class="">-->
<label for="damagedMembranesNo" class="radio"><input type="radio" class="control-label" name="damagedMembranes" id="damagedMembranesNo" value="damagedMembranesNo" />No</label>
<label for="damagedMembranesNo" class="radio"><input type="radio" class="control-label" name="damagedMembranes" id="damagedMembranesNo" value="damagedMembranesNo" data-bv-notempty="true" data-bv-notempty-message="Please indicate if the membrane has been damaged." />No</label>
<label for="damagedMembranesYes" class="radio"><input type="radio" class="control-label" name="damagedMembranes" id="damagedMembranesYes" value="damagedMembranesYes" />Yes</label>
<label for="damagedMembranesYes" class="radio"><input type="radio" class="control-label" name="damagedMembranes" id="damagedMembranesYes" value="damagedMembranesYes" />Yes</label>
<!--</div>-->
<!--</div>-->
Line 385: Line 395:
<html><head></head><body>
<html><head></head><body>
<div class="form-group">
<div class="form-group">
<label class="control-label" for="testedPermeability">Tested permeability (LMH/bar):</label>
<div class="col-sm-6 sr-only">
<input type="text" class="form-control" id="permeability" name="testedPermeability" placeholder="Tested permeability in LMH/bar" />
<label class="control-label sr-only" for="testedPermeability">Tested permeability (LMH/bar):</label>
</div>
<div class="col-sm-6">
<input type="text" class="form-control" id="permeability" name="testedPermeability" placeholder="Tested permeability in LMH/bar" data-bv-notempty="true" data-bv-notempty-message="Membrane permeability is required and cannot be empty." data-bv-stringlength="true" data-bv-stringlength-max="10" data-bv-stringlength-message="The membrane permeability must be less than 10 characters in length." data-bv-regexp="true" data-bv-regexp-regexp="^[0-9]+([\.][0-9]+)?$" data-bv-regexp-message="Please enter a number greater than 0." />
</div>
</div>
</div>
</body></html>
</body></html>
Line 394: Line 408:
</ul>
</ul>
<div class="panel-heading">What is the tested NaCl rejection of your membranes? (% NaCl rejection)</div>
<div class="panel-heading">What is the tested NaCl rejection of your membranes? (% NaCl rejection)</div>
<div class="panel-body form-horizontal">
<div class="panel-body">
<html><head></head><body>
<html><head></head><body>
<div class="form-group">
<div class="form-group">
<div class="col-sm-6 sr-only">
<label class="control-label sr-only" for="NaClRejection">Tested permeability (LMH/bar):</label>
<label class="control-label sr-only" for="NaClRejection">Tested permeability (LMH/bar):</label>
<input type="text" class="form-control" id="NaClRejection" name="NaClRejection" placeholder="% NaCl Rejection" />
</div>
<div class="col-sm-6">
<input type="text" class="form-control" id="NaClRejection" name="NaClRejection" placeholder="% NaCl Rejection" data-bv-notempty="true" data-bv-notempty-message="Salt rejection is required and cannot be empty." data-bv-stringlength="true" data-bv-stringlength-max="10" data-bv-stringlength-message="The salt rejection must be less than 10 characters in length." data-bv-regexp="true" data-bv-regexp-regexp="^[0-9]+([\.][0-9]+)?$" data-bv-regexp-message="Please enter a number between 0 and 100." />
</div>
</div>
</div>
</body></html>
</body></html>
Line 610: Line 628:
margin:auto;
margin:auto;
display:block;
display:block;
}
.has-feedback .form-control-feedback {
    top:0px;
    right:30px;
}
}
</style>
</style>
Line 616: Line 638:
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.11.1/additional-methods.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.11.1/additional-methods.js"></script>
-->
-->
<script>
</head><body></div></body></html>
    //validator
    $( document ).ready(function() {
        mw.loader.using( ['jquery.ui.core', 'ext.bootstrap','ext.bootstrap.scripts', 'ext.bootstrap.styles'], function () {
            $('.form-memEOL').bootstrapValidator({
                message: 'This value is not valid.',
                live: 'enabled',
                debug: true,
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                submitButtons: 'button[type="submit"]',
                fields: {
                    damagedMembranes: {
                        validators: {
                            notEmpty: {
                                message: 'Please indicate if the membrane has been damaged.'
                            }
                        }
                    },
                    testedPermeability: {
                            notEmpty: {
                                message: 'The permeability of your membranes is a required parameter for this decision tool.'
                            },
                            stringLength: {
                                max: 3,
                                message: 'Permeability value is too long.'
                            }/*,
                            regexp: {
                                regexp: /^[0-9]+([\.][0-9]+)?$/i,
                                message: 'Please enter a number (eg. 2.0).'
                            } */         
                    },
                    NaClRejection: {
                            notEmpty: {
                                message: 'The salt rejection of your membranes is a required parameter for this decision tool.'
                            },
                            stringLength: {
                                max: 20,
                                message: 'Salt rejection value is too long.'
                            },
                            regexp: {
                                regexp: /^[0-9][0-9]?([\.][0-9]+)?$/i,
                                message: 'Please enter a number between 0 and 100.'
                            }       
                    }
                }
            });
        });
    });
    //end validator
</script></head><body></div></body></html>
[[Category:Major Resources]]
[[Category:Major Resources]]
[[Category:Resources]]
[[Category:Resources]]

Revision as of 02:14, 6 January 2015

Introduction text

Do you suspect there is any physical damage to the membranes that would prevent them from being reused?

What is the tested permeability of your membranes (LMH/bar)?

What is the tested NaCl rejection of your membranes? (% NaCl rejection)

Please order the following criteria in the order of importance for your project (drag and drop):

  • Financial
  • Effort required
  • Environmental impact
  • Landfill impact
  • Public perception
Rank from most important to least important.

Based on your inputs, the optimum end-of-life scenario for your used membrane is:

A suitable alternative is: