2009年03月 存档

fetch with PHP in eZ

2009年03月30日,星期一

1、根据path搜素

$nodeID = eZURLAliasML::fetchNodeIDByPath( $node->attribute(’url’) ); //e.g fetchNodeIDByPath(’/About/Company’)
$contentNode = eZContentObjectTreeNode::fetch( $nodeID );

2、根据nodeID得到单个node的object

$contentNode = eZContentObjectTreeNode::fetch( $nodeID );

3、根据nodeID得到子项目(tree)

$nodes = eZContentObjectTreeNode::subTreeByNodeID(array(’SortBy’=>array(’class_identifier’, false)),$PersonnalFoldersNodeId); //array for 查询条件

4、根据objectID 得到单个item

$typeitem = eZContentObject::fetch( $contentobject_id );

Credit Card Number Generator Javascript version

2009年03月27日,星期五

<html>
<head>
<script type="text/javascript">
/*
Javascript credit card number generator
Copyright (C) 2006 Graham King graham@darkcoding.net

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

www.darkcoding.net
*/

var visaPrefixList = new Array(
    "4539",
    "4556",
    "4916",
    "4532",
    "4929",
    "40240071",
    "4485",
    "4716",
    "4"
);

var mastercardPrefixList = new Array(
    "51",
    "52",
    "53",
    "54",
    "55"
);

var amexPrefixList = new Array(
    "34",
    "37"
);

var discoverPrefixList = new Array("6011");

var dinersPrefixList = new Array(
    "300",
    "301",
    "302",
    "303",
    "36",
    "38"
);

var enRoutePrefixList = new Array(
    "2014",
    "2149"
);

var jcbPrefixList16 = new Array(
    "3088",
    "3096",
    "3112",
    "3158",
    "3337",
    "3528"
);

var jcbPrefixList15 = new Array(
    "2100",
    "1800"
);

var voyagerPrefixList = new Array("8699");

function strrev(str) {
   if (!str) return '';
   var revstr='';
   for (i = str.length-1; i>=0; i--)
       revstr+=str.charAt(i)
   return revstr;
}

/*
'prefix' is the start of the CC number as a string, any number of digits.
'length' is the length of the CC number to generate. Typically 13 or 16
*/
function completed_number(prefix, length) {

    var ccnumber = prefix;

    // generate digits

    while ( ccnumber.length < (length - 1) ) {
        ccnumber += Math.floor(Math.random()*10);
    }

    // reverse number and convert to int 

    var reversedCCnumberString = strrev( ccnumber );

    var reversedCCnumber = new Array();
    for ( var i=0; i < reversedCCnumberString.length; i++ ) {
        reversedCCnumber[i] = parseInt( reversedCCnumberString.charAt(i) );
    }

    // calculate sum    

    var sum = 0;
    var pos = 0;

    while ( pos < length - 1 ) {

        odd = reversedCCnumber[ pos ] * 2;
        if ( odd > 9 ) {
            odd -= 9;
        }

        sum += odd;

        if ( pos != (length - 2) ) {

            sum += reversedCCnumber[ pos +1 ];
        }
        pos += 2;
    }

    // calculate check digit

    var checkdigit = (( Math.floor(sum/10) + 1) * 10 - sum) % 10;
    ccnumber += checkdigit;

    return ccnumber;

}

function credit_card_number(prefixList, length, howMany) {

    var result = new Array();
    for (var i = 0; i < howMany; i++) {

        var randomArrayIndex = Math.floor(Math.random() * prefixList.length);
        var ccnumber = prefixList[ randomArrayIndex ];
        result.push( completed_number(ccnumber, length) );
    }

    return result;
}</script>
</head>
<body>
<h3>VISA:</h3>
<script>
var visa = credit_card_number(visaPrefixList, 16, 5);
document.write( visa );
</script>

<h3>Amex:</h3>
<script>
var amex = credit_card_number(amexPrefixList, 15, 5);
document.write( amex  );
</script>

<h3>Mastercard:</h3>
<script>
var mastercard = credit_card_number(mastercardPrefixList, 16, 5);
document.write( mastercard );
</script>

<h3>Discover:</h3>
<script>
var discover = credit_card_number(discoverPrefixList, 16, 5 );
document.write( discover );
</script>

</body>
</html>

向上滚动js代码

2009年03月20日,星期五

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″ />
<title>无标题文档</title>
<style type=”text/css”>
ul,li{margin:0;padding:0}
#scrollDiv{width:300px;height:100px;min-height:25px;line-height:25px;border:#ccc 1px solid;overflow:hidden}
#scrollDiv li{height:25px;padding-left:10px;}
</style>
<script src=”http://www.cssrain.cn/demo/JQuery+API/jquery-1[1].2.1.pack.js” type=”text/javascript”></script>
<script type=”text/javascript”>
//滚动插件
(function($){
$.fn.extend({
Scroll:function(opt,callback){
//参数初始化
if(!opt) var opt={};
var _this=this.eq(0).find(”ul:first”);
var        lineH=_this.find(”li:first”).height(), //获取行高
line=opt.line?parseInt(opt.line,10):parseInt(this.height()/lineH,10), //每次滚动的行数,默认为一屏,即父容器高度
speed=opt.speed?parseInt(opt.speed,10):500, //卷动速度,数值越大,速度越慢(毫秒)
timer=opt.timer?parseInt(opt.timer,10):3000; //滚动的时间间隔(毫秒)
if(line==0) line=1;
var upHeight=0-line*lineH;
//滚动函数
scrollUp=function(){
_this.animate({
marginTop:upHeight
},speed,function(){
for(i=1;i<=line;i++){
_this.find(”li:first”).appendTo(_this);
}
_this.css({marginTop:0});
});
}
//鼠标事件绑定
_this.hover(function(){
clearInterval(timerID);
},function(){
timerID=setInterval(”scrollUp()”,timer);
}).mouseout();
}
})
})(jQuery);

$(document).ready(function(){
$(”#scrollDiv”).Scroll({line:4,speed:1000,timer:2000});
});
</script>
</head>

<body>
<p>多行滚动演示:</p>
<div id=”scrollDiv”>
<ul>
<li>这是公告标题的第一行</li>
<li>这是公告标题的第二行</li>
<li>这是公告标题的第三行</li>
<li>这是公告标题的第四行</li>
<li>这是公告标题的第五行</li>
<li>这是公告标题的第六行</li>
<li>这是公告标题的第七行</li>
<li>这是公告标题的第八行</li>
</ul>
</div>
</body>
</html>