whowish_word 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/.loadpath +5 -0
- data/.project +17 -0
- data/Gemfile +3 -0
- data/HOW_TO_BUILD_WHOWISH_HOOK.md +10 -0
- data/ISSUE.md +93 -0
- data/README.md +72 -0
- data/config.ru +4 -0
- data/lib/legacy/whowish_word/config.rb +1 -0
- data/lib/legacy/whowish_word/init.rb +4 -0
- data/lib/legacy/whowish_word/lib/app/controllers/whowish_word_controller.rb +115 -0
- data/lib/legacy/whowish_word/lib/app/controllers/whowish_word_email_controller.rb +66 -0
- data/lib/legacy/whowish_word/lib/app/controllers/whowish_word_facebook_controller.rb +62 -0
- data/lib/legacy/whowish_word/lib/app/models/mongodb/whowish_word.rb +12 -0
- data/lib/legacy/whowish_word/lib/app/models/mongodb/whowish_word_email.rb +10 -0
- data/lib/legacy/whowish_word/lib/app/models/mongodb/whowish_word_facebook.rb +28 -0
- data/lib/legacy/whowish_word/lib/app/models/mysql/whowish_word.rb +5 -0
- data/lib/legacy/whowish_word/lib/app/models/mysql/whowish_word_email.rb +5 -0
- data/lib/legacy/whowish_word/lib/app/models/mysql/whowish_word_facebook.rb +18 -0
- data/lib/legacy/whowish_word/lib/app/views/layouts/whowish_word_blank.html.erb +94 -0
- data/lib/legacy/whowish_word/lib/app/views/whowish_word/_javascript.html.erb +82 -0
- data/lib/legacy/whowish_word/lib/app/views/whowish_word/_row.html.erb +50 -0
- data/lib/legacy/whowish_word/lib/app/views/whowish_word/index.html.erb +219 -0
- data/lib/legacy/whowish_word/lib/app/views/whowish_word/login.html.erb +5 -0
- data/lib/legacy/whowish_word/lib/app/views/whowish_word_email/_row.html.erb +42 -0
- data/lib/legacy/whowish_word/lib/app/views/whowish_word_email/index.html.erb +99 -0
- data/lib/legacy/whowish_word/lib/app/views/whowish_word_facebook/_row.html.erb +48 -0
- data/lib/legacy/whowish_word/lib/app/views/whowish_word_facebook/index.html.erb +100 -0
- data/lib/legacy/whowish_word/lib/db_migration.rb +2 -0
- data/lib/legacy/whowish_word/lib/db_migration/mongodb.rb +0 -0
- data/lib/legacy/whowish_word/lib/db_migration/mysql.rb +60 -0
- data/lib/legacy/whowish_word/lib/hook.rb +186 -0
- data/lib/whowish_word.rb +1 -0
- data/lib/whowish_word/action_controller/base.rb +35 -0
- data/lib/whowish_word/action_mailer/base.rb +12 -0
- data/lib/whowish_word/action_view/base.rb +65 -0
- data/lib/whowish_word/action_view/template.rb +22 -0
- data/lib/whowish_word/authentication.rb +14 -0
- data/lib/whowish_word/constant.rb +9 -0
- data/lib/whowish_word/db_migration/active_record/whowish_word_html.rb +15 -0
- data/lib/whowish_word/initializer.rb +55 -0
- data/lib/whowish_word/rails/app/controllers/whowish_word_controller.rb +71 -0
- data/lib/whowish_word/rails/app/models/active_record/whowish_word_html.rb +4 -0
- data/lib/whowish_word/rails/app/models/mongoid/whowish_word_html.rb +10 -0
- data/lib/whowish_word/rails/public/javascripts/0_class.js +64 -0
- data/lib/whowish_word/rails/public/javascripts/0_jquery-1.6.4-whowish_word.js +9046 -0
- data/lib/whowish_word/rails/public/javascripts/1_csrf_and_authenticity_token_hook.js +9 -0
- data/lib/whowish_word/rails/public/javascripts/1_jquery.escape.js +23 -0
- data/lib/whowish_word/rails/public/javascripts/1_jquery.loading_button.js +66 -0
- data/lib/whowish_word/rails/public/javascripts/1_jquery.sizes.min.js +8 -0
- data/lib/whowish_word/rails/public/javascripts/2_whowish_word_variables.js +64 -0
- data/lib/whowish_word/rails/public/javascripts/3_whowish_word_dialog.js +136 -0
- data/lib/whowish_word/rails/public/javascripts/3_whowish_word_helper.js +94 -0
- data/lib/whowish_word/rails/public/javascripts/4_whowish_word.js +43 -0
- data/lib/whowish_word/rails/public/javascripts/4_whowish_word_content_handler.js +15 -0
- data/lib/whowish_word/rails/public/javascripts/4_whowish_word_creator.js +62 -0
- data/lib/whowish_word/rails/public/javascripts/5_whowish_word_common_creator.js +49 -0
- data/lib/whowish_word/rails/public/javascripts/6_whowish_word_element_creator.js +72 -0
- data/lib/whowish_word/rails/public/javascripts/6_whowish_word_html_creator.js +19 -0
- data/lib/whowish_word/rails/public/javascripts/6_whowish_word_select_creator.js +11 -0
- data/lib/whowish_word/rails/public/javascripts/6_whowish_word_text_creator.js +20 -0
- data/lib/whowish_word/rails/public/javascripts/6_whowish_word_value_creator.js +20 -0
- data/lib/whowish_word/rails/public/javascripts/7_whowish_word_attribute_handler.js +17 -0
- data/lib/whowish_word/rails/public/javascripts/7_whowish_word_html_handler.js +15 -0
- data/lib/whowish_word/rails/public/javascripts/7_whowish_word_text_handler.js +15 -0
- data/lib/whowish_word/rails/public/javascripts/7_whowish_word_value_handler.js +19 -0
- data/lib/whowish_word/rails/public/stylesheets/whowish_word.css +197 -0
- data/lib/whowish_word/whowish_word.rb +39 -0
- data/lib/whowish_word/word_for.rb +97 -0
- data/rails/Gemfile +18 -0
- data/rails/Gemfile.lock +130 -0
- data/rails/Rakefile +7 -0
- data/rails/app/assets/javascripts/integration.js +2 -0
- data/rails/app/assets/javascripts/test_javascript.js +2 -0
- data/rails/app/assets/javascripts/test_word_for.js +2 -0
- data/rails/app/assets/stylesheets/integration.css +4 -0
- data/rails/app/assets/stylesheets/test_javascript.css +4 -0
- data/rails/app/assets/stylesheets/test_word_for.css +4 -0
- data/rails/app/controllers/application_controller.rb +14 -0
- data/rails/app/controllers/home_controller.rb +9 -0
- data/rails/app/controllers/integration_controller.rb +5 -0
- data/rails/app/controllers/test_javascript_controller.rb +11 -0
- data/rails/app/controllers/test_word_for_controller.rb +5 -0
- data/rails/app/helpers/integration_helper.rb +2 -0
- data/rails/app/helpers/test_javascript_helper.rb +2 -0
- data/rails/app/helpers/test_word_for_helper.rb +2 -0
- data/rails/app/views/home/index.html.erb +95 -0
- data/rails/app/views/home/static_edit.html.erb +50 -0
- data/rails/app/views/home/static_edit_select.html.erb +9 -0
- data/rails/app/views/integration/attr.html.erb +1 -0
- data/rails/app/views/integration/index.html.erb +1 -0
- data/rails/app/views/integration/select.html.erb +3 -0
- data/rails/app/views/integration/value.html.erb +1 -0
- data/rails/app/views/layouts/integration.html.erb +14 -0
- data/rails/app/views/layouts/main.html.erb +14 -0
- data/rails/app/views/layouts/nested_test_word_for.html.erb +14 -0
- data/rails/app/views/layouts/test_javascript.html.erb +13 -0
- data/rails/app/views/layouts/test_word_for.html.erb +22 -0
- data/rails/app/views/test_javascript/change_value.html.erb +32 -0
- data/rails/app/views/test_javascript/index.html.erb +78 -0
- data/rails/app/views/test_word_for/_partial.html.erb +5 -0
- data/rails/app/views/test_word_for/index.html.erb +7 -0
- data/rails/config.ru +4 -0
- data/rails/config/application.rb +30 -0
- data/rails/config/boot.rb +9 -0
- data/rails/config/database.yml +25 -0
- data/rails/config/environment.rb +16 -0
- data/rails/config/initializers/whowish_word.rb +5 -0
- data/rails/config/mongoid.rb +6 -0
- data/rails/config/mongoid.yml +14 -0
- data/rails/config/routes.rb +7 -0
- data/rails/log/.gitignore +2 -0
- data/rails/mongo.bat +5 -0
- data/rails/public/jasmine/MIT.LICENSE +20 -0
- data/rails/public/jasmine/jasmine-html.js +190 -0
- data/rails/public/jasmine/jasmine.css +166 -0
- data/rails/public/jasmine/jasmine.js +2476 -0
- data/rails/public/jasmine/jasmine_favicon.png +0 -0
- data/rails/public/javascripts/jquery-1.6.4.js +9046 -0
- data/rails/public/sinonjs/sinonjs.js +2821 -0
- data/rails/public/stylesheets/main.css +22 -0
- data/rails/public/test/jquery_version.html +26 -0
- data/rails/script/rails +6 -0
- data/rails/spec/controllers/whowish_word_controller_spec.rb +56 -0
- data/rails/spec/integration/whowish_word_generator_spec.rb +116 -0
- data/rails/spec/integration/whowish_word_spec.rb +110 -0
- data/rails/spec/spec_helper.rb +44 -0
- data/rails/spec/support/browser.rb +194 -0
- data/rails/spec/support/json_rspec_helper.rb +9 -0
- data/rails/spec/support/mongoid_helper.rb +10 -0
- data/spec/spec_helper.rb +19 -0
- data/spec/unit/word_for_attr_in_edit_mode_spec.rb +44 -0
- data/spec/unit/word_for_attr_spec.rb +44 -0
- data/spec/unit/word_for_in_edit_mode_spec.rb +44 -0
- data/spec/unit/word_for_spec.rb +44 -0
- data/whowish_word.gemspec +21 -0
- metadata +181 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
class WhowishWordFacebook
|
2
|
+
|
3
|
+
include Mongoid::Document
|
4
|
+
|
5
|
+
field :publish_id,:type=>String
|
6
|
+
field :message, :type=>String
|
7
|
+
field :name, :type=>String
|
8
|
+
field :caption, :type=>String
|
9
|
+
field :description, :type=>String
|
10
|
+
|
11
|
+
key :publish_id
|
12
|
+
|
13
|
+
def word_for(field,*p)
|
14
|
+
|
15
|
+
content = self[field].to_s
|
16
|
+
|
17
|
+
if p.length > 0
|
18
|
+
p = p[0]
|
19
|
+
|
20
|
+
p.each_pair { |key,val|
|
21
|
+
content.gsub!("{"+key.to_s+"}",val.to_s)
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
content
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class WhowishWordFacebook < ActiveRecord::Base
|
2
|
+
|
3
|
+
def word_for(field,*p)
|
4
|
+
|
5
|
+
content = self[field].to_s
|
6
|
+
|
7
|
+
if p.length > 0
|
8
|
+
p = p[0]
|
9
|
+
|
10
|
+
p.each_pair { |key,val|
|
11
|
+
content.gsub!("{"+key.to_s+"}",val.to_s)
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
content
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" style="padding: 0px 0px 0px 0px; margin:0px 0px 0px 0px;">
|
3
|
+
<head>
|
4
|
+
<link rel="P3Pv1" href="/w3c/p3p.xml">
|
5
|
+
<meta http-equiv="P3P" policyref="/w3c/p3p.xml" content='CP="<%=COMPACT_POLICY%>"'>
|
6
|
+
<title>Whowish Wording System</title>
|
7
|
+
<%= javascript_include_tag "jquery-1.6.2.min.js"%>
|
8
|
+
<%= javascript_include_tag "/loading_button/jquery.loading_button.js"%>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<style type="text/css">
|
12
|
+
span, input,textarea {
|
13
|
+
font-family: "lucida grande",tahoma,verdana,arial,sans-serif;
|
14
|
+
margin:2px 2px 2px 2px;
|
15
|
+
font-size:11px;
|
16
|
+
}
|
17
|
+
.edited {
|
18
|
+
background-color: #CC9966 !important;
|
19
|
+
}
|
20
|
+
</style>
|
21
|
+
<script language="javascript">
|
22
|
+
|
23
|
+
var is_activated = "<%=($whowish_word_admin == true ? 'yes' : '')%>";
|
24
|
+
|
25
|
+
function toggle_activate()
|
26
|
+
{
|
27
|
+
$('#activate_button').loading_button(true);
|
28
|
+
is_activated = (is_activated=="yes")?"":"yes";
|
29
|
+
|
30
|
+
$.ajax({
|
31
|
+
type: "POST",
|
32
|
+
url: '/whowish_word/activate',
|
33
|
+
cache: false,
|
34
|
+
data: {
|
35
|
+
authenticity_token: "<%=form_authenticity_token%>",
|
36
|
+
"enabled":is_activated
|
37
|
+
},
|
38
|
+
success: function(data){
|
39
|
+
$('#activate_button').loading_button(false);
|
40
|
+
try {
|
41
|
+
if (data.ok == true) {
|
42
|
+
if (is_activated=="yes")
|
43
|
+
$('#activate_button').html('Deactivate Edit Mode');
|
44
|
+
else
|
45
|
+
$('#activate_button').html('Activate Edit Mode');
|
46
|
+
|
47
|
+
}
|
48
|
+
else {
|
49
|
+
alert(data.error_message);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
catch (e) {
|
53
|
+
alert(e);
|
54
|
+
}
|
55
|
+
|
56
|
+
},
|
57
|
+
error: function(req, status, e){
|
58
|
+
$('#activate_button').loading_button(false);
|
59
|
+
if (req.status == 0) return;
|
60
|
+
alert('Cannot connect to the server. Please try again later.');
|
61
|
+
|
62
|
+
}
|
63
|
+
});
|
64
|
+
}
|
65
|
+
</script>
|
66
|
+
<span style="display:block;width:740px;">
|
67
|
+
<a href="/whowish_word/index">All Wordings</a>
|
68
|
+
|
69
|
+
<a href="/whowish_word_email">Emails</a>
|
70
|
+
|
71
|
+
<a href="/whowish_word_facebook">Facebook Publish</a>
|
72
|
+
|
73
|
+
<a href="#" id="activate_button" onclick="toggle_activate();return false;">
|
74
|
+
<%
|
75
|
+
if $whowish_word_admin
|
76
|
+
%>
|
77
|
+
Deactivate Edit Mode
|
78
|
+
<%
|
79
|
+
else
|
80
|
+
%>
|
81
|
+
Activate Edit Mode
|
82
|
+
<%
|
83
|
+
end
|
84
|
+
%>
|
85
|
+
</a>
|
86
|
+
|
87
|
+
<a href="/whowish_word/logout">Logout</a>
|
88
|
+
</span>
|
89
|
+
<span style="display:block;width:740px;margin-top:20px;">
|
90
|
+
<%=yield%>
|
91
|
+
</span>
|
92
|
+
</body>
|
93
|
+
</html>
|
94
|
+
|
@@ -0,0 +1,82 @@
|
|
1
|
+
<%
|
2
|
+
if $whowish_word_admin == true
|
3
|
+
%>
|
4
|
+
<script language="javascript">
|
5
|
+
function change_whowish_word(self,word_id,word_arg,event)
|
6
|
+
{
|
7
|
+
if (!event) event = window.event;
|
8
|
+
event.cancelBubble = true;
|
9
|
+
if (event.stopPropagation) event.stopPropagation();
|
10
|
+
|
11
|
+
$(self).loading_button(true,{word:""});
|
12
|
+
|
13
|
+
var content = ""
|
14
|
+
$.ajax({
|
15
|
+
type: "POST",
|
16
|
+
url: '/whowish_word/get_word',
|
17
|
+
cache: false,
|
18
|
+
async: false,
|
19
|
+
data: {
|
20
|
+
authenticity_token: "<%=form_authenticity_token%>",
|
21
|
+
"word_id": word_id
|
22
|
+
},
|
23
|
+
success: function(data){
|
24
|
+
content = data.content;
|
25
|
+
}
|
26
|
+
});
|
27
|
+
|
28
|
+
$(self).loading_button(false);
|
29
|
+
var new_word = prompt("Please set "+word_id+":",content);
|
30
|
+
|
31
|
+
if (new_word == null) return
|
32
|
+
|
33
|
+
$(self).loading_button(true,{word:""});
|
34
|
+
|
35
|
+
$.ajax({
|
36
|
+
type: "POST",
|
37
|
+
url: '/whowish_word/change_word',
|
38
|
+
cache: false,
|
39
|
+
data: {
|
40
|
+
authenticity_token: "<%=form_authenticity_token%>",
|
41
|
+
"word_id":word_id,
|
42
|
+
"content":new_word
|
43
|
+
},
|
44
|
+
success: function(data){
|
45
|
+
$(self).loading_button(false);
|
46
|
+
try {
|
47
|
+
if (data.ok == true) {
|
48
|
+
|
49
|
+
for (var i in word_arg)
|
50
|
+
{
|
51
|
+
re = new RegExp("\{"+i+"\}","g")
|
52
|
+
new_word = new_word.replace(re, word_arg[i])
|
53
|
+
}
|
54
|
+
|
55
|
+
var the_container = $(self).parent().children('*:first')[0];
|
56
|
+
|
57
|
+
try {$(the_container).val(new_word);} catch (e) {}
|
58
|
+
try {$(the_container).html(new_word);} catch (e) {}
|
59
|
+
|
60
|
+
}
|
61
|
+
else {
|
62
|
+
alert(data.error_message);
|
63
|
+
}
|
64
|
+
|
65
|
+
}
|
66
|
+
catch (e) {
|
67
|
+
alert(e);
|
68
|
+
}
|
69
|
+
|
70
|
+
},
|
71
|
+
error: function(req, status, e){
|
72
|
+
$(self).loading_button(false);
|
73
|
+
if (req.status == 0) return;
|
74
|
+
alert('Cannot connect to the server. Please try again later.');
|
75
|
+
}
|
76
|
+
});
|
77
|
+
}
|
78
|
+
|
79
|
+
</script>
|
80
|
+
<%
|
81
|
+
end
|
82
|
+
%>
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<%
|
2
|
+
module_name = entity.class.to_s.underscore
|
3
|
+
|
4
|
+
icon = "ok_icon"
|
5
|
+
id = entity.id
|
6
|
+
method = "save"
|
7
|
+
save_or_add = "Save"
|
8
|
+
|
9
|
+
if is_new and is_new == true
|
10
|
+
icon = "add_icon"
|
11
|
+
id = "new"
|
12
|
+
method = "add"
|
13
|
+
save_or_add = "Add"
|
14
|
+
end
|
15
|
+
%>
|
16
|
+
<div id="<%=module_name%>[<%= id %>]" style="display:table-row;">
|
17
|
+
<span class="tool">
|
18
|
+
<span id="save_button[<%=module_name%>][<%= id %>]" onclick="<%=method%>('<%=module_name%>','<%= id %>');"><%=save_or_add%></span>
|
19
|
+
</span>
|
20
|
+
<%
|
21
|
+
field_set.each do |f|
|
22
|
+
key = f[:id]
|
23
|
+
val = entity[key]
|
24
|
+
|
25
|
+
if f[:type] == "textarea"
|
26
|
+
width = (f[:width] || 150).to_s
|
27
|
+
%>
|
28
|
+
<span style="display:table-cell;">
|
29
|
+
<textarea id="<%=module_name%>[<%= id %>][<%=key%>]" style="width:<%=width%>px;" onkeyup="$('#<%=module_name%>\\[<%= id %>\\]').addClass('edited');return true;"><%=val%></textarea>
|
30
|
+
<span id="errors[<%=module_name%>][<%= id %>][<%=key%>]" style="display: none;"></span>
|
31
|
+
</span>
|
32
|
+
<%
|
33
|
+
else
|
34
|
+
width = (f[:width] || 100).to_s
|
35
|
+
%>
|
36
|
+
<span style="display:table-cell;vertical-align:top;">
|
37
|
+
<input id="<%=module_name%>[<%= id %>][<%=key%>]" style="width:<%=width%>px;" type="text" value="<%= val %>" onkeyup="$('#<%=module_name%>\\[<%= id %>\\]').addClass('edited');return true;">
|
38
|
+
<span id="errors[<%=module_name%>][<%= id %>][<%=key%>]" style="display: none;"></span>
|
39
|
+
</span>
|
40
|
+
<%
|
41
|
+
end
|
42
|
+
end
|
43
|
+
%>
|
44
|
+
<span class="tool">
|
45
|
+
<% if id != "new" %>
|
46
|
+
<span style="visiblity:hidden;" id="delete_button[<%=module_name%>][<%= id %>]" onclick="remove_entry('<%=module_name%>','<%= id%>');">Delete</span>
|
47
|
+
<% end %>
|
48
|
+
</span>
|
49
|
+
</div>
|
50
|
+
|
@@ -0,0 +1,219 @@
|
|
1
|
+
|
2
|
+
<style type="text/css">
|
3
|
+
span, input,textarea {
|
4
|
+
font-family: "lucida grande",tahoma,verdana,arial,sans-serif;
|
5
|
+
margin:2px 2px 2px 2px;
|
6
|
+
font-size:11px;
|
7
|
+
}
|
8
|
+
|
9
|
+
.header {
|
10
|
+
display:table-cell;
|
11
|
+
padding-left:4px;
|
12
|
+
font-weight:bold;
|
13
|
+
}
|
14
|
+
|
15
|
+
.tool {
|
16
|
+
display:table-cell;
|
17
|
+
vertical-align:top;
|
18
|
+
cursor:pointer;
|
19
|
+
text-decoration:underline;
|
20
|
+
width:30px;
|
21
|
+
padding-top:4px;
|
22
|
+
}
|
23
|
+
</style>
|
24
|
+
<script language="JavaScript">
|
25
|
+
|
26
|
+
parameters = {};
|
27
|
+
parameters["whowish_word"] = ["word_id","content"];
|
28
|
+
|
29
|
+
function get_parameters(module,id)
|
30
|
+
{
|
31
|
+
params = {id:id};
|
32
|
+
|
33
|
+
for (var i=0;i<parameters[module].length;i++)
|
34
|
+
{
|
35
|
+
var key = parameters[module][i];
|
36
|
+
try
|
37
|
+
{
|
38
|
+
params[key] = $('#'+module+'\\['+id+'\\]\\['+key+'\\]').val();
|
39
|
+
} catch (e) {}
|
40
|
+
}
|
41
|
+
|
42
|
+
return params;
|
43
|
+
}
|
44
|
+
|
45
|
+
function clear(module,id)
|
46
|
+
{
|
47
|
+
$('#save_button\\['+module+'\\]\\['+id+'\\]').attr('class','add_icon');
|
48
|
+
for (i in parameters[module])
|
49
|
+
{
|
50
|
+
try
|
51
|
+
{
|
52
|
+
params[i] = $('#'+module+'\\['+id+'\\]\\['+i+'\\]').val();
|
53
|
+
} catch (e) {}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
function reset_error(module, id){
|
58
|
+
$('#' + module + '\\[' + id + '\\]').removeClass('error_row');
|
59
|
+
|
60
|
+
for (i = 0; i < parameters[module].length; i++) {
|
61
|
+
$('#errors\\['+module+'\\]\\[' + id+'\\]\\['+parameters[module][i]+'\\]').css({'display': 'none'});
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
function get_checked_values(id)
|
66
|
+
{
|
67
|
+
str = "";
|
68
|
+
i = 0;
|
69
|
+
while ($(id + '\\[' + i+'\\]'))
|
70
|
+
{
|
71
|
+
if ($(id + '\\[' + i+'\\]').checked)
|
72
|
+
{
|
73
|
+
if (str != "") str += ",";
|
74
|
+
str += "" + $(id + '\\[' + i+'\\]').value;
|
75
|
+
}
|
76
|
+
|
77
|
+
i++;
|
78
|
+
}
|
79
|
+
|
80
|
+
return str;
|
81
|
+
}
|
82
|
+
|
83
|
+
function set_error(module,id,error_message)
|
84
|
+
{
|
85
|
+
$('#save_button\\['+module+'\\]\\['+id+'\\]').attr('class','error_icon');
|
86
|
+
$('#'+module+'\\['+id+'\\]').addClass("error_row");
|
87
|
+
|
88
|
+
for (i = 0; i < parameters[module].length; i++) {
|
89
|
+
|
90
|
+
value = eval('error_message.'+parameters[module][i]+'[0]');
|
91
|
+
if (value == null || value == undefined) continue;
|
92
|
+
|
93
|
+
$('#errors['+module+'\\]\\[' + id+'\\]\\['+parameters[module][i]+'\\]').css({'display': 'block'});
|
94
|
+
$('#errors['+module+'\\]\\[' + id+'\\]\\['+parameters[module][i]+'\\]').html(eval('error_message.'+parameters[module][i]+'[0]'));
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
function save(module,id)
|
99
|
+
{
|
100
|
+
//if ($('#save_button_'+module+'_'+id).attr('class') == "ok_icon") return;
|
101
|
+
|
102
|
+
$('#save_button\\['+module+'\\]\\['+id+'\\]').loading_button(true);
|
103
|
+
|
104
|
+
reset_error(module,id);
|
105
|
+
|
106
|
+
params = get_parameters(module,id);
|
107
|
+
|
108
|
+
$.post('/'+module+'/change_word', params,
|
109
|
+
function(json){
|
110
|
+
if (json.ok == true) {
|
111
|
+
$('#'+module+'\\['+id+'\\]').removeClass('edited');
|
112
|
+
}
|
113
|
+
else
|
114
|
+
{
|
115
|
+
set_error(module,id,json.error_message);
|
116
|
+
}
|
117
|
+
|
118
|
+
$('#save_button\\['+module+'\\]\\['+id+'\\]').loading_button(false);
|
119
|
+
},"json");
|
120
|
+
}
|
121
|
+
|
122
|
+
function remove_entry(module,id)
|
123
|
+
{
|
124
|
+
//if ($('#delete_button_'+module+'_'+id).attr('class') == 'loading_icon') return;
|
125
|
+
|
126
|
+
if (!confirm('Are you sure you want to delete this entry?')) return;
|
127
|
+
|
128
|
+
$('#delete_button\\['+module+'\\]\\['+id+'\\]').loading_button(true);
|
129
|
+
|
130
|
+
reset_error(module,id);
|
131
|
+
|
132
|
+
$.post('/'+module+'/delete', {id: id},
|
133
|
+
function(json){
|
134
|
+
if (json.ok == true) {
|
135
|
+
$('#'+module+'\\['+id+'\\]').remove();
|
136
|
+
}
|
137
|
+
else
|
138
|
+
{
|
139
|
+
|
140
|
+
|
141
|
+
error_message = function() {};
|
142
|
+
error_message[parameters[module][0]] = [json.error_message];
|
143
|
+
|
144
|
+
set_error(module,id,error_message);
|
145
|
+
}
|
146
|
+
|
147
|
+
$('#delete_button\\['+module+'\\]\\['+id+'\\]').loading_button(false);
|
148
|
+
},"json");
|
149
|
+
}
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
function add(module,id)
|
155
|
+
{
|
156
|
+
|
157
|
+
//if ($('#save_button_'+module+'_'+id).attr('class') == 'loading_icon') return;
|
158
|
+
|
159
|
+
$('#save_button_'+module+'_'+id).loading_button(true);
|
160
|
+
reset_error(module,id);
|
161
|
+
|
162
|
+
params = get_parameters(module,id);
|
163
|
+
|
164
|
+
$.post('/'+module+'/add', params,
|
165
|
+
function(json){
|
166
|
+
if (json.ok == true) {
|
167
|
+
$('#'+module+'\\['+id+'\\]').removeClass('edited');
|
168
|
+
clear(module,id);
|
169
|
+
$('#'+module+'\\['+id+'\\]').before(json.new_row);
|
170
|
+
}
|
171
|
+
else
|
172
|
+
{
|
173
|
+
set_error(module,id,json.error_message);
|
174
|
+
}
|
175
|
+
|
176
|
+
$('#save_button_'+module+'_'+id).loading_button(false);
|
177
|
+
},"json");
|
178
|
+
}
|
179
|
+
|
180
|
+
$(document).ajaxError(function(){
|
181
|
+
alert("Cannot connect to server. Please try again later");
|
182
|
+
})
|
183
|
+
|
184
|
+
function restart_server()
|
185
|
+
{
|
186
|
+
$.get('/'+module+'/restart', params,
|
187
|
+
function(json){
|
188
|
+
if (json.ok == true) {
|
189
|
+
alert('The server is restarted')
|
190
|
+
}
|
191
|
+
},"json");
|
192
|
+
}
|
193
|
+
|
194
|
+
$(window).bind('beforeunload', function(){
|
195
|
+
if ($('.edited').length > 0)
|
196
|
+
{
|
197
|
+
return "You have unsaved records. Are you sure you want to exits?";
|
198
|
+
}
|
199
|
+
});
|
200
|
+
|
201
|
+
</script>
|
202
|
+
<span style="margin-bottom:20px;width:740px;display:block;">
|
203
|
+
* Please use "Finding" function of your browser to find the word you want. Trust me, it is easier.
|
204
|
+
</span>
|
205
|
+
<div>
|
206
|
+
<div id="row_header" style="display:table-row;">
|
207
|
+
<span class="header" style="width:30px;"> </span>
|
208
|
+
<span class="header" style="width:300px;">Word ID</span>
|
209
|
+
<span class="header" style="width:350px;">Content</span>
|
210
|
+
<span class="header" style="width:30px;"> </span>
|
211
|
+
</div>
|
212
|
+
<%
|
213
|
+
WhowishWord.all().each do |word|
|
214
|
+
%>
|
215
|
+
<%=render :partial=>"row", :locals=>{:entity=>word,:field_set=>@fs,:is_new=>false}%>
|
216
|
+
<% end %>
|
217
|
+
<%=render :partial=>"row", :locals=>{:entity=>WhowishWord.new,:field_set=>@fs,:is_new=>true}%>
|
218
|
+
</div>
|
219
|
+
|