Skip to content

Commit

Permalink
JSUpload plugin added to replace the SWFUpload
Browse files Browse the repository at this point in the history
  • Loading branch information
wkpark committed Oct 27, 2022
1 parent 9a3f998 commit ecc337a
Show file tree
Hide file tree
Showing 26 changed files with 282 additions and 2,729 deletions.
7 changes: 4 additions & 3 deletions config.php.default
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ $myprocessors=array('syntax'=>'vim','sh'=>'vim','csh'=>'vim',
#$myplugins=array('fullsearch'=>'FastSearch'); # substitute action/macro
#$myplugins=array('TOC'=>'TableOfContents'); # alias action/macro
#$myplugins=array('swfupload'=>false); # disable some macro
$myplugins=array('rcsexport'=>false); # disable rcsexport
$myplugins=array('rcsexport'=>false, 'swfupload'=>'jsupload'); # disable rcsexport, replace swfupload
#
#$extra_macros=array('FootNote', 'Comment'); # call some extra macros after send_page()

Expand Down Expand Up @@ -349,7 +349,7 @@ $cachetime=0;
#$cookie_path='/'; // set cookie path
#$access_control_allowed_re='@foobar.com@'; // control Access-Control-Allow-Origin header
$dynamic_macros=array('pagecount'=>1, 'recentchanges'=>1,'userpreferences'=>1,
'uploadedfiles'=>1,'SWFUpload'=>1,'Vote'=>1,
'uploadedfiles'=>1,'JSUpload'=>1, 'Vote'=>1,
'login'=>1,'minilogin'=>1,'scrap'=>1, 'subscribe'=>1, 'fortune'=>1);
$cache_public_dir='./_cache'; # enhanced caching
$cache_public_url=$url_prefix.'/_cache';
Expand All @@ -365,7 +365,8 @@ $cache_public_url=$url_prefix.'/_cache';
#$use_rating=1; # builtin Rating support
$use_jwmediaplayer=1;
$jwmediaplayer_prefix='http://www.jeroenwijering.com/embed';
$flashupload='swfupload';
#$myupload='swfupload';
#$myupload_depth=2; # uploader depth for future use
#$media_url_mode=1; # media url mode for Play/Media macro
#$icon_list='edit,diff,show,find,print,info,help,pref,rss'; # set the icon list
#$use_folding=0; # 1:default simple js / 2:with the prototype/mootools
Expand Down
7 changes: 4 additions & 3 deletions config.php.default.ko
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ $myprocessors=array('syntax'=>'vim','sh'=>'vim','csh'=>'vim',
#$myplugins=array('fullsearch'=>'FastSearch'); # substitute action/macro
#$myplugins=array('TOC'=>'TableOfContents'); # alias action/macro
#$myplugins=array('swfupload'=>false); # disable some macro
$myplugins=array('rcsexport'=>false); # disable rcsexport
$myplugins=array('rcsexport'=>false, 'swfupload'=>'jsupload'); # disable rcsexport, replace swfupload
#
#$extra_macros=array('FootNote', 'Comment'); # call some extra macros after send_page()

Expand Down Expand Up @@ -349,7 +349,7 @@ $cachetime=0;
#$cookie_path='/'; // set cookie path
#$access_control_allowed_re='@foobar.com@'; // control Access-Control-Allow-Origin header
$dynamic_macros=array('pagecount'=>1, 'recentchanges'=>1,'userpreferences'=>1,
'uploadedfiles'=>1,'SWFUpload'=>1,'Vote'=>1,
'uploadedfiles'=>1,'JSUpload'=>1, 'Vote'=>1,
'login'=>1,'minilogin'=>1,'scrap'=>1, 'subscribe'=>1, 'fortune'=>1);
$cache_public_dir='./_cache'; # enhanced caching
$cache_public_url=$url_prefix.'/_cache';
Expand All @@ -365,7 +365,8 @@ $cache_public_url=$url_prefix.'/_cache';
#$use_rating=1; # builtin Rating support
$use_jwmediaplayer=1;
$jwmediaplayer_prefix='http://www.jeroenwijering.com/embed';
$flashupload='swfupload';
#$myupload='swfupload';
#$myupload_depth=2; # uploader depth for future use
#$media_url_mode=1; # media url mode for Play/Media macro
#$icon_list='edit,diff,show,find,print,info,help,pref,rss'; # set the icon list
#$use_folding=0; # 1:default simple js / 2:with the prototype/mootools
Expand Down
2 changes: 1 addition & 1 deletion data/editform.txt.sample
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[[EditToolbar]]
[[EditHints(js)]]
#editform
###[[SWFUpload]]
###[[JSUpload]]
###[[SmileyChooser]]
###[[MathChooser]]
118 changes: 118 additions & 0 deletions local/JSUpload/handlers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/* Demo Note: This demo uses a FileProgress class that handles the UI for displaying the file name and percent complete.
The FileProgress class is not part of SWFUpload.
*/


/* **********************
Event Handlers
These are my custom event handlers to make my
web application behave the way I went when SWFUpload
completes different tasks. These aren't part of the SWFUpload
package. They are part of my application. Without these none
of the actions SWFUpload makes will show up in my application.
********************** */

/**
* remove all SWFUpload stuff and add HTML5 upload callbacks.
*/
function byId(id) {
return document.getElementById(id);
}

Math.roundf = function(val, precision) {
var p = this.pow(10, precision);
return this.round(val * p) / p;
}
/* */

function fileQueued(file) {
byId("filesDisplay").style.display = "block";

var el = document.getElementById(file.name);
if (el) {
// already have entry
var chk = el.getElementsByTagName("input")[0];
if (chk) {
if (chk.type=='checkbox' && chk.checked == 0) {
el.parentNode.removeChild(el);
} else {
return true;
}
}
byId(file.name).className = "uploading";
return true;
}

var li = document.createElement("li");
var txt = document.createTextNode(file.name);

li.className = "uploading";
li.id = file.name;

var prg = document.createElement("span");
prg.id = file.name + "progress";
prg.className = "progressBar";

li.appendChild(txt);
li.appendChild(prg);

byId("mmUploadFileListing").appendChild(li);

delFiles();
}

function delFiles() {
var listing = byId("mmUploadFileListing");
var elem = listing.getElementsByTagName("li");

for (var i=0;i<elem.length;i++) {
var chk= elem[i].getElementsByTagName("input")[0];
if (chk !== undefined && chk.type=='checkbox' && chk.checked==0) {
elem[i].parentNode.removeChild(elem[i]);
}
}
}

function fileSubmit(obj) {
var listing = byId("mmUploadFileListing");
var elem = listing.getElementsByTagName("li");
var selected = new Array();
var form = obj.parentNode;

for (var i=0;i<elem.length;i++) {
var chk= elem[i].getElementsByTagName("input")[0];
if (chk.type=='checkbox' && chk.checked==1) {
var inp = document.createElement('INPUT');
inp.setAttribute("name",'MYFILES[]');
inp.setAttribute("type",'hidden');
inp.setAttribute("value",elem[i].id);
form.appendChild(inp);

var a = elem[i].getElementsByTagName("a")[0];
a.href = "javascript:showImgPreview('" + elem[i].id + "',true)";
}
}
}

function uploadSuccess(file) {
var unt= new Array('Bytes','KB','MB','GB','TB');
var size=file.size;
var i;
for (i=0;i<4;i++) {
if (size <= 1024) {
break;
}
size=size/1024;
}
size= Math.roundf(size,2) + " " + unt[i];

byId(file.name).className = "uploadDone";
byId(file.name).innerHTML = "<input type='checkbox' checked='checked' />"
+ "<a href='javascript:showImgPreview(\"" + file.name + "\")'>" + file.name + "</a>" + " (" + size + ")";

var pie = byId("fileProgressInfo");
pie.style.background='';
pie.innerHTML = "";
}

// vim:et:sts=4:sw=4:
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
10 changes: 5 additions & 5 deletions local/SWFUpload/swfupload.css → local/JSUpload/jsupload.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SWFUpload CSS */
/* JSUpload CSS */

#filesDisplay {
padding: 5px 10px 5px 10px;
Expand Down Expand Up @@ -48,13 +48,13 @@
letter-spacing:-1px;
}

#SWFUpload {
#JSUpload {
margin:0px;
padding:0px;
height:1px;
}

#SWFUpload a {
#JSUpload a {
height:1px;
}

Expand Down Expand Up @@ -97,7 +97,7 @@ span.progressBar {
font-weight:bold;
}

a.SWFUploadLink {
a.JSUploadLink {
/*
width: 300px;
height: 100px;
Expand All @@ -109,7 +109,7 @@ a.SWFUploadLink {
display: none;
}

a.SWFUploadLink:hover {
a.JSUploadLink:hover {
background: url(images/custom_button_over.png) no-repeat;
}

Expand Down
56 changes: 35 additions & 21 deletions local/SWFUpload/preview.js → local/JSUpload/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ function alignImg(obj,val) {

var tag = document.getElementById("insertTag");
if (tag) {
var href= tag.href;
var dum=href.split(/,/);
var href = tag.href + "";
var dum=href.split(",");
if (val == 'normal') {
dum[1]="''";
} else {
dum[1]="'" + '?align='+val+"'";
dum[1]="'" + '.align='+val+"'";
}
tag.href=dum.join(",");
// revert encoded filename
dum[2] = decodeURIComponent(dum[2]);
href = dum.join(",");
tag.href = href;
if (dum[2] != '') {
if (tag.href.substr(0, 10) == 'javascript') {
eval(tag.href.substr(11));
Expand All @@ -33,7 +36,7 @@ function showImgPreview(filename,temp) {
var href_open='',href_close='';
var jspreview=0;
var icon_dir = _url_prefix + '/imgs/plugin/UploadedFiles/gnome';
var img_dir = _url_prefix + '/local/SWFUpload/images';
var img_dir = _url_prefix + '/local/JSUpload/images';
var preview_width='100px';
var alt='';
var fname='';
Expand All @@ -47,13 +50,13 @@ function showImgPreview(filename,temp) {

var ef = document.getElementById('editform');
if (ef) {
jspreview=1;
jspreview=true;
}

//var loc = location.protocol + '//' + location.host;
//if (location.port) loc += ':' + location.port;
//path = loc + _url_prefix + '/pds/.swfupload/' + mydir + filename;
path = _url_prefix + '/pds/.swfupload/' + mydir + filename;
//path = loc + _url_prefix + '/pds/.myupload/' + mydir + filename;
path = _url_prefix + '/pds/.myupload/' + mydir + filename;

if (jspreview) {
tag_open="attachment:"; tag_close="";
Expand All @@ -66,35 +69,46 @@ function showImgPreview(filename,temp) {
var isImg=0;
var myAlign='';
if (ext && ext.match(/gif|png|jpeg|jpg|bmp/)) {
// preview FIXME
if (jspreview) {
myAlign =" <img src='" + img_dir + "/normal.png' class='alignImg' onclick='javascript:alignImg(this,\"normal\")' />";
myAlign+=" <img src='" + img_dir + "/left.png' class='alignImg' onclick='javascript:alignImg(this,\"left\")' />";
myAlign+=" <img src='" + img_dir + "/right.png' class='alignImg' onclick='javascript:alignImg(this,\"right\")' />";
}

if (temp) {
var postdata = 'action=markup/ajax&value=' + encodeURIComponent("attachment:" + filename);
var myhtml='';
var href = self.location + '';
href = href.replace(/\?action=edit/, '');
myhtml= HTTPPost(href, postdata);

var m = myhtml.match(/<img src=(\'|\")([^\'\"]+)\1/i); // strip div tag
path = m[2];
HTTPPost(href, postdata, function(r){
var m = r.match(/<img src=(\'|\")([^\'\"]+)\1/i); // strip div tag
path = m[2];
fname="<img src='" + path + "' width='" + preview_width + '" ' + alt + " />";

var align = document.getElementById("previewAlign");
align.innerHTML=myAlign;
setPreviewTag();
});
return;
}
fname="<img src='" + path + "' width='" + preview_width + ' ' + alt + " />";
fname="<img src='" + path + "' width='" + preview_width + '" ' + alt + " />";
isImg=1;

if (jspreview) {
myAlign =" <img src='" + img_dir + "/normal.png' class='alignImg' onclick='javascript:alignImg(this,\"normal\")' />";
myAlign+=" <img src='" + img_dir + "/left.png' class='alignImg' onclick='javascript:alignImg(this,\"left\")' />";
myAlign+=" <img src='" + img_dir + "/right.png' class='alignImg' onclick='javascript:alignImg(this,\"right\")' />";
}
} else {
if (ext.match(/^(wmv|avi|mpeg|mpg|swf|wav|mp3|ogg|midi|mid|mov)$/)) {
if (ext.match(/^(wmv|avi|mpeg|mpg|swf|wav|mp3|mp4|flac|ogg|midi|mid|mov)$/)) {
tag_open='[[Media('; tag_close=')]]';
alt=tag_open + filename + tag_close;
} else if (!ext.match(/^(bmp|c|h|java|py|bak|diff|doc|css|php|xml|html|mod|rpm|deb|pdf|ppt|xls|tgz|gz|bz2|zip)$/)) {
ext='unknown';
}
fname="<img src='" + icon_dir + "/" + ext + ".png' " + alt + " />";
}

setPreviewTag();

function setPreviewTag() {
if (jspreview) {
//if (strpos($file,' '))
link="javascript:insertTags('" + tag_open + "','" + tag_close + "','" + filename + "',true)";
href_open="<a id='insertTag' href=\""+ link + "\">";href_close="</a>";
} else if (isImg && form.use_lightbox.value) {
Expand All @@ -108,5 +122,5 @@ function showImgPreview(filename,temp) {
var align = document.getElementById("previewAlign");
align.innerHTML=myAlign;
preview.innerHTML=href_open + fname + href_close;
}
}

Loading

0 comments on commit ecc337a

Please sign in to comment.