Discussion:
[p4] Anyone using the JSAPI ? Can't get the simple example to work
Andrew Marold
2010-08-25 01:22:25 UTC
Permalink
I'm trying to get an example from the p4JSAPI doc to work with no success. I added the centralsettings line to my protections table, created the centralsettings.js file, and told p4v to accept applets. When I run it, I don't see any new tabs, and in system info I get this:

Perforce Applet Configuration:
Central settings file specified for user: yes (line 30 of permissions table)
Central settings file: //admin/jsapi/centralsettings.js
Perforce applets accepted: yes
Warning: central settings file not found or loaded.

My protections table contains this line:

list user * centralsettings //admin/jsapi/centralsettings.js

The file //admin/jsapicentralsettings.js contains:

function settings(key) {
if (key == "p4v_mainTabs")
{
return ["//admin/jsapi/connect.html"];
}

settings(P4JsApi.centralSettingsKey());
}

and //admin/jsapi/connect.html contains (cut & paste strait from the .pdf)

<html>
<head>
<title>Current Settings</title>
</head>
<body>
<script type="text/javascript">
content = '<H1>Current Settings</H1>' +
'<p><b>Port:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getPort()) +
'<p><b>Client workspace:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getClient()) +
'<p><b>User:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getUser()) +
'<p><b>Charset:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getCharset()) +
'<p><b>Server version:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getServerVersion()) +
'<p><b>Unicode?:</b> ' +
(P4JsApi.isServerUnicode() ? 'Yes' : 'No') +
'<p><b>Case sensitive?:</b> ' +
(P4JsApi.isServerCaseSensitive() ? 'Yes' : 'No') +
'<p><b>Security level:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getServerSecurityLevel());
document.write(content);
</script>
</body>
</html>

Any ideas as to where I'm going wrong ?

Thanks,
Drew

Drew Marold - ***@unidesk.com
Sr. Tools & Release Engineer - Unidesk Corporation

I hold . . . that a man should strive to the uttermost for his life's set prize.
Robert Browning
Matt Janulewicz
2010-08-25 01:42:59 UTC
Permalink
I'd first verify 100% that the user has access to the settings file. Use
'p4 protects'. Try to 'p4 print' it.

Also, I don't know if this is the *correct* syntax for referencing p4
files/paths, but this is what worked for me. Try changing your return
line to:

return ["p4:///admin/jsapi/connect.html"];

Yep, that's three slashes.

If it's working the system info dialog should list available tabs. To
open them look under View menu in P4V.


-Matt Janulewicz
Lucasfilm Entertainment Company Ltd.
Post by Andrew Marold
Central settings file specified for user: yes (line 30 of permissions table)
Central settings file: //admin/jsapi/centralsettings.js
Perforce applets accepted: yes
Warning: central settings file not found or loaded.
list user * centralsettings //admin/jsapi/centralsettings.js
function settings(key) {
if (key == "p4v_mainTabs")
{
return ["//admin/jsapi/connect.html"];
}
settings(P4JsApi.centralSettingsKey());
}
and //admin/jsapi/connect.html contains (cut& paste strait from the .pdf)
<html>
<head>
<title>Current Settings</title>
</head>
<body>
<script type="text/javascript">
content = '<H1>Current Settings</H1>' +
'<p><b>Port:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getPort()) +
'<p><b>Client workspace:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getClient()) +
'<p><b>User:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getUser()) +
'<p><b>Charset:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getCharset()) +
'<p><b>Server version:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getServerVersion()) +
'<p><b>Unicode?:</b> ' +
(P4JsApi.isServerUnicode() ? 'Yes' : 'No') +
'<p><b>Case sensitive?:</b> ' +
(P4JsApi.isServerCaseSensitive() ? 'Yes' : 'No') +
'<p><b>Security level:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getServerSecurityLevel());
document.write(content);
</script>
</body>
</html>
Any ideas as to where I'm going wrong ?
Thanks,
Drew
Sr. Tools& Release Engineer - Unidesk Corporation
I hold . . . that a man should strive to the uttermost for his life's set prize.
Robert Browning
_______________________________________________
http://maillist.perforce.com/mailman/listinfo/perforce-user
Andrew Marold
2010-08-25 15:00:48 UTC
Permalink
I can definitely see the file, 'p4 print' displays it. I've tried every form of path specification including the one you suggested to no avail. Next I tried added a protect line just for my user, and listed the centralsettings.js file as a local path, using the path to the workspace where I've been trying to make this work. After that, p4v stopped reporting the not found or loaded error, but it still didn't display a new tab, or indicate one was available. I even changed the centralsettings file to say:

return ["http://www.google.com"];

just to avoid the whole depot path thing entirely. Still nothing.

Drew

-----Original Message-----
From: perforce-user-***@perforce.com [mailto:perforce-user-***@perforce.com] On Behalf Of Matt Janulewicz
Sent: Tuesday, August 24, 2010 9:43 PM
To: perforce-***@perforce.com
Subject: Re: [p4] Anyone using the JSAPI ? Can't get the simple example to work

I'd first verify 100% that the user has access to the settings file. Use
'p4 protects'. Try to 'p4 print' it.

Also, I don't know if this is the *correct* syntax for referencing p4
files/paths, but this is what worked for me. Try changing your return
line to:

return ["p4:///admin/jsapi/connect.html"];

Yep, that's three slashes.

If it's working the system info dialog should list available tabs. To
open them look under View menu in P4V.


-Matt Janulewicz
Lucasfilm Entertainment Company Ltd.
Post by Andrew Marold
Central settings file specified for user: yes (line 30 of permissions table)
Central settings file: //admin/jsapi/centralsettings.js
Perforce applets accepted: yes
Warning: central settings file not found or loaded.
list user * centralsettings //admin/jsapi/centralsettings.js
function settings(key) {
if (key == "p4v_mainTabs")
{
return ["//admin/jsapi/connect.html"];
}
settings(P4JsApi.centralSettingsKey());
}
and //admin/jsapi/connect.html contains (cut& paste strait from the .pdf)
<html>
<head>
<title>Current Settings</title>
</head>
<body>
<script type="text/javascript">
content = '<H1>Current Settings</H1>' +
'<p><b>Port:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getPort()) +
'<p><b>Client workspace:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getClient()) +
'<p><b>User:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getUser()) +
'<p><b>Charset:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getCharset()) +
'<p><b>Server version:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getServerVersion()) +
'<p><b>Unicode?:</b> ' +
(P4JsApi.isServerUnicode() ? 'Yes' : 'No') +
'<p><b>Case sensitive?:</b> ' +
(P4JsApi.isServerCaseSensitive() ? 'Yes' : 'No') +
'<p><b>Security level:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getServerSecurityLevel());
document.write(content);
</script>
</body>
</html>
Any ideas as to where I'm going wrong ?
Thanks,
Drew
Sr. Tools& Release Engineer - Unidesk Corporation
I hold . . . that a man should strive to the uttermost for his life's set prize.
Robert Browning
_______________________________________________
http://maillist.perforce.com/mailman/listinfo/perforce-user
_______________________________________________
perforce-user mailing list - perforce-***@perforce.com
http://maillist.perforce.com/mailman/listinfo/perforce-user
Andrew Marold
2010-08-25 15:16:57 UTC
Permalink
Well some progress. I realized that my centralsettings.js had an error, in that the final settings() call was inside the settings function instead of the last line of the file. Can you say infinite recursion ? Once I fixed that, with the local file protections entry I was able to get tabs with content. Thinking I'd solved it, I took out the me-specific line and went back to just the all users depot path. Alas, now I'm back to 'not found or loaded'.

Drew

-----Original Message-----
From: perforce-user-***@perforce.com [mailto:perforce-user-***@perforce.com] On Behalf Of Matt Janulewicz
Sent: Tuesday, August 24, 2010 9:43 PM
To: perforce-***@perforce.com
Subject: Re: [p4] Anyone using the JSAPI ? Can't get the simple example to work

I'd first verify 100% that the user has access to the settings file. Use
'p4 protects'. Try to 'p4 print' it.

Also, I don't know if this is the *correct* syntax for referencing p4
files/paths, but this is what worked for me. Try changing your return
line to:

return ["p4:///admin/jsapi/connect.html"];

Yep, that's three slashes.

If it's working the system info dialog should list available tabs. To
open them look under View menu in P4V.


-Matt Janulewicz
Lucasfilm Entertainment Company Ltd.
Post by Andrew Marold
Central settings file specified for user: yes (line 30 of permissions table)
Central settings file: //admin/jsapi/centralsettings.js
Perforce applets accepted: yes
Warning: central settings file not found or loaded.
list user * centralsettings //admin/jsapi/centralsettings.js
function settings(key) {
if (key == "p4v_mainTabs")
{
return ["//admin/jsapi/connect.html"];
}
settings(P4JsApi.centralSettingsKey());
}
and //admin/jsapi/connect.html contains (cut& paste strait from the .pdf)
<html>
<head>
<title>Current Settings</title>
</head>
<body>
<script type="text/javascript">
content = '<H1>Current Settings</H1>' +
'<p><b>Port:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getPort()) +
'<p><b>Client workspace:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getClient()) +
'<p><b>User:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getUser()) +
'<p><b>Charset:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getCharset()) +
'<p><b>Server version:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getServerVersion()) +
'<p><b>Unicode?:</b> ' +
(P4JsApi.isServerUnicode() ? 'Yes' : 'No') +
'<p><b>Case sensitive?:</b> ' +
(P4JsApi.isServerCaseSensitive() ? 'Yes' : 'No') +
'<p><b>Security level:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getServerSecurityLevel());
document.write(content);
</script>
</body>
</html>
Any ideas as to where I'm going wrong ?
Thanks,
Drew
Sr. Tools& Release Engineer - Unidesk Corporation
I hold . . . that a man should strive to the uttermost for his life's set prize.
Robert Browning
_______________________________________________
http://maillist.perforce.com/mailman/listinfo/perforce-user
_______________________________________________
perforce-user mailing list - perforce-***@perforce.com
http://maillist.perforce.com/mailman/listinfo/perforce-user
Trey Valenta
2010-08-25 15:43:20 UTC
Permalink
Assuming you really want to apply this to everyone, perhaps you could change the protection entry from:

list user * centralsettings //admin/jsapi/centralsettings.js
to
read user * centralsettings //admin/jsapi/centralsettings.js

If the read permission isn't there, P4V can't load it. And of course you'd need to ensure that //admin/jsapi/connect.html is also readable.

trey
Post by Andrew Marold
Well some progress. I realized that my centralsettings.js had an error, in that the final settings() call was inside the settings function instead of the last line of the file. Can you say infinite recursion ? Once I fixed that, with the local file protections entry I was able to get tabs with content. Thinking I'd solved it, I took out the me-specific line and went back to just the all users depot path. Alas, now I'm back to 'not found or loaded'.
Drew
-----Original Message-----
Sent: Tuesday, August 24, 2010 9:43 PM
Subject: Re: [p4] Anyone using the JSAPI ? Can't get the simple example to work
I'd first verify 100% that the user has access to the settings file. Use
'p4 protects'. Try to 'p4 print' it.
Also, I don't know if this is the *correct* syntax for referencing p4
files/paths, but this is what worked for me. Try changing your return
return ["p4:///admin/jsapi/connect.html"];
Yep, that's three slashes.
If it's working the system info dialog should list available tabs. To
open them look under View menu in P4V.
-Matt Janulewicz
Lucasfilm Entertainment Company Ltd.
Post by Andrew Marold
Central settings file specified for user: yes (line 30 of permissions table)
Central settings file: //admin/jsapi/centralsettings.js
Perforce applets accepted: yes
Warning: central settings file not found or loaded.
list user * centralsettings //admin/jsapi/centralsettings.js
function settings(key) {
if (key == "p4v_mainTabs")
{
return ["//admin/jsapi/connect.html"];
}
settings(P4JsApi.centralSettingsKey());
}
and //admin/jsapi/connect.html contains (cut& paste strait from the .pdf)
<html>
<head>
<title>Current Settings</title>
</head>
<body>
<script type="text/javascript">
content = '<H1>Current Settings</H1>' +
'<p><b>Port:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getPort()) +
'<p><b>Client workspace:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getClient()) +
'<p><b>User:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getUser()) +
'<p><b>Charset:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getCharset()) +
'<p><b>Server version:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getServerVersion()) +
'<p><b>Unicode?:</b> ' +
(P4JsApi.isServerUnicode() ? 'Yes' : 'No') +
'<p><b>Case sensitive?:</b> ' +
(P4JsApi.isServerCaseSensitive() ? 'Yes' : 'No') +
'<p><b>Security level:</b> ' +
P4JsApi.encodeForHTML(P4JsApi.getServerSecurityLevel());
document.write(content);
</script>
</body>
</html>
Any ideas as to where I'm going wrong ?
Thanks,
Drew
Sr. Tools& Release Engineer - Unidesk Corporation
I hold . . . that a man should strive to the uttermost for his life's set prize.
Robert Browning
_______________________________________________
http://maillist.perforce.com/mailman/listinfo/perforce-user
_______________________________________________
http://maillist.perforce.com/mailman/listinfo/perforce-user
_______________________________________________
http://maillist.perforce.com/mailman/listinfo/perforce-user
Loading...