ITeye博客

javascript

共 19 篇文章

Date/Time处理函数总结 [To Do]

几种我所用到的用来处理日期,时间的函数总结。 Perl localtime # 0 1 2 3 4 5 6 7 8 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); If parameter is not provides, it will use current time. Note the $year returned contains the number of years since 1900, to get a 4-digit year you need: $year += 1900; …

2013-04-12 10:46 · java · perl · python · javascript · shell

Execution Context in JavaScript

Do you know the output of the code below: (function() { console.log(typeof foo); // function pointer console.log(typeof bar); // undefined var foo = 'hello', bar = function() { return 'world'; }; function foo() { return 'hello'; } }());​ If you are not clear about this question, please read this ar…

2013-01-18 22:46 · javascript

Secrets of the JavaScript Ninja -- 1

**Chapter 3 Scoping and functions** Scoping rules in Javascript: Variable declarations are in scope from their point of declaration to the end of the function within which they are declared, regardless of block nesting. Look at this example: if(window){ var x = 13; } alert(x); // 13 Named functions…

2013-01-17 17:03 · javascript

使用ExtJS做动画效果

这是个动画效果的例子,作出一个小球弹跳然后静止. 先是一个div: 然后ExtJS代码: Ext.onReady(function(){ Ext.create('Ext.fx.Animator', { target: 'ball', duration: 5000, keyframes: { 0: { y: 50 }, 20: { y: 300 }, 40: { y: 175, backgroundColor: '#0000FF' }, 60: { y: 300 }, 80: { y: 275, backgroundColor: '#00FF00' }, 100: { y: 300 } } }…

2012-11-15 15:11 · javascript

ExtJs Event Delegation

Event handlers are a common cause of memory leaks and can cause performance degradation when not managed carefully. The more event handlers we create the more likely we are to introduce such problems, so we should try to avoid creating huge numbers of handlers when we don't have to. Event delegatio…

2012-11-15 14:06 · javascript

ExtJS 的event handler的scope

var button = Ext.create('Ext.button.Button', { text: 'My Test Button', listeners: { click: function(button, e, options){ alert(this.text); } }, renderTo: Ext.getBody() }); button.show(); 上面的代码结果是My Test Button var exampleObject = { text: 'My Test Object' }; var button = Ext.create('Ext.button.Butto…

2012-11-14 22:00 · javascript

Ext.bind() 方法

var cat = { sound: 'miaow', speak: function(){ alert(this.sound); } }; var dog = { sound: 'woof', speak: function(){ alert(this.sound); } }; cat.speak(); // alerts 'miaow' dog.speak(); // alerts 'woof' Ext.bind(dog.speak, cat)(); // alerts 'miaow' How it works: The Ext.bind method creates a wrapper…

2012-11-14 21:54 · javascript

extjs mixin example

//1. Define our simple mixin class called HasCamera with a single //method called takePhoto: Ext.define('HasCamera', { takePhoto: function(){ alert('Say Cheese! .... Click!'); } }); //2. Define a skeleton class and use the mixins configuration option //to apply our HasCamera mixin to our Cookbook.S…

2012-11-14 17:29 · javascript

What's the difference between a jQuery object and a DOM element?

http://http://stackoverflow.com/questions/6942193/whats-the-difference-between-a-jquery-object-and-a-dom-element-difference-betw I got an answer from above. HTML != DOM != Javascript != jQuery, but they're all closely related. The browser receives an HTML document from a web server, which is just t…

2012-09-28 17:26 · javascript

How to make extjs grid selectable

Ext.core.Element.prototype.unselectable = function() { var me = this; if (me.dom.className.match(/(x-grid-table|x-grid-view)/)) { return me; } me.dom.unselectable = "on"; me.swallowEvent("selectstart", true); me.applyStyles("-moz-user-select:none;-khtml-user-select:none;"); me.addCls(Ext.baseCSSPre…

2012-07-05 14:42 · javascript

Using rowexpander in extjs4

Add code snippe below to your grid: plugins: [{ ptype: 'rowexpander', rowBodyTpl : [ '<p>{yourcolumn}</p>' ] }], How to expand all after store finishes loading? I got many answers from google but they did not work! Do not use expander.expandRow(rownum); Instead you should use expander.toggleRow(row…

2012-01-31 16:35 · javascript · web

Javascript Replace innerHTML throwing Unknown Runtime Error

Quite annoying...IE sucks... http://stackoverflow.com/questions/555965/javascript-replace-innerhtml-throwing-unknown-runtime-error I encountered this problem when I want to change a table's content using el.innerHtml = '<tr>...</tr>' in which el is a table element, IE throws "unknown runtime except…

2011-11-30 12:18 · javascript

Faster InnerHTML

http://blog.stevenlevithan.com/archives/faster-than-innerhtml I got performance boost in my FF rather than IE, quite weird, anyway, I think it's useful.

2011-11-23 17:18 · javascript

jquery lazy loading

最近玩了一下jquery,主要是在做的一个小工具要在一个web page里显示一个表格,表格每一行有一个图片,大约有几万行,所以问题是一下子load下来吃不消了。对于前端我是门外汉,网上搜了一下,发现有个lazy load的插件,jquery写的。 这个是官方网站: http://www.appelsiini.net/projects/lazyload 但是因为这玩意很早写的,后来浏览器发展太快了吧所以现在的浏览器上这个插件有问题了,作者在网站上也说了。于是就有某人去改了一些: 这个是某人改进的: http://www.popo4j.com/qianduan/transformation_j…

2011-10-26 15:24 · javascript

Pie Chart With Small Value Renders Incorrectly in IE

这个bug是我在使用extjs 4的pie chart的时候发现的,貌似还没有解决。 http://www.sencha.com/forum/showthread.php?137809-4.0.2a-Pie-Chart-with-small-value-renders-incorrectly-in-IE&p=616611

2011-09-02 14:26 · javascript

Great HTML5 Example

This author shows how to draw interactive pie chart with html5. http://www.elated.com/articles/snazzy-animated-pie-chart-html5-jquery/

2011-07-07 18:05 · javascript

Extjs 4 : Customize Legend of Pie Chart

Unlike extjs 3, pie chart of Extjs 4 can be customized according to your requirment. For example, in my application, I need to customize pie chart's legend to show a combination of both category and its count.(Default it will show only category.) So I hacked extjs library, create my own Legend, I'm…

2011-06-09 18:43 · javascript

ajax css optimization

http://blog.zimbra.com/blog/archives/2006/01/ajax-and-css-optimization.html

2011-04-15 12:59 · javascript

JavaScript, 5 ways to call a function

http://devlicio.us/blogs/sergio_pereira/archive/2009/02/09/javascript-5-ways-to-call-a-function.aspx

2011-04-06 14:45 · javascript