Merge branch 'master' of ssh://git.indexdata.com/home/git/pub/pazpar2
authorDennis Schafroth <dennis@indexdata.com>
Fri, 18 Nov 2011 15:32:19 +0000 (16:32 +0100)
committerDennis Schafroth <dennis@indexdata.com>
Fri, 18 Nov 2011 15:32:19 +0000 (16:32 +0100)
www/iphone/UiUIKit/stylesheets/iphone.css
www/iphone/example_client.js
www/iphone/gfx/progress.gif [new file with mode: 0755]
www/iphone/index.html
www/iphone/styles.css

index 23e48ff..d0fb9a2 100644 (file)
                        margin: 15px 0 0 10px;  
                        }
 
+
 #searchForm {
-  background-color: #7ec8b2;
+  background-color: #4AB694; 
+//8AD0B9;
 }
 #nav {
     background-color: #000;
@@ -46,7 +48,7 @@
 #nav li {
   margin: 10px 5px 0 5px;
   float: left;
-  padding: 0;
+  padding: 10px 5px 10px 5px;
   margin: 0;
   list-style: none;
   border-bottom-width: 0px;
                        padding: 10px;
                        margin: 0 0 0 -10px;
                        min-height: 44px;
+                       //position: absolute;
                        -webkit-box-sizing: border-box;
                        }
 
                                color: #666;
                                border-top: 0px;
                                list-style-type: none;  
+//                             padding: 10px 10px 10px 10px;
+//                             border: 1px solid #B4B4B4;
+                               }
+
+                       ul.termlist li a {
+                               color: #666;
+                               border-top: 0px;
+                               list-style-type: none;  
                                padding: 10px 10px 10px 10px;
+                               border: 1px solid #B4B4B4;
                                }
                                
 
                                        background-image: url(../images/chevron.png);
                                        background-position: right center;
                                        background-repeat: no-repeat;
+                                       border: 1px solid rgb(180,180,180);
                                        }
                                        
                                        
                                        white-space: nowrap;
                                        overflow: hidden;
                                        display: block;
-                                       padding: 12px 10px 12px 10px;
-                                       margin: -10px;
+                                       padding: 0px 0px 0px 0px;
+                                       margin: 0px;
                                        -webkit-tap-highlight-color:rgba(0,0,0,0);
                                }
                                
                                        ul li.img a + a {
-                                               margin: -10px 10px -20px -5px;
+                                               margin: 0px 10px 0px -5px;
                                                font-size: 17px;
                                                font-weight: bold;
                                        }
                                        ul li.img a + a + a {
                                                        font-size: 14px;
                                                        font-weight: normal;
-                                                       margin-left: -10px;
-                                                       margin-bottom: -10px;
+                                                       margin-left: -5px;
+                                                       margin-bottom: 0px;
                                                        margin-top: 0;
                                                }
                                                
                                                
                                                
                                                ul li.img a + small + a + a {
-                                                       margin-left: -10px;
-                                                       margin-top: -20px;
-                                                       margin-bottom: -10px;
+                                                       margin-left:  -5px;
+                                                       margin-top:    0px;
+                                                       margin-bottom: 0px;
                                                        font-size: 14px;
                                                        font-weight: normal;
                                                        }
                                                ul li a + a + a, ul li.img a + a + a + a, ul li.img a + small + a + a + a {
                                                        color: #666;
                                                        font: 13px Helvetica;
-                                                       margin: 0;
+                                                       margin-left: -5px;
                                                        text-overflow: ellipsis;
                                                        white-space: nowrap;
                                                        overflow: hidden;
                /* images */
                
                        ul li.img {
-                               padding-left: 115px;
+                               padding-left: 60px;
+                               height: 58px;
                        }
                
                        ul li.img a.img {
-                               background: url(../images/standard-img.png) no-repeat;
+                               /* background: url(../images/standard-img.png) no-repeat; */
                                display: inline-block;
-                               width: 100px;
-                               height: 75px;
-                               margin: -10px 0 -20px -115px;
+                               width: 45px;
+                               height: 60px;
+                               margin: 0px 0px 0px -60px;
+                               padding: 0px 0px 0px 0px;
                                float: left;
                        }
                
                                                                                                                                
                                                                ul.field li small {
                                                                        font-size: 13px;
-                                                                       font-weight: bold;
+                                                                       font-weight: bold
+                                                                       display: inline-block;
                                                                }
                                                        
                                                
index 3edabac..e447c9e 100644 (file)
@@ -14,21 +14,23 @@ var querys_server = {};
 var useLimit = 1;
 // Fail to get JSON working stabil.
 var showResponseType = 'xml';
+
+var imageHelper = new ImageHelper();
+
 if (document.location.hash == '#pazpar2' || document.location.search.match("useproxy=false")) {
     usesessions = true;
     pazpar2path = '/pazpar2/search.pz2';
     showResponseType = 'xml';
 }
 
-
 my_paz = new pz2( { "onshow": my_onshow,
-                    "showtime": 500,            //each timer (show, stat, term, bytarget) can be specified this way
+//                    "showtime": 2000,            //each timer (show, stat, term, bytarget) can be specified this way
                     "pazpar2path": pazpar2path,
                     "oninit": my_oninit,
-                    "onstat": my_onstat,
+                    "onstat": null,
                     "onterm": my_onterm_iphone,
                     "termlist": "xtargets,subject,author",
-                    "onbytarget": my_onbytarget,
+                    "onbytarget": null,
                    "usesessions" : usesessions,
                     "showResponseType": showResponseType,
                     "onrecord": my_onrecord } );
@@ -153,6 +155,35 @@ function showMoreRecords() {
     }
 }
 
+function hideRecords() {
+    for ( var i = 0; i < recToShow; i++) {
+       var element = document.getElementById(recIDs[i]);
+       if (element && recIDs != curDetRecId)
+           element.style.display = 'none';
+    }
+    var element = document.getElementById('recdiv_END');
+    if (element)
+       element.style.display = 'none';
+}
+
+function showRecords() {
+    for (var i = 0 ; i < recToShow && i < recPerPage; i++) {
+       var element = document.getElementById(recIDs[i]);
+       if (element)
+           element.style.display = '';
+    }
+    var element = document.getElementById('recdiv_END');
+    if (element) {
+       if (i == recPerPage)
+           element.style.display = 'none';
+       else
+           element.style.display = '';
+    }
+}
+
+
+
+
 function my_onshow(data) {
     totalRec = data.merged;
     // move it out
@@ -172,35 +203,72 @@ function my_onshow(data) {
     var style = '';
     for (var i = 0; i < data.hits.length; i++) {
         var hit = data.hits[i];
-       var recID = "recdiv_" + hit.recid; 
-       //var recID = "recdiv_" + i; 
-       recIDs[i] = recID;
+       var recDivID = "recdiv_" + hit.recid; 
+       recIDs[i] = recDivID;
+       var lines = 0;
        if (i == recToShow)
            style = ' style="display:none" ';
-       html.push('<li id="' + recID + '" ' + style +  '>' 
-                 +'<a href="#" id="rec_'+hit.recid
-                 +'" onclick="showDetails(this.id);return false;">' 
-                 + hit["md-title"] +'</a> '); 
-       if (hit["md-title-remainder"] !== undefined) {
-           html.push('<a href="#">' + hit["md-title-remainder"] + ' </a> ');
+       html.push('<li class="img arrow" id="' + recDivID + '" ' + style +  '>' );
+       html.push('<a class="img" href="#' + i + '" id="rec_'+hit.recid + '" onclick="showDetails(this.id);return false;" >');
+       if (1) {
+            var useThumbnails = hit["md-use_thumbnails"];
+            var thumburls = hit["md-thumburl"];
+            if (thumburls && (useThumbnails == undefined || useThumbnails == "1")) {
+               var thumbnailtag = imageHelper.getImageTagByRecId(hit.recid,"md-thumburl", 60, "S"); 
+               html.push(thumbnailtag);
+           } else { 
+               if (hit["md-isbn"] != undefined) { 
+                   var coverimagetag = imageHelper.getImageTagByRecId(hit.recid, "md-isbn", 60, "S"); 
+                   if (coverimagetag.length>0) { 
+                        html.push(coverimagetag);
+                   } else { 
+                       html.push("&nbsp;");
+                   }
+               }
+           }
+       } 
+       html.push("</a>");
+       html.push('<a href="#" id="rec_'+hit.recid + '" onclick="showDetails(this.id);return false;">');
+       html.push(hit["md-title"]); 
+       html.push("</a>");
+
+       if (hit["md-title-remainder"] != undefined) {
+           html.push('<a href="#" id="rec_'+hit.recid + '" onclick="showDetails(this.id);return false;">');
+           html.push(hit["md-title-remainder"]);
+           html.push("</a>");
+           lines++;
        }
        if (hit["md-author"] != undefined) {
-           html.push('<a href="#">'+hit["md-author"]+'</a> ');
+           html.push('<a href="#" id="rec_'+hit.recid + '" onclick="showDetails(this.id);return false;">');
+           html.push(hit["md-author"]);
+           html.push("</a>");
+           lines++;
+       }
+       else if (hit["md-title-responsibility"] != undefined) {
+           html.push('<a href="#" id="rec_'+hit.recid + '" onclick="showDetails(this.id);return false;">');
+           html.push(hit["md-title-responsibility"]);
+           html.push("</a>");
+           lines++;
        }
-       else if (hit["md-title-responsibility"] !== undefined) {
-           html.push('<a href="#">'+hit["md-title-responsibility"]+'</a> ');
+       for (var idx = lines ; idx < 2 ; idx++) {
+           html.push('<a href="#" id="rec_'+hit.recid + '" onclick="showDetails(this.id);return false;">');
+           html.push("&nbsp;");            
+           html.push("</a>");
        }
+/*
         if (hit.recid == curDetRecId) {
             html.push(renderDetails_iphone(curDetRecData));
         }
+*/
        html.push('</li>');
     }
+    document.getElementById("loading").style.display = 'none';
     // set up "More..." if needed. 
     style = 'display:none';
     if (recToShow < recPerPage) {
        style = 'display:block';
     }
-    html.push('<li id="recdiv_END" style="' + style + '"><a onclick="showMoreRecords()">More...</a></li>');     
+    html.push('<li class="img" id="recdiv_END" style="' + style + '"><a onclick="showMoreRecords()">More...</a></li>');     
 
     replaceHtml(results, html.join(''));
 }
@@ -217,13 +285,15 @@ function my_onstat(data) {
                         + '/' + data.hits + ' :.</span>';
 }
 
-function showhide(newtab) {
+function showhide(newtab, hash) {
     var showtermlist = false;
     if (newtab != null)
        tab = newtab;
     
     if (tab == "recordview") {
        document.getElementById("recordview").style.display = '';
+       if (hash != undefined)
+           document.location.hash = hash;
     }
     else 
        document.getElementById("recordview").style.display = 'none';
@@ -249,6 +319,16 @@ function showhide(newtab) {
     else
        document.getElementById("term_authors").style.display = 'none';
 
+    if (tab == "detailview") {
+       document.getElementById("detailview").style.display = '';
+    }
+    else {
+       document.getElementById("detailview").style.display = 'none';
+       var element = document.getElementById("rec_" + curDetRecId);
+       if (element != undefined)
+           element.scrollIntoView();
+
+    }
     if (showtermlist == false) 
        document.getElementById("termlist").style.display = 'none';
     else 
@@ -268,10 +348,10 @@ function my_onterm(data) {
     
     termlists.push('<div id="term_xtargets" >');
     termlists.push('<h4 class="termtitle">Sources</h4>');
-    termlists.push('<ul>');
-    termlists.push('<li><a href="#" target_id="reset_xt" onclick="limitOrResetTarget(\'reset_xt\',\'All\');return false;">All</a></li>');
+    termlists.push('<ul class="termlist">');
+    termlists.push('<li> <a href="#" target_id="reset_xt" onclick="limitOrResetTarget(\'reset_xt\',\'All\');return false;">All</a></li>');
     for (var i = 0; i < data.xtargets.length && i < SourceMax; i++ ) {
-        termlists.push('<li><a href="#" target_id='+data.xtargets[i].id
+        termlists.push('<li class="termlist"><a href="#" target_id='+data.xtargets[i].id
             + ' onclick="limitOrResetTarget(this.getAttribute(\'target_id\'), \'' + data.xtargets[i].name + '\');return false;">' 
            + data.xtargets[i].name + ' (' + data.xtargets[i].freq + ')</a></li>');
     }
@@ -280,7 +360,7 @@ function my_onterm(data) {
      
     termlists.push('<div id="term_subjects" >');
     termlists.push('<h4>Subjects</h4>');
-    termlists.push('<ul>');
+    termlists.push('<ul class="termlist">');
     termlists.push('<li><a href="#" target_id="reset_su" onclick="limitOrResetQuery(\'reset_su\',\'All\');return false;">All</a></li>');
     for (var i = 0; i < data.subject.length && i < SubjectMax; i++ ) {
         termlists.push('<li><a href="#" onclick="limitOrResetQuery(\'su\', \'' + data.subject[i].name + '\');return false;">' 
@@ -291,7 +371,7 @@ function my_onterm(data) {
             
     termlists.push('<div id="term_authors" >');
     termlists.push('<h4 class="termtitle">Authors</h4>');
-    termlists.push('<ul>');
+    termlists.push('<ul class="termlist">');
     termlists.push('<li><a href="#" onclick="limitOrResetQuery(\'reset_au\',\'All\');return false;">All<a></li>');
     for (var i = 0; i < data.author.length && i < AuthorMax; i++ ) {
         termlists.push('<li><a href="#" onclick="limitOrResetQuery(\'au\', \'' + data.author[i].name +'\');return false;">' 
@@ -343,15 +423,18 @@ function getAuthors() {
 }
 
 function my_onrecord(data) {
+
     // FIXME: record is async!!
     clearTimeout(my_paz.recordTimer);
     // in case on_show was faster to redraw element
-    var detRecordDiv = document.getElementById('det_'+data.recid);
-    if (detRecordDiv) return;
+    var detailRecordDiv = document.getElementById('detailrecord');
+    if (!detailRecordDiv) 
+       return;
     curDetRecData = data;
-    var recordDiv = document.getElementById('recdiv_'+curDetRecData.recid);
     var html = renderDetails_iphone(curDetRecData);
-    recordDiv.innerHTML += html;
+    detailRecordDiv.innerHTML = html;
+    document.getElementById("loading").style.diplay = 'none';
+    showhide('detailview');
 }
 
 function my_onrecord_iphone(data) {
@@ -391,6 +474,12 @@ function domReady ()
        applicationMode(true);
     else
        applicationMode(false);
+
+    var params = parseQueryString(window.location.search);
+    if (params.query) {
+       document.search.query.value = params.query;
+       onFormSubmitEventHandler();
+    }
 }
  
 function applicationMode(newmode) 
@@ -457,6 +546,7 @@ function triggerSearch ()
           "limit" : getFacets() 
        }
        );
+    document.getElementById("loading").style.diplay = 'block';
 }
 
 function loadSelect ()
@@ -662,21 +752,14 @@ function showDetails (prefixRecId) {
     var oldRecId = curDetRecId;
     curDetRecId = recId;
     
-    // remove current detailed view if any
-    var detRecordDiv = document.getElementById('det_'+oldRecId);
-    //alert("oldRecId: " + oldRecId + " " + detRecordDiv != null); 
-    // lovin DOM!
-    if (detRecordDiv)
-      detRecordDiv.parentNode.removeChild(detRecordDiv);
-
-    // if the same clicked, just hide
+    // if the same clicked, just show it again
     if (recId == oldRecId) {
-        curDetRecId = '';
-        curDetRecData = null;
+       showhide('detailview');
         return;
     }
     // request the record
     my_paz.record(recId);
+    document.getElementById("loading").style.diplay = 'block';
 }
 
 function replaceHtml(el, html) {
@@ -699,13 +782,13 @@ function renderDetails(data, marker)
     if (marker) details += '<tr><td>'+ marker + '</td></tr>';
     if (data["md-title"] != undefined) {
         details += '<tr><td><b>Title</b></td><td><b>:</b> '+data["md-title"];
-       if (data["md-title-remainder"] !== undefined) {
+       if (data["md-title-remainder"] != undefined) {
              details += ' : <span>' + data["md-title-remainder"] + ' </span>';
        }
-       if (data["md-author"] !== undefined) {
+       if (data["md-author"] != undefined) {
              details += ' <span><i>'+ data["md-auhtor"] +'</i></span>';
        }
-         details += '</td></tr>';
+       details += '</td></tr>';
     }
     if (data["md-date"] != undefined)
         details += '<tr><td><b>Date</b></td><td><b>:</b> ' + data["md-date"] + '</td></tr>';
@@ -723,10 +806,35 @@ function renderDetails(data, marker)
 
 function renderLine(title, value) {
     if (value != undefined)
-        return '<li><h3>' + title + '</h3> <big>' + value + '</big></li>';
+        return '<li><h3>' + title + '</h3> <big>' + value + '<br></big></li>';
     return '';
 }
 
+function renderLines(title, values, name) {
+    var result = "";
+    result = '<li><h3>' + title + '</h3><big>';
+    if (values != undefined && values.length)
+       for (var idx = 0 ; idx < values.length ; idx++)
+           result += values[idx][name] + '<br>';
+    result += '</big>';
+    return result;
+}
+
+function renderLinesURL(title, values, name, url) {
+    var result = "";
+    result = '<li><h3>' + title + '</h3><big>';
+    if (values != undefined && values.length) {
+       for (var idx = 0 ; idx < values.length ; idx++) {
+           if (values[idx][url] != undefined)
+               result += '<a href="' + values[idx][url] + '">' + values[idx][name] + '</a><br>';
+           else
+               result += values[idx][name] + '<br>';
+       }
+    }
+    result += '</big>';
+    return result;
+}
+
 function renderLineURL(title, URL, display) {
     if (URL != undefined)
        return '<li><h3>' + title + '</h3> <a href="' + URL + '" target="_blank">' + display + '</a></li>';
@@ -754,28 +862,30 @@ function renderDetails_iphone(data, marker)
 */
     if (marker) 
        details += '<h4>'+ marker + '</h4>'; 
-    details += '<ul class="field">';
+    details += '<ul class="field" >';
     if (data["md-title"] != undefined) {
-       details += '<li><h3>Title</h3> <big> ' + data["md-title"];
-        if (data["md-title-remainder"] !== undefined) {
-             details += ' ' + data["md-title-remainder"] + ' ';
+       details += '<li><h3>Title</h3><big> ' + data["md-title"];
+        if (data["md-title-remainder"] != undefined) {
+             details += ' - ' + data["md-title-remainder"] + ' ';
         }
-        if (data["md-author"] !== undefined) {
+/*
+        if (data["md-author"] != undefined) {
              details += '<i>'+ data["md-author"] +'</i>';
-        } else if (data["md-title-responsibility"] !== undefined) {
+        } else if (data["md-title-responsibility"] != undefined) {
              details += '<i>'+ data["md-title-responsibility"] +'</i>';
         }
+*/
         details += '</big>'
         details += '</li>'
     }
     details 
        +=renderLine('Date',    data["md-date"])
        + renderLine('Author',  data["md-author"])
-       + renderLineURL('URL',  data["md-electronic-url"], data["md-electronic-url"])
-       + renderLine('Subject', data["location"][0]["md-subject"]);
+//     + renderLineURL('URL',  data["md-electronic-url"], data["md-electronic-url"])
+       + renderLine('Description',     data["md-description"]);
+       + renderLines('Subjects', data["location"], "md-subject");
     
-    if (data["location"][0]["@name"] != undefined)
-       details += renderLine('Location', data["location"][0]["@name"] + " (" +data["location"][0]["@id"] + ")");
+    details += renderLinesURL('Location', data["location"], "@name", "md-url_recipe");
     details += '</ul></div>';
     return details;
 }
diff --git a/www/iphone/gfx/progress.gif b/www/iphone/gfx/progress.gif
new file mode 100755 (executable)
index 0000000..3ecbd97
Binary files /dev/null and b/www/iphone/gfx/progress.gif differ
index dca0792..dac136f 100644 (file)
 <!-- 
   <meta id="viewport" name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
  -->  
-
        <script type="text/javascript" src="/mk2-ui-core/js/ui_bootstrap.js"></script>
        <script type="text/javascript" src="/mk2-ui-core/js/state.js"></script>
+       <script type="text/javascript" src="/mk2-ui-core/js/images.js"></script>
        <script type="text/javascript" src="/mk2-ui-core/js/recipe.js"></script>
        <script type="text/javascript" src="/mk2-ui-core/js/snippet.js"></script>
        <script type="text/javascript" src="/mk2-ui-core/js/auth.js"></script>        
        <script type="text/javascript" src="/mk2-ui-core/js/torus.js"></script>
+       <script type="text/javascript" src="/mk2-ui-core/js/helper.js"></script>
 <!--
         <script type="text/javascript" src="/mk2-ui-core/js/client.js"></script>
 -->
@@ -46,7 +47,6 @@
    <span> | </span>
    <a href="#" onclick="switchView('targetview')">Target Info</a>
   </div>
   <div id="heading">
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
     <tr>
@@ -56,7 +56,7 @@
      <td width="100%">
       <form id="searchForm" name="search" style="display: none">
        <input id="query" type="text" onKeyPress="return handleKeyPress(event)" />
-       <input id="button" type="submit" value="go" /><a id="hidden" href=""></a>
+       <input id="button" type="submit" value="go" /><img id="loading" class="inline" src="gfx/progress.gif" height="14" /><a id="hidden" href=""></a>
       </form>
      </td>
     </tr>
         per page.
        </form>
       </div>
-      <div id="pager" style="display: none;"></div>
       <h4>Results by MasterKey</h4>
       <ul id="results"></ul>
       <img id="logo" src="IndexData_MK_logo.png"/>
+      <div id="pager" style="display: block;"></div>
+  </div>
+  <div id="detailview" style="display:none">
+    <div id="header">
+      <h1>Detailed view</h1>
+      <a href="#" onclick="showhide('recordview', 10)" id="backButton">Back</a>
+    </div>
+    <div id="detailrecord">meh</div> 
   </div>
-  
   <div id="targetview" style="display: none">
    <div id="bytarget">
        No information available yet.
index e6cd2b0..1bd06e7 100644 (file)
@@ -66,7 +66,7 @@ input#query {
 
 div.termtitle {
     margin: 4px;
-    font-weight: bold;
+//    font-weight: bold;
 }
 
 div.record {