[Gmod-ajax] writing a function

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[Gmod-ajax] writing a function

Sofia Robb
Hi,

I want to reformat one of the attributes with a function. I am starting with a simple experiment, but i am getting an error. I don't see any missing (,  { , or ;.


my first experiment in making a function:

uppercase_value = function(value){
  var ucstr = value.toUpperCase();
  return ucstr;
}

my track config:
      {
         "label"         : "mysnps",
         "key"           : "SNPs from VCF",
         "storeClass"    : "JBrowse/Store/SeqFeature/VCFTabix",
         "urlTemplate"   : "../files/recessive_eye_strict_SNPs_ann.vcf.gz",
         "type"          : "JBrowse/View/Track/CanvasVariants",
         "fmtDetailValue_ANN" :  "function(value){return uppercase_value(value);}",
      }

my error:
SyntaxError: Unexpected end of input parsing config callback 'function(value){ var ucstr = value.toUpperCase(); return ucstr;'

Thank you for any help!!
Sofia



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: writing a function

Sofia Robb
I didn't realize you had to indent the closing curly brace.

Now I get this error:
VM13004:1 Uncaught ReferenceError: uppercase_value is not defined

On Mon, Feb 20, 2017 at 1:45 PM, Sofia Robb <[hidden email]> wrote:
Hi,

I want to reformat one of the attributes with a function. I am starting with a simple experiment, but i am getting an error. I don't see any missing (,  { , or ;.


my first experiment in making a function:

uppercase_value = function(value){
  var ucstr = value.toUpperCase();
  return ucstr;
}

my track config:
      {
         "label"         : "mysnps",
         "key"           : "SNPs from VCF",
         "storeClass"    : "JBrowse/Store/SeqFeature/VCFTabix",
         "urlTemplate"   : "../files/recessive_eye_strict_SNPs_ann.vcf.gz",
         "type"          : "JBrowse/View/Track/CanvasVariants",
         "fmtDetailValue_ANN" :  "function(value){return uppercase_value(value);}",
      }

my error:
SyntaxError: Unexpected end of input parsing config callback 'function(value){ var ucstr = value.toUpperCase(); return ucstr;'

Thank you for any help!!
Sofia




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: writing a function

Eric Yao
hmm...  where did you put "uppercase_value = ..." ?
I would think putting it just about anywhere should work, given it's global.

For example, you could add it in index.html and it would work in your case:
<script>
uppercase_value = function(value){
var ucstr = value.toUpperCase();
return ucstr;
}
</script>


On Mon, Feb 20, 2017 at 12:47 PM, Sofia Robb <[hidden email]> wrote:
I didn't realize you had to indent the closing curly brace.

Now I get this error:
VM13004:1 Uncaught ReferenceError: uppercase_value is not defined

On Mon, Feb 20, 2017 at 1:45 PM, Sofia Robb <[hidden email]> wrote:
Hi,

I want to reformat one of the attributes with a function. I am starting with a simple experiment, but i am getting an error. I don't see any missing (,  { , or ;.


my first experiment in making a function:

uppercase_value = function(value){
  var ucstr = value.toUpperCase();
  return ucstr;
}

my track config:
      {
         "label"         : "mysnps",
         "key"           : "SNPs from VCF",
         "storeClass"    : "JBrowse/Store/SeqFeature/VCFTabix",
         "urlTemplate"   : "../files/recessive_eye_strict_SNPs_ann.vcf.gz",
         "type"          : "JBrowse/View/Track/CanvasVariants",
         "fmtDetailValue_ANN" :  "function(value){return uppercase_value(value);}",
      }

my error:
SyntaxError: Unexpected end of input parsing config callback 'function(value){ var ucstr = value.toUpperCase(); return ucstr;'

Thank you for any help!!
Sofia




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: writing a function

nathandunn

You may just need the “var"

var uppercase_function = function(value) . . . etc.

Nathan

On Feb 21, 2017, at 2:09 AM, Eric Yao <[hidden email]> wrote:

hmm...  where did you put "uppercase_value = ..." ?
I would think putting it just about anywhere should work, given it's global.

For example, you could add it in index.html and it would work in your case:
<script>
uppercase_value = function(value){
var ucstr = value.toUpperCase();
return ucstr;
}
</script>


On Mon, Feb 20, 2017 at 12:47 PM, Sofia Robb <[hidden email]> wrote:
I didn't realize you had to indent the closing curly brace.

Now I get this error:
VM13004:1 Uncaught ReferenceError: uppercase_value is not defined

On Mon, Feb 20, 2017 at 1:45 PM, Sofia Robb <[hidden email]> wrote:
Hi,

I want to reformat one of the attributes with a function. I am starting with a simple experiment, but i am getting an error. I don't see any missing (,  { , or ;.


my first experiment in making a function:

uppercase_value = function(value){
  var ucstr = value.toUpperCase();
  return ucstr;
}

my track config:
      {
         "label"         : "mysnps",
         "key"           : "SNPs from VCF",
         "storeClass"    : "JBrowse/Store/SeqFeature/VCFTabix",
         "urlTemplate"   : "../files/recessive_eye_strict_SNPs_ann.vcf.gz",
         "type"          : "JBrowse/View/Track/CanvasVariants",
         "fmtDetailValue_ANN" :  "function(value){return uppercase_value(value);}",
      }

my error:
SyntaxError: Unexpected end of input parsing config callback 'function(value){ var ucstr = value.toUpperCase(); return ucstr;'

Thank you for any help!!
Sofia




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: writing a function

Colin
If the function is stored in a .conf file then you can reference it like this in trackList.json

    "fmtDetailValue_ANN" :  "function(value){return ({uppercase_value})(value);}",



Putting the function in a normal <script> could work too,  but the functions stored in conf files can be referenced with curly braces

-Colin

On Tue, Feb 21, 2017 at 10:10 AM, Nathan Dunn <[hidden email]> wrote:

You may just need the “var"

var uppercase_function = function(value) . . . etc.

Nathan

On Feb 21, 2017, at 2:09 AM, Eric Yao <[hidden email]> wrote:

hmm...  where did you put "uppercase_value = ..." ?
I would think putting it just about anywhere should work, given it's global.

For example, you could add it in index.html and it would work in your case:
<script>
uppercase_value = function(value){
var ucstr = value.toUpperCase();
return ucstr;
}
</script>


On Mon, Feb 20, 2017 at 12:47 PM, Sofia Robb <[hidden email]> wrote:
I didn't realize you had to indent the closing curly brace.

Now I get this error:
VM13004:1 Uncaught ReferenceError: uppercase_value is not defined

On Mon, Feb 20, 2017 at 1:45 PM, Sofia Robb <[hidden email]> wrote:
Hi,

I want to reformat one of the attributes with a function. I am starting with a simple experiment, but i am getting an error. I don't see any missing (,  { , or ;.


my first experiment in making a function:

uppercase_value = function(value){
  var ucstr = value.toUpperCase();
  return ucstr;
}

my track config:
      {
         "label"         : "mysnps",
         "key"           : "SNPs from VCF",
         "storeClass"    : "JBrowse/Store/SeqFeature/VCFTabix",
         "urlTemplate"   : "../files/recessive_eye_strict_SNPs_ann.vcf.gz",
         "type"          : "JBrowse/View/Track/CanvasVariants",
         "fmtDetailValue_ANN" :  "function(value){return uppercase_value(value);}",
      }

my error:
SyntaxError: Unexpected end of input parsing config callback 'function(value){ var ucstr = value.toUpperCase(); return ucstr;'

Thank you for any help!!
Sofia




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax
Reply | Threaded
Open this post in threaded view
|

Re: writing a function

Sofia Robb
Oh!! Yes I have my function in a conf file. Yes. I needed to use curly braces around my function. Thank you Everyone!!!

On Tue, Feb 21, 2017 at 8:25 AM, Colin <[hidden email]> wrote:
If the function is stored in a .conf file then you can reference it like this in trackList.json

    "fmtDetailValue_ANN" :  "function(value){return ({uppercase_value})(value);}",



Putting the function in a normal <script> could work too,  but the functions stored in conf files can be referenced with curly braces

-Colin

On Tue, Feb 21, 2017 at 10:10 AM, Nathan Dunn <[hidden email]> wrote:

You may just need the “var"

var uppercase_function = function(value) . . . etc.

Nathan

On Feb 21, 2017, at 2:09 AM, Eric Yao <[hidden email]> wrote:

hmm...  where did you put "uppercase_value = ..." ?
I would think putting it just about anywhere should work, given it's global.

For example, you could add it in index.html and it would work in your case:
<script>
uppercase_value = function(value){
var ucstr = value.toUpperCase();
return ucstr;
}
</script>


On Mon, Feb 20, 2017 at 12:47 PM, Sofia Robb <[hidden email]> wrote:
I didn't realize you had to indent the closing curly brace.

Now I get this error:
VM13004:1 Uncaught ReferenceError: uppercase_value is not defined

On Mon, Feb 20, 2017 at 1:45 PM, Sofia Robb <[hidden email]> wrote:
Hi,

I want to reformat one of the attributes with a function. I am starting with a simple experiment, but i am getting an error. I don't see any missing (,  { , or ;.


my first experiment in making a function:

uppercase_value = function(value){
  var ucstr = value.toUpperCase();
  return ucstr;
}

my track config:
      {
         "label"         : "mysnps",
         "key"           : "SNPs from VCF",
         "storeClass"    : "JBrowse/Store/SeqFeature/VCFTabix",
         "urlTemplate"   : "../files/recessive_eye_strict_SNPs_ann.vcf.gz",
         "type"          : "JBrowse/View/Track/CanvasVariants",
         "fmtDetailValue_ANN" :  "function(value){return uppercase_value(value);}",
      }

my error:
SyntaxError: Unexpected end of input parsing config callback 'function(value){ var ucstr = value.toUpperCase(); return ucstr;'

Thank you for any help!!
Sofia




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gmod-ajax mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gmod-ajax