1 <html> 2 <head> 3 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9. 4 1/jquery.min.js"></script> 5 <script> 6 $(function(){ 7 $('body') 8 .append( 9 $('<div id="model-protector" align="center"></div>') 10 .css({ 11 position: 'fixed', 12 top: 0, 13 background: 'rgba(0,0,0,0.8)', 14 width: '100%', 15 height: '100%', 16 }) 17 .html('<img src="http://argoscti.com/wp- 18 content/themes/Realist/Realist%20Wordpress%20The 19 me/images/loading.gif" style="height: 50px; 20 width: 50px;margin-top:25%;" /><br/><button 21 id="cerrar_modal" type="button">Ocultar</button> 22 ') 23 ); 24 25 $('#cerrar_modal') 26 .click(function(){ 27 $('#model-protector') 28 .fadeOut(function(){ 29 $(this).remove(); 30 }); 31 }); 32 }); 33 </script> 34 </head> 35 <body></body> 36 </html>
jueves, 27 de junio de 2013
Loading - JQuery
Etiquetas:
html
,
javascript
,
jquery
,
loading
Javascript - Replace All
Un muy sencillo script para un replace all ... diviertansen!!
1 function replaceAll( busca, reemplaza, text ){ 2 var regex = new RegExp(busca, 'g'); 3 text = text.replace(regex, reemplaza); 4 return text; 5 }
Etiquetas:
expresiones regulares
,
javascript
,
regular expresion
,
replace all
jueves, 11 de abril de 2013
Convertir de RGB a Hexadecimal en Javascript
Convertir de RGB a Hexadecimal en Javascript
Copiamos el siguiente Script en un archivo llamado color.js y lo incluyen dentro de la etiqueta head del HTML principal:
color.js
#Developer
1 _rgb = function(rgb){
2 var hexDigits = new Array ("0","1","2","3","4","5","6",
3 "7","8","9","a","b","c","d","e","f");
4
5 return {
6 toHex: function(rgb){
7 rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
8 return "#" + _rgb.hex(rgb[1]) + _rgb.hex(rgb[2]) + _rgb.
9 hex(rgb[3]);
10 },
11 hex: function(x){
12 return isNaN(x) ? "00" : hexDigits[(x - x % 16) / 16] +
13 hexDigits[x % 16];
14 },
15 };
16 }();
#Production
1 _rgb=function(e){var t=new Array("0","1","2","3","4","5","6",
2 "7","8","9","a","b","c","d","e","f");return{toHex:function(e)
3 {e=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);return"#"+
4 _rgb.hex(e[1])+_rgb.hex(e[2])+_rgb.hex(e[3])},hex:function(e)
5 {return isNaN(e)?"00":t[(e-e%16)/16]+t[e%16]}}}();
index.html
1 <script type="text/javascript">
2 alert(_rgb.toHex('rgb(255,0,255)'))
3 </script>
Y listo eso es todo!.
Convertir de RGB a Hexadecimal en Javascript
Copiamos el siguiente Script en un archivo llamado color.js y lo incluyen dentro de la etiqueta head del HTML principal:
color.js
#Developer
1 _rgb = function(rgb){ 2 var hexDigits = new Array ("0","1","2","3","4","5","6", 3 "7","8","9","a","b","c","d","e","f"); 4 5 return { 6 toHex: function(rgb){ 7 rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); 8 return "#" + _rgb.hex(rgb[1]) + _rgb.hex(rgb[2]) + _rgb. 9 hex(rgb[3]); 10 }, 11 hex: function(x){ 12 return isNaN(x) ? "00" : hexDigits[(x - x % 16) / 16] + 13 hexDigits[x % 16]; 14 }, 15 }; 16 }();
#Production
1 _rgb=function(e){var t=new Array("0","1","2","3","4","5","6", 2 "7","8","9","a","b","c","d","e","f");return{toHex:function(e) 3 {e=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);return"#"+ 4 _rgb.hex(e[1])+_rgb.hex(e[2])+_rgb.hex(e[3])},hex:function(e) 5 {return isNaN(e)?"00":t[(e-e%16)/16]+t[e%16]}}}();
index.html
1 <script type="text/javascript"> 2 alert(_rgb.toHex('rgb(255,0,255)')) 3 </script>
Y listo eso es todo!.
Etiquetas:
color
,
hexadecimal
,
html
,
javascript
,
rgb
Suscribirse a:
Entradas
(
Atom
)