aboutsummaryrefslogtreecommitdiffstats
path: root/doc/schemaspy_hubzilla/schemaSpy.js
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-11-08 16:57:56 +1100
committerredmatrix <redmatrix@redmatrix.me>2015-11-08 16:57:56 +1100
commit1874346c460c29a087bb81833c0b760a91e35970 (patch)
tree4037bfe80525236c0eb493fcf28f05f663ef83f9 /doc/schemaspy_hubzilla/schemaSpy.js
parent16040063dc7bea1f6d4d76131ae8f84505531900 (diff)
parentdf2b687a95b8ad6ed58d9557aaa837f88b57f04a (diff)
downloadvolse-hubzilla-1874346c460c29a087bb81833c0b760a91e35970.tar.gz
volse-hubzilla-1874346c460c29a087bb81833c0b760a91e35970.tar.bz2
volse-hubzilla-1874346c460c29a087bb81833c0b760a91e35970.zip
Merge pull request #129 from HaakonME/master
Hubzilla database entity-relationship documentation and HonO fix
Diffstat (limited to 'doc/schemaspy_hubzilla/schemaSpy.js')
-rw-r--r--doc/schemaspy_hubzilla/schemaSpy.js97
1 files changed, 97 insertions, 0 deletions
diff --git a/doc/schemaspy_hubzilla/schemaSpy.js b/doc/schemaspy_hubzilla/schemaSpy.js
new file mode 100644
index 000000000..d1a739d4e
--- /dev/null
+++ b/doc/schemaspy_hubzilla/schemaSpy.js
@@ -0,0 +1,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'));
+ });
+});