Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

thuan-client

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

thuan-client - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

dist/index.js

111

index.js

@@ -1,7 +0,104 @@

var fs = require('fs');
var list = fs.readdirSync(__dirname+'/dist');
var name = '';
for(var i=0, n=list.length; i<n; i++){
name = list[i].replace('.js', '');
module.exports[name] = require(__dirname+'/dist/'+name);
}
function empty (s) {
return !(s||s.length||Object.keys(s).length);
};
module.exports.empty = empty;
module.exports.confirm = function (o, cb) {
var div = document.getElementById('modal');
var html = '<div id="modal_first"></div>';
html += '<div id="modal_last">';
html += '<form action="javascript:void(0);" method="GET">';
if(o.header) html += '<header>'+o.header+'</header>';
if(o.content) html += '<section>'+o.content+'</section>';
html += '<footer class="clearfix">';
html += '<span></span>';
if(o.btn) {
for(var i in o.btn){
if('string'==typeof o.btn[i]) html += '<button type="submit" name="modal_btn" value="'+i+'" class="btn btn-default">' + o.btn[i] + '</button>';
else html += '<button type="submit" name="modal_btn" value="'+i+'" class="btn '+(o.btn[i].class||'')+'">' + o.btn[i].text + '</button>';
}
};
html += '</footer></form></div>';
div.innerHTML = html; html=false;
var modal_last = document.getElementById('modal_last');
modal_last.style.left = (window.innerWidth-modal_last.clientWidth-20)/2 + 'px';
div.onclick = function (e) {
if(e.target.name=='modal_btn'){
if(o.remove===false) cb(e.target.value, div);
else{cb(e.target.value);this.innerHTML=''}
}
};
return false;
};
module.exports.cookie = {
set: function (o) {
for(var i in o){ document.cookie = i + '=' + o[i] + ';' + this.str };
return true;
},
init: function (o) {
if(o){
this.str = '';
for(var i in o){ this.str += i+'='+o[i]+';' };
}else{
var it = document.cookie, array = [];
if(!it) return false;
it = it.split('; ');
for(var i=0, n=it.length; i<n; i++){
array = it[i].split('=');
this[array[0]] = array[1];
};
it = null; array = [];
};
return this;
},
remove: function (name) {
if(name) document.cookie = name+'=;'+this.str;
return true;
}
};
module.exports.is = {
name: function (a) {
if(empty(a)) return false;
var n = a.trim(), s;
if(n.length<2||n.length>71) return false;
if(/[~`!@#\$%\^&\*\(\)_\+\-=\{\}\[\]\\:\";\'<>\?\,\.\/\|\d]+/g.test(n)) return false;
s = n.match(/\s/g);
if(s!=null){if(s.length>1) return false}
s = n.match(/[QWERTYUIOPASDFGHJKLZXCVBNMƯỨỮỬỰAĂÂÁÀẢÃẠĂẮẰẶẴẲẤẦẨẪẬĐÊẾỀỂỄỆÍÌỈĨỊÝỲỶỸỴ]/g);
if(s!=null){if(s.length>2) return false}
return true;
},
phone: function (a) {
if(empty(a)) return false;
return (/^[0-9]{9,15}$/g.test(a)&&a[0]==0);
},
code: function (a) {
if(empty(a)) return false;
return /^[0-9]{10}$/g.test(a);
},
pass: function (a) {
if(empty(a)) return false;
return /(.){8,100}/g.test(a);
},
email: function (a) {
if(empty(a)) return false;
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/g;
return filter.test(a);
},
username: function (a) {
if(empty(a)) return false;
return /^[a-zA-Z0-9\.]{1,50}$/gi.test(a);
},
url: function (a) {
if(empty(a)) return false;
var urlRegex = /(http|https|ftp)\:\/\/([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&amp;%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(\/($|[a-zA-Z0-9\.\,\?\'\\\+&amp;%\$#\=~_\-]+))*/g;
var url = urlRegex.exec(a);
if (url && url.length) { return url[0]; } else { return false; }
},
image: function (a) {
if(empty(a)) return false;
var p = a.split('/'), ext = ['jpeg', 'png', 'gif', 'bmp', 'jpg'];
return (p[0]=='image' && ext.indexOf(p[1]) > -1) ? p[1] : false;
}
};

4

package.json

@@ -5,4 +5,4 @@ {

"description": "Code use client for my project",
"version": "2.0.1",
"main": "index.js",
"version": "2.0.2",
"main": "./dist/index.js",
"scripts": {

@@ -9,0 +9,0 @@ "test": "echo \"Error: no test specified\" && exit 1"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc