Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 47 additions & 32 deletions dist/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -9150,16 +9150,19 @@ SOCR - Statistical Online Computational Resource
/*
@method: createDotPlot
@description: Dot plot tab in the accordion is populated by this call.
Call invoked when "infer" button pressed in the controller tile.
"infer" button pressed in the controller tile -> appController -> appModel -> publishes "setInferenceSettingComplete".
@return : {boolean}
*/
createDotplot: function(setting) {
var binNo, datum, dotplot, e, end, err, flag, index, lSide, pvalue, rSide, start, stop, temp, total, values;
var binNo, datum, dotplot, e, end, err, flag, index, lSide, pvalue, rSide, start, stop, temp, total, values, __accordionDOMSelector__, __dotPlotDOMSelector__;
__dotPlotDOMSelector__ = "#dotplot";
__accordionDOMSelector__ = "#accordion";
$(__dotPlotDOMSelector__).html("");
if (setting.variable == null) {
throw new Error("invalid arguments: settings");
}
_currentVariable = setting.variable;
$("#accordion").accordion("activate", 2);
$(__accordionDOMSelector__).accordion("activate", 2);
Array.max = function(array) {
return Math.max.apply(Math, array);
};
Expand Down Expand Up @@ -9251,18 +9254,20 @@ SOCR - Statistical Online Computational Resource
}
binNo = ($("input[name=\"binno\"]").val() !== "" ? $("input[name=\"binno\"]").val() : 10);
_currentValues = values;
datum = Math.round(datum * Math.pow(10, setting.precision)) / Math.pow(10, setting.precision);
lSide = Math.round(lSide * Math.pow(10, setting.precision)) / Math.pow(10, setting.precision);
rSide = Math.round(rSide * Math.pow(10, setting.precision)) / Math.pow(10, setting.precision);
try {
dotplot = socr.vis.generate({
parent: "#dotplot",
parent: __dotPlotDOMSelector__,
data: values,
height: 390,
range: [start, stop],
datum: datum,
bins: binNo,
variable: setting.variable,
pl: lSide,
pr: rSide,
precision: setting.precision
pr: rSide
});
} catch (_error) {
e = _error;
Expand Down Expand Up @@ -9459,7 +9464,18 @@ SOCR - Statistical Online Computational Resource

(function() {
socr.controller = function(model, view) {
var MIN_SAMPLE_GENERATION_STEP_COUNT, MIN_SAMPLE_GENERATION_STEP_TIME, _currentMode, _generate, _id, _noOfSteps, _runCount, _runsElapsed, _this;
var MIN_SAMPLE_GENERATION_STEP_COUNT, MIN_SAMPLE_GENERATION_STEP_TIME, __accordionDOMSelector__, __controllerBackBtnDOMSelector__, __inferBtnDOMSelector__, __inferenceAnalysisDOMSelector__, __inferenceDatasetIndexDOMSelector__, __inferencePrecisionDOMSelector__, __inferenceVariableDOMSelector__, __resetBtnDOMSelector__, __runBtnDOMSelector__, __stepBtnDOMSelector__, __stopBtnDOMSelector__, _currentMode, _generate, _id, _noOfSteps, _runCount, _runsElapsed, _this;
__accordionDOMSelector__ = "#accordion";
__controllerBackBtnDOMSelector__ = ".controller-back";
__runBtnDOMSelector__ = "#runButton";
__stepBtnDOMSelector__ = "#stepButton";
__stopBtnDOMSelector__ = "#stopButton";
__resetBtnDOMSelector__ = "#resetButton";
__inferBtnDOMSelector__ = "#infer";
__inferenceDatasetIndexDOMSelector__ = "#index";
__inferenceVariableDOMSelector__ = "#variable";
__inferenceAnalysisDOMSelector__ = "#analysis";
__inferencePrecisionDOMSelector__ = '#result-precision';
_id = 0;
_runsElapsed = 0;
_runCount = 0;
Expand Down Expand Up @@ -9570,7 +9586,7 @@ SOCR - Statistical Online Computational Resource
var e;
model.setK();
$(".tooltips").tooltip();
$(".controller-back").on("click", function(e) {
$(__controllerBackBtnDOMSelector__).on("click", function(e) {
var err;
e.preventDefault();
try {
Expand All @@ -9584,28 +9600,28 @@ SOCR - Statistical Online Computational Resource
console.log(err.message);
}
});
$("#runButton").on("click", function(e) {
$(__runBtnDOMSelector__).on("click", function(e) {
e.preventDefault();
console.log("Run Started");
setTimeout(socr.controller.run, 500);
});
$("#stepButton").on("click", function(e) {
$(__stepBtnDOMSelector__).on("click", function(e) {
e.preventDefault();
console.log("Step pressed ");
socr.controller.step();
});
$("#stopButton").on("click", function(e) {
$(__stopBtnDOMSelector__).on("click", function(e) {
e.preventDefault();
console.log("Stop Pressed ");
socr.controller.stop();
PubSub.publish("randomSampleGenerationInterrupted", {});
});
$("#resetButton").on("click", function(e) {
$(__resetBtnDOMSelector__).on("click", function(e) {
e.preventDefault();
console.log("Reset pressed");
socr.controller.reset();
});
$("#infer").on("click", function(e) {
$(__inferBtnDOMSelector__).on("click", function(e) {
e.preventDefault();
if (model.getSample(1) === false) {
view.handleResponse("<h4 class=\"alert-heading\">No Random samples to infer From!</h4>Please generate some random samples in Step 2. ", "error", "controller-content");
Expand All @@ -9617,21 +9633,21 @@ SOCR - Statistical Online Computational Resource
setTimeout(socr.controller.setDotplot, 500);
}
});
$("#variable").on("change", function() {
$(__inferenceVariableDOMSelector__).on("change", function() {
if ($(this).val() === "Mean" || $(this).val() === "Count") {
$("#index").attr("disabled", false);
$(__inferenceDatasetIndexDOMSelector__).attr("disabled", false);
} else {
$("#index").attr("disabled", true);
$(__inferenceDatasetIndexDOMSelector__).attr("disabled", true);
}
});
$("#analysis").on("change", function() {
$(__inferenceAnalysisDOMSelector__).on("change", function() {
var el;
if (socr.analysis[$(this).val()] !== "undefined") {
el = "";
$.each(socr.analysis[$(this).val()]["variables"], function(key, value) {
el += "<option value=\"" + value + "\">" + value.replace("-", " ") + "</option>";
});
$("#variable").html(el);
$(__inferenceVariableDOMSelector__).html(el);
}
});
$(".update").on("click", function() {
Expand Down Expand Up @@ -9659,7 +9675,7 @@ SOCR - Statistical Online Computational Resource
*/
step: function() {
var e;
$("#accordion").accordion("activate", 1);
$(__accordionDOMSelector__).accordion("activate", 1);
view.disableButtons();
try {
model.generateSample();
Expand Down Expand Up @@ -9757,20 +9773,20 @@ SOCR - Statistical Online Computational Resource
}
});
},

/*
@description : When user clicks "infer" button, setDotplot is triggered.
*/
setDotplot: function(precision) {
var index;
$("#dotplot").html("");
index = parseInt($("#index").val());
precision = $('#result-precision').attr('checked');
if (precision === "checked") {
precision = 3;
}
console.log("setdotplot started", "variable:" + $("#variable").val());
var inferenceDatasetIndex, inferencePrecision;
inferenceDatasetIndex = parseInt($(__inferenceDatasetIndexDOMSelector__).val());
inferencePrecision = $(__inferencePrecisionDOMSelector__).val() || 4;
console.log("setdotplot started", "variable:" + $(__inferenceVariableDOMSelector__).val());
model.setInferenceSettings({
analysis: $("#analysis").val(),
variable: $("#variable").val(),
precision: precision,
index: index
analysis: $(__inferenceAnalysisDOMSelector__).val(),
variable: $(__inferenceVariableDOMSelector__).val(),
precision: inferencePrecision,
index: inferenceDatasetIndex
});
},

Expand Down Expand Up @@ -23458,7 +23474,6 @@ if (!Array.prototype.filter) {

})(jQuery, window, Handsontable);
$(document).ready(function(){
debugger
socr.dataTable = (function () {
$dataTable = $('#input');
var $controls = $('section.controls');
Expand Down
2 changes: 1 addition & 1 deletion dist/partials/controller.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<span>
<button class="btn btn-info popups" rel="popover" data-content="This will create a plot of the variable for each generated sample. Click this once you have generated some samples!" data-original-title="Inference" id="infer">Go</button>
</span>
<p>Precision to 3 decimal places.<input type='checkbox' checked id='result-precision'/></p>
<p>Precision to <input type='text' class="input-mini" value='4' id='result-precision'/> decimal places.</p>
</form>
</div>
<div id='setN' class="modal hide fade">
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ <h3>ABOUT</h3>
</div>
<div class="modal-body">
<p>The goal of this project is to design a modern and portable SOCR web-app that demonstrates the concepts of statistical analysis such as resampling, randomization and probabilistic simulation and runs seamlessly across varied devices.</p>
<p> Current Version: <strong>0.1.2</strong> </p>
<p> Current Version: <strong>0.3.2</strong> </p>
<p > Created by SOCR @ UMich . Code available under MIT Licence at <a href='https://github.com/SOCR/Resampling-Randomization-WebApp' target='_blank'>Github</a></p>
<br/>
<p class='fine-print'> Please send an email to selvam.palanimalai@gmail.com to report bugs.</p>
Expand Down
62 changes: 38 additions & 24 deletions src/appController.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@
###
socr.controller = (model, view) ->

# PRIVATE PROPERTIES
# PRIVATE PROPERTIES
__accordionDOMSelector__ = "#accordion"
__controllerBackBtnDOMSelector__ = ".controller-back"
__runBtnDOMSelector__ = "#runButton"
__stepBtnDOMSelector__ = "#stepButton"
__stopBtnDOMSelector__ = "#stopButton"
__resetBtnDOMSelector__ = "#resetButton"
__inferBtnDOMSelector__ = "#infer"

__inferenceDatasetIndexDOMSelector__ = "#index"
__inferenceVariableDOMSelector__ = "#variable"
__inferenceAnalysisDOMSelector__ = "#analysis"
__inferencePrecisionDOMSelector__ = '#result-precision'

_id = 0 # Stores the id for setInterval in run mode
_runsElapsed = 0 # Keeps count of number of resamples generated
Expand Down Expand Up @@ -154,7 +166,7 @@ socr.controller = (model, view) ->
model.setK()
$(".tooltips").tooltip()

$(".controller-back").on "click", (e) ->
$(__controllerBackBtnDOMSelector__).on "click", (e) ->
e.preventDefault()
try
model.reset()
Expand All @@ -166,32 +178,32 @@ socr.controller = (model, view) ->
console.log err.message
return

$("#runButton").on "click", (e) ->
$(__runBtnDOMSelector__).on "click", (e) ->
e.preventDefault()
console.log "Run Started"
setTimeout socr.controller.run, 500
return

$("#stepButton").on "click", (e) ->
$(__stepBtnDOMSelector__).on "click", (e) ->
e.preventDefault()
console.log "Step pressed "
socr.controller.step()
return

$("#stopButton").on "click", (e) ->
$(__stopBtnDOMSelector__).on "click", (e) ->
e.preventDefault()
console.log "Stop Pressed "
socr.controller.stop()
PubSub.publish "randomSampleGenerationInterrupted", {}
return

$("#resetButton").on "click", (e) ->
$(__resetBtnDOMSelector__).on "click", (e) ->
e.preventDefault()
console.log "Reset pressed"
socr.controller.reset()
return

$("#infer").on "click", (e) ->
$(__inferBtnDOMSelector__).on "click", (e) ->
e.preventDefault()

if model.getSample(1) is false
Expand All @@ -203,21 +215,21 @@ socr.controller = (model, view) ->

return

$("#variable").on "change", ->
$(__inferenceVariableDOMSelector__).on "change", ->
if $(this).val() is "Mean" or $(this).val() is "Count"
$("#index").attr "disabled", false
$(__inferenceDatasetIndexDOMSelector__).attr "disabled", false
else
$("#index").attr "disabled", true
$(__inferenceDatasetIndexDOMSelector__).attr "disabled", true
return

$("#analysis").on "change", ->
$(__inferenceAnalysisDOMSelector__).on "change", ->
if socr.analysis[$(this).val()] isnt "undefined"
el = ""
$.each socr.analysis[$(this).val()]["variables"], (key, value) ->
el += "<option value=\"" + value + "\">" + value.replace("-", " ") + "</option>"
return

$("#variable").html el
$(__inferenceVariableDOMSelector__).html el
return

$(".update").on "click", ->
Expand All @@ -242,7 +254,7 @@ socr.controller = (model, view) ->
@dependencies: view.animate()
###
step: ->
$("#accordion").accordion "activate", 1
$(__accordionDOMSelector__).accordion "activate", 1

#socr.view.toggleControllerHandle("hide");
view.disableButtons() #disabling buttons
Expand Down Expand Up @@ -354,18 +366,20 @@ socr.controller = (model, view) ->

return

setDotplot: (precision)->
$("#dotplot").html ""
index = parseInt($("#index").val())
precision = $('#result-precision').attr('checked')
if precision is "checked"
precision = 3
console.log "setdotplot started", "variable:" + $("#variable").val()
###
@description : When user clicks "infer" button, setDotplot is triggered.
###
setDotplot: (precision)->
inferenceDatasetIndex = parseInt($(__inferenceDatasetIndexDOMSelector__).val())
inferencePrecision = $(__inferencePrecisionDOMSelector__).val() || 4

console.log "setdotplot started", "variable:" + $(__inferenceVariableDOMSelector__).val()

model.setInferenceSettings
analysis: $("#analysis").val()
variable: $("#variable").val()
precision: precision
index: index
analysis: $(__inferenceAnalysisDOMSelector__).val()
variable: $(__inferenceVariableDOMSelector__).val()
precision: inferencePrecision
index: inferenceDatasetIndex
return

###
Expand Down
19 changes: 13 additions & 6 deletions src/appView.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -605,25 +605,28 @@ socr.view = (model) ->
###
@method: createDotPlot
@description: Dot plot tab in the accordion is populated by this call.
Call invoked when "infer" button pressed in the controller tile.
"infer" button pressed in the controller tile -> appController -> appModel -> publishes "setInferenceSettingComplete".
@return : {boolean}
###
createDotplot: (setting) ->
__dotPlotDOMSelector__ = "#dotplot"
__accordionDOMSelector__ = "#accordion"

$(__dotPlotDOMSelector__).html ""
throw new Error("invalid arguments: settings") unless setting.variable?
_currentVariable = setting.variable
$("#accordion").accordion "activate", 2
$(__accordionDOMSelector__).accordion "activate", 2

# Function to get the Max value in Array
Array.max = (array) ->
Math.max.apply Math, array


# Function to get the Min value in Array
Array.min = (array) ->
Math.min.apply Math, array

setting.index--;
#setting.variable;

switch setting.variable
when "Mean"
values = model.getMean(setting.index) #Mean values of all the generated random samples
Expand Down Expand Up @@ -723,9 +726,14 @@ socr.view = (model) ->
#datum = Math.floor(datum*100) / 100;
_currentValues = values

# fixing the precision
datum = Math.round( datum * Math.pow(10, setting.precision) ) / Math.pow(10, setting.precision)
lSide = Math.round( lSide * Math.pow(10, setting.precision) ) / Math.pow(10, setting.precision)
rSide = Math.round( rSide * Math.pow(10, setting.precision) ) / Math.pow(10, setting.precision)

try
dotplot = socr.vis.generate(
parent: "#dotplot"
parent: __dotPlotDOMSelector__
data: values
height: 390
range: [
Expand All @@ -737,7 +745,6 @@ socr.view = (model) ->
variable: setting.variable
pl: lSide
pr: rSide
precision:setting.precision
)

# nature: 'continuous'
Expand Down
Loading