Wednesday, November 11, 2009

How to have clickable links in Yahoo Answers

I came across this problem when first starting giving answering questions on Yahoo Answers. You'd paste a link into an answer and when you view the submited answer, the link is not active (not clickable). It's just part of the text of the answer.

Well, after not getting many answers about from Yahoo Answers, I stumbled on the solution myself after answering more.

You have to get to Level 2 of Yahoo Answers in order for your links to be clickable.

Sunday, November 8, 2009

Easy Object Call HTML DOM / JavaScript

Here's a handy little function that I use a lot. Instead of having to call document.getElementById('example_tag') which is long and half the time I mis-capitalize the "getElementById", this function saves time and errors with getEle('example_tag') The plus is that it also bypasses a potential error if the element is not there.
function getEle(str){
if(document.getElementById(str)){
return document.getElementById(str);
}
else{
return false;
}
}

Friday, November 6, 2009

JavaScript HTML to XHTML Converter for Yahoo's YUI 2 Rich Text Editor

The other day after installing Yahoo's Rich Text Editor, I noticed that the output of the editor was badly formed HTML that wouldn't validate on my XHTML site. So, since I'm a bit anal, I wondered if there was a way to convert the output. After only finding a few convoluted and licenced solutions, I figured it wouldn't be too hard to do it myself. So here it is in JavaScript.


function convertToXHTML(html){

var raw1 = html.split("<"); var xhtml = ""; var tags = ""; //Make Tags Lower Case and make sure that the tags are properly closed for(var i in raw1){ if(raw1[i].indexOf(">") != -1){
var raw2 = raw1[i].split(">");
var tagName = (raw2[0].indexOf(" ") > -1) ? raw2[0].split(" ")[0] : raw2[0];
tagName = tagName.replace(/\//g, "");
var endSlash = (html.indexOf("/" + tagName) == -1 ) ? " /" : "";
raw2[1] = (raw2[1]) ? raw2[1] : "";

if(raw2[0] != "" && raw2[0]){
var begin = "<" + raw2[0].replace(eval("/" + tagName + "/"), tagName.toLowerCase()); xhtml += begin + endSlash + ">" + raw2[1];
}
}
else{
xhtml += raw1[i];
}
}

//Make sure that the attributes listed below use quotes
xhtml = xhtml.replace(/align=center/gi, 'align="center"');
xhtml = xhtml.replace(/align=left/gi, 'align="left"');
xhtml = xhtml.replace(/align=right/gi, 'align="right"');

//Make sure the attributes are separated by a space
var arr = xhtml.match(/"[a-z]+="/gi);
for(var i in arr){
if(!isNaN(i)){
xhtml = xhtml.replace(eval("/" + arr[i] + "/gi"), '" ' + arr[i].slice(1));
}
}
return xhtml;

}



Unfortunately, this isn't a 100% fix. The Yahoo Editor sometimes nests the tags in an invalid way, and I have yet to correct for that. I also haven't tested this too much yet; so, there could be quite a few other things that this isn't designed to fix.

This is specifically to convert the output of Yahoo's text tool. This function fixes glitches that only this tool creates, and does not account for errors that you or another program might export.

Wednesday, November 4, 2009

Problem Pasting from Clipboard on Blogger

This has been bugging me since I started this blog. If you have Internet Explorer 8 and cannot copy and then paste text into your Blogger Post Textbox, just turn-on "Compatibility Mode".


Go to Tools / Compatibility Mode


While you're at it, you may as well set Blogger to be in compatibility mode into the future; so, got to Tools / Comaptibility Settings. This brings up a Menu Box. Enter "Blogger.com" into the text field at the top and click "Add" then click "Ok". This makes it so Blogger is in Compatibility Mode everytime you go here.




I haven't fully tested this to see if it makes anything else not work, but at least you can copy and paste. I found this here: http://www.google.com/support/forum/p/blogger/thread?tid=418da73cad5aa018&hl=en (I copied and pasted this while in compatibility mode).

Monday, November 2, 2009

URL Encode Calculation / Function for FileMaker Pro

This function is for when you send field data to a website with the "Open URL" Script Step, or if you're storing url encoded links.

Substitute (
INSERT FIELD NAME HERE
; ["¶" ; "%0D"]
; ["%" ; "%25"]
;[ "#" ; "%23"]
;[ "`" ; "%91"]
;[ "~" ; "%7E"]
;[ "!" ; "%21"]
;[ "@" ; "%40"]
;[ "$" ; "%24"]
;[ "^" ; "%5E"]
;[ "*" ; "%2A"]
;[ "(" ; "%28"]
;[ ")" ; "%29"]
;[ "-" ; "%2D"]
;[ "_" ; "%5F"]
;[ "=" ; "%3D"]
;[ "+" ; "%2B"]
;[ "" ; "%3A"]
;["\\" ; "%5C"]
;[ "]" ; "%5D"]
;[ "[" ; "%5B"]
;["{" ; "%7B"]
;[ "}" ; "%7D"]
;[ ";" ; "%3B"]
;[ ":" ; "%3A"]
;[ "'" ; "%27"]
;[ "\"" ; "%22"]
;[ "<" ; "%3C"]
;[ ">" ; "%3E"]
;[ "," ; "%2C"]
;[ "." ; "%2E"]
;[ "/" ; "%2F"]
;[ "?" ; "%3F"]
;[ "&" ; "%26"])

Now, I created this function about a year or two ago on my own, but out of curiosity, I just did a google search for "urlencode filemaker" and found an incredibly similar function on Brian Cummings FileMaker Pro Custom Functions page. So, out of fairness, I'll give him credit for his or his team's work,
but I swear I couldn't find his page when I made the calculation. However, my function does have a few more encoded characters.

Anyway, hopefully this will help anyone else out there looking for such a function.