var old_temp_row = null; function editTmpDetails(tmp_art_id) { var el = get_by_id("edit_details"); if (el) { el.style.display = 'block'; } showTempThumb(tmp_art_id); } function reloadTempEntries() { var ajaxReq = new CXMLHttp(); ajaxReq.onDone = function(xmlhttp) { var el = get_by_id("edit_details"); el.style.display = 'none'; _innerHTML('temp_table', xmlhttp.responseText); } ajaxReq.getQuery('/ajax_temp.php'); } function checkUploaderParams() { el = get_by_id( 'title' ); el2 = get_by_id( 'comment' ); if (el.value == '') { alert('Пустой заголовок'); el.focus(); return false; } /* if (el2.value == '') { alert('Пустой комментарий!'); el2.focus(); return false; } */ var ajaxReq = new CXMLHttp(); ajaxReq.onDone = function(xmlhttp) { disableFormCtrls('submit_details', false); response = xmlhttp.responseXML.documentElement; result = response.getAttribute('result'); if (result == 'OK') { if (response.getAttribute('stay') == 0) window.location.href = response.getAttribute('url'); else { reloadTempEntries(); window.location = '#top'; } } else alert(result); } ajaxReq.onError = function(xmlhttp) { disableFormCtrls('submit_details', false); err.innerHTML = "Ошибка! Код ошибки: " + xmlhttp.status + ""; } var err = get_by_id("error"); err.innerHTML = "Отправляю данные на сервер..."; disableFormCtrls('submit_details', true); var req = collectFormItems('a=finish', 'submit_details'); ajaxReq.postQuery('/ajax_upload.php', req); return true; } function showTempThumb(tmp_id) { var ajaxReq = new CXMLHttp(); ajaxReq.onDone = function(xmlhttp) { var response = xmlhttp.responseXML.documentElement; var thumb = response.getElementsByTagName('thumb'); var categories = response.getElementsByTagName('categories'); var el = get_by_id('thumb'); var elCat = get_by_id('categories'); if (thumb.length > 0) el.innerHTML = thumb[0].firstChild.data; if (categories.length > 0) elCat.innerHTML = categories[0].firstChild.data; if (old_temp_row != null) old_temp_row.style.background = ""; get_by_id('row_' + tmp_id).style.background = "#E5F3E5"; old_temp_row = get_by_id('row_' + tmp_id); } var el = get_by_id('thumb'); el.innerHTML = "
LoadingЗагружаю картинку, подождите...
"; el = get_by_id('temp_art_id'); if (el) el.value = tmp_id; ajaxReq.getQuery('/ajax_thumb.php?tmp_id=' + tmp_id); } function deleteTempThumb(tmp_id) { var ajaxReq = new CXMLHttp(); ajaxReq.onDone = function(xmlhttp) { reloadTempEntries(); } ajaxReq.getQuery('/ajax_upload.php?a=delete&temp_art_id=' + tmp_id); } function checkUploadParams(isFinish) { r = checkStage2(isFinish); if (r && isFinish) { prepareFinish(!isFinish); uploadFile(); } return r; } function checkStage2(isFinish) { el = get_by_id( 'title' ); el2 = get_by_id( 'comment' ); if ( !el.value ) { get_by_id("art_name").style.color = 'red'; var bar = get_by_id( "bar_desc" ); open_tab( bar, "tabs", "tab_desc" ); get_by_id( 'title' ).focus(); return false; } else if( !el2.value ) { get_by_id("art_comment").style.color = 'red'; var bar = get_by_id( "bar_desc" ); open_tab( bar, "tabs", "tab_desc" ); get_by_id( 'comment' ).focus(); return false; } else { get_by_id("art_name").style.color = ''; get_by_id("art_comment").style.color = ''; return checkStage3(isFinish); } } function checkStage3(isFinish) { return checkStage4(isFinish); } function checkStage4(isFinish) { var fhash = get_by_id("filehash") if (fhash.value == "") { var bar = get_by_id( "bar_upload" ); open_tab( bar, "tabs", "tab_upload" ); get_by_id("file_choose").style.color = 'red'; return false; } else { get_by_id("file_choose").style.color = ''; prepareFinish(!isFinish); var bar = get_by_id( "bar_finish" ); open_tab( bar, "tabs", "tab_finish" ); return true; } } function fillTempFields() { var t = get_by_id("title"); var t2 = get_by_id("title__"); t2.value = t.value; var c = get_by_id("comment"); var c2 = get_by_id("comment__"); c2.value = c.value; var k = get_by_id("keywordList"); var k2 = get_by_id("keywordList__"); k2.value = k.value; var m = get_by_id("is_mature"); var m2 = get_by_id("is_mature__"); m2.value = (m.checked) ? "1" : "0"; var f = get_by_id("is_featured"); var f2 = get_by_id("is_featured__"); f2.value = (f.checked) ? "1" : "0"; var c = get_by_id("community"); var c2 = get_by_id("community__"); c2.value = c.value; } function adjustFilename() { var f = get_by_id("submission"); var fn = get_by_id("filename"); fn.value = f.value; fillTempFields(); return false; } function prepareFinish(previewComment) { get_by_id("thumb2").innerHTML = get_by_id("thumb").innerHTML; get_by_id("title2").innerHTML = get_by_id("title").value; get_by_id("kw_list2").innerHTML = get_by_id("kw_list").innerHTML; if (previewComment && get_by_id("comment").value) preview_comment('comment', 'comment2', 'comment2'); } function showMore() { if (++file_id < 10) { var el = get_by_id('submission' + file_id); if (el && el.style.display == 'none') el.style.display = 'block'; } } function adjustFilename() { for (var i = 0; i < 10; i++) { var f = get_by_id("submission" + i); var fn = get_by_id("filename" + i); if (f && fn) fn.value = f.value; } return false; } function Uploader(sid) { this.sid = sid; this.timer = 0; this.errors = 0; this.loaded = 0; var self = this; this.abort = function () { this.errors = 1; this.cleanUp(); } this.cleanUp = function() { clearInterval(this.timer); if (this.errors > 0) { this.timer = -1; var ajaxReq = new CXMLHttp(); ajaxReq.getQuery('/ajax_filestat.php?a=clean&sid=' + this.sid); } else this.timer = 0; } this.showThumb = function() { var ajaxReq = new CXMLHttp(); ajaxReq.onDone = function(xmlhttp) { var el = get_by_id('thumb'); el.innerHTML = xmlhttp.responseText; self.loaded = 1; } var el = get_by_id('thumb'); el.innerHTML = "
LoadingЗагружаю картинку, подождите...
"; ajaxReq.getQuery('/ajax_thumb.php?sid=' + this.sid); } this.doDone = function() { var el = get_by_id('progressDiv'); el.style.width = '100%'; el = get_by_id('progressMeter'); el.innerHTML = '100%'; var ajaxReq = new CXMLHttp(); ajaxReq.onDone = function(xmlhttp) { var response = xmlhttp.responseXML.documentElement; var err = response.getElementsByTagName('error'); if (err.length > 0) { var s_err = err[0].firstChild.data; alert(s_err); } else self.showThumb(); } ajaxReq.getQuery('/ajax_filestat.php?a=complete&sid=' + this.sid); } this.beginPoll = function() { var el = get_by_id('progress'); el.style.display = 'block'; el = get_by_id('progressMeter'); el.innerHTML = '0%'; el = get_by_id('progressDiv'); el.style.width = "0%"; this.loaded = 0; if (this.timer == 0) this.timer = setInterval(function(){self.doPoll();}, 250); } this.doPoll = function() { var ajaxReq = new CXMLHttp(); ajaxReq.onDone = function(xmlhttp) { var response = xmlhttp.responseXML.documentElement; var value = response.getElementsByTagName('value'); if (value.length > 0) { var el = get_by_id('progressDiv'); var p = value[0].getAttribute('percent'); if (p == 100) self.cleanUp(); el.style.width = p + '%'; var el = get_by_id('progressMeter'); el.innerHTML = p + '%'; } var err = response.getElementsByTagName('error'); if (err.length > 0) { var s_err = err[0].firstChild.data; self.abort(); if (s_err != "aborted") alert(s_err); } } ajaxReq.onError = function(xmlhttp) { self.abort(); } ajaxReq.getQuery('/ajax_filestat.php?sid=' + this.sid); } }