Author: jens Date: Fri Mar 2 20:43:35 2012 New Revision: 1296443 URL: http://svn.apache.org/viewvc?rev=1296443&view=rev Log: correct the getChildren() tables, improve output, add simple style sheet Added: chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/css/ chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/css/opencmis.css Modified: chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html Added: chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/css/opencmis.css URL: http://svn.apache.org/viewvc/chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/css/opencmis.css?rev=1296443&view=auto ============================================================================== --- chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/css/opencmis.css (added) +++ chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/css/opencmis.css Fri Mar 2 20:43:35 2012 @@ -0,0 +1,63 @@ +@CHARSET "UTF-8"; + +body { + font-family: Verdana, arial, sans-serif; + color: black; + font-size: 12px; +} + +h1 { + font-size: 24px; + line-height: normal; + font-weight: bold; + background-color: #f0f0f0; + color: #003366; + border-bottom: 1px solid #3c78b5; + padding: 2px; + margin: 4px 0px 4px 0px; +} + +h2 { + font-size: 18px; + line-height: normal; + font-weight: bold; + background-color: #f0f0f0; + border-bottom: 1px solid #3c78b5; + padding: 2px; + margin: 4px 0px 4px 0px; +} + +h3 { + font-size: 14px; + line-height: normal; + font-weight: bold; + background-color: #f0f0f0; + padding: 2px; + margin: 4px 0px 4px 0px; +} + +h4 { + font-size: 12px; + line-height: normal; + font-weight: bold; + background-color: #f0f0f0; + padding: 2px; + margin: 4px 0px 4px 0px; +} + +HR { + color: 3c78b5; + height: 1; +} + +th { + border: 1px solid #ccc; + padding: 2px 4px 2px 4px; + background: #f0f0f0; + text-align: center; +} + +td { + border: 1px solid #ccc; + padding: 3px 4px 3px 4px; +} Modified: chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html URL: http://svn.apache.org/viewvc/chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html?rev=1296443&r1=1296442&r2=1296443&view=diff ============================================================================== --- chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html (original) +++ chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html Fri Mar 2 20:43:35 2012 @@ -20,6 +20,7 @@ + Browser Binding Client @@ -35,14 +36,14 @@ var session = null; - function init1(connectionUrl, cbFct) { + function connectToRepo(connectionUrl, cbFct) { var factory = new CmisSessionFactory({ url : connectionUrl }); factory.getRepositories(cbFct); } - function init2(connectionUrl, repoId) { + function createSession(connectionUrl, repoId) { console.log("Initialzing session to " + connectionUrl); var factory = new CmisSessionFactory({ url : connectionUrl, @@ -60,31 +61,57 @@ }); } + function convertValue(value, type) { + if (type == 'string') { + if (value == '*') + return "'*'"; // confuses text() method + else + return value; + } else if (type == 'datetime') { + return new Date(value).toLocaleString(); + } else + return value.toString(); + + + } function createTable(children, baseType) { var row; var tbody; var tbl = $('').attr('id', 'childrenTable').attr('border', 1); - tbl.append($('').append(row = $(''))); + var propsToDisplay = []; + var propsToDisplayLabel = []; for (var child in children.objects) { if (baseType === children.objects[child].object.properties["cmis:baseTypeId"].value) { for (var prop in children.objects[child].object.properties) { - row.append($('').append(row = $(''))); + for (var propKey in propsToDisplay) { + row.append($('')); for (var child in children.objects) { + row = null; if (baseType === children.objects[child].object.properties["cmis:baseTypeId"].value) { + row = null; tbody.append(row = $('')); - for (var prop in children.objects[child].object.properties) { - var text = children.objects[child].object.properties[prop].value; - if (text == null) - text = "n/a"; - row.append($('
').text(children.objects[child].object.properties[prop].id)); + var propId = children.objects[child].object.properties[prop].id; + if ($.inArray(propId, propsToDisplay) < 0) { + propsToDisplay.push(propId); + propsToDisplayLabel.push(children.objects[child].object.properties[prop].displayName); + } } - break; } } + + tbl.append($('
').text(propsToDisplayLabel[propKey])); + } tbl.append(tbody = $('
').text(text)); - } + for (var propKey in propsToDisplay) { + var prop = children.objects[child].object.properties[propsToDisplay[propKey]]; + console.log ("add col: " + prop.value); + if (null != prop && null != prop.value) + row.append($('').text(convertValue(prop.value, prop.type))); + else + row.append($(''));//.text("")); + } } } @@ -138,7 +165,7 @@ $('#repositories').click(function() { var firstRepoId; - init1($("#reposfield").val(), function(repoInfos) { + connectToRepo($("#reposfield").val(), function(repoInfos) { console.log("getRepositories()"); var row; var tbl = $('').append($('').append($('
').text("Found repositories:"))) @@ -153,7 +180,7 @@ $("#repoidfield").attr('value', firstRepoId); $("#folderidfield").attr('value', repoInfos[firstRepoId].rootFolderId); - init2($("#reposfield").val(), "A1"); + createSession($("#reposfield").val(), "A1"); }); }); @@ -240,7 +267,12 @@

CMIS in Javascript

-

A simple test page how to use the browser binding in Javascript in a browser.

+

+ This is a simple test page demonstrating how to use the CMIS-browser binding from Javascript in a browser. + For getting started enter the URL referring to the browser binding endpoint of your server and press + the connect button. You then can trigger individual calls to the server by pressing the buttons on the + page. +