7 var cnBrowseCache = {};
8 var cnBrowseShowNext = false;
9 var cnBrowseShowPrev = false;
12 if( findCurrentPage() == CNBROWSE ) {
13 attachEvt("common", "run", cnBrowseLoadSearch);
14 attachEvt( "common", "locationUpdated", cnBrowseResubmit );
17 function cnBrowseLoadSearch() {
18 unHideMe($('cn_browse'));
19 cnBrowseGo(getCallnumber(), getDepth());
22 function cnBrowseResubmit() {
24 args[PARAM_CN] = cnBrowseCurrent;
25 args[PARAM_DEPTH] = getNewSearchDepth();
26 args[PARAM_LOCATION] = getNewSearchLocation();
27 goTo(buildOPACLink(args));
30 function cnBrowseGo(cn, depth) {
31 if(depth == null) depth = getDepth();
32 cnBrowseDepth = depth;
34 var req = new Request( FETCH_CNBROWSE_TARGET,
35 'org_unit', getLocation(),
36 'depth', cnBrowseDepth,
37 'label', cnBrowseCurrent,
38 'page_size', MAX_CN );
39 req.callback( cnBrowseDraw );
42 var o = findOrgUnit(getLocation());
43 var d = findOrgDepth(o);
46 o = findOrgUnit(o.parent_ou());
49 appendClear($('cn_browse_where'), text(o.name()));
52 function cnBrowseNext() {
53 cnBrowseShowNext = true;
54 if( cnBrowseCache.next ) /* if we have it, show it */
55 cnBrowseClearNext(cnBrowseCache.next);
58 function cnBrowsePrev() {
59 cnBrowseShowPrev = true;
60 if( cnBrowseCache.prev )
61 cnBrowseClearPrev(cnBrowseCache.prev);
64 function cnBrowseGrabNext() {
65 var req = new Request( FETCH_CNBROWSE_NEXT,
66 'org_unit', getLocation(),
67 'depth', cnBrowseDepth,
68 'label', cnBrowseBottomCn,
69 'boundry_id', cnBrowseBottomId,
70 'page_size', MAX_CN );
71 req.callback( cnBrowseCacheMe );
72 req.request.next = true;
77 function cnBrowseGrabPrev() {
78 var req = new Request( FETCH_CNBROWSE_PREV,
79 'org_unit', getLocation(),
80 'depth', cnBrowseDepth,
81 'label', cnBrowseTopCn,
82 'boundry_id', cnBrowseTopId,
83 'page_size', MAX_CN );
84 req.callback( cnBrowseCacheMe );
85 req.request.prev = true;
89 function cnBrowseClearNext(list) {
90 cnBrowseCache.next = null;
91 cnBrowseShowNext = false;
95 function cnBrowseClearPrev(list) {
96 cnBrowseCache.prev = null;
97 cnBrowseShowPrev = false;
101 /* cache next and previous calls unless they are
102 needed immediately */
103 function cnBrowseCacheMe(r) {
104 var list = r.getResultObject();
106 cnBrowseCache.next = list;
107 if( cnBrowseShowNext ) {
108 cnBrowseClearNext(list);
111 } else if( r.prev ) {
112 cnBrowseCache.prev = list;
113 if( cnBrowseShowPrev ) {
114 cnBrowseClearPrev(list);
120 function cnBrowseDraw( r ) {
121 var list = r.getResultObject();
129 function _cnBrowseDraw( list ) {
132 cnTbody = $('cn_tbody');
133 cnRowT = $('cn_browse_row');
134 cnTdT = cnRowT.removeChild($('cn_browse_td'));
135 cnTbody.removeChild(cnRowT);
137 removeChildren(cnTbody);
140 var currentRow = cnRowT.cloneNode(true);
141 cnTbody.appendChild(currentRow);
143 for( var idx in list ) {
146 var currentTd = cnTdT.cloneNode(true);
147 currentRow.appendChild(currentTd);
149 var td = cnTdT.cloneNode(true);
150 var label = list[idx][0];
151 var lib = list[idx][1];
152 var record = list[idx][2];
153 var id = list[idx][3];
155 if( idx == 0 ) { cnBrowseTopCn = label; cnBrowseTopId = id; }
156 cnBrowseBottomCn = label;
157 cnBrowseBottomId = id;
159 var cn_td = $n(currentTd, 'cn_browse_cn');
160 var lib_td = $n(currentTd, 'cn_browse_lib');
161 var title_td = $n(currentTd, 'cn_browse_title');
162 var author_td = $n(currentTd, 'cn_browse_author');
163 var pic_td = $n(currentTd, 'cn_browse_pic');
165 cn_td.appendChild(text(label));
166 lib_td.appendChild(text(findOrgUnit(lib).name()));
168 var req = new Request( FETCH_RMODS, record );
169 req.request.title_td = title_td;
170 req.request.author_td = author_td;
171 req.request.pic_td = pic_td;
172 req.callback( cnBrowseDrawTitle );
176 if( counter++ % 3 == 0 ) {
178 currentRow = cnRowT.cloneNode(true);
179 cnTbody.appendChild(currentRow);
186 function cnBrowseDrawTitle(r) {
187 var mods = r.getResultObject();
189 buildTitleDetailLink(mods, r.title_td);
190 buildSearchLink(STYPE_AUTHOR, mods.author(), r.author_td);
191 r.pic_td.setAttribute("src", buildISBNSrc(cleanISBN(mods.isbn())));
195 args[PARAM_OFFSET] = 0;
196 args[PARAM_RID] = mods.doc_id();
197 args[PARAM_MRID] = 0;
198 r.pic_td.parentNode.setAttribute("href", buildOPACLink(args));