Initial dev repository
[kcls-web.git] / opac / skin / condense_js / js / container.js
diff --git a/opac/skin/condense_js/js/container.js b/opac/skin/condense_js/js/container.js
new file mode 100644 (file)
index 0000000..152bb1f
--- /dev/null
@@ -0,0 +1,67 @@
+\r
+function containerDoRequest( req, callback, args ) {\r
+\r
+       if( callback ) {\r
+               req.callback( callback );\r
+               req.request.args = args;\r
+               req.send();\r
+               return null;\r
+       }\r
+\r
+       req.send(true); \r
+       return req.result();\r
+}\r
+\r
+\r
+function containerFetchAll( callback, args ) {\r
+       var req = new Request( \r
+               FETCH_CONTAINERS, G.user.session, G.user.id(), 'biblio', 'bookbag' );\r
+       return containerDoRequest( req, callback, args );\r
+}\r
+\r
+function containerFlesh( id, callback, args ) {\r
+       var req = new Request( FLESH_CONTAINER, G.user.session, 'biblio', id );\r
+       return containerDoRequest( req, callback, args );\r
+}\r
+\r
+function containerDelete( id, callback, args ) {\r
+       var req = new Request( DELETE_CONTAINER, G.user.session, 'biblio', id );\r
+       return containerDoRequest(req, callback, args );\r
+}\r
+\r
+\r
+function containerCreate( name, pub, callback, args ) {\r
+\r
+       var container = new cbreb();\r
+       container.btype('bookbag');\r
+       container.owner( G.user.id() );\r
+       container.name( name );\r
+       if(pub) container.pub('t');\r
+       else container.pub('f');\r
+\r
+       var req = new Request( \r
+               CREATE_CONTAINER, G.user.session, 'biblio', container );\r
+       return containerDoRequest( req, callback, args );\r
+}\r
+\r
+function containerUpdate( container, callback, args ) {\r
+       var req = new Request(UPDATE_CONTAINER, G.user.session, 'biblio', container);\r
+       return containerDoRequest(req, callback, args);\r
+}\r
+\r
+function containerCreateItem( containerId, target, callback, args ) {\r
+\r
+       var item = new cbrebi();\r
+       item.target_biblio_record_entry(target);\r
+       item.bucket(containerId);\r
+\r
+       var req = new Request( CREATE_CONTAINER_ITEM, \r
+               G.user.session, 'biblio', item );\r
+\r
+       return containerDoRequest( req, callback, args );\r
+}\r
+\r
+function containerRemoveItem( id, callback, args ) {\r
+       var req = new Request( DELETE_CONTAINER_ITEM, G.user.session, 'biblio', id );\r
+       return containerDoRequest( req, callback, args );\r
+}\r