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