Skip to content

Commit

Permalink
fix autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
misterpah committed Aug 31, 2013
1 parent 206f528 commit 1a6c363
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 12 deletions.
10 changes: 4 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,23 @@
<script>
jQuery(document).ready(function() {
splash_state_init();
$("#splash").fadeIn("slow");





$("#splash").fadeIn("slow");
});
</script>

</head>

<body>
<!--- hidden stuffs START -->

<div style='display:none' id='editor_vars'>
projectFile <div id='projectFile'></div>
projectContent:<div id="projectContent"></div>
projectDialog:<input id="projectDialog" type="file" />
fileDialog:<input id="fileDialog" type="file" />
</div>

<div style="position:absolute;top:10px;left:10px;width:100%;z-index:999;" id='notify_position'></div>

<div class="state" id='splash'>
<div class='valign_parent'>
Expand Down
39 changes: 37 additions & 2 deletions js/editor/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ function putsAutocomplete(error,stdout,stderr){
$(document).triggerHandler("autocomplete_complete", stderr);
}


function putsAutocomplete(error,stdout,stderr){
$(document).triggerHandler("autocomplete_complete", stderr);
}


function hint_haxe(editor,options){
}
Expand Down Expand Up @@ -38,26 +43,56 @@ $(document).on("autocomplete",function(event,data,key){

$(document).on("autocomplete_complete",function(event,data){

var skip = false;
// check if data starts with xml (<)
//console.log(data);
var startswith = data.charAt(0);
if (startswith != "<")
{
skip = true;
}


if (skip == true)
{
ide_alert(data);
}

//var retStr = "";

///////////////////////
// seek object in class
if (session['last_key'] == ".")
if (session['last_key'] == "." && skip == false)
{
session['last_key'] = '';
var json = $.xml2json(data);
var json_array = "";
var json_str = "";
var haxeHint = [];




//

if (json instanceof Array == true)
{
json_array = json.i;
for (i = 0;i < json_array.length;i++)
{
var cur = json_array[i];
haxeHint.push(cur.n);
}
}
else
{
//haxeHint.push(json);
}

localStorage.haxeHint = haxeHint;
var id = session['window_active_id'];
CodeMirror.showHint(editors[id],CodeMirror.hint.haxe);

} // END seek object in class


Expand All @@ -66,7 +101,7 @@ $(document).on("autocomplete_complete",function(event,data){

//////////////////////////
// seek object in function
if (session['last_key'] == "(")
if (session['last_key'] == "(" && skip == false)
{
var json = $.xml2json(data);
var id = session['window_active_id'];
Expand Down
50 changes: 47 additions & 3 deletions js/editor/ide.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,42 @@ $(document).on("system_parse_project_complete",function(event){
$('#editor').show();
})

function ide_alert(type_error,content)
{
var type_text = "";
if (type_error == "error")
{
type_error = "danger";
type_text = "Error";

}

if (type_error == "warning")
{
type_error = "warning";
type_text = "Warning";
}

skip = false;
if (content == undefined)
{
skip = true;
}



var retstr = ['<div style="margin:10px;" class="alert alert-'+type_error+' fade in">',
'<a class="close" data-dismiss="alert" href="#" aria-hidden="true">&times;</a>',
'<strong>'+type_text+' :</strong><br/>'+content,
'</div>'].join("\n");

if (skip ==false)
{
$('#notify_position').append(retstr);
}

}


function ide_button(type)
{
Expand Down Expand Up @@ -233,6 +269,7 @@ function system_createNewTab(){
editors[id].setOption("theme","blackboard");

editors[id].on("change",function(data){
console.log("Changed!");
$('#bufferCode_'+id).val(data.getValue());
var the_index = editors[id].getDoc().indexFromPos(editors[id].getCursor());
var the_text = data.getValue()[the_index -1];
Expand All @@ -249,9 +286,16 @@ function system_compileToFlash(){
if (system_check_os() == 'windows'){
exec("cd /D "+$('#projectFile').html()+" & openfl test flash",
function(error,stdout,stderr){
console.log(error);
console.log(stdout);
console.log(stderr);
if (error != null)
{
ide_alert("error",stderr);
}
/*
if (typeof error == "E") // error
{
console.log(stderr);
}
*/
/*
var cur_str = '<div class="autocomplete_block">';
cur_str += '<p>'+error+'</p>';
Expand Down
1 change: 1 addition & 0 deletions js/editor/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function splash_state_init() // executed in $(document).ready
editors = [];
session['last_key'] = "";
localStorage.haxeHint = new Array();

}


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"main": "index.html",
"window": {
"title": "codename: Haxeflixel Editor",
"toolbar": false,
"toolbar": true,
"frame": true,
"width": 800,
"height": 600,
Expand Down

0 comments on commit 1a6c363

Please sign in to comment.