Permalink
Browse files

未完成だけどコード保全

  • Loading branch information...
1 parent 9590064 commit e3e8d1d3cde130252505116b9b1be4eed82df233 @ongaeshi committed Mar 28, 2012
Showing with 36 additions and 1 deletion.
  1. +35 −0 lib/milkode/cdweb/public/js/milkode.js
  2. +1 −1 lib/milkode/cdweb/views/header_menu.haml
@@ -27,10 +27,45 @@ function replace_query_param(url, value)
}
}
+function package_path(url, value)
+{
+ var url_s = url.split("?");
+
+ if (url_s.length <= 1) {
+ return url + "?query=" + value;
+ } else {
+ var params = url_s[1].split("&");
+ var found_query = false;
+
+ for (var i = 0; i < params.length; i++) {
+ if (params[i].search(/^query=/) != -1) {
+ params[i] = params[i].replace(/^query=.*/, "query=" + value);
+ found_query = true;
+ }
+ }
+
+ if (!found_query)
+ params.unshift("query=" + value);
+
+ return url_s[0] + "?" + params.join("&");
+ }
+}
+
+
function topic_path(id)
{
var url = document.getElementById(id).href;
url = replace_query_param(url, document.searchform.query.value);
document.getElementById(id).href = url;
}
+function context_menu_search()
+{
+ var text = window.getSelection().toString();
+ var url = replace_query_param(document.URL, text);
+
+ alert(document.URL);
+
+ //document.location = url;
+ window.open(url);
+}
@@ -5,4 +5,4 @@
= create_headmenu(@path, params, defined?(flistpath) ? flistpath : '')
%menu(type="context" id="milkode_menu")
- %menuitem#searchMenu(label="検索" onclick="alert('検索します!');" icon="#{@setting.header_icon}")
+ %menuitem#searchMenu(label="検索" onclick="context_menu_search();" icon="#{@setting.header_icon}")

0 comments on commit e3e8d1d

Please sign in to comment.