var Log = {
elem: false,
write: function(text) { //Пишем вверху поля, что сейчас выполняется
if (!this.elem) this.elem = document.getElementById('log');
this.elem.innerHTML = text;
this.elem.style.left = (500 - this.elem.offsetWidth / 2) + 'px';
}
};
var names = new Array ();
var ids = new Array ();
var possible = new Array ();
var this_node;
function addEvent(obj, type, fn) {
if (obj.addEventListener) obj.addEventListener(type, fn, false);
else obj.attachEvent('on' + type, fn);
};
function init () {
Log.write("Загрузка...");
var infovis = document.getElementById('infovis');
var w = infovis.offsetWidth, h = infovis.offsetHeight;
//Инициализация данных в структуре JSON
//Параметры "$type" или "$dim" узлов
//переписывают параметры, глобально определенные
//в конструкторе RGraph
//tag=1 - начало, 2 - конец
var json = [
{
"id": "0", "name": "Начало",
"data": {
"$dim": 30,
"tag": 1
},
"adjacencies": [
{ "nodeTo": "1", "data": { "weight": 3 } },
{ "nodeTo": "2", "data": { "$color":"#dd99dd", "weight": 2 } }
]
},
{
"id": "1", "name": "Земля",
"data": {
"$dim": 30,
"$color": "blue"
},
"adjacencies": [
{ "nodeTo": "3", "data": { "weight": 3, "$color":"#224422" } },
{ "nodeTo": "8", "data": { "weight": 2, "$color":"#554422" } },
{ "nodeTo": "18", "data": { "weight": 3, "$color":"#442255" } }
]
},
{
"id": "2", "name": "Учёные",
"data": {
"$dim": 30,
"$type": "square",
"$color": "#333300"
},
"adjacencies": [
{ "nodeTo": "6", "data": { "$color":"#dd00dd", "$dim":20, "weight": 2 } },
{ "nodeTo": "7", "data": { "$color":"#dd99ee", "$dim":20, "weight": 2 } }
]
},
{
"id": "3", "name": "сгорает, или замерзает,
или падает на Солнце и",
"data": {
//'$aw': 0, //Вес
"$dim": 30,
"$color": "#333300",
"notfrom": "14,15"
},
"adjacencies": [
{ "nodeTo": "14", "data": { "$color":"#dd00dd", "$dim":25, "weight": 2 } },
{ "nodeTo": "15", "data": { "$color":"#dd99ee", "$dim":25, "weight": 2 } }
]
},
{
"id": "6", "name": "создают",
"data": {
"$dim": 30,
"$type": "square",
"$color": "#337788",
"notfrom": "19,20"
},
"adjacencies": [
{ "nodeTo": "19", "data": { "$color":"#dd00dd", "$dim":20, "weight": 2 } },
{ "nodeTo": "20", "data": { "$color":"#dd99ee", "$dim":20, "weight": 2 } }
]
},
{
"id": "7", "name": "открывают",
"data": {
"$dim": 30,
"$type": "square",
"$color": "#887733",
"notfrom": "19,20"
},
"adjacencies": [
{ "nodeTo": "19", "data": { "$color":"#dd00dd", "$dim":20, "weight": 2 } },
{ "nodeTo": "20", "data": { "$color":"#dd99ee", "$dim":20, "weight": 2 } }
]
},
{
"id": "8", "name": "сталкивается
с огромной кометой",
"data": {
"$dim": 26,
"$color": "#003366",
"$type": "triangle"
},
"adjacencies": [
{ "nodeTo": "9", "data": { "weight": 2 } },
{ "nodeTo": "10", "data": { "weight": 2, "$color":"#12e299" } },
{ "nodeTo": "11", "data": { "weight": 2, "$color":"#304050" } }
]
},
{
"id": "9", "name": "и взрывается",
"data": {
"$dim": 28,
"$color": "#443355",
"$type": "star",
"tag": 2
},
"adjacencies": []
},
{
"id": "10", "name": "но остаётся невредимой",
"data": {
"$dim": 29,
"$color": "#334455",
"$type": "star",
"tag": 2
},
"adjacencies": []
},
{
"id": "11", "name": "и не взрывается, но",
"data": {
"$dim": 26,
"$color": "#330066",
"notfrom": "14,15"
},
"adjacencies": [
{ "nodeTo": "14", "data": { "weight": 3 } },
{ "nodeTo": "15", "data": { "weight": 3 } }
]
},
{
"id": "14", "name": "все гибнут",
"data": {
"$dim": 30,
"$color": "#663300",
"$type": "star",
"tag": 2
},
"adjacencies": []
},
{
"id": "15", "name": "почти все гибнут",
"data": {
"$dim": 30,
"$color": "#993300",
"$type": "star",
"tag": 2
},
"adjacencies": []
},
{
"id": "18", "name": "подвергается нашествию",
"data": {
"$dim": 26,
"$color": "#334466",
"$type": "rectangle",
"$width": 90,
"$height": 30,
"notfrom": "19,20"
},
"adjacencies": [
{ "nodeTo": "19", "data": { "$color":"#cc99ee", "$dim":25, "weight": 2 } },
{ "nodeTo": "20", "data": { "$color":"#cc99ee", "$dim":55, "weight": 5 } }
]
},
{
"id": "19", "name": "маленьких",
"data": {
"$dim": 10,
"$color": "#998877",
"notfrom": "21,22,23,24,26" //!!! через запятую id узлов, переход с которых запрещен
},
"adjacencies": [
{ "nodeTo": "21", "data": { "$type":"arrow", "$direction": ["19", "21"], "$color":"#7755FF", "$dim":33, "weight": 3 } },
{ "nodeTo": "22", "data": { "$type":"arrow", "$direction": ["19", "22"], "$color":"#dd4433", "$dim":23, "weight": 2 } },
{ "nodeTo": "23", "data": { "$type":"arrow", "$direction": ["19", "23"], "$color":"#4433dd", "$dim":24, "weight": 3 } },
{ "nodeTo": "24", "data": { "$type":"arrow", "$direction": ["19", "24"], "$color":"#3344dd", "$dim":25, "weight": 2 } },
{ "nodeTo": "26", "data": { "$type":"arrow", "$direction": ["19", "26"], "$color":"#33dd44", "$dim":27, "weight": 2 } }
]
},
{
"id": "20", "name": "огромных",
"data": {
"$dim": 40,
"$color": "#778899",
"notfrom": "21,22,23,24,26"
},
"adjacencies": [
{ "nodeTo": "21", "data": { "$type":"arrow", "$direction": ["20", "21"], "$color":"#5577FF", "$dim":33, "weight": 3 } },
{ "nodeTo": "22", "data": { "$type":"arrow", "$direction": ["20", "22"], "$color":"#dd4433", "$dim":23, "weight": 2 } },
{ "nodeTo": "23", "data": { "$type":"arrow", "$direction": ["20", "23"], "$color":"#4433dd", "$dim":24, "weight": 3 } },
{ "nodeTo": "24", "data": { "$type":"arrow", "$direction": ["20", "24"], "$color":"#3344dd", "$dim":25, "weight": 2 } },
{ "nodeTo": "26", "data": { "$type":"arrow", "$direction": ["20", "26"], "$color":"#33dd44", "$dim":27, "weight": 2 } }
]
},
{
"id": "21", "name": "марсиан, селенитов,
внегалактических чудовищ - ",
"data": {
"$dim": 27,
"$color": "#334466",
"$type": "rectangle",
"$width": 40,
"$height": 60
},
"adjacencies": [
{ "nodeTo": "22", "data": { "$color":"#dd4433", "$dim":23, "weight": 2 } },
{ "nodeTo": "23", "data": { "$color":"#4433dd", "$dim":24, "weight": 3 } },
{ "nodeTo": "24", "data": { "$color":"#3344dd", "$dim":25, "weight": 2 } },
{ "nodeTo": "26", "data": { "$color":"#33dd44", "$dim":27, "weight": 2 } }
]
},
{
"id": "22", "name": "насекомых",
"data": {
"$dim": 28,
"$color": "#552277",
"$type": "triangle",
"notfrom": "27"
},
"adjacencies": [
{ "nodeTo": "27", "data": { "$type":"arrow", "$color":"#2255ee", "$dim":48, "weight": 2 } }
]
},
{
"id": "23", "name": "роботов",
"data": {
"$dim": 24,
"$color": "#223322",
"$type": "triangle",
"notfrom": "27"
},
"adjacencies": [
{ "nodeTo": "27", "data": { "$type":"arrow", "$color":"#3355ee", "$dim":48, "weight": 4 } }
]
},
{
"id": "24", "name": "пресмыкающихся",
"data": {
"$dim": 28,
"$color": "#663377",
"$type": "triangle",
"notfrom": "27"
},
"adjacencies": [
{ "nodeTo": "27", "data": { "$type":"arrow", "$color":"#4455ee", "$dim":48, "weight": 2 } }
]
},
{
"id": "26", "name": "странных внеземных созданий",
"data": {
"$dim": 30,
"$color": "#9977ee",
"$type": "triangle",
"notfrom": "27"
},
"adjacencies": [
{ "nodeTo": "27", "data": { "$type":"arrow", "$color":"#22ffee", "$dim":48, "weight": 3 } }
]
},
{
"id": "27", "name": "которые",
"data": {
"$dim": 30,
"$color": "#dd00dd",
"$type": "rectangle",
"$width": 65,
"$height": 65
},
"adjacencies": [
{ "nodeTo": "28", "data": { "$color":"#306090", "$dim":29, "weight": 4 } },
{ "nodeTo": "29", "data": { "$color":"#603090", "$dim":28, "weight": 3 } },
{ "nodeTo": "30", "data": { "$color":"#903060", "$dim":27, "weight": 2 } },
{ "nodeTo": "31", "data": { "$color":"#906630", "$dim":26, "weight": 3 } },
{ "nodeTo": "32", "data": { "$color":"#609033", "$dim":25, "weight": 4 } },
{ "nodeTo": "34", "data": { "$color":"#999033", "$dim":26, "weight": 3 } }
]
},
{
"id": "28", "name": "хотят наших женщин",
"data": {
"$dim": 30,
"$color": "#994455",
"$type": "square",
"notfrom": "40,41"
},
"adjacencies": [
{ "nodeTo": "40", "data": { "$type":"arrow", "$color":"#CC4499", "$dim":50, "weight": 4 } },
{ "nodeTo": "41", "data": { "$type":"arrow", "$color":"#CC4499", "$dim":50, "weight": 4 } },
{ "nodeTo": "38", "data": { "$color":"#eebb23", "$dim":28, "weight": 3 } }
]
},
{
"id": "29", "name": "относятся к нам хорошо",
"data": {
"$dim": 25,
"$color": "#33CCA0",
"$type": "star",
"tag" : 2
},
"adjacencies": []
},
{
"id": "30", "name": "относятся к нам хорошо,
но их никто не понимает",
"data": {
"$dim": 30,
"$color": "#ee8855",
"$type": "square",
"notfrom": "40,41"
},
"adjacencies": [
{ "nodeTo": "40", "data": { "$type":"arrow", "$color":"#339966", "$dim":46, "weight": 4 } },
{ "nodeTo": "41", "data": { "$type":"arrow", "$color":"#339966", "$dim":46, "weight": 4 } }
]
},
{
"id": "31", "name": "не понимают нас",
"data": {
"$dim": 20,
"$color": "#005144",
"$type": "square",
"notfrom": "40,41"
},
"adjacencies": [
{ "nodeTo": "40", "data": { "$type":"arrow", "$color":"#305609", "$dim":41, "weight": 5 } },
{ "nodeTo": "41", "data": { "$type":"arrow", "$color":"#305609", "$dim":41, "weight": 5 } }
]
},
{
"id": "32", "name": "трактуют нас
только как пищу",
"data": {
"$dim": 33,
"$color": "#AA4400",
"$type": "square",
"notfrom": "40,41,56"
},
"adjacencies": [
{ "nodeTo": "40", "data": { "$type":"arrow", "$color":"#994499", "$dim":45, "weight": 3 } },
{ "nodeTo": "41", "data": { "$type":"arrow", "$color":"#994499", "$dim":45, "weight": 3 } },
{ "nodeTo": "56", "data": { "$type":"arrow", "$color":"#99ee88", "$dim":24, "weight": 3 } }
]
},
{
"id": "34", "name": "отлично понимают нас",
"data": {
"$dim": 40,
"$color": "#114733",
"$type": "square",
"notfrom": "40,41"
},
"adjacencies": [
{ "nodeTo": "40", "data": { "$type":"arrow", "$color":"#dd6520", "$dim":37, "weight": 5 } },
{ "nodeTo": "41", "data": { "$type":"arrow", "$color":"#dd6520", "$dim":37, "weight": 5 } }
]
},
{
"id": "38", "name": "забирают несколько и исчезают",
"data": {
"$dim": 36,
"$color": "#004433",
"$type": "star",
"tag": 2
},
"adjacencies": []
},
{
"id": "40", "name": "и являются радиоактивными",
"data": {
"$dim": 20,
"$color": "#116133",
"$type": "circle",
"notfrom": "44,45,46,47"
},
"adjacencies": [
{ "nodeTo": "45", "data": { "$type":"arrow", "weight": 3, "$color":"#FF6600" } },
{ "nodeTo": "46", "data": { "$type":"arrow", "weight": 3, "$color":"#00EE88" } },
{ "nodeTo": "47", "data": { "$type":"arrow", "weight": 3, "$color":"#900909" } },
{ "nodeTo": "44", "data": { "$type":"arrow", "$color":"#f62128", "$dim":24, "weight": 3 } }
]
},
{
"id": "41", "name": "и являются нерадиоактивными",
"data": {
"$dim": 30,
"$color": "#541333",
"$type": "circle",
"notfrom": "44,45,46,47"
},
"adjacencies": [
{ "nodeTo": "45", "data": { "$type":"arrow", "weight": 3, "$color":"#FF6600" } },
{ "nodeTo": "46", "data": { "$type":"arrow", "weight": 3, "$color":"#00EE88" } },
{ "nodeTo": "47", "data": { "$type":"arrow", "weight": 3, "$color":"#909900" } },
{ "nodeTo": "44", "data": { "$type":"arrow", "$color":"#f62128", "$dim":24, "weight": 3 } }
]
},
{
"id": "44", "name": "и не могут быть уничтожены",
"data": {
"$dim": 30,
"$color": "#3300FF"
},
"adjacencies": [
{ "nodeTo": "51", "data": { "weight": 3, "$color":"#FF6600" } },
{ "nodeTo": "52", "data": { "weight": 3, "$color":"#00EE88" } },
{ "nodeTo": "53", "data": { "weight": 3, "$color":"#970929" } }
]
},
{
"id": "45", "name": "и могут быть уничтожены толпой
парней с факелами - и мы побеждаем их!",
"data": {
"$dim": 22,
"$color": "#FF6600",
"$type": "rectangle",
"$width": 90,
"$height": 30,
"tag": 2
},
"adjacencies": []
},
{
"id": "46", "name": "и могут быть уничтожены армией, флотом,
авиацией, морской пехотой и/или
войсками береговой охраны - и мы побеждаем их!",
"data": {
"$dim": 28,
"$color": "#00EE88",
"$type": "rectangle",
"$width": 90,
"$height": 40,
"tag": 2
},
"adjacencies": []
},
{
"id": "47", "name": "и могут быть уничтожены атомной бомбой
- и мы побеждаем их!",
"data": {
"$dim": 32,
"$color": "#312470",
"$type": "rectangle",
"$width": 90,
"$height": 50,
"tag": 2
},
"adjacencies": []
},
{
"id": "51", "name": "толпой парней с факелами",
"data": {
"$dim": 22,
"$color": "#FF6600",
"$type": "rectangle",
"$width": 90,
"$height": 30,
"notfrom": "54,55,56,57"
},
"adjacencies": [
{ "nodeTo": "54", "data": { "$color":"#FF6633", "$dim":15, "weight": 2 } },
{ "nodeTo": "55", "data": { "$color":"#33FF66", "$dim":15, "weight": 2 } },
{ "nodeTo": "56", "data": { "$color":"#6633FF", "$dim":15, "weight": 2 } },
{ "nodeTo": "57", "data": { "$color":"#3366FF", "$dim":15, "weight": 2 } }
]
},
{
"id": "52", "name": "армией, флотом, авиацией,
морской пехотой и/или
войсками береговой охраны",
"data": {
"$dim": 28,
"$color": "#004422",
"$type": "rectangle",
"$width": 90,
"$height": 40,
"notfrom": "54,55,56,57"
},
"adjacencies": [
{ "nodeTo": "54", "data": { "$color":"#33EE88", "$dim":15, "weight": 2 } },
{ "nodeTo": "55", "data": { "$color":"#33FF66", "$dim":15, "weight": 2 } },
{ "nodeTo": "56", "data": { "$color":"#6633FF", "$dim":15, "weight": 2 } },
{ "nodeTo": "57", "data": { "$color":"#3366FF", "$dim":15, "weight": 2 } }
]
},
{
"id": "53", "name": "атомной бомбой",
"data": {
"$dim": 32,
"$color": "#612280",
"$type": "rectangle",
"$width": 90,
"$height": 50,
"notfrom": "54,55,56,57"
},
"adjacencies": [
{ "nodeTo": "54", "data": { "$color":"#993399", "$dim":15, "weight": 2 } },
{ "nodeTo": "55", "data": { "$color":"#33FF66", "$dim":15, "weight": 2 } },
{ "nodeTo": "56", "data": { "$color":"#6633FF", "$dim":15, "weight": 2 } },
{ "nodeTo": "57", "data": { "$color":"#3366FF", "$dim":15, "weight": 2 } }
]
},
{
"id": "54", "name": "но",
"data": {
"$dim": 30,
"$color": "red",
"$type": "square"
},
"adjacencies": [
{ "nodeTo": "61", "data": { "$color":"#33EE88", "$dim":12, "weight": 4 } },
{ "nodeTo": "62", "data": { "$color":"#33FF66", "$dim":12, "weight": 4 } },
{ "nodeTo": "63", "data": { "$color":"#6633FF", "$dim":12, "weight": 4 } },
{ "nodeTo": "64", "data": { "$color":"#6633FF", "$dim":12, "weight": 4 } },
{ "nodeTo": "65", "data": { "$color":"#3366FF", "$dim":12, "weight": 4 } }
]
},
{
"id": "55", "name": "и они убивают нас",
"data": {
"$dim": 22,
"$color": "#FF6600",
"$type": "rectangle",
"$width": 90,
"$height": 30,
"tag": 2
},
"adjacencies": []
},
{
"id": "56", "name": "и они съедают нас",
"data": {
"$dim": 28,
"$color": "#EE3158",
"$type": "rectangle",
"$width": 90,
"$height": 40,
"tag": 2
},
"adjacencies": []
},
{
"id": "57", "name": "и они устанавливают систему
добродушной диктатуры",
"data": {
"$dim": 32,
"$color": "#326831",
"$type": "rectangle",
"$width": 90,
"$height": 50,
"tag": 2
},
"adjacencies": []
},
{
"id": "61", "name": "умирают от земных болезней",
"data": {
"$dim": 32,
"$color": "#641240",
"$type": "rectangle",
"$width": 90,
"$height": 50,
"tag": 2
},
"adjacencies": []
},
{
"id": "62", "name": "ученые изобретают
новое оружие",
"data": {
"$dim": 24,
"$color": "#446600",
"$type": "circle",
"notfrom": "67,72,73"
},
"adjacencies": [
{ "nodeTo": "67", "data": { "$color":"#553333", "$dim":15, "weight": 2 } },
{ "nodeTo": "72", "data": { "$type":"arrow", "$color":"#553322", "$dim":15, "weight": 2 } },
{ "nodeTo": "73", "data": { "$type":"arrow", "$color":"#335522", "$dim":15, "weight": 2 } }
]
},
{
"id": "63", "name": "некий ловкий юноша
убеждает их,
что люди хорошие",
"data": {
"$dim": 28,
"$color": "#226633",
"$type": "square",
"notfrom": "72,73,74"
},
"adjacencies": [
{ "nodeTo": "72", "data": { "$color":"#553333", "$dim":15, "weight": 2 } },
{ "nodeTo": "73", "data": { "$color":"#553322", "$dim":15, "weight": 2 } },
{ "nodeTo": "74", "data": { "$color":"#335522", "$dim":15, "weight": 2 } }
]
},
{
"id": "64", "name": "священник рассказывает
им о Боге",
"data": {
"$dim": 30,
"$color": "#440000",
"$type": "circle",
"notfrom": "72,73,74"
},
"adjacencies": [
{ "nodeTo": "72", "data": { "$color":"#554433", "$dim":15, "weight": 2 } },
{ "nodeTo": "73", "data": { "$color":"#552244", "$dim":15, "weight": 2 } },
{ "nodeTo": "74", "data": { "$color":"#445522", "$dim":15, "weight": 2 } }
]
},
{
"id": "65", "name": "влюбляются в красивую девушку",
"data": {
"$dim": 30,
"$color": "#cd4747",
"$type": "circle",
"notfrom": "72,73,74,78"
},
"adjacencies": [
{ "nodeTo": "72", "data": { "$color":"#558833", "$dim":15, "weight": 2 } },
{ "nodeTo": "73", "data": { "$color":"#552288", "$dim":15, "weight": 2 } },
{ "nodeTo": "74", "data": { "$color":"#885522", "$dim":15, "weight": 2 } },
{ "nodeTo": "78", "data": { "$color":"#885599", "$dim":15, "weight": 2 } }
]
},
{
"id": "67", "name": "которое отказывает",
"data": {
"$dim": 30,
"$color": "#464651",
"$type": "rectangle",
"$width": 60,
"$height": 40,
"notfrom": "55,56,57"
},
"adjacencies": [
{ "nodeTo": "55", "data": { "$color":"#33FF66", "$dim":15, "weight": 2 } },
{ "nodeTo": "56", "data": { "$color":"#6633FF", "$dim":15, "weight": 2 } },
{ "nodeTo": "57", "data": { "$color":"#3366FF", "$dim":15, "weight": 2 } }
]
},
{
"id": "72", "name": "и они умирают",
"data": {
"$dim": 22,
"$color": "#FF6600",
"$type": "rectangle",
"$width": 90,
"$height": 30,
"tag": 2
},
"adjacencies": []
},
{
"id": "73", "name": "и они превращаются в гадкие глыбы",
"data": {
"$dim": 28,
"$color": "#6400CC",
"$type": "rectangle",
"$width": 90,
"$height": 40,
"tag": 2
},
"adjacencies": []
},
{
"id": "74", "name": "и они улетают",
"data": {
"$dim": 32,
"$color": "#231971",
"$type": "rectangle",
"$width": 90,
"$height": 50,
"tag": 2
},
"adjacencies": []
},
{
"id": "78", "name": "женятся и живут долго и счастливо",
"data": {
"$dim": 32,
"$color": "#130372",
"$type": "rectangle",
"$width": 90,
"$height": 50,
"tag": 2
},
"adjacencies": []
}
];
//Конец структуры JSON
//Инициализация канвы
var canvas = new Canvas('mycanvas', {
'injectInto': 'infovis',
'width': w,
'height': h,
//Опционально - добавить фон канвы,
//на котором нарисованы концентрические окружности
'backgroundCanvas': {
'styles': {
'strokeStyle': '#444'
},
'impl': {
'init':
function() {},
'plot':
function(canvas, ctx) {
var times = 6, d = 200;
var pi2 = Math.PI * 2;
for (var i = 1; i <= times; i++) {
ctx.beginPath();
ctx.arc(0, 0, i * d, 0, pi2, true);
ctx.stroke();
ctx.closePath();
}
}
}
}
});
//Конец инициализации канвы
//Инициализация RGraph
var rgraph = new RGraph(canvas, {
//Параметры узлов и линий
//могут быть изменены, если определены
//в структуре JSON
//Можно изменить на свой вид узлов
Node: {
'overridable': true,
'color': '#cc0000'
},
Edge: {
'overridable': true,
'color': '#cccc00'
},
//Ставим полярную интерполяцию. По умолчанию линейная (linear).
interpolation: 'polar',
//Меняем эффект перехода с линейного на плавный (elastic).
transition: Trans.Elastic.easeOut,
//Меняем другие параметры анимации
duration:2000,
fps: 30,
//Расстояние от предка до потомка
levelDistance: 200,
//Этот метод вызывается перед отрисовкой линий
//Полезен для настройки их стилей
onBeforePlotLine: function(adj){
//Каждой линии назначается случайная толщина
if (!adj.data.$lineWidth)
adj.data.$lineWidth = Math.random() * 3 + 1;
},
onBeforeCompute: function(node) {
//Метод вызывается перед вычислением нового положения узлов
//Patched jit.js: если return false - обработки не будет
Log.write("обработка: " + node.name + "...");
//Блок контроля разрешений
var may = false;
var go_node = -1;
for (var i=0; i1 && node.id==ids[ids.length-2])) {
window.alert ('Этот переход запрещен');
return false;
}
}
}
//Блок формирования разрешений
possible = [];
possible.push (json[this_node].id);
for (var i=0; iСвязи:";
html += "";
Graph.Util.eachAdjacency (node, function(adj) {
var child = adj.nodeTo;
html += "- " + child.name + "
";
});
html += "
";
document.getElementById('inner-details').innerHTML = html;
//Сделать сюжет
if (node.data.tag==1) {
document.getElementById('inner-template').innerHTML = '';
names = [];
ids = [];
}
else {
//Блок перехода
var tmp = node.name;
if (ids.length < 2 || node.id != ids[ids.length-2]) {
names.push (tmp);
ids.push (node.id);
document.getElementById('inner-template').innerHTML += tmp+'
';
if (node.data.tag==2) window.alert ('Это последний пункт, текущая история закончена');
}
else { //Вернуться назад
names.pop ();
ids.pop ();
tmp = '';
for (i=0; i';
document.getElementById('inner-template').innerHTML = tmp;
}
}
return true;
},
//Добавляем обработчик кликов по узлам
//Метод вызывается 1 раз при создании узла
onCreateLabel: function(domElement, node){
domElement.innerHTML = node.name;
domElement.onclick = function () {
rgraph.onClick (node.id, { hideLabels: false });
};
var style = domElement.style;
style.cursor = 'pointer';
style.fontSize = "0.8em";
style.color = "#fff";
},
//Метод вызывается для размещения метки
onPlaceLabel: function(domElement, node){
var style = domElement.style;
var left = parseInt(style.left);
var w = domElement.offsetWidth;
style.left = (left - w / 2) + 'px';
},
onAfterCompute: function(){
Log.write("ОК"); //+json.length
}
});
//Начало работы
this_node = 0; //номер стартового узла в массиве json (не id!)
var n=json[this_node].adjacencies.length;
possible = [];
for (i=0; i