forked from steven-copley/nubuilder4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnuace.php
More file actions
152 lines (100 loc) · 4.55 KB
/
Copy pathnuace.php
File metadata and controls
152 lines (100 loc) · 4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
require_once('nuchoosesetup.php');
$jquery = $_SESSION['nubuilder_session_data']['JQ_PATH'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Ace Editor</title>
<script src="<?php echo $jquery; ?>" type="text/javascript"></script>
<?php echo $_SESSION['nubuilder_session_data']['PLUGIN'] ? '<script> var $ = jQuery; </script>' : ''; ?>
<script src="ace/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="ace/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="ace/src-min-noconflict/ext-language_tools.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="nubuilder4.css">
<script>
window.c = opener.window.nuAce[0];
window.o = opener.window.nuAce[1];
window.t = opener.window.nuFORM.tableSchema;
window.f = opener.window.nuFORM.formSchema;
window.l = $('#' + o, window.opener.document).attr('data-nu-label');
function nuLoad(){
ace.require("ace/ext/language_tools");
window.editor = ace.edit("nu_editor");
editor.setTheme("ace/theme/monokai");
editor.setOptions({
enableBasicAutocompletion: true,
enableSnippets: true,
enableLiveAutocompletion: true
});
editor.on('change', function() {$('#copy_to_nubuilder').css('background-color', 'red');});
window.startValue = opener.window.document.getElementById(window.o).value;
editor.setFontSize(14);
var cl = '';
if ( window.c == 'HTML' ) {editor.getSession().setMode({path:"ace/mode/html", inline:true});cl='html';}
if ( window.c == 'Javascript' ) {editor.getSession().setMode({path:"ace/mode/javascript", inline:true});cl='js';}
if ( window.c == 'MySql' ) {editor.getSession().setMode({path:"ace/mode/mysql", inline:true});cl='sql';}
if ( window.c == 'PHP' ) {editor.getSession().setMode({path:"ace/mode/php", inline:true});cl='php';}
if ( window.c == 'SQL' ) {editor.getSession().setMode({path:"ace/mode/sql", inline:true});cl='sql';}
document.getElementById('nu_language').innerHTML = c;
if($('#' + o, window.opener.document)[0].id == 'deb_message'){
$('#copy_to_nubuilder').remove();
}else{
document.getElementById('copy_to_nubuilder').value = 'Copy changes back to ' + l;
}
nuResize();
editor.setValue(window.startValue);
editor.focus();
editor.navigateFileStart();
$('#copy_to_nubuilder').css('background-color', '');
}
function nuResize(){
document.getElementById('nu_editor_pad').style.width = String(Number(window.innerWidth)) + 'px';
document.getElementById('nu_editor').style.width = String(Number(window.innerWidth)) + 'px';
document.getElementById('nu_editor').style.height = String(Number(window.innerHeight) - 75) + 'px';
}
function nuAceSave(){
window.nuWarn = 0;
if(!opener.window.document.getElementById(window.o)){
alert('The opening Form is no longer available.');
return;
}
opener.window.document.getElementById(o).value = editor.getValue();
if ("createEvent" in document) {
var evt = document.createEvent("HTMLEvents");
evt.initEvent("change", false, true);
opener.window.document.getElementById(window.o).dispatchEvent(evt);
}else{
opener.window.document.getElementById(window.o).fireEvent("onchange");
}
window.close();
}
function nuWarning(){
if(editor.getValue() != window.startValue && window.nuWarn == 1){
return "Close this window without Saving?";
}
}
function nuUpdateDrag(t){
document.getElementById('nuDrag').value = document.getElementById('nuField')[t.value].innerHTML;
}
function nuChooseFields(){
var n = document.getElementById('nuTable').value;
var t = window.s[n];
var f = document.getElementById('nuField').value;
document.getElementById('nuDrag').value = t.fields[f];
}
function nuChooseSnips(t){
document.getElementById('nuDrag').value = t.value;
}
window.nuWarn = 1;
window.onbeforeunload = nuWarning;
</script>
</head>
<body onload='nuLoad()' onresize='nuResize()'>
<input type='button' id='copy_to_nubuilder' class='nuActionButton' style='top:8px;left:8px;position:absolute' onclick='nuAceSave()'>
<span id='nu_language' class="nuNotBreadcrumb" style='top:35px;left:10px;position:absolute;font-wieght:500'></span>
<div id='nu_editor_pad' style='width:1000px;height:10px;top:55px;left:0px;text-align:left;position:absolute;background-color:#272822;' ></div>
<div id='nu_editor' style='width:1000px;height:800px;top:65px;left:0px;text-align:left;position:absolute;' ></div>
<img id="nulogo" style="position:absolute;top:5px;right:20px" width="120px" src="graphics/logo.png">
</body>
</html>