source: branches/bibliolocean/src/locean_tablerefsabsbibsort.begin.layout @ 189

Last change on this file since 189 was 189, checked in by pinsard, 12 years ago

improve sorting issue (no more tablerefsabsbibsort in recent jabref filters)

File size: 19.7 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2<html lang="en">
3<!--
4
5FILES
6=====
7
8/usr/home/fplod/locean/hal/src/data/locean_tablerefsabsbibsort.begin.layout sur aedon.locean-ipsl.upmc.fr
9
10EVOLUTIONS
11==========
12
13- fplod 20120419
14
15  * remove link to main page (desastrous effect on sort)
16    now in end.layout
17
18- fplod 20120406
19
20  * remove DOI/URL column (they are in journal column)
21  * remove css media print
22  * add a link to the main page
23   
24- fplod 20100616T072219Z aedon.locean-ipsl.upmc.fr (Darwin)
25
26  * add meta robots
27
28- fplod 2009-09-04T15:17:15Z aedon.locean-ipsl.upmc.fr (Darwin)
29
30  * change media print to see year, journal, page,vol and so on on printed
31    version
32
33- fplod 2009-08-21T07:10:53Z aedon.locean-ipsl.upmc.fr (Darwin)
34
35  * add loceanaffectation column
36  * sort by year descendant
37
38- fplod 2009-03-04T10:13:46Z aedon.locean-ipsl.upmc.fr (Darwin)
39
40  * creation from http://www.markschenk.com/tools/jabref/filterfiles/tablerefsabsbibsort/v2/
41
42  * adaptation for LOCEAN (add team column)
43  * add some little help
44
45-->
46<head>
47<title>JabRef References output for LOCEAN</title>
48<meta http-equiv="Content-Type" content="text/html; charset=\encoding">
49<meta name="robots" content="noindex,nofollow,noarchive">
50
51<script type="text/javascript">
52<!--
53// QuickSearch script for JabRef HTML export
54// Version: 2.0
55//
56// Copyright (c) 2006-2008, Mark Schenk
57//
58// This software is distributed under a Creative Commons Attribution 3.0 License
59// http://creativecommons.org/licenses/by/3.0/
60
61// Some features:
62// + optionally searches Abstracts and Reviews
63// + allows RegExp searches
64//   e.g. to search for entries between 1980 and 1989, type:  198[0-9]
65//   e.g. for any entry ending with 'symmetry', type:  symmetry$
66//   e.g. for all reftypes that are books: ^book$, or ^article$
67//   e.g. for entries by either John or Doe, type john|doe
68// + easy toggling of Abstract/Review/BibTeX
69
70// Search settings
71var searchAbstract = true;
72var searchReview = true;
73
74// Speed optimisation introduced some esoteric problems with certain RegExp searches
75// e.g. if the previous search is 200[-7] and the next search is 200[4-7] then the search doesn't work properly until the next 'keyup'
76// hence the searchOpt can be turned off for RegExp adepts
77var searchOpt = true;
78
79if (window.addEventListener) {
80        window.addEventListener("load",initSearch,false); }
81else if (window.attachEvent) {
82        window.attachEvent("onload", initSearch); }
83
84function initSearch() {
85        // basic object detection
86        if(!document.getElementById || !document.getElementsByTagName) { return; }
87        if (!document.getElementById('qstable')||!document.getElementById('qs')) { return; }
88
89        // find QS table and appropriate rows
90        searchTable = document.getElementById('qstable');
91        var allRows = searchTable.getElementsByTagName('tbody')[0].getElementsByTagName('tr');
92
93        // split all rows into entryRows and infoRows (e.g. abstract, review, bibtex)
94        entryRows = new Array();
95        infoRows = new Array(); absRows = new Array(); revRows = new Array();
96
97        for (var i=0, k=0, j=0; i<allRows.length;i++) {
98                if (allRows[i].className.match(/entry/)) {
99                        entryRows[j++] = allRows[i];
100                } else {
101                        infoRows[k++] = allRows[i];
102                        // check for abstract/review
103                        if (allRows[i].className.match(/abstract/)) {
104                                absRows.push(allRows[i]);
105                        } else if (allRows[i].className.match(/review/)) {
106                                revRows.push(allRows[i]);
107                        }
108                }
109        }
110
111        //number of entries and rows
112        numRows = allRows.length;
113        numEntries = entryRows.length;
114        numInfo = infoRows.length;
115        numAbs = absRows.length;
116        numRev = revRows.length;
117
118        //find the query field
119        qsfield = document.getElementById('qsfield');
120
121        // previous search term; used for speed optimisation
122        prevSearch = '';
123
124        //find statistics location
125        stats = document.getElementById('stat');
126        setStatistics(-1);
127
128        // creates the appropriate search settings
129        createQSettingsDialog();
130
131        // shows the searchfield
132        document.getElementById('qs').style.display = 'block';
133        document.getElementById('qsfield').onkeyup = testEvent;
134}
135
136function quickSearch(tInput){
137
138         if (tInput.value.length == 0) {
139                showAll();
140                setStatistics(-1);
141                qsfield.className = '';
142                return;
143        } else {
144                // only search for valid RegExp
145                try {
146                        var searchText = new RegExp(tInput.value,"i")
147                        closeAllInfo();
148                        qsfield.className = '';
149                }
150                catch(err) {
151                        prevSearch = tInput.value;
152                        qsfield.className = 'invalidsearch';
153                        return;
154                }
155        }
156       
157        // count number of hits
158        var hits = 0;
159
160        // start looping through all entry rows
161        for (var i = 0; cRow = entryRows[i]; i++){
162
163                // only show search the cells if it isn't already hidden OR if the search term is getting shorter, then search all
164                // some further optimisation is possible: if the search string is getting shorter, and the row is already visible, skip it. Then be careful with hits!
165                if(!searchOpt || cRow.className.indexOf('noshow')==-1 || tInput.value.length <= prevSearch.length){
166                        var found = false;
167
168                        var inCells = cRow.getElementsByTagName('td');
169                        var numCols = inCells.length;
170                               
171                        for (var j=0; j<numCols; j++) {
172                                cCell = inCells[j];
173                                var t = cCell.innerText?cCell.innerText:getTextContent(cCell);
174                                if (t.search(searchText) != -1){
175                                        found=true;
176                                        break;
177                                }
178                        }
179
180                        // look for further hits in Abstract and Review
181                        if(!found) {
182                                var articleid = cRow.id;
183                                if(searchAbstract && (abs = document.getElementById('abs_'+articleid))) {
184                                        if (getTextContent(abs).search(searchText) != -1){ found=true; }
185                                }
186                                if(searchReview && (rev = document.getElementById('rev_'+articleid))) {
187                                        if (getTextContent(rev).search(searchText) != -1){ found=true; }
188                                }
189                        }
190                       
191                        if(found) {
192                                cRow.className = 'entry show';
193                                hits++;
194                        } else {
195                                cRow.className = 'entry noshow';
196                        }
197                }
198        }
199
200        // update statistics
201        setStatistics(hits)
202       
203        // set previous search value
204        prevSearch = tInput.value;
205}
206
207function toggleInfo(articleid,info) {
208
209        var entry = document.getElementById(articleid);
210        var abs = document.getElementById('abs_'+articleid);
211        var rev = document.getElementById('rev_'+articleid);
212        var bib = document.getElementById('bib_'+articleid);
213
214        // Get the abstracts/reviews/bibtext in the right location
215        // in unsorted tables this is always the case, but in sorted tables it is necessary.
216        // Start moving in reverse order, so we get: entry, abstract,review,bibtex
217        if (searchTable.className.indexOf('sortable') != -1) {
218                if(bib) { entry.parentNode.insertBefore(bib,entry.nextSibling); }
219                if(rev) { entry.parentNode.insertBefore(rev,entry.nextSibling); }
220                if(abs) { entry.parentNode.insertBefore(abs,entry.nextSibling); }
221        }
222
223        if (abs && info == 'abstract') {
224                if(abs.className.indexOf('abstract') != -1) {
225                abs.className.indexOf('noshow') == -1?abs.className = 'abstract noshow':abs.className = 'abstract';
226                }
227        } else if (rev && info == 'review') {
228                if(rev.className.indexOf('review') != -1) {
229                rev.className.indexOf('noshow') == -1?rev.className = 'review noshow':rev.className = 'review';
230                }
231        } else if (bib && info == 'bibtex') {
232                if(bib.className.indexOf('bibtex') != -1) {
233                bib.className.indexOf('noshow') == -1?bib.className = 'bibtex noshow':bib.className = 'bibtex';
234                }               
235        } else {
236                return;
237        }
238       
239        // check if one or the other is available
240        var revshow = false;
241        var absshow = false;
242        var bibshow = false;
243        (abs && abs.className.indexOf('noshow') == -1)? absshow = true: absshow = false;
244        (rev && rev.className.indexOf('noshow') == -1)? revshow = true: revshow = false;       
245        (bib && bib.className == 'bibtex')? bibshow = true: bibshow = false;
246       
247        // highlight original entry
248        if(entry) {
249                if (revshow || absshow || bibshow) {
250                entry.className = 'entry highlight show';
251                } else {
252                entry.className = 'entry show';
253                }               
254        }
255       
256        // When there's a combination of abstract/review/bibtex showing, need to add class for correct styling
257        if(absshow) {
258                (revshow||bibshow)?abs.className = 'abstract nextshow':abs.className = 'abstract';
259        }
260        if (revshow) {
261                bibshow?rev.className = 'review nextshow': rev.className = 'review';
262        }
263       
264}
265
266function setStatistics (hits) {
267        if(hits < 0) { hits=numEntries; }
268        if(stats) { stats.firstChild.data = hits + '/' + numEntries}
269}
270
271function getTextContent(node) {
272        // Function written by Arve Bersvendsen
273        // http://www.virtuelvis.com
274       
275        if (node.nodeType == 3) {
276        return node.nodeValue;
277        } // text node
278        if (node.nodeType == 1) { // element node
279        var text = [];
280        for (var chld = node.firstChild;chld;chld=chld.nextSibling) {
281                text.push(getTextContent(chld));
282        }
283        return text.join("");
284        } return ""; // some other node, won't contain text nodes.
285}
286
287function showAll(){
288        // first close all abstracts, reviews, etc.
289        closeAllInfo();
290
291        for (var i = 0; i < numEntries; i++){
292                entryRows[i].className = 'entry show';
293        }
294}
295
296function closeAllInfo(){
297        for (var i=0; i < numInfo; i++){
298                if (infoRows[i].className.indexOf('noshow') ==-1) {
299                        infoRows[i].className = infoRows[i].className + ' noshow';
300                }
301        }
302}
303
304function testEvent(e){
305        if (!e) var e = window.event;
306        quickSearch(this);
307}
308
309function clearQS() {
310        qsfield.value = '';
311        quickSearch(qsfield);
312}
313
314function redoQS(){
315        showAll();
316        quickSearch(qsfield);
317}
318
319// Create Search Settings
320
321function toggleQSettingsDialog() {
322
323        var qssettings = document.getElementById('qssettings');
324       
325        if(qssettings.className.indexOf('active')==-1) {
326                qssettings.className = 'active';
327
328                if(absCheckBox && searchAbstract == true) { absCheckBox.checked = 'checked'; }
329                if(revCheckBox && searchReview == true) { revCheckBox.checked = 'checked'; }
330
331        } else {
332                qssettings.className= '';
333        }
334}
335
336function createQSettingsDialog(){
337        var qssettingslist = document.getElementById('qssettings').getElementsByTagName('ul')[0];
338       
339        if(numAbs!=0) {
340                var x = document.createElement('input');
341                x.id = "searchAbs";
342                x.type = "checkbox";
343                x.onclick = toggleQSetting;
344                var y = qssettingslist.appendChild(document.createElement('li')).appendChild(document.createElement('label'));
345                y.appendChild(x);
346                y.appendChild(document.createTextNode('search abstracts'));             
347        }
348        if(numRev!=0) {
349                var x = document.createElement('input');
350                x.id = "searchRev";
351                x.type = "checkbox";           
352                x.onclick = toggleQSetting;
353                var y = qssettingslist.appendChild(document.createElement('li')).appendChild(document.createElement('label'));         
354                y.appendChild(x);               
355                y.appendChild(document.createTextNode('search reviews'));
356        }
357               
358        // global variables
359        absCheckBox = document.getElementById('searchAbs');
360        revCheckBox = document.getElementById('searchRev');
361       
362        // show search settings
363        if(absCheckBox||revCheckBox) {
364                document.getElementById('qssettings').style.display = 'block';
365        }
366}
367
368function toggleQSetting() {
369        if(this.id=='searchAbs') { searchAbstract = !searchAbstract; }
370        if(this.id=='searchRev') { searchReview = !searchReview; }
371        redoQS()
372}
373-->
374</script>
375<script type="text/javascript">
376<!--
377// Sort Table Script
378// Version: 1.1
379//
380// Copyright (c) 2006-2008, Mark Schenk
381//
382// This software is distributed under a Creative Commons Attribution 3.0 License
383// http://creativecommons.org/licenses/by/3.0/
384
385// NB: slow as molasses in FireFox, especially when sorting columns with a lot of text.
386// An optimization is implemented which makes speed bearable, toggled by the following variable
387var SORT_SPEED_OPT = true;
388// a bit of browser preference: Opera does not need optimization
389if(window.opera) { SORT_SPEED_OPT=false; }
390// the optimization has one limitation on the functionality: when sorting search
391// results, the expanded info, e.g. bibtex/review, is collapsed. In the non-optimized
392// version they remain visible.
393
394
395if (window.addEventListener) {
396        window.addEventListener("load",initSortTable,false) }
397else if (window.attachEvent) {
398        window.attachEvent("onload", initSortTable); }
399
400function initSortTable() {
401var alltables = document.getElementsByTagName('table');
402for(i=0;i<alltables.length;i++) {
403        var currentTable = alltables[i];
404        if(currentTable.className.indexOf('sortable') !=-1) {
405                var thead = currentTable.getElementsByTagName('thead')[0];
406                thead.title = 'Click on any column header to sort';
407                for (var i=0;cell = thead.getElementsByTagName('th')[i];i++) {
408                        cell.onclick = function () { resortTable(this); };
409                        // make it possible to have a default sort column
410                        if(cell.className.indexOf('sort')!=-1) {
411                                resortTable(cell)
412                        }
413                }
414        }
415}
416}
417
418var SORT_COLUMN_INDEX
419
420function resortTable(td) {
421        var column = td.cellIndex;
422        var table = getParent(td,'TABLE');
423
424        var allRows = table.getElementsByTagName('tbody')[0].getElementsByTagName('tr');
425        var newRows = new Array();
426
427        for (var i=0, k=0; i<allRows.length;i++) {
428
429                var rowclass = allRows[i].className;
430
431                if (rowclass.indexOf('entry') != -1) {
432                newRows[k++] = allRows[i];
433                }
434               
435                if (SORT_SPEED_OPT) {
436                // remove highlight class
437                allRows[i].className = rowclass.replace(/highlight/,'');
438                // close information
439                if(rowclass.indexOf('entry') == -1 && rowclass.indexOf('noshow') == -1) { allRows[i].className = rowclass + ' noshow';}
440                }
441        }
442
443
444        // If other sort functions are deemed necessary (e.g. for
445        // dates and currencies) they can be added.
446        var sortfn = ts_sort_firstchild_caseinsensitive;
447        SORT_COLUMN_INDEX = column;
448        newRows.sort(sortfn);
449
450        // create a container for showing sort arrow
451        var arrow =  td.getElementsByTagName('span')[0];
452        if (!arrow) { var arrow = td.appendChild(document.createElement('span'));}
453       
454        if (td.className) {
455                if (td.className.indexOf('sort_asc') !=-1) {
456                        td.className = td.className.replace(/_asc/,"_des");
457                        newRows.reverse();
458                        arrow.innerHTML = '&uArr;';
459                } else if (td.className.indexOf('sort_des') !=-1) {
460                        td.className = td.className.replace(/_des/,"_asc");
461                        arrow.innerHTML = '&dArr;';
462                } else {
463                        td.className += ' sort_asc';
464                        arrow.innerHTML = '&dArr;';
465                }
466        } else {
467                td.className += 'sort_asc';
468                arrow.innerHTML = '&dArr;';
469        }
470       
471        // Remove the classnames and up/down arrows for the other headers
472        var ths = table.getElementsByTagName('thead')[0].getElementsByTagName('th');
473        for (var i=0; i<ths.length; i++) {
474                if(ths[i]!=td && ths[i].className.indexOf('sort_')!=-1) {
475                // argh, moronic JabRef thinks (backslash)w is an output field!!
476                //ths[i].className = ths[i].className.replace(/sort_(backslash)w{3}/,"");
477                ths[i].className = ths[i].className.replace(/sort_asc/,"");
478                ths[i].className = ths[i].className.replace(/sort_des/,"");
479
480                // remove span
481                var arrow =  ths[i].getElementsByTagName('span')[0];
482                if (arrow) { ths[i].removeChild(arrow); }
483                }
484        }
485
486        // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
487        for (i=0;i<newRows.length;i++) {
488                table.getElementsByTagName('tbody')[0].appendChild(newRows[i]);
489
490                if(!SORT_SPEED_OPT){
491                // moving additional information, e.g. bibtex/abstract to right locations
492                // this allows to sort, even with abstract/review/etc. still open
493                var articleid = newRows[i].id;
494
495                var entry = document.getElementById(articleid);
496                var abs = document.getElementById('abs_'+articleid);
497                var rev = document.getElementById('rev_'+articleid);
498                var bib = document.getElementById('bib_'+articleid);           
499       
500                var tbody = table.getElementsByTagName('tbody')[0];
501                // mind the order of adding the entries
502                if(abs) { tbody.appendChild(abs); }
503                if(rev) { tbody.appendChild(rev); }
504                if(bib) { tbody.appendChild(bib); }
505                }
506        }
507}
508
509function ts_sort_firstchild_caseinsensitive(a,b) {
510        // only search in .firstChild of the cells. Speeds things up tremendously in FF
511        // problem is that it won't find all the text in a cell if the firstChild is an element
512        // or if there are other elements in the cell. Risky fix, but the speed boost is worth it.
513        var acell = a.cells[SORT_COLUMN_INDEX];
514        var bcell = b.cells[SORT_COLUMN_INDEX];
515       
516        acell.firstChild? aa = getTextContent(acell.firstChild).toLowerCase():aa = "";
517        bcell.firstChild? bb = getTextContent(bcell.firstChild).toLowerCase():bb = "";
518
519        if (aa==bb) return 0;
520        if (aa<bb) return -1;
521        return 1;
522}
523
524function ts_sort_caseinsensitive(a,b) {
525        aa = getTextContent(a.cells[SORT_COLUMN_INDEX]).toLowerCase();
526        bb = getTextContent(b.cells[SORT_COLUMN_INDEX]).toLowerCase();
527        if (aa==bb) return 0;
528        if (aa<bb) return -1;
529        return 1;
530}
531
532function ts_sort_default(a,b) {
533        aa = getTextContent(a.cells[SORT_COLUMN_INDEX]);
534        bb = getTextContent(b.cells[SORT_COLUMN_INDEX]);
535        if (aa==bb) return 0;
536        if (aa<bb) return -1;
537        return 1;
538}
539
540function getParent(el, pTagName) {
541        if (el == null) {
542                return null;
543        } else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()) {
544                return el;
545        } else {
546                return getParent(el.parentNode, pTagName);
547        }
548}
549-->
550</script>
551<style type="text/css">
552body { background-color: white; font-family: "Trebuchet MS", Arial, sans-serif; font-size: 12px; line-height: 1.2; padding: 1em; color: #2E2E2E; }
553
554#qs { width: auto; border-style: solid; border-color: gray; border-width: 1px 1px 0px 1px; padding: 0.5em 0.5em; display:none; position:relative; }
555#qs form { padding: 0px; margin: 0px; }
556#qs form p { padding: 0px; margin: 0px; }
557#qs p.help { font-weight:normal;}
558
559.invalidsearch { background-color: red; }
560
561table { border: 1px gray solid; width: 100%; empty-cells: show; }
562th, td { border: 1px gray solid; padding: 0.5em; vertical-align: top;  }
563td { text-align: left; vertical-align: top; }
564th { background-color: #EFEFEF; }
565
566td a { color: navy; text-decoration: none; }
567td a:hover  { text-decoration: underline; }
568
569tr.noshow { display: none;}
570
571tr.highlight td { background-color: #F1F1F1; border-top: 2px black solid; font-weight: bold; }
572tr.abstract td, tr.review td, tr.bibtex td { background-color: #F1F1F1; border-bottom: 2px black solid; }
573tr.nextshow td { border-bottom: 1px gray solid; }
574
575tr.bibtex pre { width: 100%; overflow: auto;}
576
577p.infolinks { margin: 0.5em 0em 0em 0em; padding: 0px; }
578
579
580#qssettings { padding: 0.5em; position: absolute; top: 0.2em; right: 0.2em; border: 1px gray solid; background-color: white; display: none; }
581#qssettings p { font-weight: bold; cursor: pointer; }
582#qssettings p.help { font-weight:normal;}
583#qssettings ul { display: none; list-style-type: none; padding-left: 0; margin: 0; }
584#qssettings.active ul { display: block; }
585
586
587th.sort_asc, th.sort_des { border: 2px black solid; }
588</style>
589</head>
590<body>
591
592<div id="qs">
593        <form action="">
594        <p>QuickSearch: <input type="text" name="qsfield" id="qsfield" autocomplete="off" title="Allows plain text as well as RegExp searches" /><input type="button" onclick="clearQS()" value="clear" />&nbsp; Number of matching entries: <span id="stat">0</span>.</p>
595<p class="help">
596allows RegExp searches
597<ul>
598 <li><p class="help"> e.g. to search for entries between 1980 and 1989, type:  <code>198[0-9]</code></p></li>
599 <li><p class="help"> e.g. for any entry ending with 'symmetry', type:  <code>symmetry$</code></p></li>
600 <li><p class="help"> e.g. for all reftypes that are books: <code>^book$</code>, or <code>^article$</code></p></li>
601  <li><p class="help">e.g. for entries by either John or Doe, type <code>john|doe</code></p></li>
602</ul>
603</p>
604
605        <div id="qssettings">
606                <p onclick="toggleQSettingsDialog()">Search Settings</p>
607                <ul></ul>
608                <p class="help">optionally searches Abstracts and Reviews</p>
609        </div>
610        </form>
611</div>
612<table id="qstable" class="sortable" summary="LOCEAN bibliography" border="1">
613<thead>
614<tr>
615<th width="20%">Author</th>
616<th width="2%">Team</th>
617<th width="2%">AERES Team</th>
618<th width="2%">Organization</th>
619<th width="20%">Title</th>
620<th class="sort_asc" width="5%">Year</th>
621<th width="5%">Journal/Proceedings; DOI/URL</th>
622<th width="2%">Reftype</th>
623<th width="2%">AERES Type</th>
624</tr>
625</thead>
626<tbody>
Note: See TracBrowser for help on using the repository browser.