File: moat.js

package info (click to toggle)
virtuoso-opensource 7.2.5.1%2Bdfsg1-0.3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 285,240 kB
  • sloc: ansic: 641,220; sql: 490,413; xml: 269,570; java: 83,893; javascript: 79,900; cpp: 36,927; sh: 31,653; cs: 25,702; php: 12,690; yacc: 10,227; lex: 7,601; makefile: 7,129; jsp: 4,523; awk: 1,697; perl: 1,013; ruby: 1,003; python: 326
file content (116 lines) | stat: -rw-r--r-- 2,912 bytes parent folder | download | duplicates (7)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
function moat_init ()
{
  var tags = $("post_tags").value;
  var moat = $("tb_moat");
  var msg = OAT.Dom.text ("Associate your tags, in the current context, with one or more of the following things or concepts:");
  var arr = tags.split (",");
  var nodes = 0;
  OAT.Dom.clear (moat);
  for (var i = 0; i < arr.length; i++)
    {
      var tag = arr[i].trim();
      if (tag.length < 1)
	continue;
      if (0 == i) 
	moat.appendChild (msg);
      var fset = OAT.Dom.create("fieldset",{});
      var div = OAT.Dom.create("div",{});
      var legend = OAT.Dom.create("legend",{});
      var text = OAT.Dom.text (tag, {});
      var a = OAT.Dom.create ("a", {});

      a.appendChild (text);
      assign_cl (a, div);
      a.href="javascript:void(0)";
      legend.appendChild (a);
      fset.appendChild (legend);
      fset.appendChild (div);
      toggleTag (a, div);
      moat_get_meanings (tag, div);
      moat.appendChild (fset);
      nodes ++;
    }
  if (0 == nodes)
    {
      msg = OAT.Dom.text ("You don't appear to have any tags defined in this context, please define tags first.");
      moat.appendChild (msg);	  
    }
}

function panel_init ()
{
  var pb = new OAT.Tab ("tb_cont");
  pb.add ("tags","tb_tags");
  pb.add ("category","tb_cat");
  pb.add ("moat","tb_moat");
  pb.add ("trackback","tb_tab");
  pb.go (0);
  moat_init ();
}

function toggleTag (a, div)
{
  if (div.style.display == "none")
    {
      OAT.Dom.show (div);
      a.className = "collapsible";
    }
  else
    { 
      OAT.Dom.hide (div);
      a.className = "collapsed";
    }
}

function assign_cl (a, div)
{
  var ref = function() {
    toggleTag (a, div);
  }
  OAT.Event.attach(a, "click", ref);
}

function moat_get_meanings (tag, par)
{
  function tags_cb (text)
    {
      var div;
      var a;
      var cb;

      eval ('var obj = ' + text);
      var arr = obj.results.bindings;
      for (var i = 0; i < arr.length; i++)
	{
	  if (null == arr[i])
	    break;
	  var url = arr[i].uri.value;
	  div = OAT.Dom.create("div", {});
	  a = OAT.Dom.create("a", {});
	  cb = OAT.Dom.create("input");
	  cb.type = "checkbox";
	  cb.name = 'tag_' + escape (tag);
	  cb.value = url;
	  cb.checked = cb.defaultChecked = arr[i].uri.checked;
	  a.innerHTML = url;
	  a.href = url;
	  div.appendChild (cb);
	  div.appendChild (a);
	  par.appendChild (div);
	}
      div = OAT.Dom.create("div", {});
      a = OAT.Dom.create("input", { "width":"240px" }, "textbox");
      a.type = "text";
      a.name = "tag_" +escape (tag);
      cb = OAT.Dom.create("input");
      cb.type = "checkbox";
      cb.name = "new_tag_" +escape (tag);
      div.appendChild (cb);
      div.appendChild (a);
      par.appendChild (div);
    }
  OAT.AJAX.GET ("/ods_services/Http/tag_meanings?tag="+ escape(tag)+"&inst="+inst_id+"&post="+post_id,
		false, tags_cb, {type:OAT.AJAX.TYPE_TEXT, onstart:function(){}, onerror:function(){}});
}