From 0e27ddab747710d311addf631737a932bd69e037 Mon Sep 17 00:00:00 2001 From: smilerz Date: Thu, 25 Mar 2021 14:02:57 -0500 Subject: [PATCH] added bookmarklet that doesn't work yet --- cookbook/static/js/bookmarklet.js | 37 ++++++++++++++++++++++++++++ cookbook/templates/url_import.html | 11 +++++++-- cookbook/templatetags/custom_tags.py | 22 +++++++++++++++++ cookbook/urls.py | 2 +- 4 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 cookbook/static/js/bookmarklet.js diff --git a/cookbook/static/js/bookmarklet.js b/cookbook/static/js/bookmarklet.js new file mode 100644 index 00000000..8558f584 --- /dev/null +++ b/cookbook/static/js/bookmarklet.js @@ -0,0 +1,37 @@ +(function(){ + + var v = "1.3.2"; + + if (window.jQuery === undefined || window.jQuery.fn.jquery < v) { + var done = false; + var script = document.createElement("script"); + script.src = "https://ajax.googleapis.com/ajax/libs/jquery/" + v + "/jquery.min.js"; + script.onload = script.onreadystatechange = function(){ + if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) { + done = true; + initBookmarklet(); + } + }; + document.getElementsByTagName("head")[0].appendChild(script); + } else { + initBookmarklet(); + } + function initBookmarklet() { + (window.bookmarkletTandoor = function() { + r = confirm('Click OK to import recipe automatically, click Cancel to import the recipe manually.'); + if (r) { + auto=true + } else { + auto=false + } + + var newIframe = document.createElement('iframe'); + newIframe.width = '200';newIframe.height = '200'; + newIframe.src = localStorage.getItem('importURL'); + document.body.appendChild(newIframe); + + + } + )(); + } +})(); diff --git a/cookbook/templates/url_import.html b/cookbook/templates/url_import.html index 16b358de..aa232ac4 100644 --- a/cookbook/templates/url_import.html +++ b/cookbook/templates/url_import.html @@ -1,6 +1,7 @@ {% extends "base.html" %} {% load i18n %} {% load static %} +{% load custom_tags %} {% block title %}{% trans 'URL Import' %}{% endblock %} @@ -20,9 +21,15 @@ {% endblock %} {% block content %} -
-

{% trans 'Import' %}

+
+

{% trans 'Import' %}

+ + {% trans 'Bookmark Me!' %} +