/* -----------------------------------------------------------------------------------
return middle of the string
example:
middle('&count=25&start=1&', '&count=', '&')
will return:
'25'
------------------------------------------------------------------------------------*/
function middle(str, ina, inb){ // return middle of the string
//alert('middle function');
var startix = str.indexOf(ina);
var endix = str.indexOf(inb, startix + 1);
var newStr = '';
if (startix >= 0) {
if (endix < 0) {endix = str.length;}
newStr = str.substring(startix + ina.length, endix);
} else {newStr = ''; }
return newStr;
} // end of function middle()
/* -----------------------------------------------------------------------------------------------------------------------
Generate links in groups
place this script on a $$viewtemplate or $$searchtemplate
Input parameters:
total - the total number of documents in the view or search result
format - the format of the generated links
0 (or omitted) generates page numbers, ex. Previous | 1 | 2 | 3 | Next
1 generates groups, ex.. Previous | 1 - 4 | 5 - 8 | 9 - 10 | Next
when you call the original view the URL should include two parameters:
&count will be used to calculate the intervals
&start must be the last parameter in the URL
defaults &count=30&start=1
place call to this function on the $$...template at the spot where you want the links to appear
set the total passed to this function to TotalHits or
use @dbLookup to set it to the number of documents in the view
-------------------------------------------------------------------------------------------------------------------------*/
function generateLinks(total, format) { // generate a range of links
//alert('generateLinks, total = ' + total);
function makeLink(curStart, linkText) { // create the tag (internal function)
var tmpLink = '';
tmpLink = '' ;
tmpLink = tmpLink + linkText + '';
return(tmpLink );
} // end of internal function makeLink
var loc = String(window.location.href);
loc = loc.toLowerCase();
var path = window.location.pathname.toLowerCase();
path = path.substr(0,path.indexOf(".nsf") + 5);
var nextLink = 'Nästa
';
var prevLink = '
Föregående';
var style = '';
var links = '';
var ix = loc.indexOf('&start='); // &start= must be the last parameter
var shortLoc = loc;
if (ix < 0) { start = 1; }
else {
shortLoc = loc.substring(0,ix);
start = parseInt(middle(loc, '&start=', '&'),10);
}
ix = loc.indexOf('&count=');
if (ix < 0) {
count = 30 ;
shortLoc = shortLoc + '&count=' + count;
}
else {
count = parseInt(middle(loc, '&count=', '&'),10);
}
nextStart = start + count;
prevStart = start - count;
if (nextStart <= total) { nextLink = makeLink(nextStart, nextLink); } // Eva
if (prevStart > 0) { prevLink = makeLink(prevStart, prevLink); }
ix = total/count;
if (total % count == 0) {ix = ix - 1}; // set number of links
for (var j = 0; j <= ix; j++) { // create all the links
thisStart = j*count + 1;
thisEnd = thisStart + count - 1;
if (thisEnd > total) {thisEnd = total }
if (thisStart == start) {style = 'style="font-weight: bold" '; }
else { style = ''}
if (format) {thisText = '' + thisStart + ' - ' + thisEnd; }
else {thisText = String(j + 1); }
links = links + ' | ' + makeLink(thisStart, thisText);
}
document.writeln(prevLink + links + ' | ' + nextLink);
} // end of function generateLinks()
/* JavaScript functions needed to show a view with alternate row colors
Created by Eva Valenta 2003-05-13 (copied and sligthly modified from SearchDomino.com)
*/
// the following are the variables that control the table width and colors
// change this as u need...can also convert to global vars by declaring in jsheader and initiliazing onLoad
tdClassEven = "even";
tdClassOdd = "odd";
/**
This function provides the alternate row coloring for the table generated by the view.
*/
function transformView(tableIndex,IsEmbedded)
{
if (IsEmbedded == false)
{var tableElements = document.getElementsByTagName('table')}
else
// To handle Embedded view in a form, The embedded view must be
// enclosed by div tags. See below example
//
Marked as "Pass thru HTML"
// Your embedded view
//
Marked as "Pass thru HTML"
{var tableElements = document.getElementById('StripedRows').getElementsByTagName('table')}
//
var table = tableElements[tableIndex] ;
table.className="tabTable";
rows = table.getElementsByTagName("tr") ; //get the rows of the table we are transforming
for( i = 1; i < rows.length; i++)
{
cells = rows[i].getElementsByTagName("td"); //get the cells of the row
// this is a normal row
for (j = 0; j < cells.length; j++) // just set the class
{
cells[j].className = (i % 2 ? tdClassEven : tdClassOdd) ;
}
}
}
/* -----------------------------------------------------------------------------------------------------------------------
Generate Main title
----------------------------------------------------------------------------------------------------------------------- */
function mainTitle(title) {
// this function generates the title as required by seb.se
// Note that the same function exists twice in this database -
// - as a part of JavaScript library common.js - should be used on normal pages/forms
// - as a Subform - should be used on JavaScript forms
// author Eva Valenta 2003-12-10
if (title != '') {
document.writeln('');
document.writeln('');
document.writeln('');
document.writeln('| ' + title + ' | ');
document.writeln('');
document.writeln('');
document.writeln('');
document.writeln('');
document.writeln(' | ');
document.writeln(' ');
document.writeln(' ');
document.writeln(' | ');
document.writeln('
');
document.writeln('');
document.writeln('
');
}
}
/* --------------------------------------------------------------------------------------------------
This function opens the Help window
--------------------------------------------------------------------------------------------------- */
function openHours(key) {
url2db = window.location.pathname.toLowerCase();
var nsfPos = url2db.indexOf(".nsf");
url2db = url2db.substr(0,nsfPos + 5);
helpurl = url2db + "OpenHours/" + key + "?openDocument";
var w = 520;
var h = 380;
var specs = "top=" + (screen.height-(h + 60)) + ",left=" + (screen.width-(w + 16));
specs = specs + ",scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes" ;
specs = specs + ",width=" + w + ",height=" + h ;
var old ="width=400,height=360,status=no,resizable=1,menubar=0,toolbar=0,directories=0,location=0,scrollbars=no,left=500,top=150";
NewWindow = window.open(helpurl,"Hours",specs);
NewWindow.focus();
}