admin.js now used isso.js as API
JS is a horrible language. The more you try to modularize and DRY it, the greater the LoC grows...
This commit is contained in:
parent
261f2fe18e
commit
26c74cb521
11
Makefile
11
Makefile
@ -1,6 +1,6 @@
|
|||||||
ISSO = "isso/js"
|
ISSO = "isso/js"
|
||||||
|
|
||||||
all: js
|
all: admin client
|
||||||
|
|
||||||
init:
|
init:
|
||||||
git clone https://github.com/posativ/promisejs.git $(ISSO)/promise.js
|
git clone https://github.com/posativ/promisejs.git $(ISSO)/promise.js
|
||||||
@ -8,7 +8,14 @@ init:
|
|||||||
(cd $(ISSO) && ender add promise.js)
|
(cd $(ISSO) && ender add promise.js)
|
||||||
rm -rf $(ISSO)/promise.js
|
rm -rf $(ISSO)/promise.js
|
||||||
|
|
||||||
js:
|
admin:
|
||||||
|
cat $(ISSO)/ender.js $(ISSO)/isso.js $(ISSO)/utils.js $(ISSO)/admin.js > $(ISSO)/_.js
|
||||||
|
yuicompressor --type js --charset utf-8 $(ISSO)/_.js -o $(ISSO)/interface.js
|
||||||
|
|
||||||
|
rm $(ISSO)/_.js
|
||||||
|
|
||||||
|
client:
|
||||||
cat $(ISSO)/ender.js $(ISSO)/isso.js $(ISSO)/utils.js $(ISSO)/client.js > $(ISSO)/_.js
|
cat $(ISSO)/ender.js $(ISSO)/isso.js $(ISSO)/utils.js $(ISSO)/client.js > $(ISSO)/_.js
|
||||||
yuicompressor --type js --charset utf-8 $(ISSO)/_.js -o $(ISSO)/embed.js
|
yuicompressor --type js --charset utf-8 $(ISSO)/_.js -o $(ISSO)/embed.js
|
||||||
|
|
||||||
rm $(ISSO)/_.js
|
rm $(ISSO)/_.js
|
||||||
|
@ -1,29 +1,34 @@
|
|||||||
|
/* Copyright 2012, Martin Zimmermann <info@posativ.org>. All rights reserved.
|
||||||
|
* License: BSD Style, 2 clauses. See isso/__init__.py.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
var isso = isso || {};
|
||||||
|
|
||||||
|
|
||||||
function initialize() {
|
function initialize() {
|
||||||
|
|
||||||
$('div.buttons > a').forEach(function(item) {
|
$('div.buttons > a').forEach(function(item) {
|
||||||
|
|
||||||
var node = $(item).parent().parent().parent().parent()[0]
|
var node = $(item).parent().parent().parent().parent()[0],
|
||||||
var path = node.getAttribute("data-path");
|
id = node.getAttribute("data-id");
|
||||||
var id = node.getAttribute("data-id");
|
isso.path = node.getAttribute("data-path");
|
||||||
|
|
||||||
if (item.text == 'Approve') {
|
if (item.text == 'Approve') {
|
||||||
$(item).on('click', function(event) {
|
$(item).on('click', function(event) {
|
||||||
$.ajax('PUT', '/1.0/' + encodeURIComponent(path) + '/' + id + '/approve')
|
isso.approve(id, function(status, rv) {
|
||||||
.then(function(status, rv) {
|
|
||||||
$(node).prependTo($('#approved'));
|
$(node).prependTo($('#approved'));
|
||||||
$('.approve', node).remove();
|
$('.approve', node).remove();
|
||||||
});
|
});
|
||||||
event.stop();
|
event.stop();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$(item).on('click', function(event) {
|
$(item).on('click', function(event) {
|
||||||
if (confirm("RLY?") == true) {
|
if (confirm("RLY?") == true) {
|
||||||
$.ajax('DELETE', '/1.0/' + encodeURIComponent(path) + '/' + id)
|
isso.remove(id, function(status, rv) {
|
||||||
.then(function() {
|
|
||||||
$(node).remove()
|
$(node).remove()
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
event.stop();
|
event.stop();
|
||||||
});
|
});
|
||||||
};
|
};
|
@ -34,7 +34,7 @@ isso.create = function(data, func) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajax('POST', prefix + '/1.0/' + path + '/new',
|
$.ajax('POST', prefix + '/1.0/' + isso.path + '/new',
|
||||||
JSON.stringify(data), {'Content-Type': 'application/json'}).then(func);
|
JSON.stringify(data), {'Content-Type': 'application/json'}).then(func);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -44,16 +44,21 @@ isso.modify = function(id, data, func) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajax('PUT', prefix + '/1.0/' + path + '/' + id,
|
$.ajax('PUT', prefix + '/1.0/' + isso.path + '/' + id,
|
||||||
JSON.stringify(data), {'Content-Type': 'application/json'}).then(func)
|
JSON.stringify(data), {'Content-Type': 'application/json'}).then(func)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
isso.plain = function(id, func) {
|
isso.plain = function(id, func) {
|
||||||
$.ajax('GET', prefix + '/1.0/' + path + '/' + id, {'plain': '1'}).then(func);
|
$.ajax('GET', prefix + '/1.0/' + isso.path + '/' + id, {'plain': '1'}).then(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
isso.remove = function(id, func) {
|
isso.remove = function(id, func) {
|
||||||
$.ajax('DELETE', prefix + '/1.0/' + path + '/' + id).then(func);
|
$.ajax('DELETE', prefix + '/1.0/' + isso.path + '/' + id).then(func);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
isso.approve = function (id, func) {
|
||||||
|
$.ajax('PUT', '/1.0/' + isso.path + '/' + id + '/approve').then(func)
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
<%inherit file="base.mako"/>
|
<%inherit file="base.mako"/>
|
||||||
|
|
||||||
<%block name="js">
|
|
||||||
<%include file="admin.js"/>
|
|
||||||
</%block>
|
|
||||||
|
|
||||||
<%
|
<%
|
||||||
from time import strftime, gmtime
|
from time import strftime, gmtime
|
||||||
|
|
||||||
|
@ -2,11 +2,8 @@
|
|||||||
<head>
|
<head>
|
||||||
<title><%block name="title" /></title>
|
<title><%block name="title" /></title>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<script type="text/javascript" src="/js/ender.js"></script>
|
|
||||||
<script type="text/javascript">
|
|
||||||
<%block name="js" />
|
|
||||||
</script>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/static/style.css" />
|
<link rel="stylesheet" type="text/css" href="/static/style.css" />
|
||||||
|
<script type="text/javascript" src="/js/interface.js"></script>
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
/* ================ */
|
/* ================ */
|
||||||
@ -52,8 +49,6 @@
|
|||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
margin: 20px 0 0 0;
|
margin: 20px 0 0 0;
|
||||||
|
|
||||||
background: url(/static/simple-clouds.jpg) no-repeat center center fixed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
body > h1 {
|
body > h1 {
|
||||||
@ -65,7 +60,7 @@
|
|||||||
article {
|
article {
|
||||||
background-color: rgb(245, 245, 245);
|
background-color: rgb(245, 245, 245);
|
||||||
box-shadow: 0px 0px 4px 0px;
|
box-shadow: 0px 0px 4px 0px;
|
||||||
border-radius: 2px;
|
/*border-radius: 2px;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
article header {
|
article header {
|
||||||
@ -89,7 +84,7 @@
|
|||||||
.recent, .pending {
|
.recent, .pending {
|
||||||
padding: 10px 40px 10px 40px;
|
padding: 10px 40px 10px 40px;
|
||||||
box-shadow: 0px 0px 2px 0px;
|
box-shadow: 0px 0px 2px 0px;
|
||||||
border-radius: 4px;
|
/*border-radius: 4px;*/
|
||||||
margin: 2px auto 2px auto;
|
margin: 2px auto 2px auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +97,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
body > footer {
|
body > footer {
|
||||||
border-top: 1px solid #ccc;
|
border-top: 1px solid #AAA;
|
||||||
padding-top: 8px;
|
padding-top: 8px;
|
||||||
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
@ -10,8 +10,7 @@
|
|||||||
margin: 280px 270px 0 270px;
|
margin: 280px 270px 0 270px;
|
||||||
padding: 30px;
|
padding: 30px;
|
||||||
background-color: rgb(245, 245, 245);
|
background-color: rgb(245, 245, 245);
|
||||||
box-shadow: 0px 0px 4px 0px;
|
box-shadow: 0px 0px 1px 0px;
|
||||||
border-radius: 8px;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user