Archived
Added choice of project, r/w perms, and fixed up some css
This commit is contained in:
Binary file not shown.
@@ -1,10 +1,17 @@
|
|||||||
$(function() {
|
$(function() {
|
||||||
|
$('td').focus(function() {
|
||||||
|
if (this.id.split("-")[0] == "memory") {
|
||||||
|
$(this).css("background-color", "lightblue")
|
||||||
|
}
|
||||||
|
});
|
||||||
var data = [];
|
var data = [];
|
||||||
$('td').keydown(function() {
|
$('td').keydown(function() {
|
||||||
data.push(this.id, $(this).html().substr(0, 2)); //position, value
|
data.push(this.id, $(this).html().substr(0, 2)); //position, value
|
||||||
})
|
})
|
||||||
$('td').blur(function() {
|
$('td').blur(function() {
|
||||||
|
$(this).css("background", "none");
|
||||||
if ((id_i = data.indexOf(this.id) != -1) && data[id_i+1] != $(this).html().substr(0, 2)) {
|
if ((id_i = data.indexOf(this.id) != -1) && data[id_i+1] != $(this).html().substr(0, 2)) {
|
||||||
|
$(this).css("color", "darkgreen");
|
||||||
var int_id = this.id.split("-")[1]
|
var int_id = this.id.split("-")[1]
|
||||||
$.post("/memory/update_memory?project="+$(this).closest("table").data("project")+"&file="+Math.floor((int_id/2048)+1)+"&mem_id="+int_id%2048+"&value="+$(this).html().substr(0, 2));
|
$.post("/memory/update_memory?project="+$(this).closest("table").data("project")+"&file="+Math.floor((int_id/2048)+1)+"&mem_id="+int_id%2048+"&value="+$(this).html().substr(0, 2));
|
||||||
data.splice(id_i, 2);
|
data.splice(id_i, 2);
|
||||||
|
|||||||
@@ -1028,9 +1028,11 @@ nav.pagination {
|
|||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
}
|
}
|
||||||
.memory-table {
|
.memory-table {
|
||||||
width: 870px;
|
width: 980px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
|
text-align: center;
|
||||||
th, td {
|
th, td {
|
||||||
|
height: 20px;
|
||||||
border: 1px solid black;
|
border: 1px solid black;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,30 +16,31 @@ class MemoryController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def table
|
def table
|
||||||
Dir.chdir("/etc/minecraft/redstoner/plugins/JavaUtils/memory/projects/#{params[:project]}")
|
Dir.chdir("/etc/minecraft/redstoner/plugins/JavaUtils/memory/projects/#{params[:project].gsub(/[^a-zA-Z0-9-]/,"")[0..35]}")
|
||||||
@data = []
|
@data = []
|
||||||
Dir.glob('*').reverse.each do |f|
|
Dir.glob('*').reverse.each do |f|
|
||||||
File.open(Dir.pwd+"/#{f}") do |file|
|
File.open(Dir.pwd+"/#{f}") do |file|
|
||||||
@data.concat(file.read.unpack("C*").map{|h| h.to_s(16)})
|
@data.concat(file.read.unpack("C*").map{|h| h.to_s(16)})
|
||||||
if JSON.parse((jf = File.open(Dir.pwd+"/project.json")).read)["read"].include? current_user.uuid.gsub("-","")
|
unless (parse = JSON.parse((jf = File.open(Dir.pwd+"/project.json")).read))["read"].include? current_user.uuid.gsub("-","")
|
||||||
@can_edit = false
|
|
||||||
else
|
|
||||||
@can_edit = true
|
@can_edit = true
|
||||||
end
|
end
|
||||||
|
@name = parse["name"]
|
||||||
jf.close
|
jf.close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_memory
|
def update_memory
|
||||||
Dir.chdir("/etc/minecraft/redstoner/plugins/JavaUtils/memory/projects/#{params[:project]}")
|
Dir.chdir("/etc/minecraft/redstoner/plugins/JavaUtils/memory/projects/#{params[:project].gsub(/[^a-zA-Z0-9-]/,"")[0..35]}")
|
||||||
new_text = ""
|
unless params[:mem_id].to_i > JSON.parse(File.read("project.json"))["size"] || (/[^A-Fa-f0-9]/.match params[:value])
|
||||||
File.open("#{params[:file]}.hex"){|f| new_text = f.read.unpack("C*").collect{|h| h.to_s(16)}}
|
new_text = ""
|
||||||
new_text[params[:mem_id].to_i] = params[:value]
|
File.open("#{params[:file]}.hex"){|f| new_text = f.read.unpack("C*").collect{|h| h.to_s(16)}}
|
||||||
File.open("#{params[:file]}.hex", "w") do |f|
|
new_text[params[:mem_id].to_i] = params[:value]
|
||||||
f.write((new_text.collect{|h| h.to_s.to_i(16)}).pack("C*").force_encoding("UTF-8"))
|
File.open("#{params[:file]}.hex", "w") do |f|
|
||||||
|
f.write((new_text.collect{|h| h.to_s.to_i(16)}).pack("C*").force_encoding("UTF-8"))
|
||||||
|
end
|
||||||
|
render nothing: true
|
||||||
end
|
end
|
||||||
render nothing: true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<%= form_tag "memory/table", method: :get do %>
|
<%= form_tag url_for(controller: "memory", action: "table"), method: :get do %>
|
||||||
<%= select_tag "project", options_for_select(@projects.collect.with_index{|p, i| [@project_names[i], p]}) %>
|
<%= select_tag "project", options_for_select(@projects.collect.with_index{|p, i| [@project_names[i], p]}) %>
|
||||||
<%= submit_tag "View Table", name: nil %>
|
<br><br>
|
||||||
|
<%= submit_tag "Load table", name: nil, class: "btn blue" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<h1 style="text-align:center"><%= title @name + (" (read-only)" if !@can_edit).to_s %></h1>
|
||||||
<table class="memory-table", data-project="<%=params[:project]%>">
|
<table class="memory-table", data-project="<%=params[:project]%>">
|
||||||
<tr>
|
<tr>
|
||||||
<% ["Address","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"].each do |i| %>
|
<% ["Address","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"].each do |i| %>
|
||||||
@@ -8,7 +9,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><b><%=(rindex*16).to_s(16).upcase.rjust(6, "0")%></b></td>
|
<td><b><%=(rindex*16).to_s(16).upcase.rjust(6, "0")%></b></td>
|
||||||
<% row.each_with_index do |hex, hindex| %>
|
<% row.each_with_index do |hex, hindex| %>
|
||||||
<td contenteditable="<%=@can_edit%>" id="memory-<%=(16*rindex)+hindex%>"><%=hex.to_s.upcase.rjust(2, "0")%></td>
|
<td contenteditable="<%=!!@can_edit%>" id="memory-<%=(16*rindex)+hindex%>"><%=hex.to_s.upcase.rjust(2, "0")%></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
+2
-2
@@ -10,7 +10,7 @@ default: &default
|
|||||||
development:
|
development:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: redstoner-web
|
database: redstoner-web
|
||||||
username: root
|
username: web
|
||||||
|
|
||||||
production:
|
production:
|
||||||
<<: *default
|
<<: *default
|
||||||
@@ -24,4 +24,4 @@ test:
|
|||||||
adapter: sqlite3
|
adapter: sqlite3
|
||||||
database: db/test.sqlite3
|
database: db/test.sqlite3
|
||||||
pool: 5
|
pool: 5
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
|
|||||||
@@ -43,4 +43,4 @@ Redstoner::Application.configure do
|
|||||||
password: ENV["GMAIL_PASSWORD"],
|
password: ENV["GMAIL_PASSWORD"],
|
||||||
}
|
}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
+1
-1
@@ -38,4 +38,4 @@ User.create!(
|
|||||||
password: "123456789", # high seructity!
|
password: "123456789", # high seructity!
|
||||||
password_confirmation: "123456789",
|
password_confirmation: "123456789",
|
||||||
role: Role.get(:superadmin)
|
role: Role.get(:superadmin)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user