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 );
43 function cnBrowseNext() {
44 cnBrowseShowNext = true;
45 if( cnBrowseCache.next ) /* if we have it, show it */
46 cnBrowseClearNext(cnBrowseCache.next);
49 function cnBrowsePrev() {
50 cnBrowseShowPrev = true;
51 if( cnBrowseCache.prev )
52 cnBrowseClearPrev(cnBrowseCache.prev);
55 function cnBrowseGrabNext() {
56 var req = new Request( FETCH_CNBROWSE_NEXT,
57 'org_unit', getLocation(),
58 'depth', cnBrowseDepth,
59 'label', cnBrowseBottomCn,
60 'boundry_id', cnBrowseBottomId,
61 'page_size', MAX_CN );
62 req.callback( cnBrowseCacheMe );
63 req.request.next = true;
68 function cnBrowseGrabPrev() {
69 var req = new Request( FETCH_CNBROWSE_PREV,
70 'org_unit', getLocation(),
71 'depth', cnBrowseDepth,
72 'label', cnBrowseTopCn,
73 'boundry_id', cnBrowseTopId,
74 'page_size', MAX_CN );
75 req.callback( cnBrowseCacheMe );
76 req.request.prev = true;
80 function cnBrowseClearNext(list) {
81 cnBrowseCache.next = null;
82 cnBrowseShowNext = false;
86 function cnBrowseClearPrev(list) {
87 cnBrowseCache.prev = null;
88 cnBrowseShowPrev = false;
92 /* cache next and previous calls unless they are
94 function cnBrowseCacheMe(r) {
95 var list = r.getResultObject();
97 cnBrowseCache.next = list;
98 if( cnBrowseShowNext ) {
99 cnBrowseClearNext(list);
102 } else if( r.prev ) {
103 cnBrowseCache.prev = list;
104 if( cnBrowseShowPrev ) {
105 cnBrowseClearPrev(list);
111 function cnBrowseDraw( r ) {
112 var list = r.getResultObject();
120 function _cnBrowseDraw( list ) {
123 cnTbody = $('cn_tbody');
124 cnRowT = $('cn_browse_row');
125 cnTdT = cnRowT.removeChild($('cn_browse_td'));
126 cnTbody.removeChild(cnRowT);
128 removeChildren(cnTbody);
131 var currentRow = cnRowT.cloneNode(true);
132 cnTbody.appendChild(currentRow);
134 for( var idx in list ) {
137 var currentTd = cnTdT.cloneNode(true);
138 currentRow.appendChild(currentTd);
140 var td = cnTdT.cloneNode(true);
141 var label = list[idx][0];
142 var lib = list[idx][1];
143 var record = list[idx][2];
144 var id = list[idx][3];
146 if( idx == 0 ) { cnBrowseTopCn = label; cnBrowseTopId = id; }
147 cnBrowseBottomCn = label;
148 cnBrowseBottomId = id;
150 var cn_td = $n(currentTd, 'cn_browse_cn');
151 var lib_td = $n(currentTd, 'cn_browse_lib');
152 var title_td = $n(currentTd, 'cn_browse_title');
153 var author_td = $n(currentTd, 'cn_browse_author');
154 var pic_td = $n(currentTd, 'cn_browse_pic');
156 cn_td.appendChild(text(label));
157 lib_td.appendChild(text(findOrgUnit(lib).name()));
159 var req = new Request( FETCH_RMODS, record );
160 req.request.title_td = title_td;
161 req.request.author_td = author_td;
162 req.request.pic_td = pic_td;
163 req.callback( cnBrowseDrawTitle );
167 if( counter++ % 3 == 0 ) {
169 currentRow = cnRowT.cloneNode(true);
170 cnTbody.appendChild(currentRow);
177 function cnBrowseDrawTitle(r) {
178 var mods = r.getResultObject();
180 buildTitleDetailLink(mods, r.title_td);
181 buildSearchLink(STYPE_AUTHOR, mods.author(), r.author_td);
182 r.pic_td.setAttribute("src", buildISBNSrc(cleanISBN(mods.isbn())));
186 args[PARAM_OFFSET] = 0;
187 args[PARAM_RID] = mods.doc_id();
188 args[PARAM_MRID] = 0;
189 r.pic_td.parentNode.setAttribute("href", buildOPACLink(args));