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...
pull/16/head
posativ 12 years ago
parent 261f2fe18e
commit 26c74cb521

@ -1,6 +1,6 @@
ISSO = "isso/js"
all: js
all: admin client
init:
git clone https://github.com/posativ/promisejs.git $(ISSO)/promise.js
@ -8,7 +8,14 @@ init:
(cd $(ISSO) && ender add 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
yuicompressor --type js --charset utf-8 $(ISSO)/_.js -o $(ISSO)/embed.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() {
$('div.buttons > a').forEach(function(item) {
var node = $(item).parent().parent().parent().parent()[0]
var path = node.getAttribute("data-path");
var id = node.getAttribute("data-id");
var node = $(item).parent().parent().parent().parent()[0],
id = node.getAttribute("data-id");
isso.path = node.getAttribute("data-path");
if (item.text == 'Approve') {
$(item).on('click', function(event) {
$.ajax('PUT', '/1.0/' + encodeURIComponent(path) + '/' + id + '/approve')
.then(function(status, rv) {
isso.approve(id, function(status, rv) {
$(node).prependTo($('#approved'));
$('.approve', node).remove();
});
});
event.stop();
});
} else {
$(item).on('click', function(event) {
if (confirm("RLY?") == true) {
$.ajax('DELETE', '/1.0/' + encodeURIComponent(path) + '/' + id)
.then(function() {
isso.remove(id, function(status, rv) {
$(node).remove()
});
};
};
event.stop();
});
};

@ -34,7 +34,7 @@ isso.create = function(data, func) {
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);
};
@ -44,16 +44,21 @@ isso.modify = function(id, data, func) {
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)
};
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) {
$.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"/>
<%block name="js">
<%include file="admin.js"/>
</%block>
<%
from time import strftime, gmtime

@ -2,11 +2,8 @@
<head>
<title><%block name="title" /></title>
<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" />
<script type="text/javascript" src="/js/interface.js"></script>
<style>
/* ================ */
@ -52,8 +49,6 @@
font-size: 1em;
line-height: 1.4;
margin: 20px 0 0 0;
background: url(/static/simple-clouds.jpg) no-repeat center center fixed;
}
body > h1 {
@ -65,7 +60,7 @@
article {
background-color: rgb(245, 245, 245);
box-shadow: 0px 0px 4px 0px;
border-radius: 2px;
/*border-radius: 2px;*/
}
article header {
@ -89,7 +84,7 @@
.recent, .pending {
padding: 10px 40px 10px 40px;
box-shadow: 0px 0px 2px 0px;
border-radius: 4px;
/*border-radius: 4px;*/
margin: 2px auto 2px auto;
}
@ -102,7 +97,7 @@
}
body > footer {
border-top: 1px solid #ccc;
border-top: 1px solid #AAA;
padding-top: 8px;
text-align: center;

@ -10,8 +10,7 @@
margin: 280px 270px 0 270px;
padding: 30px;
background-color: rgb(245, 245, 245);
box-shadow: 0px 0px 4px 0px;
border-radius: 8px;
box-shadow: 0px 0px 1px 0px;
text-align: center;
}

Loading…
Cancel
Save