1 | //+----------------------------------------------------------------------------- |
---|
2 | //+ Isidorus |
---|
3 | //+ (c) 2008-2009 Marc Kuester, Christoph Ludwig, Lukas Giessmann |
---|
4 | //+ |
---|
5 | //+ Isidorus is freely distributable under the LGPL license. |
---|
6 | //+ This ajax module uses the frameworks PrototypeJs and Scriptaculous, both |
---|
7 | //+ are distributed under the MIT license. |
---|
8 | //+ You can find a detailed description in trunk/docs/LGPL-LICENSE.txt and |
---|
9 | //+ in trunk/src/ajax/javascripts/external/MIT-LICENSE.txt. |
---|
10 | //+----------------------------------------------------------------------------- |
---|
11 | |
---|
12 | |
---|
13 | function makeEdit(psi) |
---|
14 | { |
---|
15 | var content = new Element("div", {"class" : CLASSES.content()}); |
---|
16 | var header = new Element("h1").update("Edit a Topic"); |
---|
17 | content.insert({"bottom" : header}); |
---|
18 | $(CLASSES.subPage()).insert({"bottom" : content}); |
---|
19 | |
---|
20 | try{ |
---|
21 | var fragmentFrame = new Element("ul", {"class" : CLASSES.fragmentFrame()}); |
---|
22 | content.insert({"bottom" : fragmentFrame}); |
---|
23 | var liTopicSelect = new Element("li", {"class" : CLASSES.instanceOfFrame()}); |
---|
24 | fragmentFrame.insert({"bottom" : liTopicSelect}); |
---|
25 | |
---|
26 | // --- creates the sub-elements topic, associations and topic map id |
---|
27 | function innerMakeFragment(psis, constraints){ |
---|
28 | function rSuccessHandler(xhr){ |
---|
29 | var json = null; |
---|
30 | try{ |
---|
31 | json = xhr.responseText.evalJSON(); |
---|
32 | } |
---|
33 | catch(innrErr){} |
---|
34 | |
---|
35 | makeFragment(liTopicSelect, psis, constraints, json); |
---|
36 | } |
---|
37 | requestFragment(psis && psis.length !== 0 ? psis[0] : null, rSuccessHandler, null) |
---|
38 | } |
---|
39 | |
---|
40 | function onSuccessHandler(xhr){ |
---|
41 | var json = null; |
---|
42 | try{ |
---|
43 | json = xhr.responseText.evalJSON(); |
---|
44 | } |
---|
45 | catch(err){ |
---|
46 | alert("Got bad JSON data from " + xhr.request.url + "\n\n" + err); |
---|
47 | } |
---|
48 | var edit = null; |
---|
49 | |
---|
50 | try{ |
---|
51 | if(json === null){ |
---|
52 | var err = new Element("div", {"class" : CLASSES.error()}).update("There exist no valid topic instances!<br/>Please update the TMCL-model or create some new instances."); |
---|
53 | liTopicSelect.insert({"bottom" : err}); |
---|
54 | } |
---|
55 | else { |
---|
56 | if(!psi || psi.strip().length === 0) psi = null; |
---|
57 | edit = new EditC(json.flatten().sort(), innerMakeFragment, psi); |
---|
58 | liTopicSelect.insert({"bottom" : edit.getFrame()}); |
---|
59 | } |
---|
60 | } |
---|
61 | catch(err){ |
---|
62 | alert("There occurred an error by creating an EditC frame, please reload this page!\n\n" + err); |
---|
63 | } |
---|
64 | } |
---|
65 | getPsis(onSuccessHandler, null, {"instances" : true}); |
---|
66 | } |
---|
67 | catch(err){ |
---|
68 | alert("From makeEdit(): " + err); |
---|
69 | } |
---|
70 | } |
---|