[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] conga/luci/storage cylinder_select.js



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe sourceware org	2007-09-25 03:49:50

Added files:
	luci/storage   : cylinder_select.js 

Log message:
	Javascript code for selecting parts of the storage cylinder display

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/storage/cylinder_select.js.diff?cvsroot=cluster&r1=NONE&r2=1.1

/cvs/cluster/conga/luci/storage/cylinder_select.js,v  -->  standard output
revision 1.1
--- conga/luci/storage/cylinder_select.js
+++ -	2007-09-25 03:49:51.046752000 +0000
@@ -0,0 +1,118 @@
+/*
+** Copyright (C) 2006-2007 Red Hat, Inc.
+**
+** This program is free software; you can redistribute
+** it and/or modify it under the terms of version 2 of the
+** GNU General Public License as published by the
+** Free Software Foundation.
+*/
+
+var properties_span_id = '';
+var current_selection = '';
+var ellipse_dict = [ 2, 3, 4, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 8 ];
+
+function ellipse(y) {
+	if (y > 26)
+		return ellipse(40 - y);
+	if (y > 13)
+		return 9;
+	return ellipse_dict[y];
+}
+
+function select_subcyl(id, h_data) {
+	var old_selection = current_selection;
+	unselect_cyl(old_selection, h_data);
+	if (id == old_selection)
+		current_selection = h_data[0][0];
+	else
+		current_selection = id;
+	display_props(h_data);
+}
+
+function unselect_cyl(id, h_data) {
+	for (var i = 0 ; i < h_data.length ; i++) {
+		var t_id = h_data[i][0];
+		if (t_id == id) {
+			var list = h_data[i][1];
+			for (var j = 0 ; j < list.length ; j++) {
+				var el = document.getElementById(list[j]);
+				if (el)
+					el.className = 'invisible';
+			}
+		}
+	}
+	current_selection = '';
+}
+
+function display_props(h_data) {
+	for (var i = 0 ; i < h_data.length ; i++) {
+		var id = h_data[i][0];
+		if (id == current_selection) {
+			var list = h_data[i][1];
+			for (var j = 0; j < list.length ; j++) {
+				var el = document.getElementById(list[j]);
+				el.className = 'visible';
+			}
+		}
+	}
+
+	parent = top.document.getElementById(properties_span_id);
+
+	for (var i = 0 ; i < parent.childNodes.length ; i++) {
+		var item = parent.childNodes[i];
+		var item_type = item.nodeName.lower();
+		if (item_type == 'span' || item.type == 'div') {
+			if (item.id == current_selection) {
+				item.className = 'visible';
+			} else if (item.className == 'visible') {
+				item.className = 'invisible';
+			}
+		}
+	}
+}
+
+function cyl_click(X, Y, c_data, h_data) {
+	if (Y < 0 || Y > 40) {
+		return;
+	}
+
+	var x = X - ellipse(Y);
+	var y = Y;
+
+	for (var i = 0 ; i < c_data.length ; i++) {
+		var elem = c_data[i];
+		var id = elem[0];
+		var beg = elem[1][0];
+		var end = elem[1][1];
+		if (x > beg && x < end) {
+			select_subcyl(id, h_data);
+		}
+	}
+}
+
+function cyl_over(msg_board, X, Y, c_data, h_data) {
+	if (Y < 0 || Y > 40) {
+		msg_board.style.visibility = 'invisible';
+		return;
+	}
+
+	var x = X - ellipse(Y);
+	var y = Y;
+
+	for (var i = 0 ; i < c_data.length ; i++) {
+		var elem = c_data[i];
+		var beg = elem[1][0];
+		var end = elem[1][1];
+
+		if (x > beg && x < end) {
+			var descr = elem[2];
+			msg_board.innerHTML = descr;
+			msg_board.style.width = (descr.length + 1) + 'ex';
+			msg_board.style.left = X - 35;
+			msg_board.style.top = Y + 15;
+			msg_board.style.visibility = 'visible';
+			return;
+		}
+	}
+	msg_board.style.visibility = 'invisible';
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]