Welcome to TiddlyWiki created by Jeremy Ruston; Copyright © 2004-2007 Jeremy Ruston, Copyright © 2007-2011 UnaMesa Association
!Served
||!Period|!Rank|!Ship|!Position|
|1|2376-2380|Ensign|Stargazer|Security Officer|
|2|2380-2382|Lieutenant Junior Grade|Stargazer|Security Officer|
|3|2382-2384|Lieutenant|Stargazer||
|servedtable|k
!Other stuff
/***
|Name|[[CrewListPlugin]]|
|Source|http://crewlist.tiddlyspot.com|
|Version|1.0.3.1|
|Author|Kristjan Brezovnik|
|License|[[Creative Commons Attribution-Share Alike 3.0 License|http://creativecommons.org/licenses/by-sa/3.0/]]|
|~CoreVersion|2.2.4|
|Dependencies|[[FatSlicesPlugin|http://svn.tiddlywiki.org/Trunk/contributors/PaulDowney/plugins/FatSlicePlugin/FatSlicePlugin.js]]|
|Type|plugin|
|Description|Displays crew lists for vessels.|
***/
/***
!Use
{{{<<crewlist vessel:"value" position:"value">>}}}
There are two parameters, which are both optional:
* ''vessel'': name of the vessel whose crew you want to list
* ''position'': position occupied by the crew you want to list; if omitted, the commanding officers are excluded
** ''all'': a special value used by the ''position'' parameter; it displays the entire crew, including the commanding officers
Output display when position is undefined or the ''all'' value is used: ''rank name (position)''
Output display for a specific position: ''rank name (period)''
Vessels must be tagged ''vessel'' and the crew must be tagged one of the following: <<option txtPeople>>.
If used without the parameters, the plugin first checks if the containing tiddler is tagged one of the following: <<option txtLocations>>. If it is, it displays all crew except Commanding Officers. If it's not, it displays a message.
If no crew is found, it displays a message.
If ''position'' parameter is omitted, it displays all crew except the commanding officers.
If ''position'' parameter has the value ''"all"'', it displays the entire crew, including the commanding officers.
If ''position'' parameter has s specific position value (eg Commanding Officer), it displays only the crew matching that position (eg Commanding Officer). In this case, the period is listed instead of position (or multiple periods, if the officer's rank changed while holding that position or if an officer came back to that same position after a break).
!!Structure of table
The table containing the list of ranks and position for an officer must be in a section called ''Served''. It should look like this:
||!Period|!Rank|!Ship|!Position|
|1|||||
|2|||||
|3|||||
|4|||||
|...|||||
|n|||||
|servedtable|k
The first and the last row are mandatory and must not be changed. All other lines must be sequentially numbered. The only annoying thing here is that if you want to insert a position retroactively, you need to manually change the row numbers.
If the information is unknown, leave the cell empty, the plugin adds the information that the information is unknown.
!Configuration
Tags used for locations: <<option txtLocations>>
Tags used for people: <<option txtPeople>>
!Version History
1.0.3.1 - Fixed a bug where the macro didn't render when on a deferred nested slider
1.0.3 - Added display of multiple periods
1.0.2 - Added support for multiple tags for locations and people
1.0.1 - Removed special treatment for Commanding Officers; all ranks now use that display when they are specified
1.0.0 - Initial release
***/
/***
!Code
***/
//{{{
if (!version.extensions.CrewListPlugin) {
version.extensions.CrewListPlugin = {installed: true};
version.extensions.CrewListPlugin = {major: 1, minor: 0, revision: 3, date: new Date(2012,7,10)};
if (config.options.txtLocations === undefined) {
config.options.txtLocations = "vessel, ship, starbase";
}
if (config.options.txtPeople === undefined) {
config.options.txtPeople = "officer, NCO, civilian";
}
config.shadowTiddlers.CrewListStylesheet=
".servedtable td:first-child {display: none;}\n";
store.addNotification("CrewListStylesheet", refreshStyles);
config.macros.crewlist = {};
config.macros.crewlist.handler = function (place,macroName,params,wikifier,paramString,tiddler) {
var tiddler=store.getTiddler(story.findContainingTiddler(place).getAttribute('tiddler')); //get the tiddler context, so it can be used on deferred sliders
params = paramString.parseParams(null, null, true);
var vessel = getParam(params, 'vessel', tiddler.title);
var position = getParam(params, 'position', undefined);
if (vessel === tiddler.title) { //if vessel parameter is not used, check if containing tiddler is tagged "vessel"
var vesselcheck = store.getTiddler(vessel);
var locsnormal = config.options.txtLocations;
var locs = locsnormal.split(", ");
var l;
var c = 0;
for (l = 0; l < locs.length; l++) {
if (!vesselcheck.isTagged(locs[l])) {
c = c + 1;
}
}
if (c === locs.length) {
wikify("''"+vesselcheck.title+"'' is not a vessel or is not tagged as ''"+locsnormal+"''.", place);
return;
}
}
var peoplenormal = config.options.txtPeople;
var people = peoplenormal.split(", ");
var countcrew = 0;
var m;
for (m = 0; m < people.length; m++) { //find people matching tag
var tids = store.getTaggedTiddlers(people[m]); //get all people matching tag
var i;
for (i = 0; i < tids.length; i++) { //go through each person
var periods = "";
var officer = tids[i].title;
var slices = store.getTiddlerText(officer+'##Served'); //get section "Served"
if (slices !== undefined && slices.match(vessel)) { //if section exists and contains the vessel name
var slicessplit = slices.split("\n");
var periodslice, rankslice, vesselslice, positionslice = 0;
if (position === undefined) { //if position is undefined, check if a person is a Commanding Officer of the vessel
var k;
var isCO = 0;
for (k = 1; k < slicessplit.length; k++) {
if (slicessplit[k].match(vessel) && slicessplit[k].match("Commanding Officer")) {
isCO = isCO + 1;
}
}
}
var j;
for (j = 1; j < slicessplit.length; j++) { //go through slices for people
if (position === undefined) { //all but CO
if (isCO === 0) { //officer is not a CO
if (slicessplit[j].match(vessel)) {
periodslice = store.getFatSlice(officer+'##Served', [j], 'Period');
rankslice = store.getFatSlice(officer+'##Served', [j], 'Rank');
vesselslice = store.getFatSlice(officer+'##Served', [j], 'Ship');
positionslice = store.getFatSlice(officer+'##Served', [j], 'Position');
if (periodslice === "") {
periodslice = "unknown period";
}
if (rankslice === "") {
rankslice = "(unknown rank)";
}
if (positionslice === "") {
positionslice = "unknown position";
}
}
}
}
else if (position === "all") { //all
if (slicessplit[j].match(vessel)) {
periodslice = store.getFatSlice(officer+'##Served', [j], 'Period');
rankslice = store.getFatSlice(officer+'##Served', [j], 'Rank');
vesselslice = store.getFatSlice(officer+'##Served', [j], 'Ship');
positionslice = store.getFatSlice(officer+'##Served', [j], 'Position');
if (periodslice === "") {
periodslice = "unknown period";
}
if (rankslice === "") {
rankslice = "(unknown rank)";
}
if (positionslice === "") {
positionslice = "unknown position";
}
}
}
else if (position !== undefined && position !== "all") { //specific position
if (slicessplit[j].match(vessel) && slicessplit[j].match(position)) {
periodslice = store.getFatSlice(officer+'##Served', [j], 'Period');
rankslice = store.getFatSlice(officer+'##Served', [j], 'Rank');
vesselslice = store.getFatSlice(officer+'##Served', [j], 'Ship');
positionslice = store.getFatSlice(officer+'##Served', [j], 'Position');
if (periodslice === "") {
periodslice = "unknown period";
}
periods += periodslice+", ";
if (rankslice === "") {
rankslice = "(unknown rank)";
}
if (positionslice === "") {
positionslice = "unknown position";
}
}
}
} //end go though slices for people
if (vesselslice !== undefined) { //if there are matches, show message
countcrew = countcrew + 1;
if (positionslice !== 0) {
if (position === undefined || position === "all") { //when displaying all crew, including CO
wikify("[["+rankslice+" "+officer+"|"+officer+"]] ("+positionslice+")\n", place);
}
else if (position !== "all") { //when displaying only a specific position
wikify("[["+rankslice+" "+officer+"|"+officer+"]] ("+periods.replace(/, $/, "")+")\n", place);
}
}
}
} //end if section exists and contains the vessel name
} //end go through each person
} //end find people matching tag
if (countcrew === 0) { //if there no matches, show message //where there is no crew available or wrong spelling; if vessel title, no crew, otherwise check if vessel exists
wikify("No crew listed for ''"+vessel+"''.", place);
return;
}
}; //End of macro
} //End of install only once
//}}}
|servedtable|k
!Other stuff
Vessel and position undefined (default; all crew but CO's, uses containing tiddler for vessel name) - on a deferred nested slider
{{{<<crewlist>>}}}
+++[Show crew|Show crew][Hide crew|Hide crew]...
<<crewlist>>
===
Vessel and position undefined (default; all crew but CO's, uses containing tiddler for vessel name) - transcluded from [[Stargazer]]
<<tiddler [[Stargazer]]>>
Vessel and position undefined (default; all crew but CO's, uses containing tiddler for vessel name)
{{{<<crewlist>>}}}
<<crewlist>>
Vessel defined, but no crew found for it; position also undefined
{{{<<crewlist vessel:"Nonexistent">>}}}
<<crewlist vessel:"Nonexistent">>
Vessel defined, position undefined (all crew but CO's)
{{{<<crewlist vessel:"Republic">>}}}
<<crewlist vessel:"Republic">>
Vessel defined, position undefined (all crew but CO's)
{{{<<crewlist vessel:"Stargazer">>}}}
<<crewlist vessel:"Stargazer">>
Vessel defined, position is ''all'' (all crew, including CO's)
{{{<<crewlist vessel:"Stargazer" position:"all">>}}}
<<crewlist vessel:"Stargazer" position:"all">>
Vessel and position defined (First Officer) (only crew matching the position, regardless of rank)
{{{<<crewlist vessel:"Stargazer" position:"First Officer">>}}}
<<crewlist vessel:"Stargazer" position:"First Officer">>
Vessel and position defined (Commanding Officer) (only crew matching the position, regardless of rank; displays period instead of position)
{{{<<crewlist vessel:"Stargazer" position:"Commanding Officer">>}}}
<<crewlist vessel:"Stargazer" position:"Commanding Officer">>
/***
|''Name:''|FatSlicePlugin|
|''Description:''|slices with multiple columns|
|''Author:''|PaulDowney (psd (at) osmosoft (dot) com)|
|''Source:''|http://svn.tiddlywiki.org/Trunk/contributors/PaulDowney/plugins/FatSlicePlugin/ |
|''CodeRepository:''|http://svn.tiddlywiki.org/Trunk/contributors/PaulDowney/plugins/FatSlicePlugin/ |
|''Documentation:''|##Documentation |
|''Status:''|@@Beta@@|
|''Version:''|0.1|
|''License:''|[[BSD open source license]]|
|''Comments:''|Please make comments at http://groups.google.co.uk/group/TiddlyWikiDev |
|''~CoreVersion:''|2.4.1|
!Documentation
The Fat Slice Plugin enriches the existing Slice mechanism in TiddlyWiki.
It enables the specification of lookup tables which are addressable by column and row rather than just Name/Value pairs of the current slice implementation.
A data table takes the form:
{{{
| |!column1 |!column2 |!column3 |
|row1| a | b | c |
|row2| d | e | f |
|row3| g | h | i |
}}}
Values can be retrieved from the data set via the getFatSlice() function:
{{{
var v = getFatSlice('TiddlerName', 'RowName', 'ColumnName');
}}}
Such data is also accessable from wikitext via the slice macro:
{{{
<<slice [[TiddlerName]] "RowName" "ColumnName">>
}}}
The slice macro also provides access to data in standard tiddler slices:
{{{
<<slice [[TiddlerName]] "SliceName">>
}}}
!!Source Code
***/
//{{{
if(!version.extensions.FatSlicePlugin){
version.extensions.FatSlicePlugin = {installed:true};
TiddlyWiki.prototype.fatSlicesRE = /^\|(.*)\|$/gm;
// @internal
TiddlyWiki.prototype.calcFatSlices = function(title) {
var slices = {};
var cols = [];
var text = this.getTiddlerText(title,"");
this.slicesRE.lastIndex = 0;
var m = this.fatSlicesRE.exec(text);
while(m) {
var slice = m[1].split('|');
var key = slice.shift();
key = key.replace(/[^\w]/g, '');
if (!key) {
cols = slice;
for(var i=0;i<cols.length;i++){
cols[i] = cols[i].replace(/[^\w]/g, '');
}
} else {
row = {};
for(var i=0; i<cols.length; i++){
if (cols[i]){
row[cols[i]]=slice[i];
}
}
slices[key] = row;
}
m = this.fatSlicesRE.exec(text);
}
return slices;
};
TiddlyWiki.prototype.getFatSlice = function(title,row,col) {
if (!col) {
return store.getTiddlerSlice(title,row);
}
var slices = this.calcFatSlices(title);
return slices[row]?slices[row][col]:undefined;
};
// Slice macro.
config.macros.slice = {};
config.macros.slice.handler = function(place,macroName,params,wikifier,paramString,tiddler) {
wikify(store.getFatSlice(params[0],params[1],params[2]),place);
};
} //# end of 'install only once'
//}}}
!Required tiddlers
[[CrewListPlugin]]
[[FatSlicesPlugin|http://svn.tiddlywiki.org/Trunk/contributors/PaulDowney/plugins/FatSlicePlugin/FatSlicePlugin.js]]
!Examples
[[Examples]]
!Served
||!Period|!Rank|!Ship|!Position|
|1|2376-2380|Ensign|Republic|Yeoman|
|servedtable|k
!Other stuff
!Served
||!Period|!Rank|!Ship|!Position|
|1|2376-2380|Ensign|Republic|Science Officer|
|2|2380-2382|Lieutenant Junior Grade|Republic|Science Officer|
|3|2382-2384|Lieutenant|Stargazer|Navigator|
|4|2384-2385|Lieutenant Commander|Stargazer|First Officer|
|5|2385-2388|Commander|Stargazer|First Officer|
|6|2388-2392|Captain|Stargazer|Commanding Officer|
|7|2388-2392|Admiral|Stargazer|Commanding Officer|
|8|2392-2402|Admiral|Enterprise|Commanding Officer|
|servedtable|k
!Other stuff
!Served
||!Period|!Rank|!Ship|!Position|
|1|2376-2380|Ensign|Republic|Science Officer|
|2|2380-2382|Lieutenant Junior Grade|Republic|Science Officer|
|3|2382-2384|Lieutenant|Stargazer|Navigator|
|4|2384-2385|Lieutenant Commander|Stargazer|First Officer|
|5|2385-2388|Commander|Stargazer|First Officer|
|6|2388-2392|Captain|Stargazer|Commanding Officer|
|7||Admiral|Stargazer|Commanding Officer|
|8|2392-2402|Admiral|Enterprise|Commanding Officer|
|servedtable|k
!Other stuff
/***
|''Name:''|LoadRemoteFileThroughProxy (previous LoadRemoteFileHijack)|
|''Description:''|When the TiddlyWiki file is located on the web (view over http) the content of [[SiteProxy]] tiddler is added in front of the file url. If [[SiteProxy]] does not exist "/proxy/" is added. |
|''Version:''|1.1.0|
|''Date:''|mar 17, 2007|
|''Source:''|http://tiddlywiki.bidix.info/#LoadRemoteFileHijack|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0|
***/
//{{{
version.extensions.LoadRemoteFileThroughProxy = {
major: 1, minor: 1, revision: 0,
date: new Date("mar 17, 2007"),
source: "http://tiddlywiki.bidix.info/#LoadRemoteFileThroughProxy"};
if (!window.bidix) window.bidix = {}; // bidix namespace
if (!bidix.core) bidix.core = {};
bidix.core.loadRemoteFile = loadRemoteFile;
loadRemoteFile = function(url,callback,params)
{
if ((document.location.toString().substr(0,4) == "http") && (url.substr(0,4) == "http")){
url = store.getTiddlerText("SiteProxy", "/proxy/") + url;
}
return bidix.core.loadRemoteFile(url,callback,params);
}
//}}}
[[GettingStarted]]
[[CrewListPlugin]]
[[FatSlicesPlugin|http://svn.tiddlywiki.org/Trunk/contributors/PaulDowney/plugins/FatSlicePlugin/FatSlicePlugin.js]]
!Served
||!Period|!Rank|!Ship|!Position|
|1|2376-2380|Ensign|Stargazer|Security Officer|
|2|2380-2382|Lieutenant Junior Grade|Stargazer|Security Officer|
|3|2382-2384|Lieutenant|Stargazer|Chief Security Officer|
|servedtable|k
!Other stuff
/***
|Name|NestedSlidersPlugin|
|Source|http://www.TiddlyTools.com/#NestedSlidersPlugin|
|Documentation|http://www.TiddlyTools.com/#NestedSlidersPluginInfo|
|Version|2.4.9|
|Author|Eric Shulman|
|License|http://www.TiddlyTools.com/#LegalStatements <br>and [[Creative Commons Attribution-ShareAlike 2.5 License|http://creativecommons.org/licenses/by-sa/2.5/]]|
|~CoreVersion|2.1|
|Type|plugin|
|Requires||
|Overrides||
|Options|##Configuration|
|Description|show content in nest-able sliding/floating panels, without creating separate tiddlers for each panel's content|
!!!!!Documentation
>see [[NestedSlidersPluginInfo]]
!!!!!Configuration
<<<
<<option chkFloatingSlidersAnimate>> allow floating sliders to animate when opening/closing
>Note: This setting can cause 'clipping' problems in some versions of InternetExplorer.
>In addition, for floating slider animation to occur you must also allow animation in general (see [[AdvancedOptions]]).
<<<
!!!!!Revisions
<<<
2008.11.15 - 2.4.9 in adjustNestedSlider(), don't make adjustments if panel is marked as 'undocked' (CSS class). In onClickNestedSlider(), SHIFT-CLICK docks panel (see [[MoveablePanelPlugin]])
|please see [[NestedSlidersPluginInfo]] for additional revision details|
2005.11.03 - 1.0.0 initial public release. Thanks to RodneyGomes, GeoffSlocock, and PaulPetterson for suggestions and experiments.
<<<
!!!!!Code
***/
//{{{
version.extensions.NestedSlidersPlugin= {major: 2, minor: 4, revision: 9, date: new Date(2008,11,15)};
// options for deferred rendering of sliders that are not initially displayed
if (config.options.chkFloatingSlidersAnimate===undefined)
config.options.chkFloatingSlidersAnimate=false; // avoid clipping problems in IE
// default styles for 'floating' class
setStylesheet(".floatingPanel { position:absolute; z-index:10; padding:0.5em; margin:0em; \
background-color:#eee; color:#000; border:1px solid #000; text-align:left; }","floatingPanelStylesheet");
// if removeCookie() function is not defined by TW core, define it here.
if (window.removeCookie===undefined) {
window.removeCookie=function(name) {
document.cookie = name+'=; expires=Thu, 01-Jan-1970 00:00:01 UTC; path=/;';
}
}
config.formatters.push( {
name: "nestedSliders",
match: "\\n?\\+{3}",
terminator: "\\s*\\={3}\\n?",
lookahead: "\\n?\\+{3}(\\+)?(\\([^\\)]*\\))?(\\!*)?(\\^(?:[^\\^\\*\\@\\[\\>]*\\^)?)?(\\*)?(\\@)?(?:\\{\\{([\\w]+[\\s\\w]*)\\{)?(\\[[^\\]]*\\])?(\\[[^\\]]*\\])?(?:\\}{3})?(\\#[^:]*\\:)?(\\>)?(\\.\\.\\.)?\\s*",
handler: function(w)
{
lookaheadRegExp = new RegExp(this.lookahead,"mg");
lookaheadRegExp.lastIndex = w.matchStart;
var lookaheadMatch = lookaheadRegExp.exec(w.source)
if(lookaheadMatch && lookaheadMatch.index == w.matchStart)
{
var defopen=lookaheadMatch[1];
var cookiename=lookaheadMatch[2];
var header=lookaheadMatch[3];
var panelwidth=lookaheadMatch[4];
var transient=lookaheadMatch[5];
var hover=lookaheadMatch[6];
var buttonClass=lookaheadMatch[7];
var label=lookaheadMatch[8];
var openlabel=lookaheadMatch[9];
var panelID=lookaheadMatch[10];
var blockquote=lookaheadMatch[11];
var deferred=lookaheadMatch[12];
// location for rendering button and panel
var place=w.output;
// default to closed, no cookie, no accesskey, no alternate text/tip
var show="none"; var cookie=""; var key="";
var closedtext=">"; var closedtip="";
var openedtext="<"; var openedtip="";
// extra "+", default to open
if (defopen) show="block";
// cookie, use saved open/closed state
if (cookiename) {
cookie=cookiename.trim().slice(1,-1);
cookie="chkSlider"+cookie;
if (config.options[cookie]==undefined)
{ config.options[cookie] = (show=="block") }
show=config.options[cookie]?"block":"none";
}
// parse label/tooltip/accesskey: [label=X|tooltip]
if (label) {
var parts=label.trim().slice(1,-1).split("|");
closedtext=parts.shift();
if (closedtext.substr(closedtext.length-2,1)=="=")
{ key=closedtext.substr(closedtext.length-1,1); closedtext=closedtext.slice(0,-2); }
openedtext=closedtext;
if (parts.length) closedtip=openedtip=parts.join("|");
else { closedtip="show "+closedtext; openedtip="hide "+closedtext; }
}
// parse alternate label/tooltip: [label|tooltip]
if (openlabel) {
var parts=openlabel.trim().slice(1,-1).split("|");
openedtext=parts.shift();
if (parts.length) openedtip=parts.join("|");
else openedtip="hide "+openedtext;
}
var title=show=='block'?openedtext:closedtext;
var tooltip=show=='block'?openedtip:closedtip;
// create the button
if (header) { // use "Hn" header format instead of button/link
var lvl=(header.length>5)?5:header.length;
var btn = createTiddlyElement(createTiddlyElement(place,"h"+lvl,null,null,null),"a",null,buttonClass,title);
btn.onclick=onClickNestedSlider;
btn.setAttribute("href","javascript:;");
btn.setAttribute("title",tooltip);
}
else
var btn = createTiddlyButton(place,title,tooltip,onClickNestedSlider,buttonClass);
btn.innerHTML=title; // enables use of HTML entities in label
// set extra button attributes
btn.setAttribute("closedtext",closedtext);
btn.setAttribute("closedtip",closedtip);
btn.setAttribute("openedtext",openedtext);
btn.setAttribute("openedtip",openedtip);
btn.sliderCookie = cookie; // save the cookiename (if any) in the button object
btn.defOpen=defopen!=null; // save default open/closed state (boolean)
btn.keyparam=key; // save the access key letter ("" if none)
if (key.length) {
btn.setAttribute("accessKey",key); // init access key
btn.onfocus=function(){this.setAttribute("accessKey",this.keyparam);}; // **reclaim** access key on focus
}
btn.setAttribute("hover",hover?"true":"false");
btn.onmouseover=function(ev) {
// optional 'open on hover' handling
if (this.getAttribute("hover")=="true" && this.sliderPanel.style.display=='none') {
document.onclick.call(document,ev); // close transients
onClickNestedSlider(ev); // open this slider
}
// mouseover on button aligns floater position with button
if (window.adjustSliderPos) window.adjustSliderPos(this.parentNode,this,this.sliderPanel);
}
// create slider panel
var panelClass=panelwidth?"floatingPanel":"sliderPanel";
if (panelID) panelID=panelID.slice(1,-1); // trim off delimiters
var panel=createTiddlyElement(place,"div",panelID,panelClass,null);
panel.button = btn; // so the slider panel know which button it belongs to
btn.sliderPanel=panel; // so the button knows which slider panel it belongs to
panel.defaultPanelWidth=(panelwidth && panelwidth.length>2)?panelwidth.slice(1,-1):"";
panel.setAttribute("transient",transient=="*"?"true":"false");
panel.style.display = show;
panel.style.width=panel.defaultPanelWidth;
panel.onmouseover=function(event) // mouseover on panel aligns floater position with button
{ if (window.adjustSliderPos) window.adjustSliderPos(this.parentNode,this.button,this); }
// render slider (or defer until shown)
w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
if ((show=="block")||!deferred) {
// render now if panel is supposed to be shown or NOT deferred rendering
w.subWikify(blockquote?createTiddlyElement(panel,"blockquote"):panel,this.terminator);
// align floater position with button
if (window.adjustSliderPos) window.adjustSliderPos(place,btn,panel);
}
else {
var src = w.source.substr(w.nextMatch);
var endpos=findMatchingDelimiter(src,"+++","===");
panel.setAttribute("raw",src.substr(0,endpos));
panel.setAttribute("blockquote",blockquote?"true":"false");
panel.setAttribute("rendered","false");
w.nextMatch += endpos+3;
if (w.source.substr(w.nextMatch,1)=="\n") w.nextMatch++;
}
}
}
}
)
function findMatchingDelimiter(src,starttext,endtext) {
var startpos = 0;
var endpos = src.indexOf(endtext);
// check for nested delimiters
while (src.substring(startpos,endpos-1).indexOf(starttext)!=-1) {
// count number of nested 'starts'
var startcount=0;
var temp = src.substring(startpos,endpos-1);
var pos=temp.indexOf(starttext);
while (pos!=-1) { startcount++; pos=temp.indexOf(starttext,pos+starttext.length); }
// set up to check for additional 'starts' after adjusting endpos
startpos=endpos+endtext.length;
// find endpos for corresponding number of matching 'ends'
while (startcount && endpos!=-1) {
endpos = src.indexOf(endtext,endpos+endtext.length);
startcount--;
}
}
return (endpos==-1)?src.length:endpos;
}
//}}}
//{{{
window.onClickNestedSlider=function(e)
{
if (!e) var e = window.event;
var theTarget = resolveTarget(e);
while (theTarget && theTarget.sliderPanel==undefined) theTarget=theTarget.parentNode;
if (!theTarget) return false;
var theSlider = theTarget.sliderPanel;
var isOpen = theSlider.style.display!="none";
// if SHIFT-CLICK, dock panel first (see [[MoveablePanelPlugin]])
if (e.shiftKey && config.macros.moveablePanel) config.macros.moveablePanel.dock(theSlider,e);
// toggle label
theTarget.innerHTML=isOpen?theTarget.getAttribute("closedText"):theTarget.getAttribute("openedText");
// toggle tooltip
theTarget.setAttribute("title",isOpen?theTarget.getAttribute("closedTip"):theTarget.getAttribute("openedTip"));
// deferred rendering (if needed)
if (theSlider.getAttribute("rendered")=="false") {
var place=theSlider;
if (theSlider.getAttribute("blockquote")=="true")
place=createTiddlyElement(place,"blockquote");
wikify(theSlider.getAttribute("raw"),place);
theSlider.setAttribute("rendered","true");
}
// show/hide the slider
if(config.options.chkAnimate && (!hasClass(theSlider,'floatingPanel') || config.options.chkFloatingSlidersAnimate))
anim.startAnimating(new Slider(theSlider,!isOpen,e.shiftKey || e.altKey,"none"));
else
theSlider.style.display = isOpen ? "none" : "block";
// reset to default width (might have been changed via plugin code)
theSlider.style.width=theSlider.defaultPanelWidth;
// align floater panel position with target button
if (!isOpen && window.adjustSliderPos) window.adjustSliderPos(theSlider.parentNode,theTarget,theSlider);
// if showing panel, set focus to first 'focus-able' element in panel
if (theSlider.style.display!="none") {
var ctrls=theSlider.getElementsByTagName("*");
for (var c=0; c<ctrls.length; c++) {
var t=ctrls[c].tagName.toLowerCase();
if ((t=="input" && ctrls[c].type!="hidden") || t=="textarea" || t=="select")
{ try{ ctrls[c].focus(); } catch(err){;} break; }
}
}
var cookie=theTarget.sliderCookie;
if (cookie && cookie.length) {
config.options[cookie]=!isOpen;
if (config.options[cookie]!=theTarget.defOpen) window.saveOptionCookie(cookie);
else window.removeCookie(cookie); // remove cookie if slider is in default display state
}
// prevent SHIFT-CLICK from being processed by browser (opens blank window... yuck!)
// prevent clicks *within* a slider button from being processed by browser
// but allow plain click to bubble up to page background (to close transients, if any)
if (e.shiftKey || theTarget!=resolveTarget(e))
{ e.cancelBubble=true; if (e.stopPropagation) e.stopPropagation(); }
Popup.remove(); // close open popup (if any)
return false;
}
//}}}
//{{{
// click in document background closes transient panels
document.nestedSliders_savedOnClick=document.onclick;
document.onclick=function(ev) { if (!ev) var ev=window.event; var target=resolveTarget(ev);
if (document.nestedSliders_savedOnClick)
var retval=document.nestedSliders_savedOnClick.apply(this,arguments);
// if click was inside a popup... leave transient panels alone
var p=target; while (p) if (hasClass(p,"popup")) break; else p=p.parentNode;
if (p) return retval;
// if click was inside transient panel (or something contained by a transient panel), leave it alone
var p=target; while (p) {
if ((hasClass(p,"floatingPanel")||hasClass(p,"sliderPanel"))&&p.getAttribute("transient")=="true") break;
p=p.parentNode;
}
if (p) return retval;
// otherwise, find and close all transient panels...
var all=document.all?document.all:document.getElementsByTagName("DIV");
for (var i=0; i<all.length; i++) {
// if it is not a transient panel, or the click was on the button that opened this panel, don't close it.
if (all[i].getAttribute("transient")!="true" || all[i].button==target) continue;
// otherwise, if the panel is currently visible, close it by clicking it's button
if (all[i].style.display!="none") window.onClickNestedSlider({target:all[i].button})
if (!hasClass(all[i],"floatingPanel")&&!hasClass(all[i],"sliderPanel")) all[i].style.display="none";
}
return retval;
};
//}}}
//{{{
// adjust floating panel position based on button position
if (window.adjustSliderPos==undefined) window.adjustSliderPos=function(place,btn,panel) {
if (hasClass(panel,"floatingPanel") && !hasClass(panel,"undocked")) {
// see [[MoveablePanelPlugin]] for use of 'undocked'
var rightEdge=document.body.offsetWidth-1;
var panelWidth=panel.offsetWidth;
var left=0;
var top=btn.offsetHeight;
if (place.style.position=="relative" && findPosX(btn)+panelWidth>rightEdge) {
left-=findPosX(btn)+panelWidth-rightEdge; // shift panel relative to button
if (findPosX(btn)+left<0) left=-findPosX(btn); // stay within left edge
}
if (place.style.position!="relative") {
var left=findPosX(btn);
var top=findPosY(btn)+btn.offsetHeight;
var p=place; while (p && !hasClass(p,'floatingPanel')) p=p.parentNode;
if (p) { left-=findPosX(p); top-=findPosY(p); }
if (left+panelWidth>rightEdge) left=rightEdge-panelWidth;
if (left<0) left=0;
}
panel.style.left=left+"px"; panel.style.top=top+"px";
}
}
//}}}
//{{{
// TW2.1 and earlier:
// hijack Slider stop handler so overflow is visible after animation has completed
Slider.prototype.coreStop = Slider.prototype.stop;
Slider.prototype.stop = function()
{ this.coreStop.apply(this,arguments); this.element.style.overflow = "visible"; }
// TW2.2+
// hijack Morpher stop handler so sliderPanel/floatingPanel overflow is visible after animation has completed
if (version.major+.1*version.minor+.01*version.revision>=2.2) {
Morpher.prototype.coreStop = Morpher.prototype.stop;
Morpher.prototype.stop = function() {
this.coreStop.apply(this,arguments);
var e=this.element;
if (hasClass(e,"sliderPanel")||hasClass(e,"floatingPanel")) {
// adjust panel overflow and position after animation
e.style.overflow = "visible";
if (window.adjustSliderPos) window.adjustSliderPos(e.parentNode,e.button,e);
}
};
}
//}}}
/***
|''Name:''|PasswordOptionPlugin|
|''Description:''|Extends TiddlyWiki options with non encrypted password option.|
|''Version:''|1.0.2|
|''Date:''|Apr 19, 2007|
|''Source:''|http://tiddlywiki.bidix.info/#PasswordOptionPlugin|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0 (Beta 5)|
***/
//{{{
version.extensions.PasswordOptionPlugin = {
major: 1, minor: 0, revision: 2,
date: new Date("Apr 19, 2007"),
source: 'http://tiddlywiki.bidix.info/#PasswordOptionPlugin',
author: 'BidiX (BidiX (at) bidix (dot) info',
license: '[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D]]',
coreVersion: '2.2.0 (Beta 5)'
};
config.macros.option.passwordCheckboxLabel = "Save this password on this computer";
config.macros.option.passwordInputType = "password"; // password | text
setStylesheet(".pasOptionInput {width: 11em;}\n","passwordInputTypeStyle");
merge(config.macros.option.types, {
'pas': {
elementType: "input",
valueField: "value",
eventName: "onkeyup",
className: "pasOptionInput",
typeValue: config.macros.option.passwordInputType,
create: function(place,type,opt,className,desc) {
// password field
config.macros.option.genericCreate(place,'pas',opt,className,desc);
// checkbox linked with this password "save this password on this computer"
config.macros.option.genericCreate(place,'chk','chk'+opt,className,desc);
// text savePasswordCheckboxLabel
place.appendChild(document.createTextNode(config.macros.option.passwordCheckboxLabel));
},
onChange: config.macros.option.genericOnChange
}
});
merge(config.optionHandlers['chk'], {
get: function(name) {
// is there an option linked with this chk ?
var opt = name.substr(3);
if (config.options[opt])
saveOptionCookie(opt);
return config.options[name] ? "true" : "false";
}
});
merge(config.optionHandlers, {
'pas': {
get: function(name) {
if (config.options["chk"+name]) {
return encodeCookie(config.options[name].toString());
} else {
return "";
}
},
set: function(name,value) {config.options[name] = decodeCookie(value);}
}
});
// need to reload options to load passwordOptions
loadOptionsCookie();
/*
if (!config.options['pasPassword'])
config.options['pasPassword'] = '';
merge(config.optionsDesc,{
pasPassword: "Test password"
});
*/
//}}}
!Served
||!Period|!Rank|!Ship|!Position|
|1|2378-2382|Ensign|Bozeman|Engineering Officer|
|2|2382-2384|Lieutenant Junior Grade|Bozeman|Security Officer|
|3|2384-2387|Lieutenant|Stargazer|Senior Engineering Officer|
|4|2387-2390|Lieutenant Commander|Stargazer|Chief Engineering Officer|
|5|2390-2392|Commander|Stargazer|Chief Engineering Officer|
|6|2392-2395|Captain|Stargazer|Commanding Officer|
|servedtable|k
!Other stuff
Displays crew lists for vessels.
Vessel and position undefined (default; all crew but CO's, uses containing tiddler for vessel name)
{{{<<crewlist>>}}}
<<crewlist>>
!Served
||!Period|!Rank|!Ship|!Position|
|1|2376-2380|Ensign|Stargazer|Security Officer|
|2|2380-2382|Lieutenant Junior Grade|Stargazer|Security Officer|
|3|2382-2384||Stargazer|Chief Security Officer|
|servedtable|k
!Other stuff
/***
|Name|[[TiddlyFileImportr|TiddlyFileImportr]]|
|Version|0.2.7|
|Status|experimental|
|Source|https://github.com/jdlrobson/TiddlyWikiPlugins/tree/master/apps/fileimport|
|Latest|http://repository.tiddlyspace.com/TiddlyFileImportr|
***/
//{{{
var ImportWizard, WizardMaker;
(function($) {
window.WizardMaker = function(place, wizard) {
var steps = wizard[0];
var options = wizard[1] || {};
$("<h1 />").text(options.heading || "Wizard").appendTo(place);
var wizard = this;
$('<button class="button">restart wizard</button>').click(function(ev) {
wizard.jumpTo(0);
}).appendTo(place)[0];
this.currentStep = 0;
this.body = $('<div class="wizardBody"/>').appendTo(place)[0];
this.steps = steps;
this.values = {};
this.createStep(0);
};
WizardMaker.prototype = {
/*
OPTIONS
step: [function, options]
*/
createStep: function(stepNumber) {
$(this.body).empty();
var step = this.steps[stepNumber];
if(!step) {
throw "invalid step (" + stepNumber + ")"
}
var options = step[1] || {};
var humanStep = stepNumber + 1;
var heading = "Step " + humanStep;
if(options.heading) {
heading += ": " + options.heading;
}
$("<h2 />").text(heading).appendTo(this.body);
var container = $('<div class="wizardStep" />').appendTo(this.body)[0];
step[0](container, this);
},
next: function() {
if(this.currentStep < this.steps.length - 1) {
this.currentStep += 1;
}
this.createStep(this.currentStep);
},
jumpTo: function(step) {
this.currentStep = step;
this.createStep(step);
},
setValue: function(name, val) {
this.values[name] = val;
},
getValue: function(name) {
return this.values[name];
}
};
if(window.FileReader) {
window.ImportWizard = function(options) {
var proxy = options.proxy, saveFunction = options.save,
internalizeTiddler = options.internalizeTiddler, proxyType = options.proxyType || "GET";
return [
[
[function(body, wizard) {
$(body).html('Where do you want to import from? <select><option value="1">file</option><option value="2">the web</option></select><button class="button">ok</button>');
$("button", body).click(function(ev) {
var opt = $("select", body).val();
if(opt === "1") {
wizard.next();
} else {
wizard.jumpTo(2);
}
});
},
{ heading: "File or Web?" }],
[function(body, wizard) {
$(body).html('Browse for a file: <input type="file" size="50" name="txtBrowse"><br><hr><div class="wizardFooter"><div class="message"></div></div>');
function handleFileSelect(evt) {
reader = new FileReader();
reader.onerror = function(e, msg) {
alert("Error occurred")
};
reader.onabort = function(e) {
alert('File read cancelled');
};
reader.onload = function(e) {
var html = reader.result;
wizard.setValue("html", html);
wizard.jumpTo(3)
}
// Read in the image file as a binary string.
window.reader = reader;
reader.readAsText(evt.target.files[0]);
}
$("[type=file]", body)[0].addEventListener('change', handleFileSelect, false);
}, { heading: "Locate TiddlyWiki file" }],
[function(body, wizard) {
$(body).html('Enter the URL or pathname here: <div class="message"></div><input type="text" size="50" name="txtPath"><button class="button">open</button>');
$("button", body).click(function(ev) {
var url = proxy.replace("%0", $("input", body).val())
ajaxReq({
type: options.proxyType,
url: url,
success: function(html) {
wizard.setValue("html", html);
wizard.jumpTo(3);
},
error: function() {
$(".message").html("There is something wrong with that url please try another.");
$("input", body).addClass("error");
}
})
})
},
{ heading: "Import from Web" }],
[function(body, wizard) {
var html = wizard.getValue("html");
var doc = $(html);
var store;
$(html).each(function(i, el) {
if(el.id === "storeArea") {
store = el;
}
});
if(store) {
var tiddlers = [];
$(store).children().each(function(i, el) {
var title = $(el).attr("title");
tiddlers.push(internalizeTiddler(el));
});
$("<div />").text("Choose tiddlers that you wish to import");
var table = $("<table />").appendTo(body)[0];
$("<tr />").html('<th><input type="checkbox" checked/></th><th>title</th>').
appendTo(table)
$("input", table).change(function(ev) {
var checked = $(ev.target).is(':checked');
$("input[type=checkbox]", body).attr("checked", checked);
});
for(var i = 0; i < tiddlers.length; i++) {
var title = tiddlers[i].title;
var row = $("<tr />").data("tiddler", tiddlers[i]).appendTo(table)[0];
$("<td />").html('<input type="checkbox" checked="checked"/>').appendTo(row);
$("<td />").text(title).appendTo(row);
}
$('<button class="button">import all selected tiddlers</button>').click(function(ev) {
var tids = [];
$("input[type=checkbox]:checked").each(function(i, chk) {
var tiddler = $(chk).parents("tr").data("tiddler");
if(tiddler) {
tids.push(tiddler);
}
});
wizard.setValue("selected", tids);
wizard.jumpTo(4)
}).prependTo(body);
}
},
{ heading: "Choose tiddlers" }],
[function(body, wizard) {
var tids = wizard.getValue("selected");
$(body).text("Please wait");
// do import
var save = 0;
var complete = function() {
save += 1;
if(save === tids.length) {
wizard.jumpTo(5);
}
};
$(body).text("Please wait (Importing " + tids.length + " tiddlers)");
for(var i = 0; i < tids.length; i++) {
var tid = tids[i];
$(body).text("Please wait (Importing " + tid.title + ")");
saveFunction(tid, complete);
}
},
{ heading: "Importing" }],
[function(body, wizard) {
$(body).html("Good news! Everything is now imported.");
},
{ heading: "Finished!" }]
],
{
heading: "Import tiddlers from another file or server"
}
];
}
} else {
$("#container").addClass("error").text("Your browser is not modern enough to support this app.");
}
})(jQuery);
(function($) {
if(window.ImportWizard) {
var proxy = "%0", proxyType = "GET";
if(config.extensions.tiddlyspace) {
proxy = "/reflector?uri=%0";
proxyType: "POST";
}
var loader = new TW21Loader();
var internalizer = function(node) {
var title = $(node).attr("title");
var tiddler = new Tiddler(title);
loader.internalizeTiddler(store, tiddler, title, node);
return tiddler;
};
var importer = ImportWizard({proxy:"%0", save: function(tid, callback) {
merge(tid.fields, config.defaultCustomFields);
delete tid.fields["server.page.revision"];
delete tid.fields["server.etag"];
tid = store.saveTiddler(tid.title, tid.title, tid.text,
tid.modifier, tid.modified, tid.tags, tid.fields, null, tid.created, tid.creator);
autoSaveChanges(null, [tid]);
callback();
}, internalizeTiddler: internalizer, proxyType: proxyType });
config.macros.importTiddlers = {
handler: function(place) {
var container = $("<div />").appendTo(place)[0];
new WizardMaker(container, importer);
}
};
} else if(config.macros.importTiddlers) {
var _import = config.macros.importTiddlers.handler;
config.macros.importTiddlers.handler = function(place) {
_import.apply(this, arguments);
jQuery("<div class='annotation error' />").text("Please upgrade your browser to take advantage of the modernised file import mechanism of the TiddlyFileImportr plugin.").prependTo(place);
};
}
})(jQuery);
//}}}
/***
Description: Contains the stuff you need to use Tiddlyspot
Note, you also need UploadPlugin, PasswordOptionPlugin and LoadRemoteFileThroughProxy
from http://tiddlywiki.bidix.info for a complete working Tiddlyspot site.
***/
//{{{
// edit this if you are migrating sites or retrofitting an existing TW
config.tiddlyspotSiteId = 'crewlist';
// make it so you can by default see edit controls via http
config.options.chkHttpReadOnly = false;
window.readOnly = false; // make sure of it (for tw 2.2)
window.showBackstage = true; // show backstage too
// disable autosave in d3
if (window.location.protocol != "file:")
config.options.chkGTDLazyAutoSave = false;
// tweak shadow tiddlers to add upload button, password entry box etc
with (config.shadowTiddlers) {
SiteUrl = 'http://'+config.tiddlyspotSiteId+'.tiddlyspot.com';
SideBarOptions = SideBarOptions.replace(/(<<saveChanges>>)/,"$1<<tiddler TspotSidebar>>");
OptionsPanel = OptionsPanel.replace(/^/,"<<tiddler TspotOptions>>");
DefaultTiddlers = DefaultTiddlers.replace(/^/,"[[WelcomeToTiddlyspot]] ");
MainMenu = MainMenu.replace(/^/,"[[WelcomeToTiddlyspot]] ");
}
// create some shadow tiddler content
merge(config.shadowTiddlers,{
'TspotControls':[
"| tiddlyspot password:|<<option pasUploadPassword>>|",
"| site management:|<<upload http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/store.cgi index.html . . " + config.tiddlyspotSiteId + ">>//(requires tiddlyspot password)//<br>[[control panel|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/controlpanel]], [[download (go offline)|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/download]]|",
"| links:|[[tiddlyspot.com|http://tiddlyspot.com/]], [[FAQs|http://faq.tiddlyspot.com/]], [[blog|http://tiddlyspot.blogspot.com/]], email [[support|mailto:support@tiddlyspot.com]] & [[feedback|mailto:feedback@tiddlyspot.com]], [[donate|http://tiddlyspot.com/?page=donate]]|"
].join("\n"),
'TspotSidebar':[
"<<upload http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/store.cgi index.html . . " + config.tiddlyspotSiteId + ">><html><a href='http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/download' class='button'>download</a></html>"
].join("\n"),
'WelcomeToTiddlyspot':[
"This document is a ~TiddlyWiki from tiddlyspot.com. A ~TiddlyWiki is an electronic notebook that is great for managing todo lists, personal information, and all sorts of things.",
"",
"@@font-weight:bold;font-size:1.3em;color:#444; //What now?// @@ Before you can save any changes, you need to enter your password in the form below. Then configure privacy and other site settings at your [[control panel|http://" + config.tiddlyspotSiteId + ".tiddlyspot.com/controlpanel]] (your control panel username is //" + config.tiddlyspotSiteId + "//).",
"<<tiddler TspotControls>>",
"See also GettingStarted.",
"",
"@@font-weight:bold;font-size:1.3em;color:#444; //Working online// @@ You can edit this ~TiddlyWiki right now, and save your changes using the \"save to web\" button in the column on the right.",
"",
"@@font-weight:bold;font-size:1.3em;color:#444; //Working offline// @@ A fully functioning copy of this ~TiddlyWiki can be saved onto your hard drive or USB stick. You can make changes and save them locally without being connected to the Internet. When you're ready to sync up again, just click \"upload\" and your ~TiddlyWiki will be saved back to tiddlyspot.com.",
"",
"@@font-weight:bold;font-size:1.3em;color:#444; //Help!// @@ Find out more about ~TiddlyWiki at [[TiddlyWiki.com|http://tiddlywiki.com]]. Also visit [[TiddlyWiki.org|http://tiddlywiki.org]] for documentation on learning and using ~TiddlyWiki. New users are especially welcome on the [[TiddlyWiki mailing list|http://groups.google.com/group/TiddlyWiki]], which is an excellent place to ask questions and get help. If you have a tiddlyspot related problem email [[tiddlyspot support|mailto:support@tiddlyspot.com]].",
"",
"@@font-weight:bold;font-size:1.3em;color:#444; //Enjoy :)// @@ We hope you like using your tiddlyspot.com site. Please email [[feedback@tiddlyspot.com|mailto:feedback@tiddlyspot.com]] with any comments or suggestions."
].join("\n"),
'TspotOptions':[
"tiddlyspot password:",
"<<option pasUploadPassword>>",
""
].join("\n")
});
//}}}
| !date | !user | !location | !storeUrl | !uploadDir | !toFilename | !backupdir | !origin |
| 22/06/2012 09:33:28 | Kristjan | [[/|http://crewlist.tiddlyspot.com/]] | [[store.cgi|http://crewlist.tiddlyspot.com/store.cgi]] | . | [[index.html | http://crewlist.tiddlyspot.com/index.html]] | . |
| 22/06/2012 09:34:17 | Kristjan | [[index.html|http://crewlist.tiddlyspot.com/index.html]] | [[store.cgi|http://crewlist.tiddlyspot.com/store.cgi]] | . | [[index.html | http://crewlist.tiddlyspot.com/index.html]] | . |
| 22/06/2012 09:38:06 | Kristjan | [[/|http://crewlist.tiddlyspot.com/]] | [[store.cgi|http://crewlist.tiddlyspot.com/store.cgi]] | . | [[index.html | http://crewlist.tiddlyspot.com/index.html]] | . |
| 08/07/2012 11:30:46 | Kristjan | [[/|http://crewlist.tiddlyspot.com/]] | [[store.cgi|http://crewlist.tiddlyspot.com/store.cgi]] | . | [[index.html | http://crewlist.tiddlyspot.com/index.html]] | . |
| 09/07/2012 17:50:09 | Kristjan | [[/|http://crewlist.tiddlyspot.com/]] | [[store.cgi|http://crewlist.tiddlyspot.com/store.cgi]] | . | [[index.html | http://crewlist.tiddlyspot.com/index.html]] | . | ok |
| 09/07/2012 17:51:17 | Kristjan | [[/|http://crewlist.tiddlyspot.com/]] | [[store.cgi|http://crewlist.tiddlyspot.com/store.cgi]] | . | [[index.html | http://crewlist.tiddlyspot.com/index.html]] | . | ok |
| 09/07/2012 18:19:16 | Kristjan | [[/|http://crewlist.tiddlyspot.com/]] | [[store.cgi|http://crewlist.tiddlyspot.com/store.cgi]] | . | [[index.html | http://crewlist.tiddlyspot.com/index.html]] | . |
| 10/07/2012 11:45:58 | Kristjan | [[/|http://crewlist.tiddlyspot.com/]] | [[store.cgi|http://crewlist.tiddlyspot.com/store.cgi]] | . | [[index.html | http://crewlist.tiddlyspot.com/index.html]] | . |
| 13/03/2014 18:47:58 | Kristjan | [[/|http://crewlist.tiddlyspot.com/]] | [[store.cgi|http://crewlist.tiddlyspot.com/store.cgi]] | . | [[index.html | http://crewlist.tiddlyspot.com/index.html]] | . |
| 18/04/2018 09:51:01 | Kristjan | [[/|http://crewlist.tiddlyspot.com/]] | [[store.cgi|http://crewlist.tiddlyspot.com/store.cgi]] | . | [[index.html | http://crewlist.tiddlyspot.com/index.html]] | . |
/***
|''Name:''|UploadPlugin|
|''Description:''|Save to web a TiddlyWiki|
|''Version:''|4.1.3|
|''Date:''|Feb 24, 2008|
|''Source:''|http://tiddlywiki.bidix.info/#UploadPlugin|
|''Documentation:''|http://tiddlywiki.bidix.info/#UploadPluginDoc|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|''~CoreVersion:''|2.2.0|
|''Requires:''|PasswordOptionPlugin|
***/
//{{{
version.extensions.UploadPlugin = {
major: 4, minor: 1, revision: 3,
date: new Date("Feb 24, 2008"),
source: 'http://tiddlywiki.bidix.info/#UploadPlugin',
author: 'BidiX (BidiX (at) bidix (dot) info',
coreVersion: '2.2.0'
};
//
// Environment
//
if (!window.bidix) window.bidix = {}; // bidix namespace
bidix.debugMode = false; // true to activate both in Plugin and UploadService
//
// Upload Macro
//
config.macros.upload = {
// default values
defaultBackupDir: '', //no backup
defaultStoreScript: "store.php",
defaultToFilename: "index.html",
defaultUploadDir: ".",
authenticateUser: true // UploadService Authenticate User
};
config.macros.upload.label = {
promptOption: "Save and Upload this TiddlyWiki with UploadOptions",
promptParamMacro: "Save and Upload this TiddlyWiki in %0",
saveLabel: "save to web",
saveToDisk: "save to disk",
uploadLabel: "upload"
};
config.macros.upload.messages = {
noStoreUrl: "No store URL in parmeters or options",
usernameOrPasswordMissing: "Username or password missing"
};
config.macros.upload.handler = function(place,macroName,params) {
if (readOnly)
return;
var label;
if (document.location.toString().substr(0,4) == "http")
label = this.label.saveLabel;
else
label = this.label.uploadLabel;
var prompt;
if (params[0]) {
prompt = this.label.promptParamMacro.toString().format([this.destFile(params[0],
(params[1] ? params[1]:bidix.basename(window.location.toString())), params[3])]);
} else {
prompt = this.label.promptOption;
}
createTiddlyButton(place, label, prompt, function() {config.macros.upload.action(params);}, null, null, this.accessKey);
};
config.macros.upload.action = function(params)
{
// for missing macro parameter set value from options
if (!params) params = {};
var storeUrl = params[0] ? params[0] : config.options.txtUploadStoreUrl;
var toFilename = params[1] ? params[1] : config.options.txtUploadFilename;
var backupDir = params[2] ? params[2] : config.options.txtUploadBackupDir;
var uploadDir = params[3] ? params[3] : config.options.txtUploadDir;
var username = params[4] ? params[4] : config.options.txtUploadUserName;
var password = config.options.pasUploadPassword; // for security reason no password as macro parameter
// for still missing parameter set default value
if ((!storeUrl) && (document.location.toString().substr(0,4) == "http"))
storeUrl = bidix.dirname(document.location.toString())+'/'+config.macros.upload.defaultStoreScript;
if (storeUrl.substr(0,4) != "http")
storeUrl = bidix.dirname(document.location.toString()) +'/'+ storeUrl;
if (!toFilename)
toFilename = bidix.basename(window.location.toString());
if (!toFilename)
toFilename = config.macros.upload.defaultToFilename;
if (!uploadDir)
uploadDir = config.macros.upload.defaultUploadDir;
if (!backupDir)
backupDir = config.macros.upload.defaultBackupDir;
// report error if still missing
if (!storeUrl) {
alert(config.macros.upload.messages.noStoreUrl);
clearMessage();
return false;
}
if (config.macros.upload.authenticateUser && (!username || !password)) {
alert(config.macros.upload.messages.usernameOrPasswordMissing);
clearMessage();
return false;
}
bidix.upload.uploadChanges(false,null,storeUrl, toFilename, uploadDir, backupDir, username, password);
return false;
};
config.macros.upload.destFile = function(storeUrl, toFilename, uploadDir)
{
if (!storeUrl)
return null;
var dest = bidix.dirname(storeUrl);
if (uploadDir && uploadDir != '.')
dest = dest + '/' + uploadDir;
dest = dest + '/' + toFilename;
return dest;
};
//
// uploadOptions Macro
//
config.macros.uploadOptions = {
handler: function(place,macroName,params) {
var wizard = new Wizard();
wizard.createWizard(place,this.wizardTitle);
wizard.addStep(this.step1Title,this.step1Html);
var markList = wizard.getElement("markList");
var listWrapper = document.createElement("div");
markList.parentNode.insertBefore(listWrapper,markList);
wizard.setValue("listWrapper",listWrapper);
this.refreshOptions(listWrapper,false);
var uploadCaption;
if (document.location.toString().substr(0,4) == "http")
uploadCaption = config.macros.upload.label.saveLabel;
else
uploadCaption = config.macros.upload.label.uploadLabel;
wizard.setButtons([
{caption: uploadCaption, tooltip: config.macros.upload.label.promptOption,
onClick: config.macros.upload.action},
{caption: this.cancelButton, tooltip: this.cancelButtonPrompt, onClick: this.onCancel}
]);
},
options: [
"txtUploadUserName",
"pasUploadPassword",
"txtUploadStoreUrl",
"txtUploadDir",
"txtUploadFilename",
"txtUploadBackupDir",
"chkUploadLog",
"txtUploadLogMaxLine"
],
refreshOptions: function(listWrapper) {
var opts = [];
for(i=0; i<this.options.length; i++) {
var opt = {};
opts.push();
opt.option = "";
n = this.options[i];
opt.name = n;
opt.lowlight = !config.optionsDesc[n];
opt.description = opt.lowlight ? this.unknownDescription : config.optionsDesc[n];
opts.push(opt);
}
var listview = ListView.create(listWrapper,opts,this.listViewTemplate);
for(n=0; n<opts.length; n++) {
var type = opts[n].name.substr(0,3);
var h = config.macros.option.types[type];
if (h && h.create) {
h.create(opts[n].colElements['option'],type,opts[n].name,opts[n].name,"no");
}
}
},
onCancel: function(e)
{
backstage.switchTab(null);
return false;
},
wizardTitle: "Upload with options",
step1Title: "These options are saved in cookies in your browser",
step1Html: "<input type='hidden' name='markList'></input><br>",
cancelButton: "Cancel",
cancelButtonPrompt: "Cancel prompt",
listViewTemplate: {
columns: [
{name: 'Description', field: 'description', title: "Description", type: 'WikiText'},
{name: 'Option', field: 'option', title: "Option", type: 'String'},
{name: 'Name', field: 'name', title: "Name", type: 'String'}
],
rowClasses: [
{className: 'lowlight', field: 'lowlight'}
]}
};
//
// upload functions
//
if (!bidix.upload) bidix.upload = {};
if (!bidix.upload.messages) bidix.upload.messages = {
//from saving
invalidFileError: "The original file '%0' does not appear to be a valid TiddlyWiki",
backupSaved: "Backup saved",
backupFailed: "Failed to upload backup file",
rssSaved: "RSS feed uploaded",
rssFailed: "Failed to upload RSS feed file",
emptySaved: "Empty template uploaded",
emptyFailed: "Failed to upload empty template file",
mainSaved: "Main TiddlyWiki file uploaded",
mainFailed: "Failed to upload main TiddlyWiki file. Your changes have not been saved",
//specific upload
loadOriginalHttpPostError: "Can't get original file",
aboutToSaveOnHttpPost: 'About to upload on %0 ...',
storePhpNotFound: "The store script '%0' was not found."
};
bidix.upload.uploadChanges = function(onlyIfDirty,tiddlers,storeUrl,toFilename,uploadDir,backupDir,username,password)
{
var callback = function(status,uploadParams,original,url,xhr) {
if (!status) {
displayMessage(bidix.upload.messages.loadOriginalHttpPostError);
return;
}
if (bidix.debugMode)
alert(original.substr(0,500)+"\n...");
// Locate the storeArea div's
var posDiv = locateStoreArea(original);
if((posDiv[0] == -1) || (posDiv[1] == -1)) {
alert(config.messages.invalidFileError.format([localPath]));
return;
}
bidix.upload.uploadRss(uploadParams,original,posDiv);
};
if(onlyIfDirty && !store.isDirty())
return;
clearMessage();
// save on localdisk ?
if (document.location.toString().substr(0,4) == "file") {
var path = document.location.toString();
var localPath = getLocalPath(path);
saveChanges();
}
// get original
var uploadParams = new Array(storeUrl,toFilename,uploadDir,backupDir,username,password);
var originalPath = document.location.toString();
// If url is a directory : add index.html
if (originalPath.charAt(originalPath.length-1) == "/")
originalPath = originalPath + "index.html";
var dest = config.macros.upload.destFile(storeUrl,toFilename,uploadDir);
var log = new bidix.UploadLog();
log.startUpload(storeUrl, dest, uploadDir, backupDir);
displayMessage(bidix.upload.messages.aboutToSaveOnHttpPost.format([dest]));
if (bidix.debugMode)
alert("about to execute Http - GET on "+originalPath);
var r = doHttp("GET",originalPath,null,null,username,password,callback,uploadParams,null);
if (typeof r == "string")
displayMessage(r);
return r;
};
bidix.upload.uploadRss = function(uploadParams,original,posDiv)
{
var callback = function(status,params,responseText,url,xhr) {
if(status) {
var destfile = responseText.substring(responseText.indexOf("destfile:")+9,responseText.indexOf("\n", responseText.indexOf("destfile:")));
displayMessage(bidix.upload.messages.rssSaved,bidix.dirname(url)+'/'+destfile);
bidix.upload.uploadMain(params[0],params[1],params[2]);
} else {
displayMessage(bidix.upload.messages.rssFailed);
}
};
// do uploadRss
if(config.options.chkGenerateAnRssFeed) {
var rssPath = uploadParams[1].substr(0,uploadParams[1].lastIndexOf(".")) + ".xml";
var rssUploadParams = new Array(uploadParams[0],rssPath,uploadParams[2],'',uploadParams[4],uploadParams[5]);
var rssString = generateRss();
// no UnicodeToUTF8 conversion needed when location is "file" !!!
if (document.location.toString().substr(0,4) != "file")
rssString = convertUnicodeToUTF8(rssString);
bidix.upload.httpUpload(rssUploadParams,rssString,callback,Array(uploadParams,original,posDiv));
} else {
bidix.upload.uploadMain(uploadParams,original,posDiv);
}
};
bidix.upload.uploadMain = function(uploadParams,original,posDiv)
{
var callback = function(status,params,responseText,url,xhr) {
var log = new bidix.UploadLog();
if(status) {
// if backupDir specified
if ((params[3]) && (responseText.indexOf("backupfile:") > -1)) {
var backupfile = responseText.substring(responseText.indexOf("backupfile:")+11,responseText.indexOf("\n", responseText.indexOf("backupfile:")));
displayMessage(bidix.upload.messages.backupSaved,bidix.dirname(url)+'/'+backupfile);
}
var destfile = responseText.substring(responseText.indexOf("destfile:")+9,responseText.indexOf("\n", responseText.indexOf("destfile:")));
displayMessage(bidix.upload.messages.mainSaved,bidix.dirname(url)+'/'+destfile);
store.setDirty(false);
log.endUpload("ok");
} else {
alert(bidix.upload.messages.mainFailed);
displayMessage(bidix.upload.messages.mainFailed);
log.endUpload("failed");
}
};
// do uploadMain
var revised = bidix.upload.updateOriginal(original,posDiv);
bidix.upload.httpUpload(uploadParams,revised,callback,uploadParams);
};
bidix.upload.httpUpload = function(uploadParams,data,callback,params)
{
var localCallback = function(status,params,responseText,url,xhr) {
url = (url.indexOf("nocache=") < 0 ? url : url.substring(0,url.indexOf("nocache=")-1));
if (xhr.status == 404)
alert(bidix.upload.messages.storePhpNotFound.format([url]));
if ((bidix.debugMode) || (responseText.indexOf("Debug mode") >= 0 )) {
alert(responseText);
if (responseText.indexOf("Debug mode") >= 0 )
responseText = responseText.substring(responseText.indexOf("\n\n")+2);
} else if (responseText.charAt(0) != '0')
alert(responseText);
if (responseText.charAt(0) != '0')
status = null;
callback(status,params,responseText,url,xhr);
};
// do httpUpload
var boundary = "---------------------------"+"AaB03x";
var uploadFormName = "UploadPlugin";
// compose headers data
var sheader = "";
sheader += "--" + boundary + "\r\nContent-disposition: form-data; name=\"";
sheader += uploadFormName +"\"\r\n\r\n";
sheader += "backupDir="+uploadParams[3] +
";user=" + uploadParams[4] +
";password=" + uploadParams[5] +
";uploaddir=" + uploadParams[2];
if (bidix.debugMode)
sheader += ";debug=1";
sheader += ";;\r\n";
sheader += "\r\n" + "--" + boundary + "\r\n";
sheader += "Content-disposition: form-data; name=\"userfile\"; filename=\""+uploadParams[1]+"\"\r\n";
sheader += "Content-Type: text/html;charset=UTF-8" + "\r\n";
sheader += "Content-Length: " + data.length + "\r\n\r\n";
// compose trailer data
var strailer = new String();
strailer = "\r\n--" + boundary + "--\r\n";
data = sheader + data + strailer;
if (bidix.debugMode) alert("about to execute Http - POST on "+uploadParams[0]+"\n with \n"+data.substr(0,500)+ " ... ");
var r = doHttp("POST",uploadParams[0],data,"multipart/form-data; ;charset=UTF-8; boundary="+boundary,uploadParams[4],uploadParams[5],localCallback,params,null);
if (typeof r == "string")
displayMessage(r);
return r;
};
// same as Saving's updateOriginal but without convertUnicodeToUTF8 calls
bidix.upload.updateOriginal = function(original, posDiv)
{
if (!posDiv)
posDiv = locateStoreArea(original);
if((posDiv[0] == -1) || (posDiv[1] == -1)) {
alert(config.messages.invalidFileError.format([localPath]));
return;
}
var revised = original.substr(0,posDiv[0] + startSaveArea.length) + "\n" +
store.allTiddlersAsHtml() + "\n" +
original.substr(posDiv[1]);
var newSiteTitle = getPageTitle().htmlEncode();
revised = revised.replaceChunk("<title"+">","</title"+">"," " + newSiteTitle + " ");
revised = updateMarkupBlock(revised,"PRE-HEAD","MarkupPreHead");
revised = updateMarkupBlock(revised,"POST-HEAD","MarkupPostHead");
revised = updateMarkupBlock(revised,"PRE-BODY","MarkupPreBody");
revised = updateMarkupBlock(revised,"POST-SCRIPT","MarkupPostBody");
return revised;
};
//
// UploadLog
//
// config.options.chkUploadLog :
// false : no logging
// true : logging
// config.options.txtUploadLogMaxLine :
// -1 : no limit
// 0 : no Log lines but UploadLog is still in place
// n : the last n lines are only kept
// NaN : no limit (-1)
bidix.UploadLog = function() {
if (!config.options.chkUploadLog)
return; // this.tiddler = null
this.tiddler = store.getTiddler("UploadLog");
if (!this.tiddler) {
this.tiddler = new Tiddler();
this.tiddler.title = "UploadLog";
this.tiddler.text = "| !date | !user | !location | !storeUrl | !uploadDir | !toFilename | !backupdir | !origin |";
this.tiddler.created = new Date();
this.tiddler.modifier = config.options.txtUserName;
this.tiddler.modified = new Date();
store.addTiddler(this.tiddler);
}
return this;
};
bidix.UploadLog.prototype.addText = function(text) {
if (!this.tiddler)
return;
// retrieve maxLine when we need it
var maxLine = parseInt(config.options.txtUploadLogMaxLine,10);
if (isNaN(maxLine))
maxLine = -1;
// add text
if (maxLine != 0)
this.tiddler.text = this.tiddler.text + text;
// Trunck to maxLine
if (maxLine >= 0) {
var textArray = this.tiddler.text.split('\n');
if (textArray.length > maxLine + 1)
textArray.splice(1,textArray.length-1-maxLine);
this.tiddler.text = textArray.join('\n');
}
// update tiddler fields
this.tiddler.modifier = config.options.txtUserName;
this.tiddler.modified = new Date();
store.addTiddler(this.tiddler);
// refresh and notifiy for immediate update
story.refreshTiddler(this.tiddler.title);
store.notify(this.tiddler.title, true);
};
bidix.UploadLog.prototype.startUpload = function(storeUrl, toFilename, uploadDir, backupDir) {
if (!this.tiddler)
return;
var now = new Date();
var text = "\n| ";
var filename = bidix.basename(document.location.toString());
if (!filename) filename = '/';
text += now.formatString("0DD/0MM/YYYY 0hh:0mm:0ss") +" | ";
text += config.options.txtUserName + " | ";
text += "[["+filename+"|"+location + "]] |";
text += " [[" + bidix.basename(storeUrl) + "|" + storeUrl + "]] | ";
text += uploadDir + " | ";
text += "[[" + bidix.basename(toFilename) + " | " +toFilename + "]] | ";
text += backupDir + " |";
this.addText(text);
};
bidix.UploadLog.prototype.endUpload = function(status) {
if (!this.tiddler)
return;
this.addText(" "+status+" |");
};
//
// Utilities
//
bidix.checkPlugin = function(plugin, major, minor, revision) {
var ext = version.extensions[plugin];
if (!
(ext &&
((ext.major > major) ||
((ext.major == major) && (ext.minor > minor)) ||
((ext.major == major) && (ext.minor == minor) && (ext.revision >= revision))))) {
// write error in PluginManager
if (pluginInfo)
pluginInfo.log.push("Requires " + plugin + " " + major + "." + minor + "." + revision);
eval(plugin); // generate an error : "Error: ReferenceError: xxxx is not defined"
}
};
bidix.dirname = function(filePath) {
if (!filePath)
return;
var lastpos;
if ((lastpos = filePath.lastIndexOf("/")) != -1) {
return filePath.substring(0, lastpos);
} else {
return filePath.substring(0, filePath.lastIndexOf("\\"));
}
};
bidix.basename = function(filePath) {
if (!filePath)
return;
var lastpos;
if ((lastpos = filePath.lastIndexOf("#")) != -1)
filePath = filePath.substring(0, lastpos);
if ((lastpos = filePath.lastIndexOf("/")) != -1) {
return filePath.substring(lastpos + 1);
} else
return filePath.substring(filePath.lastIndexOf("\\")+1);
};
bidix.initOption = function(name,value) {
if (!config.options[name])
config.options[name] = value;
};
//
// Initializations
//
// require PasswordOptionPlugin 1.0.1 or better
bidix.checkPlugin("PasswordOptionPlugin", 1, 0, 1);
// styleSheet
setStylesheet('.txtUploadStoreUrl, .txtUploadBackupDir, .txtUploadDir {width: 22em;}',"uploadPluginStyles");
//optionsDesc
merge(config.optionsDesc,{
txtUploadStoreUrl: "Url of the UploadService script (default: store.php)",
txtUploadFilename: "Filename of the uploaded file (default: in index.html)",
txtUploadDir: "Relative Directory where to store the file (default: . (downloadService directory))",
txtUploadBackupDir: "Relative Directory where to backup the file. If empty no backup. (default: ''(empty))",
txtUploadUserName: "Upload Username",
pasUploadPassword: "Upload Password",
chkUploadLog: "do Logging in UploadLog (default: true)",
txtUploadLogMaxLine: "Maximum of lines in UploadLog (default: 10)"
});
// Options Initializations
bidix.initOption('txtUploadStoreUrl','');
bidix.initOption('txtUploadFilename','');
bidix.initOption('txtUploadDir','');
bidix.initOption('txtUploadBackupDir','');
bidix.initOption('txtUploadUserName','');
bidix.initOption('pasUploadPassword','');
bidix.initOption('chkUploadLog',true);
bidix.initOption('txtUploadLogMaxLine','10');
// Backstage
merge(config.tasks,{
uploadOptions: {text: "upload", tooltip: "Change UploadOptions and Upload", content: '<<uploadOptions>>'}
});
config.backstageTasks.push("uploadOptions");
//}}}
!Served
||!Period|!Rank|!Ship|!Position|
|1|2376-2380|Ensign|Republic|Engineering Officer|
|2|2380-2382|Lieutenant Junior Grade|Republic|Science Officer|
|3|2382-2384|Lieutenant|Yamato|Navigator|
|4|2384-2385|Lieutenant Commander|Bozeman|First Officer|
|5|2385-2388|Commander|Bozeman|First Officer|
|6|2388-2392|Commander|Enterprise|First Officer|
|7|2392-2402|Captain|Yamato|Commanding Officer|
|servedtable|k
!Other stuff
!Served
||!Period|!Rank|!Ship|!Position|
|1|2376-2380|Ensign|Republic|Science Officer|
|2|2380-2382|Lieutenant Junior Grade|Republic|Science Officer|
|3|2382-2384|Lieutenant|Stargazer|Navigator|
|4|2384-2385|Lieutenant Commander|Bozeman|First Officer|
|5|2385-2388|Commander|Stargazer|First Officer|
|6|2388-2392|Commander|Enterprise|First Officer|
|7|2392-2402|Captain|Enterprise|Commanding Officer|
|servedtable|k
!Other stuff