Project

General

Profile

« Previous | Next » 

Revision 4046

Added by berkley about 16 years ago

added a tabbed interface

View differences:

lib/style/skins/sms/util.js
1
var fullDocId;
2

  
3
//log the user in 
1 4
function login()
2 5
{
3 6
  var user = document.getElementById("un").value;
......
27 30
    }, "XML");
28 31
}
29 32

  
33
//update the users status on the page
30 34
function updateStatus()
31 35
{
32 36
  var url = window.location.href;
......
49 53
  
50 54
}
51 55

  
56
//set the header when the user logs in
52 57
function setLoginHeader(loggedin)
53 58
{
54 59
  if(loggedin)
......
60 65
    slideUp("#loginformdiv");
61 66
    $('#maindiv').css("display", "block");
62 67
    $('#bottomimg').css("bottom", "0px");
63
    $.get("metacat", {action:"getlastdocid", scope:"sms"}, 
64
      function(data)
65
      {
66
        var docid = data.substring(data.indexOf("<docid>") + 7, data.indexOf("</docid>"));
67
        var nextid;
68
        if(docid == 'null')
69
        {
70
          nextid = "sms.1.1";
71
        }
72
        else
73
        {
74
          nextid = docid.substring(docid.indexOf(".") + 1, docid.lastIndexOf("."));
75
          nextid++;
76
          nextid = "sms." + nextid + ".1"; 
77
        }
78
        $('#docidtextfield').val(nextid); 
79
      }, 
80
      "XML");
68
    getId();
81 69
  }
82 70
  else
83 71
  {
......
89 77
  }
90 78
}
91 79

  
80
//log the user out.
92 81
function logout()
93 82
{
94 83
  $.get("metacat", {action:"logout", qformat:"xml"});
......
96 85
  setCookie("sms-login", false);
97 86
}
98 87

  
88
//make sure the user is logged in.
99 89
function checkLogin()
100 90
{
101 91
  if(getCookie("sms-login") == "true")
102 92
  {
103 93
    setLoginHeader(true);
104 94
    showDatasets();
95
    showSearchPane();
105 96
  }
106 97
  else
107 98
  {
......
109 100
  }
110 101
}
111 102

  
103
//search the document base in metacat
112 104
function search()
113 105
{
114 106
  var searchval = document.getElementById("searchtextbox").value
......
118 110
  reloadSearchContent(url);
119 111
}
120 112

  
113
//show all of the datasets in metacat
121 114
function showDatasets()
122 115
{
123 116
  var searchval = getCookie('sms-searchval');
......
136 129
  }
137 130
}
138 131

  
132
//reload the search result table
139 133
function reloadSearchContent(url)
140 134
{
141 135
  var page = url.substring(url.indexOf('pagestart=') + 10, url.length);
......
143 137
  $("#searchresulttable").load(url);
144 138
}
145 139

  
140
//upload a file to metacat
146 141
function uploadfile()
147 142
{
148 143
  if(getCookie("sms-login") != "true")
......
150 145
    alert('You cannot upload.  You are not logged in.');
151 146
    return;
152 147
  }
153
  $("form").submit();
148
  if(!checkId(true))
149
  { //make sure the id is valid
150
    alert('The ID prefix you chose is not valid.  The prefix must be a string of alpha characters only.');
151
  }
152
  else
153
  {
154
    if(document.getElementById("datafile").value == null || document.getElementById("datafile").value == "")
155
    {
156
      alert('You must choose a file to upload.');
157
      return;
158
    }
159
    getId(true, true, true);
160
  }
154 161
}
155 162

  
163
//make a document public
156 164
function makepublic(docid)
157 165
{
158 166
  $.get("/sms/metacat?action=setaccess&docid=" + docid + 
......
175 183
        }, "XML");
176 184
}
177 185

  
186
//get the next id and put it in the id text boxes
187
function getId(setFields, setForm, submitForm)
188
{
189
  if(setFields == null)
190
  {
191
    setFields = true;
192
  }
193
  
194
  if(setForm == null)
195
  {
196
    setForm = false;
197
  }
198
  
199
  if(submitForm == null)
200
  {
201
    submitForm = false;
202
  }
203
  
204
  var scopeStr = document.getElementById("docidfamily").value;
205
  //var scopeStr = $('#docidfamily').value;
206
  if(scopeStr == '' || scopeStr == null)
207
  {
208
    scopeStr = "sms";
209
  }
210
  
211
  $.get("metacat", {action:"getlastdocid", scope:scopeStr}, 
212
      function(data)
213
      {
214
        var docid = data.substring(data.indexOf("<docid>") + 7, data.indexOf("</docid>"));
215
        var nextid;
216
        if(docid == 'null')
217
        {
218
          nextid = 1;
219
        }
220
        else
221
        {
222
          nextid = docid.substring(docid.indexOf(".") + 1, docid.lastIndexOf("."));
223
          nextid++;
224
          //nextid = scopeStr + nextid + ".1"; 
225
        }
226
        //$('#docidtextfield').val(nextid);
227
        if(setFields)
228
        {
229
          $('#docidfamily').val(scopeStr);
230
          $('#docidnumber').val(nextid);
231
          $('#docidrevision').val("1");
232
        }
233
        fullDocId = scopeStr + "." + nextid + ".1";
234
        //alert('fullDocId: ' + fullDocId);
235
        if(setForm)
236
        {
237
          //alert('setting docid to ' + fullDocId);
238
          $('#docid').val(fullDocId);
239
        }
240
        
241
        if(submitForm)
242
        {
243
          $("form").submit();
244
        }
245
      }, 
246
      "XML");
247
}
248

  
249
//check for a valid docid
250
function checkId(setForm)
251
{
252
  if(setForm == null)
253
  {
254
    setForm = false;
255
  }
256
  getId(false, setForm, false);
257
  var scopeStr = document.getElementById("docidfamily").value;
258
  var numberStr = document.getElementById("docidnumber").value;
259
  var userDocid = scopeStr + "." + numberStr; 
260
  
261
  //fullDocId is a global var that gets set by getId()
262
  var nextnum = fullDocId.substring(fullDocId.indexOf(".") + 1, fullDocId.lastIndexOf("."));
263
  var regexp = "[^[[a-z]|[A-Z]]+]"; //search for anything thats not an alpha 
264
  var re = new RegExp(regexp);
265
  var match = re.test(scopeStr);
266
  if(match)
267
  { //if it matches, reject
268
    return false;
269
  }
270
  
271
  return true;
272
}
273

  
274
//show the search tab
275
function showSearchPane()
276
{
277
  //hide all, then slide down the search pane
278
  $('#uploaddiv').fadeOut("slow");
279
  $('#searchresultdiv').fadeOut("slow");
280
  $('#searchdiv').fadeIn("slow");
281
  switchTabs('search');
282
}
283

  
284
//show the upload tab
285
function showUploadPane()
286
{
287
  //hide all, then slide down the upload pane
288
  $('#searchdiv').fadeOut("slow");
289
  $('#searchresultdiv').fadeOut("slow");
290
  $('#uploaddiv').fadeIn("slow");
291
  $('#uploadetabimg').hide();
292
  $('#uploadtabimgsel').show();
293
  switchTabs('upload');
294
}
295

  
296
//show the browse tab
297
function showBrowsePane()
298
{
299
  //hide all, then slide down the browse pane
300
  $('#searchdiv').fadeOut("slow");
301
  $('#uploaddiv').fadeOut("slow");
302
  $('#searchresultdiv').fadeIn("slow");
303
  $('#browsetabimg').hide();
304
  $('#browsetabimgsel').show();
305
  switchTabs('browse');
306
}
307

  
308
function switchTabs(tab)
309
{
310
  if(tab == 'browse')
311
  {
312
    $('#searchtabimg').show();
313
    $('#uploadtabimg').show();
314
    $('#browsetabimg').hide();
315
    
316
    $('#uploadtabimgsel').hide();
317
    $('#browsetabimgsel').show();
318
    $('#searchtabimgsel').hide();
319
  }
320
  else if(tab == 'search')
321
  {
322
    $('#searchtabimg').hide();
323
    $('#uploadtabimg').show();
324
    $('#browsetabimg').show();
325
    
326
    $('#uploadtabimgsel').hide();
327
    $('#browsetabimgsel').hide();
328
    $('#searchtabimgsel').show();
329
  }
330
  else if(tab == 'upload')
331
  {
332
    $('#searchtabimg').show();
333
    $('#uploadtabimg').hide();
334
    $('#browsetabimg').show();
335
    
336
    $('#uploadtabimgsel').show();
337
    $('#browsetabimgsel').hide();
338
    $('#searchtabimgsel').hide();
339
  }
340
}
341

  
342
//slide an element up
178 343
function slideUp(id)
179 344
{
180 345
  $(id).slideUp("slow");
181 346
}
182 347

  
348
//slide and element down
183 349
function slideDown(id)
184 350
{
185 351
  $(id).slideDown("slow");
186 352
}
187 353

  
354
//set a cookie
188 355
function setCookie( name, value, expires, path, domain, secure ) 
189 356
{
190 357
  // set time, it's in milliseconds
......
210 377
  ( ( secure ) ? ";secure" : "" );
211 378
}
212 379

  
380
//get a cookie
213 381
function getCookie( check_name ) {
214 382
	// first we'll split this cookie up into name/value pairs
215 383
	// note: document.cookie only returns name=value, not the other components
lib/style/skins/sms/resultset.xsl
93 93
        <xsl:when test="doctype='rdf:RDF'">
94 94
          RDF Ontology
95 95
        </xsl:when>
96
        <xsl:when test="doctype='http://daks.ucdavis.edu/sms-annot-1.0.0rc1'">
97
          SMS Annotation
98
        </xsl:when>
96 99
        <!--add more doctypes here-->
97 100
        <xsl:otherwise>
98
          Unknown Document Type
101
          <xsl:value-of select="doctype"/>
99 102
        </xsl:otherwise>
100 103
        </xsl:choose>
101 104
      </td>
lib/style/skins/sms/index.jsp
27 27
      <div id="loginheaderdiv" style="padding: 3px;">
28 28
        <h2 style="text-align:center" id="loginheader">Please Login</h2>
29 29
      </div>
30
      <!--login div-->
30 31
      <div id="loginformdiv" style="padding:20px;">
31 32
      <form action="metacat" name="loginform" method="POST">
32 33
        <div style="width:300px; margin:0px auto; height: 150px;">
......
51 52
      
52 53
      <!--main part of the page after logging in-->
53 54
      <div id="maindiv" style="display:none; width:625px; margin:0px auto; padding: 10px;">
54
      <table style="width:625px">
55
        <tr valign="top">
56
          <td width="50%" height="100%">
55
        <a href="javascript:showSearchPane()"><img id="searchtabimg" src="style/skins/sms/search-tab.png"/></a><img id="searchtabimgsel" src="style/skins/sms/search-tab-selected.png"/>
56
        <a href="javascript:showUploadPane()"><img id="uploadtabimg" src="style/skins/sms/upload-tab.png"/></a><img id="uploadtabimgsel" src="style/skins/sms/upload-tab-selected.png"/>
57
        <a href="javascript:showBrowsePane()"><img id="browsetabimg" src="style/skins/sms/browse-tab.png"/></a><img id="browsetabimgsel" src="style/skins/sms/browse-tab-selected.png"/>
57 58
          
58 59
          <!--search panel-->
59
            <div id="leftspan" style="background:grey; border:1px solid; height: 99%; width: 99%;">
60
              <h4 style="text-align:center">Semantic Search</h4>
61
              <form>
62
                <table>
63
                  <tr>
64
                    <td>Search:</td><td><input id="searchtextbox" type="text" name="anytext"/></td>
65
                  </tr>
66
                  <tr>
67
                    <td><a href="javascript:search()">[Search]</a></td><td>&nbsp;</td>
68
                  </tr>
69
                </table>
70
              </form>
71
            </div>
60
        <div id="searchdiv" style="background:grey; border:1px solid; height: 99%; width: 99%;">
61
          <div style="padding: 5px;">
62
            <h4 style="text-align:center">Semantic Search</h4>
63
            <form>
64
              <table>
65
                <tr>
66
                  <td>Search:</td><td><input id="searchtextbox" type="text" name="anytext"/></td>
67
                </tr>
68
                <tr>
69
                  <td><a href="javascript:search()">[Search]</a></td><td>&nbsp;</td>
70
                </tr>
71
              </table>
72
            </form>
73
          </div>
74
        </div>
72 75
          
73
          </td>
74 76
          
75 77
          <!--upload panel-->
76
          <td width="50%">
77
            <div id="rightspan" style="background:grey; border:1px solid; width: 99%; height: 99%;">
78
              <h4 style="text-align:center">Upload an ontology or data package</h4>
79
              <form action="metacat" name="uploadform" method="POST" enctype="multipart/form-data">
80
                <input type="hidden" name="action" value="insertmultipart"/>
81
                <input type="hidden" name="qformat" value="sms"/>
82
                <table>
83
                  <tr>
84
                    <td>File:</td><td><input type="file" id="datafile" name="datafile"/></td>
85
                  </tr>
86
                  <tr>
87
                    <td>DocId:</td><td><input id="docidtextfield" type="text" name="docid" readonly="true"/></td>
88
                  </tr>
89
                  <tr>
90
                    <td>
91
                      <a href="javascript:uploadfile()" >[Upload]</a>
92
                      <!--<input type="submit"/>-->
93
                    </td>
94
                  </tr>
95
                </table>
96
              </form>
97
              <div id="uploadstatus" style="width:312px">
98
              <%
99
                if(status != null && status.equals("success"))
100
                {
101
                  out.print("Your file was successfully uploaded with id <a href=\"http://linus.nceas.ucsb.edu/sms/metacat?docid=" + docid 
102
                  + "&action=read&qformat=sms\">" + docid + "</a>.  " +  
103
                  "<a href=\"javascript:makepublic('" + docid + "')\">Click here</a> to make this document publicly readable.");
104
                }
105
                else
106
                {
107
                  if(docid != null)
108
                  {
109
                    out.print("Sorry, your file upload failed.  Try logging in again.");
110
                  }
111
                }
112
                
113
                %>
114
              </div>
78
        <div id="uploaddiv" style="background:grey; border:1px solid; width: 99%; height: 99%;">
79
          <div style="padding:5px;">
80
            <h4 style="text-align:center">Upload an ontology or data package</h4>
81
            <form action="metacat" name="uploadform" method="POST" enctype="multipart/form-data">
82
              <input type="hidden" name="action" value="insertmultipart"/>
83
              <input type="hidden" name="qformat" value="sms"/>
84
              <input type="hidden" name="updateXMLNS" value="true"/>
85
              <table>
86
                <tr>
87
                  <td>File:<input type="file" id="datafile" name="datafile"/></td>
88
                </tr>
89
                <tr>
90
                  <!--<td>DocId:</td><td><input id="docidtextfield" type="text" name="docid" readonly="true"/></td>-->
91
                  <td>
92
                      Identifier Prefix: <input style="display:inline" id="docidfamily" type="text" value="sms" size="3"/>
93
                      <input style="display:inline" id="docidnumber" type="hidden" size="1"/>
94
                      <input style="display:inline" id="docidrevision" type="hidden" size="1"/>
95
                      <input style="display:inline" id="docid" type="hidden" name="docid" value="x"/>
96
                      <span style="font-size:70%"><a href="javascript:getId()">[Check Id]</a></span>
97
                  </td>
98
                </tr>
99
                <tr>
100
                  <td>
101
                    <a href="javascript:uploadfile()" >[Upload]</a>
102
                    <!--<input type="submit"/>-->
103
                  </td>
104
                </tr>
105
              </table>
106
            </form>
107
            <div id="uploadstatus" style="font-size: 70%; width:312px"> 
108
            <%
109
              if(status != null && status.equals("success"))
110
              {
111
                out.print("Your file was successfully uploaded with id <a href=\"http://linus.nceas.ucsb.edu/sms/metacat?docid=" + docid 
112
                + "&action=read&qformat=sms\">" + docid + "</a>.  " +  
113
                "<a href=\"javascript:makepublic('" + docid + "')\">Click here</a> to make this document publicly readable.");
114
              }
115
              else
116
              {
117
                out.print("Sorry, your file upload failed.  Try logging in again.");
118
              }
119
              
120
              %>
115 121
            </div>
116
          </td>
117
        </tr>
118
      </table>
122
          </div>
123
        </div>
119 124
      
120
      <!--search result panel-->
121
      <div id="searchresultdiv" style="position: relative; left: 3px; border: 1px solid ; padding: 10px; width: 595px;">
122
        <div id="searchresulttable">
123
          <!--this is filled in via an AJAX call.  see showDatasets()-->
125
        <!--search result panel-->
126
        <div id="searchresultdiv" style="position: relative; left: 3px; border: 1px solid ; padding: 10px; width: 595px; ">
127
          <div id="searchresulttable">
128
            <!--this is filled in via an AJAX call.  see showDatasets()-->
129
          </div>
124 130
        </div>
125 131
      </div>
126 132
      
127
      </div>
128
      
129 133
    </div>
130 134
  </div>
131 135
  <img id="bottomimg" src="style/skins/sms/sms-page-bottom.png" style="position:relative; bottom: 0px;"/>

Also available in: Unified diff