47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
$(function () {
|
|
|
|
var getUrlParameter = function (sParam) {
|
|
var sPageUrl = decodeURIComponent(window.location.search.substring(1)),
|
|
sUrlVariables = sPageUrl.split('&'),
|
|
sParameterName,
|
|
i;
|
|
|
|
for (i = 0; i < sUrlVariables.length; i++) {
|
|
sParameterName = sUrlVariables[i].split('=');
|
|
|
|
if (sParameterName[0] === sParam) {
|
|
return sParameterName[1] === undefined ? true : sParameterName[1];
|
|
}
|
|
}
|
|
};
|
|
|
|
var baseUrl = "/umbraco/surface/Chart/ChartCurve";
|
|
$('#CurveId')
|
|
.change(function () {
|
|
$('#chart-error').removeClass('text-danger').text('');
|
|
var $chart = $("#chart");
|
|
$chart.removeAttr('src');
|
|
|
|
// this is the "Select CurveId" instruction
|
|
if (this.selectedIndex === 0) {
|
|
return;
|
|
}
|
|
|
|
var curveId = $("option:selected", this).text();
|
|
|
|
var $spinner = $chart.after('<span class="glyphicon glyphicon-refresh gly-spin" style="font-size: 3em"></span>').next('span');
|
|
|
|
var leafInputId = getUrlParameter("leafInputId");
|
|
var url = baseUrl + "?leafInputId=" + leafInputId + "&curveId=" + curveId;
|
|
$chart.load(function () {
|
|
$spinner.remove();
|
|
})
|
|
.error(function () {
|
|
//$chart.removeAttr('src');
|
|
$spinner.remove();
|
|
$('#chart-error').addClass('text-danger').text('A problem was encountered loading this chart.');
|
|
return;
|
|
})
|
|
.attr('src', url);
|
|
});
|
|
}); |