aboutsummaryrefslogtreecommitdiffstats
path: root/doc/schemaspy_hubzilla/schemaSpy.js
blob: d1a739d4e02a16461fab9d304584164080c92f44 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// table-based pages are expected to set 'table' to their name
var table = null;

// sync target's visibility with the state of checkbox
function sync(cb, target) {
  var checked = cb.attr('checked');
  var displayed = target.css('display') != 'none';
  if (checked != displayed) {
    if (checked)
      target.show();
    else
      target.hide();
  }
}

// sync target's visibility with the inverse of the state of checkbox
function unsync(cb, target) {
  var checked = cb.attr('checked');
  var displayed = target.css('display') != 'none';
  if (checked == displayed) {
    if (checked)
      target.hide();
    else
      target.show();
  }
}

// associate the state of checkbox with the visibility of target
function associate(cb, target) {
  sync(cb, target);
  cb.click(function() {
    sync(cb, target);
  });
}

// select the appropriate image based on the options selected
function syncImage() {
  var implied   = $('#implied').attr('checked');

  $('.diagram').hide();

  if (table) {
    if (implied && $('#impliedTwoDegreesImg').size() > 0) {
      $('#impliedTwoDegreesImg').show();
    } else {
      var oneDegree = $('#oneDegree').attr('checked');

      if (oneDegree || $('#twoDegreesImg').size() == 0) {
        $('#oneDegreeImg').show();
      } else {
        $('#twoDegreesImg').show();
      }
    }
  } else {
    var showNonKeys = $('#showNonKeys').attr('checked');

    if (implied) {
      if (showNonKeys && $('#impliedLargeImg').size() > 0) {
        $('#impliedLargeImg').show();
      } else if ($('#impliedCompactImg').size() > 0) {
        $('#impliedCompactImg').show();
      } else {
        $('#realCompactImg').show();
      }
    } else {
      if (showNonKeys && $('#realLargeImg').size() > 0) {
        $('#realLargeImg').show();
      } else {
        $('#realCompactImg').show();
      }
    }
  }
}

// our 'ready' handler makes the page consistent
$(function(){
  associate($('#implied'),         $('.impliedRelationship'));
  associate($('#showComments'),    $('.comment'));
  associate($('#showLegend'),      $('.legend'));
  associate($('#showRelatedCols'), $('.relatedKey'));
  associate($('#showConstNames'),  $('.constraint'));

  syncImage();
  $('#implied,#oneDegree,#twoDegrees,#showNonKeys').click(function() {
    syncImage();
  });

  unsync($('#implied'), $('.degrees'));
  $('#implied').click(function() {
    unsync($('#implied'), $('.degrees'));
  });

  unsync($('#removeImpliedOrphans'), $('.impliedNotOrphan'));
  $('#removeImpliedOrphans').click(function() {
    unsync($('#removeImpliedOrphans'), $('.impliedNotOrphan'));
  });
});