Phonegap - How to add collapasible-set in for loop? - sql

I'm stuck. How do I add collapsible-set into for loop? I have tried this code below, but it only shows the h3 and p field. The collapsible-set doesn't work. Please help.
function querySuccess(tx, results) {
var len = results.rows.length;
var display ="";
display +="<div data-role='collapsible-set'>";
for (var i=0; i<len; i++){
display +="<div data-role='collapsible' data-collapsed='true'>";
display += "<h3>"+ results.rows.item(i).title +"</h3>";
display += "<p>"+ results.rows.item(i).line1 +"</p>";
display +="</div>";
}
display +="</div>";
document.getElementById("news_DB").innerHTML = display;
}

try this
$.each(results.rows,function(index){
var row = results.rows.item(index);
$('<div data-role="collapsible"><h3>'+row['col_name']+'</h3><p>Content</p></div>').appendTo('[data-role="content"]');
$('div[data-role=collapsible]').collapsible({theme:'c',refresh:true});
});
}

Related

Change line spacing in a cell in a Google Doc using Google App Script

I have a Google Doc which has a table that needs updating weekly and content to be inserted from a spreadsheet. I successfully paste in the correct data into each cell but the lines are spaced at 1.15 not single spaced.
Any ideas on how to accomplish this?
Here is the code I have tried:
const doc = DocumentApp.getActiveDocument();
var paddingTop = 1.5; // You can adjust the height by modifying this.
var paddingBottom = 1.5; // You can adjust the height by modifying this.
var tables = doc.getBody().getTables();
tables.forEach(table => {
for (var r = 0; r < table.getNumRows(); r++) {
var row = table.getRow(r);
for (var c = 0; c < row.getNumCells(); c++) {
row.getCell(c).setPaddingTop(paddingTop).setPaddingBottom(paddingBottom);
var p=row.getCell(c);
Logger.log(c)
for(i=0;i<p.length; i++){
p[i].setLineSpacing(100);
}
}
}
});
This does not change the line spacing inside the cells at all.
This is what worked for me:
var paddingTop = 1.5; // You can adjust the height by modifying this.
var paddingBottom = 1.5; // You can adjust the height by modifying this.
var paraStyle = {};
paraStyle[DocumentApp.Attribute.LINE_SPACING] = 1;
var tables = doc.getBody().getTables();
tables.forEach(table => {
for (var r = 0; r < table.getNumRows(); r++) {
var row = table.getRow(r);
for (var c = 0; c < row.getNumCells(); c++) {
var cell=row.getCell(c);
cell.setPaddingTop(paddingTop)
cell.setPaddingBottom(paddingBottom);
var items = cell.getNumChildren();
for (var i = 0; i < items; i++){
var paraInCell = cell.getChild(i).asParagraph();
paraInCell.setAttributes(paraStyle);
}
}
}
});

Adobe InDesign script to affect only selected Table/Text Frame

I am new to scripting and copied this one below and it works great but not all tables are the same in the document and I just want to affect the selected tables/text frames.
Is there an easy way to make this code work the way I am looking to do.
var myDoc = app.activeDocument;
var myWidths = [.5,.35,.44,.44];
for(var T=0; T < myDoc.textFrames.length; T++){
for(var i=0; i < myDoc.textFrames[T].tables.length; i++){
for(var j=0; j < myWidths.length; j++){
myDoc.textFrames[T].tables[i].columns[j].width = myWidths[j];
}
}
}
Thanks for any help, just starting to dive into InDesign Scripting and understand it.
Yes, it can be done quite easy:
var myWidths = [.5,.35,.44,.44];
var sel = app.selection;
if (sel.length != 1) exit();
var frame = sel[0];
if (frame.constructor.name != 'TextFrame') exit();
for (var i = 0; i < frame.tables.length; i++) {
for (var j = 0; j < myWidths.length; j++) {
frame.tables[i].columns[j].width = myWidths[j];
}
}
It will work for one selected text frame.
If you need to process several selected frames here is another variant of the code:
var myWidths = [.5,.35,.44,.44];
var frames = app.selection
var f = frames.length
while(f--) {
if (frames[f].constructor.name != 'TextFrame') continue;
var tables = frames[f].tables;
var t = tables.length;
while(t--) {
var table = tables[t];
var c = table.columns.length;
while(c--) {
table.columns[c].width = myWidths[c];
}
}
}

Changes reflecting in payload but is not getting applied on target widget in workdetails page in casemanager 5.2.1

In Workdetails page, under ‘Documents’ tab, when I set the alignment to ‘center’ from ‘right’ for the column value, its getting updated in payload but is not actually getting applied on target widget.
I have tried thru controller/Grid as well but its not getting set. Attached snap of same. A pointer in this regard would be of immense help.
Here is the snip:
var callbackFolderContent = function (resultset)
{
var classText = 'Abc';
var found = 0;
for (var i=0; i < resultset.length; i++)
{
var items = resultset[i].resultSet.items;
for (var j=0; j < items.length; j++)
{
var pos = id.indexOf(classText);
if(pos !== -1)
{
var PC= items[j].resultSet.structure.cells[0][3];
if(PC.styles=="text-align:right;")
{
PC.styles="text-align:center;";
var NEWpc=PC.styles; //Its reflecting in payload.
alert("Changed aligning to: "+NEWpc);
}
found ++;
} //end f if loop
} //end of inner for loop
} //end of for loop
if (found < 1)
{
payload.stateCode = 4;
payload.hideMessage=true;
abort({silent:true});
}
else
{
complete();
}
}; //end of callback function

Telegram bot dynamic keyboard in c# every button on one row

Hi i new in stackoverflow...
I want to make a keyboard(replykeyboardmarkup) that read data from the database and every button on every row of the keyboard to show .
I read this link:
create dynamic Keyboard telegram bot in c# , MrRoundRobin API
But all button show in one row...
What i can do?
Tnx!
like this image
try this
private static InlineKeyboardButton[][] GetInlineKeyboard(string[] stringArray)
{
var keyboardInline = new InlineKeyboardButton[stringArray.Length][];
var keyboardButtons = new InlineKeyboardButton[stringArray.Length];
for (var i = 0; i < stringArray.Length; i++)
{
keyboardButtons[i] = new InlineKeyboardButton
{
Text = stringArray[i],
CallbackData = stringArray[i],
};
}
for (var j = 1; j <= stringArray.Length;j++)
{
keyboardInline[j-1] = keyboardButtons.Take(1).ToArray();
keyboardButtons = keyboardButtons.Skip(1).ToArray();
}
return keyboardInline;
}

How do I programmatically capture and replicate Ai path shape?

I'm using ExtendScript for scripting Adobe Illustrator. I was wondering if there was a sneaky way or a script available to programmatically capture and then replicate a path shape, sort of JavaScript's .toSource() equivalent.
Thanks
Try this:
main();
function main(){
var doc = app.activeDocument; // get the active doc
var coords = new Array(); // make a new array for the coords of the path
var directions = new Array();
var sel = doc.selection[0];// get first object in selection
if(sel == null) {
// check if something is slected
alert ("You need to sevlect a path");
return;
}
var points = sel.pathPoints;// isolate pathpoints
// loop points
for (var i = 0; i < points.length; i++) {
// this could be done in one lines
// just to see whats going on line like
//~ coords.push(new Array(points[i].anchor[0],points[i].anchor[1]));
var p = points[i]; // the point
var a = p.anchor; // his anchor
var px = a[0];// x
var py = a[1]; // y
var ldir = p.leftDirection;
var rdir = p.rightDirection;
directions.push(new Array(ldir,rdir));
coords.push(new Array(px,py));// push into new array of array
}
var new_path = doc.pathItems.add(); // add a new pathitem
new_path.setEntirePath(coords);// now build the path
// check if path was closed
if(sel.closed){
new_path.closed = true;
}
// set the left and right directions
for(var j = 0; j < new_path.pathPoints.length;j++){
new_path.pathPoints[j].leftDirection = directions[j][0];
new_path.pathPoints[j].rightDirection = directions[j][1];
}
}