Procházet zdrojové kódy

meshviewer html version now uses cookies to autosave command.

undefined
Benjamin ‘Touky’ Huet Sam Hocevar <sam@hocevar.net> před 11 roky
rodič
revize
0d9cd0d84d
4 změnil soubory, kde provedl 36 přidání a 19 odebrání
  1. +2
    -0
      test/javascript/naclloading.js
  2. +2
    -1
      test/javascript/utils.js
  3. +3
    -0
      test/meshviewer.em.html
  4. +29
    -18
      test/meshviewer.index.html

+ 2
- 0
test/javascript/naclloading.js Zobrazit soubor

@@ -64,6 +64,8 @@ function NaClModuleDidLoad()
//Hide the progress div
AddTextStatus('Module is live, thank you for your patience.');
window.setTimeout('HideProgressStatus(true)', GetMaxStatusTime(0.5) * 1000);

ModuleIsLive();
}

//Module did crash


+ 2
- 1
test/javascript/utils.js Zobrazit soubor

@@ -28,7 +28,6 @@ function LolCookieDate(m_name, m_value, m_expire_date)
//Set a cookie
function StoreLolCookie(cookie)
{
//Get the cookie and removes it if it exists.
GetLolCookie(cookie.m_name, true);

var enc_value = escape(cookie.m_value) + ";";
@@ -58,6 +57,8 @@ function GetLolCookie(name, remove)
//Retrieve value
var val_start = cki_doc.indexOf("=", cki_start) + 1;
var val_end = cki_doc.indexOf(";", cki_start);
if (val_end < 0)
val_end = cki_doc.length;
cookie.m_value = unescape(cki_doc.substring(val_start, val_end));

if (remove)


+ 3
- 0
test/meshviewer.em.html Zobrazit soubor

@@ -139,7 +139,10 @@ canvas.emscripten
if (left)
Module.setStatus('Downloading dependencies ', (this.totalDependencies - left), this.totalDependencies);
else
{
Module.setStatus('All downloads complete.', 1, 1);
parent.ModuleIsLive();
}
},
//IMPORTANT : This is the C -> Javascript wraping, add your functions list here.
wrapup_list: [ {src_obj: null, func_name: 'DoSendMessage', c_func_name: 'C_Send', return_var: 'number', args: ['string'] } ],


+ 29
- 18
test/meshviewer.index.html Zobrazit soubor

@@ -107,13 +107,13 @@ progress::-webkit-progress-value

var g_autosave_timer = 4.0;
var g_autosave_time = 4.0;
var g_code_addin = ['custom setmesh "#CODE#"', '#CODE#'];
var g_code_addin = [' custom setmesh "#CODE#" ', '#CODE#'];
var g_code_base = [];
var CodeDictionnary = [];

g_code_id = 0;
g_code_base = ["//This is a comment\nsc#f8f afcb 1 1 1 0",
"//This is a comment\naddlight 0.0 position (4 -1 -4) color (.0 .2 .5 1)\naddlight 0.0 position (8 2 6) color #ffff\nshowgizmo true\nshowlight true"];
var g_code_id = 0;
g_code_base[0] = "//This is a comment\nsc#f8f afcb 1 1 1 0";
g_code_base[1] = "//This is a comment\naddlight 0.0 position (4 -1 -4) color (.0 .2 .5 1)\naddlight 0.0 position (8 2 6) color #ffff\nshowgizmo true\nshowlight true";
function machinchose() { return 'test machin '; }
function GetTextAreaCodeSrc() { return g_txtarea_code_src; }
@@ -184,11 +184,16 @@ function machinchose() { return 'test machin '; }
//Put here any cookie update
if (DoesLolCookieExist("LolMeshViewerAutosave"))
{
var lol_cookie = GetLolCookie("LolMeshViewerAutosave");
var value_list = lol_cookie.m_value.split(";");
var lol_cookie = GetLolCookie("LolMeshViewerAutosave", false);
var value_list = lol_cookie.m_value.split(";");
for (var i = 0; i < g_code_base.length && i < value_list.length; i++)
{
g_code_base[i] = value_list[i];
var addins = g_code_addin[i].split('#CODE#');
for (var j = 0; j < addins.length; j++)
if (addins[j] && addins[j] != '')
g_code_base[i] = g_code_base[i].replace(addins[j], "");
}
g_txtarea_code_src.value = g_code_base[g_code_id];
}
else if (!g_txtarea_code_src.value)
@@ -249,20 +254,16 @@ function machinchose() { return 'test machin '; }
if (g_autosave_timer < 0.0)
{
g_autosave_timer = g_autosave_time;
StoreLolCookie("LolMeshViewerAutosave", GetTextValue(true), 10);
StoreCodeCookie();
}
}

function GetTextValue(getall)
function StoreCodeCookie()
{
var result = '';
for (var i = (getall)?(0):(g_code_id); i < g_code_base.length; i++)
{
result += g_code_addin[i].replace('#CODE#', g_code_base[i]) + (getall)?(';'):('');
if (getall && i == g_code_id)
break;
}
return result;
for (var i = 0; i < g_code_base.length; i++)
{ result += g_code_addin[i].replace('#CODE#', g_code_base[i]) + ";"; }
StoreLolCookie(new LolCookieDays("LolMeshViewerAutosave", result, 10));
}

function StoreTextAreaValue()
@@ -289,14 +290,24 @@ function machinchose() { return 'test machin '; }
alert('Module sent message: ' + message.data);
}

//When module is live, it calls this.
function ModuleIsLive()
{
for (var i = 0; i < g_code_base.length; i++)
{
SendMessageToModule();
ExchangeSetup();
}
}

//Called by the "Send Mesh Command !" button
function SendMessageToModule()
{
StoreTextAreaValue();
if (g_embed_module)
{
StoreLolCookie("LolMeshViewerAutosave", GetTextValue(true), 10);
g_embed_module.SendMessage(GetTextValue(false));
StoreCodeCookie();
g_embed_module.SendMessage(g_code_addin[g_code_id].replace('#CODE#', g_code_base[g_code_id]));
}
else
alert("Module not loaded !");


Načítá se…
Zrušit
Uložit