分类为 Javascript 的文章:
对齐:用 style=”text-align:center” 属性代替 quill 的 class=”ql-align-center” 版对齐功能 import Quill from 'quill'; const QuillAlign = Quill.import('attributors/style/align'); QuillAlign.whitelist = ['right', 'center', 'justify']; Quill.register(QuillAlign, true); 字号:用 style=”font-size:18px;” 代替 qu...
2024/08/10 浏览数(26) 分类(Javascript)
function dodash(callsign = '') { var sign = callsign.match(/[a-z0-9]+/)[0].toUpperCase(); var hash = 0x73e2; var i = 0; while (i < sign.length) { var f = sign[i].charCodeAt(); hash ^= f<<8; if (sign[i + 1]) { var s = sign[i+1].charCodeAt(); hash ^= s; } i += 2; } return Math.abs(hash); } var code = dodash('BZ0ZZZ'); co...
2021/03/29 浏览数(598) 分类(Ham Radio, Javascript)
basename function basename(str) { return str.split('/').reverse()[0]; } in_array function in_array(elem, arr, i) {// 代码来自 jquery 1.11.3,返回索引或-1 var len; if (arr) { len = arr.length; i = i ? i < 0 ? Math.max(0, len + i) : i : 0; for (; i < len; i++) { // Skip accessing in sparse arrays if (i in arr && arr[i] === elem) { return i; } ...
2017/09/25 浏览数(1,048) 分类(Javascript, PHP)
将 JS 代码放入图片文件 void function(){ var source = 'js.png'; // 存放JS代码的图片 var img = document.createElement('img'); img.src = source; img.onload = function(){ var canvas = document.createElement('canvas'); canvas.width = img.width; canvas.height = img.height; var context = canvas.getContext("2d"); context.drawImage(img, 0, 0); var imageData = contex...
2017/08/12 浏览数(418) 分类(Javascript, 数据安全)
var code = 'alert("hello image.");'; var w=6,h=8; // 宽和高的计算方法 w * h * 32 / 8 = code.length // 按3个字符的长度分段 var codeArray = code.match(/.{3}/g); if(codeArray.length * 3 < code.length){ codeArray.push( code.substring( codeArray.length * 3 - 1) ); } for(var i = 0, cl = codeArray.length; i < cl; c++){ codeArray[i] = codeArray[i]+String.fromChar...
2017/08/12 浏览数(484) 分类(Javascript, 数据安全)
// 是否身份证号 // 15位用正则验证,18位用校验码 // https://wapbaike.baidu.com/item/身份证校验码 String.prototype.isIdCard = function () { var id = this; var a = id.toUpperCase().split(''); var c = '7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2'.split(','); var d = '10X98765432'.split(''); var s = 0; var l = a.length; var v = a[l - 1]; var n = /^\d{6}(18|19|20)\d{2}[01]\d[0123]\d\d{3}...
2017/04/24 浏览数(2,008) 分类(Javascript)
点击默认的input标签时所有文件类型都会显示出来,如果想限制为我们设定的文件类型比如“word“,”excel“,”pdf“等时该怎么办呢? 解决办法是可以给它添加一个accept属性,比如: &amp;lt;input id="File1" type="file" accept=".xls,.doc,.txt,.pdf" /&amp;gt; 文件选择框内只显示出你自定义文件类型的文件,如果想选择其它后缀的文件可以: 支持的文件类型: *.3gpp audio/3gpp, ...
2015/10/14 浏览数(2,350) 分类(Javascript)
keycode 8 = BackSpace BackSpace keycode 9 = Tab Tab keycode 12 = Clear keycode 13 = Enter keycode 16 = Shift_L keycode 17 = Control_L keycode 18 = Alt_L keycode 19 = Pause keycode 20 = Caps_Lock keycode 27 = Escape Escape keycode 32 = space space keycode 33 = Prior keycode 34 = Next keycode 35 = End keycode 36 = Home keycode 37 = Left keycode 38 = Up keycod...
2013/07/31 浏览数(1,985) 分类(Javascript)
获取浏览器地址栏URL中的某个参数值。 function getParam(paramName){ paramValue = ""; isFound = false; if (this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=")>1){ arrSource = unescape(this.location.search).substring(1,this.location.search.length).split("&"); i = 0; while (i < arrSource.length &&a...
2013/06/30 浏览数(1,707) 分类(Javascript)
import CryptoJS from 'crypto-js'; export const encrypt = (string) => { let password = process.env.APP_KEY; var key = CryptoJS.enc.Utf8.parse(password); var option = { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }; var encrypted = CryptoJS.DES.encrypt(string, key, option); return CryptoJS.enc.Base64.stringify(encrypted.ciphertext); }; export const de...
2013/06/27 浏览数(2,957) 分类(Javascript)
点击返回顶部
  1. 留言
  2. 联系方式