| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457 |
- file_parameter = {
- first : '(0)',
- last : '(0)',
- count : 20
- };
- function file_get_init() {
- $('#content').html('');
- $('#result').html('');
- var str = '<table border="1" width="100%">';
- str += '<tr><td colspan="2"><a href="#" id="get">get</a></td></tr>';
- str += '<tr><td>id:</td><td><input type="text" style="width:95%" id="id"></td></tr>';
- str += '</table>';
- $('#content').html(str);
- $('#get').click(function() {
- file_get($('#id').val());
- });
- }
- function file_get(id) {
- $('#result').html('');
- $.ajax({
- type : 'get',
- dataType : 'json',
- url : '../jaxrs/file/' + id,
- contentType : 'application/json; charset=utf-8',
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
- function file_list_referenceType() {
- $('#content').html('');
- $('#result').html('');
- $.ajax({
- type : 'get',
- dataType : 'json',
- url : '../jaxrs/file/list/referencetype',
- contentType : 'application/json; charset=utf-8',
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
- function file_list_next(id) {
- var id = (id ? id : file_parameter.last);
- $.ajax({
- type : 'get',
- dataType : 'json',
- url : '../jaxrs/file/list/' + id + '/next/' + file_parameter.count,
- contentType : 'application/json; charset=utf-8',
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).done(function(json) {
- if (json.type == 'success') {
- if (json.data.length > 0) {
- file_parameter.first = json.data[0].id;
- file_parameter.last = json.data[json.data.length - 1].id;
- } else {
- file_parameter.first = '(0)';
- }
- file_list_grid(json);
- }
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
- function file_list_prev(id) {
- var id = (id ? id : file_parameter.first);
- $.ajax({
- type : 'get',
- dataType : 'json',
- url : '../jaxrs/file/list/' + id + '/prev/' + file_parameter.count,
- contentType : 'application/json; charset=utf-8',
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).done(function(json) {
- if (json.type == 'success') {
- if (json.data.length > 0) {
- file_parameter.first = json.data[0].id;
- file_parameter.last = json.data[json.data.length - 1].id;
- } else {
- file_parameter.last = '(0)';
- }
- file_list_grid(json);
- }
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
- function file_list_grid(json) {
- var str = '<table border="1" width="100%">';
- str += '<tr><td colspan="5"> <a href="#" id="prev">prev</a> <a href="#" id="next">next</a> <span id="total">' + json.count + '</span></td></tr>';
- str += '<tr><th>id</th><th>name</th><th>person</th><th>referenceType</th><th>reference</th></tr>';
- if (json.data) {
- $.each(json.data, function(index, item) {
- str += '<tr>';
- str += '<td>' + item.id + '</td>';
- str += '<td>' + item.name + '</td>';
- str += '<td>' + item.person + '</td>';
- str += '<td>' + item.referenceType + '</td>';
- str += '<td>' + item.reference + '</td>';
- str += '</tr>';
- });
- }
- str += '</table>';
- $('#content').html(str);
- $('#next').click(function() {
- file_list_next();
- });
- $('#prev').click(function() {
- file_list_prev();
- });
- }
- function file_list_next_all(id) {
- var id = (id ? id : file_parameter.last);
- $.ajax({
- type : 'get',
- dataType : 'json',
- url : '../jaxrs/file/list/' + id + '/next/' + file_parameter.count + '/all',
- contentType : 'application/json; charset=utf-8',
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).done(function(json) {
- if (json.type == 'success') {
- if (json.data.length > 0) {
- file_parameter.first = json.data[0].id;
- file_parameter.last = json.data[json.data.length - 1].id;
- } else {
- file_parameter.first = '(0)';
- }
- file_list_all_grid(json);
- }
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
- function file_list_prev_all(id) {
- var id = (id ? id : file_parameter.first);
- $.ajax({
- type : 'get',
- dataType : 'json',
- url : '../jaxrs/file/list/' + id + '/prev/' + file_parameter.count + '/all',
- contentType : 'application/json; charset=utf-8',
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).done(function(json) {
- if (json.type == 'success') {
- if (json.data.length > 0) {
- file_parameter.first = json.data[0].id;
- file_parameter.last = json.data[json.data.length - 1].id;
- } else {
- file_parameter.last = '(0)';
- }
- file_list_all_grid(json);
- }
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
- function file_list_all_grid(json) {
- var str = '<table border="1" width="100%">';
- str += '<tr><td colspan="5"> <a href="#" id="prev">prev</a> <a href="#" id="next">next</a> <span id="total">' + json.count + '</span></td></tr>';
- str += '<tr><th>id</th><th>name</th><th>person</th><th>referenceType</th><th>reference</th></tr>';
- if (json.data) {
- $.each(json.data, function(index, item) {
- str += '<tr>';
- str += '<td>' + item.id + '</td>';
- str += '<td>' + item.name + '</td>';
- str += '<td>' + item.person + '</td>';
- str += '<td>' + item.referenceType + '</td>';
- str += '<td>' + item.reference + '</td>';
- str += '</tr>';
- });
- }
- str += '</table>';
- $('#content').html(str);
- $('#next').click(function() {
- file_list_next_all();
- });
- $('#prev').click(function() {
- file_list_prev_all();
- });
- }
- function file_list_withReferenceTypeWithReference_init() {
- $('#content').html('');
- $('#result').html('');
- var str = '<table border="1" width="100%">';
- str += '<thead>';
- str += '<tr><td colspan="5"><a href="#" id="list">list</a></td></tr>';
- str += '<tr><td>referenceType:</td><td colspan="4"><input type="text" style="width:95%" id="referenceType"></td></tr>';
- str += '<tr><td>reference:</td><td colspan="4"><input type="text" style="width:95%" id="referenceType"></td></tr>';
- str += '<tr><th>id</th><th>name</th><th>person</th><th>referenceType</th><th>reference</th></tr>';
- str += '</thead><tbody id="grid"></tbody>';
- str += '</table>';
- $('#content').html(str);
- $('#list').click(function() {
- file_list_withReferenceTypeWithReference();
- });
- }
- function file_list_withReferenceTypeWithReference(referenceType, reference) {
- $('#grid').html('');
- $.ajax({
- type : 'get',
- dataType : 'json',
- url : '../jaxrs/file/list/referencetype/' + referenceType + '/reference/' + reference,
- contentType : 'application/json; charset=utf-8',
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).done(function(json) {
- if (json.type == 'success') {
- if (json.data) {
- var str = '';
- $.each(json.data, function(index, item) {
- str += '<tr>';
- str += '<td>' + item.person + '</td>';
- str += '<td>' + item.id + '</td>';
- str += '<td>' + item.name + '</td>';
- str += '<td>' + item.referenceType + '</td>';
- str += '<td>' + item.reference + '</td>';
- str += '</tr>';
- });
- $('#total').html(json.count);
- $('#grid').html(str);
- }
- }
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
- function file_list_withReferenceType_init() {
- $('#content').html('');
- $('#result').html('');
- file_parameter.first = '(0)';
- file_parameter.last = '(0)';
- var str = '<table border="1" width="100%">';
- str += '<thead>';
- str += '<tr><td colspan="5"><a href="#" id="prev">prev</a> <a href="#" id="next">next</a> <span id="total">0</span></td></tr>';
- str += '<tr><td>referenceType:</td><td colspan="4"><input type="text" style="width:95%" id="referenceType"></td></tr>';
- str += '<tr><th>id</th><th>name</th><th>person</th><th>referenceType</th><th>reference</th></tr>';
- str += '</thead><tbody id="grid"></tbody>';
- str += '</table>';
- $('#content').html(str);
- $('#next').click(function() {
- file_list_next_withReferenceType();
- });
- $('#prev').click(function() {
- file_list_prev_withReferenceType();
- });
- }
- function file_list_next_withReferenceType(id) {
- var id = (id ? id : file_parameter.last);
- $.ajax({
- type : 'get',
- dataType : 'json',
- url : '../jaxrs/file/list/' + id + '/next/' + file_parameter.count + '/referencetype/' + $('#referenceType').val(),
- contentType : 'application/json; charset=utf-8',
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).done(function(json) {
- if (json.type == 'success') {
- if (json.data.length > 0) {
- file_parameter.first = json.data[0].id;
- file_parameter.last = json.data[json.data.length - 1].id;
- } else {
- file_parameter.first = '(0)';
- }
- file_list_withReference_grid(json);
- }
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
- function file_list_prev_withReferenceType(id) {
- var id = (id ? id : file_parameter.first);
- $.ajax({
- type : 'get',
- dataType : 'json',
- url : '../jaxrs/file/list/' + id + '/prev/' + file_parameter.count + '/referencetype/' + $('#referenceType').val(),
- contentType : 'application/json; charset=utf-8',
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).done(function(json) {
- if (json.type == 'success') {
- if (json.data.length > 0) {
- file_parameter.first = json.data[0].id;
- file_parameter.last = json.data[json.data.length - 1].id;
- } else {
- file_parameter.last = '(0)';
- }
- file_list_withReference_grid(json);
- }
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
- function file_list_withReference_grid(json) {
- if (json.data) {
- var str = '';
- $.each(json.data, function(index, item) {
- str += '<tr>';
- str += '<td>' + item.person + '</td>';
- str += '<td>' + item.id + '</td>';
- str += '<td>' + item.name + '</td>';
- str += '<td>' + item.referenceType + '</td>';
- str += '<td>' + item.reference + '</td>';
- str += '</tr>';
- });
- $('#total').html(json.count);
- $('#grid').html(str);
- }
- }
- function file_upload_init() {
- $('#content').html('');
- $('#result').html('');
- var str = '<table border="1" width="100%">';
- str += '<tr><td colspan="2"><a href="#" id="post">post</a></td></tr>';
- str += '<tr><td>referenceType:</td><td><input type="text" style="width:95%" id= "referenceType"/></td></tr>';
- str += '<tr><td>reference:</td><td><input type="text" style="width:95%" id= "reference"/></td></tr>';
- str += '<tr><td>scale:</td><td><input type="text" value="200" style="width:95%" id= "scale"/></td></tr>';
- str += '<tr><td>file:</td><td><form><input type="file" name="file" style="width:95%" id= "file"/></form></td></tr>';
- str += '</table>';
- $('#content').html(str);
- $('#post').click(function() {
- file_upload($('#referenceType').val(), $('#reference').val(), $('#scale').val());
- });
- }
- function file_upload(referenceType, reference, scale) {
- var formData = new FormData($('form')[0]);
- $.ajax({
- type : 'post',
- dataType : 'json',
- url : '../servlet/file/upload/referencetype/' + referenceType + '/reference/' + reference + '/scale/' + scale,
- data : formData,
- contentType : false,
- cache : false,
- processData : false,
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).success(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
- function file_download_init() {
- $('#content').html('');
- $('#result').html('');
- var str = '<table border="1" width="100%">';
- str += '<tr><td colspan="2"><a href="#" id="get">get</a></td></tr>';
- str += '<tr><td>id:</td><td><input type="text" style="width:95%" id= "id"/></td></tr>';
- str += '</table>';
- $('#content').html(str);
- $('#get').click(function() {
- file_download($('#id').val());
- });
- }
- function file_download(id) {
- window.open('../servlet/file/download/' + id, '_blank');
- }
- function file_copy_init() {
- $('#content').html('');
- $('#result').html('');
- var str = '<table border="1" width="100%">';
- str += '<tr><td colspan="2"><a href="#" id="get">get</a></td></tr>';
- str += '<tr><td>attachmentId:</td><td><input type="text" style="width:95%" id= "attachmentId"/</td></tr>';
- str += '<tr><td>referenceType:</td><td><input type="text" style="width:95%" id= "referenceType"/></td></tr>';
- str += '<tr><td>reference:</td><td><input type="text" style="width:95%" id= "reference"/></td></tr>';
- str += '<tr><td>scale:</td><td><input type="text" value="200" style="width:95%" id= "scale"/></td></tr>';
- str += '</table>';
- $('#content').html(str);
- $('#get').click(function() {
- file_copy($('#attachmentId').val(), $('#referenceType').val(), $('#reference').val(), $('#scale').val());
- });
- }
- function file_copy(attachmentId, referenceType, reference, scale) {
- $.ajax({
- type : 'get',
- dataType : 'json',
- url : '../jaxrs/file/copy/attachment/' + attachmentId + '/referencetype/' + referenceType + '/reference/' + reference + '/scale/' + scale,
- contentType : 'application/json; charset=utf-8',
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
- function file_delete_init() {
- $('#content').html('');
- $('#result').html('');
- var str = '<table border="1" width="100%">';
- str += '<tr><td colspan="2"><a href="#" id="delete">delete</a></td></tr>';
- str += '<tr><td>referenceType:</td><td><input type="text" style="width:95%" id= "referenceType"/></td></tr>';
- str += '<tr><td>reference:</td><td><input type="text" style="width:95%" id= "reference"/></td></tr>';
- str += '</table>';
- $('#content').html(str);
- $('#delete').click(function() {
- file_delete($('#referenceType').val(), $('#reference').val());
- });
- }
- function file_delete(referenceType, reference, scale) {
- $.ajax({
- type : 'delete',
- dataType : 'json',
- url : '../jaxrs/file/referencetype/' + referenceType + '/reference/' + reference,
- contentType : 'application/json; charset=utf-8',
- xhrFields : {
- 'withCredentials' : true
- },
- crossDomain : true
- }).always(function(json) {
- $('#result').html(JSON.stringify(json, null, 4));
- });
- }
|