Showing posts with label java script. Show all posts
Showing posts with label java script. Show all posts

Sunday, July 18, 2010

Add Bookmark over JS

//add-bookmark
//function bookmark(anchor){
if(window.external)
{
window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title'));
return false;
}
return true;
}
//]]>

Friday, April 02, 2010

format my source code for blogger.com

Format My Source Code for Blogging

A javascript web application application that will format source code text into html for inserting into your blog.


http://formatmysourcecode.blogspot.com/

Wednesday, May 06, 2009

Monday, October 27, 2008

ajax status display like google apps

during cleanup of my files i found the following Javascript status display js class.

unfortunately i don't know from where i have downloaded it, so if you know let me know that I can update this entry and add a link to the owner.

var ajaxStatus = Class.create();
ajaxStatus.prototype = {
ajaxStatusDisplayUserMessageElementID: 'ajaxStatusDisplay_userMessage',
ajaxStatusContainerID: 'ajaxStatusContainer',
ajaxStatusContainerCssClass: 'ajaxStatusDisplay_userStyle',
userDefinedAjaxStatusContainerCssClass: false,
ajaxStatusMessageContainerID: 'ajaxStatusMessageContainer',
ajaxStatusMessageContainerCssClass: 'ajaxStatusDisplay_userMessageStyle',
userDefinedAjaxStatusMessageContainerCssClass: false,
useUserCssStylesContainerID: 'ajaxStatusDisplay_useUserCssStyles',
statusMessage: 'Loading...',
useUserCssStyles: false,
/*
Function: initialize
Description: Creates the hidden status display elements and configures
the default status message and css styles
*/
initialize: function() {
// Create the ajax status container
Element.insert(
$$('body')[0],
{'bottom':
new Element('div', {
id: this.ajaxStatusContainerID,
style: 'display: none'
})
}
);

// Create the ajax status message container
Element.insert(
$(this.ajaxStatusContainerID),
{'bottom':
new Element('div', {
id: this.ajaxStatusMessageContainerID
})
}
);

// Setup the css styles
this.setCssStyles();

// Setup the status message text
this.setStatusMessage('');

// Register the global Ajax responders
// to show hide the status container
Ajax.Responders.register({
onCreate: this.toggle.bindAsEventListener(this),
onComplete: this.toggle.bindAsEventListener(this)
});
},
setCssStyles: function() {
// If the user has defined styles
if (document.styleSheets.length > 0) {
var theRules = new Array();

// If this is Firefox or other W3C complient browser
if (document.styleSheets[0].cssRules) {
theRules = document.styleSheets[0].cssRules;
}
// If this is IE
else if (document.styleSheets[0].rules) {
theRules = document.styleSheets[0].rules;
}

// Loop over the css rules
for (i = 0; i < theRules.length; i++) {
// If the current rule matches the name of the ajax status container css class
if (theRules[i].selectorText == '.' + this.ajaxStatusContainerCssClass) {
this.userDefinedAjaxStatusContainerCssClass = true;
}
// If the current rule matches the name of the ajax status message container css class
else if (theRules[i].selectorText == '.' + this.ajaxStatusMessageContainerCssClass) {
this.userDefinedAjaxStatusMessageContainerCssClass = true;
}
}
}

// If the user definfed css styles with the specific name
// for the ajax status container
if (this.userDefinedAjaxStatusContainerCssClass) {
// Set css class name for the container
$(this.ajaxStatusContainerID).addClassName(this.ajaxStatusContainerCssClass);
}
else {
// The user has not defined the custom css style class
// so apply default style
$(this.ajaxStatusContainerID).setStyle({
position: 'absolute',
left: '45%',
top: '2px',
height: '10px'
});
}

// If the user definfed css styles with the specific name
// for the ajax status message container
if (this.userDefinedAjaxStatusMessageContainerCssClass) {
$(this.ajaxStatusMessageContainerID).addClassName(this.ajaxStatusMessageContainerCssClass);
}
else {
// The user has not defined the custom css style class
// so apply default style
$(this.ajaxStatusMessageContainerID).setStyle({
background: '#FFF1A8 none repeat scroll 0%',
color: '#000',
padding: '0pt 5px',
fontFamily: 'Arial, Helvetica, sans-serif',
fontSize: '14px',
fontWeight: 'bold',
textAlign: 'center',
width: '100%'
});
}
},
setStatusMessage: function(statusMessage) {
if (!statusMessage.empty()) {
this.statusMessage = statusMessage;
}
else {
// If there is an element on the page with a user defined status message
if ($(this.ajaxStatusDisplayUserMessageElementID)) {
// If the user's status message is inside a input element
if ($(this.ajaxStatusDisplayUserMessageElementID).readAttribute('value') != null) {
// Use the value of the input element
// for the display as the status
this.statusMessage = $F(this.ajaxStatusDisplayUserMessageElementID);
}
else {
// Use the value of the element for the display as the status
this.statusMessage = $(this.ajaxStatusDisplayUserMessageElementID).innerHTML;
}

// Hide the user's status message container
$(this.ajaxStatusDisplayUserMessageElementID).hide();
}
}

$(this.ajaxStatusMessageContainerID).update(this.statusMessage);
},
toggle: function() {
$(this.ajaxStatusContainerID).toggle();
}
};

document.observe("dom:loaded", function() {
// Create an instance of the object defined above
ajaxStatusDisplay = new ajaxStatus();
});

Saturday, October 11, 2008

jQuery.com and Microsoft .Net

I think you have read and heard already about a javascript framework called: jQuery this js framework seems to grow and grow ... almost endless. Since Microsoft (Scott Guthrie http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx) announced they gone integrate this framework into Visual Studio they decided finally a takeover a community project into their environment instead to develop something new from scratch. My personal point of view, this is the right decision and they should do this with more projects.

Friday, July 18, 2008

Improve Web Application Performance

Introduction

In the IT world, software applications are being rapidly developed. Clients, and so employers, are just looking for those teams/individuals who can build up applications rapidly, just bothering to make their application live; but what often happens after an application goes live is that users start to use the application and it doesn’t respond well. At this point, clients start to lose users and business.To code an application is not a big deal; I believe it can be done by virtually anyone, meaning it is not necessary to have great knowledge or experience. Improving performance of an existing application (especially an one put together rapidly) could be quite risky and could cause many ripple effects. Things must be planned first to avoid horrible results.The following are a few points that can make a site scalable and reliable; but which may initially slow down development. I believe that overall, when maintenance and future changes are taken into account, total development time would be reduced.

1. Minimize HTTP based Requests
2. HTTP Compression:
3. Correct Formatted Images at the Right Place:
4. Compress CSS, JavaScript and Images
5. CSS at Top
6. Javascript at Bottom
7. Content Delivery Network: (CDN)
8. Ajax
9. Ajax vs. Callback
10. Reduce Cookie size
11. Use Cache appropriately
12. Upload compiled code rather than source code

Following are few good practices to gain better performance:

  • For HTTP compression, GZip is considered the most effective and most popular by means of browsers and HTTP server. It can reduce file size up to 70% in size.
  • Always keep JavaScript and CSS in external files.
  • Avoid redirects until needed. Server.Transfer is also provided so consider that as well since it performs better in some conditions.
  • Minimize use of Iframes as it's costly.
  • Avoid try-catch blocks for control-flow as they perform poorly. Exceptions should be used only in truly exceptional situations.
  • Minimize Cookie/CSS sizes.
  • Minimize DOM objects on page as they are heavy weight.
  • Use link tags rather than @import to use/link up CSS.
  • Favicon, being a static image displayed in the browser’s address bar, should be cacheable and compressed.
  • Always prefer a cache-friendly folder structure. For example, create specific folders for static contents, like /static for static images/static pages.
  • SSL can never be cached so minimize its usage. Keep it for those pages which need to be secure, rather than using it for all the pages.
  • HTTP Post requests can’t be cached, so choose the HTTP method appropriately.
  • Prevent Denial of Service (Dos) attacks.
  • Prevent SQL Injection.
  • Prevent Cross Site Scripting (XSS).

Read the full article by dr.honey (IT SURGEON) at the following link: http://developerscon.blogspot.com/2008/06/improve-web-application-performance.html

Saturday, January 19, 2008

Thursday, May 31, 2007

JavaScript setAttribute vs IE

http://justinfrench.com/index.php?id=25 thanks mate you saved me hours of work :-)

short version:

IE seems to have a problem while you use per JavaScript the function setAttribute for the onClick event.

as justin mention, here the solution:

document.getElementById('YourEle').setAttribute('onClick', "myFunc(null);");
/*IE6/7 ISSUE!!!*/
document.getElementById('YourEle').onclick = function() {myFunc(null);};

Tuesday, August 22, 2006

Sunday, April 16, 2006

javascript code

Great Java Script Code snippets.

javascript code

Ajaxload - Ajax loading gif generator

Great Idea, simple and very usefull :-)

Ajaxload - Ajax loading gif generator



a sample page is available at:

Loading.htm

Shared Cache - .Net Caching made easy

All information about Shared Cache is available here: http://www.sharedcache.com/. Its free and easy to use, we provide all sources at codeplex.

Facebook Badge