我有一个数学网站http://finitehelp.com,教授学生有限数学.我认为包含一个计算器会很酷,所以我在Javascript中为组合和排列做了一个.实时计算器位于http://finitehelp.com/finite-calculator.html.我对Javascript几乎一无所知,并且冒昧地猜测有一种更有效的方式来编写以下内容,特别是因为过度使用了变量.如果有人能帮助我,我会非常感激.
<script type="text/javascript">
// calculate n!
Math.factorial = function(n)
{
if(typeof n == 'string') n = Number(n);
if(typeof n != 'number' || isNaN(n))
{
alert("Factorial requires a numeric argument.");
return null;
}
if (n < 2) return 1;
return (n * Math.factorial(n-1));
}
Math.divide = function(a,b)
{
return a/b;
}
</script>
<form class="form" name="combination" action="">
<p>C(<input type="text" value="n" name="T1" size="1">,<input type="text" value="r" name="T2" size="1">)
<input type="button" value="Calculate"
onclick="var n = T1.value; var r = T2.value; var …Run Code Online (Sandbox Code Playgroud) 我所有注册的路线都在工作.它们显示视图,但在每个请求中都会在我的日志文件中显示NotFoundHttpException.
我正在使用NGINX.可能是我的NGINX配置吗?
每个请求记录的错误(即使视图显示):
log.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in /usr/share/nginx/www/example-staging/releases/20130815024541/vendor/laravel/framework/src/Illuminate/Routing/Router.php:1429
Stack trace:
#0 /usr/share/nginx/www/example-staging/releases/20130815024541/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1050): Illuminate\Routing\Router->handleRoutingException(Object(Symfony\Component\Routing\Exception\ResourceNotFoundException))
#1 /usr/share/nginx/www/example-staging/releases/20130815024541/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1014): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request))
#2 /usr/share/nginx/www/example-staging/releases/20130815024541/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(530): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#3 /usr/share/nginx/www/example-staging/releases/20130815024541/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(506): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#4 /usr/share/nginx/www/example-staging/releases/20130815024541/content/index.php(49): Illuminate\Foundation\Application->run()
#5 {main}
Run Code Online (Sandbox Code Playgroud)
NGINX配置:
# Redirect www.
server {
listen 80;
server_name www.example.com;
rewrite ^(.*) http://example.com$1 permanent;
}
server {
listen 80;
server_name example.com;
access_log /var/log/nginx/example.com/access.log;
error_log /var/log/nginx/example.com/error.log;
rewrite_log on;
root /usr/share/nginx/www/example/current/content;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~* \.php$ …Run Code Online (Sandbox Code Playgroud) 下面的代码成功地在一个推荐中淡出6秒,等待3秒,然后将其淡出并继续下一个.一旦达到第三个见证,它就会跳回到第一个.这正是我想要的,但在我的实际网站上,我有三个以上的推荐,并且将来可能会增加更多.每次添加新推荐书时,我都不想再返回并添加新功能.我尝试了一段时间,使用"this"和.next()使其工作但失败了.我希望有人可以通过循环它并使其移动到容器中的下一个p标签而不必每次调用新函数来提高效率.感谢任何帮助,谢谢.
注意:我知道有类似的问题,但没有一个是完全相同的,答案是低于标准.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<style>
#tml-container p { display: none; }
</style>
</head>
<body>
<div id="tml-container">
<p id="one">Testimonial 1</p>
<p id="two">Testimonial 2</p>
<p id="three">Testimonial 3</p>
</div>
<script>
$(document).ready(function() {
function doFade() {
$("#one").fadeIn(6000,function() {
$("#one").fadeOut(6000).delay(3000);
setTimeout(fadeTwo,6000);
});
}
function fadeTwo() {
$("#two").fadeIn(6000,function() {
$("#two").fadeOut(6000).delay(3000);
setTimeout(fadeThree,6000);
});
}
function fadeThree() {
$("#three").fadeIn(4000,function() {
$("#three").fadeOut(6000).delay(3000);
setTimeout(doFade,6000);
});
}
doFade();
});
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)