aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Vitkov <alexvitkov98@gmail.com>2021-02-18 23:50:06 +0200
committerAlex Vitkov <alexvitkov98@gmail.com>2021-02-18 23:50:06 +0200
commitecd983a83f753195688461856c5fd6437d8f53e7 (patch)
tree3dcffca84a73d3e46f19a24cfaca2456a3ff91de
parent7fe813121b2e6d95ad6e86eeaf12ed58dc2ff729 (diff)
downloadfileup-ecd983a83f753195688461856c5fd6437d8f53e7.tar.gz
URL Actions, part 1 of N
-rw-r--r--actions.js18
-rw-r--r--loggedin.js14
-rw-r--r--loggedin.php2
3 files changed, 33 insertions, 1 deletions
diff --git a/actions.js b/actions.js
new file mode 100644
index 0000000..776e7ad
--- /dev/null
+++ b/actions.js
@@ -0,0 +1,18 @@
+
+// Patterns in the URL:
+// $fileanme - filename
+// $content_urlencoded - file contents, urlencoded
+// $content_base64 - file contents, base64'd
+
+const actions = [
+ {
+ "extension": ".txt",
+ "text": "Google search filename",
+ "url": "https://www.google.com/search?q=$filename"
+ },
+ {
+ "extension": ".txt",
+ "text": "Google search contents",
+ "url": "https://www.google.com/search?q=$filename"
+ }
+];
diff --git a/loggedin.js b/loggedin.js
index 8d9e92f..4f81f34 100644
--- a/loggedin.js
+++ b/loggedin.js
@@ -949,6 +949,8 @@ function add_file_visuals(fileview) {
open_file = fileview;
openfile(fileview.is_directory);
}],
+
+
];
if (is_in_trash) {
@@ -961,6 +963,18 @@ function add_file_visuals(fileview) {
['Rename', () => { rename_file(fileview.filename); }],
);
if (!fileview.is_directory) {
+ for (let a of actions) {
+ if (fileview.filename.endsWith(a.extension)) {
+ context_list.push(
+ [a.text, () => {
+ read_file_contents(false, (x) => {
+ alert (encodeURIComponent(x));
+ }, get_path(), fileview.filename);
+ }]
+ );
+ }
+ }
+
if (fileview.write_permissions) {
context_list.push(
['Replace', () => { replace_file(false, fileview.filename); }],
diff --git a/loggedin.php b/loggedin.php
index 47bdfeb..e6e904a 100644
--- a/loggedin.php
+++ b/loggedin.php
@@ -8,5 +8,5 @@
<input type="hidden" name="parent_directory" id="upload_parent_directory">
</form>
-
+<script src="actions.js"></script>
<script src="loggedin.js"></script>