I need to go through an InDesign document a convert all the auto page number special characters to their actual value.
So on each page, find a auto page number symbol and replace it with the value it evaluates to.
I haven't been able to find a script that does that - nor am I an inDesign scripting expert.
Has anyone got a solution for this?
Ok, I think I've worked it out.
main();
function main(){
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
app.findGrepPreferences.findWhat="~N";
var FindGrep=app.activeDocument.findGrep();
for(i=0; i<FindGrep.length; i++)
{
var item = FindGrep[i];
var page = item.parentTextFrames[0].parentPage;
item.contents = page.name;
}
alert("done");
}
Struggled to find any valuable documentation from Adobe.
This really helped: http://jongware.mit.edu/idcs5/
As well as this SO question: Get current page number in InDesign CS5 from Javascript
Edit: If your page numbering is in a master, you will need to "override all page master items" (check the pages palette)
Edit 2: This worked on inDesign 5.5 (not sure about 6)
Edit 3: Works also on InDesign CC
Related
i am new with wix code so i need to know how can i use buttons that will increment text with 1 when the user click and then i need the number of clicks to be stored in database and then maker this number the same when the page is reloaded.
thanks in advance.
var num = 0;
$w.onReady(function () {
$w("#text2").text= num.toString();
$w('#button1').onClick(function (){
$w("#button1").link = "http://wix.com";
num ++;
$w("#text2").text= num.toString();
$w("#dataset1").setFieldValue("number", $w("#text2").text);
$w("#dataset1").save();
});
});
Rajaa,
is the field $w(“#text2”) connected to your dataset using the Wix Editor connection panel?
The answer to this question depends on how your page elements are wired up. If they are then you need to be careful what you change in code and when because the javascript you write might be impacted by the Wix Dataset engine working automatically due to the element binding.
I've been trying to copy a list of the open tab titles in Firefox, but I cannot seem to find a solution.
The closest I've came is by using: https://addons.mozilla.org/en-us/firefox/addon/send-tab-urls/
But this add-on copies other details in addition to the tab titles.
I cannot find a solution anywhere for this simple task.
Does anybody have any tips on how to accomplish this?
You can use the Multiple Tab Handler addon. Right click, then Copy URI of All Tabs. You will need to tweak the addon's options to output the result in the format you want.
Or alternatively, open up Firefox's Scratchpad developer tool (Shift-F4) and use the following code in browser environment.
// -sp-context: browser
var tabs=Array.from(gBrowser.visibleTabs);
var urls=tabs.map(t=>gBrowser.getBrowserForTab(t).currentURI.spec);
var titles=tabs.map(t=>gBrowser.getBrowserForTab(t).contentTitle);
urls.join("\n");
titles.join("\n");
The variable titles will contain the array of titles of the currently visible tabs (i.e. tabs in the current tab group). Use Display to view the contents of the variable.
Simple ..... here is an example
for (var i = 0, len = window.gBrowser.tabs.length; i < len; i++) {
console.log(window.gBrowser.tabs[i].label);
}
There are a few more tab related functions in my FoxyTab
I am using LimeSurvey and I want to include a question where the respondent can include up to 30 names as answer. However, I don't want to initially present the respondent with 30 boxes as it is overwhelming and requires a ton of scrolling to proceed if you only have a few names to enter. Is is possible to code the question so that a new box appears only after the previous box has been filled? Thanks.
Here is another approach that uses buttons to add/remove the array rows - http://manual.limesurvey.org/Workarounds:_Manipulating_a_survey_at_runtime_using_Javascript#Variable_Length_Array_.28Multi_Flexible_Text.29_question
Cheers
EDIT: This answer was written because I could not find the answer presented by tpartner beforehand. The main difference is that mine is based on filling out the previous row and tpartner's on buttons to add or remove rows.
The following code should work for all single-choice arrays (e.g. 5-point scale array) and is adaptable to other types if you know some Javascript/jQuery. I want to do more like that - just not today. So feel free to ask for implementations for other question types.
The code can be added in the beginning of the template.js file using the template editor. The variables "quest" and "first" have to be adapted based on your survey.
//Function to only display a new row if there is an answer in the previous row
//NOTICE: Rows which are reset to "No answer" will not be hidden
//NOTICE: This scipt was written based on LimeSurvey 2.00+ build 131107
//NOTICE: It only works for single-choice arrays (e.g. 5-point scale array) or multiple short texts
//BEGIN
$(document).ready( function() {
//SGQ code of the question to apply this to
var quest = "12345X1234X12345";
//A(nswer) code of the first row
var first = "1";
//hide all rows except the first
$("tr[id^='javatbd" + quest + "']").css("display","none");
$("tr[id='javatbd" + quest + first + "']").css("display","table-row");
//display rows if previous is answered
$("[name^='" + quest + "']").change(function() {
if(this.value.trim().length >= 1)
$("tr[id='javatbd" + this.name + "']").next().css("display","table-row");
});
});
//END
Best regards
Which question type are you planning to use? Your best bet, according to me, should be to use Multiple Short text type question and create 30 text boxes. You can then use javascript to hide these text boxes and show them as soon as the previous text box gets some value as input.
cheers!
With version 2.x (not sure which version starts allowing this, I am running 2.7 and it works there), this functionality is inbuilt via the relevance equation and doesn't require coding. Just enter !is_empty(questioncode_Code) in the relevance equation for the text box you want to let appear. Code is the code of the field one above which triggers the appearance.
I'm using a Magento 1.4.1.1 install that I'm having issues with the javascript on a custom themed store.
For example, going to any product page (e.g. http://www.papakuraeducation.co.nz/index.php/teachers/magic-caterpillar-handwriting-casey-caterpillar-small-book.html) loads a Javascript file, which contains code which is supposed to scale down the .jpg file to fit the 'product-image' container it sits inside.
The relevent code seems to be around line #10279, which is causing a exception that $(imageEl).parentNode = null
Product.Zoom.prototype = {
initialize: function(imageEl, trackEl, handleEl, zoomInEl, zoomOutEl, hintEl){
this.containerEl = $(imageEl).parentNode;
this.imageEl = $(imageEl);
this.handleEl = $(handleEl);
this.trackEl = $(trackEl);
this.hintEl = $(hintEl);
(snipped...)
I've tried debugging it in Chrome and adding breakpoints, but tbh I'm not actually sure how to use this information to find the solution.
Any help in pointing me in the right direction would be greatly appreciated.
You have to add an ID to the <IMG> in question. This ID should than be fed into the following code-space:
product_zoom = new Product.Zoom('IMAGE_ID', 'track', 'handle', 'zoom_in', 'zoom_out', 'track_hint');
With CKEDITOR, when I use JS to get the contents of the Text Editor, I'm getting back:
<p>\u000a\u0009 ad adad ad asd</p>\u000a
When I should have gotten:
<p>ad adad ad asd</p>
Any idea what's going on here?
The only difference that could be the cause is that I'm dynamically created textareas on load, and using a class to find the editor:
$('.guideItem-textarea').each(function(index, value){
// ID of the textarea
var targeteditor = $(this).attr('id');
var targeteditorID = $(this).attr('id').replace('noteguide','');
// Contents in the editor
textareacontents = CKEDITOR.instances[targeteditor].getData();
});
Any ideas?
Those strange characters are unicode control characters. The first one is a line feed, the seond is a tab. is the data in your example really the values in your question? Perhaps your prepopulated the text from some other source?
Suggested reading after you figure this out though:
http://www.joelonsoftware.com/articles/Unicode.html