Skip to content

Commit c1de25c

Browse files
committed
Resolved #5 and resolved #44. Removed annoying "pre-release" label.
1 parent f573eec commit c1de25c

9 files changed

+122
-38
lines changed

css/index.css

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ body{
6262
display: block;
6363
font-size: 13px;
6464
}
65+
#run-version{
66+
display: block;
67+
color:#7a7a7a;
68+
font-size:11px;
69+
}
6570

6671
/**
6772
* Content - The main space

index.html

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@
1616
</head>
1717
<body>
1818

19-
<!-- Pre-release warning -->
20-
<div style="color:#f00;background-color:#fff;font-weight:bold;position:fixed;right:0;bottom:0;z-index:1000;padding:5px;border-top-left-radius:5px;opacity:0.4">Pre-release</div>
21-
2219
<!-- Sidebar -->
2320
<div id="sidebar">
2421
<!-- Menu -->
2522
<ul>
26-
<li data-event="sidebar-run"><span class="glyphicon glyphicon-play" aria-hidden="true"></span> <span data-string="Run code"></span></li>
23+
<li data-event="sidebar-run"><span class="glyphicon glyphicon-play" aria-hidden="true"></span> <span data-string="Run code"></span> <span id="run-version"></span></li>
2724
<li data-event="sidebar-clear"><span class="glyphicon glyphicon-erase" aria-hidden="true"></span> <span data-string="Clear"></span></li>
2825
<li data-event="sidebar-import"><span class="glyphicon glyphicon-open-file" aria-hidden="true"></span> <span data-string="Import from file"></span></li>
2926
<li data-event="sidebar-presentation"><span class="glyphicon glyphicon-blackboard" aria-hidden="true"></span> <span data-string="Presentation mode"></span></li>

js/binary.operations.js

+76-28
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,35 @@ function binaryAdd() {
1919
var version = binaryGetVersion(path, true);
2020

2121
// Oops! Invalid PHP binary!
22-
if (!version)
22+
if (!version) {
2323
dialog.showErrorBox(i18n.__("Error"), i18n.__("Invalid PHP binary"));
24+
return;
25+
}
2426

2527
// Save new version to config
2628
conf.set("php.versions." + version, path);
2729

30+
// Is this our first?
31+
if (binaryGetCount() == 1) {
32+
// Please, set it as our new default
33+
binarySetNewDefault();
34+
}
35+
2836
// Update list
2937
binaryUpdateList();
3038
}
3139
}
3240

33-
function binaryRemove() {
34-
41+
function binaryRemove(version) {
42+
conf.del("php.versions." + version)
43+
// Are you deleting your default version?
44+
if (conf.get("php.default") == version) {
45+
binarySetNewDefault();
46+
}
3547
}
3648

3749
function binaryMakeDefault(version) {
38-
conf.set("php.default", binaryConvertVersionToSave(version));
50+
binarySetNewDefault(binaryConvertVersionToSave(version));
3951
}
4052

4153
function binaryConvertVersionToSave(version) {
@@ -66,23 +78,79 @@ function binaryGetVersion(path, replaced) {
6678
}
6779
}
6880

81+
function binaryGetCount() {
82+
return Object.keys(conf.get("php.versions")).length;
83+
}
84+
85+
/**
86+
* Commands from modal
87+
*/
88+
function makeDefaultVersion(version) {
89+
binaryMakeDefault(version);
90+
binaryUpdateList();
91+
php_path = conf.get("php.versions." + conf.get("php.default"));
92+
}
93+
94+
function removeVersion(version) {
95+
var opt = dialog.showMessageBox({
96+
"type": "question",
97+
"title": i18n.__("Are you sure?"),
98+
"message": i18n.__("Removing {{version}} version. Are you sure?", {"version": binaryConvertVersionToShow(version)}),
99+
"buttons": [i18n.__("Yes"), i18n.__("No")],
100+
});
101+
102+
// Yes = 0; No = 1
103+
if (opt == 0) {
104+
binaryRemove(version);
105+
binaryUpdateList();
106+
}
107+
}
108+
109+
function binarySetNewDefault(which) {
110+
if (which) {
111+
conf.set("php.default", which);
112+
} else if (binaryGetCount()) {
113+
// Set first option on the list as default (if we have any)
114+
var v_keys = Object.keys(conf.get("php.versions"));
115+
conf.set("php.default", v_keys[0]);
116+
} else {
117+
conf.del("php.default");
118+
}
119+
updatePhpPath();
120+
}
121+
122+
function updatePhpPath() {
123+
// Change php_path variable for runner
124+
php_path = conf.get("php.versions." + conf.get("php.default"));
125+
126+
// Change PHP version number shown in app
127+
$("#run-version").html(phpGetCurrVersion());
128+
}
129+
130+
/**
131+
* Get current version
132+
*/
133+
function phpGetCurrVersion() {
134+
return binaryConvertVersionToShow(conf.get("php.default"));
135+
}
136+
69137
/**
70138
* Binary list functions
71139
*/
72140
function binaryUpdateList() {
73141
$("#binary-list").empty();
74142

75143
var versions = conf.get("php.versions");
76-
var inUse = conf.get("php.default");
144+
var in_use = conf.get("php.default");
77145

78146
for (var v in versions) {
79-
$("#binary-list").append(binaryLineGetTemplate(v, versions[v], (inUse == v)));
147+
$("#binary-list").append(binaryLineGetTemplate(v, versions[v], (in_use == v)));
80148
}
81149
}
82150

83-
function binaryLineGetTemplate(version, path, inUse) {
151+
function binaryLineGetTemplate(version, path, in_use) {
84152
return [
85-
'<tr ' + (inUse ? 'class="info"' : '') + '>',
153+
'<tr ' + (in_use ? 'class="info"' : '') + '>',
86154
' <td>' + binaryConvertVersionToShow(version) + '</td>',
87155
' <td>' + path + '</td>',
88156
' <td class="text-right">',
@@ -98,23 +166,3 @@ function binaryLineGetTemplate(version, path, inUse) {
98166
'</tr>'
99167
].join("\n");
100168
}
101-
102-
/**
103-
* Commands from modal
104-
*/
105-
function makeDefaultVersion(version) {
106-
binaryMakeDefault(version);
107-
binaryUpdateList();
108-
php_path = conf.get("php.versions." + conf.get("php.default"));
109-
}
110-
111-
function removeVersion(version) {
112-
var opt = dialog.showMessageBox({
113-
"type": "question",
114-
"title": i18n.__("Are you sure?"),
115-
"message": i18n.__("Removing {{version}} version. Are you sure?", {"version": binaryConvertVersionToShow(version)}),
116-
"buttons": [i18n.__("Yes"), i18n.__("No")],
117-
});
118-
119-
console.log(opt);
120-
}

js/index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ const settings_default = {
3131
}
3232

3333
// Editor
34-
var php_path = conf.get("php.versions." + conf.get("php.default"));
34+
var php_path;
3535
var editor = ace.edit("editor");
36+
updatePhpPath();
3637
editor.$blockScrolling = Infinity;
3738
editor.commands.removeCommand("showSettingsMenu"); // Prevents ACE bindings at Cmd + ,
3839

@@ -145,6 +146,13 @@ function renderApp(refresh) {
145146
*/
146147
// Sends code to PHP
147148
function runCode() {
149+
150+
// Is there any PHP for us to work with?
151+
if (!php_path) {
152+
setOutput(i18n.__("Error") + ": " + i18n.__("You don't have any PHP binary. Add one using the settings screen and try again."));
153+
return;
154+
}
155+
148156
setBusy(true);
149157
editor.focus();
150158

locales/da.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,11 @@
7272
"Presentation": "Presentation",
7373
"Try to open secondary window in another display": "Try to open secondary window in another display",
7474
"Single Display Mode": "Single Display Mode",
75-
"Multi Display Mode": "Multi Display Mode"
75+
"Multi Display Mode": "Multi Display Mode",
76+
"Invalid PHP binary": "Invalid PHP binary",
77+
"Version": "Version",
78+
"Are you sure?": "Are you sure?",
79+
"Removing {{version}} version. Are you sure?": "Removing {{version}} version. Are you sure?",
80+
"OK": "OK",
81+
"You don't have any PHP binary. Add one using the settings screen and try again.": "You don't have any PHP binary. Add one using the settings screen and try again."
7682
}

locales/de.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,11 @@
7272
"Presentation": "Presentation",
7373
"Try to open secondary window in another display": "Try to open secondary window in another display",
7474
"Single Display Mode": "Single Display Mode",
75-
"Multi Display Mode": "Multi Display Mode"
75+
"Multi Display Mode": "Multi Display Mode",
76+
"Invalid PHP binary": "Invalid PHP binary",
77+
"Version": "Version",
78+
"Are you sure?": "Are you sure?",
79+
"Removing {{version}} version. Are you sure?": "Removing {{version}} version. Are you sure?",
80+
"OK": "OK",
81+
"You don't have any PHP binary. Add one using the settings screen and try again.": "You don't have any PHP binary. Add one using the settings screen and try again."
7682
}

locales/en.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,11 @@
7272
"Presentation": "Presentation",
7373
"Try to open secondary window in another display": "Try to open secondary window in another display",
7474
"Single Display Mode": "Single Display Mode",
75-
"Multi Display Mode": "Multi Display Mode"
75+
"Multi Display Mode": "Multi Display Mode",
76+
"Invalid PHP binary": "Invalid PHP binary",
77+
"Version": "Version",
78+
"Are you sure?": "Are you sure?",
79+
"Removing {{version}} version. Are you sure?": "Removing {{version}} version. Are you sure?",
80+
"OK": "OK",
81+
"You don't have any PHP binary. Add one using the settings screen and try again.": "You don't have any PHP binary. Add one using the settings screen and try again."
7682
}

locales/fr.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,11 @@
7272
"Presentation": "Presentation",
7373
"Try to open secondary window in another display": "Try to open secondary window in another display",
7474
"Single Display Mode": "Single Display Mode",
75-
"Multi Display Mode": "Multi Display Mode"
75+
"Multi Display Mode": "Multi Display Mode",
76+
"Invalid PHP binary": "Invalid PHP binary",
77+
"Version": "Version",
78+
"Are you sure?": "Are you sure?",
79+
"Removing {{version}} version. Are you sure?": "Removing {{version}} version. Are you sure?",
80+
"OK": "OK",
81+
"You don't have any PHP binary. Add one using the settings screen and try again.": "You don't have any PHP binary. Add one using the settings screen and try again."
7682
}

locales/pt-BR.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,7 @@
7676
"Invalid PHP binary": "Binário PHP inválido",
7777
"Version": "Versão",
7878
"Are you sure?": "Tem certeza?",
79-
"Removing {{version}} version. Are you sure?": "Removendo versão {{version}}. Tem certeza?"
79+
"Removing {{version}} version. Are you sure?": "Removendo versão {{version}}. Tem certeza?",
80+
"OK": "OK",
81+
"You don't have any PHP binary. Add one using the settings screen and try again.": "Você não possui nenhum binário PHP. Adicione um na tela de configurações e tente novamente."
8082
}

0 commit comments

Comments
 (0)