diff options
author | Allan Wang <me@allanwang.ca> | 2017-06-13 00:42:31 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-06-13 00:42:31 -0700 |
commit | e4377fed20ce1e3f4a0b236271eecdb1fe573b7a (patch) | |
tree | aa0b14e328daa4ece41f65cfed5a4422f2c9e898 /app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt | |
parent | a7a37f8f5b1955f006a83d4713a2c6af500c28af (diff) | |
download | frost-e4377fed20ce1e3f4a0b236271eecdb1fe573b7a.tar.gz frost-e4377fed20ce1e3f4a0b236271eecdb1fe573b7a.tar.bz2 frost-e4377fed20ce1e3f4a0b236271eecdb1fe573b7a.zip |
Created js base for facebook menu
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt new file mode 100644 index 00000000..2bf53d2e --- /dev/null +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt @@ -0,0 +1,32 @@ +package com.pitchedapps.frost.injectors + +import android.webkit.WebView +import com.pitchedapps.frost.utils.L + +/** + * Created by Allan Wang on 2017-05-31. + * Mapping of the available assets + * The enum name must match the css file name + * //TODO add folder mapping using Prefs + */ +enum class JsAssets { + MENU + ; + + var file = "${name.toLowerCase()}.min.js" + var injector: JsInjector? = null + + fun inject(webView: WebView, callback: ((String) -> Unit)?) { + if (injector == null) { + val content = webView.context.assets.open("js/$file").bufferedReader().use { it.readText() } + injector = JsBuilder().js(content).build() + } + injector!!.inject(webView, callback) + L.v("JS ${injector!!.function}") + } + + fun reset() { + injector = null + } + +}
\ No newline at end of file |