Archive for the ‘web stuff’ Category

RJ’s interesting Form data problem

Sunday, November 22nd, 2009

 AJAX file upload tutorial

So I was trying to figure out how I could upload a file without refreshing the page for a form that I am creating and boy was it a pain. I found this post here (http://www.ajaxf1.com/tutorial/ajax-file-upload-tutorial.html) that allowed me to do the file upload part without refreshing the page. I was ecstatic and thankful to Ajaxf1 when I got it to work.

It is worthwhile to mention that although this comes from a website called ajaxf1 the way that he/she does this upload does not use Ajax it loads the action of the upload form in a hidden iframe not using the xmlhttp object.

But unfortunately my joy was short lived. I soon noticed that I didn’t know how to get the URL of the uploaded image into my form data that would eventually go into my database. After some time lamenting and 2 hours of banging my head against the wall I discovered a very simple solution, shockingly simple actually. I have posted it here because I haven’t seen it anywhere else.

in the upload.php file which can be found at the link above you just change the call to the javascript function like so:

<?php

echo(‘<script language="javascript" type="text/javascript">
window.top.window.stopUpload(‘.$result.’,"’.$target_path.’");
</script>’)

?>

$result is success or not and $target_path is the URL of the uploaded image. Then modify the stopUpload function like so:

function stopUpload(success, pic){
      var result = "";
      if (success == 1){
      document.getElementById("result").innerHTML = "<span class=’msg’>The file was uploaded successfully!</span><br/><br/>";
        document.getElementById("hiddenpic").value = pic;
        }
         else
        {
        document.getElementById("result").innerHTML = "<span class=’emsg’>There was an error during file upload!</span><br/><br/>";
                }
        document.getElementById("f1_upload_process").style.visibility = "hidden";
        return true;
        }

What this ends up doing is that if success = 1 it modifies a hidden field in my form called hiddenpic with the URL of the uploaded image, which was passed into the formula in upload.php.

Oh one other interesting thing is that you cannot nest form tags. If you place the file upload form within your original form clicking upload on the form will submit the form that the upload form is nested within.

If you want it to look as though the upload form is part of the original form you will have to do some fancy css placement tricks.

Hopefully one day someone will find this useful. For the entire explanation of the whole “Ajax”( although it is not really Ajax) upload process go to the original site here.

Peace out ya’ll! hopefully this was not that boring of a read haha.

RJ’s Thoughts on the Google Chrome OS

Monday, July 13th, 2009

Last week Google announced that they would be releasing an operating system at some point next year. Of course the media went crazy over it, saying that now Google was stepping into Microsoft’s operating system arena. But they are not. Google is creating something totally different from windows. Yes it is an operating system but it is going to be a cloud operating system specializing in web applications and extremely light weight use. But just because it is not made to directly compete with Microsoft’s current Windows OS doesn’t mean Microsoft won’t be worried/pissed about it. Because they probably wanted to sell something similar down the line and now Google is going to give it away for free. But that’s neither here nor there. I, personally, would have absolutely no use for that piece of crud. People who use their computer solely for reading Facebook, posting on twitter, typing essays, and sending emails though, would have a use for such an operating system.

I really don’t understand what the big deal is. Google’s Chrome OS will probably be a flop. In the past all of Google’s forays into sources of business other than search and ads have pretty much failed. One example is the Android OS. So far it has very limited usage its  heavily overshadowed by the iPhone and now it has Palm’s WebOS to deal with also. And other things like Google Apps and all the random things that they have come out with in recent years definitely have not been cash cows. I am actually wondering how many new and pointless services will be coming from Google’s campus as this recession continues (hopefully it ends soon though). Google Wave I believe is due at the end of the year we’ll see how that does…

Google’s Chrome OS is cool, I guess, for people who are into low powered computing. But it has gotten me thinking even about my current computer and online storage usage. I think that I am already too jacked into Google. I use one Gmail account for all of my mail. I have probably six other accounts going into this one Gmail account. What does this mean? Whenever I get an email Google gets a chance to examine it and use it to learn about what I am doing and then sell ads to me more efficiently. Granted I never click on Adwords ads but but the point is that Google sees all of my data and mines it for information about me. The Chrome OS would be one thousand times worse! I bet some people would save the entire contents of their My Documents folder up on the “cloud” so that they would have access to it everywhere. But the user is not the only person with access to all that data. Google has access, Google’s employees have access, any crazy computer hacker could get access. Just like the damn hackers got my Social Security number out of UCLA’s database they could get info out of Google.

The announcement about this Chrome OS really has me thinking about how I have been using my computer recently. And I have been way to dependant on Google. I think it is back to Outlook for me because I don’t want anyone data-mining my private and/or business emails.

Oh and one last thing! all of the benefits of the “cloud” can be achieved with some minor tweaking of Windows, Linux, or even OS X. All you need to do is set up and ftp server(IIS and Apache can do this). You can share whatever you want to share and password protect it so that only you can get to it. You could even create new accounts on your computer so that others could log in and have access. You could also set up your entire hard drive to be the shared area for the FTP server (although I wouldn’t recommend it). But then I guess you wouldn’t have the collaboration benefits but at least nobody would be searching through your data and trying to sell crap to you. If you need collaboration use Google chat or something else. Personally, I use Pidgin. Pidgin is an open source instant messaging application that supports a plethora of chatting standards. You should check it out. The main benefit of this is that YOU are in control of your data. It is local to your computer and nobody will get to it except the people you want, and probably hackers. Provided that they know about you and you have something they want.

In conclusion, the Google Chrome browser is great, the Google Chrome OS will not be great, for me at least. I need the power! It seems like Google has its hands on the lid of Pandora’s box and is about to open it. And no I am not talking about online music streaming.

Peace out ya’ll. I’ve got a test to take.

RJ’s Internet Explorer Hate Number 3!

Friday, July 10th, 2009

from the user’s end Internet Explorer is probably the most friendly to your average computer user. But what people don’t know about is the freaking gargantuan number of man hours going into making websites work with internet explorer.

General random html like tables and what not display pretty much the same in any browser provided that your table has been written properly but once you start to get into CSS for positioning sometimes Internet Explorer uses a different method to place things on the page, which then requires using non-standard html and stupid browser specific html conditional statements. Arrg!! if you care these are IE conditional comments

 <!—[if IE]> blah blah blah <![endif]—> 
 <!—[if gte IE 6]> blah blah blah <![endif]—>
 <!—[if lte IE 6]> blah blah blah <![endif]—>
 <!—[if gt IE 6]> blah blah blah <![endif]—> 
 <!—[if lt IE 6]> blah blah blah <![endif]—>

gte is greater than or equal to lte less than or equal to and so on and so forth. This is an example of Internet Explorer specific comments

<comment>this text would not show up in IE</comment>

So now pages can be riddled with redundant code and it just gets confusing and messy. But whatever not much you can do about it.

But my most recent issue had no solution! conditional comments or whatever could not take care of it. I was adding in a fade in/fade out to a user initiated page switching (done by onclick attribute on an anchor tag) and everything worked fine and dandy. All the text faded nicely and came back in nicely, on every browser except IE.

On Internet Explorer you have to use an alpha filter to achieve different levels of opacity. It is a complicated syntax and on top of that, it turns off cleartype. And actually any of the filters in IE will turn off cleartype when used on text, I don’t think you would notice it on pictures but that is besides the point.

So the user clicks on the link to switch the pages and then the text loses cleartype, and it is a noticeable change and then even when the text comes back to full opacity it still has cleartype turned off. So what you have is this nasty jagged edged, internet 1.0, type looking font that is difficult to read. This is friggin ridiculous!

But! there is a solution! all you have to do is add more code! and here is the line of code that needed to be added.

document.getElementById('textdiv').style.removeAttribute("filter");

this line removes the IE filter after the text becomes 100% opaque. this is the only solution to the problem with fade effects on text, other than getting a better browser. After the filter is removed cleartype is automatically restored.

The only problem with this is that even in the short amount of time it takes for the effect the removal and addition of cleartype is very noticeable. But all things considered it is good enough.

I think the best solution to this problem, though, would be to fade text in and out by changing the colors of the text. But changing from some off the wall red color to white would be annoying to do and then you have a lot of work to do if the customer decides that they want a different color behind the text.

Eh whatever hopefully this will help someone some day when they are doing something similar.