Commit 7883bb10 authored by iv's avatar iv

OfficeJS drive: Fix unecessary line and add message errors for cd/ls 'commands'.

parent 409c5988
...@@ -167,32 +167,37 @@ ...@@ -167,32 +167,37 @@
\n \n
// if command given: proceed\n // if command given: proceed\n
if (command) {\n if (command) {\n
switch (command) {\n try {\n
case \'cd\':\n switch (command) {\n
case \'ls\':\n case \'cd\':\n
if (args.length === 1) {\n if (args.length === 1) {\n
return gadget.redirect({\n return gadget.redirect({\n
position: absolutePosition(gadget.props.currentPosition, args[0])\n position: absolutePosition(gadget.props.currentPosition, args[0])\n
});\n });\n
}\n }\n
throw (\'Usage of \' + command + \' requires a single argument.\');\n throw new Error(\'Usage of \' + command + \' requires a single argument.\');\n
\n \n
case \'vim\':\n case \'vim\':\n
case \'vi\':\n case \'vi\':\n
if (args.length === 1) {\n if (args.length === 1) {\n
return gadget.redirect({\n return gadget.redirect({\n
page: \'edit\',\n page: \'edit\',\n
position: absolutePosition(\n position: absolutePosition(\n
gadget.props.currentPosition,\n gadget.props.currentPosition,\n
position.join(\'/\')\n position.join(\'/\')\n
),\n ),\n
resource: resource\n resource: resource\n
});\n });\n
}\n
throw new Error(\'Usage of \' + command + \' requires a single argument.\');\n
default:\n
throw new Error(\'Unknown command: \' + command);\n
}\n }\n
throw (\'Usage of \' + command + \' requires a single argument.\');\n } catch (e) {\n
default:\n gadget.props.element.querySelector(\'.error\').textContent = e.name +\n
throw (\'Unknown command: \' + command);\n ": " +\n
}\n e.message;\n
}
}\n }\n
})\n })\n
\n \n
...@@ -208,7 +213,6 @@ ...@@ -208,7 +213,6 @@
}\n }\n
gadget.props.currentPosition = options.position;\n gadget.props.currentPosition = options.position;\n
gadget.props.element.querySelector(\'input\').value = \'\';\n gadget.props.element.querySelector(\'input\').value = \'\';\n
gadget.props.element.querySelector(\'.position\').value = options.position;\n
\n \n
// clean previous ul children\n // clean previous ul children\n
while (ul.hasChildNodes()) {\n while (ul.hasChildNodes()) {\n
...@@ -230,7 +234,7 @@ ...@@ -230,7 +234,7 @@
liContent = document.createElement(\'a\');\n liContent = document.createElement(\'a\');\n
\n \n
liContent.setAttribute(\'href\', \'#page=edit&resource=\' +\n liContent.setAttribute(\'href\', \'#page=edit&resource=\' +\n
key + \'&position=\' + options.position);\n key + \'&position=\' + options.position);\n
liContent.appendChild(resourceName);\n liContent.appendChild(resourceName);\n
} else {\n } else {\n
liContent = resourceName;\n liContent = resourceName;\n
......
...@@ -134,8 +134,9 @@ ...@@ -134,8 +134,9 @@
<body>\n <body>\n
<h1>Super OfficeJS Drive</h1>\n <h1>Super OfficeJS Drive</h1>\n
<form>\n <form>\n
position: <input type="text" name="position">\n <input type="text">\n
</form>\n </form>\n
<div><a class="error"></a></div>\n
<ul>\n <ul>\n
</ul>\n </ul>\n
</body>\n </body>\n
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment