Related
Is there a way to delete a file in Roxy Fileman, I keep on getting a error when I try to delete a pdf in Roxy Fileman, the delete folder is working fine just the file not want to delete.
I have been struggling to find a solution for two weeks, still this problem persist, Any help, suggestions would be much appreciated.
Hi yall,
Basically everything is working fine just not the deleteFile() the only thing that's giving me error, when Im I try to delete, its a javascript error Main.js the deleteFile() function needs to be corrected
I have updated the script
Please see code below, Thanks alot
Main.js
$.ajaxSetup ({cache: false});
function selectFile(item){
$('#pnlFileList li').removeClass('selected');
$(item).prop('class', 'selected');
var html = RoxyUtils.GetFilename($(item).attr('data-path'));
html += ' ('+t('Size')+': '+RoxyUtils.FormatFileSize($(item).attr('data-size'));
if($(item).attr('data-w') > 0)
html += ', '+t('Dimensions')+':'+$(item).attr('data-w')+'x'+$(item).attr('data-h');
html += ')';
$('#pnlStatus').html(html);
}
var uploadFileList = new Array();
function showUploadList(files){
var filesPane = $('#uploadFilesList');
filesPane.html('');
clearFileField();
for(i = 0; i < files.length; i++){
filesPane.append('<div class="fileUpload"><div class="fileName">'+files[i].name+' ('+RoxyUtils.FormatFileSize(files[i].size)+')<span class="progressPercent"></span><div class="uploadProgress"><div class="stripes"></div></div></div><a class="removeUpload" onclick="removeUpload(' + i + ')"></a></div>');
}
if(files.length > 0)
$('#btnUpload').button('enable');
else
$('#btnUpload').button('disable');
}
function listUploadFiles(files){
if(!window.FileList) {
$('#btnUpload').button('enable');
}
else if(files.length > 0) {
uploadFileList = new Array();
addUploadFiles(files);
}
}
function addUploadFiles(files){
for(i = 0; i < files.length; i++)
uploadFileList.push(files[i]);
showUploadList(uploadFileList);
}
function removeUpload(i){
var el = findUploadElement(i);
el.remove();
try{
uploadFileList.splice(i, 1);
showUploadList(uploadFileList);
}
catch(ex){
//alert(ex);
}
}
function findUploadElement(i){
return $('#uploadFilesList .fileUpload:eq(' + (i)+ ')');
}
function updateUploadProgress(e, i){
var el = findUploadElement(i);
var percent = 99;
if (e.lengthComputable) {
percent = Math.floor((e.loaded / e.total) * 100);
}
if(percent > 99)
percent = 99;
el.find('.uploadProgress').css('width', percent + '%');
el.find('.progressPercent').html(' - ' + percent + '%');
}
function uploadComplete(e, i){
uploadFinished(e, i, 'ok');
}
function uploadError(e, i){
setUploadError(i);
uploadFinished(e, i, 'error');
}
function setUploadError(i){
var el = findUploadElement(i);
el.find('.uploadProgress').css('width', '100%').addClass('uploadError').removeClass('uploadComplete');
el.find('.progressPercent').html(' - <span class="error">' + t('E_UploadingFile')+'</span>');
}
function setUploadSuccess(i){
var el = findUploadElement(i);
el.find('.uploadProgress').css('width', '100%').removeClass('uploadError').addClass('uploadComplete');
el.find('.progressPercent').html(' - 100%');
}
function uploadCanceled(e, i){
uploadFinished(e, i, 'error');
}
function uploadFinished(e, i, res){
var el = findUploadElement(i);
var httpRes = null;
try{
httpRes = JSON.parse(e.target.responseText);
}
catch(ex){}
if((httpRes && httpRes.res == 'error') || res != 'ok'){
res = 'error';
setUploadError(i);
}
else{
res = 'ok';
setUploadSuccess(i)
}
el.attr('data-ulpoad', res);
checkUploadResult();
}
function checkUploadResult(){
var all = $('#uploadFilesList .fileUpload').length;
var completed = $('#uploadFilesList .fileUpload[data-ulpoad]').length;
var success = $('#uploadFilesList .fileUpload[data-ulpoad="ok"]').length;
if(completed == all){
//$('#uploadResult').html(success + ' files uploaded; '+(all - success)+' failed');
uploadFileList = new Array();
var d = Directory.Parse($('#hdDir').val());
d.ListFiles(true);
$('#btnUpload').button('disable');
}
}
function fileUpload(f, i){
var http = new XMLHttpRequest();
var fData = new FormData();
var el = findUploadElement(i);
el.find('.removeUpload').remove();
fData.append("action", 'upload');
fData.append("method", 'ajax');
fData.append("d", $('#hdDir').attr('value'));
fData.append("files[]", f);
http.upload.addEventListener("progress", function(e){updateUploadProgress(e, i);}, false);
http.addEventListener("load", function(e){uploadComplete(e, i);}, false);
http.addEventListener("error", function(e){uploadError(e, i);}, false);
http.addEventListener("abort", function(e){uploadCanceled(e, i);}, false);
http.open("POST", RoxyFilemanConf.UPLOAD, true);
http.setRequestHeader("Accept", "*/*");
http.send(fData);
}
function dropFiles(e, append){
if(e && e.dataTransfer && e.dataTransfer.files){
addFile();
if(append)
addUploadFiles(e.dataTransfer.files);
else
listUploadFiles(e.dataTransfer.files);
}
else
addFile();
}
function clearFileField(selector){
if(!selector)
selector = '#fileUploads';
try{
$(selector).val('');
$(selector).val(null);
}
catch(ex){}
}
function addFileClick(){
$('#uploadResult').html('');
showUploadList(new Array());
addFile();
}
function addFile(){
clickFirstOnEnter('dlgAddFile');
$('#uploadResult').html('');
clearFileField();
var dialogButtons = {};
dialogButtons[t('Upload')] = {id:'btnUpload', text: t('Upload'), disabled:true, click:function(){
if(!$('#fileUploads').val() && (!uploadFileList || uploadFileList.length == 0))
alert(t('E_SelectFiles'));
else{
if(!RoxyFilemanConf.UPLOAD){
alert(t('E_ActionDisabled'));
//$('#dlgAddFile').dialog('close');
}
else{
if(window.FormData && window.XMLHttpRequest && window.FileList && uploadFileList && uploadFileList.length > 0){
for(i = 0; i < uploadFileList.length; i++){
fileUpload(uploadFileList[i], i);
}
}
else{
document.forms['addfile'].action = RoxyFilemanConf.UPLOAD;
document.forms['addfile'].submit();
}
}
}
}};
dialogButtons[t('Cancel')] = function(){$('#dlgAddFile').dialog('close');};
$('#dlgAddFile').dialog({title:t('T_AddFile'),modal:true,buttons:dialogButtons,width:400});
}
function fileUploaded(res){
if(res.res == 'ok' && res.msg){
$('#dlgAddFile').dialog('close');
var d = Directory.Parse($('#hdDir').val());
d.ListFiles(true);
alert(res.msg);
}
else if(res.res == 'ok'){
$('#dlgAddFile').dialog('close');
var d = Directory.Parse($('#hdDir').val());
d.ListFiles(true);
}
else
alert(res.msg);
}
function renameDir(){
var f = getSelectedDir();
if(!f)
return;
if($('[data-path="'+f.fullPath+'"]').parents('li').length < 1){
alert(t('E_CannotRenameRoot'));
return;
}
clickFirstOnEnter('pnlDirName');
$('#txtDirName').val(f.name);
var dialogButtons = {};
dialogButtons[t('RenameDir')] = function(){
var newName = $.trim($('#txtDirName').val());
if(!newName)
alert(t('E_MissingDirName'));
if(f.Rename(newName))
$('#pnlDirName').dialog('close');
};
dialogButtons[t('Cancel')] = function(){$('#pnlDirName').dialog('close');};
$('#pnlDirName').dialog({title:t('T_RenameDir'),modal:true,buttons:dialogButtons});
RoxyUtils.SelectText('txtDirName', 0, new String(f.name).length);
}
function renameFile(){
var f = getSelectedFile();
if(!f)
return;
clickFirstOnEnter('pnlRenameFile');
$('#txtFileName').val(f.name);
var dialogButtons = {};
dialogButtons[t('RenameFile')] = function(){
var newName = $.trim($('#txtFileName').val());
if(!newName)
alert('Missing file name');
else if(f.Rename(newName)){
$('li[data-path="'+f.fullPath+'"] .name').text(newName);
$('li[data-path="'+f.fullPath+'"]').attr('data-path', RoxyUtils.MakePath(f.path, newName));
$('#pnlRenameFile').dialog('close');
}
};
dialogButtons[t('Cancel')] = function(){$('#pnlRenameFile').dialog('close');};
$('#pnlRenameFile').dialog({title:t('T_RenameFile'),modal:true,buttons:dialogButtons});
if(f.name.lastIndexOf('.') > 0)
RoxyUtils.SelectText('txtFileName', 0, f.name.lastIndexOf('.'));
}
function getSelectedFile(){
var ret = null;
if($('#pnlFileList .selected').length > 0)
ret = new File($('#pnlFileList .selected').attr('data-path'));
return ret;
}
function getSelectedDir(){
var ret = null;
if($('#pnlDirList .selected'))
ret = Directory.Parse($('#pnlDirList .selected').closest('li').attr('data-path'));
return ret;
}
function deleteDir(path){
var d = null;
if(path)
d = Directory.Parse(path);
else
d = getSelectedDir();
if(d && confirm(t('Q_DeleteFolder'))){
d.Delete();
}
}
function deleteFile(){
var f = getSelectedFile();
if(f && confirm(t('Q_DeleteFile'))){
f.Delete();
}
}
function previewFile(){
var f = getSelectedFile();
if(f){
window.open(f.fullPath);
}
}
function downloadFile(){
var f = getSelectedFile();
if(f && RoxyFilemanConf.DOWNLOAD){
var url = RoxyUtils.AddParam(RoxyFilemanConf.DOWNLOAD, 'f', f.fullPath);
window.frames['frmUploadFile'].location.href = url;
}
else if(!RoxyFilemanConf.DOWNLOAD)
alert(t('E_ActionDisabled'));
}
function downloadDir(){
var d = getSelectedDir();
if(d && RoxyFilemanConf.DOWNLOADDIR){
var url = RoxyUtils.AddParam(RoxyFilemanConf.DOWNLOADDIR, 'd', d.fullPath);
window.frames['frmUploadFile'].location.href = url;
}
else if(!RoxyFilemanConf.DOWNLOAD)
alert(t('E_ActionDisabled'));
}
function closeMenus(el){
if(!el || el == 'dir')
$('#menuDir').fadeOut();
if(!el || el == 'file')
$('#menuFile').fadeOut();
}
function selectFirst(){
var item = $('#pnlDirList li:first').children('div').first();
if(item.length > 0)
selectDir(item);
else
window.setTimeout('selectFirst()', 300);
}
function tooltipContent(){
if($('#menuFile').is(':visible'))
return '';
var html = '';
var f = File.Parse($(this).attr('data-path'));
if($('#hdViewType').val() == 'thumb' && f.IsImage()){
html = f.fullPath+'<br><span class="filesize">'+t('Size')+': '+RoxyUtils.FormatFileSize(f.size) + ' '+t('Dimensions')+': '+f.width+'x'+f.height+'</span>';
}
else if(f.IsImage()){
if(RoxyFilemanConf.GENERATETHUMB){
imgUrl = RoxyUtils.AddParam(RoxyFilemanConf.GENERATETHUMB, 'f', f.fullPath);
imgUrl = RoxyUtils.AddParam(imgUrl, 'width', RoxyFilemanConf.PREVIEW_THUMB_WIDTH);
imgUrl = RoxyUtils.AddParam(imgUrl, 'height', RoxyFilemanConf.PREVIEW_THUMB_HEIGHT);
}
else
imgUrl = f.fullPath;
html = '<img src="'+imgUrl+'" class="imgPreview"><br>'+f.name+' <br><span class="filesize">'+t('Size')+': '+RoxyUtils.FormatFileSize(f.size) + ' '+t('Dimensions')+': '+f.width+'x'+f.height+'</span>';
}
else
html = f.fullPath+' <span class="filesize">'+t('Size')+': '+RoxyUtils.FormatFileSize(f.size) + '</span>';
return html;
}
function filterFiles(){
var str = $('#txtSearch').val();
$('#pnlSearchNoFiles').hide();
if($('#pnlFileList li').length == 0)
return;
if(!str){
$('#pnlFileList li').show();
return;
}
var i = 0;
$('#pnlFileList li').each(function(){
var name = $(this).children('.name').text();
if(name.toLowerCase().indexOf(str.toLowerCase()) > -1){
i++;
$(this).show();
}
else{
$(this).removeClass('selected');
$(this).hide();
}
});
if(i == 0)
$('#pnlSearchNoFiles').show();
}
function sortFiles(){
var d = getSelectedDir();
if(!d)
return;
d.ListFiles();
filterFiles();
switchView($('#hdViewType').val());
}
function switchView(t){
if(t == $('#hdViewType').val())
return;
if(!t)
t = $('#hdViewType').val();
$('.btnView').removeClass('selected');
if(t == 'thumb'){
$('#pnlFileList .icon').attr('src', 'images/blank.gif');
$('#pnlFileList').addClass('thumbView');
if($('#dynStyle').length == 0){
$('head').append('<style id="dynStyle" />');
var rules = 'ul#pnlFileList.thumbView li{width:'+RoxyFilemanConf.THUMBS_VIEW_WIDTH+'px;}';
rules += 'ul#pnlFileList.thumbView li{height:'+(parseInt(RoxyFilemanConf.THUMBS_VIEW_HEIGHT) + 20)+'px;}';
rules += 'ul#pnlFileList.thumbView .icon{width:'+RoxyFilemanConf.THUMBS_VIEW_WIDTH+'px;}';
rules += 'ul#pnlFileList.thumbView .icon{height:'+RoxyFilemanConf.THUMBS_VIEW_HEIGHT+'px;}';
$('#dynStyle').html(rules);
}
$('#pnlFileList li').each(function(){
//$('ul#pnlFileList.thumbView li').css('width', RoxyFilemanConf.THUMBS_VIEW_WIDTH + 'px');
//$('ul#pnlFileList.thumbView li').css('height', (parseInt(RoxyFilemanConf.THUMBS_VIEW_HEIGHT) + 20) + 'px');
//$('ul#pnlFileList.thumbView .icon').css('width', RoxyFilemanConf.THUMBS_VIEW_WIDTH + 'px');
//$('ul#pnlFileList.thumbView .icon').css('height', RoxyFilemanConf.THUMBS_VIEW_HEIGHT + 'px');
var imgUrl = $(this).attr('data-icon-big');
if(RoxyFilemanConf.GENERATETHUMB && RoxyUtils.IsImage($(this).attr('data-path'))){
imgUrl = RoxyUtils.AddParam(RoxyFilemanConf.GENERATETHUMB, 'f', imgUrl);
imgUrl = RoxyUtils.AddParam(imgUrl, 'width', RoxyFilemanConf.THUMBS_VIEW_WIDTH);
imgUrl = RoxyUtils.AddParam(imgUrl, 'height', RoxyFilemanConf.THUMBS_VIEW_HEIGHT);
}
$(this).children('.icon').css('background-image', 'url('+imgUrl+')');
$(this).tooltip('option', 'show', {delay:50});
});
$('#btnThumbView').addClass('selected');
}
else{
$('#pnlFileList').removeClass('thumbView');
$('#pnlFileList li').each(function(){
$(this).children('.icon').css('background-image','').attr('src', $(this).attr('data-icon'));
$(this).tooltip('option', 'show', {delay:500});
});
$('#btnListView').addClass('selected');
}
$('#hdViewType').val(t);
RoxyUtils.SetCookie('roxyview', t, 10);
}
var clipBoard = null;
function Clipboard(a, obj){
this.action = a;
this.obj = obj;
}
function cutDir(){
var d = getSelectedDir();
if(d){
setClipboard('cut', d);
d.GetElement().addClass('pale');
}
}
function copyDir(){
var d = getSelectedDir();
if(d){
setClipboard('copy', d);
}
}
function cutFile(){
var f = getSelectedFile();
if(f){
setClipboard('cut', f);
f.GetElement().addClass('pale');
}
}
function copyFile(){
var f = getSelectedFile();
if(f){
setClipboard('copy', f);
}
}
function pasteToFiles(e, el){
if($(el).hasClass('pale')){
e.stopPropagation();
return false;
}
var d = getSelectedDir();
if(!d)
d = Directory.Parse($('#pnlDirList li:first').children('div').first());
if(d && clipBoard && clipBoard.obj){
if(clipBoard.action == 'copy')
clipBoard.obj.Copy(d.fullPath);
else{
clipBoard.obj.Move(d.fullPath);
clearClipboard();
}
}
return true;
}
function pasteToDirs(e, el){
if($(el).hasClass('pale')){
e.stopPropagation();
return false;
}
var d = getSelectedDir();
if(!d)
d = Directory.Parse($('#pnlDirList li:first').children('div').first());
if(clipBoard && d){
if(clipBoard.action == 'copy')
clipBoard.obj.Copy(d.fullPath);
else{
clipBoard.obj.Move(d.fullPath);
clearClipboard();
d.ListFiles(true);
}
}
else
alert('error');
return true;
}
function clearClipboard(){
$('#pnlDirList li').removeClass('pale');
$('#pnlFileList li').removeClass('pale');
clipBoard = null;
$('.paste').addClass('pale');
}
function setClipboard(a, obj){
clearClipboard();
if(obj){
clipBoard = new Clipboard(a, obj);
$('.paste').removeClass('pale');
}
}
function ResizeLists(){
var tmp = $(window).innerHeight() - $('#fileActions .actions').outerHeight() - $('.bottomLine').outerHeight();
$('.scrollPane').css('height', tmp);
}
function removeDisabledActions(){
if(RoxyFilemanConf.CREATEDIR == ''){
$('#mnuCreateDir').next().remove();
$('#mnuCreateDir').remove();
$('#btnAddDir').remove();
}
if(RoxyFilemanConf.DELETEDIR == ''){
$('#mnuDeleteDir').prev().remove();
$('#mnuDeleteDir').remove();
$('#btnDeleteDir').remove();
}
if(RoxyFilemanConf.MOVEDIR == ''){
$('#mnuDirCut').next().remove();
$('#mnuDirCut').remove();
}
if(RoxyFilemanConf.COPYDIR == ''){
$('#mnuDirCopy').next().remove();
$('#mnuDirCopy').remove();
}
if(RoxyFilemanConf.COPYDIR == '' && RoxyFilemanConf.MOVEDIR == ''){
$('#mnuDirPaste').next().remove();
$('#mnuDirPaste').remove();
}
if(RoxyFilemanConf.RENAMEDIR == ''){
$('#mnuRenameDir').next().remove();
$('#mnuRenameDir').remove();
$('#btnRenameDir').remove();
}
if(RoxyFilemanConf.UPLOAD == ''){
$('#btnAddFile').remove();
}
if(RoxyFilemanConf.DOWNLOAD == ''){
$('#mnuDownload').next().remove();
$('#mnuDownload').remove();
}
if(RoxyFilemanConf.DOWNLOADDIR == ''){
$('#mnuDownloadDir').next().remove();
$('#mnuDownloadDir').remove();
}
if(RoxyFilemanConf.DELETEFILE == ''){
$('#mnuDeleteFile').prev().remove();
$('#mnuDeleteFile').remove();
$('#btnDeleteFile').remove();
}
if(RoxyFilemanConf.MOVEFILE == ''){
$('#mnuFileCut').next().remove();
$('#mnuFileCut').remove();
}
if(RoxyFilemanConf.COPYFILE == ''){
$('#mnuFileCopy').next().remove();
$('#mnuFileCopy').remove();
}
if(RoxyFilemanConf.COPYFILE == '' && RoxyFilemanConf.MOVEFILE == ''){
$('#mnuFilePaste').next().remove();
$('#mnuFilePaste').remove();
}
if(RoxyFilemanConf.RENAMEFILE == ''){
$('#mnuRenameFile').next().remove();
$('#mnuRenameFile').remove();
$('#btnRenameFile').remove();
}
}
function getPreselectedFile(){
var filePath = RoxyUtils.GetUrlParam('selected');
if(!filePath){
switch(getFilemanIntegration()){
case 'ckeditor':
try{
var dialog = window.opener.CKEDITOR.dialog.getCurrent();
filePath = dialog.getValueOf('info', (dialog.getName() == 'link'?'url':'txtUrl'));
}
catch(ex){}
break;
case 'tinymce3':
try{
var win = tinyMCEPopup.getWindowArg("window");
filePath = win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value;
if(filePath.indexOf('..') == 0)
filePath = filePath.substr(2);
}
catch(ex){}
break;
case 'tinymce4':
try{
var win = (window.opener?window.opener:window.parent);
filePath = win.document.getElementById(RoxyUtils.GetUrlParam('input')).value;
if(filePath.indexOf('..') == 0)
filePath = filePath.substr(2);
}
catch(ex){}
break;
default:
filePath = GetSelectedValue();
break;
}
}
if(RoxyFilemanConf.RETURN_URL_PREFIX){
var prefix = RoxyFilemanConf.RETURN_URL_PREFIX;
if(filePath.indexOf(prefix) == 0){
if(prefix.substr(-1) == '/')
prefix = prefix.substr(0, prefix.length - 1);
filePath = filePath.substr(prefix.length);
}
}
return filePath;
}
function initSelection(filePath){
var hasSelection = false, fileSelected = true;
if(!filePath)
filePath = getPreselectedFile();
if(!filePath && RoxyUtils.ToBool(RoxyFilemanConf.OPEN_LAST_DIR)){
filePath = getLastDir();
fileSelected = false;
}
if(filePath){
var p = (fileSelected? RoxyUtils.GetPath(filePath): filePath);
var d = tmp = Directory.Parse(p);
do{
if(tmp){
tmp.Expand(true);
hasSelection = true;
}
tmp = Directory.Parse(tmp.path);
}while(tmp);
if(d){
d.Select(filePath);
hasSelection = true;
}
}
if(!hasSelection)
selectFirst();
}
$(function(){
RoxyUtils.LoadConfig();
var d = new Directory();
d.LoadAll();
$('#wraper').show();
window.setTimeout('initSelection()', 100);
RoxyUtils.Translate();
$('body').click(function(){
closeMenus();
});
var viewType = RoxyUtils.GetCookie('roxyview');
if(!viewType)
viewType = RoxyFilemanConf.DEFAULTVIEW;
if(viewType)
switchView(viewType);
ResizeLists();
$(".actions input").tooltip({track: true});
$( window ).resize(ResizeLists);
document.oncontextmenu = function() {return false;};
removeDisabledActions();
$('#copyYear').html(new Date().getFullYear());
if(RoxyFilemanConf.UPLOAD && RoxyFilemanConf.UPLOAD != ''){
var dropZone = document.getElementById('fileActions');
dropZone.ondragover = function () { return false; };
dropZone.ondragend = function () { return false; };
dropZone.ondrop = function (e) {
e.preventDefault();
e.stopPropagation();
dropFiles(e);
};
dropZone = document.getElementById('dlgAddFile');
dropZone.ondragover = function () { return false; };
dropZone.ondragend = function () { return false; };
dropZone.ondrop = function (e) {
e.preventDefault();
e.stopPropagation();
dropFiles(e, true);
};
}
if(getFilemanIntegration() == 'tinymce3'){
try {
$('body').append('<script src="js/tiny_mce_popup.js"><\/script>');
}
catch(ex){}
}
});
function getFilemanIntegration(){
var integration = RoxyUtils.GetUrlParam('integration');
if(!integration)
integration = RoxyFilemanConf.INTEGRATION;
return integration.toLowerCase();
}
function setFile(){
var f = getSelectedFile();
if(!f){
alert(t('E_NoFileSelected'));
return;
}
var insertPath = f.fullPath;
if(RoxyFilemanConf.RETURN_URL_PREFIX){
var prefix = RoxyFilemanConf.RETURN_URL_PREFIX;
if(prefix.substr(-1) == '/')
prefix = prefix.substr(0, prefix.length - 1);
insertPath = prefix + (insertPath.substr(0, 1) != '/'? '/': '') + insertPath;
}
switch(getFilemanIntegration()){
case 'ckeditor':
window.opener.CKEDITOR.tools.callFunction(RoxyUtils.GetUrlParam('CKEditorFuncNum'), insertPath);
self.close();
break;
case 'tinymce3':
var win = tinyMCEPopup.getWindowArg("window");
win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = insertPath;
if (typeof(win.ImageDialog) != "undefined") {
if (win.ImageDialog.getImageData)
win.ImageDialog.getImageData();
if (win.ImageDialog.showPreviewImage)
win.ImageDialog.showPreviewImage(insertPath);
}
tinyMCEPopup.close();
break;
case 'tinymce4':
var win = (window.opener?window.opener:window.parent);
win.document.getElementById(RoxyUtils.GetUrlParam('input')).value = insertPath;
if (typeof(win.ImageDialog) != "undefined") {
if (win.ImageDialog.getImageData)
win.ImageDialog.getImageData();
if (win.ImageDialog.showPreviewImage)
win.ImageDialog.showPreviewImage(insertPath);
}
win.tinyMCE.activeEditor.windowManager.close();
break;
default:
FileSelected(f);
break;
}
}
Below is the error I'm getting in Nopcommerce roxyFileman
jquery-migrate.js:69 JQMIGRATE: Migrate is installed, version 3.3.2
plugin.min.js:9 Text color plugin is now built in to the core editor, please remove it from your editor configuration
(anonymous) # plugin.min.js:9
DevTools failed to load source map: Could not load content for http://localhost:51848/lib_npm/bootstrap/js/bootstrap.bundle.min.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://localhost:51848/lib_npm/admin-lte/js/adminlte.min.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://localhost:51848/lib_npm/moment/min/moment-with-locales.min.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://localhost:51848/lib_npm/fine-uploader/jquery.fine-uploader/jquery.fine-uploader.min.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://localhost:51848/lib_npm/admin-lte/css/adminlte.min.css.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load source map: Could not load content for http://localhost:51848/lib_npm/fine-uploader/fine-uploader/fine-uploader.min.css.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
I don't know who need this, I found the solution I was using NopCommerce 4.40.3 version, upgrade Nopcommerce to its latest version then the delete pdf etc. and all functions will work in roxy Fileman.
function startGame(diff){
if (diff === 'easy'){
loadEasy();
}
}
function loadEasy(){
difficultyPage.style.display = 'none';
game.style.display = 'block';
medHardTemplate.style.display = 'none';
easyTemplate.style.display = 'block';
newGame.addEventListener('click', function(){
changeDifficulty('easy');
});
colors = randomColorsArray(3);
correctColor = colorToChoose(colors);
colorRGB.innerHTML = correctColor;
for (var i = 0; i < easySquares.length; i++) {
//add colors to squares
easySquares[i].style.backgroundColor = colors[i];
easySquares[i].addEventListener('click', function(){
var clickedColor = this.style.backgroundColor;
if(clickedColor === correctColor) {
changeColorsOnWinEasy(correctColor);
message.innerHTML = "Correct!"
again.textContent = "Play Again?"
again.addEventListener('click', function(){
again.textContent = "NEW COLORS";
header.style.backgroundColor = "#232323";
colorRGB.style.backgroundColor = "#232323";
message.innerHTML = "";
changeDifficulty('easy');
});
}
else {
this.style.backgroundColor = "#232323";
message.innerHTML = "Wrong!"
}
});
}
}
I don't know when to return the function so that I don't have many functions running at the same time if I spam the newGame button causing my app to lag. I added a return; at the end of the loadEasy function but that didn't seem to do anything.
You may set a flag indicating the current gametype, then you dont need to rebind a button handler everytime, you just need to define the button as start the current game:
let gametype = "easy":
function startGame(diff){
gametype = diff || gametype;
if (gametype === 'easy'){
loadEasy();
}
else {
throw Error('unknown gametype: ' + gametype);
}
}
function loadEasy(){
//... Whatever
}
newGame.addEventListener('onclick', function(){
startGame();
});
So to start a game with the current gametype do:
startGame();
To start a different one, pass a parameter:
startGame("medium");
If this question is totally unsuitable, please forgive me. I don't know anything about programming. I should learn Javascript, I know, but it is a bit difficult for a total layman.
I have two bookmarklets and one userscript that, together, do what I need; but I need to click, wait, and click. Could they all be combined into a single bookmarklet? This is for Firefox 5, on Windows XP.
The first bookmarklet takes all links on a page that point to images and displays all these images in a single page in a new tab:
javascript:(function(){function%20I(u){var%20t=u.split('.'),e=t[t.length-1].toLowerCase();return%20{gif:1,jpg:1,jpeg:1,png:1,mng:1}[e]}function%20hE(s){return%20s.replace(/&/g,'&').replace(/>/g,'>').replace(/</g,'<').replace(/"/g,'"');}var%20q,h,i,z=open().document;z.write('<p>Images%20linked%20to%20by%20'+hE(location.href)+':</p><hr>');for(i=0;q=document.links[i];++i){h=q.href;if(h&&I(h))z.write('<p>'+q.innerHTML+'%20('+hE(h)+')<br><img%20src="'+hE(h)+'">');}z.close();})()
Then the userscript kicks in, which changes the title of the page to include [Page loaded]:
// ==UserScript==
// #name Add "loaded" to title if page is loaded
// #namespace my
// #description Indicate if a page is loaded
// #include *
// ==/UserScript==
window.addEventListener(
'load',
function (e) {
document.title += " - [Page loaded]";
},
false);
Lastly, I click the second bookmarklet, which removes all text and all images smaller than a certain size from the page, and gives it a black background. It'd like this part to kick in only after all images have been loaded (hence the "loaded" title from the userscript).
I have to put this in in-line code, because the other methods seemed to fail (neither the code button nor blockquote did anything). It would be awesome if someone could help me out! I couldn't write a single line of Javascript myself and have no idea what to do.
function wrap(image, href) {
var img = document.createElement('img');
var div = document.createElement('div');
img.src = image.src;
var node = image.parentNode;
if (!href) {
div.appendChild(img);
} else {
var a = document.createElement('a');
a.href = href;
a.appendChild(img);
div.appendChild(a);
}
return div;
}
function findNext(document) {
var res = document.evaluate('//a[#rel='
next ']', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if (res.singleNodeValue) {
return res.singleNodeValue.href;
} else {
return null;
}
}
if ('scrollMaxY' in window) {
function getScrollMaxY() {
return window.scrollMaxY;
}
} else {
function getScrollMaxY() {
return document.body.scrollHeight - window.innerHeight;
}
}
function streamify() {
var contentDiv = document.createElement('div');
var imageDiv = document.createElement('div');
var moreButton = document.createElement('input');
var style = document.createElement('style');
var iframe = document.createElement('iframe');
var errorSpan = document.createElement('span');
var retryButton = document.createElement('input');
var currentPageDiv = document.createElement('div');
var currentPageLink = document.createElement('a');
var nextUrl = findNext(document);
var occured = {};
var images = [];
var loadTimer = null;
var scrolledToBottom = false;
function extract(elem, href, images) {
switch (elem.localName) {
case 'a':
href = elem.href;
break;
case 'img':
if (!(elem.src in occured) && elem.offsetWidth > 250 && elem.offsetHeight > 300) {
images.push(wrap(elem));
occured[elem.src] = true;
}
}
var child = elem.firstElementChild;
while (child) {
extract(child, href, images);
child = child.nextElementSibling;
}
}
function loadNext() {
if (loadTimer !== null) {
window.clearTimeout(loadTimer);
}
if (nextUrl) {
loadTimer = window.setTimeout(function () {
errorSpan.style.display = '';
loadTimer = null;
}, 30000);
iframe.src = nextUrl;
}
}
style.type = 'text/css';
style.appendChild(document.createTextNode('body {background-color: black;color: white;}a {color: white;font-weight: bold;text-decoration: none;}a:hover {text-decoration: underline;}#greasemonkey-image-stream-content {text-align: center;}#greasemonkey-image-stream-content > div > div {margin-top: 2em;margin-bottom: 2em;}#greasemonkey-image-stream-content input {padding: 0.5em;font-weight: bold;}'));
contentDiv.id = 'greasemonkey-image-stream-content';
currentPageLink.appendChild(document.createTextNode('current page'));
currentPageLink.href = window.location.href;
currentPageDiv.appendChild(currentPageLink);
moreButton.type = 'button';
moreButton.value = 'More';
moreButton.disabled = true;
function handleMore() {
currentPageLink.href = iframe.src;
scrolledToBottom = false;
errorSpan.style.display = 'none';
moreButton.disabled = true;
for (var i = 0; i < images.length; ++i) {
imageDiv.appendChild(images[i]);
}
images = [];
loadNext();
}
moreButton.addEventListener('click', handleMore, false);
retryButton.type = 'button';
retryButton.value = 'Retry';
retryButton.addEventListener('click', function (event) {
loadNext();
errorSpan.style.display = 'none';
}, false);
errorSpan.style.fontWeight = 'bold';
errorSpan.style.color = 'red';
errorSpan.style.display = 'none';
errorSpan.appendChild(document.createTextNode(' Load Error '));
errorSpan.appendChild(retryButton);
iframe.style.width = '0px';
iframe.style.height = '0px';
iframe.style.visibility = 'hidden';
iframe.addEventListener('load', function (event) {
if (loadTimer !== null) {
window.clearTimeout(loadTimer);
}
errorSpan.style.display = 'none';
nextUrl = findNext(iframe.contentDocument);
extract(iframe.contentDocument.body, null, images);
if (images.length == 0 && nextUrl) {
loadNext();
moreButton.disabled = true;
} else {
moreButton.disabled = !nextUrl && images.length == 0;
if (scrolledToBottom && (nextUrl || images.length > 0)) {
handleMore();
}
}
}, false);
extract(document.body, null, images);
for (var i = 0; i < images.length; ++i) {
imageDiv.appendChild(images[i]);
}
images = [];
contentDiv.appendChild(style);
contentDiv.appendChild(currentPageDiv);
contentDiv.appendChild(imageDiv);
contentDiv.appendChild(moreButton);
contentDiv.appendChild(errorSpan);
contentDiv.appendChild(iframe);
var elem = document.documentElement.firstElementChild;
while (elem) {
switch (elem.localName) {
case 'head':
var child = elem.firstElementChild;
while (child) {
var next = child.nextElementSibling;
if (child.localName != 'title') {
elem.removeChild(child);
}
child = next;
}
break;
case 'body':
while (elem.firstChild) {
elem.removeChild(elem.firstChild);
}
}
elem = elem.nextElementSibling;
}
window.addEventListener('scroll', function (event) {
if (window.scrollY >= getScrollMaxY()) {
scrolledToBottom = true;
moreButton.click();
}
}, false);
document.body.appendChild(contentDiv);
loadNext();
}
streamify();
void(0)
(function(){
var a=Array.filter(document.getElementsByTagName('a'),function(e){
var h=e.href.split('.').pop().toLowerCase();
return {gif:1,jpg:1,jpeg:1,png:1,mng:1}[h];
}),b=document.getElementsByTagName('body')[0],i=0,l=a.length;
b.innerHTML='';
b.style.background='#000';
b.style.color='#ddd'
for(i;i<l;i++){
var t=a[i].href,p=document.createElement('img'),s=document.createElement('div');
s.innerHTML=t;
p.src=t;
b.appendChild(p);
b.appendChild(s);
}
})()
Here it is compressed
javascript:(function(){var c=Array.filter(document.getElementsByTagName("a"),function(a){return{gif:1,jpg:1,jpeg:1,png:1,mng:1}[a.href.split(".").pop().toLowerCase()]}),a=document.getElementsByTagName("body")[0],b=0,g=c.length;a.innerHTML="";a.style.background="#000";a.style.color="#ddd";for(b;b<g;b++){var d=c[b].href,e=document.createElement("img"),f=document.createElement("div");f.innerHTML=d;e.src=d;a.appendChild(e);a.appendChild(f)}})();
One that waits for each image to load. Added error detection.
(function(){
var a=Array.filter(document.getElementsByTagName('a'),function(e){
return {gif:1,jpg:1,jpeg:1,png:1,mng:1}[e.href.split('.').pop().toLowerCase()];
}),b=document.getElementsByTagName('body')[0],i=0,l=a.length;
b.innerHTML='';
b.style.background='#000';
b.style.color='#ddd'
add(0);
function add(i){
var img=new Image(),t=a[i].href,p=document.createElement('img'),s=document.createElement('div');
img.src=t;
img.onload=function(){
s.innerHTML=t;
p.src=t;
b.appendChild(p);
b.appendChild(s);
++i<a.length?add(i):'';
};
img.onerror=function(){
++i<a.length?add(i):'';
};
}
})()
And the minified version.
javascript:(function(){function d(b){var e=new Image,c=f[b].href,g=document.createElement("img"),h=document.createElement("div");e.src=c;e.onerror=function(){++b<f.length&&d(b)};e.onload=function(){h.innerHTML=c;g.src=c;a.appendChild(g);a.appendChild(h);++b<f.length&&d(b)}}var f=Array.filter(document.getElementsByTagName("a"),function(a){return{gif:1,jpg:1,jpeg:1,png:1,mng:1}[a.href.split(".").pop().toLowerCase()]}),a=document.getElementsByTagName("body")[0];a.innerHTML="";a.style.background="#000";a.style.color="#ddd";d(0)})();
Here is some test HTML
<a href='http://mozcom-cdn.mozilla.net/img/covehead/about/logo/download/logo-only-preview.png'>Firefox</a>
<a href='http://ie.microsoft.com/testdrive/Graphics/IEBeatz/assets/ie-logo-small.png'>IE</a>
<a href='http://code.google.com/tv/images/chrome-logo.png'>Chrome</a>
I did not add limiter on size of images because I was not sure if it was necessary and I wasn't sure what size limit you wanted.
I'm getting WebResource error in my asp.Net page:
var __pendingCallbacks = new Array();
Microsoft JScript runtime error: 'Array' is undefined
I have no idea what might cause this to happen. Isn't Array part of Javascript itself? Any help would be appreciated.
EDIT
The problem is that this isn't code that I wrote, it's built into the page structure in asp.Net.
EDIT
The problem only occurs in IE9 and only when run in IE9 mode (not compatibility)
Code:
(This is dynamically generated code, sorry for the length. Problem is about halfway down)
function WebForm_PostBackOptions(eventTarget, eventArgument, validation, validationGroup, actionUrl, trackFocus, clientSubmit) {
this.eventTarget = eventTarget;
this.eventArgument = eventArgument;
this.validation = validation;
this.validationGroup = validationGroup;
this.actionUrl = actionUrl;
this.trackFocus = trackFocus;
this.clientSubmit = clientSubmit;
}
function WebForm_DoPostBackWithOptions(options) {
var validationResult = true;
if (options.validation) {
if (typeof(Page_ClientValidate) == 'function') {
validationResult = Page_ClientValidate(options.validationGroup);
}
}
if (validationResult) {
if ((typeof(options.actionUrl) != "undefined") && (options.actionUrl != null) && (options.actionUrl.length > 0)) {
theForm.action = options.actionUrl;
}
if (options.trackFocus) {
var lastFocus = theForm.elements["__LASTFOCUS"];
if ((typeof(lastFocus) != "undefined") && (lastFocus != null)) {
if (typeof(document.activeElement) == "undefined") {
lastFocus.value = options.eventTarget;
}
else {
var active = document.activeElement;
if ((typeof(active) != "undefined") && (active != null)) {
if ((typeof(active.id) != "undefined") && (active.id != null) && (active.id.length > 0)) {
lastFocus.value = active.id;
}
else if (typeof(active.name) != "undefined") {
lastFocus.value = active.name;
}
}
}
}
}
}
if (options.clientSubmit) {
__doPostBack(options.eventTarget, options.eventArgument);
}
}
var __pendingCallbacks = new Array();
var __synchronousCallBackIndex = -1;
function WebForm_DoCallback(eventTarget, eventArgument, eventCallback, context, errorCallback, useAsync) {
var postData = __theFormPostData +
"__CALLBACKID=" + WebForm_EncodeCallback(eventTarget) +
"&__CALLBACKPARAM=" + WebForm_EncodeCallback(eventArgument);
if (theForm["__EVENTVALIDATION"]) {
postData += "&__EVENTVALIDATION=" + WebForm_EncodeCallback(theForm["__EVENTVALIDATION"].value);
}
var xmlRequest,e;
try {
xmlRequest = new XMLHttpRequest();
}
catch(e) {
try {
xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
}
}
var setRequestHeaderMethodExists = true;
try {
setRequestHeaderMethodExists = (xmlRequest && xmlRequest.setRequestHeader);
}
catch(e) {}
var callback = new Object();
callback.eventCallback = eventCallback;
callback.context = context;
callback.errorCallback = errorCallback;
callback.async = useAsync;
var callbackIndex = WebForm_FillFirstAvailableSlot(__pendingCallbacks, callback);
if (!useAsync) {
if (__synchronousCallBackIndex != -1) {
__pendingCallbacks[__synchronousCallBackIndex] = null;
}
__synchronousCallBackIndex = callbackIndex;
}
if (setRequestHeaderMethodExists) {
xmlRequest.onreadystatechange = WebForm_CallbackComplete;
callback.xmlRequest = xmlRequest;
xmlRequest.open("POST", theForm.action, true);
xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
xmlRequest.send(postData);
return;
}
callback.xmlRequest = new Object();
var callbackFrameID = "__CALLBACKFRAME" + callbackIndex;
var xmlRequestFrame = document.frames[callbackFrameID];
if (!xmlRequestFrame) {
xmlRequestFrame = document.createElement("IFRAME");
xmlRequestFrame.width = "1";
xmlRequestFrame.height = "1";
xmlRequestFrame.frameBorder = "0";
xmlRequestFrame.id = callbackFrameID;
xmlRequestFrame.name = callbackFrameID;
xmlRequestFrame.style.position = "absolute";
xmlRequestFrame.style.top = "-100px"
xmlRequestFrame.style.left = "-100px";
try {
if (callBackFrameUrl) {
xmlRequestFrame.src = callBackFrameUrl;
}
}
catch(e) {}
document.body.appendChild(xmlRequestFrame);
}
var interval = window.setInterval(function() {
xmlRequestFrame = document.frames[callbackFrameID];
if (xmlRequestFrame && xmlRequestFrame.document) {
window.clearInterval(interval);
xmlRequestFrame.document.write("");
xmlRequestFrame.document.close();
xmlRequestFrame.document.write('<html><body><form method="post"><input type="hidden" name="__CALLBACKLOADSCRIPT" value="t"></form></body></html>');
xmlRequestFrame.document.close();
xmlRequestFrame.document.forms[0].action = theForm.action;
var count = __theFormPostCollection.length;
var element;
for (var i = 0; i < count; i++) {
element = __theFormPostCollection[i];
if (element) {
var fieldElement = xmlRequestFrame.document.createElement("INPUT");
fieldElement.type = "hidden";
fieldElement.name = element.name;
fieldElement.value = element.value;
xmlRequestFrame.document.forms[0].appendChild(fieldElement);
}
}
var callbackIdFieldElement = xmlRequestFrame.document.createElement("INPUT");
callbackIdFieldElement.type = "hidden";
callbackIdFieldElement.name = "__CALLBACKID";
callbackIdFieldElement.value = eventTarget;
xmlRequestFrame.document.forms[0].appendChild(callbackIdFieldElement);
var callbackParamFieldElement = xmlRequestFrame.document.createElement("INPUT");
callbackParamFieldElement.type = "hidden";
callbackParamFieldElement.name = "__CALLBACKPARAM";
callbackParamFieldElement.value = eventArgument;
xmlRequestFrame.document.forms[0].appendChild(callbackParamFieldElement);
if (theForm["__EVENTVALIDATION"]) {
var callbackValidationFieldElement = xmlRequestFrame.document.createElement("INPUT");
callbackValidationFieldElement.type = "hidden";
callbackValidationFieldElement.name = "__EVENTVALIDATION";
callbackValidationFieldElement.value = theForm["__EVENTVALIDATION"].value;
xmlRequestFrame.document.forms[0].appendChild(callbackValidationFieldElement);
}
var callbackIndexFieldElement = xmlRequestFrame.document.createElement("INPUT");
callbackIndexFieldElement.type = "hidden";
callbackIndexFieldElement.name = "__CALLBACKINDEX";
callbackIndexFieldElement.value = callbackIndex;
xmlRequestFrame.document.forms[0].appendChild(callbackIndexFieldElement);
xmlRequestFrame.document.forms[0].submit();
}
}, 10);
}
This happens because we have this setup
<collapsible panel>
<iframe>
<script>
</script>
</iframe>
</collapsible panel>
When the page loads, the panel being shown forces the script inside the iframe to be dragged through the DOM before the javascript libraries are loaded. This seems to be a change in that was made for IE9. I have yet to fine a way around this issue but at least I know the cause. A temporary workaround is to force the compatibility of the page to IE8 using a meta tag in case anybody else runs into this issue.
The problem was fixed when I removed the SRC attribute from the iframe and I added onOpen event to jQuery's dialog:
open: function(){
document.getElementById("iframename").src = "page.aspx";
}
I am trying to make a table inside a table so I can organize stuff in the right place. But I simple cannot set the table width. Here is a picture of the table
and circled in red is the table inside table that I've created, it has one row 3 columns:
and here is the code I've used to create the 2nd table:
// attack type
var farmTableAttack = dom.cn("table");
var ftableBodyAttack = dom.cn("tbody");
farmTableAttack.style.tableLayout = "fixed";
farmTableAttack.width = "20px";
ftableBodyAttack.setAttribute("colspan", 4);
ftableBodyAttack.setAttribute("width", 50);
tableRow = dom.cn("tr");
tableCol = dom.cn("th");
tableCol.setAttribute("colspan", 2);
tableCol.innerHTML = "Attack: ";
tableRow.appendChild(tableCol);
tableCol = dom.cn("th");
tableCol.setAttribute("colspan", 1);
tableCol.innerHTML = "N";
var Button = createInputButton("checkbox");
Button.id = "attackTypeN";
Button.checked = GM_getValue("checkBoxAttackType_"+suffixLocal, "tabela") == "normal";
Button.addEventListener("click", function() {
if (Button.checked) {
Button.checked = false;
GM_setValue("checkBoxAttackType_"+suffixLocal, "tabela");
}
else if (document.getElementbyId("attackTypeA").checked == true) {
document.getElementbyId("attackTypeA").checked = false;
GM_setValue("checkBoxAttackType_"+suffixLocal, "normal");
}
}, false);
tableCol.appendChild(Button);
tableRow.appendChild(tableCol);
tableCol = dom.cn("th");
tableCol.setAttribute("colspan", 1);
tableCol.innerHTML = "A";
var Button = createInputButton("checkbox");
Button.id = "attackTypeA";
Button.checked = GM_getValue("checkBoxAttackType_"+suffixLocal, "tabela") == "assalto";
Button.addEventListener("click", function() {
if (Button.checked) {
Button.checked = false;
GM_setValue("checkBoxAttackType_"+suffixLocal, "tabela");
}
else if (document.getElementbyId("attackTypeN").checked == true) {
document.getElementbyId("attackTypeN").checked = false;
GM_setValue("checkBoxAttackType_"+suffixLocal, "assalto");
}
}, false);
tableCol.appendChild(Button);
//append the row in the table
tableRow.appendChild(tableCol);
ftableBodyAttack.appendChild(tableRow);
farmTableAttack.appendChild(ftableBodyAttack);
I want the second table to be inside this place (this is the original table without the 2nd table coded into it):
I simple don't know what to do.
another option would be to fix the stuff inside that circle region of the original table without having to use another table, I just donĀ“t know how to do that.
dom.cn:
var dom = new DOMUtils();
//DOM functions
function DOMUtils(doc, ctxt, html) { // from FranMod
this.cn = function(tag, html) {
var elem = this.document.createElement(tag);
if (html)
elem.innerHTML = html;
return elem;
}
this.ct = function(text) {
return this.document.createTextNode(text);
}
this.id = function(id) {
return this.document.getElementById(id);
}
this.tag = function(tag) {
return this.document.getElementsByTagName(tag);
}
this.xs = function(xpath) {
var res = this.document.evaluate(xpath, this.context, null,
XPathResult.FIRST_ORDERED_NODE_TYPE, null);
return res.singleNodeValue;
}
this.xa = function(xpath) {
var arr = [];
var xpr = this.document.evaluate(xpath, this.context, null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; item = xpr.snapshotItem(i); i++)
arr.push(item);
return arr.length == 0 ? null : arr;
}
this.xo = function(xpath) {
var ret = this.document.evaluate(xpath, this.context, null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
return ret; //no snapshot
}
this.find = function(xpath, xpres, doc) {
if (!doc)
doc = document;
else if (typeof doc == 'string')
doc = cn('div', doc);
var ret = document.evaluate(xpath, doc, null, xpres, null);
return xpres == XPFirst ? ret.singleNodeValue : ret;
}
this.get = function(id, doc) {
if (!doc)
doc = document;
return doc.getElementById(id);
}
if (!doc)
doc = document;
if (!ctxt)
ctxt = doc;
if (html) {
this.document = doc.implementation.createDocument('', '', null);
this.context = doc.createElement('div');
this.context.innerHTML = html;
ansDoc.appendChild(this.context);
} else {
this.document = doc;
this.context = ctxt;
}
}
well if all fails take the three items. put the cell to display block.
put each item into a div with css float: left; works for me ...
If that subtable will only ever be one row, consider NOT using a subtable and instead adding additional cells in that row. For other rows, use colspan to span all of those former subtable cells:
<table>
<tr><td colspan='3'>Cell 1</td> <td>0</td></tr>
<tr><td colspan='3'>Cell 2</td> <td>0</td></tr>
<tr><td>'subcell'a</td><td>'subcell'b</td><td>'subcell'c</td> <td>0</td></tr>
</table>
following helle suggestion I used css float left and it solved the problem. here is the final code:
Button = dom.cn("div");
Button.setAttribute("style", "width:10px;float:left;");
Button.innerHTML = " ";
tableCol.appendChild(Button);
Button = dom.cn("div");
Button.setAttribute("style", "float:left;");
Button.innerHTML = "Attack type: ";
tableCol.appendChild(Button);
var Button = createInputButton("checkbox");
Button.id = "attackTypeN";
Button.checked = GM_getValue("checkBoxAttackType_"+suffixLocal, "tabela") == "normal";
Button.addEventListener("click", function() {
if (Button.checked) {
Button.checked = false;
GM_setValue("checkBoxAttackType_"+suffixLocal, "tabela");
}
else if (document.getElementbyId("attackTypeA").checked == true) {
document.getElementbyId("attackTypeA").checked = false;
GM_setValue("checkBoxAttackType_"+suffixLocal, "normal");
}
}, false);
Button.setAttribute("style", "float:left;");
tableCol.appendChild(Button);
Button = dom.cn("div");
Button.setAttribute("style", "float:left;");
Button.innerHTML = "N";
tableCol.appendChild(Button);
var Button = createInputButton("checkbox");
Button.id = "attackTypeA";
Button.checked = GM_getValue("checkBoxAttackType_"+suffixLocal, "tabela") == "assalto";
Button.addEventListener("click", function() {
if (Button.checked) {
Button.checked = false;
GM_setValue("checkBoxAttackType_"+suffixLocal, "tabela");
}
else if (document.getElementbyId("attackTypeN").checked == true) {
document.getElementbyId("attackTypeN").checked = false;
GM_setValue("checkBoxAttackType_"+suffixLocal, "assalto");
}
}, false);
Button.setAttribute("style", "float:left;");
tableCol.appendChild(Button);
Button = dom.cn("div");
Button.setAttribute("style", "float:left;");
Button.innerHTML = "A";
tableCol.appendChild(Button);
//append the row in the table
tableRow.appendChild(tableCol);