whowish_word 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -3
- data/lib/whowish_word/initializer.rb +2 -4
- data/lib/whowish_word/rails/app/controllers/whowish_word_controller.rb +0 -10
- data/rails/app/controllers/application_controller.rb +2 -0
- data/rails/config/initializers/whowish_word.rb +0 -2
- data/rails/spec/integration/whowish_word_spec.rb +7 -0
- data/rails/spec/spec_helper.rb +0 -8
- data/whowish_word.gemspec +1 -1
- metadata +1 -25
- data/lib/legacy/whowish_word/config.rb +0 -1
- data/lib/legacy/whowish_word/init.rb +0 -4
- data/lib/legacy/whowish_word/lib/app/controllers/whowish_word_controller.rb +0 -115
- data/lib/legacy/whowish_word/lib/app/controllers/whowish_word_email_controller.rb +0 -66
- data/lib/legacy/whowish_word/lib/app/controllers/whowish_word_facebook_controller.rb +0 -62
- data/lib/legacy/whowish_word/lib/app/models/mongodb/whowish_word.rb +0 -12
- data/lib/legacy/whowish_word/lib/app/models/mongodb/whowish_word_email.rb +0 -10
- data/lib/legacy/whowish_word/lib/app/models/mongodb/whowish_word_facebook.rb +0 -28
- data/lib/legacy/whowish_word/lib/app/models/mysql/whowish_word.rb +0 -5
- data/lib/legacy/whowish_word/lib/app/models/mysql/whowish_word_email.rb +0 -5
- data/lib/legacy/whowish_word/lib/app/models/mysql/whowish_word_facebook.rb +0 -18
- data/lib/legacy/whowish_word/lib/app/views/layouts/whowish_word_blank.html.erb +0 -94
- data/lib/legacy/whowish_word/lib/app/views/whowish_word/_javascript.html.erb +0 -82
- data/lib/legacy/whowish_word/lib/app/views/whowish_word/_row.html.erb +0 -50
- data/lib/legacy/whowish_word/lib/app/views/whowish_word/index.html.erb +0 -219
- data/lib/legacy/whowish_word/lib/app/views/whowish_word/login.html.erb +0 -5
- data/lib/legacy/whowish_word/lib/app/views/whowish_word_email/_row.html.erb +0 -42
- data/lib/legacy/whowish_word/lib/app/views/whowish_word_email/index.html.erb +0 -99
- data/lib/legacy/whowish_word/lib/app/views/whowish_word_facebook/_row.html.erb +0 -48
- data/lib/legacy/whowish_word/lib/app/views/whowish_word_facebook/index.html.erb +0 -100
- data/lib/legacy/whowish_word/lib/db_migration/mongodb.rb +0 -0
- data/lib/legacy/whowish_word/lib/db_migration/mysql.rb +0 -60
- data/lib/legacy/whowish_word/lib/db_migration.rb +0 -2
- data/lib/legacy/whowish_word/lib/hook.rb +0 -186
@@ -1,82 +0,0 @@
|
|
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
|
-
%>
|
@@ -1,50 +0,0 @@
|
|
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
|
-
|
@@ -1,219 +0,0 @@
|
|
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
|
-
|
@@ -1,42 +0,0 @@
|
|
1
|
-
<%
|
2
|
-
id = ""
|
3
|
-
if is_new
|
4
|
-
entity = WhowishWordEmail.new
|
5
|
-
id = 0
|
6
|
-
else
|
7
|
-
id = entity.id
|
8
|
-
end
|
9
|
-
%>
|
10
|
-
<span style="width:740px;display:block;margin-top:20px;border:5px solid black;background-color:#EDEDED;" id="email_<%=id%>">
|
11
|
-
<span style="width:720px;display:block;margin:10px 10px 10px 10px;">
|
12
|
-
<span style="width:100px;display:inline-block;font-weight:bold;font-size:20px;color:#999999;">
|
13
|
-
<%=entity.id%>
|
14
|
-
</span>
|
15
|
-
<span style="width:610px;display:inline-block;">
|
16
|
-
<span style="display:block;font-weight:bold;font-size:20px;">
|
17
|
-
Email ID: <input type="text" id="page_id_<%=id%>" value="<%=entity.page_id%>" style="width:450px;font-size:20px;" onchange="$('#email_<%=id%>').addClass('edited');">
|
18
|
-
</span>
|
19
|
-
<span style="display:block;font-weight:bold;font-size:20px;">
|
20
|
-
Content ID: <input type="text" id="word_id_<%=id%>" value="<%=entity.word_id%>" style="width:450px;font-size:20px;" onchange="$('#email_<%=id%>').addClass('edited');">
|
21
|
-
</span>
|
22
|
-
<span style="display:block;">
|
23
|
-
<textarea style="width:550px;height:200px;" id="content_<%=id%>" onchange="$('#email_<%=id%>').addClass('edited');"><%=entity.content%></textarea>
|
24
|
-
</span>
|
25
|
-
<span style="display:block;font-weight:bold;margin-left:5px;">
|
26
|
-
<a href="#" style="font-weight:bold;font-size:20px;" id="save_button_<%=id%>" onclick="save_email(<%=id%>);return false;">
|
27
|
-
<% if is_new %>
|
28
|
-
Add
|
29
|
-
<% else %>
|
30
|
-
Save
|
31
|
-
<% end %>
|
32
|
-
</a>
|
33
|
-
|
34
|
-
<% if !is_new %>
|
35
|
-
<a href="#" style="font-weight:bold;font-size:20px;" id="delete_button_<%=id%>" onclick="delete_email(<%=id%>);return false;">
|
36
|
-
Delete
|
37
|
-
</a>
|
38
|
-
<% end %>
|
39
|
-
</span>
|
40
|
-
</span>
|
41
|
-
</span>
|
42
|
-
</span>
|
@@ -1,99 +0,0 @@
|
|
1
|
-
|
2
|
-
<script language="javascript">
|
3
|
-
|
4
|
-
function save_email(email_id)
|
5
|
-
{
|
6
|
-
|
7
|
-
$('#save_button_'+email_id).loading_button(true);
|
8
|
-
var action = "edit";
|
9
|
-
if (email_id == 0 || email_id == undefined) action = "add";
|
10
|
-
|
11
|
-
$.ajax({
|
12
|
-
type: "POST",
|
13
|
-
url: '/whowish_word_email/'+action,
|
14
|
-
cache: false,
|
15
|
-
async: false,
|
16
|
-
data: {
|
17
|
-
authenticity_token: "<%=form_authenticity_token%>",
|
18
|
-
"page_id": $('#page_id_'+email_id).val(),
|
19
|
-
"word_id": $('#word_id_'+email_id).val(),
|
20
|
-
"content": $('#content_'+email_id).val(),
|
21
|
-
"id":email_id
|
22
|
-
},
|
23
|
-
success: function(data){
|
24
|
-
try
|
25
|
-
{
|
26
|
-
if (data.ok == true)
|
27
|
-
{
|
28
|
-
$('#email_'+email_id).removeClass('edited');
|
29
|
-
if (action == "add")
|
30
|
-
$('#block_anchor').before(data.html);
|
31
|
-
}
|
32
|
-
else
|
33
|
-
{
|
34
|
-
alert(data.error_message);
|
35
|
-
}
|
36
|
-
|
37
|
-
} catch (e) {
|
38
|
-
|
39
|
-
}
|
40
|
-
|
41
|
-
$('#save_button_'+email_id).loading_button(false);
|
42
|
-
},
|
43
|
-
error: function(req, status, e){
|
44
|
-
$('#save_button_'+email_id).loading_button(false);
|
45
|
-
if (req.status == 0) return;
|
46
|
-
alert('Cannot connect to the server. Please try again later.');
|
47
|
-
}
|
48
|
-
});
|
49
|
-
}
|
50
|
-
|
51
|
-
function delete_email(email_id)
|
52
|
-
{
|
53
|
-
$('#delete_button_'+email_id).loading_button(true);
|
54
|
-
|
55
|
-
$.ajax({
|
56
|
-
type: "POST",
|
57
|
-
url: '/whowish_word_email/delete',
|
58
|
-
cache: false,
|
59
|
-
async: false,
|
60
|
-
data: {
|
61
|
-
authenticity_token: "<%=form_authenticity_token%>",
|
62
|
-
"id": email_id
|
63
|
-
},
|
64
|
-
success: function(data){
|
65
|
-
try
|
66
|
-
{
|
67
|
-
$('#email_'+email_id).fadeOut(function() {
|
68
|
-
$('#email_'+email_id).remove();
|
69
|
-
});
|
70
|
-
} catch (e) {
|
71
|
-
|
72
|
-
}
|
73
|
-
|
74
|
-
$('#delete_button_'+email_id).loading_button(false);
|
75
|
-
},
|
76
|
-
error: function(req, status, e){
|
77
|
-
$('#delete_button_'+email_id).loading_button(false);
|
78
|
-
if (req.status == 0) return;
|
79
|
-
alert('Cannot connect to the server. Please try again later.');
|
80
|
-
}
|
81
|
-
});
|
82
|
-
}
|
83
|
-
|
84
|
-
$(window).bind('beforeunload', function(){
|
85
|
-
if ($('.edited').length > 0)
|
86
|
-
{
|
87
|
-
return "You have unsaved records. Are you sure you want to exits?";
|
88
|
-
}
|
89
|
-
});
|
90
|
-
</script>
|
91
|
-
<%
|
92
|
-
WhowishWordEmail.all().each do |entity|
|
93
|
-
%>
|
94
|
-
<%=render :partial=>"row",:locals=>{:entity=>entity,:is_new=>false}%>
|
95
|
-
<%
|
96
|
-
end
|
97
|
-
%>
|
98
|
-
<span id="block_anchor"></span>
|
99
|
-
<%=render :partial=>"row",:locals=>{:entity=>nil,:is_new=>true}%>
|
@@ -1,48 +0,0 @@
|
|
1
|
-
<%
|
2
|
-
id = ""
|
3
|
-
if is_new
|
4
|
-
entity = WhowishWordFacebook.new
|
5
|
-
id = 0
|
6
|
-
else
|
7
|
-
id = entity.id
|
8
|
-
end
|
9
|
-
%>
|
10
|
-
<span style="width:740px;display:block;margin-top:20px;border:5px solid black;background-color:#EDEDED;" id="facebook_<%=id%>">
|
11
|
-
<span style="width:720px;display:block;margin:10px 10px 10px 10px;">
|
12
|
-
<span style="width:100px;display:inline-block;font-weight:bold;font-size:20px;color:#999999;">
|
13
|
-
<%=entity.id%>
|
14
|
-
</span>
|
15
|
-
<span style="width:610px;display:inline-block;">
|
16
|
-
<span style="display:block;font-weight:bold;font-size:20px;">
|
17
|
-
Publish ID: <input type="text" id="publish_id_<%=id%>" value="<%=entity.publish_id%>" style="width:450px;font-size:20px;" onchange="$('#facebook_<%=id%>').addClass('edited');">
|
18
|
-
</span>
|
19
|
-
<span style="display:block;">
|
20
|
-
Message: <input type="text" id="message_<%=id%>" value="<%=entity.message%>" style="width:500px;" onchange="$('#facebook_<%=id%>').addClass('edited');">
|
21
|
-
</span>
|
22
|
-
<span style="display:block;">
|
23
|
-
Topic: <input type="text" id="name_<%=id%>" value="<%=entity.name%>" style="width:500px;" onchange="$('#facebook_<%=id%>').addClass('edited');">
|
24
|
-
</span>
|
25
|
-
<span style="display:block;">
|
26
|
-
Caption: <input type="text" id="caption_<%=id%>" value="<%=entity.caption%>" style="width:500px;" onchange="$('#facebook_<%=id%>').addClass('edited');">
|
27
|
-
</span>
|
28
|
-
<span style="display:block;">
|
29
|
-
Description: <input type="text" id="description_<%=id%>" value="<%=entity.description%>" style="width:500px;" onchange="$('#facebook_<%=id%>').addClass('edited');">
|
30
|
-
</span>
|
31
|
-
<span style="display:block;font-weight:bold;margin-left:5px;">
|
32
|
-
<a href="#" style="font-weight:bold;font-size:20px;" id="save_button_<%=id%>" onclick="save_facebook(<%=id%>);return false;">
|
33
|
-
<% if is_new %>
|
34
|
-
Add
|
35
|
-
<% else %>
|
36
|
-
Save
|
37
|
-
<% end %>
|
38
|
-
</a>
|
39
|
-
|
40
|
-
<% if !is_new %>
|
41
|
-
<a href="#" style="font-weight:bold;font-size:20px;" id="delete_button_<%=id%>" onclick="delete_facebook(<%=id%>);return false;">
|
42
|
-
Delete
|
43
|
-
</a>
|
44
|
-
<% end %>
|
45
|
-
</span>
|
46
|
-
</span>
|
47
|
-
</span>
|
48
|
-
</span>
|
@@ -1,100 +0,0 @@
|
|
1
|
-
<script language="javascript">
|
2
|
-
|
3
|
-
function save_facebook(id)
|
4
|
-
{
|
5
|
-
|
6
|
-
$('#save_button_'+id).loading_button(true);
|
7
|
-
var action = "edit";
|
8
|
-
if (id == 0 || id == undefined) action = "add";
|
9
|
-
|
10
|
-
$.ajax({
|
11
|
-
type: "POST",
|
12
|
-
url: '/whowish_word_facebook/'+action,
|
13
|
-
cache: false,
|
14
|
-
async: false,
|
15
|
-
data: {
|
16
|
-
authenticity_token: "<%=form_authenticity_token%>",
|
17
|
-
"publish_id": $('#publish_id_'+id).val(),
|
18
|
-
"message": $('#message_'+id).val(),
|
19
|
-
"name": $('#name_'+id).val(),
|
20
|
-
"caption": $('#caption_'+id).val(),
|
21
|
-
"description": $('#description_'+id).val(),
|
22
|
-
"id":id
|
23
|
-
},
|
24
|
-
success: function(data){
|
25
|
-
try
|
26
|
-
{
|
27
|
-
if (data.ok)
|
28
|
-
{
|
29
|
-
$('#facebook_'+id).removeClass('edited');
|
30
|
-
if (action == "add")
|
31
|
-
$('#block_anchor').before(data.html);
|
32
|
-
}
|
33
|
-
else
|
34
|
-
{
|
35
|
-
alert(data.error_message);
|
36
|
-
}
|
37
|
-
|
38
|
-
} catch (e) {
|
39
|
-
|
40
|
-
}
|
41
|
-
|
42
|
-
$('#save_button_'+id).loading_button(false);
|
43
|
-
},
|
44
|
-
error: function(req, status, e){
|
45
|
-
$('#save_button_'+id).loading_button(false);
|
46
|
-
if (req.status == 0) return;
|
47
|
-
alert('Cannot connect to the server. Please try again later.');
|
48
|
-
}
|
49
|
-
});
|
50
|
-
}
|
51
|
-
|
52
|
-
function delete_facebook(id)
|
53
|
-
{
|
54
|
-
$('#delete_button_'+id).loading_button(true);
|
55
|
-
|
56
|
-
$.ajax({
|
57
|
-
type: "POST",
|
58
|
-
url: '/whowish_word_facebook/delete',
|
59
|
-
cache: false,
|
60
|
-
async: false,
|
61
|
-
data: {
|
62
|
-
authenticity_token: "<%=form_authenticity_token%>",
|
63
|
-
"id": id
|
64
|
-
},
|
65
|
-
success: function(data){
|
66
|
-
try
|
67
|
-
{
|
68
|
-
$('#facebook_'+id).fadeOut(function() {
|
69
|
-
$('#facebook_'+id).remove();
|
70
|
-
});
|
71
|
-
} catch (e) {
|
72
|
-
|
73
|
-
}
|
74
|
-
|
75
|
-
$('#delete_button_'+id).loading_button(false);
|
76
|
-
},
|
77
|
-
error: function(req, status, e){
|
78
|
-
$('#delete_button_'+id).loading_button(false);
|
79
|
-
if (req.status == 0) return;
|
80
|
-
alert('Cannot connect to the server. Please try again later.');
|
81
|
-
}
|
82
|
-
});
|
83
|
-
}
|
84
|
-
|
85
|
-
$(window).bind('beforeunload', function(){
|
86
|
-
if ($('.edited').length > 0)
|
87
|
-
{
|
88
|
-
return "You have unsaved records. Are you sure you want to exits?";
|
89
|
-
}
|
90
|
-
});
|
91
|
-
</script>
|
92
|
-
<%
|
93
|
-
WhowishWordFacebook.all().each do |entity|
|
94
|
-
%>
|
95
|
-
<%=render :partial=>"row",:locals=>{:entity=>entity,:is_new=>false}%>
|
96
|
-
<%
|
97
|
-
end
|
98
|
-
%>
|
99
|
-
<span id="block_anchor"></span>
|
100
|
-
<%=render :partial=>"row",:locals=>{:entity=>nil,:is_new=>true}%>
|
File without changes
|