Revision 4076
Added by berkley almost 16 years ago
util.js | ||
---|---|---|
88 | 88 |
//make sure the user is logged in. |
89 | 89 |
function checkLogin() |
90 | 90 |
{ |
91 |
var currentTab = getCookie("sms-current-tab"); |
|
92 |
|
|
91 | 93 |
if(getCookie("sms-login") == "true") |
92 | 94 |
{ |
93 | 95 |
setLoginHeader(true); |
94 | 96 |
showDatasets(); |
95 |
showSearchPane(); |
|
97 |
if(currentTab == null || currentTab == 'search') |
|
98 |
{ |
|
99 |
showSearchPane(); |
|
100 |
} |
|
101 |
else |
|
102 |
{ |
|
103 |
if(currentTab == 'browse') |
|
104 |
{ |
|
105 |
showBrowsePane(); |
|
106 |
} |
|
107 |
else if(currentTab == 'upload') |
|
108 |
{ |
|
109 |
showUploadPane(); |
|
110 |
} |
|
111 |
} |
|
96 | 112 |
} |
97 | 113 |
else |
98 | 114 |
{ |
... | ... | |
107 | 123 |
var url = '/sms/metacat?action=query&anyfield=' + searchval + '&returnfield=dataset/title&qformat=sms&pagesize=10&pagestart=0'; |
108 | 124 |
setCookie("sms-searchval", searchval); |
109 | 125 |
setCookie("sms-pagestart", 0); |
110 |
reloadSearchContent(url,'#innersearchresultdiv'); |
|
111 |
setCookie('sms-pagestart', 0); |
|
126 |
reloadSearchContent(url); |
|
112 | 127 |
} |
113 | 128 |
|
114 | 129 |
//show all of the datasets in metacat |
... | ... | |
119 | 134 |
{ |
120 | 135 |
searchval = '%25'; |
121 | 136 |
} |
122 |
var page = getCookie('sms-pagestart'); |
|
137 |
var currentTab = getCookie('sms-current-tab'); |
|
138 |
var page; |
|
139 |
if(currentTab == null) |
|
140 |
{ |
|
141 |
page = 0; |
|
142 |
} |
|
143 |
else if(currentTab == 'search' || currentTab == 'upload') |
|
144 |
{ |
|
145 |
page = getCookie('sms-search-pagestart'); |
|
146 |
} |
|
147 |
else |
|
148 |
{ |
|
149 |
page = getCookie('sms-browse-pagestart'); |
|
150 |
setCookie('sms-browse-content-loaded', 'true'); |
|
151 |
searchval = '%25'; |
|
152 |
} |
|
153 |
|
|
123 | 154 |
if(page) |
124 | 155 |
{ |
125 |
reloadSearchContent('/sms/metacat?action=query&anyfield=' + searchval + '&returnfield=dataset/title&qformat=sms&pagesize=10&pagestart=' + page, '#searchresultdiv');
|
|
156 |
reloadSearchContent('/sms/metacat?action=query&anyfield=' + searchval + '&returnfield=dataset/title&qformat=sms&pagesize=10&pagestart=' + page); |
|
126 | 157 |
} |
127 | 158 |
else |
128 | 159 |
{ |
129 |
reloadSearchContent('/sms/metacat?action=query&anyfield=' + searchval + '&returnfield=dataset/title&qformat=sms&pagesize=10&pagestart=0', '#searchresultdiv');
|
|
160 |
reloadSearchContent('/sms/metacat?action=query&anyfield=' + searchval + '&returnfield=dataset/title&qformat=sms&pagesize=10&pagestart=0'); |
|
130 | 161 |
} |
131 | 162 |
} |
132 | 163 |
|
133 | 164 |
//reload the search result table |
134 |
function reloadSearchContent(url, div)
|
|
165 |
function reloadSearchContent(url) |
|
135 | 166 |
{ |
167 |
var table; |
|
168 |
var div; |
|
136 | 169 |
var page = url.substring(url.indexOf('pagestart=') + 10, url.length); |
137 |
setCookie("sms-pagestart", page); |
|
138 |
$("#searchresulttable").load(url); |
|
170 |
var currentTab = getCookie('sms-current-tab'); |
|
171 |
if(currentTab == null || currentTab == 'search' || currentTab == 'upload') |
|
172 |
{ |
|
173 |
table = '#searchresulttable'; |
|
174 |
div = '#searchresultdiv' |
|
175 |
setCookie("sms-search-pagestart", page); |
|
176 |
} |
|
177 |
else if(currentTab == 'browse') |
|
178 |
{ |
|
179 |
table = '#browseresulttable'; |
|
180 |
div = '#browseresultdiv' |
|
181 |
setCookie("sms-browse-pagestart", page); |
|
182 |
} |
|
183 |
|
|
184 |
$(table).load(url); |
|
139 | 185 |
} |
140 | 186 |
|
141 | 187 |
//upload a file to metacat |
... | ... | |
275 | 321 |
//show the search tab |
276 | 322 |
function showSearchPane() |
277 | 323 |
{ |
324 |
setCookie('sms-current-tab', 'search'); |
|
278 | 325 |
//hide all, then slide down the search pane |
279 | 326 |
$('#uploaddiv').fadeOut("slow"); |
280 |
$('#searchresultdiv').fadeOut("slow");
|
|
327 |
$('#browseresultdiv').fadeOut("slow");
|
|
281 | 328 |
$('#searchdiv').fadeIn("slow"); |
282 | 329 |
switchTabs('search'); |
283 | 330 |
} |
... | ... | |
285 | 332 |
//show the upload tab |
286 | 333 |
function showUploadPane() |
287 | 334 |
{ |
335 |
setCookie('sms-current-tab', 'upload'); |
|
288 | 336 |
//hide all, then slide down the upload pane |
289 | 337 |
$('#searchdiv').fadeOut("slow"); |
290 |
$('#searchresultdiv').fadeOut("slow");
|
|
338 |
$('#browseresultdiv').fadeOut("slow");
|
|
291 | 339 |
$('#uploaddiv').fadeIn("slow"); |
292 | 340 |
$('#uploadetabimg').hide(); |
293 | 341 |
$('#uploadtabimgsel').show(); |
... | ... | |
297 | 345 |
//show the browse tab |
298 | 346 |
function showBrowsePane() |
299 | 347 |
{ |
348 |
setCookie('sms-current-tab', 'browse'); |
|
349 |
var contentLoaded = getCookie('sms-browse-content-loaded'); |
|
350 |
if(!contentLoaded) |
|
351 |
{ |
|
352 |
reloadSearchContent('/sms/metacat?action=query&anyfield=%25&returnfield=dataset/title&qformat=sms&pagesize=10&pagestart=0'); |
|
353 |
} |
|
300 | 354 |
//hide all, then slide down the browse pane |
301 | 355 |
$('#searchdiv').fadeOut("slow"); |
302 | 356 |
$('#uploaddiv').fadeOut("slow"); |
303 |
$('#searchresultdiv').fadeIn("slow");
|
|
357 |
$('#browseresultdiv').fadeIn("slow");
|
|
304 | 358 |
$('#browsetabimg').hide(); |
305 | 359 |
$('#browsetabimgsel').show(); |
306 | 360 |
switchTabs('browse'); |
Also available in: Unified diff
more improvements to the UI