I am creating an application with an acrobat dynamic stamp pop up window and I would like it to reflect the stamp comment. My dynamic stamp has some JavaScript that will generate a pop-up window. The information on the pop-up window text field will become part of the stamp. I'm trying to add the contents of the pop-up window in two areas.
On the Dynamic stamp (done)
On the Stamp Comments (need help)
Below I added the JavaScript I currently have. If anyone here can help me find a solution, I'd really appreciate it.
var builder =
{
// These map to Text Fields in the Stamp
textBoxes :
[
{ field:"IsoNum", description:"Isometric Number:", default:function() { return Collab.user; } }
]
}
/*********** belongs to: AcroForm:Calculation:Calculate ***********/
// SEE GLOBAL JAVASCRIPT SECTION FOR CUSTOMIZATION
if (event.source.forReal)
{
var stampDialog = CreateDialog(builder);
app.execDialog(stampDialog);
for (var i = 0; i < builder.textBoxes.length; ++i)
{
var t = builder.textBoxes[i];
this.getField(t.field).value = stampDialog.textBoxResults[i];
}
}
function CreateDialog(dialogBuilder)
{
var sd = new Object();
sd.builder = dialogBuilder;
sd.textBoxResults = new Array();
var optionsElements = new Array();
for (var i = 0; i < dialogBuilder.textBoxes.length; ++i)
{
var view = new Object();
view.type = "view";
view.align_children = "align_row";
view.elements = new Array();
var t = dialogBuilder.textBoxes[i];
var s = new Object();
s.type = "static_text";
s.item_id = "sta" + i;
s.name = t.description;
s.width = 110;
var e = new Object();
e.type = "edit_text";
e.item_id = "edt" + i;
e.width = 150;
view.elements[0] = s;
view.elements[1] = e;
optionsElements[i] = view;
}
var optionsCluster =
{
type: "cluster",
name: "Options",
elements: optionsElements
};
sd.initialize = function(dialog)
{
var init = new Object();
for (var i = 0; i < this.builder.textBoxes.length; ++i)
{
var t = this.builder.textBoxes[i];
var id = "edt" + i;
init[id] = t.default();
}
dialog.load(init);
};
sd.commit = function(dialog)
{
var res = dialog.store();
for (var i = 0; i < this.builder.textBoxes.length; ++i)
{
var t = this.builder.textBoxes[i];
var id = "edt" + i;
this.textBoxResults[i] = res[id];
}
};
sd.description =
{
name: "Stamp Dialog",
elements:
[
{
type: "view",
align_children: "align_fill",
elements:
[
optionsCluster
]
},
{
type: "ok"
}
]
};
return sd;
}
I don't have any specific code but it seems you understand enough Acrobat JavaScript to understand my instructions.
The dialog code runs between the time you select and position the stamp and when the stamp actually gets created. For that reason, you can't set the contents of the note directly in your code because the stamp annotation doesn't actually exist until your commit function finishes. What you have to do instead is create a function that sets the contents of the note inside a timeOut and use a delay of about a half second.
I want to make a form for a live D3 sankey diagram Link to source code here but I want to use firebase not JSON.
// load the data
d3.json("ConTech.json", function(error, graph) {
var nodeMap = {};
graph.nodes.forEach(function(x) { nodeMap[x.name] = x; });
graph.links = graph.links.map(function(x) {
return {
source: nodeMap[x.source],
target: nodeMap[x.target],
value: x.value
};
});
sankey
.nodes(graph.nodes)
.links(graph.links)
.layout(32);
The above is what I need to edit to refer to my firebase database.
This is my data from my form in firebase
This is my attempt to extract the data into an array and seems to give me what I need.
function gotData(data) {
//console.log(data.val());
var links = data.val();
var nodes = data.val()
var lkeys = Object.keys(links);
var nkeys = Object.keys(nodes);
//console.log(keys);
for (var i = 0; i < lkeys.length; i++) {
var k = lkeys[i];
var source = links[k].source;
var target = links[k].target;
if (source !== undefined){
slist.push(source);
}
if (target !== undefined){
tlist.push(target);
}
//console.log(source, target);
}
for (var x = 0; x < nkeys.length; x++) {
var kn = nkeys[x];
var name = nodes[kn].name;
if (name !== undefined){
nlist.push(name);
}
//console.log(name);
}
//console.log(slist, tlist, nlist);
//console.log(source, target, name);
}
function errData(err) {
console.log('broke!');
console.log('err');
}
function getData () {
console.log(slist, tlist, nlist);
}
However im struggling to swap
"d3.json("ConTech.json", function(error, graph)"
for the right implementaiton.
I want to customize an autocomplete function to Codemirror.
So I have build this code:
CodeMirror.commands.autocomplete = function (cm) {
var arrayTabNONDefault = new Array();
var stringaCampi = null;
var arrayTabellaCampo = null;
var textVal = cm.getValue();
textVal = textVal.toUpperCase();
var res = textVal.match("SELECT(.*)FROM");
if (res != null) {
stringaCampi = res[1];
arrayTabellaCampo = stringaCampi.split(",");
var nomeTab = null;
for (var i = 0; i < arrayTabellaCampo.length; i++) {
nomeTab = (arrayTabellaCampo[i].split(".")[0]).trim();
if (hintTables[nomeTab] == null)
hintTables[nomeTab] = new Array();
} //FINE FOR
} //FINE IF
CodeMirror.showHint(cm, CodeMirror.hint.sql, {
tables: hintTables
});
cm.on("beforeChange", function (cm, change) {
var before = cm.getRange({ line: 0, ch: 0 }, change.from);
var text = cm.getRange(change.from, change.to);
var after = cm.getRange(change.to, { line: cm.lineCount() + 1, ch: 0 });
if (before.indexOf("FROM") !== -1)
// alert("Ho scritto FROM");
console.log("before change", before, text, after);
});
cm.on("change", function (cm, change) {
var from = change.from;
var text = change.text.join("\n");
var removed = change.removed.join("\n");
var to = cm.posFromIndex(cm.indexFromPos(from) + text.length);
var before = cm.getRange({ line: 0, ch: 0 }, from);
var after = cm.getRange(to, { line: cm.lineCount() + 1, ch: 0 });
if (before.indexOf("FROM") !== -1)
console.log("after change", before, removed, text, after);
});
} //FINE ESTENSIONE
This is the content of hintTables
var hintTables = { "#T_TF_FilesList": ["FilesListHeaderID", "NumRecord", "FileTypeID", "FileID", "FilesListHeaderID", "NumRecord"],
"#T_TF_SelectedItems": ["EventHeaderID", "ItemType", "ItemID1", "ItemID2", "EventHeaderID", "ItemType", "ItemID1", "ItemID2"],
"#T_TFT_CacheSearchCriteriaHeaders": ["ID", "SyncDate", "FileTypeID", "CriteriaExpressionString", "CriteriaExpressionHash", "PageRecordsNumber", "PageNumber", "NumFiles"]
};
So I want that the system should propose a list of this table after I write FROM, or the system should to propose a list of stored procedures after I write EXECUTE.
It is possible to do this?
Are you trying to customize the SQL hint addon? If so, you should make changes inside sql-hint.js (under codemirror/addon/hint).
Basically what you should do is:
1.In your app.js (whatever js file for your main logic) call editor.showHint({hint: CodeMirror.hint.sql) on "change" event;
2.Inside sql-hint.js, return {list: hintTables, from: somePos, to: somePos} when the user types FROM or EXECUTE which can be detected by regular expression or inspecting the tokens at the line. I made up some code for your reference:
var cursor = editor.getCursor();
var tokenAtCursor = editor.getTokenAt(cursor);
if (tokenAtCursor.type == "FROM-and-EXECUTE")
return {list: hintTables,
from: CodeMirror.Pos(cur.line, tokenAtCursor.start),
to: CodeMirror.Pos(cur.line, tokenAtCursor.end)};
If I misunderstand your question and this answer is not helpful, please tell me and I will delete it.
I want to get the color(red) below the picture.
enter image description here
I use next code, but I don't know next step.
run main function.
var mainCalendarName = 'main';
function main() {
var calendar = getCalendar();
if (calendar == null) {
return;
}
var now = new Date();
var calendarEventArray = calendar.getEventsForDay(now);
Logger.log('current color = ' + calendarEventArray[0].getColor()); // not use!!!
//log 'current color = #FF0000'
}
function getCalendar() {
var calendarList = CalendarApp.getAllCalendars();
for (i in calendarList) {
if (mainCalendarName === calendarList[i].getName()) {
return calendarList[i];
}
}
return null;
}
First of all you need to enable the Advanced Google Services.
Please see here description how do that.
Then the following code will do the job
function main(){
var now = new Date();
var events = Calendar.Events.list("main", {
timeMin: now.toISOString(),
singleEvents: true,
orderBy: 'startTime',
maxResults: 10
});
for (var i = 0; i < events.items.length; i++) {
Logger.log(events.items[i].colorId); //Here the color of the specific event
}
}
I successfully create a organizational chart with BasicPrimitives-orgChart but I have a problem with the node's preview when you do mouse hover.
Sometimes randomly gray "preview" node appears on the left of the screen.
Sometimes the preview shows correctly
But somethimes appear the gray node
My fucntion to chart create
function buildChart() {
var options = new primitives.orgdiagram.Config();
var jsonString = $("[id$=txhDat]").val();
var datos = JSON.parse(jsonString);
var arrayItem = [];
for (index = 0; index < datos.length; index++) {
var objUbica = datos[index];
var item = new itemUbica(objUbica.cve, objUbica.name, objUbica.parent, objUbica.index);
var itemFinal = new primitives.orgdiagram.ItemConfig(item);
arrayItem[arrayItem.length] = itemFinal;
}
options.items = arrayItem;
options.cursorItem = 0;
options.templates = [getTemplateUbica()];
options.onItemRender = onTemplateRender;
options.hasButtons = primitives.common.Enabled.True;
options.hasSelectorCheckbox = primitives.common.Enabled.False;
options.onButtonClick = function (e, data) {
switch (data.name) {
case "move":
$("[id$=]")
dialogMoveOp(data.context.cveUbica, data.context.ubica);
break;
}
};
jQuery("#divChart").orgDiagram(options);
}
Also this happend just after the first render I dont manipulate anything in the DOM.