Skip to content

Instantly share code, notes, and snippets.

View unique
// Удаляем повторяющиеся элементы в массиве
function unique(aa) {
var a = [],
o = {},
n = aa.length;
for (var i = 0; i < n; ++i) {
o[aa[i]] = aa[i];
}
for (var i in o) {
a.push(o[i]);
View unique
// Удаляем повторяющиеся элементы в массиве
function unique(aa) {
var a = [],
o = {},
n = aa.length;
for (var i = 0; i < n; ++i) {
o[aa[i]] = aa[i];
}
for (var i in o) {
a.push(o[i]);
View textFramesBadeLine
//https://forum.rudtp.ru/threads/najti-perejti-k-frejmu-gde-tekst-ne-prilegaet-k-nizhnej-granice.75885/
var tfs = app.activeDocument.textFrames.everyItem().getElements();
for (var i = 0; i < tfs.length; i++) {
var tf = tfs[i];
var line = tf.lines.lastItem();
if (line.isValid) {
var bottom = tf.geometricBounds[2] - tf.textFramePreferences.insetSpacing[2];
var baseline = line.baseline;
if (bottom - baseline > 0.1) {
View getGeometricSelect
// координаты выделенных объектов c учетом 'clipped' элементов
var Bds = doc.selection;
var coord = getGeometricSelect(Bds);
function getGeometricSelect(item) {
var el, el1;
// координаты первого элемента
el1 = getVisibleBounds(item[0], true);
// перебираем оставшиеся
View Letter
var letters = app.activeDocument.textFrames[0].textRange.characters;
letters.length
letters[i].fillColor
View removeGuidesfromGroup
function removeGuidesfromGroup(item) {
var el, el1;
var one = true;
for (var p = 0; p < item.length; p++) {
if (!item[p].guides) {
if (item[p].typename == 'GroupItem') {
one = false;
el = removeGuidesfromGroup(item[p].pageItems)
} else {
el = item[p].geometricBounds;
View mouseClickPos
document.body.onclick = function(e) {
e = e || window.event;
e = jQuery.event.fix(e);
alert([e.pageX, e.pageY]);
};
View copyText
https://community.adobe.com/t5/coding-corner/adobe-cep-v9-i-cant-seem-to-copy-the-html-text-from-panel-to-the-os-clipboard-with-javascript/m-p/10896257?page=1
function click_copyList(){
var copyText = document.getElementById("fileNameTable").innerText; // gets text from table
document.getElementById("holdText").innerText = copyText;//send table text to input field
document.getElementById("holdText").select();//select or highlight the input field text
document.execCommand("copy");//copy selected text
alert("copied the text!");
} //end copyList
View getManifect
// https://community.adobe.com/t5/photoshop/get-version-from-manifest-xml-cep-extension/m-p/10719134?page=1
function getPluginVersion() {
const fs = require('fs');
const path = csInterface.getSystemPath(SystemPath.EXTENSION);
const data = fs.readFileSync(`${path}/CSXS/manifest.xml`);
if (!data) {
needNewVersion = true;
return;
View foo
$("#setOption").click( function() {
foo("Option");
} );
function foo(id) {
if (document.getElementById(id).style.display == "none") {
document.getElementById(id).style.display = "block"
} else {
document.getElementById(id).style.display = "none"
}
You can’t perform that action at this time.