对齐:用 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...
分类为 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...
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;
}
...
将 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...
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...
// 是否身份证号
// 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}...
点击默认的input标签时所有文件类型都会显示出来,如果想限制为我们设定的文件类型比如“word“,”excel“,”pdf“等时该怎么办呢?
解决办法是可以给它添加一个accept属性,比如:
&lt;input id="File1" type="file" accept=".xls,.doc,.txt,.pdf" /&gt;
文件选择框内只显示出你自定义文件类型的文件,如果想选择其它后缀的文件可以:
支持的文件类型:
*.3gpp audio/3gpp, ...
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...
效果:
[Demo] [Case]
用法:
见 js/bookSettings.js:
flippingBook.pages = [
"pages/page-001.jpeg",
"pages/page-002.jpeg",
"pages/page-003.jpeg",
"pages/page-004.jpeg",
"pages/page-005.jpeg",
"pages/page-006.jpeg",
"pages/page-007.jpeg",
"pages/page-008.jpeg",
"pages/page-009.jpeg",
&q...
方法其实相当简单:
把“eval”换为“alert”就能看到源码了。
下图是例子(Firefox的弹出框可以复制):
获取浏览器地址栏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...
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...