forked from fieldOfView/krpano_fovplugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a js version of the string plugin for krpanoJS
- Loading branch information
1 parent
ce6565f
commit acfb1cb
Showing
4 changed files
with
85 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
string plugin for KRPano | ||
by Aldo Hoeben / fieldOfView.com | ||
http://fieldofview.github.com/krpano_fovplugins/string/plugin.html | ||
This software can be used free of charge and the source code is available under a Creative Commons Attribution license: | ||
http://creativecommons.org/licenses/by/3.0/ | ||
*/ | ||
|
||
var krpanoplugin=function(){var c=this,f=null,d=null;c.registerplugin=function(i,h,j){f=i;d=j;if(f.version<"1.0.8.14"||f.build<"2011-03-30"){f.trace(3,"gyro plugin - too old krpano version (min. 1.0.8.14)");return}d.txtlength=a;d.txtchunk=g;d.txtfind=b;d.txtreplace=e};c.unloadplugin=function(){d=null;f=null};function a(i,h){f.set(i,h.length)}function g(k,h,j,i){f.set(k,h.substr(j,i))}function b(j,h,i){f.set(j,h.indexOf(i))}function e(m,j,l,i,h){var k=new RegExp(l,h);f.set(m,j.replace(k,i))}}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
string plugin for KRPanoJS | ||
by Aldo Hoeben / fieldOfView.com | ||
http://fieldofview.github.com/krpano_fovplugins/string/plugin.html | ||
This software can be used free of charge and the source code is available under a Creative Commons Attribution license: | ||
http://creativecommons.org/licenses/by/3.0/ | ||
*/ | ||
|
||
var krpanoplugin = function() | ||
{ | ||
var local = this, | ||
krpano = null, plugin = null; | ||
|
||
//////////////////////////////////////////////////////////// | ||
// plugin management | ||
|
||
local.registerplugin = function(krpanointerface, pluginpath, pluginobject) | ||
{ | ||
krpano = krpanointerface; | ||
plugin = pluginobject; | ||
|
||
if (krpano.version < "1.0.8.14" || krpano.build < "2011-03-30") | ||
{ | ||
krpano.trace(3,"gyro plugin - too old krpano version (min. 1.0.8.14)"); | ||
return; | ||
} | ||
|
||
// register methods | ||
plugin.txtlength = txtlength; | ||
plugin.txtchunk = txtchunk; | ||
plugin.txtfind = txtfind; | ||
plugin.txtreplace = txtreplace; | ||
} | ||
|
||
|
||
local.unloadplugin = function() | ||
{ | ||
plugin = null; | ||
krpano = null; | ||
} | ||
|
||
|
||
//////////////////////////////////////////////////////////// | ||
// public methods | ||
|
||
function txtlength(varName, subject) | ||
{ | ||
// return the length of the supplied text | ||
krpano.set(varName, subject.length); | ||
} | ||
|
||
function txtchunk(varName, subject, start, length) | ||
{ | ||
// return a substring of the supplied text | ||
krpano.set(varName, subject.substr(start, length)); | ||
} | ||
|
||
function txtfind(varName, subject, find) | ||
{ | ||
// find a needle in a haystack and return its position | ||
krpano.set(varName, subject.indexOf(find)); | ||
} | ||
|
||
function txtreplace(varName, subject, find, replace, flags) | ||
{ | ||
// find and replace a needle in a haystack | ||
var pattern = new RegExp(find, flags); | ||
krpano.set(varName, subject.replace(pattern, replace) ); | ||
} | ||
|
||
} |