AngularJs 公告栏及敏感字过滤
来源:互联网 发布:g92的编程实例 编辑:程序博客网 时间:2024/06/04 18:35
下面代码是通过AngularJs进行布局,然后把输入内容添加到公布栏,并进行敏感字过滤的过程。
<!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8"> <script type="text/javascript" src="angular-1.3.0.js"></script> <title></title> <style> * { margin: 0 auto; } li { height: 20px; line-height: 20px; list-style: none; } main { position: relative; width: 512px; margin: 0 auto; } div { height: 48px; line-height: 45px; } section { width: 512px; } .note_list { width: 512px; height: 384px; border: 2px solid #999999; padding: 12px; } .texts { width: 388px; margin: 0 auto; } .texts input { width: 320px; height: 24px; } .btn { width: 80px; margin: 0 auto; } button { width: 80px; height: 24px; } #toast { position: absolute; top: 256px; left: 128px; width: 160px; height: 148px; background-color: #fff; border: 1px solid #999; } #toast h3 { text-align: center; } #toast h5 { text-align: center; } #toast button { display: block; margin: 16px auto; } </style> <script type="text/javascript"> var app = angular.module("myApp",[]); app.constant("tips",{ add_empty:["请输入记录内容","好吧"], add_repeat:["记录已存在","好吧"], add_minganzi:["输入内容含有敏感字","逼逼啥"], search_success:["搜索到相关内容","很好"], search_failure:["未搜索到相关内容","失望"] }); app.controller("myCtrl",function($scope,tips) { var tipsShow = function (tips) { $scope.tips_message = tips[0]; $scope.tips_btn = tips[1]; $scope.tips_is_show = true; }; var tipsHide = function() { $scope.tips_is_show = false; } $scope.list = []; $scope.addNote = function() { if($scope.note == undefined) { tipsShow(tips.add_empty); return; } var note = $scope.note.trim(); if(note.length == 0) { tipsShow(tips.add_empty); return; } var array = ["习近平"]; var showCount = note; for(var i=0;i<array.length;i++) { var r = new RegExp(array[i],"ig"); showCount = showCount.replace(r,"*"); if(showCount.indexOf('*')!='-1') { tipsShow(tips.add_minganzi); }else { if($scope.list.indexOf(showCount)>=0) { tipsShow(tips.add_repeat); return; } } } $scope.list.push(showCount); $scope.note=""; } $scope.search = function() { if($scope.keyword == undefined || $scope.keyword.length == 0) { tipsShow(tips.add_empty); return; } var key = $scope.keyword.trim(); var array = ["习近平"]; var showCount = key; for(var i=0;i<array.length;i++) { var r = new RegExp(array[i],"ig"); showCount = showCount.replace(r,"*"); if(showCount.indexOf('*')!='-1') { tipsShow(tips.add_minganzi); }else { if($scope.list.indexOf(showCount)>=0) { tipsShow(tips.search_success); return; }else { tipsShow(tips.search_failure); return; } } } } $scope.tipsHide = function() { tipsHide(); } }); </script></head><body ng-app="myApp"><main ng-controller="myCtrl"> <div>记账本</div> <div class="note_list"> <ul> <li ng-repeat="value in list">{{value}}</li> </ul> </div> <section> <div class="texts">输入框: <input type="text" size="48" ng-model="note"/></div> </section> <section> <div class="btn"> <button ng-click="addNote()">记录</button> </div> </section> <section> <div class="texts">搜索框:<input type="text" size="48" ng-model="keyword"/></div> </section> <section> <div class="btn"> <button ng-click="search()">搜索</button> </div> </section> <div id="toast" ng-if="tips_is_show"> <h3>提示</h3> <h5>{{tips_message}}</h5> <button ng-click="tipsHide()">{{tips_btn}}</button> </div></main></body></html>
阅读全文
0 0
- AngularJs 公告栏及敏感字过滤
- HTML公告栏发布及敏感字过滤
- angularjs过滤敏感字符
- angularjs过滤敏感字符
- AngularJS敏感字符过滤代码案例
- angularjs查询删除 过滤敏感信息
- java 敏感字过滤
- 敏感字过滤算法
- 敏感字过滤
- 敏感字自动过滤
- angularJS实现查询/选择排序/添加/敏感字符过滤
- 过滤敏感字的算法
- 过滤敏感字的算法
- angular js 敏感字过滤
- 敏感词过滤及字符串编码问题
- AngularJS+查询+敏感字+排序+添加
- AngularJS+查询+敏感字+排序+添加
- angularjs 自定义过滤器 改变敏感字
- How to disable DRM
- 交叉编译opencv时候ffmpeg选项始终为no的解决方法
- SIMD单指令数据流(MMX、SSE2、NEON)
- Hibernate与Mybatis对比
- 第五章:表格
- AngularJs 公告栏及敏感字过滤
- JPush Java SDK 示例代码与简要注释
- Android 反编译自己挖的坑
- 操作系统
- 无线远传LORA水表是什么样的智能水表?
- DP:钢条切割问题
- n阶数字正方形/n阶数字三角形/n阶递减三角形/乘法表
- java中的方法调用-解析与分派
- es6开发环境搭建(gulp实时转码)