From 2e26e272980ac8b1f5c74d48e5e8b06cfe824a21 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 5 May 2015 17:08:46 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E6=94=B6=E8=B5=B7?= =?UTF-8?q?=E5=90=8E=E4=B9=8B=E4=BF=9D=E5=AD=98=E5=9C=A8cookie=E4=B8=AD?= =?UTF-8?q?=EF=BC=8C=E5=88=B7=E6=96=B0=E9=A1=B5=E9=9D=A2=E5=90=8E=E4=BB=8D?= =?UTF-8?q?=E4=BF=9D=E6=8C=81=E6=94=B6=E8=B5=B7=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_projects.html.erb | 2 +- app/views/repositories/show.html.erb | 2 +- public/javascripts/cookie.js | 39 ++++++++++++++++++++++++ public/javascripts/project.js | 30 +++++++++--------- 4 files changed, 56 insertions(+), 17 deletions(-) create mode 100644 public/javascripts/cookie.js diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 64a9111e0..958d62975 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -13,7 +13,7 @@ <%= javascript_heads %> <%= heads_for_theme %> <%= stylesheet_link_tag 'public', 'pleft', 'project','jquery/jquery-ui-1.9.2' %> - <%= javascript_include_tag 'project', 'header','select_list_move' %> + <%= javascript_include_tag 'cookie','project', 'header','select_list_move' %> <%= call_hook :view_layouts_base_html_head %> <%= yield :header_tags -%> diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 9d545d89a..96e3b84be 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -30,7 +30,7 @@

-
收起Git操作指南
+
收起Git操作指南

diff --git a/public/javascripts/cookie.js b/public/javascripts/cookie.js new file mode 100644 index 000000000..9e14ed810 --- /dev/null +++ b/public/javascripts/cookie.js @@ -0,0 +1,39 @@ +//保存cookie +//n:cookie的名字 +//v:cookie的值 +//mins:时间(分钟) +//dn: +//path:保存路径 +function cookiesave(n, v, mins, dn, path) +{ + if(n) + { + + if(!mins) mins = 365 * 24 * 60; + if(!path) path = "/"; + var date = new Date(); + + date.setTime(date.getTime() + (mins * 60 * 1000)); + + var expires = "; expires=" + date.toGMTString(); + + if(dn) dn = "domain=" + dn + "; "; + document.cookie = n + "=" + v + expires + "; " + dn + "path=" + path; + + } +} + +//获取cookie +function cookieget(n) +{ + var name = n + "="; + var ca = document.cookie.split(';'); + for(var i=0;i