added link to QR-Code for opening plan on mobile devices
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>de.srsoftware</groupId>
|
<groupId>de.srsoftware</groupId>
|
||||||
<artifactId>web4rail</artifactId>
|
<artifactId>web4rail</artifactId>
|
||||||
<version>0.6.4</version>
|
<version>0.6.5</version>
|
||||||
<name>Web4Rail</name>
|
<name>Web4Rail</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<description>Java Model Railway Control</description>
|
<description>Java Model Railway Control</description>
|
||||||
|
|||||||
@@ -178,8 +178,11 @@ function request(data){
|
|||||||
function runAction(ev){
|
function runAction(ev){
|
||||||
var clicked = ev.target;
|
var clicked = ev.target;
|
||||||
var realm = clicked.hasAttribute('class') ? clicked.getAttribute('class') : null;
|
var realm = clicked.hasAttribute('class') ? clicked.getAttribute('class') : null;
|
||||||
//console.log("runAction: ",{action: clicked.id, realm:realm});
|
console.log("runAction: ",{action: clicked.id, realm:realm});
|
||||||
return request({action:ev.target.id,realm:realm}); // TODO: ask for name
|
if (clicked.id == 'qrcode'){
|
||||||
|
window.open("https://api.qrserver.com/v1/create-qr-code/?data="+window.location.href,'_blank');
|
||||||
|
return false;
|
||||||
|
} else return request({action:ev.target.id,realm:realm}); // TODO: ask for name
|
||||||
}
|
}
|
||||||
|
|
||||||
function stream(ev){
|
function stream(ev){
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import java.io.IOException;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
@@ -48,7 +49,7 @@ public class Application implements Constants{
|
|||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
plan = new Plan();
|
plan = new Plan();
|
||||||
}
|
}
|
||||||
Desktop.getDesktop().browse(URI.create("http://localhost:"+config.getInt(PORT)+"/plan"));
|
Desktop.getDesktop().browse(URI.create("http://"+InetAddress.getLocalHost().getHostName()+":"+config.getInt(PORT)+"/plan"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Object handle(HashMap<String, String> params) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
|
private static Object handle(HashMap<String, String> params) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ public class Plan implements Constants{
|
|||||||
private static final String Y = "y";
|
private static final String Y = "y";
|
||||||
private static final String DIRECTION = "direction";
|
private static final String DIRECTION = "direction";
|
||||||
private static final HashMap<OutputStreamWriter,Integer> clients = new HashMap<OutputStreamWriter, Integer>();
|
private static final HashMap<OutputStreamWriter,Integer> clients = new HashMap<OutputStreamWriter, Integer>();
|
||||||
|
private static final String ACTION_QR = "qrcode";
|
||||||
|
|
||||||
public HashMap<String,Tile> tiles = new HashMap<String,Tile>();
|
public HashMap<String,Tile> tiles = new HashMap<String,Tile>();
|
||||||
private HashSet<Block> blocks = new HashSet<Block>();
|
private HashSet<Block> blocks = new HashSet<Block>();
|
||||||
@@ -112,9 +113,10 @@ public class Plan implements Constants{
|
|||||||
private Tag actionMenu() throws IOException {
|
private Tag actionMenu() throws IOException {
|
||||||
Tag actionMenu = new Tag("div").clazz("actions").content(t("Actions"));
|
Tag actionMenu = new Tag("div").clazz("actions").content(t("Actions"));
|
||||||
Tag actions = new Tag("div").clazz("list").content("");
|
Tag actions = new Tag("div").clazz("list").content("");
|
||||||
new Div("power").clazz(REALM_CU).content(t("Toggle power")).addTo(actions);
|
new Div(ACTION_POWER).clazz(REALM_CU).content(t("Toggle power")).addTo(actions);
|
||||||
new Div("save").clazz(REALM_PLAN).content(t("Save plan")).addTo(actions);
|
new Div(ACTION_SAVE).clazz(REALM_PLAN).content(t("Save plan")).addTo(actions);
|
||||||
new Div("analyze").clazz(REALM_PLAN).content(t("Analyze plan")).addTo(actions);
|
new Div(ACTION_ANALYZE).clazz(REALM_PLAN).content(t("Analyze plan")).addTo(actions);
|
||||||
|
new Div(ACTION_QR).clazz(REALM_PLAN).content(t("QR-Code")).addTo(actions);
|
||||||
return actions.addTo(actionMenu);
|
return actions.addTo(actionMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user