/*
// Docs:
// - cache_enabled = bool - default false
// - cache_prname = name of propertyes used to store cache data (default: "cache-" + concatenate prlist)
// - cache_data = any - value to store
// ------------------ Config ----------------------------------------
*/
var debug=(user.name=='wikiadmin' ? true : false); // mus be exactly true or false
var cache = $0 ?? $cache ?? "empty";
var labels = {ita:{
msgIsAppendDataDetect:"Sono presenti dati salvati con una versione precedente del modulo: "
},
eng:{MsgNoData:"-"}};
var loc = "ita";
var debugmsg = "<!-- ============ XsysPrCache debug =========== \n\nCache status: "..cache.cache_status.."\nCache prname: "..cache.cache_prname.."\nCache last update"..cache.cache_lastupdate.."\nCache store pid: "..cache.cache_storepageid.."\n\n================================== -->";
web.html(debugmsg);
if (cache == "empty") {
"Error: cache_object is required";
} else if (user.name !='Anonymous' && cache.cache_status == "old") {
/* ------------------------------ javascript ------------------------- */
if (debug) {<div id="FormMessages">;</div>;}
<script type="text/jem">"
/* controllo */
/* ---- variable definition --------- */
var sapi='"..site.api.."';
var debug ="..debug..";
var cache_prname ='"..cache.cache_prname.."';
var cache_storepageid = '"..cache.cache_storepageid.."';
var cache_data = "..json.emit(cache)..";
var errors = 0;
var papistore = sapi + '/pages/'+cache_storepageid;/* ------------------------------------------
// Update page property
//
*/
function FormUpdateProperty(ipapi, m, prname) {
var prop = 'urn:custom.mindtouch.com#' + prname;
Deki.Api.ReadPageProperty(ipapi, prop, function(result) {
var data = m;
if(result.etag) {
MindTouch.Web.Put(ipapi+'/properties/'+encodeURIComponent(encodeURIComponent(prop)), YAHOO.lang.JSON.stringify(data), 'text/plain; charset=utf-8', { ETag: result.etag}, function(xhr) {
if(MindTouch.Web.IsSuccessful(xhr)) {
xhrOut(xhr,'"..labels[loc].msgAjaxOkPropertyUpdate.."');
} else {
xhrOut(xhr,'"..labels[loc].msgAjaxErrorPropertyUpdate.."');
}
});
} else {
MindTouch.Web.Post(ipapi+'/properties', YAHOO.lang.JSON.stringify(data), 'text/plain; charset=utf-8', { Slug: prop }, function(xhr) {
if(MindTouch.Web.IsSuccessful(xhr)) {
xhrOut(xhr,'"..labels[loc].msgAjaxOkPropertyCreate.."');
} else {
xhrOut(xhr,'"..labels[loc].msgAjaxErrorPropertyCreate.."');
}
});
}
}, function(result) {
xhrOut(result.xhr,'"..labels[loc].msgAjaxErrorPropertyRead.."');
});
}
function xhrOut(xhr, msg) {
var tag = 'p';
if (debug) {
msg += ' \\n\ReadyState:'+ xhr.readyState + '\\nStatus: ' + xhr.status + '\\nResponse text: '+ xhr.responseText + '\\nResponseXml: '+ xhr.responseXml + '\\nStatusText: ' + xhr.statusText ;
tag = 'pre';
}
if(MindTouch.Web.IsSuccessful(xhr))
writeMessage('<'+tag+'>'+msg+'</'+tag+'>');
else {
errors++;
writeMessage('<'+tag+'>'+msg+'</'+tag+'>');
}
}
function writeMessage(msg) {
var div = '#FormMessages';
var t = $(div).html();
$(div).html(t+msg);
}
FormUpdateProperty(papistore, cache_data, cache_prname);
"</script>
}
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by