继开 | 博客

热爱生活,努力学习,实现自己的价值


  • 短诗的序

  • 迷途自渡

  • 寒星三两

  • 林深见鹿

  • 记昨日书

  • 顾探往昔

Js Bootstrap-treeview.js插件下载,树形菜单

发表于 2020-07-09
字数统计: 275 字 | 阅读时长 ≈ 1 min

下载地址

bootstrap-treeview 中文开发手册

github地址

使用

依赖

调用

1
2
3
4
5
6
7
8
<!-- 新 Bootstrap 核心 CSS 文件 -->
<link href="https://wjikai.gitee.io/myresoursce/js/bootstrap/css/bootstrap.min.css" rel="stylesheet">

<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="https://wjikai.gitee.io/myresoursce/js/jquery/jquery.min.js"></script>

<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://wjikai.gitee.io/myresoursce/js/bootstrap/js/bootstrap.min.js"></script>

或者

1
2
3
4
5
6
7
8
<!-- 新 Bootstrap 核心 CSS 文件 -->
<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>

<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

使用方法

1
2
3
4
5
<!-- 新 bootstrap-treeview 核心 CSS 文件 -->
<link href="https://wjikai.gitee.io/myresoursce/js/bootstrap/bootstrap-treeview/bootstrap-treeview.min.css" rel="stylesheet">

<!-- 最新的 bootstrap-treeview 核心 JavaScript 文件 -->
<script src="https://wjikai.gitee.io/myresoursce/js/bootstrap/bootstrap-treeview/bootstrap-treeview-wjk.js"></script>

增加的调用

1
2
3
4
5
$("#treeview").treeview("addNode", [nodeParentInfo.nodeId, {
"node": dataInfoArr
}]);
//dataInfoArr 是数组
//nodeParentInfo.nodeId 是上级节点id

Js bootstrap.js插件下载

发表于 2020-07-08
字数统计: 186 字 | 阅读时长 ≈ 1 min

下载地址

bootstrap中文网

菜鸟教程详解

使用

使用方法

调用

1
2
3
4
5
6
7
8
<!-- 新 Bootstrap 核心 CSS 文件 -->
<link href="https://wjikai.gitee.io/myresoursce/js/bootstrap/css/bootstrap.min.css" rel="stylesheet">

<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="https://wjikai.gitee.io/myresoursce/js/jquery.min.js"></script>

<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://wjikai.gitee.io/myresoursce/js/bootstrap/js/bootstrap.min.js"></script>

或者

1
2
3
4
5
6
7
8
<!-- 新 Bootstrap 核心 CSS 文件 -->
<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>

<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

Js jQuery Cookie Plugin v1.4.1

发表于 2020-07-07
字数统计: 1,184 字 | 阅读时长 ≈ 6 min

下载地址

菜鸟教程详解

使用

使用方法

创建 cookie:

1
$.cookie('name', 'value');

如果未指定过期时间,则会在关闭浏览器或过期。

创建 cookie,并设置 7 天后过期:

1
$.cookie('name', 'value', { expires: 7 });

创建 cookie,并设置 cookie 的有效路径,路径为网站的根目录:

1
$.cookie('name', 'value', { expires: 7, path: '/' });

注:在默认情况下,只有设置 cookie 的网页才能读取该 cookie。如果想让一个页面读取另一个页面设 置的cookie,必须设置 cookie 的路径。cookie 的路径用于设置能够读取 cookie 的顶级目录。将这 个路径设置为网站的根目录,可以让所有网页都能互相读取 cookie (一般不要这样设置,防止出现冲突)。

读取 cookie:

1
2
$.cookie('name'); // => "value"
$.cookie('nothing'); // => undefined

读取所有的 cookie 信息:

1
$.cookie(); // => { "name": "value" }

删除 cookie:

// cookie 删除成功返回 true,否则返回 false

1
2
$.removeCookie('name'); // => true
$.removeCookie('nothing'); // => false

// 写入使用了 path时,读取也需要使用相同的属性 (path, domain)

1
$.cookie('name', 'value', { path: '/' });

// 以下代码【删除失败】

1
$.removeCookie('name'); // => false

// 以下代码【删除成功】

1
$.removeCookie('name', { path: '/' }); // => true

注意:删除 cookie 时,必须传递用于设置 cookie 的完全相同的路径,域及安全选项。

实例

1
2
3
4
5
6
7
8
$(document).ready(function(){
$.cookie('name', 'runoob'); // 创建 cookie
name = $.cookie('name'); // 读取 cookie
$("#test").text(name);
$.cookie('name2', 'runoob2', { expires: 7, path: '/' });
name2 = $.cookie('name2');
$("#test2").text(name2);
});

参数说明

raw

默认值:false。

默认情况下,读取和写入 cookie 的时候自动进行编码和解码(使用 encodeURIComponent 编码,decodeURIComponent 解码)。要关闭这个功能设置 raw:true 即可:

1
$.cookie.raw = true;

json

设置 cookie 的数据使用 json 存储与读取,这时就不需要使用 JSON.stringify 和 JSON.parse 了。

1
2
3
$.cookie.json = true;
expires
expires: 365

定义 cookie 的有效时间,值可以是一个数字(从创建 cookie 时算起,以天为单位)或一个 Date 对象。如果省略,那么创建的 cookie 是会话 cookie,将在用户退出浏览器时被删除。

1
2
path
path: '/'

默认情况:只有设置 cookie 的网页才能读取该 cookie。

定义 cookie 的有效路径。默认情况下, 该参数的值为创建 cookie 的网页所在路径(标准浏览器的行为)。

如果你想在整个网站中访问这个 cookie 需要这样设置有效路径:path: ‘/‘。如果你想删除一个定义了有效路径的 cookie,你需要在调用函数时包含这个路径:

1
2
3
$.cookie('the_cookie', null,{ path: '/' });
domain
domain: 'example.com'

默认值:创建 cookie 的网页所拥有的域名。

1
2
secure
secure: true

默认值:false。如果为 true,cookie 的传输需要使用安全协议(HTTPS)。
s

源码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*!
* jQuery Cookie Plugin v1.4.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2006, 2014 Klaus Hartl
* Released under the MIT license
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD (Register as an anonymous module)
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS
module.exports = factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {

var pluses = /\+/g;

function encode(s) {
return config.raw ? s : encodeURIComponent(s);
}

function decode(s) {
return config.raw ? s : decodeURIComponent(s);
}

function stringifyCookieValue(value) {
return encode(config.json ? JSON.stringify(value) : String(value));
}

function parseCookieValue(s) {
if (s.indexOf('"') === 0) {
// This is a quoted cookie as according to RFC2068, unescape...
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
}

try {
// Replace server-side written pluses with spaces.
// If we can't decode the cookie, ignore it, it's unusable.
// If we can't parse the cookie, ignore it, it's unusable.
s = decodeURIComponent(s.replace(pluses, ' '));
return config.json ? JSON.parse(s) : s;
} catch(e) {}
}

function read(s, converter) {
var value = config.raw ? s : parseCookieValue(s);
return $.isFunction(converter) ? converter(value) : value;
}

var config = $.cookie = function (key, value, options) {

// Write

if (arguments.length > 1 && !$.isFunction(value)) {
options = $.extend({}, config.defaults, options);

if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setMilliseconds(t.getMilliseconds() + days * 864e+5);
}

return (document.cookie = [
encode(key), '=', stringifyCookieValue(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}

// Read

var result = key ? undefined : {},
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling $.cookie().
cookies = document.cookie ? document.cookie.split('; ') : [],
i = 0,
l = cookies.length;

for (; i < l; i++) {
var parts = cookies[i].split('='),
name = decode(parts.shift()),
cookie = parts.join('=');

if (key === name) {
// If second argument (value) is a function it's a converter...
result = read(cookie, value);
break;
}

// Prevent storing a cookie that we couldn't decode.
if (!key && (cookie = read(cookie)) !== undefined) {
result[name] = cookie;
}
}

return result;
};

config.defaults = {};

$.removeCookie = function (key, options) {
// Must not alter options, thus extending a fresh object...
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
return !$.cookie(key);
};

}));

Java 加密MD5使用

发表于 2020-07-06
字数统计: 158 字 | 阅读时长 ≈ 1 min

下载地址

常用字符串处理

使用

1
String pwd = MD5.md5("test");

源码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.wangjikai.util;

import java.security.MessageDigest;
/**
* 说明:MD5处理
* 修改时间:2014年9月20日
* @version
*/
public class MD5 {

public static String md5(String str) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(str.getBytes());
byte b[] = md.digest();

int i;

StringBuffer buf = new StringBuffer("");
for (int offset = 0; offset < b.length; offset++) {
i = b[offset];
if (i < 0)
i += 256;
if (i < 16)
buf.append("0");
buf.append(Integer.toHexString(i));
}
str = buf.toString();
} catch (Exception e) {
e.printStackTrace();

}
return str;
}
public static void main(String[] args) {
String pwd = MD5.md5("test");
}
}

Js md5.js

发表于 2020-07-05
字数统计: 30 字 | 阅读时长 ≈ 1 min

下载地址

调用

1
2
<!-- md5文件 -->
<script src="https://wjikai.gitee.io/myresoursce/js/md5/md5.js"></script>

使用

1
var pwd=hex_md5("test")

Java 常用字符串处理

发表于 2020-07-04
字数统计: 773 字 | 阅读时长 ≈ 4 min

下载地址

常用字符串处理

使用

1
StringUtils.isNullOrEmpty("test")

源码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
package com.wangjikai.util;
import java.util.UUID;
/**
* 字符串操作常用方法集
* 2020/07/04.
*/
public class StringUtils {

/**
* 对象是否为无效值
* @param obj 要判断的对象
* @return 是否为有效值(不为null 和 ""字符串)
*/
public static boolean isNullOrEmpty(Object obj) {
return obj == null || "".equals(obj.toString());
}

/**
* 将字符串的第一位转为小写
* @param str 需要转换的字符串
* @return 转换后的字符串
*/
public static String toLowerCaseFirstOne(String str) {
if (Character.isLowerCase(str.charAt(0))) {
return str;
} else {
char[] chars = str.toCharArray();
chars[0] = Character.toLowerCase(chars[0]);
return new String(chars);
}
}

/**
* 将字符串的第一位转为大写
* @param str 需要转换的字符串
* @return 转换后的字符串
*/
public static String toUpperCaseFirstOne(String str) {
if (Character.isUpperCase(str.charAt(0))) {
return str;
} else {
char[] chars = str.toCharArray();
chars[0] = Character.toUpperCase(chars[0]);
return new String(chars);
}
}

/**
* 下划线命名转为驼峰命名
* @param str 下划线命名格式
* @return 驼峰命名格式
*/
public static String underScoreCase2CamelCase(String str) {
if (!str.contains("_")) {
return str;
}
StringBuilder sb = new StringBuilder();
char[] chars = str.toCharArray();
boolean flag = false;
for (int i = 0; i < chars.length; i++) {
char ch = chars[i];
if (ch == '_') {
flag = true;
} else {
if (flag) {
sb.append(Character.toUpperCase(ch));
flag = false;
} else {
sb.append(ch);
}
}
}
return sb.toString();
}

/**
* 驼峰命名转为下划线命名
* @param str 驼峰命名格式
* @return 下划线命名格式
*/
public static String camelCase2UnderScoreCase(String str) {
StringBuilder sb = new StringBuilder();
char[] chars = str.toCharArray();
for (int i = 0; i < chars.length; i++) {
char ch = chars[i];
if (Character.isUpperCase(ch)) {
sb.append("_").append(Character.toLowerCase(ch));
} else {
sb.append(ch);
}
}
return sb.toString();
}
/**
* 检证传入值是不是数值类型
*
* @param num
* 待检证的对象
*
* @return true 是数值型数据 false 不是数值型数据
*/
public static boolean checkNum(String num) {
try {
Double.valueOf(num);
} catch (Exception e) {
return false;
}
return true;
}

/**
* 检证传入值是不是INT型
*
* @param num
* 待检证的对象
*
* @return true 是INT型数据 false 不是INT型数据
*/
public static boolean checkInt(String num) {
if (isNullOrEmpty(num)) {
return false;
}
try {
Integer.parseInt(num);
} catch (Exception e) {
return false;
}
return true;
}
/**
* 将字符串中的负数转换成0
*
* */
public static String replaceStr(String str){
if(!str.startsWith("-")){
return str;
}
if (!str.startsWith("-")) {
System.out.println(str);
return str;
}
str = str.replaceAll("^-.*[0-9][.]", "0.");
//str = str.replaceAll("[.][0-9]", ".0");
// 转换负整数
str = str.replaceAll("^-[0-9]{0,}", "0");
// 小数的情况
if(str.indexOf(".") > 0){
String ss = str.substring(0, str.indexOf(".") + 1);
String s = null;
for(int i = str.indexOf(".") + 1; i < str.length(); i ++){
s = str.substring(i, i +1);
if(s.compareTo("0") >= 0 && s.compareTo("9") <= 0){
ss = ss.concat("0");
}else{
ss = ss.concat(str.substring(i));
break;
}
}
str = ss;
}
return str;
}
/**
* 获取uuid
*
* @return uuid
* */
public static String getUuid(){
// uuid
String uuid = UUID.randomUUID().toString();
return uuid;
}

}

Java 自动生成16位Ling类型id

发表于 2020-07-03
字数统计: 463 字 | 阅读时长 ≈ 3 min

下载地址

自动生成16位Ling类型id

使用

1
ID16NumberGenerator.get16NumberID()

源码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125

package com.wangjikai.util;

import org.apache.commons.lang3.time.DateFormatUtils;

/*
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
*/
import java.util.*;

public class ID16NumberGenerator {
private static ID16NumberGenerator instance = new ID16NumberGenerator();
//private Logger logger = LoggerFactory.getLogger(this.getClass());
private long time = 0L;
private int seq = 101;

private ID16NumberGenerator() {
}

public static Long get16NumberID() {
ID16NumberGenerator var0 = instance;
synchronized(instance) {
return instance.generate16Id();
}
}

public static int getNRdmNumber(int n) {
if (n > 10) {
n = 10;
} else if (n < 1) {
n = 1;
}

int min = (int)Math.pow(10.0D, (double)(n - 1));
int max = (int)Math.pow(10.0D, (double)n) - 1;
return getVectorNum(max, min);
}

public static Set<Long> get16NumberID(int count) {
int size = count > 0 ? count : 1;
TreeSet ids = new TreeSet();

while(ids.size() < size) {
ids.add(get16NumberID());
}

return ids;
}

private static synchronized int getVectorNum(int max, int min) {
Random random = new Random();
int s1 = random.nextInt(max) % (max - min + 1) + min;
return s1;
}



public static String getPrchaseNum() {
String timeString = DateFormatUtils.format(new Date(), "yyMMdd");
String result = "CG" + timeString + getVectorNum(999999, 100000);
return result;
}

private Long generate16Id() {
long currentTime = System.currentTimeMillis();
if (currentTime == this.time) {
++this.seq;
} else {
this.seq = 101;
this.time = currentTime;
}

if (this.seq > 999) {
try {
Thread.sleep(1L);
} catch (InterruptedException var4) {
//this.logger.warn(var4.getMessage(), var4);
}

return this.generate16Id();
} else {
return this.time * 1000L + (long)this.seq;
}
}
/**
* 获取uuid
*
* @return uuid
* */
public static String getUuid(){
// uuid
String uuid = UUID.randomUUID().toString();
return uuid;
}

public static void main(String[] arg) throws InterruptedException {

for(int i = 0; i < 10; ++i) {
System.out.println(ID16NumberGenerator.get16NumberID());
}
for(int i = 0; i < 10; ++i) {
// System.out.println(getNRdmNumber(2));
Thread.sleep(1);
System.out.println(ID16NumberGenerator.get16NumberID());
}
System.out.println(ID16NumberGenerator.get16NumberID());


Set<Integer> ints = new TreeSet();

for(int i = 0; i < 10; ++i) {
System.out.println(getNRdmNumber(2));
}

Iterator i$ = ints.iterator();

while(i$.hasNext()) {
Integer num = (Integer)i$.next();
System.out.println(num);
}

System.out.println(ints.size());
}
}

Js jQuery v3.4.1

发表于 2020-07-02
字数统计: 327 字 | 阅读时长 ≈ 2 min

下载地址

中文文档

调用

1
2
3

<!-- jQuery文件 -->
<script src="https://wjikai.gitee.io/myresoursce/js/jquery.min.js"></script>

1. 增加了日期格式化

2. 增加了url传参参数处理中文字符

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* 添加了日期格式化
*/
Date.prototype.format = function(fmt) {
var o = {
"M+" : this.getMonth()+1, //月份
"d+" : this.getDate(), //日
"h+" : this.getHours(), //小时
"m+" : this.getMinutes(), //分
"s+" : this.getSeconds(), //秒
"q+" : Math.floor((this.getMonth()+3)/3), //季度
"S" : this.getMilliseconds() //毫秒
};
if(/(y+)/.test(fmt)) {
fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
}
for(var k in o) {
if(new RegExp("("+ k +")").test(fmt)){
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
}
}
return fmt;
}

/**
* 添加了参数格式化
*/
var setPageParam = function(param, key) {
var paramStr = "";
if (param instanceof String || param instanceof Number || param instanceof Boolean) {
paramStr += "&" + key + "=" + encodeURIComponent(escape(param));
} else {
$.each(param, function(i) {
var k = key == null ? i : key + (param instanceof Array ? "[" + i + "]" : "." + i);
paramStr += '&' + setPageParam(this, k);
});
}
return paramStr.substr(1);
};
/**
* 添加了参数格式化
*/
function getPageParam(){
var theRequest = {};
var url = decodeURI(location.search) // 解决乱码问题
var str = url.substr(1) //substr()方法返回从参数值开始到结束的字符串;
var strs = str.split("&")
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = unescape((strs[i].split("=")[1]));
}
return theRequest;
}
1…333435…38

继开

一辈子很短,努力的做好两件事就好:第一件事是热爱生活,好好的去爱身边的人;第二件事是努力学习,在工作中取得不一样的成绩,实现自己的价值,而不是仅仅为了赚钱。

303 日志
171 标签
RSS
gitee E-Mail
0%
鲁ICP备18007712号
© 2025 继开 | 站点字数统计: 262.2k
博客使用 Hexo 搭建
|
主题 — NexT.Mist v5.1.4
人访问 次查看