注册 登录
编程论坛 JavaScript论坛

大话日本人的编程风格

wangnannan 发布于 2015-06-19 08:48, 4732 次点击
日本人抛弃民族情绪来说 不得不承认他们真的做事认真严谨 追求细腻到了无微不至 堪称登峰造极 在对这个国家没有深入了解之前 对他们事不厌细 毫厘计较的做事态度和方法也许觉得多余甚至可笑 但是 如果理智地思考和面对 就会感觉这种较真纤密的做事风格对社会来讲 无疑是一种无形的责任链接
废话少说 上干货
下面我就拿一套代码及UI(日本人的) 来给大家详细说说日本人编码风格
Nissan R&D WebUIDemo
只有本站会员才能查看附件,请 登录
25 回复
#2
wangnannan2015-06-19 08:50
只有本站会员才能查看附件,请 登录
这是一个DEMO 整体命名很规范
 
#3
wangnannan2015-06-19 08:51
下边我截取一段JS的代码 大家可以看看日本人的编程风格
程序代码:
/*--------------------------------------------------|

| dTree 2.05 | www. |

|---------------------------------------------------|

| Copyright (c) 2002-2003 Geir Landr?              |

|                                                   |

| This script can be used freely as long as all     |

| copyright messages are intact.                    |

|                                                   |

| Updated: 17.04.2003                               |

|--------------------------------------------------
*/



// Node object

function Node(id, pid, name, url, title, target, icon, iconOpen, open) {

    this.id = id;

    this.pid = pid;

    this.name = name;

    this.url = url;

    this.title = title;

    this.target = target;

    this.icon = icon;

    this.iconOpen = iconOpen;

    this._io = open || false;

    this._is = false;

    this._ls = false;

    this._hc = false;

    this._ai = 0;

    this._p;

};



// Tree object

function dTree(objName) {

    this.config = {

        target                    : null,

        folderLinks            : true,

        useSelection        : true,

        useCookies            : true,

        useLines                : true,

        useIcons                : true,

        useStatusText        : false,

        closeSameLevel    : false,

        inOrder                    : false

    }

    this.icon = {

        root                : 'images/base.gif',

        folder            : 'images/folder.gif',

        folderOpen    : 'images/folderopen.gif',

        node                : 'images/page.gif',

        empty                : 'images/empty.gif',

        line                : 'images/line.gif',

        join                : 'images/join.gif',

        joinBottom    : 'images/joinbottom.gif',

        plus                : 'images/plus.gif',

        plusBottom    : 'images/plusbottom.gif',

        minus                : 'images/minus.gif',

        minusBottom    : 'images/minusbottom.gif',

        nlPlus            : 'images/nolines_plus.gif',

        nlMinus            : 'images/nolines_minus.gif'

    };

    this.obj = objName;

    this.aNodes = [];

    this.aIndent = [];

    this.root = new Node(-1);

    this.selectedNode = null;

    this.selectedFound = false;

    this.completed = false;

};



// Adds a new node to the node array

dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) {

    this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open);

};



// Open/close all nodes

dTree.prototype.openAll = function() {

    this.oAll(true);

};

dTree.prototype.closeAll = function() {

    this.oAll(false);

};



// Outputs the tree to the page

dTree.prototype.toString = function() {

    var str = '<div class="dtree">\n';

    if (document.getElementById) {

        if (this.config.useCookies) this.selectedNode = this.getSelected();

        str += this.addNode(this.root);

    } else str += 'Browser not supported.';

    str += '</div>';

    if (!this.selectedFound) this.selectedNode = null;

    this.completed = true;

    return str;

};



// Creates the tree structure

dTree.prototype.addNode = function(pNode) {

    var str = '';

    var n=0;

    if (this.config.inOrder) n = pNode._ai;

    for (n; n<this.aNodes.length; n++) {

        if (this.aNodes[n].pid == pNode.id) {

            var cn = this.aNodes[n];

            cn._p = pNode;

            cn._ai = n;

            this.setCS(cn);

            if (!cn.target && this.config.target) cn.target = this.config.target;

            if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);

            if (!this.config.folderLinks && cn._hc) cn.url = null;

            if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) {

                    cn._is = true;

                    this.selectedNode = n;

                    this.selectedFound = true;

            }

            str += this.node(cn, n);

            if (cn._ls) break;

        }

    }

    return str;

};



// Creates the node icon, url and text

dTree.prototype.node = function(node, nodeId) {

    var str = '<div class="dTreeNode">' + this.indent(node, nodeId);

    if (this.config.useIcons) {

        if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);

        if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;

        if (this.root.id == node.pid) {

            node.icon = this.icon.root;

            node.iconOpen = this.icon.root;

        }

        str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />';

    }

    if (node.url) {

        str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"';

        if (node.title) str += ' title="' + node.title + '"';

        if (node.target) str += ' target="' + node.target + '"';

        if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" ';

        if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))

            str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"';

        str += ' target="mainFrame">';

    }

    else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)

        str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">';

    str += node.name;

    if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>';

    str += '</div>';

    if (node._hc) {

        str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">';

        str += this.addNode(node);

        str += '</div>';

    }

    this.aIndent.pop();

    return str;

};



// Adds the empty and line icons

dTree.prototype.indent = function(node, nodeId) {

    var str = '';

    if (this.root.id != node.pid) {

        for (var n=0; n<this.aIndent.length; n++)

            str += '<img src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" />';

        (node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);

        if (node._hc) {

            str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');"><img id="j' + this.obj + nodeId + '" src="';

            if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;

            else str += ( (node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus ) );

            str += '" alt="" /></a>';

        } else str += '<img src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" />';

    }

    return str;

};



// Checks if a node has any children and if it is the last sibling

dTree.prototype.setCS = function(node) {

    var lastId;

    for (var n=0; n<this.aNodes.length; n++) {

        if (this.aNodes[n].pid == node.id) node._hc = true;

        if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id;

    }

    if (lastId==node.id) node._ls = true;

};



// Returns the selected node

dTree.prototype.getSelected = function() {

    var sn = this.getCookie('cs' + this.obj);

    return (sn) ? sn : null;

};



// Highlights the selected node

dTree.prototype.s = function(id) {

    if (!this.config.useSelection) return;

    var cn = this.aNodes[id];

    if (cn._hc && !this.config.folderLinks) return;

    if (this.selectedNode != id) {

        if (this.selectedNode || this.selectedNode==0) {

            eOld = document.getElementById("s" + this.obj + this.selectedNode);

            eOld.className = "node";

        }

        eNew = document.getElementById("s" + this.obj + id);

        eNew.className = "nodeSel";

        this.selectedNode = id;

        if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);

    }

};



// Toggle Open or close

dTree.prototype.o = function(id) {

    var cn = this.aNodes[id];

    this.nodeStatus(!cn._io, id, cn._ls);

    cn._io = !cn._io;

    if (this.config.closeSameLevel) this.closeLevel(cn);

    if (this.config.useCookies) this.updateCookie();

};



// Open or close all nodes

dTree.prototype.oAll = function(status) {

    for (var n=0; n<this.aNodes.length; n++) {

        if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) {

            this.nodeStatus(status, n, this.aNodes[n]._ls)

            this.aNodes[n]._io = status;

        }

    }

    if (this.config.useCookies) this.updateCookie();

};



// Opens the tree to a specific node

dTree.prototype.openTo = function(nId, bSelect, bFirst) {

    if (!bFirst) {

        for (var n=0; n<this.aNodes.length; n++) {

            if (this.aNodes[n].id == nId) {

                nId=n;

                break;

            }

        }

    }

    var cn=this.aNodes[nId];

    if (cn.pid==this.root.id || !cn._p) return;

    cn._io = true;

    cn._is = bSelect;

    if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls);

    if (this.completed && bSelect) this.s(cn._ai);

    else if (bSelect) this._sn=cn._ai;

    this.openTo(cn._p._ai, false, true);

};



// Closes all nodes on the same level as certain node

dTree.prototype.closeLevel = function(node) {

    for (var n=0; n<this.aNodes.length; n++) {

        if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) {

            this.nodeStatus(false, n, this.aNodes[n]._ls);

            this.aNodes[n]._io = false;

            this.closeAllChildren(this.aNodes[n]);

        }

    }

}



// Closes all children of a node

dTree.prototype.closeAllChildren = function(node) {

    for (var n=0; n<this.aNodes.length; n++) {

        if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc) {

            if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls);

            this.aNodes[n]._io = false;

            this.closeAllChildren(this.aNodes[n]);        

        }

    }

}



// Change the status of a node(open or closed)

dTree.prototype.nodeStatus = function(status, id, bottom) {

    eDiv    = document.getElementById('d' + this.obj + id);

    eJoin    = document.getElementById('j' + this.obj + id);

    if (this.config.useIcons) {

        eIcon    = document.getElementById('i' + this.obj + id);

        eIcon.src = (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon;

    }

    eJoin.src = (this.config.useLines)?

    ((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)):

    ((status)?this.icon.nlMinus:this.icon.nlPlus);

    eDiv.style.display = (status) ? 'block': 'none';

};





// [Cookie] Clears a cookie

dTree.prototype.clearCookie = function() {

    var now = new Date();

    var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);

    this.setCookie('co'+this.obj, 'cookieValue', yesterday);

    this.setCookie('cs'+this.obj, 'cookieValue', yesterday);

};



// [Cookie] Sets value in a cookie

dTree.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {

    document.cookie =

        escape(cookieName) + '=' + escape(cookieValue)

        + (expires ? '; expires=' + expires.toGMTString() : '')

        + (path ? '; path=' + path : '')

        + (domain ? '; domain=' + domain : '')

        + (secure ? '; secure' : '');

};



// [Cookie] Gets a value from a cookie

dTree.prototype.getCookie = function(cookieName) {

    var cookieValue = '';

    var posName = document.cookie.indexOf(escape(cookieName) + '=');

    if (posName != -1) {

        var posValue = posName + (escape(cookieName) + '=').length;

        var endPos = document.cookie.indexOf(';', posValue);

        if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));

        else cookieValue = unescape(document.cookie.substring(posValue));

    }

    return (cookieValue);

};



// [Cookie] Returns ids of open nodes as a string

dTree.prototype.updateCookie = function() {

    var str = '';

    for (var n=0; n<this.aNodes.length; n++) {

        if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) {

            if (str) str += '.';

            str += this.aNodes[n].id;

        }

    }

    this.setCookie('co' + this.obj, str);

};



// [Cookie] Checks if a node id is in a cookie

dTree.prototype.isOpen = function(id) {

    var aOpen = this.getCookie('co' + this.obj).split('.');

    for (var n=0; n<aOpen.length; n++)

        if (aOpen[n] == id) return true;

    return false;

};



// If Push and pop is not implemented by the browser

if (!Array.prototype.push) {

    Array.prototype.push = function array_push() {

        for(var i=0;i<arguments.length;i++)

            this[this.length]=arguments[i];

        return this.length;

    }

};

if (!Array.prototype.pop) {

    Array.prototype.pop = function array_pop() {

        lastElement = this[this.length-1];

        this.length = Math.max(this.length-1,0);

        return lastElement;

    }

};

#4
wangnannan2015-06-19 08:53
很精细 这里借用某大师的一句话 如下
如果你的代码易于阅读,那么代码中bug也将会很少,因为一些bug可以很容被调试,并且,其他开发者参与你项目时的门槛也会比较低。因此,如果项目中有多人参与,采取一个有共识的编码风格约定非常有必要
#5
wangnannan2015-06-19 08:54
JavaScript没有一个权威的编码风格指南,取而代之的是一些流行的编码风格:
•Google的JavaScript风格指南(以下简称Google)
•NPM编码风格(以下简称NPM)
•Felix的Node.js风格指南(以下简称Node.js)
•惯用(Idiomatic)的JavaScript(以下简称Idiomatic)
•jQuery JavaScript风格指南(以下简称jQuery)
•Douglas Crockford的JavaScript风格指南(以下简称Crockford),Douglas Crockford是Web开发领域最知名的技术权威之一,ECMA JavaScript 2.0标准化委员会委员
#6
wangnannan2015-06-19 08:55
OK 现在在看看前台的代码
只有本站会员才能查看附件,请 登录
#7
wangnannan2015-06-19 08:59
只有本站会员才能查看附件,请 登录
#8
wangnannan2015-06-19 09:01
只有本站会员才能查看附件,请 登录
#9
wangnannan2015-06-19 09:01
给大家上一张大图 日本业务系统的UI 怎么说呢 很简洁 很直接 直接让你一目了然
#10
wangnannan2015-06-19 09:03
可以灵活的收缩
只有本站会员才能查看附件,请 登录
#11
wangnannan2015-06-19 09:06
只有本站会员才能查看附件,请 登录
#12
wangnannan2015-06-19 09:07
程序代码:
<script language="javascript" type="text/javascript">

function changeChild(op){
switch(op){
case "1": var arr=new Array("図面手配","試作予備部品","試作組み込み部品","試作同時手配","IPL手配","正規手配","限定手配","暫定手配");break;
case "2": var arr=new Array("図面手配","試作予備部品","試作組み込み部品","試作同時手配","IPL手配","正規手配","限定手配","暫定手配");break;
case "3": var arr=new Array("正規手配");break;
case "4": var arr=new Array("IPL手配");break;
case "5": var arr=new Array("IPL手配");break;
case "6": var arr=new Array("IPL手配");break;
case "7": var arr=new Array("仕様提示","図面手配","試作予備部品","試作組み込み部品","IPL手配","正規手配");break;
case "8": var arr=new Array("仕様提示","図面手配","試作予備部品","試作組み込み部品","IPL手配","正規手配");break;
case "9": var arr=new Array("仕様提示","図面手配","試作予備部品","試作組み込み部品","IPL手配","正規手配");break;
}


var selObj = document.getElementById("selectChange")
selObj.length=1;
for (i=0;i<arr.length;i++){
var obj=new Option()
obj.text=arr[i]
obj.value=arr[i]

selObj.options[i+1] = obj
}
}
function open_link3()
{
    open("Report Template\\総合進捗管理レポート.xls");
}
function EditErrorCase0()
{
    window.showModalDialog("EditErrorCase0.htm","","dialogWidth=510px;dialogHeight=480px;status=no;help=no;scroll=no")
}
function HideAll()
{
CloseLayer(noReceive);ShowLayer(noReceivePlus);CloseLayer(noReceiveMinus);

CloseLayer(process);ShowLayer(processPlus);CloseLayer(processMinus);

CloseLayer(error);ShowLayer(errorPlus);CloseLayer(errorMinus);

}

function ShowAll()
{
ShowLayer(noReceive);CloseLayer(noReceivePlus);ShowLayer(noReceiveMinus);

ShowLayer(process);CloseLayer(processPlus);ShowLayer(processMinus);

ShowLayer(error);CloseLayer(errorPlus);ShowLayer(errorMinus);
}
前台函数
#13
wangnannan2015-06-19 09:08
程序代码:
function ShowAll()
{
ShowLayer(SeachToolBarBasic);ShowLayer(contorlSearchtoolbarBasic1);CloseLayer(contorlSearchtoolbarBasic);

/*ShowLayer(SeachToolBarReferenced);ShowLayer(contorlSearchtoolbarReferenced1);CloseLayer(contorlSearchtoolbarReferenced);*/

}

function HideAll()
{
ShowLayer(contorlSearchtoolbarBasic);CloseLayer(SeachToolBarBasic);CloseLayer(contorlSearchtoolbarBasic1);

/*ShowLayer(contorlSearchtoolbarReferenced);CloseLayer(SeachToolBarReferenced);CloseLayer(contorlSearchtoolbarReferenced1);*/

}


 function NewRow()
{
    var tbody = document.getElementById('tAddNewRow').tBodies[0];
    var tr = tbody.appendChild(document.createElement('tr'));
    var form = tr.appendChild(document.createElement('form'));
    var td = form.appendChild(document.createElement('td'));
    var delBtn = td.appendChild(document.createElement('<input type="button" value="この行を削除しますか" class="buttonInside"/>'));
    var lable1 = td.appendChild(document.createElement());
    lable1.innerText = '  ';
    td.appendChild(document.createElement('<input name="file" type="file" id="f1"  style="display:none" onChange="t1.value=this.value"/>'));
    td.appendChild(document.createElement('<input name="text2" type="text"  id="t1" size="145" style="width:360px"/>'));
    var lable2 = td.appendChild(document.createElement());
    lable2.innerText = ' ';
    td.appendChild(document.createElement('<input type="button" name="" value="Browse..." class="buttonInside" id="b1" onClick="f1.click()"/>'));
    var lable3 = td.appendChild(document.createElement());
    lable3.innerText = ' ';
    td.appendChild(document.createElement('<input type="button" name="" value="Upload" class="buttonInside"/>'));
    var td1 = td.appendChild(document.createElement());
    td1.innerText = '        ファイル名  ';
    td.appendChild(document.createElement('<input type="text" name=""  size="145" style="width:360px"/>'));
   
   
    delBtn.onclick = function ()
    {
        tbody.removeChild(tr);
    }
}
#14
wangnannan2015-06-19 09:11
程序代码:
function checkAll()
{
    if(document.all("CheckAll").checked==true)
    {
        document.all("Check1").checked = true;
        document.all("Check2").checked = true;
        document.all("Check3").checked = true;
        document.all("Check4").checked = true;
        document.all("Check5").checked = true;
        document.all("Check6").checked = true;
        document.all("Check7").checked = true;
        document.all("Check8").checked = true;
        document.all("Check9").checked = true;
    }
    else
    {
        document.all("Check1").checked = false;
        document.all("Check2").checked = false;
        document.all("Check3").checked = false;
        document.all("Check4").checked = false;
        document.all("Check5").checked = false;
        document.all("Check6").checked = false;
        document.all("Check7").checked = false;
        document.all("Check8").checked = false;
        document.all("Check9").checked = false;
    }
}
哈哈看到这儿我笑了 严谨中透着死板教条 写个循环不好吗 这就像抗日剧里面 鬼子一万年不变的三角队形
#15
wangnannan2015-06-19 09:13
只有本站会员才能查看附件,请 登录
连图片命名都如此规范 我真服了
#16
wangnannan2015-06-19 09:14
截取一段CSS 跟咱们差不多
程序代码:
/* Styles Updated: 11/13/2008 @ 13:30 P.M. ——-*/

body{margin:0 auto; padding:0; background:#FFF; font-family: verdana, Arial, Tahoma; height:100%; border:none; font-size:12px; text-align:center;}
img {border:0;}
a {text-decoration:none;font-size:12px;}
a:hover{ text-decoration:underline;}
form{margin:0px;display: inline}
input, button, select { font-size:12px;}
table {margin:0px auto;  font-size:12px;}
div {margin:0px auto;}

HTML{OVERFLOW-Y: auto;
SCROLLBAR-FACE-COLOR: #e4f0ff;
SCROLLBAR-HIGHLIGHT-COLOR: #fff;
SCROLLBAR-SHADOW-COLOR: #8091a9;
SCROLLBAR-3DLIGHT-COLOR: #8091a9;
SCROLLBAR-ARROW-COLOR: #8091a9;
SCROLLBAR-TRACK-COLOR: #f3f3f3;
SCROLLBAR-DARKSHADOW-COLOR: #eee;}


/* =Head ----------------------------------*/

.logOut{ text-align:right; margin-right:10px;}
.copyRight{ float:right; margin:0px; padding:0px; color:#f9fbff; font-size:10px; top:800px;}
.menuAndCopy{ width:100%;}

.language{padding:20px 20px 30px 30px; clear:both; width:300px; float:left; font-size:12px;}
.language a{ padding-left:10px; padding-right:10px;}
.language a,.language a:visited{color:#333;}


/* =Menu ----------------------------------*/
.dtree {font-size: 11px; color: #666; white-space: nowrap; padding:5px 0px 5px 5px;}
.dtree img {border: 0px; vertical-align: middle;}
.dtree a {color: #333; text-decoration: none;}
.dtree a.node, .dtree a.nodeSel {white-space: nowrap; padding: 1px 2px 1px 2px;}
.dtree a.node:hover, .dtree a.nodeSel:hover {color: #333; text-decoration: underline;}
.dtree a.nodeSel {background-color: #c0d2ec;}
.dtree .clip {overflow: hidden;}

.logo a{ color:#0063e9}
.logo { color:#3560b7}

#17
wangnannan2015-06-19 09:15
那时候才08年 一个DEMO 就写的这么严谨 还居然用了 source safe

[ 本帖最后由 wangnannan 于 2015-6-19 09:17 编辑 ]
#18
wangnannan2015-06-19 09:18
只有本站会员才能查看附件,请 登录
项目导出的EXCEL文件
#19
wangnannan2015-06-19 09:20
只有本站会员才能查看附件,请 登录
#20
wangnannan2015-06-19 09:20
我们一直在学习人家的式样书 可我们学到的只是皮毛
#21
wangnannan2015-06-19 09:22
只有本站会员才能查看附件,请 登录
#22
wangnannan2015-06-19 09:23
工余与日本员工闲聊的时候 我不禁疑惑地问他们 你们这样严格刻板的要求是否过分了?
他非常严肃地回答 这些文件都是提供给我们客户做参考用的 制作的必须严谨漂亮 这些细微之处 不但体现了我们公司的工作是否严密 关系到客户对我们是否放心 也是我们对客户尊重的表现!
不得不说程序员是一个严谨的职业


[ 本帖最后由 wangnannan 于 2015-6-19 09:28 编辑 ]
#23
wangnannan2015-06-19 09:26
未完待续。。(本人并非崇洋媚外 好像又写跑题了)

[ 本帖最后由 wangnannan 于 2015-6-19 09:31 编辑 ]
#24
冰镇柠檬汁儿2015-06-21 09:16
就编码风格来说,我觉得没什么特别的地方,我的代码格式和这些类似,注释比这多的多
不过日本公司的严谨让我觉得有点头疼
#25
butterfeild2015-08-06 21:38
回复 10楼 wangnannan
感觉跟我现在写EXTJS的表格的风格差不多

我的标准页面格式,这样写比用EXT那种风格要容易掌握
<html xmlns="http://www.
<head>
    <title>titleName</title>
    //各类引用
    <script type="text/javascript">
function go() {
    = Ext.get("tabDIV");
    //这里放所有的公共变量
    this.init();
}
go.prototype.init = function () {
    //这里放页面数据格式
    var url = urlString;
    var dhp = new Ext.data.HttpProxy({ url: url, method: "GET" });
    var djr= new Ext.data.JsonReader({
          root: 'data',
          totalProperty: 'totalPageCount',
          fields: ["data1","data2","data3"]
    });
    this.gridStore = new Ext.data.GroupingStore({
          proxy: dhp,
          reader: djr,
          sortInfo: {field: "data1", direction: "ASC"}
    });
    this.createwin
}
go.prototype.createwin= function () {
    //这里写整个页面的界面
    this.searchBtn = new Ext.Button({ text: "按键" });
    this.tabgrid = new Ext.grid.GridPanel({
                store: this.gridStore,
                selModel: new Ext.grid.RowSelectionModel({ singleSelect: false }),
                columns: [
                        new Ext.grid.RowNumberer({ width: 30 }),
                        { header: "字段1", sortable: true, align: "right", width: 60, dataIndex: 'filecarnumber' },
                        { header: "字段2", sortable: true, align: "right", width: 60, dataIndex: 'cargoupname' },
                        { header: "字段3", sortable: true, align: "left", width: 60, dataIndex: 'cartypename' }
                       ],
                view: new Ext.grid.GridView({
                    autoFill: false,
                    sortAscText: '正向排序',
                    sortDescText: '反向排序',
                    columnsText: '显示列/隐藏列'
                }),
                height: (),
                width: (),
                frame: false,
                border: false,
                hideMode: "display",
                autoScroll: true,
                tbar: [this.searchBtn],
                renderTo: "tabDIV",
                loadMask: { msg: '数据加载中...' }
            });
    this.eventwin
}
go.prototype.eventwin= function () {
    //最后这里是汇集页面所有的事件
    this.searchBtn .addListener("click", function () {
        this.gridStore.load({});
    }, this);
}

Ext.onReady(function () {
    var go = new go();
});

</script>
</head>
<body>
<div id='tabDIV' style='width:100%;height:100%;'></div>
</body>
</html>
#26
外部三电铃2015-08-06 22:21
他们的社会环境能静下心来钻技术,我们的环境太浮躁,搞技术不如搞关系,想静下心来搞技术也没有那个条件
1