Team:Warsaw/JSTest

From 2008.igem.org

(Difference between revisions)
 
(8 intermediate revisions not shown)
Line 6: Line 6:
-
<script src=http://adamv.com/dev/javascript/files/querystring.js"></script>
+
 
<script type="text/javascript">
<script type="text/javascript">
 +
/* <![CDATA[ */  
/* <![CDATA[ */  
 +
 +
/* Client-side access to querystring name=value pairs
 +
Version 1.3
 +
28 May 2008
 +
 +
License (Simplified BSD):
 +
http://adamv.com/dev/javascript/qslicense.txt
 +
*/
 +
function Querystring(qs) { // optionally pass a querystring to parse
 +
this.params = {};
 +
 +
if (qs == null) qs = location.search.substring(1, location.search.length);
 +
if (qs.length == 0) return;
 +
 +
// Turn <plus> back to <space>
 +
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
 +
qs = qs.replace(/\+/g, ' ');
 +
var args = qs.split(String.fromCharCode(38)); // parse out name/value pairs separated via &
 +
 +
// split out each name=value pair
 +
for (var i = 0; i < args.length; i++) {
 +
var pair = args[i].split('=');
 +
var name = decodeURIComponent(pair[0]);
 +
 +
var value = (pair.length==2)
 +
? decodeURIComponent(pair[1])
 +
: name;
 +
 +
this.params[name] = value;
 +
}
 +
}
 +
 +
Querystring.prototype.get = function(key, default_) {
 +
var value = this.params[key];
 +
return (value != null) ? value : default_;
 +
}
 +
 +
Querystring.prototype.contains = function(key) {
 +
var value = this.params[key];
 +
return (value != null);
 +
}
 +
 +
Array.prototype.indexOf = function( v, b, s ) {
Array.prototype.indexOf = function( v, b, s ) {
Line 24: Line 68:
}
}
-
function removeHTMLTags(strInputCode ){
+
function removeHTMLTags(strInputCode2 ){
-
strInputCode = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1){
+
                var strInputCode=new String();
 +
                strInputCode=strInputCode2;
 +
                //if (strInputCode==undefined) return;
 +
/*
 +
                strInputCode = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1){
return (p1 == "lt")? "<" : ">";
return (p1 == "lt")? "<" : ">";
});
});
 +
                */
 +
                strInputCode = strInputCode.replace(/&(lt);/g,"<");
 +
                strInputCode = strInputCode.replace(/&(gt);/g,">");
var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, "");
var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, "");
return strTagStrippedText;
return strTagStrippedText;
Line 95: Line 146:
if (titles[i].search("h3")>0)  
if (titles[i].search("h3")>0)  
{
{
 +
//alert(titles[i].split(/(<h3>)|(<\/h3>)/i));
var notags=titles[i].split(/(<h3>)|(<\/h3>)/i);
var notags=titles[i].split(/(<h3>)|(<\/h3>)/i);
-
 
+
if (notags[3]==undefined) var currtitle=removeHTMLTags(notags[0]);  //dirty IE hack
-
var currtitle=removeHTMLTags(notags[3]);
+
else var currtitle=removeHTMLTags(notags[3]);
currtitle=trimStr(currtitle.replace(/\+/g,' '));
currtitle=trimStr(currtitle.replace(/\+/g,' '));
//alert ("C: "+currtitle+"\nT: "+title);
//alert ("C: "+currtitle+"\nT: "+title);

Latest revision as of 18:40, 28 October 2008

Gallery Bricks Notebook Team Project Home