Projet

Général

Profil

« Précédent | Suivant » 

Révision bc28d3dc

IDbc28d3dc5bbaef5a60444798f9c4b332ac79b5f4
Parent 3a832cbc
Enfant 799a2e21

Ajouté par Jocelyn Delande il y a plus de 10 ans

adds and delete ref_points from js interface

Fichiers

  • ajouté
  • modifié
  • copié
  • renommé
  • supprimé

Voir les différences

Révisions

js/pano.js
39 39
var test = {x:0, y:0, i:100};
40 40

  
41 41

  
42
function getXMLHttpRequest() {
43
	var xhr = null;
44
	
45
	if (window.XMLHttpRequest || window.ActiveXObject) {
46
		if (window.ActiveXObject) {
47
			try {
48
				xhr = new ActiveXObject("Msxml2.XMLHTTP");
49
			} catch(e) {
50
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
51
			}
52
		} else {
53
			xhr = new XMLHttpRequest(); 
54
		}
55
	} else {
56
		alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest...");
57
		return null;
58
	}
59
	
60
	return xhr;
61
}
62

  
63

  
64

  
42 65
function nmodulo(val, div) {                // pour obtenir un modulo dans l'espace des nombres naturels N.
43 66
    return Math.floor((val%div+div)%div);   // il y a peut être plus simple, mais en attendant ....
44 67
}
......
252 275
    return fname;
253 276
}
254 277

  
278
function get_base_name() {
279
	/** 
280
	 * @returns the base name, which is the name (not path) of the folder where
281
	 * the tiles are.
282
	 */
283
	return img_prefix.split('/').reverse()[0];
284
}
285

  
286

  
255 287
function keys(key) {
256 288

  
257 289
    hide_links();
......
745 777
}
746 778

  
747 779
function insert_ref_point(el, x, y) {
748
    var label;
780
	var label, posx, posy;
749 781
    el.style.display = 'none';
750 782
    for(var i = 0; i < zm.pt_list.length; i++) {
751 783
	label = zm.pt_list[i]['label'];
752 784
	if(label == document.getElementById('sel_point').value) {
753
	    var posx = nmodulo(last.x + x - canvas.width/2, zm.im.width)/zm.im.width;
754
	    var posy = 0.5 - (last.y + y - canvas.height/2)/zm.im.height;
785
	    posx = nmodulo(last.x + x - canvas.width/2, zm.im.width)/zm.im.width;
786
	    posy = 0.5 - (last.y + y - canvas.height/2)/zm.im.height;
755 787
	    var pval = {x:posx, y:posy, cap:zm.pt_list[i]['cap'], ele:zm.pt_list[i]['ele'], label:label};
756 788
	    ref_points[label] = pval;
757 789
	    document.getElementById('res').innerHTML = '<h4>Dernier point entré</h4>';
......
761 793
	    break;
762 794
	}
763 795
    }
764
    show_result();
796
	show_result();
797
	
798
	// Then push the modif
799
	var xhr = getXMLHttpRequest();
800
	xhr.open("POST", "ajax/add_reference.php", true);
801
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
802
	xhr.send("ref_point="+encodeURIComponent(label)
803
	         +"&panorama="+encodeURIComponent(get_base_name())
804
	         +"&x="+posx+"&y="+posy);
765 805
}
766 806

  
767 807
function show_result(clear_before) {
......
776 816
}
777 817

  
778 818
function delete_ref_point(el) {
819
	var ref_name = document.getElementById('sel_point').value;
779 820
    el.style.display = 'none';
780
    delete ref_points[document.getElementById('sel_point').value];
821
    delete ref_points[ref_name];
781 822
    reset_zooms();
782 823
    putImage(last.x, last.y);
783
    show_result(true);
824
	show_result(true);
825
	
826
	// Then push the modif
827
	var xhr = getXMLHttpRequest();
828
	xhr.open("POST", "ajax/rm_reference.php", true);
829
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
830
	xhr.send("ref_point="+encodeURIComponent(ref_name)
831
	         +"&panorama="+encodeURIComponent(get_base_name()));
784 832
}
785 833

  
786 834
function clean_canvas_events(e) {