TellmeaboutUrl = SNIP_BASE + "tellmeabout/tellmeabout-service.php"; //function tellmeabout(id,text,callback,includeNoActions) { // if ( arguments.length < 4 ) includeNoActions = false; function tellmeabout(id,text,callback,opts) { if ( arguments.length < 4 ) opts = {}; doAjaxCall(TellmeaboutUrl,{ text: text, op: 'actions', key: opts.key },tellmeaboutResponse,{ id: id, text: text, callback: callback, includeNoActions: opts.includeNoActions }); } //function tellmeabout_snip(id,snipid,callback,includeNoActions) { // if ( arguments.length < 4 ) includeNoActions = false; function tellmeabout_snip(id,snipid,callback,opts) { if ( arguments.length < 4 ) opts = {}; doAjaxCall(TellmeaboutUrl,{ snipid: snipid, op: 'actions', key: opts.key },tellmeaboutResponse,{ id: id, snipid: snipid, callback: callback, includeNoActions: opts.includeNoActions }); } //function tellmeabout_url(id,url,callback,includeNoActions) { // if ( arguments.length < 4 ) includeNoActions = false; function tellmeabout_url(id,url,callback,opts) { if ( arguments.length < 4 ) opts = {}; doAjaxCall(TellmeaboutUrl,{ text: url, type: 'url', op: 'actions', key: opts.key },tellmeaboutResponse,{ id: id, url: url, callback: callback, includeNoActions: opts.includeNoActions }); } function tellmeaboutResponse(status,ajaxreq,data) { //debug("tellmeaboutResponse: "+status); var text = data.text; var callback = data.callback; var req_id = data.id; var includeNoActions = data.includeNoActions; if ( ! status ) { //debug("tellmeaboutResponse(" + req_id + "): "+status); return; } var xml = ajaxreq.responseXML; var xmlMatches = xml.getElementsByTagName("match"); //debug("nos matches = "+xmlMatches.length); var matches = new Array(); var nosMatches = 0; for ( n=0; n 0 ) { //debug(match.type + " has " + match.actions.length + " actions"); matches[nosMatches++] = match; } } callback(req_id,matches); } function readMatch(xmlMatch) { var type = xmlMatch.getElementsByTagName("type")[0].firstChild.nodeValue; var title = xmlMatch.getElementsByTagName("title")[0].firstChild.nodeValue; var actionsXML = xmlMatch.getElementsByTagName("action"); var nosActions = actionsXML.length; //debug("readMatch: type="+type); var actions = new Array(); for ( var c = 0; c lookup words like "text" in thesaurus.com http://www.thesaurus.com/cgi-bin/search?config=roget&words=text */ function readAction(actionXML) { //debug("readAction:"); //debug("readAction trim( abc ): (" + trim(" abc " ) + ")"); //debugXML(actionXML); //var description = trim( actionXML.getElementsByTagName("description")[0].firstChild.nodeValue ); var description = getElementText(actionXML,"description"); //debug("description OK"); //var url = trim( actionXML.getElementsByTagName("url")[0].firstChild.nodeValue ); var url = getElementText(actionXML,"url"); //debug("url OK"); //var info = trim( actionXML.getElementsByTagName("info")[0].firstChild.nodeValue ); var info = getElementText(actionXML,"info"); //debug("info OK"); var iconXML_list = actionXML.getElementsByTagName("icon"); //debug("iconXML_list OK"); var icon, iconW, iconH; if ( iconXML_list.length > 0 ) { var iconXML=iconXML_list[0]; icon = iconXML.getAttribute('src'); iconH = iconXML.getAttribute('width'); iconW = iconXML.getAttribute('height'); } else { icon = ""; iconH = 0; iconW = 0; } //debug("finished readAction {description: "+description+", url: "+url+", info: "+info+" }"); return { description: description, url: url, info: info, icon: icon, iconW: iconW, iconH: iconH }; }