Submitted by gouki on 2011, September 6, 11:01 PM
nodeType的取值还是会经常用到的,但一般我们只用1和3,找了一下资料,1和3的含义是什么,才发现,原来是这样的。【部分资料来自:http://www.impng.com/web-dev/element-nodetype-values.html】
整数 |
常量 |
1 |
ELEMENT_NODE,普通元素节点,如<html>,<p>,<div>,<span>,<img> |
2 |
ATTRIBUTE_NODE,元素属性 |
3 |
TEXT_NODE,文本节点 |
4 |
CDATA_SECTION_NODE,即<![CDATA[ ]]> |
5 |
ENTITY_REFERENCE_NODE,实体引用,如& |
6 |
ENTITY_NODE,实体,如<!ENTITY copyright “Copyright 2010, impng. All rights reserved”]> |
7 |
PROCESSING_INSTRUCTION_NODE,PI,处理指令,如<?xml version=”1.0″?> |
8 |
COMMENT_NODE,注释<!– –> |
9 |
DOCUMENT_NODE,根节点,即document.nodeType |
10 |
DOCUMENT_TYPE_NODE,DTD,文档类型<!DOCTYPE > |
11 |
DOCUMENT_FRAGMENT_NODE,文档片段 |
12 |
NOTATION_NODE,DTD中定义的记号 |
需要注意的是,在IE下会直接跳过HTML中的空格/Tab/换行,而Firefox下空格会认为是一个节点,因此,对类似节点取nextSibling或previousSibling时,需要判断是否是元素节点。所以。要取某个节点下面的文字时,必须是类似这样的写法。
JavaScript代码
- function L(a) {
- var b = "";
- for (a = a.firstChild; a; a = a.nextSibling){
- if (a.nodeType === 3){
- b += a.nodeValue;
- } else if (a.nodeType === 1){
- b += L(a);
- }
- }
- return b
- }
Tags: nodetype, dom
Javascript | 评论:0
| 阅读:19563
Submitted by gouki on 2011, September 6, 10:32 PM
刚开始用mac,对于添加删除程序还是不太习惯。毕竟那种windows下的注册表之类的概念已经不在了。
不过,装软件还是很方便啦。
如果是dmg的软件,直接双击就OK了。如果不是,是其他的,一般来说,解压缩后,COPY到Application目录下也就OK了。
删除程序的话,就有点纠结了。
Mac OS X下的程序,通常不像Windows电脑下的那么复杂,什么注册表,DLL什么的,完全不用考虑。
要删除一个电脑程序之前,我先说一下安装一个程序后,通常生成了什么文件。
首先,正常情况下,是在“应用程序”(Applications)文件夹中,这是程序的主文件。当然,也可能放在其他地方,但是默认都是放在这里面的。
其次,就是程序的配置文件了,一般是”.plist”为扩展名的文件,都是放在”~/Library/Preferences/”中。
再次,就是程序的数据文件了,和图像有关的,可能放在”图片”(~/Pictures)中,其他的可能会在”文稿”(~/Documents)中。
这里不排除一些比较特殊的情况,具体问题具体分析了。
现在说说苹果电脑MACOSX下怎么删除软件。
先用菜单右上角的spotlight来搜索。比如我装的vmware fusion,我想要删除,我就直接去Application目录下把vmware fusion拖到废纸瘘里。但为了以防万一,我还是用spotlight搜索一下vmware,除了找到一些vmdk的文件,其他就找不到了。所以我就认为它已经从系统里消失了。
当然,还是会有一些专业的软件的,毕竟有的程序自带解载程序,运行就可以了,再有,就是给大家推荐个解载用的程序,AppZapper用这个程序可以很干净,很方便的清除要删除的程序,只要把程序文件托拽到它的图标上,再点清除就可以了。
Tags: mac, spotlight, applications, vmware
Flutter | 评论:0
| 阅读:26549
Submitted by gouki on 2011, September 5, 9:33 PM
先不说什么功能,只能说这种功能对我们来说太有用了。
refactor,这种重构,其实在ZS和NETBEANS 中效果并没有现在这个软件(phpstorm)那么明显。看看它的功能就知道了。
官方网址(http://blog.jetbrains.com/webide/2011/05/extract-function-method-refactoring-for-php/)说:
We are working hard on new features for PhpStorm 2.1, and the ‘Extract Function/Method’ refactoring for PHP is one of them. This feature has been available since the first PhpStorm 2.1 EAP(106.444), and we are looking forward for your feedback.

Picture 1b: Select an expression

Invoke the refactoring from the menu ‘Refactor -> Extract Method‘ or using a hotkey. The default hotkey is Ctrl+Alt+M for Windows/Linux and Cmd+Opt+M for Mac.
Depending on the context of the selected code fragment, ‘Extract method’ (the code fragment is inside a method) (Picture 2b) or ‘Extract Function’(the code fragment is inside a function or script) (Picture 2a).
Picture 2a: ‘Extract Function’ dialog

Picture 2b: ‘Extract Method’ dialog

Enter the name of the new function/method. Press OK.
Picture 3a: The code fragment is replaced with a function call statement

Picture 3b: The expression is replaced with a method call expression

Picture 4a: Definition of the extracted function

Picture 4b: Definition of the extracted method

Develop with pleasure!
------------
看完上面的内容,你是否觉 得,原来重构也可以这样简单?
Tags: phpstorm, refactor
Software | 评论:0
| 阅读:17032
Submitted by gouki on 2011, September 4, 9:33 PM
如果到facebook上关注一下yii framework的群组,会发现有人在介绍yiicookbook.org,里面是一本关于1.1的书。
然后去yii framework官方上搜索一下phpstorm,会发现同一个人在说自己用phpstorm,问phpstorm有没有什么支持。结果官网说暂时好象不支持。。。
然后再搜索了一下,发现在yii的官网有一个简单的例子在说如何让项目支持yii framework。看了一下,发现,大多数都用过,只有第一点,说是把yiilite.php过滤掉。这个其实很重要了,否则有些变量就会出现提示两次。
OK,来看官网的wiki吧:http://www.yiiframework.com/wiki/92/configuring-phpstorm-ide-for-yii
Code completion
- Exclude yiilite.php from index:
- File → Settings → IDE Settings → File Types.
- yiilite.php to Ignore files and folders.
- Exclude not used directories, specify resources.
- File → Settings → Project settings → Directories.
- Mark framework/cli/views, protected/runtime and assets as excluded.
- Mark website root as resource root.
- Specify path to your PHP.
- File → Settings → Project settings → PHP → PHP Home.
- If your project uses common Yii framework folder you need to include it.
- File → Settings → Project settings → PHP → PHP Home → Add.
- Specify a path to framework directory.
- If you are writing unit tests you can include PHPUnit to get code completion:
- File → Settings → Project settings → PHP → PHP Home → Add.
- Specify a path to PHPUnit.
- Complete code: Ctrl+Space.
- Show method arguments: Ctrl+Q.
Testing
You should install PHPUnit to run unit tests.
- PHPUnit.
- Follow official PHPUnit installation guide.
- In your IDE: Run → Edit configurations.
- Press "+".
- Name: anything.
- Test: depending on what do you want to test select an appropriate option. Specify path.
- Use XML configuration file: specifying path to phpunit.xml. Often it's path_to_your_webroot/protected/tests/phpunit.xml.
- To run tests use SHIFT+F10.
OK,现在这样就可以简单的支持yii framework了。只是phpstorm还是有点小问题,因为提示的时候不会显示phpdoc的信息。纠结,啥时候会有doc的提示呢?
Tags: phpstorm, yii, facebook
Software | 评论:0
| 阅读:24573
Submitted by gouki on 2011, September 3, 10:44 PM
图片附件(缩略图):

图片附件(缩略图):

图片附件(缩略图):

图片附件(缩略图):

图片附件(缩略图):

Scala & Ruby | 评论:1
| 阅读:15300