intrusively report failure to save pad
This commit is contained in:
@@ -7,11 +7,11 @@
|
||||
|
||||
// REMEMBER THAT CONSOLE OUTPUT GOES TO A SEPARATE BACKGROUND CONSOLE.
|
||||
(API.browser.browserAction.onClicked.addListener ->:Void [tab info] {
|
||||
(WebPad.find tab.url ->[:Dynamic pad] (sendMessage (Std.int tab.id) "openPad" [pad]))
|
||||
(WebPad.find tab.url ->[:Dynamic pad] (sendMessage (Std.int tab.id) "openPad" [pad (Std.int tab.id)]))
|
||||
})
|
||||
|
||||
(onMessage "savePad" [pad]
|
||||
(WebPad.save ~pad))
|
||||
(onMessage "savePad" [pad tabId]
|
||||
(WebPad.save pad ->:Void [type data] (sendMessage tabId type data)))
|
||||
|
||||
(onMessage "downloadTxtFile" [filename contents]
|
||||
(let [file (new File [contents] filename)
|
||||
|
||||
@@ -6,9 +6,11 @@
|
||||
(var &mut showing false)
|
||||
|
||||
|
||||
(onMessage "alert" [message]
|
||||
(window.alert message))
|
||||
|
||||
// on message from the button action, open the web pad
|
||||
(onMessage "openPad" [pad]
|
||||
(onMessage "openPad" [pad tabId]
|
||||
(unless div
|
||||
(set div (document.createElement "div"))
|
||||
(set div.style "position: absolute; top: 0; z-index:999999999; background: #555;")
|
||||
@@ -34,11 +36,14 @@
|
||||
value pad.content
|
||||
language "lisp")))
|
||||
(.addEventListener ($elem "saveBtn") "click"
|
||||
->e (sendMessage "savePad" [(object
|
||||
->e (sendMessage "savePad" [
|
||||
(object
|
||||
id pad.id
|
||||
urlPattern .value ($elem "pattern")
|
||||
language .value ($elem "lang")
|
||||
content (editor.getValue))]))
|
||||
content (editor.getValue))
|
||||
tabId
|
||||
]))
|
||||
(.addEventListener ($elem "launchBtn") "click"
|
||||
->e (let [interp (new KissWebPadInterp)]
|
||||
(dictSet interp.globals "document" document)
|
||||
|
||||
@@ -17,9 +17,11 @@ The WebPad contains an array of element objects:
|
||||
`(awaitLet [_padObj (API.browser.storage.sync.get (object webPad (new Array<Dynamic>)))
|
||||
&sync :Array<Dynamic> ,padSymbol (dictGet _padObj "webPad")]
|
||||
,@body
|
||||
(if ,change
|
||||
(API.browser.storage.sync.set (object webPad ,padSymbol))
|
||||
null)))
|
||||
,(if (eval change)
|
||||
`(awaitLet [_ (API.browser.storage.sync.set (object webPad ,padSymbol))]
|
||||
(catch [e] (sendMessage "alert" ["Error saving pad! $e"]) 0)
|
||||
0)
|
||||
`null)))
|
||||
|
||||
(function :Void find [:String url :Dynamic->Void resolve]
|
||||
(localVar &mut sent false)
|
||||
@@ -33,7 +35,7 @@ The WebPad contains an array of element objects:
|
||||
// Make new pad with exact current url as pattern
|
||||
(resolve (object id pad.length urlPattern url language "" content "")))))
|
||||
|
||||
(function :Null save [:Dynamic pad]
|
||||
(function :Null save [:Dynamic pad :(Dynamic,Array<Dynamic>)->Void sendMessage]
|
||||
(withWebPad true wholePad
|
||||
(if (= pad.id wholePad.length)
|
||||
(wholePad.push pad)
|
||||
|
||||
Reference in New Issue
Block a user