fixing javascripts

master
Alinson S. Xavier 12 years ago
parent e75d1f23ea
commit cdafe05e86

@ -1,2 +1,84 @@
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
events = {};
events['#password:keyup'] = function(element, e) {
passmeter();
};
function startup() {
EventSelectors.start(events);
var validation_box = $('validation');
if(validation_box != null) new Effect.Appear(validation_box);
$$('.highlight').each(function(e) {
new Effect.Highlight(e, {duration: 1.5});
});
if(window.history_update) history_update();
}
spin_count = Array();
function spinner_start(s)
{
if(spin_count[s]) spin_count[s]++;
else spin_count[s] = 1;
$("spinner_" + s).show();
}
function spinner_stop(s)
{
spin_count[s]--;
if(spin_count[s] == 0) $("spinner_" + s).hide();
}
function passmeter()
{
var pass = $F('password');
var meter = $('passmeter');
var nivel = 0;
if(pass.length == 0) {
meter.innerHTML = " ";
return;
}
if(pass.length >= 6) {
if(/[a-z_]/.test(pass)) nivel++;
if(/[A-Z]/.test(pass)) nivel++;
if(/[0-9]/.test(pass)) nivel++;
if(/\W/.test(pass)) nivel++;
if(pass.length >= 10) nivel++;
}
switch(nivel) {
case 0: case 1:
msg = "senha muito fraca";
cor = "#d00";
break;
case 2:
msg = "senha fraca";
cor = "#f50";
break;
case 3:
msg = "senha moderada";
cor = "#090";
break;
case 4: default:
msg = "senha forte";
cor = "#05f";
break;
}
meter.style.color = cor;
meter.innerHTML = msg;
}
Ajax.Responders.register({
onComplete: function() { EventSelectors.assign(events);}
})

@ -10,6 +10,7 @@ events['#show_preview:click'] = function(element, e)
spinner_stop("preview");
Element.show('wiki_preview');
new Effect.ScrollTo('wiki_preview');
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
}
});

@ -20,6 +20,9 @@
%script{:type => 'text/javascript'}
== BASE_PATH = "#{App.base_path}";
= javascript_include_tag :base
= javascript_include_tag 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML'
%script{:type => 'text/x-mathjax-config'}
== MathJax.Hub.Config({tex2jax: {inlineMath: [['{$','$}']], displayMath: [['{$$','$$}']]}});
%body{'onload' => 'javascript: startup()'}
#wrapper

@ -396,7 +396,7 @@ class BlueCloth < String
return rval
end
MimeTexURL = "http://isoron.org/tex/math.cgi"
MimeTexURL = "http://lupus.isoron.org/tex/math.cgi"
LatexBlockRegexp = %r{
\{\$\$(.*?)\$\$\}
}xm
@ -419,17 +419,19 @@ class BlueCloth < String
# Block Latex
rval = rval.gsub(LatexBlockRegexp) {|block|
codeblock = $1.strip.gsub("\n", '%0A').gsub(/[ \t]+/, " ")
codeblock = %{<div class="tex_block"><img src="#{MimeTexURL}?%s"/></div>} %
[ encode_code( codeblock, rs ) ]
tokenize(codeblock, rs)
tokenize("{$$#{$1.strip}$$}", rs)
#codeblock = $1.strip.gsub("\n", '%0A').gsub(/[ \t]+/, " ")
#codeblock = %{<div class="tex_block"><img src="#{MimeTexURL}?%s"/></div>} %
# [ encode_code( codeblock, rs ) ]
#tokenize(codeblock, rs)
}
# Inline math
rval = rval.gsub( LatexInlineRegexp ) {|block|
codeblock = $1.strip
codeblock = %{<img class="tex_inline" src="#{MimeTexURL}?\\small %s"/>} % [ encode_code( codeblock, rs ) ]
tokenize(codeblock, rs)
tokenize("{$#{$1.strip}$}", rs)
#codeblock = $1.strip
#codeblock = %{<img class="tex_inline" src="#{MimeTexURL}?\\small %s"/>} % [ encode_code( codeblock, rs ) ]
#tokenize(codeblock, rs)
}
end