links.js 1.19 KB
{% load staticfiles %}
{% load hash %}
{% load jsonify %}

var schema = new Array();
var connected = new Array();
var same = new Array();

{% for ident, connected in complement_position.items %}
    connected["{{ ident }}"] = jQuery.parseJSON('{{ connected|hash:0|jsonify }}');
    same["{{ ident }}"] = jQuery.parseJSON('{{ connected|hash:1|jsonify }}');
    schema["{{ ident }}"] = jQuery.parseJSON('{{ connected|hash:2|jsonify }}');
{% endfor %}

var id = "";

function onClick(td_id) {
    if (id) {
        color(id, "", "", "", "");
    }
    if (id == td_id) {
        id = ""
    } else {
        id = td_id;
        color(id, "LightSteelBlue", "#E9E9E9", "#949494", "LightSteelBlue");
    }
}    

function color(what, how, subschema_background, subschema_text, self) {

    for (i = 0; i < schema[what].length; i++) {
        $('#' + schema[what][i]).css('background-color', subschema_background);
        $('#' + schema[what][i]).css('color', subschema_text);
    }
    for (i = 0; i < connected[what].length; i++) {
        $('#' + connected[what][i]).css('background-color', how);
    }
    for (i = 0; i < same[what].length; i++) {
        $('#' + same[what][i]).css('background-color', self);
    }

}