Commit f9163829 authored by Tom Dwelly's avatar Tom Dwelly
Browse files

added print to png button, added vers2d/run2d field

parent e13d97a6
......@@ -28,7 +28,7 @@
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
var ctx = canvas.getContext("2d", {'alpha': false});
ctx.canvas.width = window.innerWidth * 0.96;
ctx.canvas.height = window.innerHeight * 0.6;
......@@ -519,7 +519,13 @@ function plotData() {
var dx_inv = (xsize-padx)/(x1-x0);
var dy_inv = (ysize-2.*pady)/(y1-y0);
var dx2_inv = (xsize-padx)*(1.+znow)/(x1-x0);
ctx.clearRect (0 ,0,canvas.width, canvas.height);
// ctx.clearRect (0 ,0,canvas.width, canvas.height);
ctx.fillStyle = "white";
ctx.rect(0, 0, canvas.width, canvas.height);
ctx.fill();
ctx.fillStyle = "black";
ctx.strokeStyle = "#000000";
//determine the tics to use
......@@ -942,6 +948,25 @@ function applyOffset(xfrac,yfrac){
plotData();
}
function check_valid_conf_class(z_conf_person, class_person){
var result = false;
// console.log(z_conf_person);
// console.log(class_person);
// console.log(typeof z_conf_person);
// console.log(typeof class_person);
if ( (z_conf_person == 0 && class_person == "NONE") ||
(z_conf_person == 1 && class_person == "QSO" )) { result = true; }
else if ( (z_conf_person >= 2 && z_conf_person <= 3) &&
(class_person == "NONE" ||
class_person == "STAR" ||
class_person == "QSO" ||
class_person == "GALAXY" ||
class_person == "QSO_BAL" ||
class_person == "BLAZAR") ) { result = true; }
return result;
}
//see guide at https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/Sending_forms_through_JavaScript
//write required values to url encoded string and send using an XMLHttpRequest
function submitVIinfo(){
......@@ -976,6 +1001,12 @@ function submitVIinfo(){
}
}
// catch invalid combinations of class/z_conf
if ( !check_valid_conf_class(Number(z_conf_person), class_person) )
{
alert('Error! You supplied an illegal combination of Z_CONF_PERSON and CLASS_PERSON.');
}
FD.append("PLATE" ,plate);
FD.append("MJD" ,mjd);
FD.append("FIBERID" ,fiberid);
......@@ -1082,6 +1113,7 @@ function writePipeInfo(){
case "PLATE": document.getElementById("pipeParams_PLATE" ).innerHTML = keyvals[i]; break;
case "MJD": document.getElementById("pipeParams_MJD" ).innerHTML = keyvals[i]; break;
case "FIBERID": document.getElementById("pipeParams_FIBERID" ).innerHTML = keyvals[i]; break;
case "RUN2D": document.getElementById("pipeParams_RUN2D" ).innerHTML = keyvals[i]; break;
case "PLUG_RA": document.getElementById("pipeParams_PLUG_RA" ).innerHTML = keyvals[i]; ra = Number(keyvals[i]); break;
case "PLUG_DEC": document.getElementById("pipeParams_PLUG_DEC" ).innerHTML = keyvals[i]; dec = Number(keyvals[i]); break;
case "Z": document.getElementById("pipeParams_Z" ).innerHTML = precise(keyvals[i],7); break;
......@@ -1283,3 +1315,12 @@ function writeLineListTable(linelist){
nrows ++;
}
}
function downloadPng(){
var plate = parseInt(document.getElementById("pipeParams_PLATE").innerHTML);
var mjd = parseInt(document.getElementById("pipeParams_MJD").innerHTML);
var fiberid = parseInt(document.getElementById("pipeParams_FIBERID").innerHTML);
document.getElementById("downloader").download = "spec-" + ("0000" + plate).slice(-4) + "-" + mjd + "-" + ("0000" + fiberid).slice(-4) + ".png";
document.getElementById("downloader").href = document.getElementById("myCanvas").toDataURL("image/png").replace(/^data:image\/[^;]/, 'data:application/octet-stream');
}
......@@ -75,6 +75,7 @@
<th title="SDSS Plate index">Plate</th>
<th title="MJD when this plate was last observed">MJD</th>
<th title="SDSS fiber index">FiberID</th>
<th title="SDSS 'RUN2D/VERS2D' pipeline version">RUN2D</th>
<th title="Right Ascension of plugged fiber (deg, J2000)">RA<sub>plug</sub></th>
<th title="Declination of plugged fiber (deg, J2000)">Dec<sub>plug</sub></th>
<th title="SDSS 1D pipeline redshift">Z<sub>pipe</sub></th>
......@@ -90,6 +91,7 @@
<td id="pipeParams_PLATE" ></td>
<td id="pipeParams_MJD" ></td>
<td id="pipeParams_FIBERID" ></td>
<td id="pipeParams_RUN2D" ></td>
<td id="pipeParams_PLUG_RA" ></td>
<td id="pipeParams_PLUG_DEC" ></td>
<td id="pipeParams_Z" ></td>
......@@ -294,6 +296,8 @@
<p id="inspectInBrowser"></p>
<a href="#" id="downloader" onclick="downloadPng()" download="spectrum.png"><button type="button">Download as png</button></a>
<hr>
<h4>Usage:</h4>
<p><blockquote><samp>http://erosita-bhm.mpe.mpg.de/speccy/speccy.html?specfile={URL}</samp></blockquote>&nbsp; (substitute URL of a valid speccy file)<br>
......@@ -400,6 +404,14 @@
<div style='text-align:left'>[<a href='/impressum'>Imprint</a> <a href='/data-protection'>Privacy Policy</a>]</div>
<script src="./js/speccy.js" type="text/javascript"></script>
<script type="text/javascript">
// function downloadPng(){
//
// document.getElementById("downloader").download = "image.png";
// document.getElementById("downloader").href = document.getElementById("myCanvas").toDataURL("image/png").replace(/^data:image\/[^;]/, 'data:application/octet-stream');
// }
</script>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment