dojo.provide("tmw.widgets.CommentsPanel");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.declare("tmw.widgets.CommentsPanel", [dijit._Widget,dijit._Templated], {
widgetsInTemplate: true,
templateString: '
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
',
oid: null,
type: null,
nodes: [],
startup: function(){
this.inherited(arguments);
this.init(651,1);
},
postCreate: function(){
this.inherited(arguments);
dojo.connect(this.postButton, "onClick", this, this._newComment);
dojo.connect(this.okNode, "onClick", this, this.postComment);
dojo.connect(this.cancelNode, "onClick", dojo.hitch(this, function(){ this.dialogNode.hide(); }));
},
init: function(id,type){
this.oid=id;
this.type=type;
this.reset();
this.getComments();
},
reset: function(){
for (var i=0; i0) {a.push(p); p=parent[p];}
for (var j=a.length-1;j>=0;j--){
ptr=ptr[a[j]].sub;
}
ptr[t]={ tid:t, level: levels[t], sub:[], username: el.username, date: el.date, txt: el.txt };
}
}
//console.dir(levels);
//console.dir(tl);
// setup widgets
for (i in tl){
this.doLayout(tl[i]);
}
},
doLayout: function(el){
this.addComment(Number(el.tid),Number(el.level),el.username,el.txt);
// recursion on sub-threads
for (var j in el.sub) this.doLayout(el.sub[j]);
},
addComment: function(tid,level,username,txt){
var div = document.createElement('li');
this.containerNode.appendChild(div);
txt = txt.replace(/\n/g,"
");
this.nodes.push(new tmw.widgets._CommentNode({tid:tid, level:level, username:username, txt:txt},div));
//node.startup();
},
getComments: function(){
// retrieve comments from db
var dm=this;
dojo.xhrPost({
url: "scripts/msg.php" ,
handleAs: "text" ,
timeout: 5000,
load: dojo.hitch(this,function(res){
var ret=dojo.fromJson(res);
if (ret.done) {
//console.dir(ret);
dm.buildThreads(ret.o);
} else console.log(res);
}),
content:{l:dojo.toJson([{c:19, t:dm.type, id: dm.oid}])}
});
},
postComment: function(){
var dm=this;
//console.log("posting..");
// commit comment on db
var txt=this.textNode.attr('value');
var parent_tid=0;
dojo.xhrPost({
url: "scripts/msg.php" ,
handleAs: "text" ,
timeout: 5000,
load: dojo.hitch(this,function(res){
var ret=dojo.fromJson(res);
if (ret.done) {
// maybe just locally update ?
dm.getComments();
} else console.log(res);
dm.dialogNode.hide();
}),
content:{l:dojo.toJson([{c:18, t:dm.type, id: dm.oid, p: parent_tid, v:txt}])}
});
}
});
dojo.declare("tmw.widgets._CommentNode", [dijit._Widget,dijit._Templated], {
widgetsInTemplate: true,
templateString: '',
txt: "",
username: "",
tid: null,
level: null,
postCreate: function(){
this.inherited(arguments);
//this.userNode.innerHTML=this.username;
//this.txtNode.resize();
if (this.level>1) dojo.addClass(this.classNode,"watch-comment-entry-reply-two");
else if (this.level==1) dojo.addClass(this.classNode,"watch-comment-entry-reply");
}
});
/*
==============================================================================================================================
from youtube
==============================================================================================================================
*/
dojo.provide("tmw.widgets.Footer");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("dojo.parser");
dojo.require("dijit.layout.ContentPane");
//dojo.require("tmw.util.util");
dojo.declare( "tmw.widgets.Footer", [ dijit.layout.ContentPane, dijit._Templated], {
templatePath: dojo.moduleUrl("tmw","widgets/resources/Footer.html"),
postCreate: function(args,frag) {
tmw.util.addBackgroundImage(this.hlNode,"borders/test_footer2.png",false);
tmw.util.addBackgroundImage(this.hrNode,"borders/test_footer2.png",false);
}
}
);
dojo.provide("tmw.widgets.Header");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("dojo.parser");
dojo.require("dijit.layout.ContentPane");
//dojo.require("tmw.util.util");
dojo.declare(
"tmw.widgets.Header",
[ dijit.layout.ContentPane, dijit._Templated], {
/*
Usage
*/
widgetType: "Header",
isContainer: true,
expandoId: "",
ref: "",
par: "",
main: "",
titleL: "",
titleR: "",
border: 0,
opacity: null,
bgcolor: "",
panelPadding: 4,
panelHeaderHeight: 26,
rightPad: 4,
lImgFloat: 30,
rImgFloat: 30,
ltTxtFloat: 2,
llTxtFloat: 14,
rtTxtFloat: 2,
rrTxtFloat: 30,
templatePath: dojo.moduleUrl("tmw","widgets/resources/Header.html"),
postCreate: function(args,frag) {
tmw.util.addBackgroundImage(this.hlNode,"borders/test_header3_28.png",false);
tmw.util.addBackgroundImage(this.hrNode,"borders/test_header3_28.png",false);
/*
if (this.ref != "") {
var node = dojo.byId(this.ref);
if (node) {
this.containerNode.appendChild(node);
}
}
*/
/* TOP fixed header */
// var topLNode = dojo.byId("TOP_L_"+this.id);
// tmw.util.addBackgroundImage(topLNode,"borders/TLt.png",false);
//dojo.style(topLNode,"opacity",0.8);
// var topCNode = dojo.byId("TOP_C_"+this.id);
// tmw.util.addBackgroundImage(topCNode,"borders/borderTC.png",true);
//dojo.style(topCNode,"opacity",0.8);
// var topRNode = dojo.byId("TOP_R_"+this.id);
// tmw.util.addBackgroundImage(topRNode,"borders/TRt.png",false);
//console.debug("created widget "+this.id);
//dojo.style(topRNode,"opacity",0.8);
/* TOP float header components */
var topLTitle = dojo.byId("TOP_LTxtFloat_"+this.id);
if (this.titleL != "")
tmw.util.addBackgroundImage(topLTitle,"borders/"+this.titleL,false);
var topRTitleNode = dojo.byId("TOP_RTxtFloat_"+this.id);
if (this.titleR != "")
tmw.util.addBackgroundImage(topRTitleNode,"borders/"+this.titleR,false);
if (!this.expandoId) this.iconNode.parentNode.removeChild(dojo.byId(this.iconNode));
},
toggle: function(){
if (this.expandoId) dijit.byId(this.expandoId).toggle();
}
});
dojo.provide("tmw.widgets.Player");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("dijit.form.CheckBox");
dojo.require("dojo.parser");
dojo.declare( "tmw.widgets.Player", [ dijit._Widget, dijit._Templated], {
widgetsInTemplate: true,
iid: "",
base: "",
/*
Usage
*/
templatePath: dojo.moduleUrl("tmw","widgets/resources/Player.html"),
constructor: function() {
// call order: #1
//console.debug("constructor"+this.iid);
},
postMixInProperties: function(){
// call order: #2
//console.debug("postMixInProperties"+this.iid);
this.base = this.id.substring(0,2);
this.iid = this.id.substring(8);
},
postCreate: function(args,frag) {
// call order: #3
//console.debug("postCreate"+this.iid);
},
startup: function(){
//console.debug("startup"+this.iid);
}
});
dojo.provide("tmw.widgets.POIPalette");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("dijit._PaletteMixin");
dojo.declare("tmw.widgets.POIPalette",
[dijit._Widget, dijit._Templated, dijit._PaletteMixin],
{
// summary:
// A keyboard accessible poiIcon-picking widget
// description:
// Grid showing various poiIcons, so the user can pick a certain poiIcon
// Can be used standalone, or as a popup.
//
// example:
// |
//
// example:
// | var picker = new dijit.POIPalette({ },srcNode);
// | picker.startup();
// palette: String
// Size of grid
//palette: "4x6",
palette: "5x6",
_palettes: {
"4x6": [[1, 4, 5, 3, 16, 17],
[18, 11, 2, 19, 6, 20],
[9, 8, 23, 22, 10, 21],
[12, 13, 14, 15, 24, 24]],
"5x6": [[1, 51, 4, 50, 52, 17],
[18, 11, 2, 19, 6, 20],
[9, 8, 23, 22, 10, 21],
[12, 13, 14, 15, 24, 5],
[3, 16, 53, 31, 30, 53]]
},
// _imagePaths: [protected] Map
// This is stores the path to the palette images
_imagePaths: {
"4x6": dojo.moduleUrl("tmw.widgets", "resources/images/poi_all_blue.png"),
"5x6": dojo.moduleUrl("tmw.widgets", "resources/images/poi_all_blue5x6.png")
},
// templatePath: String
// Path to the template of this widget.
templatePath: dojo.moduleUrl("tmw","widgets/resources/POIPalette.html"),
// _paletteDims: [protected] Object
// Size of the supported palettes for alignment purposes.
_paletteDims: {
"4x6": {"width": "180px", "height": "120px"},
"5x6": {"width": "180px", "height": "150px"}
},
dyeClass: '_poi',
buildRendering: function(){
// Instantiate the template, which makes a skeleton into which we'll insert a bunch of
//
nodes
this.inherited(arguments);
this.imageNode.setAttribute("src", this._imagePaths[this.palette].toString());
this._preparePalette(
this._palettes[this.palette],
poiNames
);
}
});
dojo.declare("_poi", null,
// summary:
// Object associated with each cell in a ColorPalette palette.
// Implements dijit.Dye.
{
constructor: function(/*String*/alias){
this._alias = alias;
},
getValue: function(){
// summary:
// Note that although dijit._Color is initialized with a value like "white" getValue() always
// returns a hex value
//return this.toHex();
return this._alias;
},
fillCell: function(/*DOMNode*/ cell, /*String*/ blankGif){
dojo.create("img", {
src: blankGif,
"class": "dijitPaletteImg",
alt: this._alias
}, cell);
}
}
);
dojo.provide("tmw.widgets.ControlPanel");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("dojo.parser");
dojo.require("dojo.dnd.Moveable");
dojo.require("dijit.form.CheckBox");
dojo.declare("tmw.widgets.ControlPanel", [ dijit._Widget, dijit._Templated ], {
widgetsInTemplate: true,
height: 40,
retryCnt: 20,
retry: 0,
repostionPanel: true,
rootId: "",
speedId: "",
speedGfxId: "",
nodes: ["playNode","stopNode","slowNode","fastNode","minusNode","plusNode","userinfo"],
E0KRG: {"p1": {w:630,h:67,UEmE2:"bgcontrolsp1.png"}, "p2": {w:488,h:67,UEmE2:"bgcontrolsp2.png"}},
templatePath: dojo.moduleUrl("tmw","widgets/resources/ControlPanel.html"),
postCreate: function() {
tmw.util.addBackgroundImage(this.containerNode,this.E0KRG[this.rootId].UEmE2);
dojo.style(this.containerNode,"width",this.E0KRG[this.rootId].w+"px");
dojo.style(this.containerNode,"height",this.E0KRG[this.rootId].h+"px");
if (this.rootId=="p1"){
this.gfx.id=this.rootId+"gfxp0";
this.hrNode.id=this.rootId+"hr0";
this.speedNode.id=this.rootId+"s0";
} else{
this.containerNode.removeChild(this.gfx);
this.containerNode.removeChild(this.hrNode);
this.containerNode.removeChild(this.bpmUnit);
this.containerNode.removeChild(this.speedUnit);
this.containerNode.removeChild(this.speedNode);
}
SYgJS1=new dojo.dnd.move.parentConstrainedMoveable(this.containerNode, {area: "content", within: true});
this.IRLV=dojo.connect(SYgJS1, "onFirstMove", this, this.tXT);
setTimeout(dojo.hitch(this,function(){dojo.style(this.containerNode,"display","block");}), 2000);
setTimeout(dojo.hitch(this,this.I8S), 2000);
var domain=this;
dojo.forEach(this.nodes, function(xS54){
var node=domain[xS54];
dojo.connect(node, "onmouseover", function(){
dojo.style(node.childNodes[0],"visibility","visible");
});
dojo.connect(node, "onmouseout", function(){
dojo.style(node.childNodes[0],"visibility","hidden");
});
dojo.connect(node, "onmousedown", function(){
var fire=domain.rootId.s.action;
switch (xS54) {
case "playNode":
fire.play();
break;
case "stopNode":
fire.stop();
break;
case "slowNode":
fire.YLJ(-1);
break;
case "fastNode":
fire.YLJ(1);
break;
case "minusNode":
fire.mKs3();
break;
case "plusNode":
fire.qI4VRVN();
break;
};
});
});
},
I8S: function(TA7YVK){
if (!TA7YVK && !this.repostionPanel) return;
var Fm3QQ=dojo.contentBox(this.containerNode);
var rXdYA=dojo.contentBox(this.containerNode.parentNode);
if (rXdYA.w*rXdYA.h == 0) {
this.retry++;
if (this.retry == this.retryCnt) {
console.error("oops..could not set cb.");
return {w:0, h:0, t:40,l:20};
}
setTimeout(dojo.hitch(this,this.I8S), 200);
return;
}
var t,l;
if (rXdYA.w*rXdYA.h == 0) {
t=rXdYA.t;
l=rXdYA.l;
} else {
t=rXdYA.h-Fm3QQ.h;
l=(rXdYA.w-Fm3QQ.w)/2;
}
dojo.style(this.containerNode,"top",t + "px");
dojo.style(this.containerNode,"left",l + "px");
},
tXT: function(){
this.repostionPanel=false;
dojo.disconnect(this.IRLV);
},
DKTV29: function(fVU){
dojo.style(this.speedid,"backgroundPosition","0px "+(1-(24-fVU)*13)+"px");
}
});
dojo.provide("tmw.widgets.Standing");
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");
dojo.require("dojo.parser");
dojo.declare("tmw.widgets.Standing", [ dijit._Widget, dijit._Templated ], {
TGXIkx: [],
gtJCwz: 8,
isOpen: true,
cj8Yx: [ ["","Nick","Total Time","Avg speed (Km/h)","Max speed"],
["","Nick","Sector Time","Avg speed (Km/h)","Total Time"]
],
BFuLNB: ["0.5em","4.5em","6em","5.5em","6em"],
templatePath: dojo.moduleUrl("tmw","widgets/resources/Standing.html"),
postCreate: function() {
tmw.util.addBackgroundImage(this.header0Node,"borders/standing0.png");
tmw.util.addBackgroundImage(this.header1Node,"borders/standing1.png");
tmw.util.addBackgroundImage(this.bodyNode,"bgb60.png",true);
this.rXdYA=dojo.contentBox(this.bodyNode);
this.tlXT(this.BFuLNB);
this.chXn7();
},
fill: function(xtE5d,list) {
this.TGXIkx=list;
this.g2eML();
this.chXn7();
if (xtE5d==0) dojo.style(this.header1Node,"visibility","hidden");
else {
dojo.style(this.header1Node,"visibility","visible");
this.rankNode.innerHTML=xtE5d;
}
var domain=this;
var mKeEQ=list[0].type;
dojo.forEach(domain.cj8Yx[mKeEQ], function(t,E7Zd){
domain["titleNode"+E7Zd].firstChild.nodeValue=t;
});
dojo.forEach(list, function(KnsE,r) {
var node=domain["rowNode"+r];
dojo.query("div",node).forEach(function(xS54,E7Zd){
switch(E7Zd) {
case 0:
dojo.toggleClass(xS54,"ts_color"+KnsE.GR6LFh);
break;
case 1:
xS54.firstChild.nodeValue=KnsE.CgxUP6;
break;
case 2:
var t,QFJGpq,AW2I;
if (KnsE.type==0) {
t=KnsE.t-(r?list[0].t:0);
AW2I=tmw.util.formatTimeSimple(Math.abs(t));
} else {
QFJGpq=KnsE.QFJGpq-(r?list[0].QFJGpq:0);
AW2I=tmw.util.formatTimeSimple(Math.abs(QFJGpq));
}
if (AW2I=="") AW2I='0"';
xS54.firstChild.nodeValue=(r?"+":"")+AW2I;
break;
case 3:
xS54.firstChild.nodeValue=(+KnsE.s).toFixed(1);
break;
case 4:
if (KnsE.type==0) xS54.firstChild.nodeValue=(+KnsE.aVrDp).toFixed(1);
else {
var AW2I,StRoo,t,IONZHs3;
t=KnsE.t-(r?list[0].t:0);
var IONZHs3=Math.abs(t);
AW2I=tmw.util.formatTimeSimple(IONZHs3);
if (r>0) {
if (t>0) AW2I="+"+AW2I;
else AW2I="-"+AW2I;
}
xS54.firstChild.nodeValue=AW2I;
}
break;
};
});
});
},
g2eML: function(){
for (var E7Zd=0;E7Zd0));
this.g2eML();
},
o9A8MG: function(ikHN){
this.a6X74p=ikHN;
},
wXhB: function(){
this.skip=true;
},
ISj: function(){
this.skip=false;
},
cVf: function(GR6LFh,CgxUP6,xtE5d){
if (this.pj2oQ || this.skip) return;
var p;
for (p=0;p' +
'' +
'' +
'' +
'' +
'
' +
'';
var QRV5R = '';
var uo1Ub = "";
for(var E7Zd = 0; E7Zd < this.GUjbR*2; E7Zd++){
if (E7Zd%2==0)
uo1Ub += dojo.string.substitute(QRV5R, {value:E7Zd+1, cls:"tmwRatingStarL"});
else
uo1Ub += dojo.string.substitute(QRV5R, {value:E7Zd+1, cls:"tmwRatingStarR"});
}
this.templateString = dojo.string.substitute(LNMU8, {stars:uo1Ub});
},
postCreate: function(){
this.inherited(arguments);
this.inV5(this.value);
this.uvV9Q(null,false,0,0);
dojo.connect(this.ratevalueNode, "onClick", this, this.RPP);
dojo.connect(this.cancelNode, "onClick", dojo.hitch(this, function(){ this.dialogNode.hide(); }));
},
_onMouse: function(evt){
this.inherited(arguments);
if(this._hovering){
var NU98XQ = +dojo.attr(evt.target, "value");
this.onMouseOver(evt, NU98XQ);
this.inV5(NU98XQ, true);
}else{
this.inV5(this.gBJK2R);
}
},
inV5: function(value, mNJY){
dojo.query(".tmwRatingStarL", this.domNode).forEach(function(U2iET5, E7Zd){
if(E7Zd*2 + 1 > value){
dojo.removeClass(U2iET5, "tmwRatingStarLHover");
dojo.removeClass(U2iET5, "tmwRatingStarLChecked");
}else{
dojo.removeClass(U2iET5, "tmwRatingStarL" + (mNJY ? "Checked" : "Hover"));
dojo.addClass(U2iET5, "tmwRatingStarL" + (mNJY ? "Hover" : "Checked"));
}
});
dojo.query(".tmwRatingStarR", this.domNode).forEach(function(U2iET5, E7Zd){
if(1+E7Zd*2 + 1 > value){
dojo.removeClass(U2iET5, "tmwRatingStarRHover");
dojo.removeClass(U2iET5, "tmwRatingStarRChecked");
}else{
dojo.removeClass(U2iET5, "tmwRatingStarR" + (mNJY ? "Checked" : "Hover"));
dojo.addClass(U2iET5, "tmwRatingStarR" + (mNJY ? "Hover" : "Checked"));
}
});
},
onStarClick:function( evt){
var E1n7 = +dojo.attr(evt.target, "value");
this.setAttribute("value", E1n7 == this.value ? 0 : E1n7);
this.inV5(this.value);
this.onChange(this.value);
if (!this.rated) this.luUGH0w();
},
onMouseOver: function( ){
},
setAttribute: function( key, value){
this.inherited("attr", arguments);
if (key=="value"){
this.inV5(this.value);
this.onChange(this.value);
}
},
uvV9Q: function(id, rated, rating_cnt, rating_sum){
if (rated) this.rated=rated;
else this.rated=false;
if (id) this.show();
else this.hide();
this.SHId1=id;
this.rating_cnt=rating_cnt;
this.rating_sum=rating_sum;
this.ratingNode.innerHTML=rating_cnt+" ratings";
if (rating_sum==0 && rating_cnt==0) this.gBJK2R=0;
else this.gBJK2R=Math.round(rating_sum/rating_cnt);
this.inV5(this.gBJK2R);
},
reset: function(){
this.SHId1=null;
this.uvV9Q(null,false,0,0);
},
hide: function(){
dojo.style(this.domNode,"visibility","hidden");
},
show: function(){
dojo.style(this.domNode,"visibility","visible");
},
luUGH0w: function(){
this.dialogNode.show();
this.ratevalueNode.attr("label","Rate "+this.value+" points");
},
RPP: function(){
var DXH0=this;
dojo.xhrPost({
url: "scripts/msg.php" ,
handleAs: "text" ,
timeout: 5000,
load: dojo.hitch(this,function(tWY09I){
var p8lYB=dojo.fromJson(tWY09I);
if (p8lYB.done) {
DXH0.rated=true;
DXH0.rating_cnt++;
DXH0.rating_sum+=DXH0.value;
DXH0.uvV9Q(DXH0.SHId1,DXH0.rated,DXH0.rating_cnt,DXH0.rating_sum);
dojo.publish("/objRated",
[{type:DXH0.type, id:DXH0.SHId1, rated:DXH0.rated, rating_cnt:DXH0.rating_cnt, rating_sum:DXH0.rating_sum}]);
} else console.log(tWY09I);
DXH0.dialogNode.hide();
}),
content:{l:dojo.toJson([{c:15, t:DXH0.type, id: DXH0.SHId1, v:DXH0.value}])}
});
}
});