isidorus-cvs
Threads by month
- ----- 2025 -----
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
June 2009
- 1 participants
- 50 discussions
Author: lgiessmann
Date: Fri Jun 19 09:17:20 2009
New Revision: 52
Log:
ajax-client: fixed a few bugs and prepared the client for the implementation of editing existing fragments
Modified:
trunk/src/ajax/css/frame.css
trunk/src/ajax/javascripts/constants.js
trunk/src/ajax/javascripts/create.js
trunk/src/ajax/javascripts/datamodel.js
trunk/src/ajax/javascripts/edit.js
trunk/src/ajax/javascripts/requests.js
Modified: trunk/src/ajax/css/frame.css
==============================================================================
--- trunk/src/ajax/css/frame.css (original)
+++ trunk/src/ajax/css/frame.css Fri Jun 19 09:17:20 2009
@@ -34,4 +34,9 @@
input[value="generate fragment"] {
margin-top: 10px;
margin-bottom: 10px;
+}
+
+input[value="commit fragment"] {
+ margin-top: -20px;
+ float: right;
}
\ No newline at end of file
Modified: trunk/src/ajax/javascripts/constants.js
==============================================================================
--- trunk/src/ajax/javascripts/constants.js (original)
+++ trunk/src/ajax/javascripts/constants.js Fri Jun 19 09:17:20 2009
@@ -82,6 +82,7 @@
"__divTmIdFrame__" : "tmIdFrame",
"__divLoad__" : "loadFrame",
"__imgAjaxLoader__" : "ajaxLoader",
+ "__divEditFrame__" : "editFrame",
"page" : function(){ return this.__divPage__; },
"subPage" : function(){ return this.__divSubPage__; },
@@ -124,5 +125,6 @@
"commitButton" : function(){ return this.__inputCommitButton__; },
"tmIdFrame" : function(){ return this.__divTmIdFrame__; },
"load" : function(){ return this.__divLoad__; },
- "ajaxLoader" : function(){ return this.__imgAjaxLoader__; }
+ "ajaxLoader" : function(){ return this.__imgAjaxLoader__; },
+ "editFrame" : function(){ return this.__divEditFrame__; }
};
\ No newline at end of file
Modified: trunk/src/ajax/javascripts/create.js
==============================================================================
--- trunk/src/ajax/javascripts/create.js (original)
+++ trunk/src/ajax/javascripts/create.js Fri Jun 19 09:17:20 2009
@@ -10,6 +10,7 @@
//+-----------------------------------------------------------------------------
+// --- Creates the "create"-sub-page.
function makeCreate(psi)
{
var content = new Element("div", {"class" : CLASSES.content()});
@@ -24,7 +25,7 @@
fragmentFrame.insert({"bottom" : liTopicSelect});
function innerMakeFragment(psis, constraints){
- makeFragment(liTopicSelect, psis, constraints);
+ makeFragment(liTopicSelect, psis, constraints, null);
}
function onSuccessHandler(xhr){
@@ -45,7 +46,7 @@
}
} //onSuccessHandler
- getTypePsis(onSuccessHandler, null);
+ getPsis(onSuccessHandler, null, true);
}catch(err){
alert("From makeCreate(): " + err);
}
@@ -53,22 +54,31 @@
// --- Creates the sub-elemts Topic, Associations and Topic Maps ID of a Fragment element.
-function makeFragment(context, psis, constraints){
+function makeFragment(context, psis, constraints, contents){
clearFragment();
+
+ var topicContent = null;
+ var associationsContent = null;
+ var tmContent = null;
+ if(contents){
+ topicContent = contents.topic;
+ associationsContent = contents.associations;
+ tmContent = contents.tmIds;
+ }
var instanceOfs = new Array();
for(var i = 0; psis && i !== psis.length; ++i){
instanceOfs.push(new Array(psis[i]));
}
- var topic = new TopicC(null, (constraints ? constraints.topicConstraints : null), instanceOfs);
+ var topic = new TopicC(topicContent, (constraints ? constraints.topicConstraints : null), instanceOfs);
var liT = new Element("li", {"class" : CLASSES.topicFrame()}).update(topic.getFrame());
context.insert({"after" : liT});
var liA = null;
var associations = null;
- if(constraints && constraints.associationsConstraints && constraints.associationsConstraints.length !== 0){
+ if((constraints && constraints.associationsConstraints && constraints.associationsConstraints.length !== 0) || associationsContent && associationsContent.length !== 0){
addTopicAsPlayer((constraints ? constraints.associationsConstraints : null), topic.getContent().instanceOfs);
- associations = new AssociationContainerC(null, (constraints ? constraints.associationsConstraints : null));
+ associations = new AssociationContainerC(associationsContent, (constraints ? constraints.associationsConstraints : null));
liA = new Element("li", {"class" : CLASSES.associationContainer()}).update(associations.getFrame());
liT.insert({"after" : liA});
}
@@ -76,10 +86,10 @@
liA = liT;
}
- var tmId = new TmIdC(null);
+ var tmId = new TmIdC(tmContent);
var liTm = new Element("li", {"class" : CLASSES.tmIdFrame()}).update(tmId.getFrame());
liA.insert({"after" : liTm});
- var commitButton = new Element("input", {"type" : "button", "value" : "commit fragment", "style" : "float: right; margin-top: -10px;"})
+ var commitButton = new Element("input", {"type" : "button", "value" : "commit fragment"})
commitButton.observe("click", function(event){
// --- validates the given data
var ret = true;
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Fri Jun 19 09:17:20 2009
@@ -242,6 +242,51 @@
}});
+// --- Representation of a
+var EditC = Class.create(ContainerC, {"initialize" : function($super, contents, successFun){
+ $super();
+ this.__frame__.writeAttribute({"class" : CLASSES.editFrame()});
+ this.__container__ = new Object();
+ try{
+ var row = new SelectrowC(contents, this.__container__, 1, 1);
+ this.__error__.insert({"before" : row.getFrame()});
+ }
+ catch(err){
+ throw "From EditC(): The following exception was thrown:\n" + err;
+ this.__container__ = null;
+ }
+ this.__commit__ = new Element("input", {"type" : "button", "value" : "generate fragment"});
+
+ function setHandler(myself){
+ function onSuccessHandler(xhr){
+ var json = null;
+ try{
+ json = xhr.responseText.evalJSON();
+ }
+ catch(err){
+ alert("Got bad JSON data from " + xhr.request.url + "!\n\n" + err);
+ }
+ successFun(new Array(myself.getContent()), json);
+ }
+
+ myself.__commit__.observe("click", function(event){
+ myself.hideError();
+ clearFragment();
+ requestConstraints("[" + myself.toJSON() + "]", onSuccessHandler, null)
+ });
+ }
+ setHandler(this);
+
+ this.__error__.insert({"before" : this.__commit__});
+ },
+ "getContent" : function(){
+ return this.__container__.__frames__[0].getContent();
+ },
+ "toJSON" : function(){
+ return this.getContent().toJSON();
+ }});
+
+
// --- Represents a container for all instanceOf-Psis of a fragment's topic
var InstanceOfC = Class.create(ContainerC, {"initialize" : function($super, contents, successFun){
$super();
@@ -281,10 +326,7 @@
str += "<br/>";
}
}
- var items = $$("li." + CLASSES.topicFrame());
- for(var i = 0; i != items.length; ++i){
- items[i].remove();
- }
+ clearFragment();
myself.showError(str);
}
else {
@@ -295,7 +337,7 @@
myself.__commit__.observe("click", function(event){
myself.hideError();
clearFragment();
- requestConstraints(myself.toJSON(true), onSuccessHandler, null);
+ requestConstraints(myself.toJSON(true), onSuccessHandler, null, true);
});
}
setHandler(this);
@@ -479,11 +521,11 @@
// --- checks card-min and card-max for the current constraint
if(cardMin > currentIdentifiers.length){
- errorStr += "card-min of the constraint regexp: \"" + this.__constraints__[i].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " is not satisfied (" + cardMin + ")!<br/>";
+ errorStr += "card-min of the constraint regexp: \"" + this.__constraints__[i].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " is not satisfied (" + currentIdentifiers.length + ")!<br/>";
ret = false;
}
if(cardMax !== MMAX_INT && cardMax < currentIdentifiers.length){
- errorStr += "card-max of the constraint regexp: \"" + this.__constraints__[i].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " is not satisfied (" + cardMax + ")!<br/>";
+ errorStr += "card-max of the constraint regexp: \"" + this.__constraints__[i].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " is not satisfied (" + currentIdentifiers.length + ")!<br/>";
ret = false;
}
}
@@ -842,8 +884,15 @@
this.__dblClickHandler__ = dblClickHandler;
try{
+ var itemIdentityContent = null;
+ var scopesContent = null;
+ if(contents){
+ itemIdentityContent = contents.itemIdentities;
+ scopesContent = contents.scopes;
+ }
+
// --- control row + itemIdentity
- makeControlRow(this, 4, contents ? contents.itemIdentities : null);
+ makeControlRow(this, 4, itemIdentityContent);
checkRemoveAddButtons(owner, 1, -1);
setRemoveAddHandler(this, owner, 1, -1, function(){
return new VariantC(null, owner, dblClickHandler, parent);
@@ -1037,8 +1086,21 @@
this.__dblClickHandler__ = dblClickHandler;
try{
+ var itemIdentityContent = null;
+ var typeContent = null;
+ var scopesContent = null;
+ var valueContent = "";
+ var variantsContent = null;
+ if(contents){
+ itemIdentityContent = contents.itemIdentities;
+ typeContent = contents.type;
+ scopesContent = contents.scopes;
+ valueContent = contents.value;
+ variantsContent = contents.variants;
+ }
+
// --- control row + ItemIdentity
- makeControlRow(this, 5, contents ? contents.itemIdentities : null);
+ makeControlRow(this, 5, itemIdentityContent);
checkRemoveAddButtons(owner, min, max);
setRemoveAddHandler(this, owner, min, max, function(){
return new NameC(null, nametypescopes, simpleConstraint, owner, min, max, cssTitle, dblClickHandler);
@@ -1049,7 +1111,7 @@
for(var i = 0; nametypescopes && i !== nametypescopes.length; ++i){
for(var j = 0; j != nametypescopes[i].nameType.length; ++j){
types.push(nametypescopes[i].nameType[j]);
- if(contents && contents.type && contents.type[0] === nametypescopes[i].nameType[j]){
+ if(typeContent && typeContent[0] === nametypescopes[i].nameType[j]){
var selected = nametypescopes[i].nameType[j];
types[types.length - 1] = types[0];
types[0] = selected;
@@ -1061,7 +1123,7 @@
this.__table__.insert({"bottom" : tr});
// --- scopes
- this.__scope__ = new ScopeContainerC(contents && contents.scopes ? scopes : null, nametypescopes && nametypescopes[0].scopeConstraints ? nametypescopes[0].scopeConstraints : null);
+ this.__scope__ = new ScopeContainerC(scopesContent, nametypescopes && nametypescopes[0].scopeConstraints ? nametypescopes[0].scopeConstraints : null);
this.__table__.insert({"bottom" : newRow(CLASSES.scopeContainer(), "Scope", this.__scope__.getFrame())});
onTypeChangeScope(this, contents ? contents.scopes : null, nametypescopes, "name");
@@ -1071,11 +1133,11 @@
var _max = simpleConstraint.cardMax !== MAX_INT ? parseInt(simpleConstraint.cardMax) : MMAX_INT;
var cssTitleV = "min: " + _min + " max: " + _max + " regular expression: " + (simpleConstraint ? simpleConstraint.regexp : ".*");
this.__cssTitle__ = cssTitle;
- new TextrowC((contents ? contents.value : ""), (simpleConstraint ? simpleConstraint.regexp : ".*"), this.__value__, 1, 1, cssTitleV);
+ new TextrowC(valueContent, (simpleConstraint ? simpleConstraint.regexp : ".*"), this.__value__, 1, 1, cssTitleV);
this.__table__.insert({"bottom" : newRow(CLASSES.valueFrame(), "Value", this.__value__.__frames__[0].getFrame())});
// --- variants
- this.__variants__ = new VariantContainerC(contents? contents.variants : null, this);
+ this.__variants__ = new VariantContainerC(variantsContent, this);
this.__table__.insert({"bottom" : newRow(CLASSES.variantContainer(), "Variants", this.__variants__.getFrame())});
// --- adds a second show handler, so the variants will be hidden, when the entire
@@ -1348,8 +1410,17 @@
this.__dblClickHandler__ = dblClickHandler;
try{
+ var itemIdentityContent = null;
+ var typeContent = null;
+ var scopesContent = null;
+ if(contents){
+ itemIdentityContent = contents.itemIdentities;
+ typeContent = contents.type;
+ scopesContent = contents.scopes;
+ }
+
// --- control row + itemIdentity
- makeControlRow(this, 5, contents ? contents.itemIdentities : null);
+ makeControlRow(this, 5, itemIdentityContent);
checkRemoveAddButtons(owner, 1, max);
setRemoveAddHandler(this, owner, 1, max, function(){
return new OccurrenceC(null, occurrenceTypes, constraint, uniqueConstraints, owner, min, max, cssTitle, dblClickHandler);
@@ -1360,7 +1431,7 @@
for(var i = 0; occurrenceTypes && i !== occurrenceTypes.length; ++i){
for(var j = 0; j != occurrenceTypes[i].occurrenceType.length; ++j){
types.push(occurrenceTypes[i].occurrenceType[j]);
- if(contents && contents.type && contents.type[0] === ooccurrenceTypes[i].occurrenceType[j]){
+ if(typeContent && typeContent[0] === ooccurrenceTypes[i].occurrenceType[j]){
var selected = occurrenceTypes[i].occurrenceType[j];
types[types.length - 1] = types[0];
types[0] = selected;
@@ -1372,7 +1443,7 @@
this.__table__.insert({"bottom" : tr});
// --- scopes
- this.__scope__ = new ScopeContainerC(contents && contents.scopes ? contents.scopes : null, occurrenceTypes && occurrenceTypes[0].scopeConstraints ? occurrenceTypes[0].scopeConstraints : null);
+ this.__scope__ = new ScopeContainerC(scopesContent, occurrenceTypes && occurrenceTypes[0].scopeConstraints ? occurrenceTypes[0].scopeConstraints : null);
this.__table__.insert({"bottom" : newRow(CLASSES.scopeContainer(), "Scope", this.__scope__.getFrame())});
onTypeChangeScope(this, contents && contents.scopes ? contents.scopes : null, occurrenceTypes, "occurrence");
@@ -1655,6 +1726,20 @@
this.__instanceOfs__ = (!instanceOfs || instanceOfs.length === 0 ? null : instanceOfs);
try{
+ var topicidContent = null;
+ var itemIdentityContent = null;
+ var subjectLocatorContent = null;
+ var subjectIdentifierContent = null;
+ var namesContent = null;
+ var occurrencesContent = null;
+ if(content){
+ topicidContent = content.id
+ itemIdentityContent = content.itemIdentities
+ subjectLocatorContent = content.subjectLocators;
+ subjectIdentifierContent = content.subjectIdentifiers;
+ namesContent = content.names;
+ occurrencesContent = content.occurrences;
+ }
this.__frame__ .writeAttribute({"class" : CLASSES.topicFrame()});
this.__table__ = new Element("table", {"class" : CLASSES.topicFrame()});
this.__frame__.insert({"top" : this.__table__});
@@ -1670,35 +1755,31 @@
// --- topic id
this.__topicid__ = new Object();
- new TextrowC((content ? content.topicid : null), ".*", this.__topicid__, 1, 1, null);
+ new TextrowC(topicidContent, ".*", this.__topicid__, 1, 1, null);
this.__table__.insert({"bottom" : newRow(CLASSES.topicIdFrame(), "Topic ID", this.__topicid__.__frames__[0].getFrame())});
// --- itemIdentity
- this.__itemIdentity__ = new ItemIdentityC(content ? content.itemIdentities : null, this);
+ this.__itemIdentity__ = new ItemIdentityC(itemIdentityContent, this);
this.__table__.insert({"bottom" : newRow(CLASSES.itemIdentityFrame(), "ItemIdentity", this.__itemIdentity__.getFrame())});
// --- subjectLocator
- var _contents = (content ? content.subjectLocators : null);
var _constraints = (constraints ? constraints.subjectLocatorConstraints : null);
- this.__subjectLocator__ = new IdentifierC(_contents, _constraints, CLASSES.subjectLocatorFrame());
+ this.__subjectLocator__ = new IdentifierC(subjectLocatorContent, _constraints, CLASSES.subjectLocatorFrame());
this.__table__.insert({"bottom" : newRow(CLASSES.subjectLocatorFrame(), "SubjectLocator", this.__subjectLocator__.getFrame())});
// --- subjectIdentifier
- _contents = (content ? content.subjectIdentifiers : null);
_constraints = (constraints ? constraints.subjectIdentifierConstraints : null);
- this.__subjectIdentifier__ = new IdentifierC(_contents, _constraints, CLASSES.subjectIdentifierFrame());
+ this.__subjectIdentifier__ = new IdentifierC(subjectIdentifierContent, _constraints, CLASSES.subjectIdentifierFrame());
this.__table__.insert({"bottom" : newRow(CLASSES.subjectIdentifierFrame(), "SubjectIdentifier", this.__subjectIdentifier__.getFrame())});
// --- names
- _contents = (content ? content.names : null);
_constraints = (constraints ? constraints.topicNameConstraints : null);
- this.__name__ = new NameContainerC(_contents, _constraints);
+ this.__name__ = new NameContainerC(namesContent, _constraints);
this.__table__.insert({"bottom" : newRow(CLASSES.nameContainer(), "Names", this.__name__.getFrame())});
// --- occurrences
- _contents = (content ? content.occurrences : null);
_constraints = (constraints ? constraints.topicOccurrenceConstraints : null);
- this.__occurrence__ = new OccurrenceContainerC(_contents, _constraints);
+ this.__occurrence__ = new OccurrenceContainerC(occurrencesContent, _constraints);
this.__table__.insert({"bottom" : newRow(CLASSES.occurrenceContainer(), "Occurrences", this.__occurrence__.getFrame())});
}catch(err){
alert("From TopciC(): " + err);
@@ -2689,8 +2770,20 @@
this.__dblClickHandler__ = dblClickHandlerF;
try{
+ var itemIdentityContent = null;
+ var typeContent = null;
+ var scopesContent = null;
+ var rolesContent = null;
+ if(contents){
+ itemIdentityContent = contents.itemIdentities;
+ typeContent = contents.type;
+ scopesContent = contents.scopes;
+ rolesContent = contents.roles;
+ }
+
+
// --- control row + ItemIdentity
- makeControlRow(this, 4, contents ? contents.itemIdentities : null);
+ makeControlRow(this, 4, itemIdentityContent);
checkRemoveAddButtons(owner, 1, -1);
setRemoveAddHandler(this, owner, 1, -1, function(){
return new AssociationC(null, constraints, owner);
@@ -2701,7 +2794,7 @@
for(var i = 0; constraints && i !== constraints.length; ++i){
for(var j = 0; j != constraints[i].associationType.length; ++j){
types.push(constraints[i].associationType[j]);
- if(contents && contents.type && contents.type[0] === constraints[i].associationType[j]){
+ if(typeContent && typeContent[0] === constraints[i].associationType[j]){
var selected = constraints[i].associationType[j];
types[types.length - 1] = types[0];
types[0] = selected;
@@ -2713,7 +2806,7 @@
this.__table__.insert({"bottom" : tr});
// --- scopes
- this.__scope__ = new ScopeContainerC(this.__contents__ && this.__contents__.scopes ? this.__contents__.scopes : null, this.__constraints__ && this.__constraints__[0].scopeConstraints ? this.__constraints__[0].scopeConstraints : null);
+ this.__scope__ = new ScopeContainerC(scopesContent, this.__constraints__ && this.__constraints__[0].scopeConstraints ? this.__constraints__[0].scopeConstraints : null);
this.__table__.insert({"bottom" : newRow(CLASSES.scopeContainer(), "Scope", this.__scope__.getFrame())});
// --- roles
@@ -2724,7 +2817,7 @@
_otherRoleConstraints = this.__constraints__[0].otherRoleConstraints;
}
- this.__roles__ = new RoleContainerC(this.__contents__ ? this.__contents__.roles : null, _roleConstraints, _playerConstraints, _otherRoleConstraints, this);
+ this.__roles__ = new RoleContainerC(rolesContent, _roleConstraints, _playerConstraints, _otherRoleConstraints, this);
this.__table__.insert({"bottom" : newRow(CLASSES.roleContainer(), "Roles", this.__roles__.getFrame())});
// --- registers the onChangeHandler of the Type-selectrow
Modified: trunk/src/ajax/javascripts/edit.js
==============================================================================
--- trunk/src/ajax/javascripts/edit.js (original)
+++ trunk/src/ajax/javascripts/edit.js Fri Jun 19 09:17:20 2009
@@ -25,28 +25,37 @@
// --- creates the sub-elements topic, associations and topic map id
function innerMakeFragment(psis, constraints){
- makeFragment(liTopicSelect, psis, constraints);
+ function rSuccessHandler(xhr){
+ var json = null;
+ try{
+ json = xhr.responseText.evalJSON();
+ }
+ catch(innrErr){}
+
+ makeFragment(liTopicSelect, psis, constraints, json);
+ }
+ requestFragment(psis && psis.length !== 0 ? psis[0] : null, rSuccessHandler, null)
}
function onSuccessHandler(xhr){
var json = null;
try{
json = xhr.responseText.evalJSON();
- }
- catch(innerErr){
- alert("Got bad JSON data from " + xhr.request.url + "\n\n" + innerErr);
}
- var instanceOf = null;
+ catch(err){
+ alert("Got bad JSON data from " + xhr.request.url + "\n\n" + err);
+ }
+ var edit = null;
+
try{
- instanceOf = new InstanceOfC(json.flatten().sort(), innerMakeFragment);
- liTopicSelect.insert({"bottom" : instanceOf.getFrame()});
+ edit = new EditC(json.flatten().sort(), innerMakeFragment);
+ liTopicSelect.insert({"bottom" : edit.getFrame()});
}
- catch(innerErr){
- alert("There occurred an error by creating an InstanceOfC frame, please reload this page!\n\n" + innerErr);
+ catch(err){
+ alert("There occurred an error by creating an EditC frame, please reload this page!\n\n" + err);
}
- } //onSuccessHandler
-
- getTypePsis(onSuccessHandler, null);
+ }
+ getPsis(onSuccessHandler, null, false);
}
catch(err){
alert("From makeEdit(): " + err);
Modified: trunk/src/ajax/javascripts/requests.js
==============================================================================
--- trunk/src/ajax/javascripts/requests.js (original)
+++ trunk/src/ajax/javascripts/requests.js Fri Jun 19 09:17:20 2009
@@ -81,36 +81,43 @@
}
-// --- Gets all type psis from the server.
-function getTypePsis(onSuccessHandler, onFailureHandler)
+// --- Gets all psis from the server. If typePsis is set to true
+// --- there will be requested only TopicType's psis.
+function getPsis(onSuccessHandler, onFailureHandler, typePsis)
{
try{
var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
var timeFun = setAjaxTimeout(TIMEOUT, TYPE_PSIS_URL);
onLoad("Requesting all type PSIs");
- new Ajax.Request(TYPE_PSIS_URL, {
+ var url = ALL_PSIS_URL;
+ if(typePsis === true) url = TYPE_PSIS_URL;
+
+ new Ajax.Request(url, {
"method" : "get",
"requestHeaders" : INIT_DATE,
"onSuccess" : createXHRHandler(onSuccessHandler, timeFun),
"onFailure" : createXHRHandler(onFailure, timeFun)});
}
catch(err){
- alert("Could not request all type PSIs, please try again!\n\n" + err);
+ alert("From getTypePsis(): could not request all type PSIs, please try again!\n\n" + err);
}
}
// --- Sends a post-request to the server with the passed psis as postBody.
// --- Gets a constraint-object.
-function requestConstraints(psis, onSuccessHandler, onFailureHandler)
+function requestConstraints(psis, onSuccessHandler, onFailureHandler, typeConstraints)
{
try{
var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
var timeFun = setAjaxTimeout(TIMEOUT, TMCL_TYPE_URL);
onLoad("Requesting all constraints for the psis:\<br/>" + psis.gsub("\\[", "").gsub("\\]", ""));
- new Ajax.Request(TMCL_TYPE_URL, {
+ url = TMCL_INSTANCE_URL;
+ if(typeConstraints === true) url = TMCL_TYPE_URL;
+
+ new Ajax.Request(url, {
"method" : "post",
"postBody" : psis,
"onSuccess" : createXHRHandler(onSuccessHandler, timeFun),
@@ -198,4 +205,29 @@
catch(err){
alert("From commitFragment(): " + err);
}
+}
+
+
+// --- Requests a JSON-Fragment for the passed psi and calls the onSuccessHandler function
+// --- after a succeeded request.
+function requestFragment(psi, onSuccessHandler, onFailureHandler)
+{
+ if(!psi || !onSuccessHandler) throw "From requestFragment(): psi and onSuccessHandler must be set!";
+
+ try{
+ var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
+ var timeFun = setAjaxTimeout(TIMEOUT, COMMIT_URL);
+ onLoad("Requesting fragment for the topic " + psi);
+
+ var url = GET_PREFIX + psi.gsub("#", "%23");
+
+ new Ajax.Request(url, {
+ "method" : "get",
+ "requestHeaders" : INIT_DATE,
+ "onSuccess" : createXHRHandler(onSuccessHandler, timeFun),
+ "onFailure" : createXHRHandler(onFailure, timeFun)});
+ }
+ catch(err){
+ alert("From requestFragment(): " + err);
+ }
}
\ No newline at end of file
1
0
Author: lgiessmann
Date: Fri Jun 19 06:17:27 2009
New Revision: 51
Log:
ajax-client: fixed a bug by committing fragments without an associationcontainer
Modified:
trunk/src/ajax/css/frame.css
trunk/src/ajax/javascripts/create.js
trunk/src/ajax/javascripts/datamodel.js
trunk/src/ajax/javascripts/edit.js
trunk/src/ajax/javascripts/requests.js
Modified: trunk/src/ajax/css/frame.css
==============================================================================
--- trunk/src/ajax/css/frame.css (original)
+++ trunk/src/ajax/css/frame.css Fri Jun 19 06:17:27 2009
@@ -29,4 +29,9 @@
li.errorMessage {
margin-top: 1em;
font-size: 1.2em;
+}
+
+input[value="generate fragment"] {
+ margin-top: 10px;
+ margin-bottom: 10px;
}
\ No newline at end of file
Modified: trunk/src/ajax/javascripts/create.js
==============================================================================
--- trunk/src/ajax/javascripts/create.js (original)
+++ trunk/src/ajax/javascripts/create.js Fri Jun 19 06:17:27 2009
@@ -23,111 +23,111 @@
var liTopicSelect = new Element("li", {"class" : CLASSES.instanceOfFrame()});
fragmentFrame.insert({"bottom" : liTopicSelect});
+ function innerMakeFragment(psis, constraints){
+ makeFragment(liTopicSelect, psis, constraints);
+ }
+
+ function onSuccessHandler(xhr){
+ var json = null;
+ try{
+ json = xhr.responseText.evalJSON();
+ }
+ catch(innerErr){
+ alert("Got bad JSON data from " + xhr.request.url + "\n\n" + innerErr);
+ }
+ var instanceOf = null;
+ try{
+ instanceOf = new InstanceOfC(json.flatten().sort(), innerMakeFragment);
+ liTopicSelect.insert({"bottom" : instanceOf.getFrame()});
+ }
+ catch(innerErr){
+ alert("There occurred an error by creating an InstanceOfC frame, please reload this page!\n\n" + innerErr);
+ }
+ } //onSuccessHandler
- function makeInstanceOfFrame(context){
- function makeFragment(psis, constraints){
- clearFragment();
- var instanceOfs = new Array();
- for(var i = 0; psis && i !== psis.length; ++i){
- instanceOfs.push(new Array(psis[i]));
- }
- var topic = new TopicC(null, (constraints ? constraints.topicConstraints : null), instanceOfs);
- var liT = new Element("li", {"class" : CLASSES.topicFrame()}).update(topic.getFrame());
- context.insert({"after" : liT});
-
- var liA = null;
- var associations = null;
- if(constraints && constraints.associationsConstraints && constraints.associationsConstraints.length !== 0){
- addTopicAsPlayer((constraints ? constraints.associationsConstraints : null), topic.getContent().instanceOfs);
- associations = new AssociationContainerC(null, (constraints ? constraints.associationsConstraints : null));
- liA = new Element("li", {"class" : CLASSES.associationContainer()}).update(associations.getFrame());
- liT.insert({"after" : liA});
- }
- else {
- liA = liT;
- }
-
- var tmId = new TmIdC(null);
- var liTm = new Element("li", {"class" : CLASSES.tmIdFrame()}).update(tmId.getFrame());
- liA.insert({"after" : liTm});
-
- var commitButton = new Element("input", {"type" : "button", "value" : "commit fragment", "style" : "float: right; margin-top: -10px;"})
- commitButton.observe("click", function(event){
- // --- validates the given data
- var ret = true;
- if(topic.isValid() === false) ret = false;
- if(associations.isValid() === false) ret = false;
- if(tmId.isValid() === false) ret = false;
-
- if(ret === false){
- alert("The fragment wasn't committed!");
- return;
- }
-
- // --- if the validation succeeded the fragment will be sent to the server
- var tPsis = topic.getContent().subjectIdentifiers;
- var referencedTopics = topic.getReferencedTopics();
- if(associations){
- referencedTopics = referencedTopics.concat(associations.getReferencedTopics()).without(CURRENT_TOPIC).uniq();
- }
-
- function onSuccessHandler(topicStubs){
- var tsStr = "null";
- if(topicStubs && topicStubs.length !== 0){
- tsStr = "[";
- for(var i = 0; i !== topicStubs.length; ++i){
- tsStr += topicStubs[i];
- if(i !== topicStubs.length - 1) tsStr += ",";
- }
- tsStr += "]";
- }
- var jTopic = "\"topic\":" + topic.toJSON();
- var jTopicStubs = "\"topicStubs\":" + tsStr;
- var jAssociations = "\"associations\":" + (associations ? associations.toJSON().gsub(CURRENT_TOPIC_ESCAPED, tPsis) : "null");
- var jTmId = "\"tmIds\":" + tmId.toJSON();
- var json = "{" + jTopic + "," + jTopicStubs + "," + jAssociations + "," + jTmId + "}";
- commitFragment(json, function(xhr){ alert("The fragment was committed succesfully!"); }, null);
- }
-
- function onErrorHandler(){
- // --- currently there is not needed a special handling for errors
- // --- occurred during this operation
- }
- getTopicStubs(referencedTopics, onSuccessHandler, onErrorHandler);
- });
- var liCB = new Element("li", {"class" : CLASSES.commitButton()});
- liCB.update(commitButton);
- liTm.insert({"after" : liCB});
- } //makeFragment
-
- function onSuccessHandler(xhr){
- var json = null;
- try{
- json = xhr.responseText.evalJSON();
- }
- catch(innerErr){
- alert("Got bad JSON data from " + xhr.request.url + "\n\n" + innerErr);
- }
- var instanceOf = null;
- try{
- instanceOf = new InstanceOfC(json.flatten().sort(), makeFragment);
- context.insert({"bottom" : instanceOf.getFrame()});
- }
- catch(innerErr){
- alert("There occurred an error by creating an InstanceOfC frame, please reload this page!\n\n" + innerErr);
- }
- } //onSuccessHandler
-
- getTypePsis(onSuccessHandler, null);
- } //makeInstanceOfFrame
-
- makeInstanceOfFrame(liTopicSelect);
+ getTypePsis(onSuccessHandler, null);
}catch(err){
alert("From makeCreate(): " + err);
}
}
+// --- Creates the sub-elemts Topic, Associations and Topic Maps ID of a Fragment element.
+function makeFragment(context, psis, constraints){
+ clearFragment();
+
+ var instanceOfs = new Array();
+ for(var i = 0; psis && i !== psis.length; ++i){
+ instanceOfs.push(new Array(psis[i]));
+ }
+ var topic = new TopicC(null, (constraints ? constraints.topicConstraints : null), instanceOfs);
+ var liT = new Element("li", {"class" : CLASSES.topicFrame()}).update(topic.getFrame());
+ context.insert({"after" : liT});
+
+ var liA = null;
+ var associations = null;
+ if(constraints && constraints.associationsConstraints && constraints.associationsConstraints.length !== 0){
+ addTopicAsPlayer((constraints ? constraints.associationsConstraints : null), topic.getContent().instanceOfs);
+ associations = new AssociationContainerC(null, (constraints ? constraints.associationsConstraints : null));
+ liA = new Element("li", {"class" : CLASSES.associationContainer()}).update(associations.getFrame());
+ liT.insert({"after" : liA});
+ }
+ else {
+ liA = liT;
+ }
+
+ var tmId = new TmIdC(null);
+ var liTm = new Element("li", {"class" : CLASSES.tmIdFrame()}).update(tmId.getFrame());
+ liA.insert({"after" : liTm});
+ var commitButton = new Element("input", {"type" : "button", "value" : "commit fragment", "style" : "float: right; margin-top: -10px;"})
+ commitButton.observe("click", function(event){
+ // --- validates the given data
+ var ret = true;
+ if(topic.isValid() === false) ret = false;
+ if(associations && associations.isValid() === false) ret = false;
+ if(tmId.isValid() === false) ret = false;
+
+ if(ret === false){
+ alert("The fragment wasn't committed - Please correct your input date!");
+ return;
+ }
+
+ // --- if the validation succeeded the fragment will be sent to the server
+ var tPsis = topic.getContent().subjectIdentifiers;
+ var referencedTopics = topic.getReferencedTopics();
+ if(associations){
+ referencedTopics = referencedTopics.concat(associations.getReferencedTopics()).without(CURRENT_TOPIC).uniq();
+ }
+ function onSuccessHandler(topicStubs){
+ var tsStr = "null";
+ if(topicStubs && topicStubs.length !== 0){
+ tsStr = "[";
+ for(var i = 0; i !== topicStubs.length; ++i){
+ tsStr += topicStubs[i];
+ if(i !== topicStubs.length - 1) tsStr += ",";
+ }
+ tsStr += "]";
+ }
+ var jTopic = "\"topic\":" + topic.toJSON();
+ var jTopicStubs = "\"topicStubs\":" + tsStr;
+ var jAssociations = "\"associations\":" + (associations ? associations.toJSON().gsub(CURRENT_TOPIC_ESCAPED, tPsis) : "null");
+ var jTmId = "\"tmIds\":" + tmId.toJSON();
+ var json = "{" + jTopic + "," + jTopicStubs + "," + jAssociations + "," + jTmId + "}";
+ commitFragment(json, function(xhr){ alert("The fragment was committed succesfully!"); }, null);
+ }
+
+ function onErrorHandler(){
+ // --- currently there is not needed a special handling for errors
+ // --- occurred during this operation
+ }
+ getTopicStubs(referencedTopics, onSuccessHandler, onErrorHandler);
+ });
+ var liCB = new Element("li", {"class" : CLASSES.commitButton()});
+ liCB.update(commitButton);
+ liTm.insert({"after" : liCB});
+}
+
+
// --- removes old elements from the fragment frame
function clearFragment()
{
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Fri Jun 19 06:17:27 2009
@@ -255,7 +255,7 @@
throw "From InstanceOfC(): The following exception was thrown:\n" + err;
this.__container__ = null;
}
- this.__commit__ = new Element("input", {"type" : "button", "value" : "get constraints"});
+ this.__commit__ = new Element("input", {"type" : "button", "value" : "generate fragment"});
function setHandler(myself){
function onSuccessHandler(xhr){
@@ -442,68 +442,64 @@
return content.length === 0 ? "null" : content.toJSON();
},
"isValid" : function(){
- try {
- var allIdentifiers = new Array();
- var errorStr = "";
- var ret = true;
-
- // --- checks if there are any constraints
- if((!this.__constraints__ || this.__constraints__.length === 0) && this.__containers__.length !== 0){
- for(var i = 0; i !== this.__containers__.length; ++i){
- for(var j = 0; this.__containers__[i].__frames__ && j !== this.__containers__[i].__frames__.length; ++j){
- this.__containers__[i].__frames__[j].showError("No constraints found for this identifier!");
- }
- }
- return false;
- }
- else if(!this.__constraints__ || this.__constraints__.length === 0) return true;
-
- // --- collects all non-empty identifiers
+ var allIdentifiers = new Array();
+ var errorStr = "";
+ var ret = true;
+
+ // --- checks if there are any constraints
+ if((!this.__constraints__ || this.__constraints__.length === 0) && this.__containers__.length !== 0){
for(var i = 0; i !== this.__containers__.length; ++i){
for(var j = 0; this.__containers__[i].__frames__ && j !== this.__containers__[i].__frames__.length; ++j){
- var row = this.__containers__[i].__frames__[j];
- row.hideError();
- if(row.isUsed() === true && row.getContent().strip().length !== 0) allIdentifiers.push(row);
+ this.__containers__[i].__frames__[j].showError("No constraints found for this identifier!");
}
}
+ return false;
+ }
+ else if(!this.__constraints__ || this.__constraints__.length === 0) return true;
+
+ // --- collects all non-empty identifiers
+ for(var i = 0; i !== this.__containers__.length; ++i){
+ for(var j = 0; this.__containers__[i].__frames__ && j !== this.__containers__[i].__frames__.length; ++j){
+ var row = this.__containers__[i].__frames__[j];
+ row.hideError();
+ if(row.isUsed() === true && row.getContent().strip().length !== 0) allIdentifiers.push(row);
+ }
+ }
+
+ var checkedIdentifiers = new Array();
+ for(var i = 0; i !== this.__constraints__.length; ++i){
+ var regexp = new RegExp(this.__constraints__[i].regexp);
+ var cardMin = parseInt(this.__constraints__[i].cardMin);
+ var cardMax = this.__constraints__[i].cardMax === MAX_INT ? MMAX_INT : parseInt(this.__constraints__[i].cardMax);
+ var currentIdentifiers = new Array();
+ for(var j = 0; j !== allIdentifiers.length; ++j){
+ if(regexp.match(allIdentifiers[j].getContent()) === true) currentIdentifiers.push(allIdentifiers[j]);
+ }
+ checkedIdentifiers = checkedIdentifiers.concat(currentIdentifiers);
- var checkedIdentifiers = new Array();
- for(var i = 0; i !== this.__constraints__.length; ++i){
- var regexp = new RegExp(this.__constraints__[i].regexp);
- var cardMin = parseInt(this.__constraints__[i].cardMin);
- var cardMax = this.__constraints__[i].cardMax === MAX_INT ? MMAX_INT : parseInt(this.__constraints__[i].cardMax);
- var currentIdentifiers = new Array();
- for(var j = 0; j !== allIdentifiers.length; ++j){
- if(regexp.match(allIdentifiers[j].getContent()) === true) currentIdentifiers.push(allIdentifiers[j]);
- }
- checkedIdentifiers = checkedIdentifiers.concat(currentIdentifiers);
-
- // --- checks card-min and card-max for the current constraint
- if(cardMin > currentIdentifiers.length){
- errorStr += "card-min of the constraint regexp: \"" + this.__constraints__[i].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " is not satisfied (" + cardMin + ")!<br/>";
- ret = false;
- }
- if(cardMax !== MMAX_INT && cardMax < currentIdentifiers.length){
- errorStr += "card-max of the constraint regexp: \"" + this.__constraints__[i].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " is not satisfied (" + cardMax + ")!<br/>";
- ret = false;
- }
+ // --- checks card-min and card-max for the current constraint
+ if(cardMin > currentIdentifiers.length){
+ errorStr += "card-min of the constraint regexp: \"" + this.__constraints__[i].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " is not satisfied (" + cardMin + ")!<br/>";
+ ret = false;
}
-
- // --- checks if there are some identifiers which don't satisfies any constraint
- checkedIdentifiers = checkedIdentifiers.uniq();
- if(checkedIdentifiers.length < allIdentifiers.length){
+ if(cardMax !== MMAX_INT && cardMax < currentIdentifiers.length){
+ errorStr += "card-max of the constraint regexp: \"" + this.__constraints__[i].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " is not satisfied (" + cardMax + ")!<br/>";
ret = false;
- for(var i = 0; i !== allIdentifiers.length; ++i){
- if(checkedIdentifiers.indexOf(allIdentifiers[i]) === -1) allIdentifiers[i].showError("This Identifier does not satisfie any constraint!");
- }
}
-
- if(ret === true) this.hideError();
- else this.showError(errorStr);
- return ret;
- }catch(err){ alert("err: " + err); }
-
-
+ }
+
+ // --- checks if there are some identifiers which don't satisfies any constraint
+ checkedIdentifiers = checkedIdentifiers.uniq();
+ if(checkedIdentifiers.length < allIdentifiers.length){
+ ret = false;
+ for(var i = 0; i !== allIdentifiers.length; ++i){
+ if(checkedIdentifiers.indexOf(allIdentifiers[i]) === -1) allIdentifiers[i].showError("This Identifier does not satisfie any constraint!");
+ }
+ }
+
+ if(ret === true) this.hideError();
+ else this.showError(errorStr);
+ return ret;
}});
@@ -1754,7 +1750,6 @@
return this.__subjectIdentifier__.getContent(true, true).length !== 0;
},
"isValid" : function(){
- try{
var ret = true;
if(this.__topicid__.__frames__[0].getContent().strip().length === 0){
ret = false;
@@ -1768,7 +1763,6 @@
if(this.__subjectIdentifier__.isValid() === false) ret = false;
if(this.__name__.isValid() === false) ret = false;
if(this.__occurrence__.isValid() === false) ret = false;
- }catch(err){ alert("err: " + err); }
return ret;
},
"getReferencedTopics" : function(){
Modified: trunk/src/ajax/javascripts/edit.js
==============================================================================
--- trunk/src/ajax/javascripts/edit.js (original)
+++ trunk/src/ajax/javascripts/edit.js Fri Jun 19 06:17:27 2009
@@ -18,7 +18,35 @@
$(CLASSES.subPage()).insert({"bottom" : content});
try{
+ var fragmentFrame = new Element("ul", {"class" : CLASSES.fragmentFrame()});
+ content.insert({"bottom" : fragmentFrame});
+ var liTopicSelect = new Element("li", {"class" : CLASSES.instanceOfFrame()});
+ fragmentFrame.insert({"bottom" : liTopicSelect});
+
+ // --- creates the sub-elements topic, associations and topic map id
+ function innerMakeFragment(psis, constraints){
+ makeFragment(liTopicSelect, psis, constraints);
+ }
+
+ function onSuccessHandler(xhr){
+ var json = null;
+ try{
+ json = xhr.responseText.evalJSON();
+ }
+ catch(innerErr){
+ alert("Got bad JSON data from " + xhr.request.url + "\n\n" + innerErr);
+ }
+ var instanceOf = null;
+ try{
+ instanceOf = new InstanceOfC(json.flatten().sort(), innerMakeFragment);
+ liTopicSelect.insert({"bottom" : instanceOf.getFrame()});
+ }
+ catch(innerErr){
+ alert("There occurred an error by creating an InstanceOfC frame, please reload this page!\n\n" + innerErr);
+ }
+ } //onSuccessHandler
+ getTypePsis(onSuccessHandler, null);
}
catch(err){
alert("From makeEdit(): " + err);
Modified: trunk/src/ajax/javascripts/requests.js
==============================================================================
--- trunk/src/ajax/javascripts/requests.js (original)
+++ trunk/src/ajax/javascripts/requests.js Fri Jun 19 06:17:27 2009
@@ -27,12 +27,9 @@
function createXHRHandler(handler, timeFun)
{
function fun(xhr){
- try{
- clearTimeout(timeFun);
- hideLoad();
- handler(xhr);
- }
- catch(err) {alert("err: " + err); }
+ clearTimeout(timeFun);
+ hideLoad();
+ handler(xhr);
}
return fun;
}
1
0
Author: lgiessmann
Date: Fri Jun 19 04:53:38 2009
New Revision: 50
Log:
ajax-client: fixed the following bugs: (1) by requesting all needed topicStubs now there will be requested the instanceOf-topics, too. (2) by showing the "loading"-.GIF and changing the sub-page at the same time - the .Gif will be first set to the initial state, so it won't be removed accidentally anymore. (3) the fragment will be REALLY sent to the server - the "onSuccessFun" will be executed after a succeeded validation. (4) after a bad validation there appears an alert-window with a corresponding message, the same behaviour occurrs by sending the data to the server
Modified:
trunk/src/ajax/javascripts/create.js
trunk/src/ajax/javascripts/datamodel.js
trunk/src/ajax/javascripts/edit.js
trunk/src/ajax/javascripts/home.js
trunk/src/ajax/javascripts/navi.js
trunk/src/ajax/javascripts/requests.js
trunk/src/ajax/javascripts/search.js
Modified: trunk/src/ajax/javascripts/create.js
==============================================================================
--- trunk/src/ajax/javascripts/create.js (original)
+++ trunk/src/ajax/javascripts/create.js Fri Jun 19 04:53:38 2009
@@ -14,8 +14,8 @@
{
var content = new Element("div", {"class" : CLASSES.content()});
var header = new Element("h1").update("Create a Topic");
- content.insert(header, {"position" : "bottom"});
- $(CLASSES.subPage()).insert(content, {"position" : "bottom"});
+ content.insert({"bottom" : header});
+ $(CLASSES.subPage()).insert({"bottom" : content});
try{
var fragmentFrame = new Element("ul", {"class" : CLASSES.fragmentFrame()});
@@ -59,7 +59,10 @@
if(associations.isValid() === false) ret = false;
if(tmId.isValid() === false) ret = false;
- if(ret === false) return;
+ if(ret === false){
+ alert("The fragment wasn't committed!");
+ return;
+ }
// --- if the validation succeeded the fragment will be sent to the server
var tPsis = topic.getContent().subjectIdentifiers;
@@ -67,7 +70,7 @@
if(associations){
referencedTopics = referencedTopics.concat(associations.getReferencedTopics()).without(CURRENT_TOPIC).uniq();
}
-
+
function onSuccessHandler(topicStubs){
var tsStr = "null";
if(topicStubs && topicStubs.length !== 0){
@@ -90,7 +93,6 @@
// --- currently there is not needed a special handling for errors
// --- occurred during this operation
}
-
getTopicStubs(referencedTopics, onSuccessHandler, onErrorHandler);
});
var liCB = new Element("li", {"class" : CLASSES.commitButton()});
@@ -121,7 +123,7 @@
makeInstanceOfFrame(liTopicSelect);
}catch(err){
- alert(err);
+ alert("From makeCreate(): " + err);
}
}
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Fri Jun 19 04:53:38 2009
@@ -1805,6 +1805,12 @@
}
}
}
+
+ if(this.__instanceOfs__){
+ for(var i = 0; i !== this.__instanceOfs__.length; ++i){
+ if(referencedTopics.indexOf(this.__instanceOfs__[i][0]) === -1) referencedTopics.push(this.__instanceOfs__[i][0]);
+ }
+ }
return referencedTopics;
}});
Modified: trunk/src/ajax/javascripts/edit.js
==============================================================================
--- trunk/src/ajax/javascripts/edit.js (original)
+++ trunk/src/ajax/javascripts/edit.js Fri Jun 19 04:53:38 2009
@@ -14,5 +14,13 @@
{
var content = new Element("div", {"class" : CLASSES.content()});
var header = new Element("h1").update("Edit a Topic");
- $(CLASSES.subPage()).insert((content.insert(header, {"position" : "bottom"})), {"position" : "bottom"});
+ content.insert({"bottom" : header});
+ $(CLASSES.subPage()).insert({"bottom" : content});
+
+ try{
+
+ }
+ catch(err){
+ alert("From makeEdit(): " + err);
+ }
}
Modified: trunk/src/ajax/javascripts/home.js
==============================================================================
--- trunk/src/ajax/javascripts/home.js (original)
+++ trunk/src/ajax/javascripts/home.js Fri Jun 19 04:53:38 2009
@@ -14,5 +14,6 @@
{
var content = new Element("div", {"class" : CLASSES.content()});
var header = new Element("h1").update("Topic Map Overview");
- $(CLASSES.subPage()).insert((content.insert(header, {"position" : "bottom"})), {"position" : "bottom"});
+ content.insert({"bottom" : header});
+ $(CLASSES.subPage()).insert({"bottom" : content});
}
Modified: trunk/src/ajax/javascripts/navi.js
==============================================================================
--- trunk/src/ajax/javascripts/navi.js (original)
+++ trunk/src/ajax/javascripts/navi.js Fri Jun 19 04:53:38 2009
@@ -44,6 +44,7 @@
PAGES.current = newPage;
// --- removes the old content
+ hideLoad(); // to prevent the load-gif of beeing removed when it is used in the error-div
$(CLASSES.subPage()).update();
// --- creates the new content
Modified: trunk/src/ajax/javascripts/requests.js
==============================================================================
--- trunk/src/ajax/javascripts/requests.js (original)
+++ trunk/src/ajax/javascripts/requests.js Fri Jun 19 04:53:38 2009
@@ -29,7 +29,7 @@
function fun(xhr){
try{
clearTimeout(timeFun);
- removeLoad();
+ hideLoad();
handler(xhr);
}
catch(err) {alert("err: " + err); }
@@ -41,7 +41,7 @@
// --- Removes all divs with the class ajaxLoader. The inner image with the
// --- class ajaxLoader will be moved to the top of div.content and the
// --- display attribute will be set to none;
-function removeLoad()
+function hideLoad()
{
var img = $$("img." + CLASSES.ajaxLoader());
if(img.length === 1){
@@ -162,19 +162,20 @@
neededTime += delta;
if(delta > maxTimeout && psis && psis.length !== 0){
alert("From getTopicStubs(): Please check your network-connection - the request timed out!!!");
- removeLoad();
+ hideLoad();
onFailureHandler();
return;
}
if(topicStubs.length === psis.length){
- removeLoad();
+ hideLoad();
+ onSuccessHandler(topicStubs);
+
}
else setTimeout(checkRequests, delta);
}
checkRequests();
-
}
catch(err){
alert("From getTopicStubs(): Could not request topicStubs information for: " + psis + "\n\n" + err);
Modified: trunk/src/ajax/javascripts/search.js
==============================================================================
--- trunk/src/ajax/javascripts/search.js (original)
+++ trunk/src/ajax/javascripts/search.js Fri Jun 19 04:53:38 2009
@@ -14,5 +14,6 @@
{
var content = new Element("div", {"class" : CLASSES.content()});
var header = new Element("h1").update("Search a Topic");
- $(CLASSES.subPage()).insert((content.insert(header, {"position" : "bottom"})), {"position" : "bottom"});
+ content.insert({"bottom" : header});
+ $(CLASSES.subPage()).insert({"bottom" : content});
}
1
0

[isidorus-cvs] r49 - in trunk: docs src/ajax src/ajax/css src/ajax/javascripts
by Lukas Giessmann 18 Jun '09
by Lukas Giessmann 18 Jun '09
18 Jun '09
Author: lgiessmann
Date: Thu Jun 18 13:30:48 2009
New Revision: 49
Log:
ajax-client: during AJAX-requests the client hides all current sub-content and shows a GIF representing a loader with a message what the client is currently doing
Modified:
trunk/docs/JSON_model.pdf
trunk/src/ajax/css/main.css
trunk/src/ajax/isidorus.html
trunk/src/ajax/javascripts/constants.js
trunk/src/ajax/javascripts/requests.js
Modified: trunk/docs/JSON_model.pdf
==============================================================================
Binary files. No diff available.
Modified: trunk/src/ajax/css/main.css
==============================================================================
--- trunk/src/ajax/css/main.css (original)
+++ trunk/src/ajax/css/main.css Thu Jun 18 13:30:48 2009
@@ -55,4 +55,10 @@
div.loadFrame {
padding: 2em;
color: #ff7f00;
+ text-align: center;
+}
+
+img.ajaxLoader {
+ display: none;
+ margin-left: 412px; /* the image has a width of 100px */
}
\ No newline at end of file
Modified: trunk/src/ajax/isidorus.html
==============================================================================
--- trunk/src/ajax/isidorus.html (original)
+++ trunk/src/ajax/isidorus.html Thu Jun 18 13:30:48 2009
@@ -57,6 +57,7 @@
<body>
<div id="page">
+ <img class="ajaxLoader" src="javascripts/ajaxLoader_big.gif" width="100" height="100" border="0" alt="ajax loader">
<div id="navi">
<span id="home" class="isActive">Home</span>
<span id="searchTopic" class="clickableButton">Search Topics</span>
Modified: trunk/src/ajax/javascripts/constants.js
==============================================================================
--- trunk/src/ajax/javascripts/constants.js (original)
+++ trunk/src/ajax/javascripts/constants.js Thu Jun 18 13:30:48 2009
@@ -81,6 +81,7 @@
"__inputCommitButton__" : "commitButton",
"__divTmIdFrame__" : "tmIdFrame",
"__divLoad__" : "loadFrame",
+ "__imgAjaxLoader__" : "ajaxLoader",
"page" : function(){ return this.__divPage__; },
"subPage" : function(){ return this.__divSubPage__; },
@@ -122,5 +123,6 @@
"fog" : function(){ return this.__divFog__; },
"commitButton" : function(){ return this.__inputCommitButton__; },
"tmIdFrame" : function(){ return this.__divTmIdFrame__; },
- "load" : function(){ return this.__divLoad__; }
+ "load" : function(){ return this.__divLoad__; },
+ "ajaxLoader" : function(){ return this.__imgAjaxLoader__; }
};
\ No newline at end of file
Modified: trunk/src/ajax/javascripts/requests.js
==============================================================================
--- trunk/src/ajax/javascripts/requests.js (original)
+++ trunk/src/ajax/javascripts/requests.js Thu Jun 18 13:30:48 2009
@@ -11,7 +11,6 @@
-
// --- Sets a timeout function which alerts a message.
function setAjaxTimeout(time, url)
{
@@ -24,16 +23,13 @@
// --- Returns a function whihc can be used as an XHR-Handler.
// --- The returned function is the passed handler wrapped in
// --- a lambda-function which additionally clears the passed timeout
-// --- function.
+// --- function and call onLoad.
function createXHRHandler(handler, timeFun)
{
function fun(xhr){
try{
clearTimeout(timeFun);
- var loading = $$("div." + CLASSES.load());
- if(loading.length === 1) loading[0].remove();
- var content = $$("div." + CLASSES.content());
- if(content.length === 1) content[0].show();
+ removeLoad();
handler(xhr);
}
catch(err) {alert("err: " + err); }
@@ -42,14 +38,40 @@
}
+// --- Removes all divs with the class ajaxLoader. The inner image with the
+// --- class ajaxLoader will be moved to the top of div.content and the
+// --- display attribute will be set to none;
+function removeLoad()
+{
+ var img = $$("img." + CLASSES.ajaxLoader());
+ if(img.length === 1){
+ img[0].setStyle({"display" : "none"})
+ $("page").insert({"top" : img[0]});
+ }
+
+ var loading = $$("div." + CLASSES.load());
+ if(loading.length === 1) loading[0].remove();
+ var content = $$("div." + CLASSES.content());
+ if(content.length === 1) content[0].show();
+}
+
+
+// --- The hidden image with the class ajaxLoader will be moved to the new created
+// --- div with the given message. The div with the class content will be hidden and instaed
+// --- of the hidden div there will be shown the new created element.
function onLoad(text)
{
var div = new Element("div", {"class" : CLASSES.load()}).update(content);
var content = $$("div." + CLASSES.content());
if(content.length === 1){
content[0].hide();
- var load = new Element("div", {"class" : CLASSES.load()}).update(text);
+ var load = new Element("div", {"class" : CLASSES.load()}).update("<br/><br/>" + text);
content[0].insert({"before" : load});
+ var img = $$("img." + CLASSES.ajaxLoader());
+ if(img.length === 1){
+ img[0].setStyle({"display" : "block"})
+ load.insert({"top" : img[0]})
+ }
}
}
@@ -68,7 +90,7 @@
try{
var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
var timeFun = setAjaxTimeout(TIMEOUT, TYPE_PSIS_URL);
- onLoad("Requesting all Type PSIs");
+ onLoad("Requesting all type PSIs");
new Ajax.Request(TYPE_PSIS_URL, {
"method" : "get",
@@ -89,7 +111,7 @@
try{
var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
var timeFun = setAjaxTimeout(TIMEOUT, TMCL_TYPE_URL);
- onLoad("Requesting all constraints for psis:\<br/>" + psis.gsub("\\[", "").gsub("\\]", ""));
+ onLoad("Requesting all constraints for the psis:\<br/>" + psis.gsub("\\[", "").gsub("\\]", ""));
new Ajax.Request(TMCL_TYPE_URL, {
"method" : "post",
@@ -140,20 +162,13 @@
neededTime += delta;
if(delta > maxTimeout && psis && psis.length !== 0){
alert("From getTopicStubs(): Please check your network-connection - the request timed out!!!");
- var loading = $$("div." + CLASSES.load());
- if(loading.length === 1) loading[0].remove();
- var content = $$("div." + CLASSES.content());
- if(content.length === 1) content[0].show();
+ removeLoad();
onFailureHandler();
return;
}
if(topicStubs.length === psis.length){
- var loading = $$("div." + CLASSES.load());
- if(loading.length === 1) loading[0].remove();
- var content = $$("div." + CLASSES.content());
- if(content.length === 1) content[0].show();
- onSuccessHandler(topicStubs);
+ removeLoad();
}
else setTimeout(checkRequests, delta);
}
1
0
Author: lgiessmann
Date: Thu Jun 18 11:06:47 2009
New Revision: 48
Log:
added two .GIFs which will be used as ajax-loader-animations
Added:
trunk/src/ajax/javascripts/ajaxLoader_big.gif (contents, props changed)
trunk/src/ajax/javascripts/ajaxLoader_small.gif (contents, props changed)
Added: trunk/src/ajax/javascripts/ajaxLoader_big.gif
==============================================================================
Binary file. No diff available.
Added: trunk/src/ajax/javascripts/ajaxLoader_small.gif
==============================================================================
Binary file. No diff available.
1
0
Author: lgiessmann
Date: Thu Jun 18 11:05:08 2009
New Revision: 47
Log:
ajax-client: fixed a bug with exclusive-instance-constraints; changes: associations created from constraints are initialy disabled; during ajax-requests there will be hidden the entire content. instead of the content there will be shown a message with some information what the client is doing at the moment - but this should be displaced by a loader-gif or something
Modified:
trunk/src/ajax/css/main.css
trunk/src/ajax/javascripts/constants.js
trunk/src/ajax/javascripts/create.js
trunk/src/ajax/javascripts/datamodel.js
trunk/src/ajax/javascripts/requests.js
Modified: trunk/src/ajax/css/main.css
==============================================================================
--- trunk/src/ajax/css/main.css (original)
+++ trunk/src/ajax/css/main.css Thu Jun 18 11:05:08 2009
@@ -47,6 +47,12 @@
}
.errorMessage {
+ margin: 0.5em;
color: red;
font-size: 0.85em;
+}
+
+div.loadFrame {
+ padding: 2em;
+ color: #ff7f00;
}
\ No newline at end of file
Modified: trunk/src/ajax/javascripts/constants.js
==============================================================================
--- trunk/src/ajax/javascripts/constants.js (original)
+++ trunk/src/ajax/javascripts/constants.js Thu Jun 18 11:05:08 2009
@@ -32,6 +32,9 @@
var STRING = "http://www.w3.org/2001/XMLSchema#string";
var CURRENT_TOPIC = "**current-topic**";
var CURRENT_TOPIC_ESCAPED = "\\*\\*current-topic\\*\\*";
+var INIT_DATE = ["If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT"];
+var MAX_INT = "MAX_INT";
+var MMAX_INT = "*";
// --- Contains most css classes used in this project
// --- There should be called only the function to be sure to don't override
@@ -77,6 +80,7 @@
"__divFog__" : "fog",
"__inputCommitButton__" : "commitButton",
"__divTmIdFrame__" : "tmIdFrame",
+ "__divLoad__" : "loadFrame",
"page" : function(){ return this.__divPage__; },
"subPage" : function(){ return this.__divSubPage__; },
@@ -117,5 +121,6 @@
"deselect" : function(){ return this.__spanDeselect__; },
"fog" : function(){ return this.__divFog__; },
"commitButton" : function(){ return this.__inputCommitButton__; },
- "tmIdFrame" : function(){ return this.__divTmIdFrame__; }
+ "tmIdFrame" : function(){ return this.__divTmIdFrame__; },
+ "load" : function(){ return this.__divLoad__; }
};
\ No newline at end of file
Modified: trunk/src/ajax/javascripts/create.js
==============================================================================
--- trunk/src/ajax/javascripts/create.js (original)
+++ trunk/src/ajax/javascripts/create.js Thu Jun 18 11:05:08 2009
@@ -26,26 +26,7 @@
function makeInstanceOfFrame(context){
function makeFragment(psis, constraints){
- var items = $$("li." + CLASSES.topicFrame());
- for(var i = 0; i != items.length; ++i){
- items[i].remove();
- }
-
- items = $$("li." + CLASSES.associationContainer());
- for(var i = 0; i != items.length; ++i){
- items[i].remove();
- }
-
- items = $$("li." + CLASSES.tmIdFrame());
- for(var i = 0; i !== items.length; ++i){
- items[i].remove();
- }
-
- items = $$("li." + CLASSES.commitButton());
- for(var i = 0; i !== items.length; ++i){
- items[i].remove();
- }
-
+ clearFragment();
var instanceOfs = new Array();
for(var i = 0; psis && i !== psis.length; ++i){
instanceOfs.push(new Array(psis[i]));
@@ -115,8 +96,7 @@
var liCB = new Element("li", {"class" : CLASSES.commitButton()});
liCB.update(commitButton);
liTm.insert({"after" : liCB});
-
- }
+ } //makeFragment
function onSuccessHandler(xhr){
var json = null;
@@ -134,13 +114,38 @@
catch(innerErr){
alert("There occurred an error by creating an InstanceOfC frame, please reload this page!\n\n" + innerErr);
}
- }
+ } //onSuccessHandler
getTypePsis(onSuccessHandler, null);
- }
+ } //makeInstanceOfFrame
makeInstanceOfFrame(liTopicSelect);
}catch(err){
alert(err);
}
+}
+
+
+// --- removes old elements from the fragment frame
+function clearFragment()
+{
+ var items = $$("li." + CLASSES.topicFrame());
+ for(var i = 0; i != items.length; ++i){
+ items[i].remove();
+ }
+
+ items = $$("li." + CLASSES.associationContainer());
+ for(var i = 0; i != items.length; ++i){
+ items[i].remove();
+ }
+
+ items = $$("li." + CLASSES.tmIdFrame());
+ for(var i = 0; i !== items.length; ++i){
+ items[i].remove();
+ }
+
+ items = $$("li." + CLASSES.commitButton());
+ for(var i = 0; i !== items.length; ++i){
+ items[i].remove();
+ }
}
\ No newline at end of file
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Thu Jun 18 11:05:08 2009
@@ -294,6 +294,7 @@
myself.__commit__.observe("click", function(event){
myself.hideError();
+ clearFragment();
requestConstraints(myself.toJSON(true), onSuccessHandler, null);
});
}
@@ -395,7 +396,7 @@
for(var i = 0; i != constraints.length; ++i){
this.__containers__.push(new Object());
var min = parseInt(constraints[i].cardMin);
- var max = constraints[i].cardMax !== "MAX_INT" ? parseInt(constraints[i].cardMax) : "*";
+ var max = constraints[i].cardMax !== MAX_INT ? parseInt(constraints[i].cardMax) : MMAX_INT;
if(max !== 0){
var cssTitle = "min: " + min + " max: " + max + " regular expression: " + constraints[i].regexp;
for(var j = 0; j != (min === 0 ? 1 : min); ++j){
@@ -403,7 +404,7 @@
var dblClickHandler = null;
if(min === 0) dblClickHandler = dblClickHandlerF;
var row = new TextrowC("", constraints[i].regexp, this.__containers__[i],
- min === 0 ? 1 : min, max === "*" ? -1 : max, cssTitle, dblClickHandler);
+ min === 0 ? 1 : min, max === MMAX_INT ? -1 : max, cssTitle, dblClickHandler);
row.dblClick();
this.__error__.insert({"before" : row.getFrame()});
}
@@ -470,7 +471,7 @@
for(var i = 0; i !== this.__constraints__.length; ++i){
var regexp = new RegExp(this.__constraints__[i].regexp);
var cardMin = parseInt(this.__constraints__[i].cardMin);
- var cardMax = this.__constraints__[i].cardMax === "MAX_INT" ? "*" : parseInt(this.__constraints__[i].cardMax);
+ var cardMax = this.__constraints__[i].cardMax === MAX_INT ? MMAX_INT : parseInt(this.__constraints__[i].cardMax);
var currentIdentifiers = new Array();
for(var j = 0; j !== allIdentifiers.length; ++j){
if(regexp.match(allIdentifiers[j].getContent()) === true) currentIdentifiers.push(allIdentifiers[j]);
@@ -482,7 +483,7 @@
errorStr += "card-min of the constraint regexp: \"" + this.__constraints__[i].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " is not satisfied (" + cardMin + ")!<br/>";
ret = false;
}
- if(cardMax !== "*" && cardMax < currentIdentifiers.length){
+ if(cardMax !== MMAX_INT && cardMax < currentIdentifiers.length){
errorStr += "card-max of the constraint regexp: \"" + this.__constraints__[i].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " is not satisfied (" + cardMax + ")!<br/>";
ret = false;
}
@@ -773,7 +774,7 @@
for(var i = 0; i != constraints.length; ++i){
var scopeTypes = constraints[i].scopeTypes;
var min = parseInt(constraints[i].cardMin);
- var max = constraints[i].cardMax !== "MAX_INT" ? parseInt(constraints[i].cardMax) : "*";
+ var max = constraints[i].cardMax !== MAX_INT ? parseInt(constraints[i].cardMax) : MMAX_INT;
// TODO: check and adds contents to the types
@@ -781,7 +782,7 @@
if(min === 0){ // TODO: check contents of this type
scopeTypes.unshift(new Array(new Array(""))); // [[""]]
}
- this.__container__.push(new ScopeC(scopeTypes, min === 0 ? 1 : min, max === "*" ? -1 : max));
+ this.__container__.push(new ScopeC(scopeTypes, min === 0 ? 1 : min, max === MMAX_INT ? -1 : max));
this.__error__.insert({"before" : this.__container__[this.__container__.length - 1].getFrame()});
}
}
@@ -1071,7 +1072,7 @@
// --- value
this.__value__ = new Object();
var _min = parseInt(simpleConstraint.cardMin);
- var _max = simpleConstraint.cardMax !== "MAX_INT" ? parseInt(simpleConstraint.cardMax) : "*";
+ var _max = simpleConstraint.cardMax !== MAX_INT ? parseInt(simpleConstraint.cardMax) : MMAX_INT;
var cssTitleV = "min: " + _min + " max: " + _max + " regular expression: " + (simpleConstraint ? simpleConstraint.regexp : ".*");
this.__cssTitle__ = cssTitle;
new TextrowC((contents ? contents.value : ""), (simpleConstraint ? simpleConstraint.regexp : ".*"), this.__value__, 1, 1, cssTitleV);
@@ -1179,7 +1180,7 @@
for(var j = 0; j != constraints[i].constraints.length; ++j){
this.__containers__[i].push(new Object());
var min = parseInt(constraints[i].constraints[j].cardMin);
- var max = constraints[i].constraints[j].cardMax !== "MAX_INT" ? parseInt(constraints[i].constraints[j].cardMax) : "*";
+ var max = constraints[i].constraints[j].cardMax !== MAX_INT ? parseInt(constraints[i].constraints[j].cardMax) : MMAX_INT;
var regexp = constraints[i].constraints[j].regexp;
if(max !== 0){
var dblClickHandler = null;
@@ -1187,7 +1188,7 @@
var title = "min: " + min + " max: " + max + " regular expression: " + regexp;
for(var k = 0; k !== (min === 0 ? 1 : min); ++k){
- var name = new NameC("", constraints[i].nametypescopes, constraints[i].constraints[j], this.__containers__[i][j], min === 0 ? 1 : min, max === "*" ? -1 : max, title, dblClickHandler);
+ var name = new NameC("", constraints[i].nametypescopes, constraints[i].constraints[j], this.__containers__[i][j], min === 0 ? 1 : min, max === MMAX_INT ? -1 : max, title, dblClickHandler);
if(min === 0)name.disable();
this.__error__.insert({"before" : name.getFrame()});
if(min === 0)name.minimize();
@@ -1300,7 +1301,7 @@
for(var j = 0; j !== this.__constraints__[i].constraints.length; ++j){
var regexp = new RegExp(this.__constraints__[i].constraints[j].regexp);
var cardMin = parseInt(this.__constraints__[i].constraints[j].cardMin);
- var cardMax = this.__constraints__[i].constraints[j].cardMax === "MAX_INT" ? "*" : parseInt(this.__constraints__[i].constraints[j].cardMax);
+ var cardMax = this.__constraints__[i].constraints[j].cardMax === MAX_INT ? MMAX_INT : parseInt(this.__constraints__[i].constraints[j].cardMax);
var matchedNames = 0;
for(var k = 0; k !== currentNames.length; ++k){
if(regexp.match(currentNames[k].getContent().value) === true){
@@ -1313,7 +1314,7 @@
if(errorStr.length !== 0) errorStr += "<br/><br/>";
errorStr += "card-min of the constraint regexp: \"" + this.__constraints__[i].constraints[j].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " for the nametype \"" + currentConstraintTypes + " is not satisfied (" + matchedNames + ")!";
}
- if(cardMax !== "*" && matchedNames > cardMax){
+ if(cardMax !== MMAX_INT && matchedNames > cardMax){
ret = false;
if(errorStr.length !== 0) errorStr += "<br/><br/>";
errorStr += "card-max of the constraint regexp: \"" + this.__constraints__[i].constraints[j].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " for the nametype \"" + currentConstraintTypes + " is not satisfied (" + matchedNames + ")!";
@@ -1381,7 +1382,7 @@
// --- resource value and datatype
var _min = parseInt(constraint.cardMin);
- var _max = constraint.cardMax !== "MAX_INT" ? parseInt(constraint.cardMax) : "*";
+ var _max = constraint.cardMax !== MAX_INT ? parseInt(constraint.cardMax) : MMAX_INT;
var cssTitle = "min: " + _min + " max: " + _max + " regular expression: " + constraint.regexp;
this.__cssTitle__ = cssTitle;
makeResource(this, contents, constraint, (occurrenceTypes ? occurrenceTypes[0].datatypeConstraint : null), cssTitle);
@@ -1493,7 +1494,7 @@
for(var j = 0; j != constraints[i].constraints.length; ++j){
this.__containers__[i].push(new Object());
var min = parseInt(constraints[i].constraints[j].cardMin);
- var max = constraints[i].constraints[j].cardMax !== "MAX_INT" ? parseInt(constraints[i].constraints[j].cardMax) : "*";
+ var max = constraints[i].constraints[j].cardMax !== MAX_INT ? parseInt(constraints[i].constraints[j].cardMax) : MMAX_INT;
var regexp = constraints[i].constraints[j].regexp;
if(max !== 0){
var dblClickHandler = null;
@@ -1501,7 +1502,7 @@
var title = "min: " + min + " max: " + max + " regular expression: " + regexp;
for(var k = 0; k !== (min === 0 ? 1 : min); ++k){
- var occurrence = new OccurrenceC("", constraints[i].occurrenceTypes, constraints[i].constraints[j], constraints[i].uniqueConstraints, this.__containers__[i][j], min === 0 ? 1 : min, max === "*" ? -1 : max, title, dblClickHandler);
+ var occurrence = new OccurrenceC("", constraints[i].occurrenceTypes, constraints[i].constraints[j], constraints[i].uniqueConstraints, this.__containers__[i][j], min === 0 ? 1 : min, max === MMAX_INT ? -1 : max, title, dblClickHandler);
if(min === 0) occurrence.disable();
this.__error__.insert({"before" : occurrence.getFrame()});
if(min === 0)occurrence.minimize();
@@ -1572,7 +1573,7 @@
for(var j = 0; j !== this.__constraints__[i].constraints.length; ++j){
var regexp = new RegExp(this.__constraints__[i].constraints[j].regexp);
var cardMin = parseInt(this.__constraints__[i].constraints[j].cardMin);
- var cardMax = this.__constraints__[i].constraints[j].cardMax === "MAX_INT" ? "*" : parseInt(this.__constraints__[i].constraints[j].cardMax);
+ var cardMax = this.__constraints__[i].constraints[j].cardMax === MAX_INT ? MMAX_INT : parseInt(this.__constraints__[i].constraints[j].cardMax);
var matchedOccurrences = 0;
for(var k = 0; k !== currentOccurrences.length; ++k){
var value = currentOccurrences[k].getContent().resourceRef;
@@ -1589,7 +1590,7 @@
if(errorStr.length !== 0) errorStr += "<br/><br/>";
errorStr += "card-min of the constraint regexp: \"" + this.__constraints__[i].constraints[j].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " for the occurrencetype \"" + currentConstraintTypes + " is not satisfied (" + matchedOccurrences + ")!";
}
- if(cardMax !== "*" && matchedOccurrences > cardMax){
+ if(cardMax !== MMAX_INT && matchedOccurrences > cardMax){
ret = false;
if(errorStr.length !== 0) errorStr += "<br/><br/>";
errorStr += "card-max of the constraint regexp: \"" + this.__constraints__[i].constraints[j].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " for the occurrencetype \"" + currentConstraintTypes + " is not satisfied (" + matchedOccurrences + ")!";
@@ -2170,7 +2171,7 @@
if(!role || !constraint) return;
var cOtherPlayers = constraint.otherPlayers;
var cOtherRoleType = constraint.otherRoleType;
- var cardMax = constraint.cardMax === "MAX_INT" ? "*" : parseInt(constraint.cardMax);
+ var cardMax = constraint.cardMax === MAX_INT ? MMAX_INT : parseInt(constraint.cardMax);
var cardMin = parseInt(constraint.cardMin);
var existingRoles = this.getExistingRoles(cOtherRoleType, cOtherPlayers, this.__orContainer__.__frames__);
var cleanedPlayers = new Array();
@@ -2199,7 +2200,7 @@
"__checkARCButtons__" : function(rolesToCheck, players, associationRoleConstraint){
if(!rolesToCheck || !associationRoleConstraint) return;
var cardMin = associationRoleConstraint.cardMin === 0 ? 1 : parseInt(associationRoleConstraint.cardMin);
- var cardMax = associationRoleConstraint.cardMax === "MAX_INT" ? "*" : parseInt(associationRoleConstraint.cardMax);
+ var cardMax = associationRoleConstraint.cardMax === MAX_INT ? MMAX_INT : parseInt(associationRoleConstraint.cardMax);
var lenPlayers = players ? players.length : 0;
if(cardMin < rolesToCheck.length) {
for(var i = 0; i !== rolesToCheck.length; ++i) rolesToCheck[i].showRemoveButton();
@@ -2208,7 +2209,7 @@
for(var i = 0; i !== rolesToCheck.length; ++i) rolesToCheck[i].hideRemoveButton();
}
- if(cardMax === "*" || cardMax > rolesToCheck.length && rolesToCheck.length < lenPlayers){
+ if(cardMax === MMAX_INT || cardMax > rolesToCheck.length && rolesToCheck.length < lenPlayers){
for(var i = 0; i !== rolesToCheck.length; ++i) rolesToCheck[i].showAddButton();
}
else {
@@ -2222,7 +2223,7 @@
function addHandler(myself){
var cOtherPlayers = currentConstraint.otherPlayers;
var cOtherRoleType = currentConstraint.otherRoleType;
- var cardMax = currentConstraint.cardMax === "MAX_INT" ? "*" : parseInt(currentConstraint.cardMax);
+ var cardMax = currentConstraint.cardMax === MAX_INT ? MMAX_INT : parseInt(currentConstraint.cardMax);
var cardMin = currentConstraint.cardMin === 0 ? 1 : parseInt(currentConstraint.cardMin);
var cardMinOrg = parseInt(currentConstraint.cardMin);;
var existingRoles = roleContainer.getExistingRoles(cOtherRoleType, cOtherPlayers, roleContainer.__orContainer__.__frames__);
@@ -2260,7 +2261,7 @@
function removeHandler(myself){
var cOtherPlayers = currentConstraint.otherPlayers;
var cOtherRoleType = currentConstraint.otherRoleType;
- var cardMax = currentConstraint.cardMax === "MAX_INT" ? "*" : parseInt(currentConstraint.cardMax);
+ var cardMax = currentConstraint.cardMax === MAX_INT ? MMAX_INT : parseInt(currentConstraint.cardMax);
var cardMin = currentConstraint.cardMin === 0 ? 1 : parseInt(currentConstraint.cardMin);
var playerToAdd = null;
for(var i = 0; i !== cOtherPlayers.length; ++i){
@@ -2283,7 +2284,7 @@
if(!existingRoles) return;
// --- checks all control buttons after an add or remove operation
- if(cardMax !== "*" && existingRoles.length >= cardMax){
+ if(cardMax !== MMAX_INT && existingRoles.length >= cardMax){
for(var i = 0; i !== existingRoles.length; ++i){
existingRoles[i].hideAddButton();
}
@@ -2319,9 +2320,9 @@
}
// --- creates a new role
- var cardMax = associationRoleConstraint.cardMax === "MAX_INT" ? "*" : parseInt(associationRoleConstraint.cardMax);
+ var cardMax = associationRoleConstraint.cardMax === MAX_INT ? MMAX_INT : parseInt(associationRoleConstraint.cardMax);
var cardMin = parseInt(associationRoleConstraint.cardMin);
- if(cardMax === "*" || cardMax > rolesToCheck.length){
+ if(cardMax === MMAX_INT || cardMax > rolesToCheck.length){
var usedPlayers = new Array();
for(var i = 0; i !== rolesToCheck.length; ++i) usedPlayers.push(rolesToCheck[i].getPlayer());
var cleanedPlayers = cleanPlayers(players ? players : new Array(), usedPlayers);
@@ -2582,7 +2583,7 @@
var currentRoles = new Array();
var rType = arcs[i].roleType.flatten();
var cardMin = parseInt(arcs[i].cardMin);
- var cardMax = arcs[i].cardMax === "MAX_INT" ? "*" : parseInt(arcs[i].cardMax);
+ var cardMax = arcs[i].cardMax === MAX_INT ? MMAX_INT : parseInt(arcs[i].cardMax);
// --- collects all roles for the current constraint
for(var j = 0; j !== allAroles.length; ++j){
@@ -2595,7 +2596,7 @@
if(errorStr.length !== 0) errorStr += "<br/><br/>";
errorStr += "card-min of the associationrole-constraint card-min: " + cardMin + " card-max: " + cardMax + " for the roletype \"" + rType + " is not satisfied (" + currentRoles.length + ")!";
}
- if(cardMax !== "*" && cardMax < currentRoles.length){
+ if(cardMax !== MMAX_INT && cardMax < currentRoles.length){
ret = false;
if(errorStr.length !== 0) errorStr += "<br/><br/>";
errorStr += "card-max of the associationrole-constraint card-min: " + cardMin + " card-max: " + cardMax + " for the roletype \"" + rType + " is not satisfied (" + currentRoles.length + ")!";
@@ -2611,14 +2612,14 @@
var players = currentRpcs[i].players;
var pType = currentRpcs[i].playerType.flatten();
cardMin = parseInt(currentRpcs[i].cardMin);
- cardMax = currentRpcs[i].cardMax === "MAX_INT" ? "*" : parseInt(currentRpcs[i].cardMax);
+ cardMax = currentRpcs[i].cardMax === MAX_INT ? MMAX_INT : parseInt(currentRpcs[i].cardMax);
var foundRoles = this.getExistingRoles(rType, players, currentRoles);
if(cardMin > foundRoles.length){
ret = false;
if(errorStr.length !== 0) errorStr += "<br/><br/>";
errorStr += "card-min of the roleplayer-constraint card-min: " + cardMin + " card-max: " + cardMax + " for the roletype \"" + rType + " and the playertype \"" + pType + "\" is not satisfied (" + foundRoles.length + ")!";
}
- if(cardMax !== "*" && cardMax < foundRoles.length){
+ if(cardMax !== MMAX_INT && cardMax < foundRoles.length){
ret = false;
if(errorStr.length !== 0) errorStr += "<br/><br/>";
errorStr += "card-max of the roleplayer-constraint card-min: " + cardMin + " card-max: " + cardMax + " for the roletype \"" + rType + " and the playertype \"" + pType + "\" is not satisfied (" + foundRoles.length + ")!";
@@ -2649,7 +2650,7 @@
var pType = usedOrcs[i].otherPlayerType;
var rType = usedOrcs[i].otherRoleType;
var cardMin = parseInt(usedOrcs[i].cardMin);
- var cardMax = usedOrcs[i].cardMax === "MAX_INT" ? "*" : parseInt(usedOrcs[i].cardMax);
+ var cardMax = usedOrcs[i].cardMax === MAX_INT ? MMAX_INT : parseInt(usedOrcs[i].cardMax);
var foundRoles = this.getExistingRoles(rType, players, allOroles);
checkedRoles = checkedRoles.concat(foundRoles);
if(cardMin > foundRoles.length){
@@ -2657,7 +2658,7 @@
if(errorStr.length !== 0) errorStr += "<br/><br/>";
errorStr += "card-min of the otherrole-constraint card-min: " + cardMin + " card-max: " + cardMax + " for the roletype \"" + rType + " and the playertype \"" + pType + "\" is not satisfied (" + foundRoles.length + ")!";
}
- if(cardMax !== "*" && cardMax < foundRoles.length){
+ if(cardMax !== MMAX_INT && cardMax < foundRoles.length){
ret = false;
if(errorStr.length !== 0) errorStr += "<br/><br/>";
errorStr += "card-max of the otherrole-constraint card-min: " + cardMin + " card-max: " + cardMax + " for the roletype \"" + rType + " and the playertype \"" + pType + "\" is not satisfied (" + foundRoles.length + ")!";
@@ -2835,6 +2836,7 @@
td.update(association.getFrame());
tr.update(td);
this.__table__.insert({"bottom" : tr});
+ association.disable();
}
function setMinimizeHandler(myself){
myself.__caption__.observe("click", function(event){
Modified: trunk/src/ajax/javascripts/requests.js
==============================================================================
--- trunk/src/ajax/javascripts/requests.js (original)
+++ trunk/src/ajax/javascripts/requests.js Thu Jun 18 11:05:08 2009
@@ -10,6 +10,8 @@
//+-----------------------------------------------------------------------------
+
+
// --- Sets a timeout function which alerts a message.
function setAjaxTimeout(time, url)
{
@@ -26,13 +28,32 @@
function createXHRHandler(handler, timeFun)
{
function fun(xhr){
- clearTimeout(timeFun);
- handler(xhr);
+ try{
+ clearTimeout(timeFun);
+ var loading = $$("div." + CLASSES.load());
+ if(loading.length === 1) loading[0].remove();
+ var content = $$("div." + CLASSES.content());
+ if(content.length === 1) content[0].show();
+ handler(xhr);
+ }
+ catch(err) {alert("err: " + err); }
}
return fun;
}
+function onLoad(text)
+{
+ var div = new Element("div", {"class" : CLASSES.load()}).update(content);
+ var content = $$("div." + CLASSES.content());
+ if(content.length === 1){
+ content[0].hide();
+ var load = new Element("div", {"class" : CLASSES.load()}).update(text);
+ content[0].insert({"before" : load});
+ }
+}
+
+
// --- This is the default error handler of the used ajax.requests.
function defaultFailureHandler(xhr)
{
@@ -47,10 +68,11 @@
try{
var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
var timeFun = setAjaxTimeout(TIMEOUT, TYPE_PSIS_URL);
+ onLoad("Requesting all Type PSIs");
new Ajax.Request(TYPE_PSIS_URL, {
"method" : "get",
- "requestHeaders" : ["If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT"],
+ "requestHeaders" : INIT_DATE,
"onSuccess" : createXHRHandler(onSuccessHandler, timeFun),
"onFailure" : createXHRHandler(onFailure, timeFun)});
}
@@ -67,6 +89,7 @@
try{
var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
var timeFun = setAjaxTimeout(TIMEOUT, TMCL_TYPE_URL);
+ onLoad("Requesting all constraints for psis:\<br/>" + psis.gsub("\\[", "").gsub("\\]", ""));
new Ajax.Request(TMCL_TYPE_URL, {
"method" : "post",
@@ -89,12 +112,13 @@
try{
var topicStubs = new Array();
- if(psis){
+ if(psis && psis.length !== 0){
+ onLoad("Requesting topicStubs information for<br/>" + psis);
for(var i = 0; i !== psis.length; ++i){
var url = GET_STUB_PREFIX + psis[i].gsub("#", "%23");
new Ajax.Request(url, {
"method" : "get",
- "requestHeaders" : ["If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT"],
+ "requestHeaders" : INIT_DATE,
"onSuccess" : function(xhr){
if(xhr.responseText.length === 0 || xhr.responseText.isJSON() === false) errorHandler("Got bad JSON-Data for \"" + psis[i] + "\"!");
else topicStubs.push(xhr.responseText);
@@ -116,11 +140,21 @@
neededTime += delta;
if(delta > maxTimeout && psis && psis.length !== 0){
alert("From getTopicStubs(): Please check your network-connection - the request timed out!!!");
+ var loading = $$("div." + CLASSES.load());
+ if(loading.length === 1) loading[0].remove();
+ var content = $$("div." + CLASSES.content());
+ if(content.length === 1) content[0].show();
onFailureHandler();
return;
}
- if(topicStubs.length === psis.length) onSuccessHandler(topicStubs);
+ if(topicStubs.length === psis.length){
+ var loading = $$("div." + CLASSES.load());
+ if(loading.length === 1) loading[0].remove();
+ var content = $$("div." + CLASSES.content());
+ if(content.length === 1) content[0].show();
+ onSuccessHandler(topicStubs);
+ }
else setTimeout(checkRequests, delta);
}
@@ -140,6 +174,7 @@
try{
var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
var timeFun = setAjaxTimeout(TIMEOUT, COMMIT_URL);
+ onLoad("Committing current fragment to " + COMMIT_URL);
new Ajax.Request(COMMIT_URL, {
"method" : "post",
1
0
Author: lgiessmann
Date: Thu Jun 18 09:29:56 2009
New Revision: 46
Log:
ajax-client: all ajax-requests have a timeout depending on the data to be commited or requested - the minimum timeout is set by the constant "TIMEOUT"
Modified:
trunk/src/ajax/javascripts/requests.js
Modified: trunk/src/ajax/javascripts/requests.js
==============================================================================
--- trunk/src/ajax/javascripts/requests.js (original)
+++ trunk/src/ajax/javascripts/requests.js Thu Jun 18 09:29:56 2009
@@ -10,6 +10,29 @@
//+-----------------------------------------------------------------------------
+// --- Sets a timeout function which alerts a message.
+function setAjaxTimeout(time, url)
+{
+ return setTimeout(function(){
+ alert("The AJAX request for \"" + url + "\" timed out. Please check your network connection!");
+ }, time);
+}
+
+
+// --- Returns a function whihc can be used as an XHR-Handler.
+// --- The returned function is the passed handler wrapped in
+// --- a lambda-function which additionally clears the passed timeout
+// --- function.
+function createXHRHandler(handler, timeFun)
+{
+ function fun(xhr){
+ clearTimeout(timeFun);
+ handler(xhr);
+ }
+ return fun;
+}
+
+
// --- This is the default error handler of the used ajax.requests.
function defaultFailureHandler(xhr)
{
@@ -23,12 +46,13 @@
{
try{
var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
-
+ var timeFun = setAjaxTimeout(TIMEOUT, TYPE_PSIS_URL);
+
new Ajax.Request(TYPE_PSIS_URL, {
"method" : "get",
"requestHeaders" : ["If-Modified-Since", "Thu, 1 Jan 1970 00:00:00 GMT"],
- "onSuccess" : onSuccessHandler,
- "onFailure" : onFailure});
+ "onSuccess" : createXHRHandler(onSuccessHandler, timeFun),
+ "onFailure" : createXHRHandler(onFailure, timeFun)});
}
catch(err){
alert("Could not request all type PSIs, please try again!\n\n" + err);
@@ -42,12 +66,13 @@
{
try{
var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
-
+ var timeFun = setAjaxTimeout(TIMEOUT, TMCL_TYPE_URL);
+
new Ajax.Request(TMCL_TYPE_URL, {
"method" : "post",
"postBody" : psis,
- "onSuccess" : onSuccessHandler,
- "onFailure" : onFailure});
+ "onSuccess" : createXHRHandler(onSuccessHandler, timeFun),
+ "onFailure" : createXHRHandler(onFailure, timeFun)});
}
catch(err){
alert("Could not request contraints, please try again!\n\n" + err);
@@ -108,17 +133,19 @@
}
+// --- Sends a POST-Message to the server with the fragment data which hast to be committed.
function commitFragment(json, onSuccessHandler, onFailureHandler)
{
if(!json || !onSuccessHandler) throw "From commitFragment(): json and onSuccessHandler must be set!";
try{
var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
+ var timeFun = setAjaxTimeout(TIMEOUT, COMMIT_URL);
new Ajax.Request(COMMIT_URL, {
"method" : "post",
"postBody" : json,
- "onSuccess" : onSuccessHandler,
- "onFailure" : onFailure});
+ "onSuccess" : createXHRHandler(onSuccessHandler, timeFun),
+ "onFailure" : createXHRHandler(onFailure, timeFun)});
}
catch(err){
alert("From commitFragment(): " + err);
1
0

18 Jun '09
Author: lgiessmann
Date: Thu Jun 18 09:06:59 2009
New Revision: 45
Log:
ajax-client: before committing a fragment, the given data will be validated by the client - and only be sent when the fragment is valid; currently the constraints "uniqueoccurrence-constraint" and "datatype-constraint" won\'t be checked
Modified:
trunk/docs/xtm_json.txt
trunk/src/ajax/css/frame.css
trunk/src/ajax/javascripts/create.js
trunk/src/ajax/javascripts/datamodel.js
Modified: trunk/docs/xtm_json.txt
==============================================================================
--- trunk/docs/xtm_json.txt (original)
+++ trunk/docs/xtm_json.txt Thu Jun 18 09:06:59 2009
@@ -1,4 +1,4 @@
-//+-----------------------------------------------------------------------------
+//+-----------------------------------------------------------------------------
//+ Overview:
//+ *Part 1: XTM - data model
//+ *Part 2: Object summaries
Modified: trunk/src/ajax/css/frame.css
==============================================================================
--- trunk/src/ajax/css/frame.css (original)
+++ trunk/src/ajax/css/frame.css Thu Jun 18 09:06:59 2009
@@ -24,4 +24,9 @@
tr.showHiddenRows {
background-color: #eaeaee;
+}
+
+li.errorMessage {
+ margin-top: 1em;
+ font-size: 1.2em;
}
\ No newline at end of file
Modified: trunk/src/ajax/javascripts/create.js
==============================================================================
--- trunk/src/ajax/javascripts/create.js (original)
+++ trunk/src/ajax/javascripts/create.js Thu Jun 18 09:06:59 2009
@@ -45,7 +45,7 @@
for(var i = 0; i !== items.length; ++i){
items[i].remove();
}
-
+
var instanceOfs = new Array();
for(var i = 0; psis && i !== psis.length; ++i){
instanceOfs.push(new Array(psis[i]));
@@ -66,12 +66,21 @@
liA = liT;
}
- var tmId = new tmIdC(null);
+ var tmId = new TmIdC(null);
var liTm = new Element("li", {"class" : CLASSES.tmIdFrame()}).update(tmId.getFrame());
liA.insert({"after" : liTm});
var commitButton = new Element("input", {"type" : "button", "value" : "commit fragment", "style" : "float: right; margin-top: -10px;"})
commitButton.observe("click", function(event){
+ // --- validates the given data
+ var ret = true;
+ if(topic.isValid() === false) ret = false;
+ if(associations.isValid() === false) ret = false;
+ if(tmId.isValid() === false) ret = false;
+
+ if(ret === false) return;
+
+ // --- if the validation succeeded the fragment will be sent to the server
var tPsis = topic.getContent().subjectIdentifiers;
var referencedTopics = topic.getReferencedTopics();
if(associations){
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Thu Jun 18 09:06:59 2009
@@ -92,6 +92,7 @@
this.__max__ = max;
this.__regexp__ = new RegExp(regexp);
+ this.__regExpString__ = regexp;
this.__frame__.writeAttribute({"class" : CLASSES.textrowWithRemoveButton()});
this.__content__.remove();
this.__content__ = new Element("input", {"type" : "text", "value" : content});
@@ -129,6 +130,7 @@
this.getFrame().writeAttribute({"class" : CLASSES.textrowWithoutRemoveButton()});
},
"disable" : function(){
+ this.hideError();
this.__content__.writeAttribute({"readonly" : "readonly"});
this.hideRemoveButton();
this.hideAddButton();
@@ -138,6 +140,9 @@
this.__content__.removeAttribute("readonly");
checkRemoveAddButtons(this.__owner__, this.__min__, this.__max__);
this.__disabled__ = false;
+ },
+ "getRegexp" : function(){
+ return this.__regExpString__;
}});
@@ -174,6 +179,7 @@
this.getFrame().writeAttribute({"class" : CLASSES.selectrowWithoutRemoveButton()});
},
"disable" : function(){
+ this.hideError();
this.__content__.writeAttribute({"disabled" : "disables"});
this.__disabled__ = true;
},
@@ -314,7 +320,7 @@
try{
for(var i = 0; i != contents.length; ++i){
- new TextrowC(contents[i], ".*", this.__container__, 1, -1, null);
+ new TextrowC(decodeURI(contents[i]), ".*", this.__container__, 1, -1, null);
this.__error__.insert({"before" : this.__container__.__frames__[i].getFrame()});
}
}
@@ -350,6 +356,7 @@
if(removeNull === true && this.__container__.__frames__[i].getContent().strip().length === 0) continue;
values.push(this.__container__.__frames__[i].getContent().strip());
}
+ for(var i = 0; i !== values.length; ++i)values[i] = encodeURI(values[i]);
return values;
},
"toJSON" : function(unique, removeNull){
@@ -357,6 +364,7 @@
return content.length === 0 ? "null" : content.toJSON();
},
"disable" : function(){
+ this.hideError();
if(this.__container__.__frames__){
for(var i = 0; i !== this.__container__.__frames__.length; ++i){
this.__container__.__frames__[i].disable();
@@ -380,6 +388,7 @@
$super();
this.__frame__.writeAttribute({"class" : cssClass});
this.__containers__ = new Array();
+ this.__constraints__ = constraints;
try{
if((!contents || contents.length === 0) && constraints && constraints.length > 0){
@@ -421,8 +430,10 @@
}
}
catch(err){
+ for(var i = 0; i !== values.length; ++i) values[i] = encodeURI(values[i]);
return values;
}
+ for(var i = 0; i !== values.length; ++i) values[i] = encodeURI(values[i]);
return values;
},
"toJSON" : function(unique, removeNull){
@@ -430,8 +441,68 @@
return content.length === 0 ? "null" : content.toJSON();
},
"isValid" : function(){
- // TODO: check the validity of this frame with the passed constraints and return a boolean value
- return true;
+ try {
+ var allIdentifiers = new Array();
+ var errorStr = "";
+ var ret = true;
+
+ // --- checks if there are any constraints
+ if((!this.__constraints__ || this.__constraints__.length === 0) && this.__containers__.length !== 0){
+ for(var i = 0; i !== this.__containers__.length; ++i){
+ for(var j = 0; this.__containers__[i].__frames__ && j !== this.__containers__[i].__frames__.length; ++j){
+ this.__containers__[i].__frames__[j].showError("No constraints found for this identifier!");
+ }
+ }
+ return false;
+ }
+ else if(!this.__constraints__ || this.__constraints__.length === 0) return true;
+
+ // --- collects all non-empty identifiers
+ for(var i = 0; i !== this.__containers__.length; ++i){
+ for(var j = 0; this.__containers__[i].__frames__ && j !== this.__containers__[i].__frames__.length; ++j){
+ var row = this.__containers__[i].__frames__[j];
+ row.hideError();
+ if(row.isUsed() === true && row.getContent().strip().length !== 0) allIdentifiers.push(row);
+ }
+ }
+
+ var checkedIdentifiers = new Array();
+ for(var i = 0; i !== this.__constraints__.length; ++i){
+ var regexp = new RegExp(this.__constraints__[i].regexp);
+ var cardMin = parseInt(this.__constraints__[i].cardMin);
+ var cardMax = this.__constraints__[i].cardMax === "MAX_INT" ? "*" : parseInt(this.__constraints__[i].cardMax);
+ var currentIdentifiers = new Array();
+ for(var j = 0; j !== allIdentifiers.length; ++j){
+ if(regexp.match(allIdentifiers[j].getContent()) === true) currentIdentifiers.push(allIdentifiers[j]);
+ }
+ checkedIdentifiers = checkedIdentifiers.concat(currentIdentifiers);
+
+ // --- checks card-min and card-max for the current constraint
+ if(cardMin > currentIdentifiers.length){
+ errorStr += "card-min of the constraint regexp: \"" + this.__constraints__[i].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " is not satisfied (" + cardMin + ")!<br/>";
+ ret = false;
+ }
+ if(cardMax !== "*" && cardMax < currentIdentifiers.length){
+ errorStr += "card-max of the constraint regexp: \"" + this.__constraints__[i].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " is not satisfied (" + cardMax + ")!<br/>";
+ ret = false;
+ }
+ }
+
+ // --- checks if there are some identifiers which don't satisfies any constraint
+ checkedIdentifiers = checkedIdentifiers.uniq();
+ if(checkedIdentifiers.length < allIdentifiers.length){
+ ret = false;
+ for(var i = 0; i !== allIdentifiers.length; ++i){
+ if(checkedIdentifiers.indexOf(allIdentifiers[i]) === -1) allIdentifiers[i].showError("This Identifier does not satisfie any constraint!");
+ }
+ }
+
+ if(ret === true) this.hideError();
+ else this.showError(errorStr);
+ return ret;
+ }catch(err){ alert("err: " + err); }
+
+
}});
@@ -656,6 +727,7 @@
return values;
},
"disable" : function(){
+ this.hideError();
var rows = this.getFrame().select("div");
for(var i = 0; i != rows.length; ++i){
rows[i].select("select")[0].disable();
@@ -750,6 +822,7 @@
return this.getContent().toJSON();
},
"disable" : function(){
+ this.hideError();
for(var i = 0; i !== this.__container__.length; ++i) this.__container__[i].disable();
this.__disabled__ = true;
},
@@ -836,13 +909,24 @@
",\"scopes\":null,\"resourceRef\":" + resourceRef + ",\"resourceData\":" + resourceData + "}";
},
+ "isEmpty" : function(){
+ return this.__value__.value.length === 0;
+ },
"isValid" : function(){
- return this.__value__.value.strip() !== "";
+ if(this.__value__.value.strip() === ""){
+ this.showError("Resource Value must be set!");
+ return false;
+ }
+ else {
+ this.hideError();
+ return true;
+ }
},
"isUsed" : function(){
return !this.__disabled__;
},
"disable" : function(){
+ this.hideError();
this.__itemIdentity__.disable();
// TODO: scope
this.__value__.writeAttribute({"readonly" : "readonly"});
@@ -890,41 +974,41 @@
var variant = new VariantC(null, this.__container__, dblClickHandlerF, parent);
this.__frame__.insert({"bottom" : variant.getFrame()});
variant.minimize();
+ variant.disable();
}
},
"getContent" : function(){
var values = new Array();
for(var i = 0; i != this.__container__.__frames__.length; ++i){
- if(this.__container__.__frames__[i].isUsed() === true){
+ if(this.__container__.__frames__[i].isUsed() === true && this.__container__.__frames__[i].isEmpty() === false){
values.push(this.__container__.__frames__[i].getContent());
}
}
return values;
},
"isValid" : function(){
+ var ret = true;
for(var i = 0; i != this.__container__.__frames__.length; ++i){
if(this.__container__.__frames__[i].isUsed() === true &&
- this.__container__.__frames__[i].isValid() === false) return false;
+ this.__container__.__frames__[i].isValid() === false) ret = false;;
}
- return true;
+ return ret;
},
"toJSON" : function(){
var str = "[";
for(var i = 0; i != this.__container__.__frames__.length; ++i){
- if(this.__container__.__frames__[i].isUsed() === true){
- str += this.__container__.__frames__[i].toJSON();
- }
- if(i < this.__container__.__frames__.length - 1){
- str += ","
+ if(this.__container__.__frames__[i].isUsed() === true && this.__container__.__frames__[i].isEmpty() === false){
+ str += this.__container__.__frames__[i].toJSON() + ",";
}
}
- str += "]";
- return str === "[]" ? null : str;
+ str = str.substring(0, str.length - 1) + "]"
+ return str === "]" ? null : str;
},
"isUsed" : function(){
return !this.__disabled__;
},
"disable" : function(){
+ this.hideError();
if(this.__container__.__frames__){
for(var i = 0; i !== this.__container__.__frames__.length; ++i)
this.__container__.__frames__[i].disable();
@@ -1019,6 +1103,9 @@
alert("From NameC(): " + err);
}
},
+ "isEmpty" : function(){
+ return this.__value__.__frames__[0].getContent().length === 0;
+ },
"getContent" : function(){
if(this.isUsed() === false) return null;
var type = this.__type__.__frames__[0].getContent();
@@ -1037,8 +1124,11 @@
",\"variants\":" + this.__variants__.toJSON() + "}";
},
"isValid" : function(){
- // TODO: check the content and the constraints + variants.isValid()
- return true;
+ var valueValid = this.__value__.__frames__[0].isValid();
+ if(valueValid === false) this.showError("The name-value \"" + this.__value__.__frames__[0].getContent() + "\" doesn't matches the constraint \"" + this.__value__.__frames__[0].getRegexp() + "\"!");
+ else this.hideError();
+ var variantsValid = this.__variants__.isValid();
+ return valueValid && variantsValid;
},
"minimize" : function(){
var trs = this.__table__.select("tr");
@@ -1048,6 +1138,7 @@
}
},
"disable" : function(){
+ this.hideError();
this.__itemIdentity__.disable();
this.__type__.__frames__[0].disable();
this.__scope__.disable();
@@ -1079,6 +1170,7 @@
$super();
this.__frame__.writeAttribute({"class" : CLASSES.nameContainer()});
this.__containers__ = new Array();
+ this.__constraints__ = constraints;
try{
if((!contents || contents.length === 0) && constraints && constraints.length > 0){
@@ -1094,11 +1186,12 @@
if(min === 0) dblClickHandler = dblClickHandlerF;
var title = "min: " + min + " max: " + max + " regular expression: " + regexp;
- var name = new NameC("", constraints[i].nametypescopes, constraints[i].constraints[j],
- this.__containers__[i][j], min === 0 ? 1 : min, max === "*" ? -1 : max, title, dblClickHandler);
- if(min === 0)name.disable();
- this.__error__.insert({"before" : name.getFrame()});
- if(min === 0)name.minimize();
+ for(var k = 0; k !== (min === 0 ? 1 : min); ++k){
+ var name = new NameC("", constraints[i].nametypescopes, constraints[i].constraints[j], this.__containers__[i][j], min === 0 ? 1 : min, max === "*" ? -1 : max, title, dblClickHandler);
+ if(min === 0)name.disable();
+ this.__error__.insert({"before" : name.getFrame()});
+ if(min === 0)name.minimize();
+ }
}
}
}
@@ -1117,7 +1210,7 @@
for(var i = 0; i != this.__containers__.length; ++i){
for(var j = 0; j != this.__containers__[i].length; ++j){
for(var k = 0; k != this.__containers__[i][j].__frames__.length; ++k){
- if(this.__containers__[i][j].__frames__[k].isUsed() === true){
+ if(this.__containers__[i][j].__frames__[k].isUsed() === true && this.__containers__[i][j].__frames__[k].isEmpty() === false){
values.push(this.__containers__[i][j].__frames__[k].getContent());
}
}
@@ -1135,7 +1228,7 @@
for(var i = 0; i != this.__containers__.length; ++i){
for(var j = 0; j != this.__containers__[i].length; ++j){
for(var k = 0; k != this.__containers__[i][j].__frames__.length; ++k){
- if(this.__containers__[i][j].__frames__[k].isUsed() === true){
+ if(this.__containers__[i][j].__frames__[k].isUsed() === true && this.__containers__[i][j].__frames__[k].isEmpty() === false){
str += this.__containers__[i][j].__frames__[k].toJSON() + ",";
}
}
@@ -1150,8 +1243,97 @@
}
},
"isValid" : function(){
- // TODO: check the validity of this frame with the passed constraints and return a boolean value + isValid() of all names
- return true;
+ var ret = true;
+ var errorStr = "";
+
+ // --- checks if there are any constraints
+ if((!this.__constraints__ || this.__constraints__.length === 0) && this.__containers__.length !== 0){
+ var nameTypes = new Array();
+ for(var i = 0; i !== this.__containers__.length; ++i){
+ for(var j = 0; j !== this.__containers__[i].length; ++j){
+ for(var k = 0; k !== this.__containers__[i][j].__frames__.length; ++k){
+ this.__containers__[i][j].__frames__[k].hideError();
+ if(this.__containers__[i][j].__frames__[k].isUsed() === true){
+ this.__containers__[i][j].__frames__[k].showError("No constraints found for this name!");
+ }
+ }
+ }
+ }
+ return false;
+ }
+ else if(!this.__constraints__ || this.__constraints__.length === 0) return true;
+
+ // --- summarizes all names
+ var allNames = new Array();
+ for(var i = 0; i !== this.__containers__.length; ++i){
+ for(var j = 0; j !== this.__containers__[i].length; ++j){
+ for(var k = 0; k !== this.__containers__[i][j].__frames__.length; ++k){
+ this.__containers__[i][j].__frames__[k].hideError();
+ if(this.__containers__[i][j].__frames__[k].isUsed() === true && this.__containers__[i][j].__frames__[k].isEmpty() === false){
+ allNames.push(this.__containers__[i][j].__frames__[k]);
+ }
+ }
+ }
+ }
+
+ // --- checks every constraint and the existing names corresponding to the constraint
+ for(var i = 0; i !== this.__constraints__.length; ++i){
+ var currentConstraintTypes = new Array();
+ for(var j = 0; j !== this.__constraints__[i].nametypescopes.length; ++j){
+ currentConstraintTypes = currentConstraintTypes.concat(this.__constraints__[i].nametypescopes[j].nameType);
+ }
+ currentConstraintTypes = currentConstraintTypes.uniq();
+
+ // --- collects all names to the current constraint
+ var currentNames = new Array();
+ for(var j = 0; j !== allNames.length; ++j){
+ var type = allNames[j].getContent().type;
+ if(type && currentConstraintTypes.indexOf(type[0]) !== -1) currentNames.push(allNames[j]);
+
+ }
+ // --- removes all current found names from "allNames"
+ for(var j = 0; j !== currentNames.length; ++j) allNames = allNames.without(currentNames[j]);
+ // --- removes empty names (for constraints that have a subset of regexp)
+
+ // --- checks the regExp, card-min and card-max for the found types
+ var satisfiedNames = new Array();
+ for(var j = 0; j !== this.__constraints__[i].constraints.length; ++j){
+ var regexp = new RegExp(this.__constraints__[i].constraints[j].regexp);
+ var cardMin = parseInt(this.__constraints__[i].constraints[j].cardMin);
+ var cardMax = this.__constraints__[i].constraints[j].cardMax === "MAX_INT" ? "*" : parseInt(this.__constraints__[i].constraints[j].cardMax);
+ var matchedNames = 0;
+ for(var k = 0; k !== currentNames.length; ++k){
+ if(regexp.match(currentNames[k].getContent().value) === true){
+ ++matchedNames;
+ satisfiedNames.push(currentNames[k]);
+ }
+ }
+ if(matchedNames < cardMin){
+ ret = false;
+ if(errorStr.length !== 0) errorStr += "<br/><br/>";
+ errorStr += "card-min of the constraint regexp: \"" + this.__constraints__[i].constraints[j].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " for the nametype \"" + currentConstraintTypes + " is not satisfied (" + matchedNames + ")!";
+ }
+ if(cardMax !== "*" && matchedNames > cardMax){
+ ret = false;
+ if(errorStr.length !== 0) errorStr += "<br/><br/>";
+ errorStr += "card-max of the constraint regexp: \"" + this.__constraints__[i].constraints[j].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " for the nametype \"" + currentConstraintTypes + " is not satisfied (" + matchedNames + ")!";
+ }
+ }
+
+ // --- checks if there are names which wasn't checked --> bad value
+ satisfiedNames = satisfiedNames.uniq();
+ for(var j = 0; j !== satisfiedNames.length; ++j)currentNames = currentNames.without(satisfiedNames[j]);
+ if(currentNames.length !== 0){
+ ret = false;
+ for(var j = 0; j !== currentNames.length; ++j)
+ currentNames[j].showError("This name does not satisfie any constraint!");
+ }
+ }
+
+ // --- all names are valid -> hide the error-div-element
+ if(ret === true) this.hideError();
+ else this.showError(errorStr);
+ return ret;
}});
@@ -1164,6 +1346,7 @@
this.__table__ = new Element("table", {"class" : CLASSES.occurrenceFrame()});
this.__frame__.insert({"top" : this.__table__});
this.__max__ = max;
+ this.__constraint__ = constraint;
this.__owner__ = owner;
this.__dblClickHandler__ = dblClickHandler;
@@ -1253,9 +1436,14 @@
return "null";
}
},
+ "isEmpty" : function(){
+ return this.__value__.value.length === 0;
+ },
"isValid" : function(){
- // TODO: check the content and the constraints
- return true;
+ var regexp = new RegExp(this.__constraint__.regexp);
+ // TODO: validate the data via the given datatype
+ // TODO: validate the uniqeuoccurrence-constraint
+ return regexp.match(this.__value__.value);
},
"minimize" : function(){
var trs = this.__table__.select("tr");
@@ -1265,6 +1453,7 @@
}
},
"disable" : function(){
+ this.hideError();
this.__itemIdentity__.disable();
this.__type__.__frames__[0].disable();
this.__scope__.disable();
@@ -1295,6 +1484,7 @@
$super();
this.__containers__ = new Array();
this.__frame__.writeAttribute({"class" : CLASSES.occurrenceContainer()});
+ this.__constraints__ = constraints;
try{
if((!contents || contents.length === 0) && constraints && constraints.length > 0){
@@ -1310,12 +1500,12 @@
if(min === 0) dblClickHandler = dblClickHandlerF;
var title = "min: " + min + " max: " + max + " regular expression: " + regexp;
- var occurrence = new OccurrenceC("", constraints[i].occurrenceTypes, constraints[i].constraints[j],
- constraints[i].uniqueConstraints, this.__containers__[i][j],
- min === 0 ? 1 : min, max === "*" ? -1 : max, title, dblClickHandler);
- if(min === 0) occurrence.disable();
- this.__error__.insert({"before" : occurrence.getFrame()});
- if(min === 0)occurrence.minimize();
+ for(var k = 0; k !== (min === 0 ? 1 : min); ++k){
+ var occurrence = new OccurrenceC("", constraints[i].occurrenceTypes, constraints[i].constraints[j], constraints[i].uniqueConstraints, this.__containers__[i][j], min === 0 ? 1 : min, max === "*" ? -1 : max, title, dblClickHandler);
+ if(min === 0) occurrence.disable();
+ this.__error__.insert({"before" : occurrence.getFrame()});
+ if(min === 0)occurrence.minimize();
+ }
}
}
}
@@ -1329,8 +1519,97 @@
}
},
"isValid" : function(){
- // TODO: implement this method
- return true;
+ var ret = true;
+ var errorStr = "";
+
+ // --- checks if there are any constraints
+ if((!this.__constraints__ || this.__constraints__.length === 0) && this.__containers__.length !== 0){
+ for(var i = 0; i !== this.__containers__.length; ++i){
+ for(var j = 0; j !== this.__containers__[i].length; ++j){
+ for(var k = 0; k !== this.__containers__[i][j].__frames__.length; ++k){
+ this.__containers__[i][j].__frames__[k].hideError();
+ if(this.__containers__[i][j].__frames__[k].isUsed() === true){
+ var type = this.__containers__[i][j].__frames__[k].showError("No constraints found for this occurrence!");
+ }
+ }
+ }
+ }
+ return false;
+ }
+ else if(!this.__constraints__ || this.__constraints__.length === 0) return true;
+
+ // --- summarizes all occurrences
+ var allOccurrences = new Array();
+ for(var i = 0; i !== this.__containers__.length; ++i){
+ for(var j = 0; j !== this.__containers__[i].length; ++j){
+ for(var k = 0; k !== this.__containers__[i][j].__frames__.length; ++k){
+ if(this.__containers__[i][j].__frames__[k].isUsed() === true && this.__containers__[i][j].__frames__[k].isEmpty() === false){
+ allOccurrences.push(this.__containers__[i][j].__frames__[k]);
+ }
+ this.__containers__[i][j].__frames__[k].hideError();
+ }
+ }
+ }
+
+ // --- checks every constraint and the existing occurrences corresponding to the current constraint
+ for(var i = 0; i !== this.__constraints__.length; ++i){
+ var currentConstraintTypes = new Array();
+ for(var j = 0; j !== this.__constraints__[i].occurrenceTypes.length; ++j){
+ currentConstraintTypes = currentConstraintTypes.concat(this.__constraints__[i].occurrenceTypes[j].occurrenceType);
+ }
+ currentConstraintTypes = currentConstraintTypes.uniq();
+
+ // --- collects all occurrences to the current constraint
+ var currentOccurrences = new Array();
+ for(var j = 0; j !== allOccurrences.length; ++j){
+ var type = allOccurrences[j].getContent().type;
+ if(type && currentConstraintTypes.indexOf(type[0]) !== -1) currentOccurrences.push(allOccurrences[j]);
+ }
+ // --- removes all current found occurrences from "allOccurrences"
+ for(var j = 0; j !== currentOccurrences.length; ++j) allOccurrences = allOccurrences.without(currentOccurrences[j]);
+ // --- checks the regExp, card-min and card-max for the found types
+ var satisfiedOccurrences = new Array();
+ for(var j = 0; j !== this.__constraints__[i].constraints.length; ++j){
+ var regexp = new RegExp(this.__constraints__[i].constraints[j].regexp);
+ var cardMin = parseInt(this.__constraints__[i].constraints[j].cardMin);
+ var cardMax = this.__constraints__[i].constraints[j].cardMax === "MAX_INT" ? "*" : parseInt(this.__constraints__[i].constraints[j].cardMax);
+ var matchedOccurrences = 0;
+ for(var k = 0; k !== currentOccurrences.length; ++k){
+ var value = currentOccurrences[k].getContent().resourceRef;
+ if(!value) value = currentOccurrences[k].getContent().resourceData.value;
+ if(regexp.match(value) === true){
+ ++matchedOccurrences;
+ satisfiedOccurrences.push(currentOccurrences[k]);
+ }
+ }
+ // TODO: check the unique-occurrence
+ // TODO: check the occurrence's datatype and its content
+ if(matchedOccurrences < cardMin){
+ ret = false;
+ if(errorStr.length !== 0) errorStr += "<br/><br/>";
+ errorStr += "card-min of the constraint regexp: \"" + this.__constraints__[i].constraints[j].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " for the occurrencetype \"" + currentConstraintTypes + " is not satisfied (" + matchedOccurrences + ")!";
+ }
+ if(cardMax !== "*" && matchedOccurrences > cardMax){
+ ret = false;
+ if(errorStr.length !== 0) errorStr += "<br/><br/>";
+ errorStr += "card-max of the constraint regexp: \"" + this.__constraints__[i].constraints[j].regexp + "\" card-min: " + cardMin + " card-max: " + cardMax + " for the occurrencetype \"" + currentConstraintTypes + " is not satisfied (" + matchedOccurrences + ")!";
+ }
+ }
+
+ // --- checks if there are any occurrences which wasn't checked --> bad value
+ satisfiedOccurrences = satisfiedOccurrences.uniq();
+ for(var j = 0; j !== satisfiedOccurrences.length; ++j)
+ currentOccurrences = currentOccurrences.without(satisfiedOccurrences[j]);
+ if(currentOccurrences.length !== 0){
+ ret = false;
+ for(var j = 0; j !== currentOccurrences.length; ++j)
+ currentOccurrences[j].showError("This occurrence does not satisfie any constraint!");
+ }
+ }
+
+ if(ret === true) this.hideError();
+ else this.showError(errorStr);
+ return ret;
},
"getContent" : function(){
var values = new Array();
@@ -1377,6 +1656,7 @@
$super();
this.__minimized__ = false;
this.__instanceOfs__ = (!instanceOfs || instanceOfs.length === 0 ? null : instanceOfs);
+
try{
this.__frame__ .writeAttribute({"class" : CLASSES.topicFrame()});
this.__table__ = new Element("table", {"class" : CLASSES.topicFrame()});
@@ -1427,10 +1707,6 @@
alert("From TopciC(): " + err);
}
},
- "isValid" : function(){
- // TODO: implement
- return true;
- },
"getContent" : function(){
try{
return {"id" : this.__topicid__.__frames__[0].getContent().strip(),
@@ -1476,6 +1752,24 @@
"hasPsi" : function(){
return this.__subjectIdentifier__.getContent(true, true).length !== 0;
},
+ "isValid" : function(){
+ try{
+ var ret = true;
+ if(this.__topicid__.__frames__[0].getContent().strip().length === 0){
+ ret = false;
+ this.__topicid__.__frames__[0].showError("The topic must contain a topic ID!");
+ }
+ else {
+ this.__topicid__.__frames__[0].hideError();
+ }
+
+ if(this.__subjectLocator__.isValid() === false) ret = false;
+ if(this.__subjectIdentifier__.isValid() === false) ret = false;
+ if(this.__name__.isValid() === false) ret = false;
+ if(this.__occurrence__.isValid() === false) ret = false;
+ }catch(err){ alert("err: " + err); }
+ return ret;
+ },
"getReferencedTopics" : function(){
var referencedTopics = new Array();
var names = this.getContent().names;
@@ -1682,13 +1976,11 @@
return "null";
},
- "isValid" : function(){
- return this.getType().length !== 0 && this.getPlayer().length !== 0;
- },
"isUsed" : function(){
return !this.__disabled__;
},
"disable" : function(){
+ this.hideError();
this.__itemIdentity__.disable();
this.__type__.__frames__[0].disable();
this.__player__.__frames__[0].disable();
@@ -1712,9 +2004,11 @@
this.__frame__.writeAttribute({"class" : CLASSES.roleContainer()});
this.__arContainer__ = new Object();
this.__orContainer__ = new Object();
+ this.__associationRoleConstraints__ = associationRoleConstraints;
this.__otherRoleConstraints__ = otherRoleConstraints;
this.__rolePlayerConstraints__ = rolePlayerConstraints;
this.__parentElem__ = parent;
+
try{
if((!contents || contents.length === 0) && associationRoleConstraints){
this.resetValues(associationRoleConstraints, rolePlayerConstraints, otherRoleConstraints);
@@ -2226,6 +2520,7 @@
return roles.substring(0, roles.length - 1) + "]";
},
"disable" : function(){
+ this.hideError();
if(this.__orContainer__.__frames__){
for(var i = 0; i !== this.__orContainer__.__frames__.length; ++i) this.__orContainer__.__frames__[i].disable();
}
@@ -2244,8 +2539,135 @@
this.__disable__ = false;
},
"isValid" : function(){
- // TODO: implement
- return true;
+ var ret = true;
+ var errorStr = "";
+
+ var arcs = this.__associationRoleConstraints__;
+ var orcs = this.__otherRoleConstraints__;
+ var rpcs = this.__rolePlayerConstraints__;
+
+ // --- checks if there exist any constraints
+ if(!arcs || arcs.length === 0){
+ this.showError("No association-constraints found for this association!");
+ return false;
+ }
+
+ if(!rpcs || rpcs.length === 0){
+ this.showError("No roleplayer-constraints found for this association!");
+ return false;
+ }
+
+ // --- collects all used roles depending on associationrole-constraints
+ var allAroles = new Array();
+ var allAroles2 = new Array();
+ for(var i = 0; this.__arContainer__.__frames__ && i !== this.__arContainer__.__frames__.length; ++i){
+ this.__arContainer__.__frames__[i].hideError();
+ if(this.__arContainer__.__frames__[i].isUsed() === true){
+ allAroles.push(this.__arContainer__.__frames__[i]);
+ allAroles2.push(this.__arContainer__.__frames__[i]);
+ }
+ }
+
+ // --- collects all used roles depending on otherrole-constraints
+ var allOroles = new Array();
+ for(var i = 0; i !== this.__orContainer__.__frames__.length; ++i){
+ this.__orContainer__.__frames__[i].hideError();
+ if(this.__orContainer__.__frames__[i].isUsed() === true)
+ allOroles.push(this.__orContainer__.__frames__[i]);
+ }
+
+ // --- checks all associationrole-constraints
+ var checkedRoles = new Array();
+ for(var i = 0; i !== arcs.length; ++i){
+ var currentRoles = new Array();
+ var rType = arcs[i].roleType.flatten();
+ var cardMin = parseInt(arcs[i].cardMin);
+ var cardMax = arcs[i].cardMax === "MAX_INT" ? "*" : parseInt(arcs[i].cardMax);
+
+ // --- collects all roles for the current constraint
+ for(var j = 0; j !== allAroles.length; ++j){
+ if(rType.indexOf(allAroles[j].getType()) !== -1) currentRoles.push(allAroles[j]);
+ }
+ allAroles = allAroles.uniq();
+
+ if(cardMin > currentRoles.length){
+ ret = false;
+ if(errorStr.length !== 0) errorStr += "<br/><br/>";
+ errorStr += "card-min of the associationrole-constraint card-min: " + cardMin + " card-max: " + cardMax + " for the roletype \"" + rType + " is not satisfied (" + currentRoles.length + ")!";
+ }
+ if(cardMax !== "*" && cardMax < currentRoles.length){
+ ret = false;
+ if(errorStr.length !== 0) errorStr += "<br/><br/>";
+ errorStr += "card-max of the associationrole-constraint card-min: " + cardMin + " card-max: " + cardMax + " for the roletype \"" + rType + " is not satisfied (" + currentRoles.length + ")!";
+ }
+
+ // --- checks roleplayer-constraints for the found roles
+ var currentRpcs = getRolePlayerConstraintsForRole(rType, rpcs);
+ if(currentRpcs.length === 0){
+ ret = false;
+ for(var j = 0; j !== currentRoles.length; ++j) currentRoles[j].showError("This role does not satisfie any roleplayer-constraint!");
+ }
+ for(var j = 0; j !== currentRpcs.length; ++j){
+ var players = currentRpcs[i].players;
+ var pType = currentRpcs[i].playerType.flatten();
+ cardMin = parseInt(currentRpcs[i].cardMin);
+ cardMax = currentRpcs[i].cardMax === "MAX_INT" ? "*" : parseInt(currentRpcs[i].cardMax);
+ var foundRoles = this.getExistingRoles(rType, players, currentRoles);
+ if(cardMin > foundRoles.length){
+ ret = false;
+ if(errorStr.length !== 0) errorStr += "<br/><br/>";
+ errorStr += "card-min of the roleplayer-constraint card-min: " + cardMin + " card-max: " + cardMax + " for the roletype \"" + rType + " and the playertype \"" + pType + "\" is not satisfied (" + foundRoles.length + ")!";
+ }
+ if(cardMax !== "*" && cardMax < foundRoles.length){
+ ret = false;
+ if(errorStr.length !== 0) errorStr += "<br/><br/>";
+ errorStr += "card-max of the roleplayer-constraint card-min: " + cardMin + " card-max: " + cardMax + " for the roletype \"" + rType + " and the playertype \"" + pType + "\" is not satisfied (" + foundRoles.length + ")!";
+ }
+ // --- marks all found roles from "allAroles"
+ for(var k = 0; k !== foundRoles.length; ++k) checkedRoles.push(foundRoles[k]);
+ }
+ }
+
+ // --- checks roles that does not belong to any constraint
+ for(var i = 0; i !== checkedRoles.length; ++i) allAroles = allAroles.without(checkedRoles[i]);
+
+ if(allAroles.length !== 0){
+ for(var i = 0; i !== allAroles.length; ++i) allAroles[i].showError("This role does not satisfie any associationrole- or roleplayer-constraints!");
+ }
+
+ // --- checks otherrole-constraints
+ // --- collects all neede otherrole-constraints
+ var usedOrcs = new Array();
+ allAroles = allAroles2;
+ for(var i = 0; i !== allAroles.length; ++i){
+ usedOrcs = usedOrcs.concat(getOtherRoleConstraintsForRole(new Array(allAroles[i].getType()), new Array(allAroles[i].getPlayer()), orcs));
+ }
+
+ checkedRole = new Array();
+ for(var i = 0; i !== usedOrcs.length; ++i){
+ var players = usedOrcs[i].otherPlayers;
+ var pType = usedOrcs[i].otherPlayerType;
+ var rType = usedOrcs[i].otherRoleType;
+ var cardMin = parseInt(usedOrcs[i].cardMin);
+ var cardMax = usedOrcs[i].cardMax === "MAX_INT" ? "*" : parseInt(usedOrcs[i].cardMax);
+ var foundRoles = this.getExistingRoles(rType, players, allOroles);
+ checkedRoles = checkedRoles.concat(foundRoles);
+ if(cardMin > foundRoles.length){
+ ret = false;
+ if(errorStr.length !== 0) errorStr += "<br/><br/>";
+ errorStr += "card-min of the otherrole-constraint card-min: " + cardMin + " card-max: " + cardMax + " for the roletype \"" + rType + " and the playertype \"" + pType + "\" is not satisfied (" + foundRoles.length + ")!";
+ }
+ if(cardMax !== "*" && cardMax < foundRoles.length){
+ ret = false;
+ if(errorStr.length !== 0) errorStr += "<br/><br/>";
+ errorStr += "card-max of the otherrole-constraint card-min: " + cardMin + " card-max: " + cardMax + " for the roletype \"" + rType + " and the playertype \"" + pType + "\" is not satisfied (" + foundRoles.length + ")!";
+ }
+ }
+
+
+ if(ret === false) this.showError(errorStr);
+ else this.hideError();
+ return ret;
}});
@@ -2255,12 +2677,13 @@
if(!owner) throw "From NameC(): owner must be set but is null";
if(!owner.__frames__) owner.__frames__ = new Array();
owner.__frames__.push(this);
-
+
this.__frame__.writeAttribute({"class" : CLASSES.associationFrame()});
this.__table__ = new Element("table", {"class" : CLASSES.associationFrame()});
this.__frame__.insert({"top" : this.__table__});
this.__constraints__ = constraints;
this.__contents__ = contents;
+ this.__constraints__ = constraints;
this.__owner__ = owner;
this.__dblClickHandler__ = dblClickHandlerF;
@@ -2357,10 +2780,10 @@
",\"roles\":" + this.__roles__.toJSON() + "}";
},
"isValid" : function(){
- // TODO: implement
- return true;
+ return this.__roles__.isValid();
},
"disable" : function(){
+ this.hideError();
this.__itemIdentity__.disable();
this.__roles__.disable();
this.__type__.__frames__[0].disable();
@@ -2394,7 +2817,6 @@
this.__frame__.insert({"top" : this.__table__});
this.__caption__ = new Element("caption", {"class" : CLASSES.clickable()}).update("Associations");
this.__table__.insert({"top" : this.__caption__})
-
this.__container__ = new Object();
for(var i = 0; contents && i != contents.length; ++i){
@@ -2443,8 +2865,13 @@
return associations.substring(0, associations.length - 1) + "]";
},
"isValid" : function(){
- // TODO: implement
- return true;
+ var ret = true;
+ for(var i = 0; i !== this.__container__.__frames__.length; ++i){
+ if(this.__container__.__frames__[i].isUsed() === true && this.__container__.__frames__[i].isValid() === false)
+ ret = false;
+ }
+
+ return ret;
},
"minimize" : function(){
var rows = this.__table__.select("tr." + CLASSES.associationFrame());
@@ -2483,7 +2910,7 @@
// --- Representation of a topic map if frame.
-var tmIdC = Class.create(ContainerC, {"initialize" : function($super, contents){
+var TmIdC = Class.create(ContainerC, {"initialize" : function($super, contents){
$super();
try{
this.__frame__.writeAttribute({"class" : CLASSES.itemIdentityFrame()});
@@ -2493,7 +2920,7 @@
this.__frame__.insert({"top" : this.__table__});
this.__caption__ = new Element("caption", {"class" : CLASSES.clickable()}).update("Topic Map ID");
this.__table__.update(this.__caption__);
- var value = contents && contents.length !== 0 ? contents[0] : "";
+ var value = contents && contents.length !== 0 ? decodeURI(contents[0]) : "";
this.__contentrow__ = new Element("input", {"type" : "text", "value" : value});
this.__tr__ = new Element("tr", {"class" : CLASSES.tmIdFrame()});
var td =new Element("td", {"class" : CLASSES.content()});
@@ -2515,13 +2942,20 @@
},
"getContent" : function(){
if(this.__contentrow__.value.strip().length === 0) return null;
- return new Array(this.__contentrow__.value.strip());
+ return new Array(encodeURI(this.__contentrow__.value.strip()));
},
"toJSON" : function(){
return (this.getContent() === null ? "null" : this.getContent().toJSON());
},
"isValid" : function(){
- return this.getContent() !== null;
+ if(this.getContent() !== null){
+ this.hideError();
+ return true;
+ }
+ else {
+ this.showError("Please enter a Topic Map ID!");
+ return false;
+ }
},
"minimize": function(){
if(this.__minimized__ === false) this.__tr__.hide();
1
0
Author: lgiessmann
Date: Tue Jun 16 08:17:10 2009
New Revision: 44
Log:
ajax-client: a fragment commit without validation is implemented; json-importer: to import a topic or a topicStub it is necessary to define a psi for this element - this is difference between the xtm-importer \(there must be one of the elements psi, itemidentity, subjectlocator defined\), because all topics are referenced via psis and not topicid\'s
Modified:
trunk/src/ajax/javascripts/create.js
trunk/src/ajax/javascripts/datamodel.js
trunk/src/ajax/javascripts/requests.js
trunk/src/json/json_importer.lisp
Modified: trunk/src/ajax/javascripts/create.js
==============================================================================
--- trunk/src/ajax/javascripts/create.js (original)
+++ trunk/src/ajax/javascripts/create.js Tue Jun 16 08:17:10 2009
@@ -36,6 +36,11 @@
items[i].remove();
}
+ items = $$("li." + CLASSES.tmIdFrame());
+ for(var i = 0; i !== items.length; ++i){
+ items[i].remove();
+ }
+
items = $$("li." + CLASSES.commitButton());
for(var i = 0; i !== items.length; ++i){
items[i].remove();
@@ -49,10 +54,17 @@
var liT = new Element("li", {"class" : CLASSES.topicFrame()}).update(topic.getFrame());
context.insert({"after" : liT});
- addTopicAsPlayer((constraints ? constraints.associationsConstraints : null), topic.getContent().instanceOfs);
- var associations = new AssociationContainerC(null, (constraints ? constraints.associationsConstraints : null));
- var liA = new Element("li", {"class" : CLASSES.associationContainer()}).update(associations.getFrame());
- liT.insert({"after" : liA});
+ var liA = null;
+ var associations = null;
+ if(constraints && constraints.associationsConstraints && constraints.associationsConstraints.length !== 0){
+ addTopicAsPlayer((constraints ? constraints.associationsConstraints : null), topic.getContent().instanceOfs);
+ associations = new AssociationContainerC(null, (constraints ? constraints.associationsConstraints : null));
+ liA = new Element("li", {"class" : CLASSES.associationContainer()}).update(associations.getFrame());
+ liT.insert({"after" : liA});
+ }
+ else {
+ liA = liT;
+ }
var tmId = new tmIdC(null);
var liTm = new Element("li", {"class" : CLASSES.tmIdFrame()}).update(tmId.getFrame());
@@ -60,10 +72,12 @@
var commitButton = new Element("input", {"type" : "button", "value" : "commit fragment", "style" : "float: right; margin-top: -10px;"})
commitButton.observe("click", function(event){
- try{
var tPsis = topic.getContent().subjectIdentifiers;
- var referencedTopics = topic.getReferencedTopics().concat(associations.getReferencedTopics()).without(CURRENT_TOPIC).uniq();
-
+ var referencedTopics = topic.getReferencedTopics();
+ if(associations){
+ referencedTopics = referencedTopics.concat(associations.getReferencedTopics()).without(CURRENT_TOPIC).uniq();
+ }
+
function onSuccessHandler(topicStubs){
var tsStr = "null";
if(topicStubs && topicStubs.length !== 0){
@@ -76,19 +90,18 @@
}
var jTopic = "\"topic\":" + topic.toJSON();
var jTopicStubs = "\"topicStubs\":" + tsStr;
- var jAssociations = "\"associations\":" + associations.toJSON().gsub(CURRENT_TOPIC_ESCAPED, tPsis)
+ var jAssociations = "\"associations\":" + (associations ? associations.toJSON().gsub(CURRENT_TOPIC_ESCAPED, tPsis) : "null");
var jTmId = "\"tmIds\":" + tmId.toJSON();
var json = "{" + jTopic + "," + jTopicStubs + "," + jAssociations + "," + jTmId + "}";
- alert(json);
+ commitFragment(json, function(xhr){ alert("The fragment was committed succesfully!"); }, null);
}
-
+
function onErrorHandler(){
- // --- currently there is not neede a special handling for errors
+ // --- currently there is not needed a special handling for errors
// --- occurred during this operation
}
-
+
getTopicStubs(referencedTopics, onSuccessHandler, onErrorHandler);
- }catch(err){ alert("test: " + err); }
});
var liCB = new Element("li", {"class" : CLASSES.commitButton()});
liCB.update(commitButton);
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Tue Jun 16 08:17:10 2009
@@ -650,6 +650,9 @@
catch(err){
return new Array();
}
+
+ for(var i = 0; i !== values.length; ++i)
+ values[i] = new Array(values[i]);
return values;
},
"disable" : function(){
@@ -1486,7 +1489,7 @@
var scopes = names[i].scopes;
if(scopes){
for(var j = 0; j !== scopes.length; ++j){
- if(referencedTopics.indexOf(scopes[j]) === -1) referencedTopics.push(scopes[j]);
+ if(referencedTopics.indexOf(scopes[j][0]) === -1) referencedTopics.push(scopes[j][0]);
}
}
}
@@ -1502,7 +1505,7 @@
var scopes = occurrences[i].scopes;
if(scopes){
for(var j = 0; j !== scopes.length; ++j){
- if(referencedTopics.indexOf(scopes[j]) === -1) referencedTopics.push(scopes[j]);
+ if(referencedTopics.indexOf(scopes[j][0]) === -1) referencedTopics.push(scopes[j][0]);
}
}
}
@@ -2461,7 +2464,7 @@
var scopes = associations[i].scopes;
if(scopes){
for(var j = 0; j !== scopes.length; ++j){
- if(referencedTopics.indexOf(scopes[j]) === -1) referencedTopics.push(scopes[j]);
+ if(referencedTopics.indexOf(scopes[j][0]) === -1) referencedTopics.push(scopes[j][0]);
}
}
var roles = associations[i].roles;
Modified: trunk/src/ajax/javascripts/requests.js
==============================================================================
--- trunk/src/ajax/javascripts/requests.js (original)
+++ trunk/src/ajax/javascripts/requests.js Tue Jun 16 08:17:10 2009
@@ -89,7 +89,7 @@
function checkRequests(){
var delta = 100;
neededTime += delta;
- if(delta > maxTimeout){
+ if(delta > maxTimeout && psis && psis.length !== 0){
alert("From getTopicStubs(): Please check your network-connection - the request timed out!!!");
onFailureHandler();
return;
@@ -105,4 +105,22 @@
catch(err){
alert("From getTopicStubs(): Could not request topicStubs information for: " + psis + "\n\n" + err);
}
+}
+
+
+function commitFragment(json, onSuccessHandler, onFailureHandler)
+{
+ if(!json || !onSuccessHandler) throw "From commitFragment(): json and onSuccessHandler must be set!";
+ try{
+ var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
+
+ new Ajax.Request(COMMIT_URL, {
+ "method" : "post",
+ "postBody" : json,
+ "onSuccess" : onSuccessHandler,
+ "onFailure" : onFailure});
+ }
+ catch(err){
+ alert("From commitFragment(): " + err);
+ }
}
\ No newline at end of file
Modified: trunk/src/json/json_importer.lisp
==============================================================================
--- trunk/src/json/json_importer.lisp (original)
+++ trunk/src/json/json_importer.lisp Tue Jun 16 08:17:10 2009
@@ -391,9 +391,8 @@
(t
(error "json-importer:get-topicStub-values-from-json-string:
bad item-specifier found in json-list"))))
- (unless (or itemIdentities subjectLocators subjectIdentifiers)
- (error "json-importer:get-topicStub-values-from-json-string: one of the elements
- itemIdentity, sbjectLocator or subjectIdentifier must be set"))
+ (unless subjectIdentifiers
+ (error "json-importer:get-topicStub-values-from-json-string: the element subjectIdentifiers mus be set!"))
(unless id
(error "json-importer:get-topic-valuesStub-from-json-string: the element id must be set"))
(list :id id
@@ -433,9 +432,8 @@
(t
(error "json-importer:get-topic-values-from-json-string:
bad item-specifier found in json-list ~a" (car j-elem)))))
- (unless (or itemIdentities subjectLocators subjectIdentifiers)
- (error "json-importer:get-topic-values-from-json-string: one of the elements
- itemIdentity, sbjectLocator or subjectIdentifier must be set"))
+ (unless subjectIdentifiers
+ (error "json-importer:get-topic-values-from-json-string: the element subjectIdentifiers must be set!"))
(unless id
(error "json-importer:get-topic-values-from-json-string: the element id must be set"))
(let ((names-list (map 'list #'get-name-values-from-json-list names))
1
0
Author: lgiessmann
Date: Tue Jun 16 06:52:20 2009
New Revision: 43
Log:
ajax-client: finalized the "toJSON()" methods of all needed classes - so it is possible to create a json-string of the users objects
Modified:
trunk/src/ajax/javascripts/constants.js
trunk/src/ajax/javascripts/create.js
trunk/src/ajax/javascripts/datamodel.js
Modified: trunk/src/ajax/javascripts/constants.js
==============================================================================
--- trunk/src/ajax/javascripts/constants.js (original)
+++ trunk/src/ajax/javascripts/constants.js Tue Jun 16 06:52:20 2009
@@ -76,6 +76,7 @@
"__spanDeselect__" : "deselect",
"__divFog__" : "fog",
"__inputCommitButton__" : "commitButton",
+ "__divTmIdFrame__" : "tmIdFrame",
"page" : function(){ return this.__divPage__; },
"subPage" : function(){ return this.__divSubPage__; },
@@ -115,5 +116,6 @@
"playerFrame" : function(){ return this.__divPlayerFrame__; },
"deselect" : function(){ return this.__spanDeselect__; },
"fog" : function(){ return this.__divFog__; },
- "commitButton" : function(){ return this.__inputCommitButton__; }
+ "commitButton" : function(){ return this.__inputCommitButton__; },
+ "tmIdFrame" : function(){ return this.__divTmIdFrame__; }
};
\ No newline at end of file
Modified: trunk/src/ajax/javascripts/create.js
==============================================================================
--- trunk/src/ajax/javascripts/create.js (original)
+++ trunk/src/ajax/javascripts/create.js Tue Jun 16 06:52:20 2009
@@ -50,10 +50,14 @@
context.insert({"after" : liT});
addTopicAsPlayer((constraints ? constraints.associationsConstraints : null), topic.getContent().instanceOfs);
- var associations = new AssociationContainerC(null, (constraints ? constraints.associationsConstraints : null), topic);
+ var associations = new AssociationContainerC(null, (constraints ? constraints.associationsConstraints : null));
var liA = new Element("li", {"class" : CLASSES.associationContainer()}).update(associations.getFrame());
liT.insert({"after" : liA});
+ var tmId = new tmIdC(null);
+ var liTm = new Element("li", {"class" : CLASSES.tmIdFrame()}).update(tmId.getFrame());
+ liA.insert({"after" : liTm});
+
var commitButton = new Element("input", {"type" : "button", "value" : "commit fragment", "style" : "float: right; margin-top: -10px;"})
commitButton.observe("click", function(event){
try{
@@ -61,16 +65,20 @@
var referencedTopics = topic.getReferencedTopics().concat(associations.getReferencedTopics()).without(CURRENT_TOPIC).uniq();
function onSuccessHandler(topicStubs){
- var str = "null";
+ var tsStr = "null";
if(topicStubs && topicStubs.length !== 0){
- str = "[";
+ tsStr = "[";
for(var i = 0; i !== topicStubs.length; ++i){
- str += topicStubs[i];
- if(i !== topicStubs.length - 1) str += ",";
+ tsStr += topicStubs[i];
+ if(i !== topicStubs.length - 1) tsStr += ",";
}
- str += "]";
+ tsStr += "]";
}
- var json = "{\"topic\":" + topic.toJSON() + ",\"topicStubs\":" + str + ",\"associations\":" + associations.toJSON().gsub(CURRENT_TOPIC_ESCAPED, tPsis) + ",\"tmIds\":" + "[\"myTM\"]}";
+ var jTopic = "\"topic\":" + topic.toJSON();
+ var jTopicStubs = "\"topicStubs\":" + tsStr;
+ var jAssociations = "\"associations\":" + associations.toJSON().gsub(CURRENT_TOPIC_ESCAPED, tPsis)
+ var jTmId = "\"tmIds\":" + tmId.toJSON();
+ var json = "{" + jTopic + "," + jTopicStubs + "," + jAssociations + "," + jTmId + "}";
alert(json);
}
@@ -84,7 +92,7 @@
});
var liCB = new Element("li", {"class" : CLASSES.commitButton()});
liCB.update(commitButton);
- liA.insert({"after" : liCB});
+ liTm.insert({"after" : liCB});
}
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Tue Jun 16 06:52:20 2009
@@ -2382,10 +2382,9 @@
// --- contains all fragment's associations depending on the main topic
-var AssociationContainerC = Class.create(ContainerC, {"initialize" : function($super, contents, constraints, mainTopic){
+var AssociationContainerC = Class.create(ContainerC, {"initialize" : function($super, contents, constraints){
$super();
this.__minimized__ = false;
- this.__mainTopic__ = mainTopic;
try{
this.__frame__ .writeAttribute({"class" : CLASSES.associationContainer()});
this.__table__ = new Element("table", {"class" : CLASSES.associationContainer()});
@@ -2480,45 +2479,53 @@
}});
+// --- Representation of a topic map if frame.
+var tmIdC = Class.create(ContainerC, {"initialize" : function($super, contents){
+ $super();
+ try{
+ this.__frame__.writeAttribute({"class" : CLASSES.itemIdentityFrame()});
+ this.__container__ = new Object();
+ this.__frame__.writeAttribute({"class" : CLASSES.tmIdFrame()});
+ this.__table__ = new Element("table", {"class" : CLASSES.tmIdFrame()});
+ this.__frame__.insert({"top" : this.__table__});
+ this.__caption__ = new Element("caption", {"class" : CLASSES.clickable()}).update("Topic Map ID");
+ this.__table__.update(this.__caption__);
+ var value = contents && contents.length !== 0 ? contents[0] : "";
+ this.__contentrow__ = new Element("input", {"type" : "text", "value" : value});
+ this.__tr__ = new Element("tr", {"class" : CLASSES.tmIdFrame()});
+ var td =new Element("td", {"class" : CLASSES.content()});
+ this.__tr__.update(td);
+ td.update(this.__contentrow__);
+ this.__table__.insert({"bottom" : this.__tr__});
+
+ this.__minimized__ = false;
+ function setMinimizeHandler(myself){
+ myself.__caption__.observe("click", function(event){
+ myself.minimize();
+ });
+ }
+ setMinimizeHandler(this);
+ }
+ catch(err){
+ alert("From tmIdC(): " + err);
+ }
+ },
+ "getContent" : function(){
+ if(this.__contentrow__.value.strip().length === 0) return null;
+ return new Array(this.__contentrow__.value.strip());
+ },
+ "toJSON" : function(){
+ return (this.getContent() === null ? "null" : this.getContent().toJSON());
+ },
+ "isValid" : function(){
+ return this.getContent() !== null;
+ },
+ "minimize": function(){
+ if(this.__minimized__ === false) this.__tr__.hide();
+ else this.__tr__.show();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ this.__minimized__ = !this.__minimized__;
+ }});
// --- A handler for the dblclick-event. So a frame can be disabled or enabled.
1
0