How to use ch method in wpt

Best JavaScript code snippet using wpt

html_decoder.js

Source:html_decoder.js Github

copy

Full Screen

1// HtmlDecode http://lab.msdn.microsoft.com/annotations/htmldecode.js2// client side version of the useful Server.HtmlDecode method3// takes one string (encoded) and returns another (decoded)4function HtmlDecode (s) {5 var out = '';6 7 if (s == null) {8 return;9 }10 11 var l = s.length;12 13 for (var i=0; i<l; i++) {14 var ch = s.charAt(i);15 if (ch == '&') {16 var semicolonIndex = s.indexOf(';', i+1);17 if (semicolonIndex > 0) {18 var entity = s.substring(i + 1, semicolonIndex);19 if (entity.length > 1 && entity.charAt(0) == '#') {20 if (entity.charAt(1) == 'x' || entity.charAt(1) == 'X') {21 ch = String.fromCharCode(eval('0'+entity.substring(1)));22 } else {23 ch = String.fromCharCode(eval(entity.substring(1)));24 }25 } else {26 switch (entity) {27 case 'quot': ch = String.fromCharCode(0x0022); break;28 case 'amp': ch = String.fromCharCode(0x0026); break;29 case 'lt': ch = String.fromCharCode(0x003c); break;30 case 'gt': ch = String.fromCharCode(0x003e); break;31 case 'nbsp': ch = String.fromCharCode(0x00a0); break;32 case 'iexcl': ch = String.fromCharCode(0x00a1); break;33 case 'cent': ch = String.fromCharCode(0x00a2); break;34 case 'pound': ch = String.fromCharCode(0x00a3); break;35 case 'curren': ch = String.fromCharCode(0x00a4); break;36 case 'yen': ch = String.fromCharCode(0x00a5); break;37 case 'brvbar': ch = String.fromCharCode(0x00a6); break;38 case 'sect': ch = String.fromCharCode(0x00a7); break;39 case 'uml': ch = String.fromCharCode(0x00a8); break;40 case 'copy': ch = String.fromCharCode(0x00a9); break;41 case 'ordf': ch = String.fromCharCode(0x00aa); break;42 case 'laquo': ch = String.fromCharCode(0x00ab); break;43 case 'not': ch = String.fromCharCode(0x00ac); break;44 case 'shy': ch = String.fromCharCode(0x00ad); break;45 case 'reg': ch = String.fromCharCode(0x00ae); break;46 case 'macr': ch = String.fromCharCode(0x00af); break;47 case 'deg': ch = String.fromCharCode(0x00b0); break;48 case 'plusmn': ch = String.fromCharCode(0x00b1); break;49 case 'sup2': ch = String.fromCharCode(0x00b2); break;50 case 'sup3': ch = String.fromCharCode(0x00b3); break;51 case 'acute': ch = String.fromCharCode(0x00b4); break;52 case 'micro': ch = String.fromCharCode(0x00b5); break;53 case 'para': ch = String.fromCharCode(0x00b6); break;54 case 'middot': ch = String.fromCharCode(0x00b7); break;55 case 'cedil': ch = String.fromCharCode(0x00b8); break;56 case 'sup1': ch = String.fromCharCode(0x00b9); break;57 case 'ordm': ch = String.fromCharCode(0x00ba); break;58 case 'raquo': ch = String.fromCharCode(0x00bb); break;59 case 'frac14': ch = String.fromCharCode(0x00bc); break;60 case 'frac12': ch = String.fromCharCode(0x00bd); break;61 case 'frac34': ch = String.fromCharCode(0x00be); break;62 case 'iquest': ch = String.fromCharCode(0x00bf); break;63 case 'Agrave': ch = String.fromCharCode(0x00c0); break;64 case 'Aacute': ch = String.fromCharCode(0x00c1); break;65 case 'Acirc': ch = String.fromCharCode(0x00c2); break;66 case 'Atilde': ch = String.fromCharCode(0x00c3); break;67 case 'Auml': ch = String.fromCharCode(0x00c4); break;68 case 'Aring': ch = String.fromCharCode(0x00c5); break;69 case 'AElig': ch = String.fromCharCode(0x00c6); break;70 case 'Ccedil': ch = String.fromCharCode(0x00c7); break;71 case 'Egrave': ch = String.fromCharCode(0x00c8); break;72 case 'Eacute': ch = String.fromCharCode(0x00c9); break;73 case 'Ecirc': ch = String.fromCharCode(0x00ca); break;74 case 'Euml': ch = String.fromCharCode(0x00cb); break;75 case 'Igrave': ch = String.fromCharCode(0x00cc); break;76 case 'Iacute': ch = String.fromCharCode(0x00cd); break;77 case 'Icirc': ch = String.fromCharCode(0x00ce ); break;78 case 'Iuml': ch = String.fromCharCode(0x00cf); break;79 case 'ETH': ch = String.fromCharCode(0x00d0); break;80 case 'Ntilde': ch = String.fromCharCode(0x00d1); break;81 case 'Ograve': ch = String.fromCharCode(0x00d2); break;82 case 'Oacute': ch = String.fromCharCode(0x00d3); break;83 case 'Ocirc': ch = String.fromCharCode(0x00d4); break;84 case 'Otilde': ch = String.fromCharCode(0x00d5); break;85 case 'Ouml': ch = String.fromCharCode(0x00d6); break;86 case 'times': ch = String.fromCharCode(0x00d7); break;87 case 'Oslash': ch = String.fromCharCode(0x00d8); break;88 case 'Ugrave': ch = String.fromCharCode(0x00d9); break;89 case 'Uacute': ch = String.fromCharCode(0x00da); break;90 case 'Ucirc': ch = String.fromCharCode(0x00db); break;91 case 'Uuml': ch = String.fromCharCode(0x00dc); break;92 case 'Yacute': ch = String.fromCharCode(0x00dd); break;93 case 'THORN': ch = String.fromCharCode(0x00de); break;94 case 'szlig': ch = String.fromCharCode(0x00df); break;95 case 'agrave': ch = String.fromCharCode(0x00e0); break;96 case 'aacute': ch = String.fromCharCode(0x00e1); break;97 case 'acirc': ch = String.fromCharCode(0x00e2); break;98 case 'atilde': ch = String.fromCharCode(0x00e3); break;99 case 'auml': ch = String.fromCharCode(0x00e4); break;100 case 'aring': ch = String.fromCharCode(0x00e5); break;101 case 'aelig': ch = String.fromCharCode(0x00e6); break;102 case 'ccedil': ch = String.fromCharCode(0x00e7); break;103 case 'egrave': ch = String.fromCharCode(0x00e8); break;104 case 'eacute': ch = String.fromCharCode(0x00e9); break;105 case 'ecirc': ch = String.fromCharCode(0x00ea); break;106 case 'euml': ch = String.fromCharCode(0x00eb); break;107 case 'igrave': ch = String.fromCharCode(0x00ec); break;108 case 'iacute': ch = String.fromCharCode(0x00ed); break;109 case 'icirc': ch = String.fromCharCode(0x00ee); break;110 case 'iuml': ch = String.fromCharCode(0x00ef); break;111 case 'eth': ch = String.fromCharCode(0x00f0); break;112 case 'ntilde': ch = String.fromCharCode(0x00f1); break;113 case 'ograve': ch = String.fromCharCode(0x00f2); break;114 case 'oacute': ch = String.fromCharCode(0x00f3); break;115 case 'ocirc': ch = String.fromCharCode(0x00f4); break;116 case 'otilde': ch = String.fromCharCode(0x00f5); break;117 case 'ouml': ch = String.fromCharCode(0x00f6); break;118 case 'divide': ch = String.fromCharCode(0x00f7); break;119 case 'oslash': ch = String.fromCharCode(0x00f8); break;120 case 'ugrave': ch = String.fromCharCode(0x00f9); break;121 case 'uacute': ch = String.fromCharCode(0x00fa); break;122 case 'ucirc': ch = String.fromCharCode(0x00fb); break;123 case 'uuml': ch = String.fromCharCode(0x00fc); break;124 case 'yacute': ch = String.fromCharCode(0x00fd); break;125 case 'thorn': ch = String.fromCharCode(0x00fe); break;126 case 'yuml': ch = String.fromCharCode(0x00ff); break;127 case 'OElig': ch = String.fromCharCode(0x0152); break;128 case 'oelig': ch = String.fromCharCode(0x0153); break;129 case 'Scaron': ch = String.fromCharCode(0x0160); break;130 case 'scaron': ch = String.fromCharCode(0x0161); break;131 case 'Yuml': ch = String.fromCharCode(0x0178); break;132 case 'fnof': ch = String.fromCharCode(0x0192); break;133 case 'circ': ch = String.fromCharCode(0x02c6); break;134 case 'tilde': ch = String.fromCharCode(0x02dc); break;135 case 'Alpha': ch = String.fromCharCode(0x0391); break;136 case 'Beta': ch = String.fromCharCode(0x0392); break;137 case 'Gamma': ch = String.fromCharCode(0x0393); break;138 case 'Delta': ch = String.fromCharCode(0x0394); break;139 case 'Epsilon': ch = String.fromCharCode(0x0395); break;140 case 'Zeta': ch = String.fromCharCode(0x0396); break;141 case 'Eta': ch = String.fromCharCode(0x0397); break;142 case 'Theta': ch = String.fromCharCode(0x0398); break;143 case 'Iota': ch = String.fromCharCode(0x0399); break;144 case 'Kappa': ch = String.fromCharCode(0x039a); break;145 case 'Lambda': ch = String.fromCharCode(0x039b); break;146 case 'Mu': ch = String.fromCharCode(0x039c); break;147 case 'Nu': ch = String.fromCharCode(0x039d); break;148 case 'Xi': ch = String.fromCharCode(0x039e); break;149 case 'Omicron': ch = String.fromCharCode(0x039f); break;150 case 'Pi': ch = String.fromCharCode(0x03a0); break;151 case ' Rho ': ch = String.fromCharCode(0x03a1); break;152 case 'Sigma': ch = String.fromCharCode(0x03a3); break;153 case 'Tau': ch = String.fromCharCode(0x03a4); break;154 case 'Upsilon': ch = String.fromCharCode(0x03a5); break;155 case 'Phi': ch = String.fromCharCode(0x03a6); break;156 case 'Chi': ch = String.fromCharCode(0x03a7); break;157 case 'Psi': ch = String.fromCharCode(0x03a8); break;158 case 'Omega': ch = String.fromCharCode(0x03a9); break;159 case 'alpha': ch = String.fromCharCode(0x03b1); break;160 case 'beta': ch = String.fromCharCode(0x03b2); break;161 case 'gamma': ch = String.fromCharCode(0x03b3); break;162 case 'delta': ch = String.fromCharCode(0x03b4); break;163 case 'epsilon': ch = String.fromCharCode(0x03b5); break;164 case 'zeta': ch = String.fromCharCode(0x03b6); break;165 case 'eta': ch = String.fromCharCode(0x03b7); break;166 case 'theta': ch = String.fromCharCode(0x03b8); break;167 case 'iota': ch = String.fromCharCode(0x03b9); break;168 case 'kappa': ch = String.fromCharCode(0x03ba); break;169 case 'lambda': ch = String.fromCharCode(0x03bb); break;170 case 'mu': ch = String.fromCharCode(0x03bc); break;171 case 'nu': ch = String.fromCharCode(0x03bd); break;172 case 'xi': ch = String.fromCharCode(0x03be); break;173 case 'omicron': ch = String.fromCharCode(0x03bf); break;174 case 'pi': ch = String.fromCharCode(0x03c0); break;175 case 'rho': ch = String.fromCharCode(0x03c1); break;176 case 'sigmaf': ch = String.fromCharCode(0x03c2); break;177 case 'sigma': ch = String.fromCharCode(0x03c3); break;178 case 'tau': ch = String.fromCharCode(0x03c4); break;179 case 'upsilon': ch = String.fromCharCode(0x03c5); break;180 case 'phi': ch = String.fromCharCode(0x03c6); break;181 case 'chi': ch = String.fromCharCode(0x03c7); break;182 case 'psi': ch = String.fromCharCode(0x03c8); break;183 case 'omega': ch = String.fromCharCode(0x03c9); break;184 case 'thetasym': ch = String.fromCharCode(0x03d1); break;185 case 'upsih': ch = String.fromCharCode(0x03d2); break;186 case 'piv': ch = String.fromCharCode(0x03d6); break;187 case 'ensp': ch = String.fromCharCode(0x2002); break;188 case 'emsp': ch = String.fromCharCode(0x2003); break;189 case 'thinsp': ch = String.fromCharCode(0x2009); break;190 case 'zwnj': ch = String.fromCharCode(0x200c); break;191 case 'zwj': ch = String.fromCharCode(0x200d); break;192 case 'lrm': ch = String.fromCharCode(0x200e); break;193 case 'rlm': ch = String.fromCharCode(0x200f); break;194 case 'ndash': ch = String.fromCharCode(0x2013); break;195 case 'mdash': ch = String.fromCharCode(0x2014); break;196 case 'lsquo': ch = String.fromCharCode(0x2018); break;197 case 'rsquo': ch = String.fromCharCode(0x2019); break;198 case 'sbquo': ch = String.fromCharCode(0x201a); break;199 case 'ldquo': ch = String.fromCharCode(0x201c); break;200 case 'rdquo': ch = String.fromCharCode(0x201d); break;201 case 'bdquo': ch = String.fromCharCode(0x201e); break;202 case 'dagger': ch = String.fromCharCode(0x2020); break;203 case 'Dagger': ch = String.fromCharCode(0x2021); break;204 case 'bull': ch = String.fromCharCode(0x2022); break;205 case 'hellip': ch = String.fromCharCode(0x2026); break;206 case 'permil': ch = String.fromCharCode(0x2030); break;207 case 'prime': ch = String.fromCharCode(0x2032); break;208 case 'Prime': ch = String.fromCharCode(0x2033); break;209 case 'lsaquo': ch = String.fromCharCode(0x2039); break;210 case 'rsaquo': ch = String.fromCharCode(0x203a); break;211 case 'oline': ch = String.fromCharCode(0x203e); break;212 case 'frasl': ch = String.fromCharCode(0x2044); break;213 case 'euro': ch = String.fromCharCode(0x20ac); break;214 case 'image': ch = String.fromCharCode(0x2111); break;215 case 'weierp': ch = String.fromCharCode(0x2118); break;216 case 'real': ch = String.fromCharCode(0x211c); break;217 case 'trade': ch = String.fromCharCode(0x2122); break;218 case 'alefsym': ch = String.fromCharCode(0x2135); break;219 case 'larr': ch = String.fromCharCode(0x2190); break;220 case 'uarr': ch = String.fromCharCode(0x2191); break;221 case 'rarr': ch = String.fromCharCode(0x2192); break;222 case 'darr': ch = String.fromCharCode(0x2193); break;223 case 'harr': ch = String.fromCharCode(0x2194); break;224 case 'crarr': ch = String.fromCharCode(0x21b5); break;225 case 'lArr': ch = String.fromCharCode(0x21d0); break;226 case 'uArr': ch = String.fromCharCode(0x21d1); break;227 case 'rArr': ch = String.fromCharCode(0x21d2); break;228 case 'dArr': ch = String.fromCharCode(0x21d3); break;229 case 'hArr': ch = String.fromCharCode(0x21d4); break;230 case 'forall': ch = String.fromCharCode(0x2200); break;231 case 'part': ch = String.fromCharCode(0x2202); break;232 case 'exist': ch = String.fromCharCode(0x2203); break;233 case 'empty': ch = String.fromCharCode(0x2205); break;234 case 'nabla': ch = String.fromCharCode(0x2207); break;235 case 'isin': ch = String.fromCharCode(0x2208); break;236 case 'notin': ch = String.fromCharCode(0x2209); break;237 case 'ni': ch = String.fromCharCode(0x220b); break;238 case 'prod': ch = String.fromCharCode(0x220f); break;239 case 'sum': ch = String.fromCharCode(0x2211); break;240 case 'minus': ch = String.fromCharCode(0x2212); break;241 case 'lowast': ch = String.fromCharCode(0x2217); break;242 case 'radic': ch = String.fromCharCode(0x221a); break;243 case 'prop': ch = String.fromCharCode(0x221d); break;244 case 'infin': ch = String.fromCharCode(0x221e); break;245 case 'ang': ch = String.fromCharCode(0x2220); break;246 case 'and': ch = String.fromCharCode(0x2227); break;247 case 'or': ch = String.fromCharCode(0x2228); break;248 case 'cap': ch = String.fromCharCode(0x2229); break;249 case 'cup': ch = String.fromCharCode(0x222a); break;250 case 'int': ch = String.fromCharCode(0x222b); break;251 case 'there4': ch = String.fromCharCode(0x2234); break;252 case 'sim': ch = String.fromCharCode(0x223c); break;253 case 'cong': ch = String.fromCharCode(0x2245); break;254 case 'asymp': ch = String.fromCharCode(0x2248); break;255 case 'ne': ch = String.fromCharCode(0x2260); break;256 case 'equiv': ch = String.fromCharCode(0x2261); break;257 case 'le': ch = String.fromCharCode(0x2264); break;258 case 'ge': ch = String.fromCharCode(0x2265); break;259 case 'sub': ch = String.fromCharCode(0x2282); break;260 case 'sup': ch = String.fromCharCode(0x2283); break;261 case 'nsub': ch = String.fromCharCode(0x2284); break;262 case 'sube': ch = String.fromCharCode(0x2286); break;263 case 'supe': ch = String.fromCharCode(0x2287); break;264 case 'oplus': ch = String.fromCharCode(0x2295); break;265 case 'otimes': ch = String.fromCharCode(0x2297); break;266 case 'perp': ch = String.fromCharCode(0x22a5); break;267 case 'sdot': ch = String.fromCharCode(0x22c5); break;268 case 'lceil': ch = String.fromCharCode(0x2308); break;269 case 'rceil': ch = String.fromCharCode(0x2309); break;270 case 'lfloor': ch = String.fromCharCode(0x230a); break;271 case 'rfloor': ch = String.fromCharCode(0x230b); break;272 case 'lang': ch = String.fromCharCode(0x2329); break;273 case 'rang': ch = String.fromCharCode(0x232a); break;274 case 'loz': ch = String.fromCharCode(0x25ca); break;275 case 'spades': ch = String.fromCharCode(0x2660); break;276 case 'clubs': ch = String.fromCharCode(0x2663); break;277 case 'hearts': ch = String.fromCharCode(0x2665); break;278 case 'diams': ch = String.fromCharCode(0x2666); break;279 default: ch = ''; break;280 }281 }282 i = semicolonIndex;283 }284 }285 out += ch;286 }287 return out;...

Full Screen

Full Screen

editarPerfil.js

Source:editarPerfil.js Github

copy

Full Screen

...9 //var foto = $("#image")[0].files[0];10 let Body = { nombre, apellidos,correo,contra,foto, opc }11 let jsonBody = JSON.stringify(Body)12 13 fetch('php/perfilUsuarioImagen.php', { method: "POST", header: { 'Content-Type': 'application/json' }, body: jsonBody })14 .then(response => {15 return response.text();16 })17 .then(data => {18 var Jason = data;19 console.log(Jason);20 if (Jason === "CambiosHechos") {21 alert("Los datos se modificaron correctamente");22 window.location.href = "Perfil.html";23 }24 else25 alert(Jason.result);26 27 })28 /* var nombre = document.getElementById("username").value;29 var apellidos = document.getElementById("lastname").value;30 var laFechas= document.getElementById("birthday").value;31 var correo = document.getElementById("email").value;32 var esProfeProv = $('input:radio[name=rol]:checked').val();33 var contra = document.getElementById("password").value; 34 var imagenComprobacion = document.getElementById("image").value; 35 36 var num = false;37 var carac = false;38 var arroba = false;39 var com = false;40 41 if (nombre.length!= 0 && apellidos.length!=0 && correo.length!=0 && imagenComprobacion.length != 0){42 43 if(correo.length > 5){ 44 45 for (var i = 0; i < correo.length; i++) {46 var ch = correo.charAt(i);47 48 if(ch == "@"){49 arroba = true50 }51 52 if (ch == "."){53 if ((ch = correo.charAt(i+1)) == "c"){54 if ((ch = correo.charAt(i+2)) == "o"){55 if ((ch = correo.charAt(i+3)) == "m"){56 com = true57 }58 }59 }60 }61 62 }63 64 if(arroba == true && com == true){65 if (contra.length >= 8) {66 67 for (var i = 0; i < contra.length; i++) {68 var ch = contra.charAt(i);69 if (ch >= "0" || ch <= "9")70 num = true;71 if (ch == "/" || ch == "*" || ch == "¡" || ch == "”" || ch == "#" || ch == "$" || ch == "%" || ch == "&" || ch == "=" || ch == "’" || ch == "?" || ch == "¡" || ch == "¿" || ch == ":" || ch == ";" || ch == "," || ch == "."72 || ch == "-" || ch == "_" || ch == "+" || ch == "{" || ch == "]" || ch == "[" || ch == "}"|| ch=="@") {73 carac = true;74 }75 }76 if (num==true&&carac==true) {77 window.alert("Contraseña guardada");78 var opc=4;79 80 let Body = {nombre,apellidos,correo,contra,imagenComprobacion,opc} 81 82 var FoDatos = new FormData();83 FoDatos.append('nombre',nombre);84 FoDatos.append('apellido',apellidos);85 FoDatos.append('correo',correo);86 FoDatos.append('contra',contra);87 FoDatos.append('foto',$("#image")[0].files[0]);88 FoDatos.append('opc',opc); 89 90 fetch('php/perfilUsuarioImagen.php',{method:"POST",body:FoDatos})91 .then(response => {92 return response.text();93 })94 .then(data => {95 96 var Jason =data;97 console.log(Jason);98 if(Jason==="success"){99 alert("Registro exitoso");100 window.location.href="Login.php";101 }102 else103 alert(Jason.result)104 //"status" => "ok",105 //"result" => array()106 })107 }else {108 window.alert("La contraseña debe tener al menos un numero y un caracter especial")109 }110 }111 else{112 window.alert("La contraseña debe tener 8 caracteres")113 }114 }115 else{116 window.alert("Verifique el correo")117 } 118 119 }120 else{121 window.alert("Correo no aceptable")122 } 123 }124 else{125 window.alert("Debe llenar todos los campos")126 }*/127 }128 function editar(form) {129 130 var nombre = document.getElementById("nombre").value;131 var apellidos = document.getElementById("apellidos").value;132 var correo = document.getElementById("email").value;133 var contra = document.getElementById("contra").value;134 var foto = document.getElementById("image").value; 135 136 var num = false;137 var carac = false;138 var arroba = false;139 var com = false;140 141 if (nombre.length!= 0 && apellidos.length!=0 && correo.length!=0 && foto.length != 0){142 143 if(correo.length > 5){ 144 145 for (var i = 0; i < correo.length; i++) {146 var ch = correo.charAt(i);147 148 if(ch == "@"){149 arroba = true150 }151 152 if (ch == "."){153 if ((ch = correo.charAt(i+1)) == "c"){154 if ((ch = correo.charAt(i+2)) == "o"){155 if ((ch = correo.charAt(i+3)) == "m"){156 com = true157 }158 }159 }160 }161 162 }163 164 if(arroba == true && com == true){165 if (contra.length >= 8) {166 167 for (var i = 0; i < contra.length; i++) {168 var ch = contra.charAt(i);169 if (ch >= "0" || ch <= "9")170 num = true;171 if (ch == "/" || ch == "*" || ch == "¡" || ch == "”" || ch == "#" || ch == "$" || ch == "%" || ch == "&" || ch == "=" || ch == "’" || ch == "?" || ch == "¡" || ch == "¿" || ch == ":" || ch == ";" || ch == "," || ch == "."172 || ch == "-" || ch == "_" || ch == "+" || ch == "{" || ch == "]" || ch == "[" || ch == "}"|| ch=="@") {173 carac = true;174 }175 }176 if (num==true&&carac==true) {177 window.alert("Contraseña guardada");178 var opc=4;179 180 181 let Body = {nombre,apellidos,correo,contra,foto,opc} 182 183 var FoDatos = new FormData();184 FoDatos.append('nombre',nombre);185 FoDatos.append('apellido',apellidos);186 FoDatos.append('correo',correo);187 FoDatos.append('contra',contra);188 FoDatos.append('foto',$("#image")[0].files[0]);189 FoDatos.append('opc',opc); 190 191 fetch('php/perfilUsuarioImagen.php',{method:"POST",body:FoDatos})192 .then(response => {193 return response.text();194 })195 .then(data => {196 197 var Jason =data;198 console.log(Jason);199 if(Jason==="success"){200 alert("Registro exitoso");201 window.location.href="Login.php"202 }203 else204 //alert(Jason.result);205 alert("Cambios hechos, se cerrará su sesión para volver a entrar");...

Full Screen

Full Screen

jquery.slug.js

Source:jquery.slug.js Github

copy

Full Screen

1//2// jQuery Slug Plugin by Perry Trinier (perrytrinier@gmail.com)3// MIT License: http://www.opensource.org/licenses/mit-license.php45jQuery.fn.slug = function(options) {6 var settings = {7 slug: 'slug', // Class used for slug destination input and span. The span is created on $(document).ready()8 hide: true // Boolean - By default the slug input field is hidden, set to false to show the input field and hide the span.9 };1011 if(options) {12 jQuery.extend(settings, options);13 }1415 $this = $(this);1617 $(document).ready( function() {18 if (settings.hide) {19 $('input.' + settings.slug).after("<span class="+settings.slug+"></span>");20 $('input.' + settings.slug).hide();21 }22 });2324 var transliterate = function(str) {25 var rExps=[26 {re: /ä|æ|ǽ/g, ch: 'ae'},27 {re: /ö|œ/g, ch: 'oe'},28 {re: /ü/g, ch: 'ue'},29 {re: /Ä/g, ch: 'Ae'},30 {re: /Ü/g, ch: 'Ue'},31 {re: /Ö/g, ch: 'Oe'},32 {re: /À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ/g, ch: 'A'},33 {re: /à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª/g, ch: 'a'},34 {re: /Ç|Ć|Ĉ|Ċ|Č/g, ch: 'C'},35 {re: /ç|ć|ĉ|ċ|č/g, ch: 'c'},36 {re: /Ð|Ď|Đ/g, ch: 'D'},37 {re: /ð|ď|đ/g, ch: 'd'},38 {re: /È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě/g, ch: 'E'},39 {re: /è|é|ê|ë|ē|ĕ|ė|ę|ě/g, ch: 'e'},40 {re: /Ĝ|Ğ|Ġ|Ģ/g, ch: 'G'},41 {re: /ĝ|ğ|ġ|ģ/g, ch: 'g'},42 {re: /Ĥ|Ħ/g, ch: 'H'},43 {re: /ĥ|ħ/g, ch: 'h'},44 {re: /Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ/g, ch: 'I'},45 {re: /ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı/g, ch: 'i'},46 {re: /Ĵ/g, ch: 'J'},47 {re: /ĵ/g, ch: 'j'},48 {re: /Ķ/g, ch: 'K'},49 {re: /ķ/g, ch: 'k'},50 {re: /Ĺ|Ļ|Ľ|Ŀ|Ł/g, ch: 'L'},51 {re: /ĺ|ļ|ľ|ŀ|ł/g, ch: 'l'},52 {re: /Ñ|Ń|Ņ|Ň/g, ch: 'N'},53 {re: /ñ|ń|ņ|ň|ʼn/g, ch: 'n'},54 {re: /Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ/g, ch: 'O'},55 {re: /ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º/g, ch: 'o'},56 {re: /Ŕ|Ŗ|Ř/g, ch: 'R'},57 {re: /ŕ|ŗ|ř/g, ch: 'r'},58 {re: /Ś|Ŝ|Ş|Š/g, ch: 'S'},59 {re: /ś|ŝ|ş|š|ſ/g, ch: 's'},60 {re: /Ţ|Ť|Ŧ/g, ch: 'T'},61 {re: /ţ|ť|ŧ/g, ch: 't'},62 {re: /Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ/g, ch: 'U'},63 {re: /ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ/g, ch: 'u'},64 {re: /Ý|Ÿ|Ŷ/g, ch: 'Y'},65 {re: /ý|ÿ|ŷ/g, ch: 'y'},66 {re: /Ŵ/g, ch: 'W'},67 {re: /ŵ/g, ch: 'w'},68 {re: /Ź|Ż|Ž/g, ch: 'Z'},69 {re: /ź|ż|ž/g, ch: 'z'},70 {re: /Æ|Ǽ/g, ch: 'AE'},71 {re: /ß/g, ch: 'ss'},72 {re: /IJ/g, ch: 'IJ'},73 {re: /ij/g, ch: 'ij'},74 {re: /Œ/g, ch: 'OE'},75 {re: /ƒ/g, ch: 'f'}76 ];77 for (var i=0, len=rExps.length; i<len; i++) {78 str = str.replace(rExps[i].re, rExps[i].ch);79 }80 return str;81 }8283 makeSlug = function() {84 var slug = transliterate(jQuery.trim($(this).val()))85 .replace(/\s+/g,'-').replace(/[^a-zA-Z0-9\-]/g,'').toLowerCase()86 .replace(/\-{2,}/g,'-')87 .replace(/\-$/, '')88 .replace(/^\-/, '')89 ;90 $('input.' + settings.slug).val(slug);91 $('span.' + settings.slug).text(slug);92 }9394 $(this).keyup(makeSlug);9596 return $this; ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const {Builder, By, Key, until} = require('selenium-webdriver');2const { Options } = require('selenium-webdriver/chrome');3const chrome = require('selenium-webdriver/chrome');4const path = require('chromedriver').path;5const fs = require('fs');6const options = new Options();7options.addArguments('--headless');8options.addArguments('--disable-gpu');9options.addArguments('--window-size=1920x1080');10options.addArguments('--ignore-certificate-errors');11options.addArguments('--no-sandbox');12options.addArguments('--disable-dev-shm-usage');13options.addArguments('--disable-extensions');14options.addArguments('--disable-dev-shm-usage');15const driver = new Builder()16 .forBrowser('chrome')17 .setChromeOptions(options)18 .build();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var util = require('util');3var fs = require('fs');4var wpt = new WebPageTest('www.webpagetest.org');5var options = {6 videoParams: {7 }8};9 if (err) return console.error(err);10 console.log('Test Results: ' + util.inspect(data));11 var testId = data.data.testId;12 var video = data.data.runs[1].firstView.videoFrames;13 var timeline = data.data.runs[1].firstView.timeline;14 console.log('Video: ' + util.inspect(video));15 console.log('Timeline: ' + util.inspect(timeline));16 var file = fs.createWriteStream("video.mp4");17 var request = http.get(video, function(response) {18 response.pipe(file);19 });20 var file2 = fs.createWriteStream("timeline.json");21 var request2 = http.get(timeline, function(response) {22 response.pipe(file2);23 });24});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var api = wpt('www.webpagetest.org');3api.runTest(url, {location: "Dulles:Chrome", connectivity: "Cable", runs: 3, firstViewOnly: true}, function(err, data) {4 if (err) return console.error(err);5 console.log(data.data.testId);6 api.getTestResults(data.data.testId, function(err, data) {7 if (err) return console.error(err);8 console.log(data.data.median.firstView.SpeedIndex);9 });10});11var psi = require('psi');12psi.output('www.google.com', {strategy: 'mobile'}, function(err) {13 if (err) {14 console.log(err);15 }16});17const lighthouse = require('lighthouse');18const chromeLauncher = require('chrome-launcher');19chromeLauncher.launch({chromeFlags: ['--headless']}).then(chrome => {20 lighthouse(url, {port: chrome.port}).then(results => {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = wpt('www.webpagetest.org', 'A.6f7f6b12c6a2f8b2a6a7b6e5b6d2b5f5');3 if (err) {4 console.log(err);5 } else {6 console.log('Test status: ' + data.statusText);7 console.log('Test ID: ' + data.data.testId);8 test.getTestResults(data.data.testId, function(err, data) {9 if (err) {10 console.log(err);11 } else {12 console.log('Test status: ' + data.statusText);13 console.log('Test ID: ' + data.data.testId);14 console.log('Test URL: ' + data.data.summary);15 console.log('Test results: ' + data.data.median.firstView.SpeedIndex);16 }17 });18 }19});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var test = new wpt(options);5 if (err) return console.error(err);6 console.log('Test submitted to WebPagetest for %s', data.data.testUrl);7 console.log('Test ID: %s', data.data.testId);8 test.getTestResults(data.data.testId, function(err, data) {9 if (err) return console.error(err);10 console.log('First View (loadTime): %d', data.data.average.firstView.loadTime);11 console.log('Repeat View (loadTime): %d', data.data.average.repeatView.loadTime);12 });13});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful