mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-09-21 23:47:35 +03:00
get current collection out of url
This commit is contained in:
parent
55de688f3d
commit
88aba74503
@ -11,7 +11,9 @@
|
||||
;p: updated {<mod.conf.col>}
|
||||
::TODO public, visible
|
||||
::
|
||||
;h2: Topics:
|
||||
;* ?~ tops.col ~
|
||||
;= ;h2: Topics:
|
||||
==
|
||||
;ul
|
||||
;* %+ turn (sort ~(tap by tops.col) dor)
|
||||
|= [top=@da topicful]
|
||||
@ -27,9 +29,7 @@
|
||||
;form(onsubmit "return easy_form.submit(this)")
|
||||
;input(type "hidden", name "easy_form:mark", value "collections-action");
|
||||
;input(type "hidden", name "easy_form:tag", value "submit");
|
||||
::
|
||||
::FIXME we really want the filename here
|
||||
;input(type "hidden", name "col", value "{<mod.conf.col>}");
|
||||
;input(type "hidden", name "easy_form:url_end", value "collections/:col");
|
||||
::
|
||||
;input(name "tit", placeholder "Title");
|
||||
;br;
|
||||
@ -43,11 +43,9 @@
|
||||
;form(onsubmit "return easy_form.submit(this)")
|
||||
;input(type "hidden", name "easy_form:mark", value "collections-action");
|
||||
;input(type "hidden", name "easy_form:tag", value "delete");
|
||||
;input(type "hidden", name "easy_form:url_end", value "collections/:col");
|
||||
;input(type "hidden", name "easy_form:confirm");
|
||||
::
|
||||
::FIXME we really want the filename here
|
||||
;input(type "hidden", name "col", value "{<mod.conf.col>}");
|
||||
::
|
||||
;input.red(type "submit", value "Archive this collection");
|
||||
==
|
||||
==
|
||||
|
@ -1,19 +1,34 @@
|
||||
//REVIEW this feels too complicated
|
||||
let match_url_end = (pattern,out={})=> {
|
||||
if(!pattern) return out
|
||||
let here = document.location.pathname.split("/").reverse()
|
||||
while(!here[0]) here.shift()
|
||||
for(let segment of pattern.split("/").reverse()){
|
||||
let val = here.shift()
|
||||
if(segment[0] != ":") continue //REVIEW check for match?
|
||||
out[segment.slice(1)] = val
|
||||
}
|
||||
return out
|
||||
}
|
||||
//
|
||||
window.easy_form = {
|
||||
submit: (form)=> {
|
||||
const param = (key)=> {
|
||||
var x = form.elements[`easy_form:${key}`]
|
||||
return x && x.value
|
||||
}
|
||||
var mark = param("mark")
|
||||
let mark = param("mark")
|
||||
if(!mark) throw new TypeError("Need a mark")
|
||||
var appl = param("appl") || mark.match(/^[^-]*/)[0]
|
||||
var tag = param("tag")
|
||||
let appl = param("appl") || mark.match(/^[^-]*/)[0]
|
||||
let tag = param("tag")
|
||||
//
|
||||
if(param("confirm") != null && !confirm("Are you sure?"))
|
||||
return false
|
||||
//
|
||||
var req = {}
|
||||
for (var [k,v] of new FormData(form)){
|
||||
let req = {}
|
||||
req = match_url_end(param("url_end"),req)
|
||||
//
|
||||
for (let [k,v] of new FormData(form)){
|
||||
if(!/^easy_form:/.test(k)) {
|
||||
req[k] = v
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user