Sha256: 4b4a0c5bc35a6c11294edba5a01c05647cf097054e10ae9ede47a40a8064d8d2

Contents?: true

Size: 1.85 KB

Versions: 12

Compression:

Stored size: 1.85 KB

Contents

<%
	if $whowish_word_admin == true
%>
	<script language="javascript">
		function change_whowish_word(self,word_id,word_arg,event)
		{
			if (!event) event = window.event;
			event.cancelBubble = true;
			if (event.stopPropagation) event.stopPropagation();
			
			$(self).loading_button(true,{word:""});
	
			var content = ""
			$.ajax({
				type: "POST",
				url: '/whowish_word/get_word',
				cache: false,
				async: false,
				data: {
					authenticity_token: "<%=form_authenticity_token%>",
					"word_id": word_id
				},
				success: function(data){
					content = data.content;
				}
			});
	
			$(self).loading_button(false);
			var new_word = prompt("Please set "+word_id+":",content);
	
			if (new_word == null) return
			
			$(self).loading_button(true,{word:""});
	
			$.ajax({
					type: "POST",
					url: '/whowish_word/change_word',
					cache: false,
					data: {
						authenticity_token: "<%=form_authenticity_token%>",
						"word_id":word_id,
						"content":new_word
					},
					success: function(data){
						$(self).loading_button(false);
						try {
							if (data.ok == true) {
	
								for (var i in word_arg)
								{
									re = new RegExp("\{"+i+"\}","g")
									new_word = new_word.replace(re, word_arg[i])
								}
	
								var the_container = $(self).parent().children('*:first')[0];
	
								try {$(the_container).val(new_word);} catch (e) {}
								try {$(the_container).html(new_word);} catch (e) {}
	
							}
							else {
								alert(data.error_message);
							}
	
						}
						catch (e) {
							alert(e);
						}
	
					},
					error: function(req, status, e){
						$(self).loading_button(false);
	                    if (req.status == 0) return;
						alert('Cannot connect to the server. Please try again later.');
					}
				});
		}
	
	</script>
<%
	end
%>

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
whowish_word-0.2.1 lib/legacy/whowish_word/lib/app/views/whowish_word/_javascript.html.erb
whowish_word-0.2.0 lib/legacy/whowish_word/lib/app/views/whowish_word/_javascript.html.erb
whowish_word-0.1.9 lib/legacy/whowish_word/lib/app/views/whowish_word/_javascript.html.erb
whowish_word-0.1.8 lib/legacy/whowish_word/lib/app/views/whowish_word/_javascript.html.erb
whowish_word-0.1.7 lib/legacy/whowish_word/lib/app/views/whowish_word/_javascript.html.erb
whowish_word-0.1.6 lib/legacy/whowish_word/lib/app/views/whowish_word/_javascript.html.erb
whowish_word-0.1.5 lib/legacy/whowish_word/lib/app/views/whowish_word/_javascript.html.erb
whowish_word-0.1.4 lib/legacy/whowish_word/lib/app/views/whowish_word/_javascript.html.erb
whowish_word-0.1.3 lib/legacy/whowish_word/lib/app/views/whowish_word/_javascript.html.erb
whowish_word-0.1.2 lib/legacy/whowish_word/lib/app/views/whowish_word/_javascript.html.erb
whowish_word-0.1.1 lib/legacy/whowish_word/lib/app/views/whowish_word/_javascript.html.erb
whowish_word-0.1.0 lib/legacy/whowish_word/lib/app/views/whowish_word/_javascript.html.erb