﻿<?xml version="1.0" encoding="utf-8"?>
<EXOconfigData format="Rwav" version="2019.4.100.249">
  <Object type="View">
    <Attribute name="Name">SimpleNotebook</Attribute>
    <Attribute name="Width">272</Attribute>
    <Attribute name="Height">210</Attribute>
    <Attribute name="Zoom">100%</Attribute>
    <Attribute name="ScaleValue">1.00</Attribute>
    <Attribute name="OnOpen">// The dot (.) before the server-side function name implicitly adds the current path
// (where the view resides).
//
// 'getStoredText' doesn't take any arguments but we're still required to pass an empty object ({})
this.view.call('.getStoredText', {}).then((result) =&gt; {
    
    // Get the result (string/text) or default to empty string if the result was null.
    const text = result || '';
    
    // Set the content text in the Text element (`StoredText`)
    console.log("setting content in Text element to:", text);
    this.view.StoredText.value(text);
});</Attribute>
    <Attribute name="ServerSideFunctionRPC">accounts.%account%.services.ssf.execute</Attribute>
    <Attribute name="ServerSideJS">// We register two server-side functions and return them (to the server-side context)
return {
    // All registered functions must be async and they all must
    // declare 'args' and 'callInfo' as params.
    
    getStoredText: async (args, callInfo) =&gt; {
        console.log('In getStoredText');
        
        // Get the value of 'textFromPage' from the notes.json in Shared:.
        return await callInfo.context.state.get(
            { 
                key: 'textFromPage',
                file: 'Shared:/notes.json',
            }
        );
    },
    
    setText: async (args, callInfo) =&gt; {
        console.log('In setText');
        
        // Set/store the text under the key 'textFromPage' in the shared notes file.
        // 'content' is the named arg we passed from the client-side code,
        // so therefor it can be found in the args object.
        return await callInfo.context.state.set(
            {
                key: 'textFromPage',
                file: 'Shared:/notes.json',
                data: args.content,
            }
        );
    }
}</Attribute>
    <Object type="ArgumentsFolder">
      <Attribute name="Name">Arguments</Attribute>
      <Attribute name="Comment">This folder contains all arguments for the view. The arguments can be sent to the view when it is used in run-time.</Attribute>
    </Object>
    <Object type="ElementsFolder">
      <Attribute name="Name">Elements</Attribute>
      <Attribute name="Comment">This folder contains all visual elements for the view.</Attribute>
      <Object type="Text">
        <Attribute name="Name">StoredText</Attribute>
        <Attribute name="ShowTitle">No</Attribute>
        <Attribute name="Multiline">Yes</Attribute>
        <Attribute name="ManeuverStyle">Editable</Attribute>
        <Attribute name="Left">10</Attribute>
        <Attribute name="Top">10</Attribute>
        <Attribute name="Width">250</Attribute>
        <Attribute name="Height">150</Attribute>
      </Object>
      <Object type="Button">
        <Attribute name="Name">SaveText</Attribute>
        <Attribute name="Left">70</Attribute>
        <Attribute name="Top">175</Attribute>
        <Attribute name="Width">120</Attribute>
        <Attribute name="OnManeuver">// Get the content/text from the Text element (`StoredText`)
const content = this.view.StoredText.value();

// Save the text to the state file 
this.view.call('.setText', { content }).then((result) =&gt; {
    console.log("Saved text:", content);
});</Attribute>
      </Object>
    </Object>
  </Object>
</EXOconfigData>