mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-25 14:19:51 +00:00
Finish work on webui project notes
This commit is contained in:
parent
0a7b7ed91e
commit
eb94217df0
File diff suppressed because one or more lines are too long
@ -1025,9 +1025,4 @@ function inColor(x) {
|
||||
return "e scr.color=true;"+x+";e scr.color=false";
|
||||
}
|
||||
|
||||
function save_project_notes() {
|
||||
if ($("#pnotes").val() === r2ui.project_notes) {
|
||||
console.log("Saving " + r2ui.project_notes);
|
||||
r2.cmd("Pnj " + btoa(r2ui.project_notes));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,9 @@ enyo.kind ({
|
||||
var key = String.fromCharCode(keynum);
|
||||
// console.log(key);
|
||||
|
||||
if (inEvent.ctrlKey||inEvent.metaKey) return true;
|
||||
if (inEvent.ctrlKey||inEvent.metaKey) return;
|
||||
if ($(inEvent.target).prop("tagName") === "INPUT" || $(inEvent.target).prop("tagName") === "TEXTAREA") return;
|
||||
|
||||
|
||||
// show help
|
||||
if (key === '?') {
|
||||
|
@ -101,7 +101,6 @@ r2ui.update_fcn_BB = function(fcn_offset, bb_offset, bbinfo) {
|
||||
}
|
||||
};
|
||||
|
||||
r2ui.project_notes = "";
|
||||
r2ui.current_fcn_offset = null;
|
||||
r2ui.graph = null;
|
||||
r2ui.console_lang = "r2";
|
||||
|
@ -30,6 +30,7 @@
|
||||
<script type="text/javascript" src="./lib/js/taphold.js"></script>
|
||||
<script type="text/javascript" src="./lib/js/jquery.ui-contextmenu.js"></script>
|
||||
<script type="text/javascript" src="./lib/js/jquery.layout-latest.js"></script>
|
||||
<script type="text/javascript" src="./lib/js/jquery.donetyping.js"></script>
|
||||
<script type="text/javascript" src="./lib/js/tree.jquery.js"></script>
|
||||
<script type="text/javascript" src="./lib/js/jquery.layout.resizePaneAccordions-latest.js"></script>
|
||||
<script type="text/javascript" src="./lib/js/jquery.scrollTo-latest.js"></script>
|
||||
|
36
shlr/www/p/lib/js/jquery.donetyping.js
Normal file
36
shlr/www/p/lib/js/jquery.donetyping.js
Normal file
@ -0,0 +1,36 @@
|
||||
;(function($){
|
||||
$.fn.extend({
|
||||
donetyping: function(callback,timeout){
|
||||
timeout = timeout || 1e3; // 1 second default timeout
|
||||
var timeoutReference,
|
||||
doneTyping = function(el){
|
||||
if (!timeoutReference) return;
|
||||
timeoutReference = null;
|
||||
callback.call(el);
|
||||
};
|
||||
return this.each(function(i,el){
|
||||
var $el = $(el);
|
||||
// Chrome Fix (Use keyup over keypress to detect backspace)
|
||||
// thank you @palerdot
|
||||
$el.is(':input') && $el.on('keyup keypress',function(e){
|
||||
// This catches the backspace button in chrome, but also prevents
|
||||
// the event from triggering too premptively. Without this line,
|
||||
// using tab/shift+tab will make the focused element fire the callback.
|
||||
if (e.type=='keyup' && e.keyCode!=8) return;
|
||||
|
||||
// Check if timeout has been set. If it has, "reset" the clock and
|
||||
// start over again.
|
||||
if (timeoutReference) clearTimeout(timeoutReference);
|
||||
timeoutReference = setTimeout(function(){
|
||||
// if we made it here, our timeout has elapsed. Fire the
|
||||
// callback
|
||||
doneTyping(el);
|
||||
}, timeout);
|
||||
}).on('blur',function(){
|
||||
// If we can, fire the event since we're leaving the field
|
||||
doneTyping(el);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
@ -278,23 +278,16 @@ $(document).ready( function() {
|
||||
|
||||
// Project notes
|
||||
r2.cmdj("Pnj", function(x){
|
||||
// TODO: Handle when project does not exist
|
||||
// TODO: remove keyhandlers from pnotes
|
||||
if (x !== null) {
|
||||
console.log(x);
|
||||
var notes = atob(x);
|
||||
$("#pnotes").html(notes);
|
||||
}
|
||||
if (x !== null) $("#pnotes").html(atob(x));
|
||||
});
|
||||
$("#pnotes").bind("keydown", function(x) {
|
||||
r2ui.project_notes = $("#pnotes").val();
|
||||
setTimeout("save_project_notes();", 3000);
|
||||
$("#pnotes").donetyping(function() {
|
||||
r2.cmd("Pnj " + btoa($("#pnotes").val()));
|
||||
r2.cmd("Po", function(x) {
|
||||
if (x === "") alert("Notes won't be persited until a project is opened. Use Project's tab or 'Ps name' to save current project");
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
function scroll_to_element(element) {
|
||||
if (element === undefined) return;
|
||||
var top = Math.max(0,element.documentOffsetTop() - ( window.innerHeight / 2 ));
|
||||
@ -324,11 +317,8 @@ function handleKeypress(inEvent) {
|
||||
var key = String.fromCharCode(keynum);
|
||||
// console.log(key);
|
||||
|
||||
if (inEvent.ctrlKey||inEvent.metaKey) return true;
|
||||
|
||||
if ($(inEvent.target).prop("tagName") === "INPUT") {
|
||||
return;
|
||||
};
|
||||
if (inEvent.ctrlKey||inEvent.metaKey) return;
|
||||
if ($(inEvent.target).prop("tagName") === "INPUT" || $(inEvent.target).prop("tagName") === "TEXTAREA") return;
|
||||
|
||||
if (r2ui._dis.renaming !== null) return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user