待续。
原创文章转载请注明:
转载自AlloyTeam:http://www.alloyteam.com/2012/10/commonly-javascript-design-patterns-state-mode/
看完了,简单易懂,非常赞同结束语
同样在实际的编码中也没有必要刻意去使用一些设计模式。就如同 tokyo hot 32 式一样,在一场友好的 papapa 过程中,没有必要去刻意使用某种姿势。一切还是看需求和感觉。
[…] 状态模式 var defaultAuthor = " 称呼 (必填)"; var defaultEmail = " 邮箱 (不会被公开, 必填)"; var defaultUrl = " 网站"; var defaultComment = " 评论内容…"; function commentform_submit(){ if(document.commentform.author.value == '' || document.commentform.author.value == defaultAuthor) {alert(' 咳咳… 称呼忘填了');document.commentform.author.focus();return;} if(document.commentform.email.value == '' || document.commentform.email.value == defaultEmail) {alert('email… 您的 email 没填');document.commentform.email.focus();return;} if(document.commentform.comment.value == '' || document.commentform.comment.value == defaultComment) {alert(' 评论内容在哪?');document.commentform.comment.focus();return;} if(document.commentform.url.value == defaultUrl) document.commentform.url.value = ''; // document.commentform.submit(); } […]
[…] 状态模式 : http://www.alloyteam.com/2012/10/commonly-javascript-design-patterns-state-mode/ var defaultAuthor = " 称呼 (必填)"; var defaultEmail = " 邮箱 (不会被公开, 必填)"; var defaultUrl = " 网站"; var defaultComment = " 评论内容…"; function commentform_submit(){ if(document.commentform.author.value == '' || document.commentform.author.value == defaultAuthor) {alert(' 咳咳… 称呼忘填了');document.commentform.author.focus();return;} if(document.commentform.email.value == '' || document.commentform.email.value == defaultEmail) {alert('email… 您的 email 没填');document.commentform.email.focus();return;} if(document.commentform.comment.value == '' || document.commentform.comment.value == defaultComment) {alert(' 评论内容在哪?');document.commentform.comment.focus();return;} if(document.commentform.url.value == defaultUrl) document.commentform.url.value = ''; // document.commentform.submit(); } […]
称呼 (必填)
邮箱 (不会被公开,必填)
网站
Yimir 2014 年 1 月 4 日
看完了,简单易懂,非常赞同结束语
Mr.L 2012 年 10 月 26 日
同样在实际的编码中也没有必要刻意去使用一些设计模式。就如同 tokyo hot 32 式一样,在一场友好的 papapa 过程中,没有必要去刻意使用某种姿势。一切还是看需求和感觉。
【Javascript设计模式16】- 享元模式 | Tencent AlloyTeam 2012 年 10 月 25 日
[…] 状态模式 var defaultAuthor = " 称呼 (必填)"; var defaultEmail = " 邮箱 (不会被公开, 必填)"; var defaultUrl = " 网站"; var defaultComment = " 评论内容…"; function commentform_submit(){ if(document.commentform.author.value == '' || document.commentform.author.value == defaultAuthor) {alert(' 咳咳… 称呼忘填了');document.commentform.author.focus();return;} if(document.commentform.email.value == '' || document.commentform.email.value == defaultEmail) {alert('email… 您的 email 没填');document.commentform.email.focus();return;} if(document.commentform.comment.value == '' || document.commentform.comment.value == defaultComment) {alert(' 评论内容在哪?');document.commentform.comment.focus();return;} if(document.commentform.url.value == defaultUrl) document.commentform.url.value = ''; // document.commentform.submit(); } […]
【Javascript设计模式1】-单例模式 | Tencent AlloyTeam 2012 年 10 月 24 日
[…] 状态模式 : http://www.alloyteam.com/2012/10/commonly-javascript-design-patterns-state-mode/ var defaultAuthor = " 称呼 (必填)"; var defaultEmail = " 邮箱 (不会被公开, 必填)"; var defaultUrl = " 网站"; var defaultComment = " 评论内容…"; function commentform_submit(){ if(document.commentform.author.value == '' || document.commentform.author.value == defaultAuthor) {alert(' 咳咳… 称呼忘填了');document.commentform.author.focus();return;} if(document.commentform.email.value == '' || document.commentform.email.value == defaultEmail) {alert('email… 您的 email 没填');document.commentform.email.focus();return;} if(document.commentform.comment.value == '' || document.commentform.comment.value == defaultComment) {alert(' 评论内容在哪?');document.commentform.comment.focus();return;} if(document.commentform.url.value == defaultUrl) document.commentform.url.value = ''; // document.commentform.submit(); } […]
【Javascript设计模式11】-中介者模式 | Tencent AlloyTeam 2012 年 10 月 24 日
[…] 状态模式 : http://www.alloyteam.com/2012/10/commonly-javascript-design-patterns-state-mode/ var defaultAuthor = " 称呼 (必填)"; var defaultEmail = " 邮箱 (不会被公开, 必填)"; var defaultUrl = " 网站"; var defaultComment = " 评论内容…"; function commentform_submit(){ if(document.commentform.author.value == '' || document.commentform.author.value == defaultAuthor) {alert(' 咳咳… 称呼忘填了');document.commentform.author.focus();return;} if(document.commentform.email.value == '' || document.commentform.email.value == defaultEmail) {alert('email… 您的 email 没填');document.commentform.email.focus();return;} if(document.commentform.comment.value == '' || document.commentform.comment.value == defaultComment) {alert(' 评论内容在哪?');document.commentform.comment.focus();return;} if(document.commentform.url.value == defaultUrl) document.commentform.url.value = ''; // document.commentform.submit(); } […]
【Javascript设计模式15】-职责链模式 | Tencent AlloyTeam 2012 年 10 月 24 日
[…] 状态模式 : http://www.alloyteam.com/2012/10/commonly-javascript-design-patterns-state-mode/ var defaultAuthor = " 称呼 (必填)"; var defaultEmail = " 邮箱 (不会被公开, 必填)"; var defaultUrl = " 网站"; var defaultComment = " 评论内容…"; function commentform_submit(){ if(document.commentform.author.value == '' || document.commentform.author.value == defaultAuthor) {alert(' 咳咳… 称呼忘填了');document.commentform.author.focus();return;} if(document.commentform.email.value == '' || document.commentform.email.value == defaultEmail) {alert('email… 您的 email 没填');document.commentform.email.focus();return;} if(document.commentform.comment.value == '' || document.commentform.comment.value == defaultComment) {alert(' 评论内容在哪?');document.commentform.comment.focus();return;} if(document.commentform.url.value == defaultUrl) document.commentform.url.value = ''; // document.commentform.submit(); } […]
【Javascript设计模式3】-观察者模式 | Tencent AlloyTeam 2012 年 10 月 24 日
[…] 状态模式 : http://www.alloyteam.com/2012/10/commonly-javascript-design-patterns-state-mode/ var defaultAuthor = " 称呼 (必填)"; var defaultEmail = " 邮箱 (不会被公开, 必填)"; var defaultUrl = " 网站"; var defaultComment = " 评论内容…"; function commentform_submit(){ if(document.commentform.author.value == '' || document.commentform.author.value == defaultAuthor) {alert(' 咳咳… 称呼忘填了');document.commentform.author.focus();return;} if(document.commentform.email.value == '' || document.commentform.email.value == defaultEmail) {alert('email… 您的 email 没填');document.commentform.email.focus();return;} if(document.commentform.comment.value == '' || document.commentform.comment.value == defaultComment) {alert(' 评论内容在哪?');document.commentform.comment.focus();return;} if(document.commentform.url.value == defaultUrl) document.commentform.url.value = ''; // document.commentform.submit(); } […]
【javascript设计模式8】-访问者模式 | Tencent AlloyTeam 2012 年 10 月 24 日
[…] 状态模式 : http://www.alloyteam.com/2012/10/commonly-javascript-design-patterns-state-mode/ var defaultAuthor = " 称呼 (必填)"; var defaultEmail = " 邮箱 (不会被公开, 必填)"; var defaultUrl = " 网站"; var defaultComment = " 评论内容…"; function commentform_submit(){ if(document.commentform.author.value == '' || document.commentform.author.value == defaultAuthor) {alert(' 咳咳… 称呼忘填了');document.commentform.author.focus();return;} if(document.commentform.email.value == '' || document.commentform.email.value == defaultEmail) {alert('email… 您的 email 没填');document.commentform.email.focus();return;} if(document.commentform.comment.value == '' || document.commentform.comment.value == defaultComment) {alert(' 评论内容在哪?');document.commentform.comment.focus();return;} if(document.commentform.url.value == defaultUrl) document.commentform.url.value = ''; // document.commentform.submit(); } […]
【javascript设计模式6】-桥接模式 | Tencent AlloyTeam 2012 年 10 月 24 日
[…] 状态模式 : http://www.alloyteam.com/2012/10/commonly-javascript-design-patterns-state-mode/ var defaultAuthor = " 称呼 (必填)"; var defaultEmail = " 邮箱 (不会被公开, 必填)"; var defaultUrl = " 网站"; var defaultComment = " 评论内容…"; function commentform_submit(){ if(document.commentform.author.value == '' || document.commentform.author.value == defaultAuthor) {alert(' 咳咳… 称呼忘填了');document.commentform.author.focus();return;} if(document.commentform.email.value == '' || document.commentform.email.value == defaultEmail) {alert('email… 您的 email 没填');document.commentform.email.focus();return;} if(document.commentform.comment.value == '' || document.commentform.comment.value == defaultComment) {alert(' 评论内容在哪?');document.commentform.comment.focus();return;} if(document.commentform.url.value == defaultUrl) document.commentform.url.value = ''; // document.commentform.submit(); } […]
【javascript设计模式5】-代理模式 | Tencent AlloyTeam 2012 年 10 月 24 日
[…] 状态模式 : http://www.alloyteam.com/2012/10/commonly-javascript-design-patterns-state-mode/ var defaultAuthor = " 称呼 (必填)"; var defaultEmail = " 邮箱 (不会被公开, 必填)"; var defaultUrl = " 网站"; var defaultComment = " 评论内容…"; function commentform_submit(){ if(document.commentform.author.value == '' || document.commentform.author.value == defaultAuthor) {alert(' 咳咳… 称呼忘填了');document.commentform.author.focus();return;} if(document.commentform.email.value == '' || document.commentform.email.value == defaultEmail) {alert('email… 您的 email 没填');document.commentform.email.focus();return;} if(document.commentform.comment.value == '' || document.commentform.comment.value == defaultComment) {alert(' 评论内容在哪?');document.commentform.comment.focus();return;} if(document.commentform.url.value == defaultUrl) document.commentform.url.value = ''; // document.commentform.submit(); } […]
【javascript设计模式4】- 适配器模式 | Tencent AlloyTeam 2012 年 10 月 24 日
[…] 状态模式 : http://www.alloyteam.com/2012/10/commonly-javascript-design-patterns-state-mode/ var defaultAuthor = " 称呼 (必填)"; var defaultEmail = " 邮箱 (不会被公开, 必填)"; var defaultUrl = " 网站"; var defaultComment = " 评论内容…"; function commentform_submit(){ if(document.commentform.author.value == '' || document.commentform.author.value == defaultAuthor) {alert(' 咳咳… 称呼忘填了');document.commentform.author.focus();return;} if(document.commentform.email.value == '' || document.commentform.email.value == defaultEmail) {alert('email… 您的 email 没填');document.commentform.email.focus();return;} if(document.commentform.comment.value == '' || document.commentform.comment.value == defaultComment) {alert(' 评论内容在哪?');document.commentform.comment.focus();return;} if(document.commentform.url.value == defaultUrl) document.commentform.url.value = ''; // document.commentform.submit(); } […]