7 var cnBrowseCache = {};
8 var cnBrowseShowNext = false;
9 var cnBrowseShowPrev = false;
12 function cnBrowseGo(cn, depth) {
13 if(depth == null) depth = getDepth();
14 cnBrowseDepth = depth;
16 var req = new Request( FETCH_CNBROWSE_TARGET,
17 'org_unit', getLocation(),
18 'depth', cnBrowseDepth,
19 'label', cnBrowseCurrent,
20 'page_size', MAX_CN );
21 req.callback( cnBrowseDraw );
25 function cnBrowseNext() {
26 cnBrowseShowNext = true;
27 if( cnBrowseCache.next ) /* if we have it, show it */
28 cnBrowseClearNext(cnBrowseCache.next);
31 function cnBrowsePrev() {
32 cnBrowseShowPrev = true;
33 if( cnBrowseCache.prev )
34 cnBrowseClearPrev(cnBrowseCache.prev);
37 function cnBrowseGrabNext() {
38 var req = new Request( FETCH_CNBROWSE_NEXT,
39 'org_unit', getLocation(),
40 'depth', cnBrowseDepth,
41 'label', cnBrowseBottomCn,
42 'boundry_id', cnBrowseBottomId,
43 'page_size', MAX_CN );
44 req.callback( cnBrowseCacheMe );
45 req.request.next = true;
50 function cnBrowseGrabPrev() {
51 var req = new Request( FETCH_CNBROWSE_PREV,
52 'org_unit', getLocation(),
53 'depth', cnBrowseDepth,
54 'label', cnBrowseTopCn,
55 'boundry_id', cnBrowseTopId,
56 'page_size', MAX_CN );
57 req.callback( cnBrowseCacheMe );
58 req.request.prev = true;
62 function cnBrowseClearNext(list) {
63 cnBrowseCache.next = null;
64 cnBrowseShowNext = false;
68 function cnBrowseClearPrev(list) {
69 cnBrowseCache.prev = null;
70 cnBrowseShowPrev = false;
74 /* cache next and previous calls unless they are
76 function cnBrowseCacheMe(r) {
77 var list = r.getResultObject();
79 cnBrowseCache.next = list;
80 if( cnBrowseShowNext ) {
81 cnBrowseClearNext(list);
85 cnBrowseCache.prev = list;
86 if( cnBrowseShowPrev ) {
87 cnBrowseClearPrev(list);
93 function cnBrowseDraw( r ) {
94 var list = r.getResultObject();
102 function _cnBrowseDraw( list ) {
105 cnTbody = $('cn_tbody');
106 cnRowT = $('cn_browse_row');
107 cnTdT = cnRowT.removeChild($('cn_browse_td'));
108 cnTbody.removeChild(cnRowT);
110 removeChildren(cnTbody);
113 var currentRow = cnRowT.cloneNode(true);
114 cnTbody.appendChild(currentRow);
116 for( var idx in list ) {
119 var currentTd = cnTdT.cloneNode(true);
120 currentRow.appendChild(currentTd);
122 var td = cnTdT.cloneNode(true);
123 var label = list[idx][0];
124 var lib = list[idx][1];
125 var record = list[idx][2];
126 var id = list[idx][3];
129 if( label != cnBrowseCurrent ) {
130 removeCSSClass( td, 'cn_browse_home_cn' );
134 if( idx == 0 ) { cnBrowseTopCn = label; cnBrowseTopId = id; }
135 cnBrowseBottomCn = label;
136 cnBrowseBottomId = id;
138 var cn_td = $n(currentTd, 'cn_browse_cn');
139 var lib_td = $n(currentTd, 'cn_browse_lib');
140 var title_td = $n(currentTd, 'cn_browse_title');
141 var author_td = $n(currentTd, 'cn_browse_author');
142 var pic_td = $n(currentTd, 'cn_browse_pic');
144 cn_td.appendChild(text(label));
145 lib_td.appendChild(text(findOrgUnit(lib).name()));
147 var req = new Request( FETCH_RMODS, record );
148 req.request.title_td = title_td;
149 req.request.author_td = author_td;
150 req.request.pic_td = pic_td;
151 req.callback( cnBrowseDrawTitle );
155 if( counter++ % 3 == 0 ) {
157 currentRow = cnRowT.cloneNode(true);
158 cnTbody.appendChild(currentRow);
165 function cnBrowseDrawTitle(r) {
166 var mods = r.getResultObject();
167 buildTitleDetailLink(mods, r.title_td);
168 buildSearchLink(STYPE_AUTHOR, mods.author(), r.author_td);
169 r.pic_td.setAttribute("src", buildISBNSrc(cleanISBN(mods.isbn())));
173 args[PARAM_OFFSET] = 0;
174 args[PARAM_RID] = mods.doc_id();
175 args[PARAM_MRID] = 0;
176 r.pic_td.parentNode.setAttribute("href", buildOPACLink(args));