GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - TextGlass/javascript: TextGlass Javascript Client

BranchesTags
Open more actions menu

Latest commit

 

History

94 Commits
94 Commits

Folders and files

NameName
Last commit message
Last commit date
js
js
 
 
.gitignore
.gitignore
 
 
LICENSE.txt
LICENSE.txt
 
 
README.md
README.md
 
 
index.html
index.html
 
 
nodejs_main.js
nodejs_main.js
 
 
package.json
package.json
 
 
run.sh
run.sh
 
 
test.sh
test.sh
 
 

Repository files navigation

TextGlass Javascript Client

Releases

http://textglass.org/releases/javascript/

Example

http://textglass.org/trunk/javascript/

API

• textglass.loadURLs(patternURL, attributeURL, patternPatchURL, attributePatchURL, readyCallback)

   patternURL - pattern file URL
   attributeURL - attribute file URL
   patternPatchURL - pattern patch file URL
   attributePatchURL - attribute patch file URL
   readyCallback - see textglass.readyCallback

   Type
     Function

   Description
     Loads a domain from URL. readyCallback is called when ready or on error.

   Return value
     None

• textglass.readyCallback(state, msg, domain)

   state - state string, either 'error' or 'ready'
   msg - message string
   domain - domain name string

   Type
     Function

   Description
     This is the callback for textglass.loadURLs().

• textglass.loadObjects(pattern, attribute, patternPatch, attributePatch)

   pattern - pattern object
   attribute - attribute object
   patternPatch - pattern patch object
   attributePatch - attribute patch object

   Type
     Function

   Description
     Loads a domain from Javascript JSON objects.

   Return value
     domain object

• textglass.domains.[domain]

   name - domain name string
   version - domain version string
   classify - function, see textglass.domains.[domain].classify(input)
   error - boolean, set to true if textglass.loadObjects() fails
   msg - message string for textglass.loadObjects()

   Type
     Object

• textglass.domains.[domain].classify(input)

   input - string to classify against domain

   Type
     Function

   Description
     Classifies a string against a domain.

   Return value
     Attribute map (object)

• textglass.loaded

   Type
     Boolean

   Description
     True when textglass has been loaded.

Example Code

<script src="http://textglass.org/releases/javascript/latest/textglass.min.js"></script>

<script>
  var textglass = textglass || {};

  function load()
  {
    var osURL = 'http://textglass.org/releases/os/latest/patterns.min.json';
    var browserURL = 'http://textglass.org/releases/browser/latest/patterns.min.json';

    if(textglass.loaded)
    {
      textglass.loadURLs(osURL, undefined, undefined, undefined, domainReady);
      textglass.loadURLs(browserURL, undefined, undefined, undefined, domainReady);
    }
    else
    {
      alert('Error, couldn\'t load TextGlass Javascript client.');
    }
  }

  function domainReady(state, msg, domain)
  {
    if(state === 'error')
    {
      alert(msg);
    }
    else if(textglass.domains.browser && textglass.domains.os)
    {
      try
      {
          var browser = textglass.domains.browser.classify(navigator.userAgent);
          var os = textglass.domains.os.classify(navigator.userAgent);
      }
      catch(e) //fatal transformer error
      {
          alert(e);
          return;
      }

      var msg;

      if(browser.unknown)
      {
        msg = 'You are using an unknown browser.';
      }
      else
      {
        msg = 'Your browser is ' + browser.name + '.';
      }

      if(os.unknown)
      {
        msg += ' You are using an unknown operating system.';
      }
      else
      {
        msg += ' Your operating system is ' + os.name + '.';
      }

      alert(msg);
    }
  }

  load();
</script>

About

TextGlass Javascript Client

textglass.org

Resources

Readme
Apache-2.0 license
Activity
Custom properties

Stars

6 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.