Showing posts with label html. Show all posts
Showing posts with label html. Show all posts

Wednesday, 4 September 2013

How to resize and crop Image Using Coldfusion script

I had requirement on my site www.eventaway.com  to resize Image after uploaded by user in two sizes one for view page and one as thumbnail, I found some script on web and improved it to fit in my requirement. here it is. I expect this code will reside in a CFC function



var l = {}; // local struct

/* Read file  and we will resize and crop it to make 200×200 */

l.img = ImageRead(“path of the image to be resized”);

l.resizeOriginalFlag = 0;
If( l.img.height GT l.img.width )
{
If( l.img.height GT 200)
{
ImageResize( l.img,’200′,”);
l.resizeOriginalFlag = 1;
l.fromX = l.img.Height / 2 – 100;
ImageCrop(l.img,0,l.fromX,200,200);
}
}
else if( l.img.width GT l.img.height )
{
If( l.img.width GT 200 )
{
ImageResize( l.img, ”,’200′);
l.resizeOriginalFlag = 1;
l.fromY = l.img.Width / 2 – 100;
ImageCrop( l.img,l.fromY,0,200,200);
}
}
else
{
If( l.img.height GT 200)
{
ImageResize(l.img,’200′,”);
l.resizeOriginalFlag = 1;
ImageCrop(l.img,0,0,200,200);
}
}




source=”#l.img#”
destination=”
overwrite=”yes”>

<!— <cfdump format="”html”" output="”/sites/resize.html”" var="”#cfcatch#”"> —>



Where do you need to use javascript MV* framework

I like following while I was reading an article on javascript frameworks: I thought it is worth repeating:

So, where will you likely need an MV* framework and where won’t you?

If you’re writing an application that will likely only be communicating with an API or back-end data service, where much of the heavy lifting for viewing or manipulating that data will be occurring in the browser, you may find a JavaScript MV* framework useful.

Good examples of applications that fall into this category are GMail and Google Docs. These applications typically download a single payload containing all the scripts, stylesheets and markup users need for common tasks and then perform a lot of additional behavior in the background. It’s trivial to switch between reading an email or document to writing one and you don’t need to ask the application to render the whole page again at all.

If, however, you’re building an application that still relies on the server for most of the heavy-lifting of Views/pages and you’re just using a little JavaScript or jQuery to make things a little more interactive, an MV framework may be overkill. There certainly are complex Web applications where the partial rendering of views can* be coupled with a single-page application effectively, but for everything else, you may find yourself better sticking to a simpler setup.

Thursday, 5 November 2009

Java script trim function

I have used this trick in different places and sometimes when I need it again, I always forget, tahts why I am putting it here:

function AllTrim(str) // call this function if you want to remove spaces from both sides
{
str = LTrim(str);
str = RTrim(str);
return str;
}
function LTrim(str) // this function removes spaces from left
{
return str.replace(/^\s+/g,'');
}
function RTrim(str) // this function removes spaces from right
{
return str.replace(/\s+$/g,'');
}

Thursday, 24 September 2009

SEO Tips and links

I was reading through some good articles about SEO (Search Engine optimization) tips, and come across really good articles and article about how to write Robots.txt file to allow or disallow content or directories of your web site, you want or dont want to be searched/ indexed.

1) Top 10 ways to link popularity - its really a good article on what one should do to improve popularity of his site.

http://www.free-seo-news.com/ways-to-link-popularity.htm

2) Improving your search-engine status - Its a tutorial in 4 parts on how to improve your sites rating score.

http://www.softsteel.co.uk/tutorials/search/searchIndex.html

Part 1: http://www.softsteel.co.uk/tutorials/search/part1.html etc

3) How to improve your Page Ranking: This is an article which helps to improve page ranking and tells seven things to take care of:

http://www.squidoo.com/OptimizationforGoogleRating

4) Tutorial to Improve and Achieve Higher Search Engine Placement and Positions: Its a good tutorial to learn about search engine rankings

http://www.tsworldofdesign.com/search_engine/higher_placement.htm

also one interesting one: http://www.kensavage.com/archives/the-basic-principles-of-seo/

5) Here are few links to help you learning how to write robots.txt

http://www.free-seo-news.com/all-about-robots-txt.htm

http://sandeepdharak.blogspot.com/2009/09/how-write-robotstxt-file-seo-google.html

enjoy above articles

Tuesday, 21 April 2009

How to make call using Ajax/ JQuery

First thing you got to include Jquery library
Second thing:
create some functions inside jqueries ready function like this:
$(document).ready(
function()
{
// if you want to take any action on load
});
Third:
There are few ways to do this call and here are 3 ways of them:

1) This is a get call
$("#DivToDisplayResult).load('pageToBeCalled.cfm',{
Param1: param1value,
Param2: param2value,
Param2: param2value,
Param2: param2value,
……..
},
// following function is required, which is being called after we get the result back
function(responseText, textStatus, XMLHttpRequest){
//alert(responseText);
}
2) $.getJSON('pageToBeCalled.cfm',{UserProfileCode: userProfCode}, function(j){
// here you can put the action and you would get result in “j” variable
// like
$("#divName").html(j);
});
3) Post
$.post(
pageToBeCalled.cfm,
{
Param1: param1value,
Param2: param2value,
Param2: param2value, },
function(j) {
//here you can take action by reading “j” variable
}
);