• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Help With HTML Panel

Participant ,
Mar 11, 2020 Mar 11, 2020

Copy link to clipboard

Copied

Figured it out. 🙂

TOPICS
Actions and scripting

Views

1.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
LEGEND ,
Mar 11, 2020 Mar 11, 2020

Copy link to clipboard

Copied

Repost then your request and share the solution 😉

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 11, 2020 Mar 11, 2020

Copy link to clipboard

Copied

I thought I had fixed this but I havent so I am throwing it out to the experts for some help.

In the html panel, I have a Combo Box. If the user chooses Excel, it open up a MS Excel file and if the user chooses Numbers, it opens up an Apple numbers file. Both of these reside in a subfolder of the extension panel.

 

I am using csInterface.getSystemPath(SystemPath.EXTENSION) to get the path to the files

I am using csInterface.evalScript to execute the file.

The user is prompted to make sure they want to do this. The prompt is coming from the photoshop.jsx file

 

HTML (index.html)

<select id="spreadsheet">
  <option value="">Choose Your Spreadsheet</option>
 <option value="Excel">Microsoft Excel</option>
 <option value="Numbers">Apple Numbers</option>
</select>
 
main.js
$("#spreadsheet").change(function() {
if($(this).val() == "Numbers") { //user chose numbers
csInterface.evalScript('Apple_Numbers()',function(result) { //call function in jsx file and bring back the result
 
if(result = "yes"){ //user chose yes from the prompt
var extensionRoot = csInterface.getSystemPath(SystemPath.EXTENSION);
var extensionRoot = "" + extensionRoot + "/spreadsheet/"; //path to the file
var myfile="project1.numbers"; // File Name
csInterface.evalScript('File("' + extensionRoot + myfile +'").execute()'); //open the file
}
});
 
Photoshop.jsx
function Apple_Numbers(){
var result = confirm ("This Will Open Apple Numbers\nAre you Sure?","");
if(result === true){
return result;
}
else if (result === false) {
return result;
}
 
Problem:
If I select No in the prompt dialog, I am getting False returned back to the main.js file but yet it is is still executing the code
and I cannot see why.
 
Ian

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 11, 2020 Mar 11, 2020

Copy link to clipboard

Copied

I thought I had fixed this but I havent so I am throwing it out to the experts for some help.

In the html panel, I have a Combo Box. If the user chooses Excel, it open up a MS Excel file and if the user chooses Numbers, it opens up an Apple numbers file. Both of these reside in a subfolder of the extension panel.

 

I am using csInterface.getSystemPath(SystemPath.EXTENSION) to get the path to the files

I am using csInterface.evalScript to execute the file.

The user is prompted to make sure they want to do this. The prompt is coming from the photoshop.jsx file

 

HTML (index.html)

<select id="spreadsheet">
  <option value="">Choose Your Spreadsheet</option>
 <option value="Excel">Microsoft Excel</option>
 <option value="Numbers">Apple Numbers</option>
</select>

 

main.js

$("#spreadsheet").change(function() {
if($(this).val() == "Numbers") { //user chose numbers
csInterface.evalScript('Apple_Numbers()',function(result) { //call function in jsx file and bring back the result
 
if(result = "yes"){ //user chose yes from the prompt
var extensionRoot = csInterface.getSystemPath(SystemPath.EXTENSION);
var extensionRoot = "" + extensionRoot + "/spreadsheet/"; //path to the file
var myfile="project1.numbers"; // File Name
csInterface.evalScript('File("' + extensionRoot + myfile +'").execute()'); //open the file
}
});

 

photoshop.jsx

function Apple_Numbers(){
var result = confirm ("This Will Open Apple Numbers\nAre you Sure?","");
if(result === true){
return result;
}
else if (result === false) {
return result;
}

 

Problem:
If I select No in the promp dialog, I am getting False returned back to the main.js file but yet it is is still executing the code
and I cannot see why.

Ian

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Mar 11, 2020 Mar 11, 2020

Copy link to clipboard

Copied

I don’t know how programming in extensions works, but
You have at least two errors.

1. if (result = "yes") is always true, because you use the assignment "=" instead of comparing "==". Equivalent to if ("yes").

2. result according to your logic can be either true or false, but not "yes" in any way.

For deguging paste the first command into your function (before if) the code:
alert (result);
 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 11, 2020 Mar 11, 2020

Copy link to clipboard

Copied

Adding alert(result);

before the if statement returns false if I choose No on the prompt  the code doesnt run (which is good) but..

 

if I choose Yes on the prompt the alert gives me true and code does not run either.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Mar 11, 2020 Mar 11, 2020

Copy link to clipboard

Copied

Not understood )

Just try replacing
if (result = "yes")
to
if (result == true)
 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 11, 2020 Mar 11, 2020

Copy link to clipboard

Copied

alert(result); <-- returns true
if(result == true){
alert("we are here"); <-- this does not get executed 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Mar 11, 2020 Mar 11, 2020

Copy link to clipboard

Copied

Can not be. Did you restart photoshop after the changes made?
 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 11, 2020 Mar 11, 2020

Copy link to clipboard

Copied

I am wondering if this is because I am working in the main.js file for Photoshop panel and it doesnot fully understand regular Javascript.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Mar 11, 2020 Mar 11, 2020

Copy link to clipboard

Copied

I do not know what to say.
Show your full (original) code if you want.
Maybe you made a typo there that you didn’t notice.
 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 11, 2020 Mar 11, 2020

Copy link to clipboard

Copied

this is is main.js

 

$("#spreadsheet").change(function() {
  if($(this).val() == "Numbers") {
     csInterface.evalScript('Apple_Numbers()',function(result) {
     alert(result);

     if(result == true){
      alert("we are here")
     }
   });
  }  					
});			

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Mar 11, 2020 Mar 11, 2020

Copy link to clipboard

Copied

Some kind of mysticism.
To understand (I do not deal with extensions) I need all your extension (all files). If you do not mind.
Then I will try to run and figure it out for myself.
Just interesting already.

P.S. And what does the alert show? Can I see a screenshot?
 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 11, 2020 Mar 11, 2020

Copy link to clipboard

Copied

I think I have fixed it but dont know why its working this way.

In the photoshop.jsx file I now have this.

 

I have declared a var as a string and then passed that string to the return

 

function Apple_Numbers(){
    var result = confirm ("This Will Open Apple Numbers\nAre you Sure?",false,"");
    if(result === true){
        var open_numbers = "yes";
        return open_numbers;
    } 
    else if (result === false) {
        var open_numbers ="no"
        return open_numbers;
    }
    else {
        alert ("Error");
    }

 

back in main.js it now looks like this

$("#spreadsheet").change(function() {
    if($(this).val() == "Numbers") {
	csInterface.evalScript('Apple_Numbers()',function(result) {
	alert(result); 				
	if(result == "yes"){
	alert("we are here")
	}
   });
  }  					
});		

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Mar 11, 2020 Mar 11, 2020

Copy link to clipboard

Copied

LATEST
The first code is missing a parenthesis.

In what was before - too.
 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines