[cleanup] remove coffee script files
This commit is contained in:
parent
fee2a4f2c9
commit
574928e625
50 changed files with 0 additions and 4951 deletions
|
@ -1,132 +0,0 @@
|
|||
class PluginList extends Class
|
||||
constructor: (plugins) ->
|
||||
@plugins = plugins
|
||||
|
||||
savePluginStatus: (plugin, is_enabled) =>
|
||||
Page.cmd "pluginConfigSet", [plugin.source, plugin.inner_path, "enabled", is_enabled], (res) =>
|
||||
if res == "ok"
|
||||
Page.updatePlugins()
|
||||
else
|
||||
Page.cmd "wrapperNotification", ["error", res.error]
|
||||
|
||||
Page.projector.scheduleRender()
|
||||
|
||||
handleCheckboxChange: (e) =>
|
||||
node = e.currentTarget
|
||||
plugin = node["data-plugin"]
|
||||
node.classList.toggle("checked")
|
||||
value = node.classList.contains("checked")
|
||||
|
||||
@savePluginStatus(plugin, value)
|
||||
|
||||
handleResetClick: (e) =>
|
||||
node = e.currentTarget
|
||||
plugin = node["data-plugin"]
|
||||
|
||||
@savePluginStatus(plugin, null)
|
||||
|
||||
handleUpdateClick: (e) =>
|
||||
node = e.currentTarget
|
||||
plugin = node["data-plugin"]
|
||||
node.classList.add("loading")
|
||||
|
||||
Page.cmd "pluginUpdate", [plugin.source, plugin.inner_path], (res) =>
|
||||
if res == "ok"
|
||||
Page.cmd "wrapperNotification", ["done", "Plugin #{plugin.name} updated to latest version"]
|
||||
Page.updatePlugins()
|
||||
else
|
||||
Page.cmd "wrapperNotification", ["error", res.error]
|
||||
node.classList.remove("loading")
|
||||
|
||||
return false
|
||||
|
||||
handleDeleteClick: (e) =>
|
||||
node = e.currentTarget
|
||||
plugin = node["data-plugin"]
|
||||
if plugin.loaded
|
||||
Page.cmd "wrapperNotification", ["info", "You can only delete plugin that are not currently active"]
|
||||
return false
|
||||
|
||||
node.classList.add("loading")
|
||||
|
||||
Page.cmd "wrapperConfirm", ["Delete #{plugin.name} plugin?", "Delete"], (res) =>
|
||||
if not res
|
||||
node.classList.remove("loading")
|
||||
return false
|
||||
|
||||
Page.cmd "pluginRemove", [plugin.source, plugin.inner_path], (res) =>
|
||||
if res == "ok"
|
||||
Page.cmd "wrapperNotification", ["done", "Plugin #{plugin.name} deleted"]
|
||||
Page.updatePlugins()
|
||||
else
|
||||
Page.cmd "wrapperNotification", ["error", res.error]
|
||||
node.classList.remove("loading")
|
||||
|
||||
return false
|
||||
|
||||
render: ->
|
||||
h("div.plugins", @plugins.map (plugin) =>
|
||||
if not plugin.info
|
||||
return
|
||||
descr = plugin.info.description
|
||||
plugin.info.default ?= "enabled"
|
||||
if plugin.info.default
|
||||
descr += " (default: #{plugin.info.default})"
|
||||
|
||||
tag_version = ""
|
||||
tag_source = ""
|
||||
tag_delete = ""
|
||||
if plugin.source != "builtin"
|
||||
tag_update = ""
|
||||
if plugin.site_info?.rev
|
||||
if plugin.site_info.rev > plugin.info.rev
|
||||
tag_update = h("a.version-update.button",
|
||||
{href: "#Update+plugin", onclick: @handleUpdateClick, "data-plugin": plugin},
|
||||
"Update to rev#{plugin.site_info.rev}"
|
||||
)
|
||||
|
||||
else
|
||||
tag_update = h("span.version-missing", "(unable to get latest vesion: update site missing)")
|
||||
|
||||
tag_version = h("span.version",[
|
||||
"rev#{plugin.info.rev} ",
|
||||
tag_update,
|
||||
])
|
||||
|
||||
tag_source = h("div.source",[
|
||||
"Source: ",
|
||||
h("a", {"href": "/#{plugin.source}", "target": "_top"}, if plugin.site_title then plugin.site_title else plugin.source),
|
||||
" /" + plugin.inner_path
|
||||
])
|
||||
|
||||
tag_delete = h("a.delete", {"href": "#Delete+plugin", onclick: @handleDeleteClick, "data-plugin": plugin}, "Delete plugin")
|
||||
|
||||
|
||||
enabled_default = plugin.info.default == "enabled"
|
||||
if plugin.enabled != plugin.loaded or plugin.updated
|
||||
marker_title = "Change pending"
|
||||
is_pending = true
|
||||
else
|
||||
marker_title = "Changed from default status (click to reset to #{plugin.info.default})"
|
||||
is_pending = false
|
||||
|
||||
is_changed = plugin.enabled != enabled_default and plugin.owner == "builtin"
|
||||
|
||||
h("div.plugin", {key: plugin.name}, [
|
||||
h("div.title", [
|
||||
h("h3", [plugin.name, tag_version]),
|
||||
h("div.description", [descr, tag_source, tag_delete]),
|
||||
])
|
||||
h("div.value.value-right",
|
||||
h("div.checkbox", {onclick: @handleCheckboxChange, "data-plugin": plugin, classes: {checked: plugin.enabled}}, h("div.checkbox-skin"))
|
||||
h("a.marker", {
|
||||
href: "#Reset", title: marker_title,
|
||||
onclick: @handleResetClick, "data-plugin": plugin,
|
||||
classes: {visible: is_pending or is_changed, pending: is_pending}
|
||||
}, "\u2022")
|
||||
)
|
||||
])
|
||||
)
|
||||
|
||||
|
||||
window.PluginList = PluginList
|
|
@ -1,71 +0,0 @@
|
|||
window.h = maquette.h
|
||||
|
||||
class UiPluginManager extends ZeroFrame
|
||||
init: ->
|
||||
@plugin_list_builtin = new PluginList()
|
||||
@plugin_list_custom = new PluginList()
|
||||
@plugins_changed = null
|
||||
@need_restart = null
|
||||
@
|
||||
|
||||
onOpenWebsocket: =>
|
||||
@cmd("wrapperSetTitle", "Plugin manager - ZeroNet")
|
||||
@cmd "serverInfo", {}, (server_info) =>
|
||||
@server_info = server_info
|
||||
@updatePlugins()
|
||||
|
||||
updatePlugins: (cb) =>
|
||||
@cmd "pluginList", [], (res) =>
|
||||
@plugins_changed = (item for item in res.plugins when item.enabled != item.loaded or item.updated)
|
||||
|
||||
plugins_builtin = (item for item in res.plugins when item.source == "builtin")
|
||||
@plugin_list_builtin.plugins = plugins_builtin.sort (a, b) ->
|
||||
return a.name.localeCompare(b.name)
|
||||
|
||||
plugins_custom = (item for item in res.plugins when item.source != "builtin")
|
||||
@plugin_list_custom.plugins = plugins_custom.sort (a, b) ->
|
||||
return a.name.localeCompare(b.name)
|
||||
|
||||
@projector.scheduleRender()
|
||||
cb?()
|
||||
|
||||
createProjector: =>
|
||||
@projector = maquette.createProjector()
|
||||
@projector.replace($("#content"), @render)
|
||||
@projector.replace($("#bottom-restart"), @renderBottomRestart)
|
||||
|
||||
render: =>
|
||||
if not @plugin_list_builtin.plugins
|
||||
return h("div.content")
|
||||
|
||||
h("div.content", [
|
||||
h("div.section", [
|
||||
if @plugin_list_custom.plugins?.length
|
||||
[
|
||||
h("h2", "Installed third-party plugins"),
|
||||
@plugin_list_custom.render()
|
||||
]
|
||||
h("h2", "Built-in plugins")
|
||||
@plugin_list_builtin.render()
|
||||
])
|
||||
])
|
||||
|
||||
handleRestartClick: =>
|
||||
@restart_loading = true
|
||||
setTimeout ( =>
|
||||
Page.cmd("serverShutdown", {restart: true})
|
||||
), 300
|
||||
Page.projector.scheduleRender()
|
||||
return false
|
||||
|
||||
renderBottomRestart: =>
|
||||
h("div.bottom.bottom-restart", {classes: {visible: @plugins_changed?.length}}, h("div.bottom-content", [
|
||||
h("div.title", "Some plugins status has been changed"),
|
||||
h("a.button.button-submit.button-restart",
|
||||
{href: "#Restart", classes: {loading: @restart_loading}, onclick: @handleRestartClick},
|
||||
"Restart ZeroNet client"
|
||||
)
|
||||
]))
|
||||
|
||||
window.Page = new UiPluginManager()
|
||||
window.Page.createProjector()
|
|
@ -1,23 +0,0 @@
|
|||
class Class
|
||||
trace: true
|
||||
|
||||
log: (args...) ->
|
||||
return unless @trace
|
||||
return if typeof console is 'undefined'
|
||||
args.unshift("[#{@.constructor.name}]")
|
||||
console.log(args...)
|
||||
@
|
||||
|
||||
logStart: (name, args...) ->
|
||||
return unless @trace
|
||||
@logtimers or= {}
|
||||
@logtimers[name] = +(new Date)
|
||||
@log "#{name}", args..., "(started)" if args.length > 0
|
||||
@
|
||||
|
||||
logEnd: (name, args...) ->
|
||||
ms = +(new Date)-@logtimers[name]
|
||||
@log "#{name}", args..., "(Done in #{ms}ms)"
|
||||
@
|
||||
|
||||
window.Class = Class
|
|
@ -1,74 +0,0 @@
|
|||
# From: http://dev.bizo.com/2011/12/promises-in-javascriptcoffeescript.html
|
||||
|
||||
class Promise
|
||||
@when: (tasks...) ->
|
||||
num_uncompleted = tasks.length
|
||||
args = new Array(num_uncompleted)
|
||||
promise = new Promise()
|
||||
|
||||
for task, task_id in tasks
|
||||
((task_id) ->
|
||||
task.then(() ->
|
||||
args[task_id] = Array.prototype.slice.call(arguments)
|
||||
num_uncompleted--
|
||||
promise.complete.apply(promise, args) if num_uncompleted == 0
|
||||
)
|
||||
)(task_id)
|
||||
|
||||
return promise
|
||||
|
||||
constructor: ->
|
||||
@resolved = false
|
||||
@end_promise = null
|
||||
@result = null
|
||||
@callbacks = []
|
||||
|
||||
resolve: ->
|
||||
if @resolved
|
||||
return false
|
||||
@resolved = true
|
||||
@data = arguments
|
||||
if not arguments.length
|
||||
@data = [true]
|
||||
@result = @data[0]
|
||||
for callback in @callbacks
|
||||
back = callback.apply callback, @data
|
||||
if @end_promise
|
||||
@end_promise.resolve(back)
|
||||
|
||||
fail: ->
|
||||
@resolve(false)
|
||||
|
||||
then: (callback) ->
|
||||
if @resolved == true
|
||||
callback.apply callback, @data
|
||||
return
|
||||
|
||||
@callbacks.push callback
|
||||
|
||||
@end_promise = new Promise()
|
||||
|
||||
window.Promise = Promise
|
||||
|
||||
###
|
||||
s = Date.now()
|
||||
log = (text) ->
|
||||
console.log Date.now()-s, Array.prototype.slice.call(arguments).join(", ")
|
||||
|
||||
log "Started"
|
||||
|
||||
cmd = (query) ->
|
||||
p = new Promise()
|
||||
setTimeout ( ->
|
||||
p.resolve query+" Result"
|
||||
), 100
|
||||
return p
|
||||
|
||||
back = cmd("SELECT * FROM message").then (res) ->
|
||||
log res
|
||||
return "Return from query"
|
||||
.then (res) ->
|
||||
log "Back then", res
|
||||
|
||||
log "Query started", back
|
||||
###
|
|
@ -1,8 +0,0 @@
|
|||
String::startsWith = (s) -> @[...s.length] is s
|
||||
String::endsWith = (s) -> s is '' or @[-s.length..] is s
|
||||
String::repeat = (count) -> new Array( count + 1 ).join(@)
|
||||
|
||||
window.isEmpty = (obj) ->
|
||||
for key of obj
|
||||
return false
|
||||
return true
|
|
@ -1,138 +0,0 @@
|
|||
class Animation
|
||||
slideDown: (elem, props) ->
|
||||
if elem.offsetTop > 2000
|
||||
return
|
||||
|
||||
h = elem.offsetHeight
|
||||
cstyle = window.getComputedStyle(elem)
|
||||
margin_top = cstyle.marginTop
|
||||
margin_bottom = cstyle.marginBottom
|
||||
padding_top = cstyle.paddingTop
|
||||
padding_bottom = cstyle.paddingBottom
|
||||
transition = cstyle.transition
|
||||
|
||||
elem.style.boxSizing = "border-box"
|
||||
elem.style.overflow = "hidden"
|
||||
elem.style.transform = "scale(0.6)"
|
||||
elem.style.opacity = "0"
|
||||
elem.style.height = "0px"
|
||||
elem.style.marginTop = "0px"
|
||||
elem.style.marginBottom = "0px"
|
||||
elem.style.paddingTop = "0px"
|
||||
elem.style.paddingBottom = "0px"
|
||||
elem.style.transition = "none"
|
||||
|
||||
setTimeout (->
|
||||
elem.className += " animate-inout"
|
||||
elem.style.height = h+"px"
|
||||
elem.style.transform = "scale(1)"
|
||||
elem.style.opacity = "1"
|
||||
elem.style.marginTop = margin_top
|
||||
elem.style.marginBottom = margin_bottom
|
||||
elem.style.paddingTop = padding_top
|
||||
elem.style.paddingBottom = padding_bottom
|
||||
), 1
|
||||
|
||||
elem.addEventListener "transitionend", ->
|
||||
elem.classList.remove("animate-inout")
|
||||
elem.style.transition = elem.style.transform = elem.style.opacity = elem.style.height = null
|
||||
elem.style.boxSizing = elem.style.marginTop = elem.style.marginBottom = null
|
||||
elem.style.paddingTop = elem.style.paddingBottom = elem.style.overflow = null
|
||||
elem.removeEventListener "transitionend", arguments.callee, false
|
||||
|
||||
|
||||
slideUp: (elem, remove_func, props) ->
|
||||
if elem.offsetTop > 1000
|
||||
return remove_func()
|
||||
|
||||
elem.className += " animate-back"
|
||||
elem.style.boxSizing = "border-box"
|
||||
elem.style.height = elem.offsetHeight+"px"
|
||||
elem.style.overflow = "hidden"
|
||||
elem.style.transform = "scale(1)"
|
||||
elem.style.opacity = "1"
|
||||
elem.style.pointerEvents = "none"
|
||||
setTimeout (->
|
||||
elem.style.height = "0px"
|
||||
elem.style.marginTop = "0px"
|
||||
elem.style.marginBottom = "0px"
|
||||
elem.style.paddingTop = "0px"
|
||||
elem.style.paddingBottom = "0px"
|
||||
elem.style.transform = "scale(0.8)"
|
||||
elem.style.borderTopWidth = "0px"
|
||||
elem.style.borderBottomWidth = "0px"
|
||||
elem.style.opacity = "0"
|
||||
), 1
|
||||
elem.addEventListener "transitionend", (e) ->
|
||||
if e.propertyName == "opacity" or e.elapsedTime >= 0.6
|
||||
elem.removeEventListener "transitionend", arguments.callee, false
|
||||
remove_func()
|
||||
|
||||
|
||||
slideUpInout: (elem, remove_func, props) ->
|
||||
elem.className += " animate-inout"
|
||||
elem.style.boxSizing = "border-box"
|
||||
elem.style.height = elem.offsetHeight+"px"
|
||||
elem.style.overflow = "hidden"
|
||||
elem.style.transform = "scale(1)"
|
||||
elem.style.opacity = "1"
|
||||
elem.style.pointerEvents = "none"
|
||||
setTimeout (->
|
||||
elem.style.height = "0px"
|
||||
elem.style.marginTop = "0px"
|
||||
elem.style.marginBottom = "0px"
|
||||
elem.style.paddingTop = "0px"
|
||||
elem.style.paddingBottom = "0px"
|
||||
elem.style.transform = "scale(0.8)"
|
||||
elem.style.borderTopWidth = "0px"
|
||||
elem.style.borderBottomWidth = "0px"
|
||||
elem.style.opacity = "0"
|
||||
), 1
|
||||
elem.addEventListener "transitionend", (e) ->
|
||||
if e.propertyName == "opacity" or e.elapsedTime >= 0.6
|
||||
elem.removeEventListener "transitionend", arguments.callee, false
|
||||
remove_func()
|
||||
|
||||
|
||||
showRight: (elem, props) ->
|
||||
elem.className += " animate"
|
||||
elem.style.opacity = 0
|
||||
elem.style.transform = "TranslateX(-20px) Scale(1.01)"
|
||||
setTimeout (->
|
||||
elem.style.opacity = 1
|
||||
elem.style.transform = "TranslateX(0px) Scale(1)"
|
||||
), 1
|
||||
elem.addEventListener "transitionend", ->
|
||||
elem.classList.remove("animate")
|
||||
elem.style.transform = elem.style.opacity = null
|
||||
|
||||
|
||||
show: (elem, props) ->
|
||||
delay = arguments[arguments.length-2]?.delay*1000 or 1
|
||||
elem.style.opacity = 0
|
||||
setTimeout (->
|
||||
elem.className += " animate"
|
||||
), 1
|
||||
setTimeout (->
|
||||
elem.style.opacity = 1
|
||||
), delay
|
||||
elem.addEventListener "transitionend", ->
|
||||
elem.classList.remove("animate")
|
||||
elem.style.opacity = null
|
||||
elem.removeEventListener "transitionend", arguments.callee, false
|
||||
|
||||
hide: (elem, remove_func, props) ->
|
||||
delay = arguments[arguments.length-2]?.delay*1000 or 1
|
||||
elem.className += " animate"
|
||||
setTimeout (->
|
||||
elem.style.opacity = 0
|
||||
), delay
|
||||
elem.addEventListener "transitionend", (e) ->
|
||||
if e.propertyName == "opacity"
|
||||
remove_func()
|
||||
|
||||
addVisibleClass: (elem, props) ->
|
||||
setTimeout ->
|
||||
elem.classList.add("visible")
|
||||
|
||||
window.Animation = new Animation()
|
|
@ -1,3 +0,0 @@
|
|||
window.$ = (selector) ->
|
||||
if selector.startsWith("#")
|
||||
return document.getElementById(selector.replace("#", ""))
|
|
@ -1,85 +0,0 @@
|
|||
class ZeroFrame extends Class
|
||||
constructor: (url) ->
|
||||
@url = url
|
||||
@waiting_cb = {}
|
||||
@wrapper_nonce = document.location.href.replace(/.*wrapper_nonce=([A-Za-z0-9]+).*/, "$1")
|
||||
@connect()
|
||||
@next_message_id = 1
|
||||
@history_state = {}
|
||||
@init()
|
||||
|
||||
|
||||
init: ->
|
||||
@
|
||||
|
||||
|
||||
connect: ->
|
||||
@target = window.parent
|
||||
window.addEventListener("message", @onMessage, false)
|
||||
@cmd("innerReady")
|
||||
|
||||
# Save scrollTop
|
||||
window.addEventListener "beforeunload", (e) =>
|
||||
@log "save scrollTop", window.pageYOffset
|
||||
@history_state["scrollTop"] = window.pageYOffset
|
||||
@cmd "wrapperReplaceState", [@history_state, null]
|
||||
|
||||
# Restore scrollTop
|
||||
@cmd "wrapperGetState", [], (state) =>
|
||||
@history_state = state if state?
|
||||
@log "restore scrollTop", state, window.pageYOffset
|
||||
if window.pageYOffset == 0 and state
|
||||
window.scroll(window.pageXOffset, state.scrollTop)
|
||||
|
||||
|
||||
onMessage: (e) =>
|
||||
message = e.data
|
||||
cmd = message.cmd
|
||||
if cmd == "response"
|
||||
if @waiting_cb[message.to]?
|
||||
@waiting_cb[message.to](message.result)
|
||||
else
|
||||
@log "Websocket callback not found:", message
|
||||
else if cmd == "wrapperReady" # Wrapper inited later
|
||||
@cmd("innerReady")
|
||||
else if cmd == "ping"
|
||||
@response message.id, "pong"
|
||||
else if cmd == "wrapperOpenedWebsocket"
|
||||
@onOpenWebsocket()
|
||||
else if cmd == "wrapperClosedWebsocket"
|
||||
@onCloseWebsocket()
|
||||
else
|
||||
@onRequest cmd, message.params
|
||||
|
||||
|
||||
onRequest: (cmd, message) =>
|
||||
@log "Unknown request", message
|
||||
|
||||
|
||||
response: (to, result) ->
|
||||
@send {"cmd": "response", "to": to, "result": result}
|
||||
|
||||
|
||||
cmd: (cmd, params={}, cb=null) ->
|
||||
@send {"cmd": cmd, "params": params}, cb
|
||||
|
||||
|
||||
send: (message, cb=null) ->
|
||||
message.wrapper_nonce = @wrapper_nonce
|
||||
message.id = @next_message_id
|
||||
@next_message_id += 1
|
||||
@target.postMessage(message, "*")
|
||||
if cb
|
||||
@waiting_cb[message.id] = cb
|
||||
|
||||
|
||||
onOpenWebsocket: =>
|
||||
@log "Websocket open"
|
||||
|
||||
|
||||
onCloseWebsocket: =>
|
||||
@log "Websocket close"
|
||||
|
||||
|
||||
|
||||
window.ZeroFrame = ZeroFrame
|
Loading…
Add table
Add a link
Reference in a new issue