GoogleTiddlyWikiCodePrototype

From TiddlyWikiGoogleTagCombinations

// JavaScript Document
//<script type="text/javascript">

//<!--
/* Linklist variable contains list of selected links */
var linklist = '';
/* SearchPrefix - search URL (customizable search engine) before Search Query */
var SearchPrefix='http://www.google.com/search?q='

/* SearchSuffix - search URL (customizable search engine) after Search Query */
var SearchSuffix='&hl=en';

/* FP_getObjectByID - cross-browser get object by id (made by expression web aka frontpage) */
function FP_getObjectByID(id,o) {//v1.0
 var c,el,els,f,m,n;

 if(!o)o=document;

 if(o.getElementById) el=o.getElementById(id);
 else if(o.layers) c=o.layers;
 else if(o.all) el=o.all[id];

 if(el) return el;

 if(o.id==id || o.name==id) return o;
 if(o.childNodes) c=o.childNodes;

 if(c)
   for(n=0; n<c.length; n++) {
    el=FP_getObjectByID(id,c[n]);
    if(el) return el;
   }

 f=o.forms;

 if(f)
   for(n=0; n<f.length; n++) {
   els=f[n].elements;

   for(m=0; m<els.length; m++){
    el=FP_getObjectByID(id,els[n]);
    if(el) return el;
   }
 }

 return null;
}

/* doCheck - will toggle between whether link is selected for searching or not
 * sender - check box triggering this function
 * link - link text
 */
function doCheck(sender, link) {
	if (linklist.match(escape(link)) == null) { //if link has been selected already //.. fp
		linklist += ',' + escape(link); //add link to link list
		sender.checked = true; /*make sure that checkbox is checked, in case the user
returned to the page via the browser's back button, but the browser remembered only the checkbox value */
	} else { //if the link has been selected
//		linklist = linklist.replace(new RegExp("," + escape(link), "gi"), ""); /*
		linklist = linklist.replace("," + escape(link), ""); /* .. fp: do we really need Regs and case-insensitivity
remove link from link list*/
		sender.checked = false; /*make sure that checkbox is unchecked, in case the user
returned to the page via the browser's back button, but the browser remembered only the checkbox value */
	}
}

function goSearch() {
// launches the Search with the TagCombination as Search Term

	var links = linklist.split(',');  // creates an array of the checked links based on linklist

  var searchUrl = SearchPrefix; // the Google search term ..

  for (var x in links) { // .. successively filled with the checked links
		searchUrl += links[x] + '+'; // the last superfluous plus-sign doesn't do any harm
	}
	location.href = searchUrl + SearchSuffix; // start the combined Google search
}

var quoteChar="\"";

function quote(s) {
return quoteChar+s+quoteChar;
}

var ahref="<a href=\"";
var searcher="test";
var GoogleIcon="http://images.aboutus.org/images/1/18/GoogleIcon.png";
var QuotedGoogleIcon=quote(GoogleIcon);

function g(s,t) { // GoogleDoubleLinkWithOptionbox
//document.writeln("<a href="+ quote(SearchPrefix + quote(s))+ "> ");
//document.writeln("<img src=" + quote(GoogleIcon) + " alt="+quote("(Google)") + " style="+quote("border-style: none;") +" /></a>");
  document.write("<input type=\"checkbox\" onclick=\"doCheck(this,"  + "\'"+s + "\'" + ");\""  + " />");
  document.write(" <a href=\"http://AboutUs.org/" +  s  + "\"" + ">" + s + "</a>");
//  document.write("<XMP>")
  document.write(" " + t +" ");
//  document.write("</XMP>")

};


// -->
//</script>

An application example

You can see, test and download the following application example in real life at Meatball:GoogleTagWiki.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Link text</title>
<script src="GoogleTag.js"></script>
</head>

<body>
<a name="top"></a>
<button onClick="goSearch();">Click here to search for a GoogleTagCombination!</button>
<p />

<script>
/*g("WikiTag");
g("TagCombination");
g("GoogleTag");
g("GoogleTagCombination");
g("TagWiki");
g("GoogleTagWiki");
g("AboutUs");
g("Vartan");
g("TedErnst");
g("fridemar");

gap(3);
*/

g("WikiTag","is the WikiWord replacement, allowing combined searches. Several WikiTags form a");
g("TagCombination","i.e. one or more checked OptionBoxes form a TagCombination. A");
g("GoogleTag","A CamelCase search term, that can be combined with other such terms.");
g("GoogleTagCombination","is a TagCombination for Google searches");
g("TagWiki","is a Wiki, where WikiTags replace WikiWords");
g("GoogleTagWiki","A wiki, whose WikiWords are GoogleTags.");
g("AboutUs","A giant wiki, for open collaboration.");
g("Vartan","is the young script programmer of this prototype in AboutUs.Org .");
g("TedErnst","motivated Vartan, to make the prototype.");
g("fridemar","initiated the idea and is a bit messing around with Vartan's code. ;-)");
</script>


</body>

</html>


Retrieved from "http://aboutus.com/index.php?title=GoogleTiddlyWikiCodePrototype&oldid=16013837"